$(document).ready( function() {
	$("#datum1display").datepicker({ dateFormat: 'DD dd MM yy', nextText: 'Volgende maand', prevText: 'Vorige maand', dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'], dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'], monthNames: ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'] });
	$("#datum2display").datepicker({ dateFormat: 'DD dd MM yy', nextText: 'Volgende maand', prevText: 'Vorige maand', dayNamesMin: ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'], dayNames: ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'], monthNames: ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december'] });
	
	// Cufon.replace('h1', {hover: true});
	$('.slidecontainer').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        animSpeed:1000, // Slide transition speed
        pauseTime:6000, // How long each slide will show
        directionNav:false, // Next & Prev navigation
        controlNav:false // 1,2,3... navigation
    });
	
	$("#menu li:not(.submenu li)").hover(function(){
		$(this).find("ul.submenu").show();
	},function(){
		$(this).find("ul.submenu").hide();
	});
	
	$("#menu li .submenu").each(function(){
		$(this).find("li:first").css("border","none");
	});
	
	$(".leesmeerlink").click(function(){
		if($(this).parent().find(".leesmeer").is(":visible")){
		
		} else {
			var vestiging = $(this).attr("id");
			var link = "/img/" + vestiging + ".jpg";
			var linktxt =  vestiging ;
			$("#vestigingfoto").fadeOut(600,function(){
				$(this).attr("src",link).fadeIn();
				$(this).attr("alt",linktxt);
			});
			if(vestiging == "haagland1"){
				$("#content").find("iframe").fadeOut("normal",function(){
					$("#content").find("iframe").remove();
					$("#content").append('<iframe style="margin-top: 10px;" width="600" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?hl=nl&amp;ie=UTF8&amp;q=autobedrijf+preuninger+haagland+b.v&amp;fb=1&amp;gl=nl&amp;hq=autobedrijf+preuninger+haagland+b.v&amp;hnear=0x47c5b7605f54c47d:0x5229bbac955e4b85,Rotterdam&amp;cid=0,0,17932381540432525795&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe>');
				});
			}
			else if(vestiging == "kerketuinen1"){
				$("#content").find("iframe").fadeOut("normal",function(){
					$("#content").find("iframe").remove();
					$("#content").append('<iframe style="margin-top: 10px;" width="600" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?f=q&amp;source=s_q&amp;hl=nl&amp;geocode=&amp;q=preuninger+kerketuinen&amp;aq=&amp;sll=52.042619,4.36125&amp;sspn=0.012103,0.033023&amp;ie=UTF8&amp;hq=preuninger+kerketuinen&amp;hnear=&amp;cid=4651654784088032311&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>');
				});
			}
			else if(vestiging == "delft1"){
				$("#content").find("iframe").fadeOut("normal",function(){
					$("#content").find("iframe").remove();
					$("#content").append('<iframe style="margin-top: 10px;" width="600" height="380" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?f=q&amp;source=s_q&amp;hl=nl&amp;geocode=&amp;q=preuninger+delft&amp;aq=&amp;sll=52.042619,4.36125&amp;sspn=0.012103,0.033023&amp;ie=UTF8&amp;hq=preuninger+delft&amp;hnear=&amp;cid=9858552569725221408&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>');
				});
			}
			else if(vestiging == "zoetermeer1"){
				$("#content").find("iframe").fadeOut("normal",function(){
					$("#content").find("iframe").remove();
					$("#content").append('<iframe style="margin-top: 10px;" width="600" height="380"  frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?f=q&amp;source=s_q&amp;hl=nl&amp;geocode=&amp;q=preuninger+zoetermeer&amp;aq=&amp;sll=52.038185,4.506283&amp;sspn=0.048415,0.132093&amp;ie=UTF8&amp;hq=preuninger&amp;hnear=Zoetermeer,+Zuid-Holland&amp;cid=17173877968003167565&amp;z=13&amp;iwloc=A&amp;output=embed"></iframe');
				});
			}
		}
		$(this).parent().find(".leesmeer").slideToggle();
	});

// Contact submit
	$("#contactsubmit").click( function() {
		var values = $("#contactformulier").serialize();
		$.ajax({
			url: '/formprocess.php?submit=true',
			type: 'POST',
			data: values,


			success: function(result) {
				$('#contactform').append('<p id="response">' + result + '</p>');
				$('#response').hide();
				$('#contactformulier').fadeOut('normal', function() {
					$('#response').fadeIn('normal');
				});
			}
		});
		return false;
	});
	
// Placeholder support
	if (Modernizr.input.placeholder)
		return;

	$('input[placeholder]').focus( function() {
		if ($(this).hasClass('placeholder')) {
			if ($(this).val() == $(this).attr('placeholder'))
				$(this).val('');
			$(this).removeClass('placeholder');
		}
	});
	$('input[placeholder]').keypress( function() {
		if ($(this).hasClass('placeholder')) {
			if ($(this).val() == $(this).attr('placeholder'))
				$(this).val('');
			$(this).removeClass('placeholder');
		}
	});
	$('input[placeholder]').blur( function() {
		if ($(this).val() !='')
			return;
		$(this).addClass('placeholder');
		$(this).val($(this).attr('placeholder'));
	});
	$('input[placeholder]').each( function() {
		if ($(this).val() !='' && $(this).val() != $(this).attr('placeholder'))
			return;
		$(this).val($(this).attr('placeholder')).addClass('placeholder');
	});
	$('form').submit( function() {
		$(this).find('placeholder').each( function() {
			$(this).removeClass('placeholder');
			$(this).val('');
		});
	});
});

function goBackContact(){
	$("#response").remove();
	$("#contactformulier").show();
}
