Cufon.replace('#headerTitel a, #headerSubtitel, #homeTopRechts li a span, .cyclePagerNav a, .splashText a', { fontFamily: "Helvetica Neue LT Std", hover: true });
Cufon.replace('.cyclePagerText, .productSubnav li a, .categoryBlockContent h2, .productBlockContent h3, .detailNav a, .detailTitel h1, .detailBestelNu a, .detailGalleryPager, .simple_overlay h1, .zoekresultatenTitel, #contactForm2 h1', { fontFamily: "Helvetica Neue LT Std" });

$(document).ready(function() {
	/**  LIGHTBOX  **/
	$('A[rel="lightbox"]').lightBox({
		overlayBgColor: "#000",
		overlayOpacity: 0.6,
		imageLoading: "/public/images/lightbox/loading.gif",
		imageBtnClose: "/public/images/lightbox/close.gif",
		imageBtnPrev: "/public/images/lightbox/prev.gif",
		imageBtnNext: "/public/images/lightbox/next.gif",
		imageBlank: "/public/images/lightbox/blank.gif", 
		containerResizeSpeed: 350,
		txtImage: "",
		txtOf: "of"
	});
	
	/**  CUSTOM CODE LIGHTBOX  **/
	$("#landkeuzeLink").bind("click", function(){
		if($("#landkeuzeSelect").css("display") == "none"){
			$("#landkeuzeSelect").css("display", "block");
		} else {
			$("#landkeuzeSelect").css("display", "none");
		}
	});
	
	$(".landkeuzeOptie").bind("click", function(){
		$("#landkeuzeSelected").html($(this).html());
		$("#landkeuzeSelect").css("display", "none");
	});
	
	/**  CYCLE STUFF  **/
	$('#cycle1').cycle({
		fx: "scrollLeft",
		timeout: 5000,
		speed: 1000,
		prev: ".cyclePrev",
		next: ".cycleNext",
		cleartype: true,
		cleartypeNoBg: true
	});
	
	$('#cycle2, #cycle3').cycle({
		fx: "fade",
		timeout: 5000,
		speed: 1000,
		prev: ".cyclePrev",
		next: ".cycleNext",
		cleartype: true,
		cleartypeNoBg: true
	});
	
	$('.cyclePrev, .cycleNext').bind("click", function(){
		$('#cycleImages, #cycleDescriptions, #cyclePager, #cycle1, #cycle2, #cycle3').cycle('pause');
	});
	
	/**  SCROLLPANE PRODUCTPAGINA  **/
	$('.detailContentBoxContent').jScrollPane({
		scrollbarWidth:10,
		scrollbarMargin:20
	});
	
	/**  OVERLAY PRODUCTPAGINA  **/
	$("a[rel]").overlay();
	
	/**  CLEAREN DEFAULT CONTENT OP CONTACTFORMS  **/
	var origNaam = $('#overlayNaam').val();
	var origEmail = $('#overlayEmail').val();
	var origTelefoon = $('#overlayTelefoon').val();
	var origBericht = $('#overlayBericht').val();
	var origBTW = $('#overlayBTW').val();
	var origUser = $('#loginUser').val();
	var origPass = $('#loginPass').val();
	
	$('#overlayNaam').focus(function(){
		if($(this).val() == origNaam) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origNaam)
		}
	});
	$('#overlayEmail').focus(function(){
		if($(this).val() == origEmail) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origEmail)
		}
	});
	$('#overlayTelefoon').focus(function(){
		if($(this).val() == origTelefoon) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origTelefoon)
		}
	});
	$('#overlayBericht').focus(function(){
		if($(this).val() == origBericht) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origBericht)
		}
	});
	$('#overlayBTW').focus(function(){
		if($(this).val() == origBTW) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origBTW)
		}
	});
	$('#loginUser').focus(function(){
		if($(this).val() == origUser) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origUser)
		}
	});
	$('#loginPass').focus(function(){
		if($(this).val() == origPass) {
			$(this).val('');
		}
	}).blur(function(){
		if($(this).val() == '') {
			$(this).val(origPass)
		}
	});
	
	/**  VALIDATIE VAN CONTACTFORM OP PRODUCTPAGINA **/
	function isValidEmailAddress(emailAddress) {
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return pattern.test(emailAddress);
	}
	
	$("#contactForm, #contactForm2").submit(function(){
		var fout = false;
		var borderTrue = "#c8c7c7 1px solid";
		var borderFalse = "#f00 1px solid";
		if($("#overlayNaam").val() == "" || $("#overlayNaam").val() == "naam *"){
			fout = true;
			$("#overlayNaam").css("border", borderFalse);
		} else {
			$("#overlayNaam").css("border", borderTrue);
		}
		if(!isValidEmailAddress($("#overlayEmail").val())){
			fout = true;
			$("#overlayEmail").css("border", borderFalse);
		} else {
			$("#overlayEmail").css("border", borderTrue);
		}
		if($("#overlayTelefoon").val() == "" || $("#overlayTelefoon").val() == "telefoon *"){
			fout = true;
			$("#overlayTelefoon").css("border", borderFalse);
		} else {
			$("#overlayTelefoon").css("border", borderTrue);
		}
		if(fout){
			$(".errormessage").css("display", "block");
			return false;
		} else {
			return true;
		}
	});
	
	$("#contactForm3").submit(function(){
		var fout = false;
		var borderTrue = "#c8c7c7 1px solid";
		var borderFalse = "#f00 1px solid";
		if($("#overlayNaam").val() == "" || $("#overlayNaam").val() == "naam *"){
			fout = true;
			$("#overlayNaam").css("border", borderFalse);
		} else {
			$("#overlayNaam").css("border", borderTrue);
		}
		if(!isValidEmailAddress($("#overlayEmail").val())){
			fout = true;
			$("#overlayEmail").css("border", borderFalse);
		} else {
			$("#overlayEmail").css("border", borderTrue);
		}
		if($("#overlayTelefoon").val() == "" || $("#overlayTelefoon").val() == "telefoon *"){
			fout = true;
			$("#overlayTelefoon").css("border", borderFalse);
		} else {
			$("#overlayTelefoon").css("border", borderTrue);
		}
		if($("#overlayBTW").val() == "" || $("#overlayBTW").val() == "BTW nummer *"){
			fout = true;
			$("#overlayBTW").css("border", borderFalse);
		} else {
			$("#overlayBTW").css("border", borderTrue);
		}
		if(fout){
			$(".errormessage").css("display", "block");
			return false;
		} else {
			return true;
		}
	});
	
	/**  TOGGLEN ZICHTBAARHEID LOGINFORM  **/
	$("#toggleForm").bind("click", function(){
		$(".memberFormContainer").css("visibility", "visible");
		return false;
	});
	
	/**  TOGGLEN ZICHTBAARHEID DEALER-PROVINCIE  **/
	$("#dealerLand").bind("change", function(){
		if($("#dealerLand").val() == "Belgie"){
			$("#dealerRegio").css("display", "block");
		} else {
			$("#dealerRegio").css("display", "none");
		}
	});
});