$(document).ready(function() { 
	// Check regels
	for(var i=1; i<5; i++) {
		var dFound = false;
		$("#regel" + i + " div").each(function() { 
			if($(this).hasClass("dubbel")) {
				dFound = true;
			}
		});
		var elements = $("#regel" + i + " div");
		if(dFound == true) {
			$(elements[3]).css("margin-right", "0px");
		} else {
			$(elements[4]).css("margin-right", "0px");
		}
	}
	
	// Overlay
	//$("#overlay_bg").css("display", "none");
	$(".openPopup").click(function() {
		var typeInschrijving = "Vloerhouder";
		$("#pcontacts").show();
		$("#overlay_bg").css("height", $(document).height() + "px");
		if( $(this).hasClass("bezoeker") ) {
			$("#popup_box strong.aanhef").html("Beste bezoeker.");
			typeInschrijving = "Bezoeker";
			$("#pcontacts").hide();
		}
		
		$("#overlay_bg").css("display", "block");
		var offset = ( $(this).offset().top - $("#popup_box").height() ) - 84;
		
		if(!$("#popup_box").hasClass("notop")) { 
			$("#popup_box").css("margin-top", offset + "px");
		} else {
			$("#popup_box").css("margin-top", "25px");
		}
		
		/* AJAX POST */
		$("#submitPopup").unbind('click')
		$("#submitPopup").click(function() { 
			var error = false;
			if($("#bedrijf").val() == "") {
				$("#bedrijf").css("border", "1px solid red");
				error = true;
			}
			if($("#naam").val() == "") {
				$("#naam").css("border", "1px solid red");
				error = true;
			}
			if($("#email").val() == "") {
				$("#email").css("border", "1px solid red");
				error = true;
			}
			
			if(error == false) {
				$.get("/includes/ajax_voorinschrijving.asp", { obj_bedrijf: $("#bedrijf").val(), obj_naam: $("#naam").val(), obj_eml: $("#email").val(), obj_nb: $("#nieuwsbrief").attr("checked"), obj_contact: $("#pcontact").attr("checked"), obj_tel: $("#tel").val(), obj_type: typeInschrijving },
				function(data){
					 $(".popContent").html(data);
				});
			}
			return false;
		});
		
		return false;
	});
	$("#popupClose").click(function() {
		$("#overlay_bg").css("display", "none");
	});
	
	//Blok links
	$("div.hok, .blokkenKolom li div").each(function() { 
		if($(this).attr("lang") != "") {
			$(this).css("cursor", "pointer");
			$(this).bind('click', function() {
				document.location = $(this).attr("lang").replace("_slash_", "/");
			});
		}
	});
	
	/*var oriPad = "";
	$('#mouseSlider img').hover(
	  function () {
		if($(this).attr("lang") != "") {
			oriPad = $(this).attr("src");
	  		$(this).attr("src", "/afbeeldingen/" + $(this).attr("lang") + "/46/46/ori/hover.jpg");
		}
	  }, 
	  function () {
		if($(this).attr("lang") != "") {
			$(this).attr("src", oriPad);
		}
	  }
	);*/

	
	
	$(".jMyCarousel").jMyCarousel({
		visible: '948px',
		auto: true
	});
	
	// Bereken
	var contentHeight = $("div.content").height();
	var newHeight = (Math.ceil(contentHeight / 180)*191)-33;
	$("div.content").css("height",newHeight+"px");
	
	// Custom font
	Cufon.replace($("h1"), {fontWeight: 'bold'});
	Cufon.replace($("h2"), {fontWeight: 'normal'});
	Cufon.replace($("h3"), {fontWeight: 'normal'});
	Cufon.replace($("h5.kop"), {fontWeight: 'bold'});
	Cufon.replace($("h5.kopwit"), {fontWeight: 'bold', color: '#ffffff'});
	
});
