$(document).ready(function(){
/************* STYLER **************/
	$('.taal-menu img').mouseover(function(){
		$(this).css('opacity','0.4')
	}).mouseout(function(){
		$(this).css('opacity','1')
	}).click(function(){
		var id_naam = $(this).attr('id')
		location.href = location.href.replace('#','')+'?taal_id='+id_naam.replace('taal-','')+'/'
	})
	$('.aanbieding').mouseover(function(){
		$(this).addClass('aanbieding-hover-style') 
	}).mouseout(function(){
		$(this).removeClass('aanbieding-hover-style')
	})
	$('.lastminutesKnop-nl').mouseover(function(){
		$(this).attr('src','/static/img/knop_lastminutes_over-nl.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_lastminutes-nl.gif')
	}).click(function(){
		location.href = '/nl/349/verhuur/lastminutes/'
	})
	$('.lastminutesKnop-en').mouseover(function(){
		$(this).attr('src','/static/img/knop_lastminutes_over-en.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_lastminutes-en.gif')
	}).click(function(){
		location.href = '/en/349/verhuur/lastminutes/'
	})
	$('.lastminutesKnop-de').mouseover(function(){
		$(this).attr('src','/static/img/knop_lastminutes_over-de.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_lastminutes-de.gif')
	}).click(function(){
		location.href = '/de/349/verhuur/lastminutes/'
	})
	$('.knop_boeken-nl').mouseover(function(){
		$(this).attr('src','/static/img/knop_boeken_over-nl.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_boeken-nl.gif')
	})
	$('.knop_boeken-en').mouseover(function(){
		$(this).attr('src','/static/img/knop_boeken_over-en.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_boeken-en.gif')
	})
	$('.knop_boeken-de').mouseover(function(){
		$(this).attr('src','/static/img/knop_boeken_over-de.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_boeken-de.gif')
	})
	$('.hoverPNG').mouseover(function(){
		$(this).attr('src',$(this).attr('src').replace('.png','_over.png'))
	}).mouseout(function(){
		$(this).attr('src',$(this).attr('src').replace('_over.png','.png'))
	})
	$('.boeken table td img').mouseover(function(){
		$(this).css('opacity','0.7')
	}).mouseout(function(){
		$(this).css('opacity','1')
	})
	$('.knop_bekijk').mouseover(function(){
		$(this).attr('src','/static/img/knop_bekijk_over.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/knop_bekijk.gif')
	})
	$('.movieThumb').mouseover(function(){
		$(this).css('opacity','1')
	}).mouseout(function(){
		$(this).css('opacity','0.7')
	})
	$('.nieuwsArchief').change(function(){
		window.open($(this).val(),'_blank')
	})
	$('.movieThumb').css('opacity','0.7')
	$('.nieuwsbericht:odd, .parkpresentatie:odd, .filmpje:odd, .lastminute:odd, #beschikbaarheidslijst p:odd').css({
		'background-color': '#eef5fc',
		'background-image': 'url(/static/img/bg-odd-nieuws.jpg)',
		'background-position': 'right bottom',
		'background-repeat': 'no-repeat'
	})
	$('#doRemove').click(function(){
		$('#splashscreen-wrapper').remove()
	})
	$('#doRemove').css({
		'float': 'right'
	})
	$('#splashscreen-wrapper').css({
		'text-align': 'center',
		'z-index': '999999',
		'position': 'absolute',
		'overflow': 'hidden',
		'background': 'url(/static/img/poptrans.jpg) center top',
		'width': '100%',
		'height': '100%',
		'left': '0px',
		'top': '0px',
		'bottom': $(window).height(),
		'right': $(window).width()
	})
	var hoogte = $(window).height()
	var breedte = $('#splashscreen a:last img').width()
	hoogte = Math.round(hoogte - $('#splashscreen').height()) / 2 - 20
	$('#splashscreen').css({
		'margin': '0 auto',
		'width': breedte,
		'margin-top': hoogte
	})
/************* ACTIONS **************/
	$('.knopBezoekWebsite').mouseover(function(){
		$(this).attr('src','/static/img/bezoek_website_over_nl.gif')
	}).mouseout(function(){
		$(this).attr('src','/static/img/bezoek_website_nl.gif')
	})
	$("#datepicker").datepicker({
		dateFormat: 'dd/mm/yy',
		monthNames:	['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
		monthNamesShort:	['Jan','Feb','Mrt','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],
		dayNames:	['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'],
		dayNamesMin:	['Zo','Ma','Di','Wo','Do','Vr','Za'],
		prevText: 'Vorige',
		nextText:	'Volgende',
		currentText: 'Vandaag'
		
	});
/************* LASTMINUTES **************/
	$('#parkSelector').change(function(){
		var url = $(this).val()
		if (url.length >= 2) {
			location.href = $(this).val()
		}
    })
/************* CONTACT **************/
	$('#verzendContact').click(function(){
		fout = false
		$('#naam, #email, #adres, #postcode, #woonplaats').removeClass('verplichtVeld verplichtVak')
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailToVal = $("#email").val();
		if ($('#naam').val() == '') {
			$('#naam').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true
		}
		if (emailToVal == '') {
			$('#email').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true
		} else if(!emailReg.test(emailToVal)) {
			$('#email').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true;
		}
		if ($('#adres').val() == '') {
			$('#adres').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true
		}
		if ($('#postcode').val() == '') {
			$('#postcode').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true
		}
		if ($('#woonplaats').val() == '') {
			$('#woonplaats').hide().addClass('verplichtVeld').fadeIn(500)
			fout = true
		}
		if (fout == false) {
			document.forms[0].submit()
		}
		return false
	})
/************* NIEUWS **************/
	$('#nieuwsOverzicht').scrollable({ 
		vertical: true,
		interval: 4000,
		size: 1,
		speed: 750,
		loop: true,
		easing: 'swing',
		onBeforeSeek: function(){
			this.getItems().fadeTo(350, 0.2);
		},
		onSeek: function(){ 
			this.getItems().fadeTo(350, 1);
		}
	})
/************** ROUTER **************/
	$('#kleineKnop').click(function(){
		var bestemming_straatnaam = $('#bestemming_straatnaam').val().replace(' ','+')
		var bestemming_huisnummer = $('#bestemming_huisnummer').val().replace(' ','+')
		var bestemming_postcode = $('#bestemming_postcode').val().replace(' ','+')
		var bestemming_plaatsnaam = $('#bestemming_plaats').val().replace(' ','+')
		var straatnaam = $("#route_straat").val()+" "+$("#route_huisnummer").val().replace(' ','+')
		var plaatsnaam = $("#route_plaats").val().replace(' ','+')
		var postcode = $("#route_postcode").val().replace(' ','+')
		var url = "http://maps.google.nl/maps?f=d&hl=nl&saddr="+straatnaam+",+"+postcode+",+"+plaatsnaam+"&daddr="+bestemming_straatnaam+" "+bestemming_huisnummer+",+"+bestemming_postcode+",+"+bestemming_plaatsnaam+"&sll=52.227431,5.949569&sspn=0.00648,0.014462&layer=&ie=UTF8&z=12&om=1";
		window.open(url,'_blank')
	})
	$('#googleKleineKnop').click(function(){
		var bestemming_straatnaam = $('#bestemming_straatnaam').val().replace(' ','+')
		var bestemming_huisnummer = $('#bestemming_huisnummer').val().replace(' ','+')
		var bestemming_postcode = $('#bestemming_postcode').val().replace(' ','+')
		var bestemming_plaatsnaam = $('#bestemming_plaats').val().replace(' ','+')
		var url = "http://maps.google.nl/maps?f=q&source=s_q&hl=nl&geocode=&q="+bestemming_straatnaam+" "+bestemming_huisnummer+","+bestemming_postcode+",+"+bestemming_plaatsnaam+"&t=h&iwloc=addr"
		window.open(url,'_blank')
	})
})

/************* MAKELAARDIJ ***********/
function makelaardijOpenWindow(k) {
	var id = $("#id_"+k).val();
	var linkPop = $("#link_"+k).val();
	window.open(linkPop)
	$.ajax({
		url: "http://archief.droomparken.nl/save_stats.php",
		type: "POST",
		data: "id="+id,
		success: function(e) {
			/* Pass */
		}
	})
}