$(document).ready(function() {

	var zIndexNumber = 9999;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});

	$("ul#marquee").marquee();
	$("ul.tabs").tabs("div.panes > div");

	$("h2 + p").css({paddingTop: 0})
	$("h3 + p").css({paddingTop: 0})
	$(".imgLeft + p").css({paddingTop: 0})

	//$("input#searchSuggest").flexbox("search.txt");

	$(".hulp").bt({
		strokeStyle: "#de0073",
		cornerRadius: 0,
		fill: '#f5ffcf',
		spikeLength: 15,
		spikeGirth: 31,		
		cssStyles: {color: "#514c51"},
		overlap: -4,
		offsetParent: "body",
		positions: "right"
	});

	if (!($.browser.msie && $.browser.version.substr(0,2) == '6.')) {MSDropDown.init();}

	$("div.scrollable").scrollable({
		size: 1,
		next: '#next', 
		prev: '#prev',
		onBeforeSeek: function() {
			if(this.getIndex() == 0) {
				$(".filler").addClass("loc1");
			}
			else {
				$(".filler").removeClass("loc1");
			}
		
		}
	});
	
	$("#vraag").inputlimitor({
		limit: 500,
		remText: "Aantal tekens: %n",
		boxId: "tekens",
		boxAttach: false,
		limitText: "",
		remTextHideOnBlur: false
	});
	
	$("#contact").validate({
		rules: {
			klant: "required",
			aanhef: "required",
			voornaam: "required",
			achternaam: "required",
			email: {
				required: true,
				email: true
			},
			vraag: "required",
			doelgroep: "required",
			onderwerp: "required",
			test: "required"
			
		}
	});

	$("#btnVerzenden").click(function() {
		if($("#contact").valid()) {
			$(".cntErrorContact").hide();
			return true;
		}
		else {
			$(".msDropDown").removeClass("error");
			$(".cntErrorContact").show();
			$("select.error").each(function() {
				$(this).next().next().addClass("error");
			});
			
			return false;
		}
		return false;
	});

	$("#modHelpcentrum").validate({
		rules: {
			q: "required",
			tg: "required"
		}
	});
	
	$("#btn_helpcentrum").click(function() {
		if($("#modHelpcentrum").valid()) {
			$(".cntError").hide();
			return true;
		}
		else {
			$(".msDropDown").removeClass("error");
			$("select.error").each(function() {
				$(this).next().next().addClass("error");
			});
			if($("#ikwilgraagfilter").val() == "") {
				$(".cntError").show();
			}
			else {
				$(".cntError").hide();
			}
			return false;
		}
		return false;
	});	
	
	$("body").click(function(e) {
		if($(e.target).attr("class") != "searchHint") {
			$("#searchHint").fadeOut().hide();
		}
	});

	$("body").click(function(e) {
		if($(e.target).attr("class") != "searchHintTop") {
			$("#searchHintTop").fadeOut().hide();
		}
	});
	
	$("#searchHint li a").live("click", function() {
		if ($(this).parent().hasClass("close")) {
			$("#searchHint").fadeOut().hide();
			
		}
		else {
			$("#searchHint").fadeOut().hide();
			$("#searchSuggest").val($(this).text());
		};
		return false;
	});	

	$("#searchHintTop li a").live("click", function() {
		if ($(this).parent().hasClass("close")) {
			$("#searchHintTop").fadeOut().hide();
			
		}
		else {
			$("#searchHintTop").fadeOut().hide();
			$("#zoeken").val($(this).text());
		};
		return false;
	});	
	
	$("#doelgroep_ms_child a").live("click", function() {
		$(".doelgroepSwitch").removeClass("doelgroepSwitchShow");
		var whichTelefoonnummer = $(this).prevAll().length - 1;
		$(".doelgroepSwitch").eq(whichTelefoonnummer).addClass("doelgroepSwitchShow");
		
	})
	
	$(".doorklik").hover(function() {
		$(this).addClass("ie6fix");
	});

	$(".doorklik").mouseout(function() {
		$(this).removeClass("ie6fix");
	});
	
	$(".doelgroepenLeft h4 a").hoverIntent(
		function() {
			$(".doelgroepenRight").find("img").hide();
			$(".doelgroepenRight img").eq($(this).parent().parent().prevAll().length).show();
		},
		function() {
			return false;
		}
	);

});