$.fn.polaroid = function() {
	return this.each( function() {
		var $this = $(this);
		x = ($this.attr('align') == 'right') ? '-r' : '-l';	
		
		if($this.hasClass('polaroid-wrapped')) {
			
		} else {
			$holder = $this.wrap('<div class="polaroid-place polaroid'+x+'"><div class="polaroid-flow">').addClass('polaroid-wrapped');
			$this.parent('div').before('<img src="/img/polaroid-empty'+x+'.png" class="polaroid-overlay" />');					  
			$this.attr('align', '').fadeIn(4000);
		}
	});
}


$(function() {
	$('.polaroid').polaroid();
	$('.datepicker').datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: '1920:2030'
	});
	$('input[type="submit"], .button').button();
	$("#sociables a").click(function(){ this.href=this.href.replace(/\[URL\]/g,encodeURIComponent(window.location.href)).replace(/\[POST\]/g,$('.pageTitle').text()); this.target="_blank"; });
	$('#doShowRoute').click(function(){
		a = $('#routeForm input[name="route-from-1"]').val(); b = $('#routeForm input[name="route-from-2"]').val(); c = a + ', ' + b; r = encodeURIComponent(c);
/*		this.href='http://maps.google.nl/maps?f=d&source=s_d&saddr='+r+'&daddr=Lichtschip&geocode=FXPGGQMdaHVNAClhkJ99XmTGRzGwTiRxa5v0lQ%3BFa_FGQMdWbJOAA&hl=nl&mra=dme&mrcr=0&mrsp=1&sz=17&sll=52.019167,5.155731&sspn=0.005381,0.008605&ie=UTF8&ll=52.019807,5.157394&spn=0.010762,0.017209&t=h&z=16';*/
		this.href='http://maps.google.nl/maps?daddr=52.020732,%205.157566&saddr='+r;

		this.target='_blank';
	});
	
	
	$('.togglerSitemap').click(function() { // start hidden
		what = ($('.toggleSitemap:visible').length == '1') ? 'tonen' : 'verbergen';
		$('.toggleSitemap').slideToggle();
		$('.togglerSitemap').attr('href', '#toggleSitemap-'+what).find('span').html(what);
	}).click();
	
	$("a[rel='fancy-webcam-iframe']").fancybox({
	//	'transitionIn'	:	'elastic',
	//	'transitionOut'	:	'elastic',
		'width'			:	361,
		'height'		:	380,					
		'overlayShow'	:	true,
		'type'			: 	'iframe',
		'scrolling'		: 	'no',
		'onStart'		: 	function () {
			$('#fancybox-inner').addClass('iframe-webcam');
		}
	});
	$("a[rel='fancy-weather-iframe']").fancybox({
	//	'transitionIn'	:	'elastic',
	//	'transitionOut'	:	'elastic',
		'width'			:	545,
		'height'		:	520,					
		'overlayShow'	:	true,
		'type'			: 	'iframe',
		'scrolling'		: 	'no',
		'onStart'		: 	function () {
			$('#fancybox-inner').addClass('iframe-weather');
		}
	});

	$("a[rel='fancy-slope-area']").fancybox({
		'overlayShow'	:	true
	});


	$('#clientLogon input').click(function() {
		$(this).val('');
	});
	
	$("#sitemap ul#main > li:gt(6)").hide();
	$("#sitemap ul#main > li:eq(6)").addClass('lastChild');
	//	$("#sitemap ul > li:eq(5)").css('clear', 'left');
	
	var bannersBottomHeight = $('#banners-bottom').height();
	var $bannersBottom 		= $('#banners-bottom');
	
/*	$bannersBottom.hover( function() {
		$(this).animate({ height: '123' });										 
	}, function() {
		setTimeout(function() {
			$bannersBottom.animate({ height: bannersBottomHeight });
		}, 1000);
	});
*/	

	setTimeout(function() {
		$('#pageHeader').slideDown();
	}, 500);

});

