// ** Cufon aanroepen

$(document).ready(function(){
	
	$("#contactform").validate();
	$("#prijsform").validate();
	
	Cufon.now(); // voor IE om de delay te voorkomen
	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.replace('h4');
	Cufon.replace('h5');
	Cufon.replace('#header ul', { hover: true });
	Cufon.replace('ul.automaten li a p', { hover: true });
	Cufon.replace('a.button', { hover: true });
	Cufon.replace('#footer ul li', { hover: true });
	Cufon.replace('ul.automaten li.red a', { hover: true });
	
	function markActiveLink() {

	    //Look through all the links in the sidebar
	   $("ul#navigation li a").filter(function() {

	      //Take the current URL and split it into chunks at each slash
	      var currentURL = window.location.toString().split("/");

	      //return true if the bit after the last slash is the current page name
	      return $(this).attr("href") == currentURL[currentURL.length-1];

	    //when the filter function is done, you're left with the links that match.
	    }).addClass("active");

	   //Afterwards, look back through the links. If none of them were marked,
	   //mark your default one.
	   if($("ul#navigation li a").hasClass("active") == false) {
	      $("ul#navigation li a:nth-child(2) a").addClass("active");
	    }
	 }

	markActiveLink();	
	
});

// ** Focus input field

addLoadEvent(focusField);

function focusField(){
	$('input[type="text"]').focus(function() { $(this).removeClass("idleField").addClass("focusField") });  
	$('input[type="text"]').blur(function() { $(this).removeClass("focusField").addClass("idleField") }); 
	$('textarea').focus(function() { $(this).removeClass("idleField").addClass("focusField") });  
	$('textarea').blur(function() { $(this).removeClass("focusField").addClass("idleField") }); 
}

// Functie om een functie aan te roepen
function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}
