// JavaScript Document

function CufonReplace() {
	Cufon.replace('h1', { fontFamily: 'thesans', hover: true } );
	Cufon.replace('h2', { fontFamily: 'thesans', hover: true } );
}

$(document).ready(function(){ 
						   
	$(".knop").mouseenter(function(){						 
	  $(this).css("background-position", "bottom left");
	  $(this).children("a").css("background-position", "bottom right");
    });	
	$(".knop").mouseleave(function(){						 
	  $(this).css("background-position", "top left");
	  $(this).children("a").css("background-position", "top right");
    });	
	
	$("#nieuwsarchief a").mouseenter(function(){						 
	  $(this).parent().children(".datum").css("background-position", "bottom");
    });	
	$("#nieuwsarchief a").mouseleave(function(){						 
	  $(this).parent().children(".datum").css("background-position", "top");
    });	
	
	$(".front-selector-wrapper a").mouseenter(function(){						 
	  $(this).parent().parent().parent(".front-selector-wrapper").css("background-position", "bottom");
    });	
	$(".front-selector-wrapper a").mouseleave(function(){						 
	  $(this).parent().parent().parent(".front-selector-wrapper").css("background-position", "top");
    });	
	$(".front-selector-small a").mouseenter(function(){						 
	  $(this).parent().parent(".front-selector-small").css("background-position", "bottom");
    });	
	$(".front-selector-small a").mouseleave(function(){						 
	  $(this).parent().parent(".front-selector-small").css("background-position", "top");
    });	
	
	$("#filialen a").parent().parent().mouseenter(function(){
	  $("#filialen").css("height", "118px");							 
    });
	$("#filialen a").parent().parent().mouseleave(function(){
	  $("#filialen").css("height", "38px");
    });	
	
	$("#filialen a").parent().mouseenter(function(){						 
	  $(this).css("background-position", "bottom left");
	  $(this).children().children(".filiaal").css("background-position", "bottom right");
	  $(this).children().css("color", "#fff");
	  $(this).children().css("font-style", "italic");
    });
	$("#filialen a").parent().mouseleave(function(){
	  $(this).css("background-position", "top left");
	  $(this).children().children(".filiaal").css("background-position", "top right");
	  $(this).children().css("color", "#5F5E5E");
	  $(this).children().css("font-style", "normal");
    });	

	
	$(".hoofdmenuitem").parent().mouseenter(function(){
	  if ($(this).is(".metsub")) {
	  	$(this).children(".hoofdmenuitem").css("background-image", "url(afbeeldingen/li_l_sub_on.png)");
		$(this).children(".hoofdmenuitem").append('<div class="li-on-sub-r"></div>');
	  } else {
	  	$(this).children(".hoofdmenuitem").css("background-image", "url(afbeeldingen/li_l_on.png)");
		$(this).children(".hoofdmenuitem").append('<div class="li-on-r"></div>');
	  }
	  $(this).children(".hoofdmenuitem").css("padding", "16px 6px 0 17px");
	  $(this).children(".hoofdmenuitem").css("margin", "0 9px 0 0");
	  $(this).children(".submenu").css("display", "block");
    });	
	
	$(".hoofdmenuitem").parent().mouseleave(function(){
	  $(this).children(".hoofdmenuitem").css("background-image", "none");
	  $(this).children(".hoofdmenuitem").css("padding", "16px 15px 0 17px");
	  $(this).children(".hoofdmenuitem").css("margin", "0");
	  if ($(this).is(".metsub")) {
	  	$(this).children().children(".li-on-sub-r").remove();
	  } else {
	  	$(this).children().children(".li-on-r").remove();
	  }
	  $(this).children(".submenu").css("display", "none");
    });	
	
	
	
	$(".knop-groot a, .knop-klein a").mouseenter(function(){
	  $(this).parent().css("background-position", "bottom left");
	  $(this).css("background-position", "bottom right");
    });	
	
	$(".knop-groot a, .knop-klein a").mouseleave(function(){
	  $(this).parent().css("background-position", "top left");
	  $(this).css("background-position", "top right");
    });	
	
	$(".knop-klein a").mouseenter(function(){
	  $(this).parent().parent().parent().css("background-position", "0px -174px");
    });	
	
	$(".knop-klein a").mouseleave(function(){
	  $(this).parent().parent().parent().css("background-position", "top left");
    });	

	$("#tileslide").mouseleave(function() { 
	  clearTimeout(t);
	  t = window.setTimeout( "tileslider()", 6000 );											
	});
	
	var tiles = $(".tile").length;
	var sliderbreedte = tiles * 304;
	$("#tileslide").css("width",sliderbreedte+"px");


	$('#tileslide').hover(function() { 
		$.data(this, 'hover', true); 
	}, function() { 
		$.data(this, 'hover', false); 
	}).data('hover', false); 
	
	
	$(".ref-leesmeer").click( 
			function(){
				$(".testimonials-lang").hide();
				$(".testimonials-kort").show();
				$(".ref-leesmeer").show();
				$(this).parent("div").parent("div").parent("div").children(".testimonials-lang").show();
				$(this).parent("div").parent("div").parent("div").children(".testimonials-kort").hide();;
				$(this).hide();;
				return false;
			}
		);

	$("#knop-verzenden").live("click",function() { 
		$("#frm-contact").submit();
		return false;
    });

	$("#knop-verzenden-testimonial").live("click",function() { 
		$("#frm-testimonial").submit();
		return false;
    });
	
	
	jQuery.validator.messages.required = "";
	$("#frm-contact").validate({   
	    errorPlacement: function(error, element) {},
		errorContainer: $('#error-wrapper')
	});

	$("#frm-testimonial").validate({   
	    errorPlacement: function(error, element) {},
		errorContainer: $('#error-wrapper2')
	});

	var aantaltiles = parseInt($(".tile").length);
	if (aantaltiles>3) {
		t = window.setTimeout( "tileslider()", 6000 );
	}
	
	$("table tr:even").addClass("donker");
	
	$(".nolink").live("click", function() { 
		return false;
	});
	
	
});


function tileslider() {
	if (!$('#tileslide').data('hover')) {
		$('#tileslide').animate({
			left: '-311px'
		}, 1500, function() {	
			var firsttile = $(".tile").first();
			$(this).append(firsttile);
			$(this).css("left","-7px");
		});
	}	
	t = window.setTimeout( "tileslider()", 6000 );	
}


	/* 
	
	geheugensteuntje
	
	$("#id").click(function(){
	  $("#id2").animate({ 
        left: "-67"
      }, 500, "swing" );
	  $("#id").val("");
    });
	
	$("#id").click(function(event){
	  $("#id2").animate({ 
        left: "-657px"
      }, 1000, "swing" );
	  event.preventDefault();
    });
	
	
	$("#id").click(function(){
	  $("#id2").css("display", "none");
    });	
	
	$(".class").live('click',function(){
	  $(this).parent().parent(".colors").children(".selected").css("display", "none");							
	  $(this).children(".selected").css("display", "block");
		  $(".class2").animate({ 
        	top: "30"
      		}, 500, "swing",function(){ $("#alert-mask").css("display", "none");} );
    });
	*/
