/* CUFON implementation */
				
		Cufon.replace('h1');
		Cufon.replace('h2');
		Cufon.replace('h3',{fontFamily: "ScalaSansOT"});
		Cufon.replace('h4',{fontFamily: "ScalaSansOT"});
		Cufon.replace('h5')
		Cufon.replace('h6')
		Cufon.replace('blockquote',{hover:true, hoverables:{a:true} })
		Cufon.replace('.payoff',{hover:true, hoverables: {a: true}});

	function nextElementChecker(element){
		$(element).each(function(){
			$(this).prev().addClass('lessMargin');
		});
	}
	
	
	
		
	 //jQuery document ready.
$(document).ready(function(){
				 
		$('.cycleItems').cycle({ 
	    		fx		: 'fade', 
	    		speed	: 600, 
	    		timeout	: 5000,
				pause	: 1,
				pager	: '#carousselNav'
			});
			
		$('#carousselItems').cycle({ 
	    		fx		: 'fade', 
	    		speed	: 600, 
	    		timeout	: 5000,
				pause	: 1,
				pager	: '#carousselNav'
			});
			
		nextElementChecker('p ~ ul');
		
		$('#mainContentContainer').height($('#contentBlocks').height());
		
		
		/*Banners in header. Animations on roll Over + block-click*/
		
		if ($(".headerHighlights ul li").parent().length > 0) {
			$(".headerHighlights ul li").click(function(){
				window.location = $(this).find("a:first").attr("href");
			});
		}
		
		var eggCounter = 0;
		
		$(".headerHighlights ul li a").css("background-position","203px 7px");
		$('.headerHighlights ul li').css("cursor","pointer");
		$('.headerHighlights ul li').hover( function(){
		    
			 $(this).find('span').stop().animate({"height":"116px","marginTop":"1px"}, 500,"easeOutQuad");
			
			 $(this).find('a').stop().animate({queue:false, backgroundPosition: "208px 7px","marginTop":"45px"},{
			 	duration:500,specialEasing:{backgroundPosition:"easeOutBounce"}});
			
		},function(){
			
			$(this).find('span').stop().animate({"height":"52px","marginTop":"65px"}, 500,"easeOutQuad");
			
     		 $(this).find('a').stop().animate({queue:false, backgroundPosition: "203px 7px","marginTop":"65px"},{
			 	duration:200,specialEasing:{backgroundPosition:"easeOutQuad"}});
				eggCounter++;
				if(eggCounter > 50){
					window.location = "http://www.tilburguniversity.edu/students/circumstances/disabled/rsi/";
					
				}
		});
		
		
		/* Main  Navigation animations */
		
		$('#navigation ul li ul li').css("background-color","#F0EEEC");
		$('#navigation ul li ul li a').hover( function(){
		    
			$(this).stop().animate({queue:false,backgroundColor: '#e1ddd8'}, 300);
		},function(){
     		
			$(this).stop().animate({queue:false,backgroundColor: '#F0EEEC'}, 1000);
		});


		/* List animations */
		
		$("li.rowBg a").css("cursor","pointer");
		$("li.rowBg a").css("background-position","15px 10px");
		$('#menuContainer ul li.rowBg a').hover( function(){
		     $(this).stop().animate({queue:false, backgroundPosition: "20px 10px",backgroundColor: '#e1ddd8'},{
			 	duration:400,specialEasing:{backgroundPosition:"easeOutQuad",backgroundColor:"easeOutQuad"}});
		},function(){
			$(this).stop().animate({queue:false, backgroundPosition: "15px 10px",backgroundColor: '#F0EEEC'},{
			 	duration:1500,specialEasing:{backgroundPosition:"easeOutElastic",backgroundColor:"easeOutQuad"}});
		});
		
		/* Link arrow animations */
		
		$(".linkArrow").css('background-position',"155px 0px");
		$('.linkArrow').hover( function(){
		     $(this).addClass("sectionhover");
			 $(this).stop().animate({queue:false, backgroundPosition: "160px 0px"}, 500,"easeOutBounce");
		},function(){
     		$(this).removeClass("sectionhover");
			$(this).stop().animate({queue:false, backgroundPosition: "155px 0px"}, 200,"easeOutQuad");
		});
		
		/* Homepage section block (right) animations */
		
		 if ($(".sectionBlock").parent().length > 0) {
		 	$(".sectionBlock").click(function(){
		 		window.location = $(this).find("a:first").attr("href");
		 	});
		 }
		
		
		$(".sectionBlock a").css('background-position',"185px 14px");
		$('.sectionBlock').hover( function(){
			 $(this).addClass("sectionhover");
		     $(this).find("a").stop().animate({queue:false, backgroundPosition: "195px 14px"}, 500,"easeOutBounce");
			 $(this).find("a").stop().animate({queue:false, color: "#000000"}, 500,"easeOutBounce");
		},function(){
			 $(this).removeClass("sectionhover");
     		 $(this).find("a").stop().animate({queue:false, backgroundPosition: "185px 14px"}, 200,"easeOutQuad");
			 $(this).find("a").stop().animate({queue:false, color: "#958b7c"}, 500,"easeOutBounce");
		});
		
		/* Main  Navigation caroussel animations */
		
		$("#carousselItems .wrap a").css('background-position',"410px 2px");
		$('#carousselItems .wrap a').hover( function(){
		     $(this).stop().animate({queue:false, backgroundPosition: "415px 2px"}, 500,"easeOutBounce");
		},function(){
     		$(this).stop().animate({queue:false, backgroundPosition: "410px 2px"}, 200,"easeOutQuad");
		});
		
			/* - List items BlockClick  + animations*/
		   if($(".newsRow").parent().length > 0) {
		       $(".newsRow").click(function() { 
			   window.location = $(this).find("a:first").attr("href"); 
			   });
		      /* :hover functie op hele block*/
			 	
			 	$(".newsRow").css("cursor","pointer");
				$(".newsRow").hover(
		             function() {  
		               $(this).addClass("sectionhover");
					   $(this).stop().animate({queue:false,backgroundColor: '#e1ddd8'}, 300);
		           },  
		           function() {  
		               $(this).removeClass("sectionhover");
					   $(this).stop().animate({queue:false,backgroundColor: 'transparent'}, 300, function(){$(this).css("background-color","transparent")});
		           }    
		       );
		   }
		   
		   
			   $(".currentNews").hover (  
		            function() {  
		               $(this).addClass("sectionhover");
					   $(this).stop().animate({queue:false,backgroundColor: '#e1ddd8'}, 300);
		               },  
		           function() {  
		               $(this).removeClass("sectionhover");
					   $(this).stop().animate({queue:false,backgroundColor: 'transparent'}, 300, function(){$(this).css("background-color","transparent")});
		           }    
		       );
			   
			  
			  /* Contact block animations */ 
			    if($(".contactBlock").parent().length > 0) {
		       $(".contactBlock").click(function() { 
			   	window.location = $(this).find("p:first").find("a:first").attr("href"); 
			   });
		      /* :hover functie op hele block*/
				$(".contactBlock").css("cursor","pointer");
				$(".contactBlock").hover (
		             function() {  
		                
					   $(this).stop().animate({queue:false,backgroundColor: '#18798d'}, 300);
		               },  
		           function() {  
		                $(this).removeClass("sectionhover");
					   $(this).stop().animate({queue:false,backgroundColor: '#66a924'}, 300);
		           }    
		       );
		   }
		   
		   /*Banner blocks aniomations*/
		   $(".banner .bannerArrow").css('background-position',"180px top");
		   if($(".banner").parent().length > 0) {
		       $(".banner").click(function() { 
			   window.location = $(this).find('.bannerArrow').find("a:first").attr("href"); 
			   });
		      /* :hover functie op hele block*/
			 	$(".bannerArrow").css('background-position',"180px 5px");
			 	$(".banner").css("cursor","pointer");
				$(".banner").hover (
		             function() {  
		                $(this).addClass("sectionhover");
					    $(this).find('.bannerArrow').stop().animate({queue:false, backgroundPosition: "185px 5px"}, 500,"easeOutBounce");
		               },  
		           function() {  
		                $(this).removeClass("sectionhover");
					      $(this).find('.bannerArrow').stop().animate({queue:false, backgroundPosition: "180px 5px"}, 500,"easeOutBounce");
		           }    
		       );
		   }
		   
/* - eperts BlockClick + animations */	
		   if($(".expertCol").length > 0) {
		       $(".expertCol").css("cursor","pointer");
			   $(".expertCol").click(function() {  
			   
			   	window.location = $(this).find("a:first").attr("href"); 
			   });  
		
		      /* :hover functie op hele block*/
		       $(".expertCol").hover (  
		          
				   function() {  
					   $(this).addClass("sectionhover");
		               },  
		           function() {  
		               $(this).removeClass("sectionhover");
		           }  
		       );
		   }
		  
		  
		   	$(".activeBackground").css("border","1px solid #F0EEEC");
			$('.header').css("background-color", "#E9E7E4");
			
			$(".activeBackground").hover (function() {
			 	
				$(this).addClass("addShadow");
		     	
				if($(this).find('.firstItem'))$(this).find('.firstItem').removeClass("addShadow");
				
				$(this).find('.header').stop().animate({queue:false,backgroundColor: '#d9d5cf'},300);
				$(this).find('.headerSub').stop().animate({queue:false,backgroundColor: '#FFF'}, 300);
				
				$(this).stop().animate({queue:false,backgroundColor: '#FFFFFF'}, 300);
				
		     },function() {
			 	
				if($(this).find('.firstItem'))$(this).find('.firstItem').addClass("addShadow");
				$(this).removeClass("addShadow");
			 	
				/*$(this).css("border","1px solid #f0eeec");*/  
		     	
				$(this).find('.header').stop().animate({queue:false,backgroundColor: '#E9E7E4'}, 600);
				$(this).find('.headerSub').stop().animate({queue:false,backgroundColor: '#F0EEEC'}, 300);
				
				$(this).stop().animate({queue:false,backgroundColor: '#F0EEEC'}, 1000);
		     });
		   
		  
			$('.firstItem img').addClass("removeShadow");
		   	$('.firstItem').addClass("addShadow");
					  
			 $(".newsBlock").hover (function() {
			 	$(this).addClass("addShadow");
		     	
				
				if($(this).find('.firstItem'))$(this).find('.firstItem').removeClass("addShadow");
				
				$(this).find('.header').stop().animate({queue:false,backgroundColor: '#d9d5cf'},300);
				$(this).find('.headerSub').stop().animate({queue:false,backgroundColor: '#FFF'}, 300);
				
				$(this).stop().animate({queue:false,backgroundColor: '#FFFFFF'}, 300);
				
		     },function() {
			 	$(this).removeClass("addShadow");
				
				if($(this).find('.firstItem'))$(this).find('.firstItem').addClass("addShadow");
				
			 	/*$(this).css("border","1px solid #f0eeec");*/  
		     	
				$(this).find('.header').stop().animate({queue:false,backgroundColor: '#E9E7E4'}, 600);
				$(this).find('.headerSub').stop().animate({queue:false,backgroundColor: '#F0EEEC'}, 300);
				
				$(this).stop().animate({queue:false,backgroundColor: '#F0EEEC'}, 1000);
		     });
			 
			/* - video overlay blockclick + animations */ 
			$('.videoOverlay').click(function(){
				$('.videoEmbed').show();
				$('.videoOverlay').fadeOut();
			});
			
			$('.videoOverlaySmall').click(function(){
				$('.videoEmbedSmall').show();
				$('.videoOverlaySmall').fadeOut();
			});
		
	//build dropdown menu's on page
jquerycssmenu.buildmenu("mainMenu", arrowimages);
jquerycssmenu.buildmenu("languages", arrowimages);

});


// This Javascript is written by Peter Velichkov (www.creonfx.com)
if (!Array.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
        for (var i = (start || 0); i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
    }
}
 
// Defining addEvent function since Internet Explorer does not support the official way of adding events
 
function addEvent(obj, type, fn) {
    if (obj.addEventListener)
    obj.addEventListener(type, fn, false);
    else if (obj.attachEvent)
    {
        obj["e" + type + fn] = fn;
        obj[type + fn] = function() {
            obj["e" + type + fn](window.event);
        }
        obj.attachEvent("on" + type, obj[type + fn]);
    }
}
 
function inputWatermark() {
    if (inputs.length < 2 || inputs.length % 2 != 0) {
        alert('Wrong usage - please read the source comments!');
    }
    for (i = 0; i < inputs.length; i++) {
        if (i % 2 == 0 && (document.getElementById(inputs[i]) || document.getElementsByName(inputs[i])[0])) {
            var cur = (document.getElementById(inputs[i])) ? (document.getElementById(inputs[i])) : (document.getElementsByName(inputs[i])[0]);
            cur.value = inputs[i + 1];
            addEvent(cur, "focus", onFocusHandler);
            addEvent(cur, "blur", onBlurHandler);
        }
    }
}
 
function onFocusHandler() {
    var inpname = this.id ? this.id: this.name;
    if (this.value == '' || this.value == inputs[inputs.indexOf(inpname) + 1]) {
        this.value = '';
    }
}
 
function onBlurHandler() {
    var inpname = this.id ? this.id: this.name;
    if (this.value == '') {
        this.value = inputs[inputs.indexOf(inpname) + 1];
    }
}


