// JavaScript Document

$(document).ready(function() {
	$('.nav_item').mouseover(function() {
		$(this).css("border-bottom","3px solid #ff0000");
	}).mouseout(function(){
		$(this).css("border-bottom","none");
	});
	
	$('.kijker .pand:last').css("margin-right","0px");
	
	var b_version=navigator.appVersion;
	if(b_version.indexOf("7.0") != -1){
		$("#flexFrame").attr("scrolling","no");
	}
	
	equalizeLeftRight();
	
	$('#video_afbeelding').click(function(){
		$('#video_link').css('display','block');
		$('#video_afbeelding').css('display','none');
	});
	
	$("#getuigenissen > area").mouseover(function(){
		hideKlantenDivs();
		var areaId = $(this).attr('id');
		var divId = areaId.replace("map_","");
		$("#" + divId).css('display','block');
		$("#" + divId + " .foto_klant").css('display','block');
	});
});

function hideKlantenDivs(){
	$("#klanten_divs div").each(function(){
		$(this).css('display','none');
	});	
}

function toonPand(dezeUrl){
	var x = 0
	var pand;
	mySearch = location.search.substr(1).split("&")
	for (x=0;x<mySearch.length;x++) {
	pand = mySearch[x];
	}
	pand = pand.replace('pand=', '');
	document.getElementById('flexFrame').src += "viewEstate.action?reference=" + pand + "&websiteId=1000582";
}

function gotoPand(url,ref){
	document.getElementById('flexFrame').src = url + "viewEstate.action?reference=" + ref + "&websiteId=1000582";
}

function equalizeLeftRight(){
	var dezeUrl = document.location + "";
	if(dezeUrl.indexOf('contact') != -1){
		var left = parseInt($(".contact .content_left").height()) + parseInt($(".contact .content_left").css("margin-bottom").replace("px", "")) + parseInt($(".contact .content_left").css("padding-bottom").replace("px", ""));	
		var right = 0;
		$(".contact .content_right").each(function(){
			right += parseInt($(this).height()) + parseInt($(this).css("margin-bottom").replace("px", "")) + parseInt($(this).css("padding-bottom").replace("px", ""));
		});
		$(".contact .content_right_noBG").each(function(){
			right += parseInt($(this).height()) + parseInt($(this).css("margin-bottom").replace("px", "")) + parseInt($(this).css("padding-bottom").replace("px", ""));
		});
		if (left < right){
			var verschil = right - left - parseInt($(".contact .content_left").css("margin-bottom").replace("px", "")) - parseInt($(".contact .content_left").css("padding-bottom").replace("px", "")) - 2;
			$(".contact .content_left").css('height',left+verschil);
		}
	} else if(dezeUrl.indexOf('diensten') != -1){
		var left = parseInt($(".diensten_cont .content_left").height()) + parseInt($(".diensten_cont .content_left").css("margin-bottom").replace("px", "")) + parseInt($(".diensten_cont .content_left").css("padding-bottom").replace("px", ""));	
		var right = 0;
		$(".diensten_cont .content_right").each(function(){
			right += parseInt($(this).height()) + parseInt($(this).css("margin-bottom").replace("px", "")) + parseInt($(this).css("padding-bottom").replace("px", ""));
		});
		$(".diensten_cont .content_right_noBG").each(function(){
			right += parseInt($(this).height()) + parseInt($(this).css("margin-bottom").replace("px", "")) + parseInt($(this).css("padding-bottom").replace("px", ""));
		});
		if (left < right){
			var verschil = right - left - parseInt($(".diensten_cont .content_left").css("margin-bottom").replace("px", "")) - parseInt($(".diensten_cont .content_left").css("padding-bottom").replace("px", "")) - 2;
			$(".diensten_cont .content_left").css('height',left+verschil);
		}
	}
}


$(window).load(function(){
	
	var screenDepth = 0;

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion = new Number(RegExp.$1) // capture x.x portion and store as a number
	}
	
	if (window.screen && (window.screen.pixelDepth || window.screen.colorDepth)) {
		var browser = navigator.appVersion ;
		if (browser.indexOf("MSIE") == -1){
			screenDepth = screen.pixelDepth;
		} else{
			screenDepth = screen.colorDepth;
		}
	}
	
	if ((screenDepth == "16") || (ffversion < 4) || (browser.indexOf("MSIE 8.0") != -1)) {
		Cufon('h1');
		Cufon('h2');
		Cufon('h3');
		Cufon('.titel_anchor');
	
		Cufon.now();
	}
});


function control(formulier) { 
	var email = formulier.email.value;
	var emailregexp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (formulier.lastname.value=="") { 
		alert("Vul uw naam in a.u.b."); 
		return false; 
	} else if (formulier.firstname.value=="") { 
		alert("Vul uw voornaam in a.u.b."); 
		return false; 
	} else if ((email=="") || (emailregexp.test(email) == false)){ 
		alert("Vul een correct e-mailadres in a.u.b."); 
		return false; 
	} else if (formulier.phone.value.length > 0 && formulier.phone.value.length < 6) { 
		alert("Vul een correct of geen telefoonnummer in a.u.b."); 
		return false; 
	} else { 
		formulier.submit();
	} 
} 


function check(formulier){   
	var email = formulier.email.value;
	var emailregexp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (formulier.lastname.value=="") { 
		alert("Vul uw naam in a.u.b."); 
		return false; 
	} else if (formulier.firstname.value=="") { 
		alert("Vul uw voornaam in a.u.b."); 
		return false; 
	} else if ((email=="") || (emailregexp.test(email) == false)){ 
		alert("Vul een correct e-mailadres in a.u.b."); 
		return false;  
	} else{
		formulier.submit();
	}
}

