var requiredVersion = 5;
var useRedirect = false;

var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var flash10Installed = false;
var flash11Installed = false;

var maxVersion = 11;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;   // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

if(isIE && isWin){ // don't write vbscript tags on anything but ie win
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n');
  document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.11"))) \n');
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

jsVersion = 1.1;
detectFlash = function(){
  if (navigator.plugins) {  // does navigator.plugins exist?
    if (navigator.plugins["Shockwave Flash 2.0"]
  || navigator.plugins["Shockwave Flash"]){

    var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
    var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
    var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));

    flash2Installed = flashVersion == 2;
    flash3Installed = flashVersion == 3;
    flash4Installed = flashVersion == 4;
    flash5Installed = flashVersion == 5;
    flash6Installed = flashVersion == 6;
    flash7Installed = flashVersion == 7;
    flash8Installed = flashVersion == 8;
    flash9Installed = flashVersion == 9;
    flash10Installed = flashVersion == 0;
    flash11Installed = flashVersion == 1;
    }
  }

  for (var i = 2; i <= maxVersion; i++) {
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }

  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;

  if (actualVersion >= requiredVersion) {
    hasRightVersion = true;
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace(flashPage);
      } else {
        window.location = flashPage;
      }
    }
  } else {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}

writeFlash = function(s,w,h,a,l) {

  var loop = l;
  if (loop == '') {
  	loop = 'false';
  }

  var alternateContent = a;
  if (alternateContent == '') {
    alternateContent = 'Voor deze site heeft u <a target="_blank" href="http://www.microsoft.com/download/">Microsoft Internet Explorer</a> versie 5.5 (of hoger) en de <a target="_blank" href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&P5_Language=English">Macromedia Flash plugin</a> versie ' + requiredVersion + ' (of hoger) nodig.'
  }

  var flashContent = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="'+w+'" HEIGHT="'+h+'" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
  + '<PARAM NAME="MOVIE" VALUE="'+s+'">'
  + '<PARAM NAME="PLAY" VALUE="true">'
  + '<PARAM NAME="LOOP" VALUE="'+loop+'">'
  + '<PARAM NAME="QUALITY" VALUE="high">'
  + '<PARAM NAME="MENU" VALUE="false">'
  + '<PARAM NAME="WMODE" VALUE="transparent">'
  + '<EMBED SRC="'+s+'" WIDTH="'+w+'" HEIGHT="'+h+'" PLAY="true" LOOP="'+loop+'" QUALITY="high" MENU="false" WMODE="transparent" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>'
  + '<NOEMBED>' + alternateContent + '</NOEMBED></OBJECT>';

  if (hasRightVersion) {
    document.write(flashContent);
  } else {
    document.write(alternateContent);
  }
}

function ButtonOver(id){
	var id;
	document.getElementById('button'+id).style.backgroundPosition="right -21px";
	document.getElementById('buttonSpan'+id).style.backgroundPosition="left -21px";
}
function ButtonOut(id){
	var id;
	document.getElementById('button'+id).style.backgroundPosition="right top";
	document.getElementById('buttonSpan'+id).style.backgroundPosition="";
}
function ButtonOverB(id){
	var id;
	document.getElementById('button'+id).style.backgroundPosition="right -20px";
	document.getElementById('buttonSpan'+id).style.backgroundPosition="left -21px";
}
function ButtonOutB(id){
	var id;
	document.getElementById('button'+id).style.backgroundPosition="right +1px";
	document.getElementById('buttonSpan'+id).style.backgroundPosition="";
}

function expand(id,rootId){
	var id;
	document.getElementById(rootId).style.display='none';
	document.getElementById(id).style.display='block';
}

function fold(id,rootId){
	var id;
	document.getElementById(rootId).style.display='block';
	document.getElementById(id).style.display='none';
}

function selecttabA(id){
	var id,now;
	now=parseInt(document.getElementById('ArivalActive').value);
   	document.getElementById('tab'+now).style.display='none';
   	document.getElementById('tab'+id).style.display='block';
 	document.getElementById('ArivalActive').value=id;
  	if(id==1) {
  		document.getElementById('tabS'+now).className="departures ";
  		document.getElementById('tabS'+id).className="arrivals selected arrivals-selected arrivals-hover";
	} else if(id==2) {
		document.getElementById('tabS'+now).className="arrivals ";
      	document.getElementById('tabS'+id).className="departures selected departures-selected ";
	}
}

function switchTab(tabRoot,tabItem) {
	var tabRoot,tabItem,tabList;
	tabList = document.getElementById(tabRoot);
	tabItem = 'li' + tabItem;
	if (tabList != null && tabList != '') {
		for (var i in tabList.childNodes) {
			node = tabList.childNodes[i];
			if (node.nodeName == 'LI') {
				tabContent = 'content' + node.id;
				if (node.className.indexOf('selected') != -1 && node.id != tabItem) {
					node.className = '';
					tabContent = document.getElementById(tabContent);

					if (tabContent != null) {
						tabContent.style.display = "none";
					}
				} else if (node.id == tabItem) {
					node.className = 'selected';
					tabContent = document.getElementById(tabContent);
					if (tabContent != null) {
						tabContent.style.display = "block";
					}
				}
			}
		}
	}
}

function getLastVisited() {
	var cookieName = 'lastvisited';
	var value = getCookieValue(cookieName);
	if (value == null || value == '') {
		return '';
	}

	value = unescape(value);
	return value.split(';');

}

function addLastVisited(url, title) {
	// http://nu.nl|Nu;http://www.feyenoord.nl|Feyenoord
	if (isAlreadyInVisited(title)) {
		return;
	}
	var cookieName = 'lastvisited';
	var value = getCookieValue(cookieName);
	if (value == null) {
		value = '';
	}

	var visitedUrl = url + '|' + title + ';';
	var lastVisitedUrls = value.split(';');
	lastVisitedUrls.push(visitedUrl);
	// Remove the first element of the array when their are more then 6 elements
	if (lastVisitedUrls.length > 6) {
		lastVisitedUrls.shift();
	}
	var lastVisitedCookieValue = lastVisitedUrls.join(';');
	placeCookie(cookieName, lastVisitedCookieValue);
}

function isAlreadyInVisited(title) {
	var cookieName = 'lastvisited';
	var value = getCookieValue(cookieName);
	if (value == null) {
		return false;
	}

	var lastVisitedUrls = value.split(';');
	for (i=0;i<lastVisitedUrls.length;i++) {
		lastVisitedUrl = lastVisitedUrls[i];
		lastVisited = lastVisitedUrl.split('|');
		if (lastVisited != null) {
			urlTitle = lastVisited[1];
			if (title == urlTitle) {
				return true;
			}
		}
	}
	return false;

}

function placeCookie(cookiename, value) {
	var name = cookiename;
	var expire = '3650';
	var expires = new Date();
    expires.setTime(expires.getTime() + (expire*24*60*60*1000));
	document.cookie = name + '=' + escape(value) + ((expire == null) ? '' : ('; expires=' + expires.toGMTString())) + '; path=/';
}

function getCookieValue(cookiename) {
	var cookie = getCookie(cookiename);

	var value = '';
	if (cookie == null || cookie == '') {
		value = ''
	} else {
		value = unescape(cookie);
	}

	return value;
}

function saveTabCookie(tab) {
	placeCookie('savedtabposition', tab);
}

function getSavedTabPosition() {
	var savedTab = getCookieValue('savedtabposition');
	var tabEl, tab;
	if (savedTab != null && savedTab != '') {
		tabEl = savedTab.slice(0,savedTab.indexOf('|'));
		tab = savedTab.slice(savedTab.indexOf('|')+1);
		switchTab(tabEl,tab);
	}
}

// datepicker
$(function(){
	if ($('.date-pick')[0] && $('.date-pick')[0].name != 'df') {
		var dayAfterTomorrow = new Date();
		var endDate = new Date();
		dayAfterTomorrow.setDate(dayAfterTomorrow.getDate() + 2);
		endDate.setDate(endDate.getDate() + 320);
		$('.date-pick').datePicker();
		$('.date-pick').dpSetStartDate(dayAfterTomorrow.asString());
		$('.date-pick').dpSetEndDate(endDate.asString());
		$('.date-pick').dpSetOffset(20, -160);
		$('.date-pick:first').bind(
		'dpClosed',
			function(e, selectedDates)
			{
				var d = selectedDates[0];
				if (d) {
					d = new Date(d);
					$('.date-pick:last').dpSetStartDate(d.addDays(1).asString());
					$('.date-pick:last').dpSetSelected(d.asString());
				}
			}
		);
	} else {
		var startDate = new Date();
		var endDate = new Date();
		startDate.setDate(startDate.getDate() - 356);
		if ($('.date-pick').length != 0) {
			$('.date-pick').datePicker();
			$('.date-pick').dpSetStartDate(startDate.asString());
			$('.date-pick').dpSetEndDate(endDate.asString());
			$('.date-pick').dpSetOffset(20, -160);
		}
	}
});


/* shadowbox conflict sitestat fix */
function openShadowBox(url, type, title, height, width){
	Shadowbox.open({
	    content:    "" + url + "",
	    player:	"" + type + "",
	    title:      "" + title + "",
	    height:     "" + height + "",
	    width:      "" + width + ""
	});
};
/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=jQuery.extend({},c);if(b===null||b===undefined){c.expires=-1}if(typeof c.expires==='number'){var d=c.expires,t=c.expires=new Date();t.setDate(t.getDate()+d)}b=String(b);return(document.cookie=[encodeURIComponent(a),'=',c.raw?b:encodeURIComponent(b),c.expires?'; expires='+c.expires.toUTCString():'',c.path?'; path='+c.path:'',c.domain?'; domain='+c.domain:'',c.secure?'; secure':''].join(''))}c=b||{};var e,decode=c.raw?function(s){return s}:decodeURIComponent;return(e=new RegExp('(?:^|; )'+encodeURIComponent(a)+'=([^;]*)').exec(document.cookie))?decode(e[1]):null};
/**
 * jQuery MD5 Plugin 1.2.1
 * https://github.com/blueimp/jQuery-MD5
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://creativecommons.org/licenses/MIT/
 * 
 * Based on
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */
(function($){'use strict';function safe_add(x,y){var a=(x&0xFFFF)+(y&0xFFFF),msw=(x>>16)+(y>>16)+(a>>16);return(msw<<16)|(a&0xFFFF)}function bit_rol(a,b){return(a<<b)|(a>>>(32-b))}function md5_cmn(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b)}function md5_ff(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t)}function md5_gg(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t)}function md5_hh(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t)}function md5_ii(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t)}function binl_md5(x,e){x[e>>5]|=0x80<<((e)%32);x[(((e+64)>>>9)<<4)+14]=e;var i,olda,oldb,oldc,oldd,a=1732584193,b=-271733879,c=-1732584194,d=271733878;for(i=0;i<x.length;i+=16){olda=a;oldb=b;oldc=c;oldd=d;a=md5_ff(a,b,c,d,x[i],7,-680876936);d=md5_ff(d,a,b,c,x[i+1],12,-389564586);c=md5_ff(c,d,a,b,x[i+2],17,606105819);b=md5_ff(b,c,d,a,x[i+3],22,-1044525330);a=md5_ff(a,b,c,d,x[i+4],7,-176418897);d=md5_ff(d,a,b,c,x[i+5],12,1200080426);c=md5_ff(c,d,a,b,x[i+6],17,-1473231341);b=md5_ff(b,c,d,a,x[i+7],22,-45705983);a=md5_ff(a,b,c,d,x[i+8],7,1770035416);d=md5_ff(d,a,b,c,x[i+9],12,-1958414417);c=md5_ff(c,d,a,b,x[i+10],17,-42063);b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);a=md5_ff(a,b,c,d,x[i+12],7,1804603682);d=md5_ff(d,a,b,c,x[i+13],12,-40341101);c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);b=md5_ff(b,c,d,a,x[i+15],22,1236535329);a=md5_gg(a,b,c,d,x[i+1],5,-165796510);d=md5_gg(d,a,b,c,x[i+6],9,-1069501632);c=md5_gg(c,d,a,b,x[i+11],14,643717713);b=md5_gg(b,c,d,a,x[i],20,-373897302);a=md5_gg(a,b,c,d,x[i+5],5,-701558691);d=md5_gg(d,a,b,c,x[i+10],9,38016083);c=md5_gg(c,d,a,b,x[i+15],14,-660478335);b=md5_gg(b,c,d,a,x[i+4],20,-405537848);a=md5_gg(a,b,c,d,x[i+9],5,568446438);d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);c=md5_gg(c,d,a,b,x[i+3],14,-187363961);b=md5_gg(b,c,d,a,x[i+8],20,1163531501);a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);d=md5_gg(d,a,b,c,x[i+2],9,-51403784);c=md5_gg(c,d,a,b,x[i+7],14,1735328473);b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);a=md5_hh(a,b,c,d,x[i+5],4,-378558);d=md5_hh(d,a,b,c,x[i+8],11,-2022574463);c=md5_hh(c,d,a,b,x[i+11],16,1839030562);b=md5_hh(b,c,d,a,x[i+14],23,-35309556);a=md5_hh(a,b,c,d,x[i+1],4,-1530992060);d=md5_hh(d,a,b,c,x[i+4],11,1272893353);c=md5_hh(c,d,a,b,x[i+7],16,-155497632);b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);a=md5_hh(a,b,c,d,x[i+13],4,681279174);d=md5_hh(d,a,b,c,x[i],11,-358537222);c=md5_hh(c,d,a,b,x[i+3],16,-722521979);b=md5_hh(b,c,d,a,x[i+6],23,76029189);a=md5_hh(a,b,c,d,x[i+9],4,-640364487);d=md5_hh(d,a,b,c,x[i+12],11,-421815835);c=md5_hh(c,d,a,b,x[i+15],16,530742520);b=md5_hh(b,c,d,a,x[i+2],23,-995338651);a=md5_ii(a,b,c,d,x[i],6,-198630844);d=md5_ii(d,a,b,c,x[i+7],10,1126891415);c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);b=md5_ii(b,c,d,a,x[i+5],21,-57434055);a=md5_ii(a,b,c,d,x[i+12],6,1700485571);d=md5_ii(d,a,b,c,x[i+3],10,-1894986606);c=md5_ii(c,d,a,b,x[i+10],15,-1051523);b=md5_ii(b,c,d,a,x[i+1],21,-2054922799);a=md5_ii(a,b,c,d,x[i+8],6,1873313359);d=md5_ii(d,a,b,c,x[i+15],10,-30611744);c=md5_ii(c,d,a,b,x[i+6],15,-1560198380);b=md5_ii(b,c,d,a,x[i+13],21,1309151649);a=md5_ii(a,b,c,d,x[i+4],6,-145523070);d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);c=md5_ii(c,d,a,b,x[i+2],15,718787259);b=md5_ii(b,c,d,a,x[i+9],21,-343485551);a=safe_add(a,olda);b=safe_add(b,oldb);c=safe_add(c,oldc);d=safe_add(d,oldd)}return[a,b,c,d]}function binl2rstr(a){var i,output='';for(i=0;i<a.length*32;i+=8){output+=String.fromCharCode((a[i>>5]>>>(i%32))&0xFF)}return output}function rstr2binl(a){var i,output=[];output[(a.length>>2)-1]=undefined;for(i=0;i<output.length;i+=1){output[i]=0}for(i=0;i<a.length*8;i+=8){output[i>>5]|=(a.charCodeAt(i/8)&0xFF)<<(i%32)}return output}function rstr_md5(s){return binl2rstr(binl_md5(rstr2binl(s),s.length*8))}function rstr_hmac_md5(a,b){var i,bkey=rstr2binl(a),ipad=[],opad=[],hash;ipad[15]=opad[15]=undefined;if(bkey.length>16){bkey=binl_md5(bkey,a.length*8)}for(i=0;i<16;i+=1){ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C}hash=binl_md5(ipad.concat(rstr2binl(b)),512+b.length*8);return binl2rstr(binl_md5(opad.concat(hash),512+128))}function rstr2hex(a){var b='0123456789abcdef',output='',x,i;for(i=0;i<a.length;i+=1){x=a.charCodeAt(i);output+=b.charAt((x>>>4)&0x0F)+b.charAt(x&0x0F)}return output}function str2rstr_utf8(a){return unescape(encodeURIComponent(a))}function raw_md5(s){return rstr_md5(str2rstr_utf8(s))}function hex_md5(s){return rstr2hex(raw_md5(s))}function raw_hmac_md5(k,d){return rstr_hmac_md5(str2rstr_utf8(k),str2rstr_utf8(d))}function hex_hmac_md5(k,d){return rstr2hex(raw_hmac_md5(k,d))}$.md5=function(a,b,c){if(!b){if(!c){return hex_md5(a)}else{return raw_md5(a)}}if(!c){return hex_hmac_md5(b,a)}else{return raw_hmac_md5(b,a)}}}(typeof jQuery==='function'?jQuery:this));
/**
 * jQuery plugin for showing/hiding form content based on formcontrol value
 */
(function($){
    var settings = {
        hideValues : ['XXX', 'Selecteer uw land', 'Nederland'],
        toggleElements : ['.formtoggle'],
        cookieKey : 'wmform',
        type: null
        };

    var methods = {
        hideElements: function(options) {
            $.each(options.toggleElements, function(index, element){
                $(element).find('select,input,textarea').addClass('hidden');
                $(element).find('.formcontrol').find('select,input,textarea').val('');
                $(element).find('cite').remove();
                $(element).hide().removeClass('error');
            });
        },
        showElements: function(options) {
            $.each(options.toggleElements, function(index, element){
                $(element).find('select,input,textarea').removeClass('hidden');
                $(element).show();
            });
        },
        saveState: function(state, UID) {
            var key = settings.cookieKey,
                obj = JSON.parse($.cookie(key)) || {};
            obj[UID] = state;
            $.cookie(key, JSON.stringify(obj), {path: '/'});
        },
        getState: function(UID) {
            var key = settings.cookieKey,
                obj = JSON.parse($.cookie(key)) || {};
            if (typeof obj[UID] == 'undefined') {
                return null;
            }
            return obj[UID];
        },
        select : function(options) {
            options = $.extend({}, settings, options || {});
            var $this = this;
            var UID = 'u' + $.md5(window.location.pathname + 'formtoggle_' + $(this).attr('id'));
            var hideValue = methods.getState(UID) == null ? this.val() : methods.getState(UID);
            if ($.inArray(hideValue, options.hideValues) >= 0) {
                this.addClass('hidden');
                methods.hideElements(options);
            }
            this.change(function(){
                methods.saveState($(this).val(), UID);

                if ($.inArray($(this).val(), options.hideValues) >= 0) {
                    $this.addClass('hidden');
                    methods.hideElements(options);
                } else {
                    $this.removeClass('hidden');
                    methods.showElements(options);
                }
            });
            return this;
        },
        checkbox : function(options) {
            options = $.extend({},settings, {showOnCheck: true}, options || {});
            var UID = 'u' + $.md5(window.location.pathname + 'formtoggle_' + $(this).find('input:checkbox').attr('id'));
            var isChecked = methods.getState(UID) == null ? false : methods.getState(UID);
            if (isChecked != options.showOnCheck) {
                methods.hideElements(options);
            }
            this.click(function(){
                methods.saveState($(this).find('input:checkbox').is(':checked'), UID);
                if (!$(this).find('input:checkbox').is(':checked') == options.showOnCheck) {
                    methods.hideElements(options);
                } else {
                    methods.showElements(options);
                }
            });
            return this;
        },
        radio : function(options) {
            options = $.extend({}, settings, options || {});
            
            var UID = 'u' + $.md5(window.location.pathname + 'formtoggle_' + $(this).find('input:radio').attr('name')),
                hideValue = $.cookie(UID) == null ? this.find('input:radio:checked').val() : $.cookie(UID);
            if ($.inArray(hideValue, options.hideValues) >= 0
                || typeof hideValue == 'undefined') {
                methods.hideElements(options);
            }
            this.click(function(){
                methods.saveState($(this).find('input:radio:checked').val(), UID);
                if ($.inArray($(this).find('input:radio:checked').val(), options.hideValues) >= 0) {
                    methods.hideElements(options);
                } else {
                    methods.showElements(options);
                }
            });
            return this;
        }
    };
    $.fn.formtoggle = function(type) {
    	if (this.length > 0) {
    		type = type || 'select';
	        if (methods[type]) {
	            return methods[type].apply(this, Array.prototype.slice.call(arguments, 1));
	        } else {
	            //$.error('Type ' +  type + ' does not exist on jQuery.formtoggle');
	            return this;
	        }
    	}
    }; 
})(jQuery);
/* jQuery plugin to show extra text in info tip */
(function($){
	$.fn.tooltip = function(options)
	{
        return this.each(function(){
			var settings = $.extend({
				origin : {top: 0, left: 0},
				addClass : null
			}, options || {});
            var self = this;
            // hide original span
			$(this).hide();
            // show question image
			$('<span>?</span>')
				.addClass('tooltip-icon')
                .insertAfter($(this))
                .hover(
                    function(event){
                        // mouse over
                    	$(this).addClass('tooltip-icon-hover');
                        $('<div>')
                            .addClass('tooltip' +
                                (settings.addClass ? (' ') + settings.addClass : ''))
                            .css({
                                position: 'absolute',
                                top: $(this).offset().top - settings.origin.top,
                                left: $(this).offset().left - settings.origin.left,
                                display: 'none'})
                            .appendTo('body')
                            .html($(self).html())
                            .fadeIn('slow');
                    },
                    function() {
                        // mouse out
                    	$(this).removeClass('tooltip-icon-hover');
                        $('.tooltip').fadeOut('slow', function(){ $(this).remove() });
                    });
			$(this).addClass('tooltipped');
        })
	}
})(jQuery);

jQuery(function($){
	$('.formextratext').tooltip({origin: {top: 100, left: -25}});
	if ($('.formpart').length > 0) {
		$('.formpart:has(cite)').parent().addClass('error');
		$('fieldset:has(div.error) .formcontent:has(img) input[type=text]:first').focus();
		$('.formpart cite').each(function() {$(this).text($(this).text().replace(':', ''))});
		$(".error input[type=text][value='']:visible:first", ".sphfullform").focus();
	}
	if ($('.form-error').length > 0) {
		$('.form-error:last').addClass('form-error-last');
	}
});

var CustomSelect = {
  init: function() {var inputs = document.getElementsByTagName("select"), span = Array(), textnode, option, active;for(a = 0; a < inputs.length; a++) {if(inputs[a].className == "styled") {option = inputs[a].getElementsByTagName("option");active = option[0].childNodes[0].nodeValue;textnode = document.createTextNode(active);for(b = 0; b < option.length; b++) {if(option[b].selected == true) {textnode = document.createTextNode(option[b].childNodes[0].nodeValue);}}span[a] = document.createElement("span");span[a].className = "select";span[a].id = "select" + inputs[a].name;span[a].appendChild(textnode);inputs[a].parentNode.insertBefore(span[a], inputs[a]);if(!inputs[a].getAttribute("disabled")) {inputs[a].onchange = CustomSelect.choose;} else {inputs[a].previousSibling.className = inputs[a].previousSibling.className += " disabled";}}}},
  choose: function() {option = this.getElementsByTagName("option");for(d = 0; d < option.length; d++) {if(option[d].selected == true) {document.getElementById("select" + this.name).childNodes[0].nodeValue = option[d].childNodes[0].nodeValue;}}}
}
$(document).ready(function() {CustomSelect.init();});

/* jQuery plugin to show youtube channel */
(function($){
	 
    $.extend({
 
    ytchannelSetup: function(settings) {
        if (!settings) {
            settings = {};
        } else if (settings && typeof(settings) == 'string') {
            settings = {user: settings};
        }
        settings = $.extend(true, $.ytchannel.defaults, settings);
        return settings;
    },
 
    ytchannel: new function() {
        var _s = {}, $this = null;
        this.defaults = {
            user: "Schiphol",
            nrItems: 2,
            videoURL: 'http://www.youtube.com/watch?v=',
            imageLocation: '',
            linkTarget: '_blank'
        }
        this.construct = function(options) {
            return this.each(function(){
                $this = $(this);
                _s = $.ytchannelSetup(options);
                // var playListURL = 'http://gdata.youtube.com/feeds/api/playlists/2E0EC9AF360F28DA?v=2&alt=json&callback=?';
                var channelURL = 'http://gdata.youtube.com/feeds/api/users/' + _s.user + '/uploads?orderby=updated&v2&alt=json&callback=?';
                $.getJSON(channelURL, function(data) {
                    var list_data="<ul>";
                    $.each(data.feed.entry, function(i, item) {
                        if (i < _s.nrItems) {
                            var feedTitle = item.title.$t;
                            var feedURL = item.link[1].href;
                            var fragments = feedURL.split("/");
                            var videoID = fragments[fragments.length - 2];
                            var url = _s.videoURL + videoID;
                            var thumb = "http://img.youtube.com/vi/"+ videoID +"/default.jpg";
                            list_data += '<li>' 
                                      + '<a class="thumb" href="'+ url +'" title="'+ feedTitle +'" target="' + _s.linkTarget + '" style="background-image:url(' + thumb + ');">'
                                      + '<img src="' + _s.imageLocation + 'play-yt.png" alt="" />'
                                      +'</a>'
                                      + '<p><a href="'+ url +'">'+ feedTitle +'</a></p>'
                                      + '</li>';
                        }
                    });
                    list_data += '</ul>';
                    $(list_data).appendTo("#ytchannel");
                });
            });
        };
    } // ytchannel
}); // extend
 
// extend plugin scope
$.fn.extend({
    ytchannel: $.ytchannel.construct
});
 
})(jQuery);
