// JavaScript Document

function goRoundedCorners () {
		$('img.rounded_corners').wrap('<div class="rounded_corner_wrapper"></div>');
		$('.rounded_corner_wrapper').append('<div class="corner_top_left corner_top_left_white"></div><div class="corner_top_right corner_top_right_white"></div><div class="corner_bottom_left corner_bottom_left_white"></div><div class="corner_bottom_right corner_bottom_right_white"></div>');
};


function goSearchbox () {
	
	var origVal = $('#searchinput input').val();
	$('#searchinput input').focus(function(){
		if($(this).val() == origVal) {
		$(this).val('');
		}
		}).blur(function(){
		if($(this).val() == '') {
		$(this).val(origVal)
		}
	});
};

function goAccordion () {
	
	$(".accordionbox").accordion({
						header:'.accordion_title',
						collapsible:false,
						active:false,
						autoheight:true,
						event:'mouseover'
	});  
};

function goLittleAccordion (activeItem) {
			
	$(".accordioncontainer").accordion({
						header:'.accordion_title',
						collapsible:false,
						active:activeItem,
						autoheight:true
	});  
};

function goCufon () {					
	Cufon.replace('#topnav a:not(#topnav ul a)',{hover:true})('#pager a',{hover:true})('h1,h2,h3,h4,h5,.slidetext .title,.welcometitle,#providertitle,#extraboxcontent .title');
				
};

function renderMenu () {
		
		$("#topnav li.hassub").hover(
			function() {
				// ie 6 users need hovers too, and a new browser ...
				$(this).addClass('sfHover');
				// speed up the cufon menu especially on ie
				Cufon.replace('#topnav .hassub a:not(#topnav .hassub li a)',{hover:true});
			},
			function() {
				$(this).removeClass('sfHover');
			}
		);
		
		$("#topnav li.hassub").mouseout(function() {
			setTimeout(function(){
				// change color back to passive menu-color (cufon-css error)
				Cufon.replace('#topnav .hassub a:not(#topnav .hassub li a)',{hover:true});
			},'0');
		}); 
		
	
};

function goBanner () {
						
		$('#slidecontainer').cycle({
								fx:'scrollVert',
								speed:1000, 
								timeout:5000,
								pause:1,
								pauseOnPagerHover: 1,
								pager:'#pager',
								pagerAnchorBuilder: function(idx, slide) {
									var pagertitle = $('.pagertext span.title',slide).text();
									var pagersubtitle = $('.pagertext span.subtitle',slide).text();
									return '<a id="pager'+idx+'" href="#"><span class="title">'+pagertitle+'</span><span class="subtitle">'+pagersubtitle+'</span></a>';
								}
		});
		
};


function goScrollBox () {
		$('.scrollbox').jScrollPane({scrollbarWidth:20, scrollbarMargin:5, showArrows:true});		
};

function goJobScrollBox () {
		$('iframe').jScrollPane({scrollbarWidth:20, scrollbarMargin:5, showArrows:true});		
};

function goLogoKwicks () {
		$('.kwicks').kwicks({  
    					max : 180,
						spacing : 7,
						duration: 170
						
     	});
};

function goPrintButton() {
		$('.print_link').click(function() {
            	$('#header,.main_title, .main_content,#footer,').jqprint();
	        	return false;
         });
};

function goFancyBox () {
		$(".viewlink,a[rel='lightbox']").fancybox({
		}); 

};

function goFancyTellaFriend () {
		$(".iframe").fancybox({
			'callbackOnShow': goCufon,
			'hideOnContentClick': false,
			'frameWidth' : 450,
			'frameHeight' : 420,
			'padding' : 20
		}); 

};

function initLanguageSwitch () {

		$(".dutchlinks a, #nl, #nl_footer").bind("click", 
				function() {
				$.cookie('language', 'nl', {path:'/',expires:25550});
				}
		);
		
		$(".frenchlinks a, #fr, #fr_footer").bind("click", 
				function() {
				$.cookie('language', 'fr', {path:'/',expires:25550});
				}
		);
		
		$(".englishlinks a, #en, #en_footer").bind("click", 
				function() {
				$.cookie('language', 'en', {path:'/',expires:25550});
				}
		);
};

function languageSwitch () {
		
		if($.cookie('language')) {
			var $activeLanguage = $.cookie('language');
			
			switch ($activeLanguage) {
				case "nl":
				url = "/nl/c/home";
				break;
				case "fr":
				url = "/fr/c/home";
				break;
				case "en":
				url = "/en/c/home";
				break;
			}
			
			window.location = url;
		
		}
};		

function fontSizeSwitch () {
			
		var $cookie_name = "textsize";
		var $originalFontSize = $("html").css("font-size");
 		 
		if($.cookie($cookie_name)) {
			
			var $getSize = $.cookie($cookie_name);
					
			switch ($getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")) {
			
				case "14px" :
				$("#small").addClass("active");
				break;
				case "16px" :
				$("#medium").addClass("active");
				break;
				case "18px" :
				$("#big").addClass("active");
				break;
			}
		
			$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")});
			} else {
			$("#medium").addClass("active");
			$.cookie($cookie_name, $originalFontSize, {path:'/'});
		}
 		
		$("#small").bind("click", function() {
			 var $newFontSize = "14px";
			 if ($newFontSize) {
				$("html").css("font-size", $newFontSize);
				$.cookie($cookie_name, $newFontSize, {path:'/'});
				$("#small").addClass("active");
				$("#big").removeClass("active");	
				$("#medium").removeClass("active");
					
				Cufon.replace('.mainbox h2,.mainbox h3,.mainbox h4');
					
			}
				
			return false;
		});
			
		$("#medium").bind("click", function() {
			var $newFontSize = "16px";
			if ($newFontSize) {
				$("html").css("font-size", $newFontSize);
				$.cookie($cookie_name, $newFontSize, {path:'/'});
				$("#big").removeClass("active");	
				$("#medium").addClass("active");
				$("#small").removeClass("active");
				
				Cufon.replace('.mainbox h2,.mainbox h3,.mainbox h4');
			}
		
			return false;
			
		});
		

		$("#big").bind("click", function() {
			var $newFontSize = "18px";
			if ($newFontSize) {
				$("html").css("font-size", $newFontSize);
				$.cookie($cookie_name, $newFontSize, {path:'/'});
				$("#big").addClass("active");	
				$("#medium").removeClass("active");
				$("#small").removeClass("active");
				
				Cufon.replace('.mainbox h2,.mainbox h3,.mainbox h4');
			}
		
			return false;
		});
						
};