// JavaScript Document
$(function(){
	// Dropdown menu's:
	// Eerste alle dropdowns verbergen:
	$("#navigation ul ul").hide();
	$("#navigation ul li").hover(function(){
		$("ul", this).fadeIn(200);
		// $("ul", this).show();
	}, function(){
		$("ul", this).fadeOut(200);
		// $("ul", this).hide();
	});
	
	// Zebra tabellen:
	$("table.zebra tr:nth-child(even)").addClass("even");
	$("table.zebra tr:nth-child(odd)").addClass("odd");
	
	// Bij thumbnails de laatste margin weghalen:
	$(".thumbnails li:nth-child(4n)").css("margin-right", "0");
	
	// jQuery LightBox:
	$(".thumbnails li a").lightBox();
	
	// Zebra list:
	$(".medewerkersOverzicht li:nth-child(even)").addClass("light");
	$(".medewerkersOverzicht li:nth-child(odd)").addClass("dark");
	
	// Bij Cases ervoor zorgen dat het nummer optelt:
	$("div.cases table").each(function(){
		var currentItem = 1;
		$("th a", this).each(function(){
			$(this).html("Project " + currentItem + " &rsaquo;");
			currentItem++;
		});
	});
	
	// Contactformulier:
	$(".contactForm").hide();
	var contactFormVisible = false;
	$("h3.contactFormButton").click(function(){
		if(contactFormVisible) {
			contactFormVisible = false;	
			$(".contactForm").slideUp();
			$(this).css("background-position", "0px 0px");
		} else {
			contactFormVisible = true;
			$(".contactForm").slideDown();
			$(this).css("background-position", "0px -24px");
		}
	});
	
	// Formulier checker:
	$("form").each(function(){
		$(this).submit(function(){
			// Kijken of alle velden met class 'required' ingevuld zijn.
			var ok = true;
			$(".required", this).each(function(){
				if($(this).val()=='') {
					ok = false;	
					$(this).addClass("error");
				} else {
					$(this).removeClass("error");	
				}
			});
			if(ok) {
				return true;
			} else {
				alert("Niet alle verplichte velden zijn ingevuld!");
				return false;
			}
		});						
	});
	
	// Crumbpath-bold uitzetten in safari:
	if($.browser.safari) {
		$("span.B_crumbBox").css("font-weight", "normal");
	}
	
	// Diensten overzicht volledig clickable maken
	$("#dienstenOverzicht ul li").hover(function(){
		$(this).css("background", "#f8f8f8");
	}, function(){
		$(this).css("background", "transparent");
	}).click(function(){
		window.location = $("a", this).attr("href");
	}).css({cursor: "pointer"});
	
	// Kopieerbeveiliging voor images:
	$("img").rightClick(function(){
		// alert('(c) 2009 Van Hoof & Van Hoof');
		return false;
	});
});

function nextSlide(informationString) {
	/*
	var info = informationString.split('|');
	$("#referentieDetail div.placeHolder").fadeOut(500, function() { 
		$("h3", this).text(info[0]);
		$("p", this).text(info[1]);
		$("a", this).attr("href", info[2]);
		$(this).fadeIn(500);
	});
	*/
}