//fgnass.github.com/spin.js#v1.2.1
(function(a,b,c){function n(a){var b={x:a.offsetLeft,y:a.offsetTop};while(a=a.offsetParent)b.x+=a.offsetLeft,b.y+=a.offsetTop;return b}function m(a,b){for(var d in b)a[d]===c&&(a[d]=b[d]);return a}function l(a,b){for(var c in b)a.style[k(a,c)||c]=b[c];return a}function k(a,b){var e=a.style,f,g;if(e[b]!==c)return b;b=b.charAt(0).toUpperCase()+b.slice(1);for(g=0;g<d.length;g++){f=d[g]+b;if(e[f]!==c)return f}}function j(a,b,c,d){var g=["opacity",b,~~(a*100),c,d].join("-"),h=.01+c/d*100,j=Math.max(1-(1-a)/b*(100-h),a),k=f.substring(0,f.indexOf("Animation")).toLowerCase(),l=k&&"-"+k+"-"||"";e[g]||(i.insertRule("@"+l+"keyframes "+g+"{"+"0%{opacity:"+j+"}"+h+"%{opacity:"+a+"}"+(h+.01)+"%{opacity:1}"+(h+b)%100+"%{opacity:"+a+"}"+"100%{opacity:"+j+"}"+"}",0),e[g]=1);return g}function h(a,b,c){c&&!c.parentNode&&h(a,c),a.insertBefore(b,c||null);return a}function g(a,c){var d=b.createElement(a||"div"),e;for(e in c)d[e]=c[e];return d}var d=["webkit","Moz","ms","O"],e={},f;h(b.getElementsByTagName("head")[0],g("style"));var i=b.styleSheets[b.styleSheets.length-1],o=function q(a){if(!this.spin)return new q(a);this.opts=m(a||{},{lines:12,length:7,width:5,radius:10,color:"#000",speed:1,trail:100,opacity:.25,fps:20})},p=o.prototype={spin:function(a){this.stop();var b=this,c=b.el=l(g(),{position:"relative"}),d,e;a&&(e=n(h(a,c,a.firstChild)),d=n(c),l(c,{left:(a.offsetWidth>>1)-d.x+e.x+"px",top:(a.offsetHeight>>1)-d.y+e.y+"px"})),c.setAttribute("aria-role","progressbar"),b.lines(c,b.opts);if(!f){var i=b.opts,j=0,k=i.fps,m=k/i.speed,o=(1-i.opacity)/(m*i.trail/100),p=m/i.lines;(function q(){j++;for(var a=i.lines;a;a--){var d=Math.max(1-(j+a*p)%m*o,i.opacity);b.opacity(c,i.lines-a,d,i)}b.timeout=b.el&&setTimeout(q,~~(1e3/k))})()}return b},stop:function(){var a=this.el;a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=c);return this}};p.lines=function(a,b){function e(a,d){return l(g(),{position:"absolute",width:b.length+b.width+"px",height:b.width+"px",background:a,boxShadow:d,transformOrigin:"left",transform:"rotate("+~~(360/b.lines*c)+"deg) translate("+b.radius+"px"+",0)",borderRadius:(b.width>>1)+"px"})}var c=0,d;for(;c<b.lines;c++)d=l(g(),{position:"absolute",top:1+~(b.width/2)+"px",transform:"translate3d(0,0,0)",opacity:b.opacity,animation:f&&j(b.opacity,b.trail,c,b.lines)+" "+1/b.speed+"s linear infinite"}),b.shadow&&h(d,l(e("#000","0 0 4px #000"),{top:"2px"})),h(a,h(d,e(b.color,"0 0 1px rgba(0,0,0,.1)")));return a},p.opacity=function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)},function(){var a=l(g("group"),{behavior:"url(#default#VML)"}),b;if(!k(a,"transform")&&a.adj){for(b=4;b--;)i.addRule(["group","roundrect","fill","stroke"][b],"behavior:url(#default#VML)");p.lines=function(a,b){function k(a,d,i){h(f,h(l(e(),{rotation:360/b.lines*a+"deg",left:~~d}),h(l(g("roundrect",{arcsize:1}),{width:c,height:b.width,left:b.radius,top:-b.width>>1,filter:i}),g("fill",{color:b.color,opacity:b.opacity}),g("stroke",{opacity:0}))))}function e(){return l(g("group",{coordsize:d+" "+d,coordorigin:-c+" "+ -c}),{width:d,height:d})}var c=b.length+b.width,d=2*c,f=e(),i=~(b.length+b.radius+b.width)+"px",j;if(b.shadow)for(j=1;j<=b.lines;j++)k(j,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(j=1;j<=b.lines;j++)k(j);return h(l(a,{margin:i+" 0 0 "+i,zoom:1}),f)},p.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}else f=k(a,"animation")}(),a.Spinner=o})(window,document)

Cufon.replace('h1, h3, h2, div.tagcloud, div#wimpelMidden, div.totalPrice, nav#sub', { fontFamily: "Myriad Pro", hover: true });

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({social_tools: '', hideflash: true});
	});

zoomShowcaseSettings = {	
	/* The original image width */
	imageWidth: 393,	
	/* The original image height */
	imageHeight: 236,	
	/* The total alloted width for the banner */
	bannerWidth: 956,	
	/* The speed of the shuffle animation in milliseconds */
	animationSpeed: 750,	
	/* Options are "easeOutQuint", "easeInOutQuint", "easeOutQuad" and "easeInOutQuad",  */
	easing: "easeOutQuint",	
	/* The opacity of the side items, 0-1 */
	sideOpacity: 0.5,	
	/* Choose to set the Slideshow to auto-play, true/false */
	autoPlay: true,	
	/* The autoPlay delay in milliseconds */
	autoPlayDelay: 4500,	
	/* Choose to randomize the slide order everytime someone visits your web page, true/false */
	randomizeItems: false,	
	/* The link target when a slide is linked, options are "_parent" and "_blank" */
	linkTarget: "_parent",	
	/* The percentage to zoom out the sides, 0-1 */
	sideZoom: 0.75,	
	/* The percentage to zoom out the back slide, 0-1 */
	backZoom: 0.5
}

jQuery(document).ready(function() {
	
	if($('#zoom-gallery').length > 0) {
		jQuery.zoomShowcase(zoomShowcaseSettings);
		zoomShowcaseSettings = null;
	}
	
});

/*function addRemoveDate(date_str) {
	if($.dates_selected[date_str]) {
		$.dates_selected.splice($.dates_selected.indexOf(date_str), 1);
	} else {
		$.dates_selected.push(date_str);
	}
}*/

$(function() {
	//$(".peKenBurns").peKenburnsSlider()
});

$(function() {

	$('.datepickerImg').click(function(){
		$(this).prev('input').focus();
	});

	$('#progress-bar').each(function(){
		pBar = $(this);

		$(this).find('.item').each(function(){
			$(this).css('width', (pBar.width() / pBar.find('.item').length) - 20);
		});
	});

	date_available = new Array;

	$('.bootkeuze').change(function(){
		$('.datepickerBeschikbaarheid').datepicker('refresh').val('');
		$('.period.page-item tbody').find('tr:not(.info)').remove();
		$('.period.page-item tbody').find('tr.info').show();
	});

	/*
	--
	---- Datepicker detail
	--
	*/
	if($('#datepickerBeschikbaarheid').length > 0){
		var d = new Date();
		if ($(this).datepicker("getDate") != null) {
			d = $(this).datepicker("getDate");
		}
		
		date_available = new Array;
		date_Mavailable = new Array;
		$.get('/pageid=56/lang='+ $('#boeklandcode_detail').val() +'/'+ ($('#datepickerBeschikbaarheid').attr('shipid') ? 'object=' + $('#datepickerBeschikbaarheid').attr('shipid') : 'type=' + $('#datepickerBeschikbaarheid').attr('shiptype')) +'/maand='+ (d.getMonth() + 1) +'/jaar='+ d.getFullYear(), function(data) {
			if($(data).find('periode').length > 0){
				$(data).find('periode').each(function(){
					var vStartD = $(this).find('startdatum').text();
					var vEindD = $(this).find('einddatum').text();

					vSYear = vStartD.substr(0,4);
					vSMonth = vStartD.substr(5,2);
					vSDay = vStartD.substr(8,2);

					vEYear = vEindD.substr(0,4);
					vEMonth = vEindD.substr(5,2);
					vEDay = vEindD.substr(8,2);
					
					if(parseInt(vSMonth)==month){
						vED = parseInt(vEDay);
						if(parseInt(vEMonth)==month){
							for(i=parseInt(vSDay);i<=parseInt(vEDay);i++){
								date_Mavailable[vSYear +'-'+  (parseInt(vSMonth) <= 9 ? '0' + vSMonth : vSMonth) +'-'+ (i <= 9 ? '0' + i : i) ].push();
							}
						}else{
							for(i=parseInt(vSDay);i<=31;i++){
								date_Mavailable[vSYear +'-'+  (parseInt(vSMonth) <= 9 ? '0' + vSMonth : vSMonth) +'-'+ (i <= 9 ? '0' + i : i) ].push();
							}
						}
					}else if(parseInt(vEMonth)==month){
						for(i=1;i<=parseInt(vEDay);i++){
							date_Mavailable[vSYear +'-'+  (parseInt(vEMonth) <= 9 ? '0' + vEMonth : vEMonth) +'-'+ (i <= 9 ? '0' + i : i) ].push();
						}
					}



					if(!date_available[$(this).find('startdatum').text()]){
						date_available[$(this).find('startdatum').text()] = [];
					}
					date_available[$(this).find('startdatum').text()].push({
						id: $(this).find('object').text(),
						startdatum: $(this).find('startdatum').text(),
						einddatum: $(this).find('einddatum').text(),
						huurprijs: $(this).find('huurprijs').text(),
						huurperiode: $(this).find('huurperiode').text()
					});
				});
				$('.noShipAvailable').hide();
			} else {
				$('.noShipAvailable').show();
			}
			
			$('#datepickerBeschikbaarheid').datepicker({

				dateFormat: 'yy-mm-dd',
				nextText: $("html").hasClass("de") ? 'Nächste' : 'volgende',
				prevText: $("html").hasClass("de") ? 'Vorherige' : 'vorige',
				dayNames: $("html").hasClass("de") ? ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'] : ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
				dayNamesShort: $("html").hasClass("de") ? ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Frei', 'Sam'] : ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
				dayNamesMin: $("html").hasClass("de") ? ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'] : ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
				monthNames: $("html").hasClass("de") ? ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'] : ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
				monthNamesShort: $("html").hasClass("de") ? ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'] : ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],

				minDate: '+0',
				maxDate: '+18m',

				changeMonth: true,
				changeYear: true,

				showWeek: true,
				
				onChangeMonthYear: function(year, month, int){
					date_available = new Array;
					date_Mavailable = new Array;

					$.get('/pageid=56/lang='+ $('#boeklandcode_detail').val() +'/'+ ($('#datepickerBeschikbaarheid').attr('shipid') ? 'object=' + $('#datepickerBeschikbaarheid').attr('shipid') : 'type=' + $('#datepickerBeschikbaarheid').attr('shiptype')) +'/maand='+ month +'/jaar='+ year, function(data) {
						if(month < 11 && month > 2) {
							$(data).find('periode').each(function(){
								var vStartD = $(this).find('startdatum').text();
								var vEindD = $(this).find('einddatum').text();

								vSYear = vStartD.substr(0,4);
								vSMonth = vStartD.substr(5,2);
								vSDay = vStartD.substr(8,2);

								vEYear = vEindD.substr(0,4);
								vEMonth = vEindD.substr(5,2);
								vEDay = vEindD.substr(8,2);
								
								if(parseInt(vSMonth)==month){
									vED = parseInt(vEDay);
									if(parseInt(vEMonth)==month){
										for(i=parseInt(vSDay);i<=parseInt(vEDay);i++){
											var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
											date_Mavailable[vA] = true;
										}
									}else{
										for(i=parseInt(vSDay);i<=31;i++){
											var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
											date_Mavailable[vA] = true;
										}
									}
								}else if(parseInt(vEMonth)==month){
									for(i=1;i<=parseInt(vEDay);i++){
										var vA = vSYear +'-'+ vEMonth +'-'+ (i <= 9 ? '0' + i : i);
										date_Mavailable[vA] = true;
									}
								}
								if(!date_available[$(this).find('startdatum').text()]){
									date_available[$(this).find('startdatum').text()] = [];
								}
								date_available[$(this).find('startdatum').text()].push({
									id: $(this).find('object').text(),
									startdatum: $(this).find('startdatum').text(),
									einddatum: $(this).find('einddatum').text(),
									huurprijs: $(this).find('huurprijs').text(),
									huurperiode: $(this).find('huurperiode').text()
								});
							});
							$('.noShipAvailable').hide();
						} else {
							$('.noShipAvailable').show();
						}
						$('#datepickerBeschikbaarheid').datepicker('refresh');
					});
				},
				beforeShowDay: function(date) {
					var date_str = [
						date.getFullYear(),
						((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)),
						(date.getDate() < 10 ? '0' + date.getDate() : date.getDate())
					].join('-');

					if (date_available[date_str]) {
						return [true, 'good_date', ''];
					} else if(date_Mavailable[date_str]){
						return [false, 'good_date', ''];
					}else{
						return [false, 'bad_date', ($("html").hasClass("de") ? 'Nicht verfügbar' : 'Niet beschikbaar')];
					}
				},
				onSelect: function(date, inst) {
					newItem = $('.period.detail tbody');
					newItem.find('tr:not(.info)').remove();
					newItem.find('tr.info').hide();

					$(date_available[date]).each(function(index){
						newSubItem = $('<tr><td class="date"></td><td class="price"></td><td class="book"><a class="Boeken" href="#">&nbsp;</a></td></tr>').appendTo(newItem);

						var einddatum = date_available[date][index].einddatum.split('-');

						newSubItem.find('td.date').html(date_available[date][index].huurperiode + ' t/m (' + einddatum[2] + '-' + einddatum[1] + ')');
						newSubItem.find('td.price').html('&euro; ' + date_available[date][index].huurprijs);

						newSubItem.find('a').attr('href', '/pageid=60/ship=' + date_available[date][index].id + '/begin=' + date_available[date][index].startdatum + '/eind=' + date_available[date][index].einddatum);
					});
				},
				firstDay: 6
			});
		});
	}

	/*
	--
	---- Datepicker page-item
	--
	*/
	$('.datepickerBeschikbaarheid').datepicker({

		dateFormat: 'yy-mm-dd',
		nextText: $("html").hasClass("de") ? 'Nächste' : 'volgende',
		prevText: $("html").hasClass("de") ? 'Vorherige' : 'vorige',
		dayNames: $("html").hasClass("de") ? ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'] : ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
		dayNamesShort: $("html").hasClass("de") ? ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Frei', 'Sam'] : ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
		dayNamesMin: $("html").hasClass("de") ? ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'] : ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
		monthNames: $("html").hasClass("de") ? ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'] : ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
		monthNamesShort: $("html").hasClass("de") ? ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'] : ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec'],

		changeMonth: true,
		changeYear: true,

		minDate: '+0',
		maxDate: '+18m',

		showWeek: true,
		// called for every date before it is displayed
		beforeShow: function(){
			var d = new Date();
			if ($(this).datepicker("getDate") != null) {
				d = $(this).datepicker("getDate");
			}
			date_available = new Array;
			date_Mavailable = new Array;
			var availableCounter = 0;

			$.get('/pageid=56/lang='+ $('#boeklandcode').val() +'/object='+ $('.bootkeuze').val() +'/maand='+ (d.getMonth() + 1) +'/jaar='+ d.getFullYear(), function(data) {
				$(data).find('periode').each(function(){
					var vStartD = $(this).find('startdatum').text();
					var vEindD = $(this).find('einddatum').text();

					vSYear = vStartD.substr(0,4);
					vSMonth = vStartD.substr(5,2);
					vSDay = vStartD.substr(8,2);

					vEYear = vEindD.substr(0,4);
					vEMonth = vEindD.substr(5,2);
					vEDay = vEindD.substr(8,2);
					
					if(parseInt(vSMonth)==month){
						vED = parseInt(vEDay);
						if(parseInt(vEMonth)==month){
							for(i=parseInt(vSDay);i<=parseInt(vEDay);i++){
								var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
								date_Mavailable[vA] = true;
							}
						}else{
							for(i=parseInt(vSDay);i<=31;i++){
								var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
								date_Mavailable[vA] = true;
							}
						}
					}else if(parseInt(vEMonth)==month){
						for(i=1;i<=parseInt(vEDay);i++){
							var vA = vSYear +'-'+ vEMonth +'-'+ (i <= 9 ? '0' + i : i);
							date_Mavailable[vA] = true;
						}
					}
					if(!date_available[$(this).find('startdatum').text()]){
						date_available[$(this).find('startdatum').text()] = [];
					}
					date_available[$(this).find('startdatum').text()].push({
						id: $(this).find('object').text(),
						startdatum: $(this).find('startdatum').text(),
						einddatum: $(this).find('einddatum').text(),
						huurprijs: $(this).find('huurprijs').text(),
						huurperiode: $(this).find('huurperiode').text()
					});
					availableCounter++;
				});
				
				$('.datepickerBeschikbaarheid').datepicker('refresh');
				$('.noShipAvailable').remove();
				if(d.getMonth() + 1 >= 11 || d.getMonth() + 1 <= 2) {
					$("#ui-datepicker-div").prepend('<span class="noShipAvailable" style="display:block;">Geen verhuur in deze maand</span>');
				}
			});
		},
		onChangeMonthYear: function(year, month, int){
			date_available = new Array;
			date_Mavailable = new Array;
			var availableCounter = 0;

			$.get('/pageid=56/lang='+ $('#boeklandcode').val() +'/object='+ $('.bootkeuze').val() +'/maand='+ month +'/jaar='+ year, function(data) {
				$(data).find('periode').each(function(){
					var vStartD = $(this).find('startdatum').text();
					var vEindD = $(this).find('einddatum').text();

					vSYear = vStartD.substr(0,4);
					vSMonth = vStartD.substr(5,2);
					vSDay = vStartD.substr(8,2);

					vEYear = vEindD.substr(0,4);
					vEMonth = vEindD.substr(5,2);
					vEDay = vEindD.substr(8,2);
					
					if(parseInt(vSMonth)==month){
						vED = parseInt(vEDay);
						if(parseInt(vEMonth)==month){
							for(i=parseInt(vSDay);i<=parseInt(vEDay);i++){
								var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
								date_Mavailable[vA] = true;
							}
						}else{
							for(i=parseInt(vSDay);i<=31;i++){
								var vA = vSYear +'-'+ vSMonth +'-'+ (i <= 9 ? '0' + i : i)
								date_Mavailable[vA] = true;
							}
						}
					}else if(parseInt(vEMonth)==month){
						for(i=1;i<=parseInt(vEDay);i++){
							var vA = vSYear +'-'+ vEMonth +'-'+ (i <= 9 ? '0' + i : i);
							date_Mavailable[vA] = true;
						}
					}
					if(!date_available[$(this).find('startdatum').text()]){
						date_available[$(this).find('startdatum').text()] = [];
					}
					date_available[$(this).find('startdatum').text()].push({
						id: $(this).find('object').text(),
						startdatum: $(this).find('startdatum').text(),
						einddatum: $(this).find('einddatum').text(),
						huurprijs: $(this).find('huurprijs').text(),
						huurperiode: $(this).find('huurperiode').text()
					});
					availableCounter++;
				});
				
				$('.datepickerBeschikbaarheid').datepicker('refresh');
				$('.noShipAvailable').remove();
				if(month >= 11 || month <= 2) {
					$("#ui-datepicker-div").prepend('<span class="noShipAvailable" style="display:block;">'  + ($('html').hasClass('de') ? 'Keine Vermietung in diesem Monat' : 'Geen verhuur in deze maand') + '</span>');
				}
			});
		},
		beforeShowDay: function(date) {
			var date_str = [
				date.getFullYear(),
				((date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)),
				(date.getDate() < 10 ? '0' + date.getDate() : date.getDate())
			].join('-');

			if (date_available[date_str]) {
				return [true, 'good_date', ''];
			} else if(date_Mavailable[date_str]){
				return [false, 'good_date', ''];
			} else {
				return [false, 'bad_date', ($("html").hasClass("de") ? 'Nicht verfügbar' : 'Niet beschikbaar')];
			}
		},
		onSelect: function(date, inst) {
			newItem = $('.period.page-item tbody');
			newItem.find('tr:not(.info)').remove();
			newItem.find('tr.info').hide();

			$(date_available[date]).each(function(index) {
				if(index > 2) return false; // Max. 3 perioden in page-item
				newSubItem = $('<tr><td class="date"></td><td class="price"></td><td class="book"><a class="Boeken" href="#">&nbsp;</a></td></tr>').appendTo(newItem);

				var einddatum = date_available[date][index].einddatum.split('-');

				newSubItem.find('td.date').html(date_available[date][index].huurperiode + ' t/m (' + einddatum[2] + '-' + einddatum[1] + ')');
				newSubItem.find('td.price').html('&euro; ' + date_available[date][index].huurprijs);

				newSubItem.find('a').attr('href', '/pageid=60/ship=' + date_available[date][index].id + '/begin=' + date_available[date][index].startdatum + '/eind=' + date_available[date][index].einddatum);
			});
		},
		firstDay: 6
	});

	$(".ship img[title]").tooltip();

	$('.BgSuper').each(function(){
		imgRatio = $(this).height() / $(this).width();
		
		$(this).width($(window).width());
		$(this).height($(window).width() * imgRatio);
	});

	$(window).resize(function(){
		$('.BgSuper').each(function(){
			imgRatio = $(this).height() / $(this).width();
			
			$(this).width($(window).width());
			$(this).height($(window).width() * imgRatio);
		});
	});
});

//DATEPICKER
$(function() {
	$(".datepicker").datepicker({
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		nextText: $("html").hasClass("de") ? 'Nächste' : 'volgende',
		prevText: $("html").hasClass("de") ? 'Vorherige' : 'vorige',
		dayNames: $("html").hasClass("de") ? ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'] : ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'],
		dayNamesShort: $("html").hasClass("de") ? ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Frei', 'Sam'] : ['Zon', 'Maa', 'Din', 'Woe', 'Don', 'Vrij', 'Zat'],
		dayNamesMin: $("html").hasClass("de") ? ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'] : ['Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'],
		monthNames: $("html").hasClass("de") ? ['Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'] : ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'],
		monthNamesShort: $("html").hasClass("de") ? ['Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'] : ['Jan','Feb','Maa','Apr','Mei','Jun','Jul','Aug','Sep','Okt','Nov','Dec']
	}
	);
});

// Twitter
$(function() {
	$(".tweetNL").tweet({
		// username: "TRES",
		query: $("html").hasClass("de") ? "yachtcharterDE" : "yachtcharterNL",
		join_text: "auto",
		avatar_size: 32,
		count: 1,
		auto_join_text_default: "we said,", 
		auto_join_text_ed: "we",
		auto_join_text_ing: "we were",
		auto_join_text_reply: "we replied to",
		auto_join_text_url: "we were checking out",
		loading_text: "loading tweets...",
		lang: $("html").hasClass("de") ? "de" : "nl"
	}).bind("empty", function() {
		$("html").hasClass("de") ? $(this).append("Es gibt keine aktuellen Tweets gefunden") : $(this).append("Er zijn geen recente tweets gevonden")
		});
});

//ALERTS
$(function() {
	/*$.alerts.overlayOpacity = 0.75;*/
	/*$.alerts.overlayColor = "#000";*/
});

$(function(){
	$('.orderform').submit(function(){
		bValid = true;
		$(this).find('input.required').each(function(){
			if($(this).val() == ""){
				bValid = false;
				$(this).css('border', '1px solid #ff0000');
			}
		});

		if(bValid == false ){
			if(!$('html').hasClass('de')){
				$('#errororderform p').text('Er zijn een of meerdere velden niet juist ingevoerd. Controleer uw invoer en probeer het opnieuw.').parent().slideDown();
			} else {
				$('#errororderform p').text('Es gibt ein oder mehrere Felder nicht korrekt. Überprüfen Sie Ihre Eingabe und versuchen Sie es erneut.').parent().slideDown();	
			}
			return false;
		}
	});
});
