/* ================================ +
		het BELOOFDE LAND
 + ================================ */



/* 
** Made by: Thomas Lievestro
** Email:	info@lievestro.com
** Website:	www.lievestro.com
*/


/* ================================ +
               GENERAL
 + ================================ */

function makeMotherScrollable(){
	
	$('#children').unbind().css({'cursor':'default'}); 
	$('#logo').click(function(){
		$('#wrapper').scrollTo({ top:0, left:'+=0'}, 800, {easing:'easeOutCirc'});
		
		$('.child').unbind().css({'cursor':'default','backgroundColor': "#eaeaea"}); 
		
		$('#logo').unbind().css({'cursor':'default'});
	
		//herstel photo_viewer_content javascripts
		$('body').stop().animate({ backgroundColor: "#ffffff" }, 800);
		$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 800);
		$(".photo_viewer_content").stop().animate({'width':'180px','height':'80px'}, 250, 'easeOutCirc', function(){ 
			$(this).css({'backgroundColor':'transparent'}) 
		});
		$(".text_album").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
			$(this).css({'backgroundColor':'transparent'}) 
		});
		$(".text_history").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
			$(this).css({'backgroundColor':'transparent'}) 
		});
		$(".video_overlay_320x240, video_overlay_500x281, .video_overlay_480x384, .video_overlay_640x360, .photo_overlay").css({'backgroundColor':'#ffffff'}).fadeOut(250);
		
		
		
		
		 
		makeChildrenScrollable();
		
	}).css({'cursor':'pointer'});
}

function makeChildrenScrollable(){ 
   	$('.child').unbind().css({'cursor':'pointer'}); 
	$('#children .child_button').show();
   	
	$('#children, #ga_verder').click(function(){
		$('#wrapper').scrollTo({ top:-510, left:'+=0'}, 800, {easing:'easeOutCirc'});
		
		DisplayedChild = $('.child')[1].id;
		
		if(DisplayedChild == 'child1'){
			setClick('2','3');			
			$('#child1').unbind().css({'cursor':'default','backgroundColor': "#ffffff"}); 
			$('#child1 .child_button').hide();
		}else if(DisplayedChild == 'child2'){
			setClick('3','1');
			$('#child2').unbind().css({'cursor':'default','backgroundColor': "#ffffff"}); 
			$('#child2 .child_button').hide();
		}else if(DisplayedChild == 'child3'){
			setClick('1','2');
			$('#child3').unbind().css({'cursor':'default','backgroundColor': "#ffffff"}); 
			$('#child3 .child_button').hide();
		}
		
		makeMotherScrollable();
		
   	}).css({'cursor':'pointer'});
   	
   
}


function setClick(id1,id2){ 
	$('#child'+id1).click(function(){
		
		scrollRight($('#child'+id1),id1);
		
  	});
  	
  	$('#child'+id2).click(function(){
  		
  		scrollLeft($('#child'+id2),id2);
  	
	});
}


function scrollRight(This,id1){ 
	
	$(This).stop().animate({ backgroundColor: "#ffffff" }, 800);
	$('#'+$(This).attr('id')+' .child_button').hide();
	$('.child').unbind().css({'cursor':'default'}); 
	
	//herstel photo_viewer_content javascripts
	$('body').stop().animate({ backgroundColor: "#ffffff" }, 800);
	$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 800);
	$(".photo_viewer_content").stop().animate({'width':'180px','height':'80px'}, 250, 'easeOutCirc', function(){ 
			$(this).css({'backgroundColor':'transparent'}) 
		});
	$(".text_album").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
		$(this).css({'backgroundColor':'transparent'}) 
	});
	$(".text_history").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
		$(this).css({'backgroundColor':'transparent'}) 
	});
	$(".video_overlay_320x240, .video_overlay_500x281, .video_overlay_480x384, .video_overlay_640x360, .photo_overlay").css({'backgroundColor':'#ffffff'}).fadeOut(250);

	if(id1 == 1){	
		$('#child2').clone(true).insertAfter(This).attr('id','child2_clone');	
		
		setTimeout(function(){
				$('#child2').remove();		
				$('#children').css('marginLeft','0px');
				$('#child2_clone').attr('id','child2');	

				setClick('2','3');
		},1000);
	}	
	else if(id1 == 2){	
		$('#child3').clone(true).insertAfter(This).attr('id','child3_clone');	
		
		setTimeout(function(){
				$('#child3').remove();		
				$('#children').css('marginLeft','0px');
				$('#child3_clone').attr('id','child3');	
				
				setClick('3','1');
		},1000);
		
	}	
	else if(id1 == 3){	
		$('#child1').clone(true).insertAfter(This).attr('id','child1_clone');	
		
		setTimeout(function(){
				$('#child1').remove();		
				$('#children').css('marginLeft','0px');
				$('#child1_clone').attr('id','child1');	
				
				setClick('1','2');
		},1000);
	}		
	
	$('#'+$('.child')[1].id).css({'cursor':'pointer'}).stop().animate({ backgroundColor: "#eaeaea" }, 800);
	$('#'+$('.child')[3].id).css({'cursor':'pointer'});
	$('#'+$('.child')[1].id+' .child_button').show();
	$('#'+$('.child')[3].id+' .child_button').show();
	$('#children').scrollTo($('#children_inner').find('.child')[2], 800, {easing:'easeOutCirc'});

}

function scrollLeft(This,id2){ 
	
	$(This).stop().animate({ backgroundColor: "#ffffff" }, 800);
	$('#'+$(This).attr('id')+' .child_button').hide();
	$('.child').unbind().css({'cursor':'default'}); 				
	$('#children').css('marginLeft','-940px');
	
	//herstel contentblokken javascripts
	$('body').stop().animate({ backgroundColor: "#ffffff" }, 800);
	$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 800);
	$(".photo_viewer_content").stop().animate({'width':'180px','height':'80px'}, 250, 'easeOutCirc', function(){ 
		$(this).css({'backgroundColor':'transparent'}) 
	});
	$(".text_album").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
		$(this).css({'backgroundColor':'transparent'}) 
	});
	$(".text_history").stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
		$(this).css({'backgroundColor':'transparent'}) 
	});
	$(".video_overlay_320x240, .video_overlay_480x384, .video_overlay_500x281, .video_overlay_640x360, .photo_overlay").css({'backgroundColor':'#ffffff'}).fadeOut(250);
	
	if(id2 == 1){	
		$('#child3').clone(true).insertBefore(This).attr('id','child3_clone');	
		
		setTimeout(function(){
				$('#child3').remove();		
				$('#child3_clone').attr('id','child3');	
				
				setClick('2','3');
		},850);
	}	
	else if(id2 == 2){	
		$('#child1').clone(true).insertBefore(This).attr('id','child1_clone');	
		
		setTimeout(function(){
				$('#child1').remove();
				$('#child1_clone').attr('id','child1');	
				
				setClick('3','1');
		},850);
	}	
	else if(id2 == 3){	
		$('#child2').clone(true).insertBefore(This).attr('id','child2_clone');	
		
		setTimeout(function(){
				$('#child2').remove();		
				$('#child2_clone').attr('id','child2');	
				
				setClick('1','2');
		},850);
	}		
	
	$('#'+$('.child')[0].id).css({'cursor':'pointer'});
	$('#'+$('.child')[2].id).css({'cursor':'pointer'}).stop().animate({ backgroundColor: "#eaeaea" }, 800);
	$('#'+$('.child')[0].id+' .child_button').show();
	$('#'+$('.child')[2].id+' .child_button').show();
	$('#children').scrollTo($('#children_inner').find('.child')[1], 800, {easing:'easeOutCirc'});

}












  

/* ================================ +
           SKILFUL FUNCTIONS
 + ================================ */


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};




	
			







 /* parse the Jquery functions after document ready */
$(document).ready(function(){
	
	
	makeChildrenScrollable();
	
	//Get browser details
	BrowserDetect.init();

	//Set browser details in variables
	OS = BrowserDetect.OS;
	browser = BrowserDetect.browser;
	version = BrowserDetect.version;
	
	
	
	if(((OS == "Windows") && (browser == "Explorer")) && ((version == "6") || (version == "7"))){ 
		$('#overlay_message').show();
	}
    
    	
	$(".overlay_message_sluiten")
	.click(function(){
		$('#overlay_message').hide();
		if(((OS == "Windows") && (browser == "Explorer") && (version == "6"))){ 
            $("#other_park").parents('.jquery-selectbox').unselectbox();
		
            $("#time").parents('.jquery-selectbox').unselectbox();
            $("#action").parents('.jquery-selectbox').unselectbox();
            $("#house").parents('.jquery-selectbox').unselectbox();
        }

	});
	
	$(".photo_viewer_content .sluiten, .photo_viewer_content .title")
	.click(function(){
	
		if($(this).parent().css('width') == '180px'){
			$(this).parent().css({'backgroundColor':'#ffffff'}).stop().animate({'width':'440px','height':'485px'}, 250, 'easeOutCirc');
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#child2').stop().animate({ backgroundColor: "#eaeaea" }, 250);
						
		}else if($(this).parent().css('width') == '440px'){
			$(this).parent().stop().animate({'width':'180px','height':'90px'}, 250, 'easeOutCirc', function(){ 
				$(this).css({'backgroundColor':'transparent'})
			});
			
			setTimeout(function(){
				var photo_viewer_content_active = false;
				$(".photo_viewer_content").each(function(){
			    	if($(this).css('width') == '440px'){
			    		photo_viewer_content_active = true;
			    	}		    		
				});
			   		
				if(photo_viewer_content_active == false){
			
					$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#child2').stop().animate({ backgroundColor: "#ffffff" }, 250);
				}
			},15);
		}
		return false;
	});
	
	$(".photo_viewer_content_small .sluiten, .photo_viewer_content_small .title")
	.click(function(){
	
		if($(this).parent().css('width') == '180px'){
			$(this).parent().css({'backgroundColor':'#ffffff'}).stop().animate({'width':'440px','height':'200px'}, 250, 'easeOutCirc');
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#child2').stop().animate({ backgroundColor: "#eaeaea" }, 250);
						
		}else if($(this).parent().css('width') == '440px'){
			$(this).parent().stop().animate({'width':'180px','height':'80px'}, 250, 'easeOutCirc', function(){ 
				$(this).css({'backgroundColor':'transparent'})
			});
			
			setTimeout(function(){
				var photo_viewer_content_active = false;
				$(".photo_viewer_content").each(function(){
			    	if($(this).css('width') == '440px'){
			    		photo_viewer_content_active = true;
			    	}		    		
				});
			   		
				if(photo_viewer_content_active == false){
			
					$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#child2').stop().animate({ backgroundColor: "#ffffff" }, 250);
				}
			},15);
		}
		return false;
	});
	
	$(".text_album .sluiten, .text_album .header260")
	.click(function(){
	
		if($(this).parent().css('width') == '250px'){
			$(this).parent().css({'backgroundColor':'#ffffff'}).stop().animate({'width':'440px','height':'250px'}, 250, 'easeOutCirc');
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#child1').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			
		}else if($(this).parent().css('width') == '440px'){
			$(this).parent().stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
				$(this).css({'backgroundColor':'transparent'}) 
			});
			
			setTimeout(function(){
				var photo_viewer_content_active = false;
				$(".photo_viewer_content").each(function(){
			    	if($(this).css('width') == '440px'){
			    		photo_viewer_content_active = true;
			    	}		    		
				});
			   		
				if(photo_viewer_content_active == false){
			
					$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#child1').stop().animate({ backgroundColor: "#ffffff" }, 250);
				}
			},15);
		}
		return false;
	});
	
	$(".text_history .sluiten, .text_history .header260")
	.click(function(){
	
		if($(this).parent().css('width') == '250px'){
			$(this).parent().css({'backgroundColor':'#ffffff'}).stop().animate({'width':'440px','height':'420px'}, 250, 'easeOutCirc');
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#child3').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			
		}else if($(this).parent().css('width') == '440px'){
			$(this).parent().stop().animate({'width':'250px','height':'80px'}, 250, 'easeOutCirc', function(){ 
				$(this).css({'backgroundColor':'transparent'}) 
			});
			
			setTimeout(function(){
				var photo_viewer_content_active = false;
				$(".photo_viewer_content").each(function(){
			    	if($(this).css('width') == '440px'){
			    		photo_viewer_content_active = true;
			    	}		    		
				});
			   		
				if(photo_viewer_content_active == false){
			
					$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);
					$('#child3').stop().animate({ backgroundColor: "#ffffff" }, 250);
				}
			},15);
		}
		return false;
	});
	
	$(".video_link")
	.click(function(){
		
		if($('#overlay_'+this.id).is(":hidden")){
			//reset
			$(".video_overlay_320x240, .video_overlay_500x281, .video_overlay_480x384, .video_overlay_640x360, .photo_overlay").css({'backgroundColor':'#ffffff'}).fadeOut(250);
			
			$('#overlay_'+this.id).css({'backgroundColor':'#ffffff'}).fadeIn(250);
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);

			$('#'+$('#overlay_'+this.id).parents()[1].id).stop().animate({ backgroundColor: "#eaeaea" }, 250);
	
		}
	});
	
	$(".video_overlay_320x240 .sluiten, .video_overlay_500x281 .sluiten, .video_overlay_480x384 .sluiten, .video_overlay_640x360 .sluiten")
	.click(function(){
		
		if($(this).parent().not(":hidden")){
			$(this).parent().css({'backgroundColor':'#ffffff'}).fadeOut(250);
			$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);

			$('#'+$(this).parent().parents()[1].id).stop().animate({ backgroundColor: "#ffffff" }, 250);
	
		}
	});
	
	$(".photo_link")
	.click(function(){
		
		if($('#overlay_'+this.id).is(":hidden")){
			//reset
			$(".video_overlay_320x240, .video_overlay_500x281, .video_overlay_480x384, .video_overlay_640x360, .photo_overlay").css({'backgroundColor':'#ffffff'}).fadeOut(250);
		
			$('#overlay_'+this.id).css({'backgroundColor':'#ffffff'}).fadeIn(250);
			$('body').stop().animate({ backgroundColor: "#eaeaea" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#eaeaea" }, 250);

			$('#'+$('#overlay_'+this.id).parents()[1].id).stop().animate({ backgroundColor: "#eaeaea" }, 250);
	
		}
	});
	
	$(".photo_overlay .sluiten")
	.click(function(){
		
		if($(this).parent().not(":hidden")){
			$(this).parent().css({'backgroundColor':'#ffffff'}).fadeOut(250);
			$('body').stop().animate({ backgroundColor: "#ffffff" }, 250);
			$('#mother').stop().animate({ backgroundColor: "#ffffff" }, 250);

			$('#'+$(this).parent().parents()[1].id).stop().animate({ backgroundColor: "#ffffff" }, 250);
	
		}
	});
	


	
	
	
	
	$("#other_park").selectbox();
	
	
	$("#time").selectbox();
	$("#action").selectbox();
	$("#house").selectbox();
	
	
	
	
	
	
	quotes = new Array();
	
	quotes.push(new Array("'Wij zijn ook gewone burgers. Met een rugzakje'","<strong>Thea</strong>, 't Beukenhof"));
	quotes.push(new Array("'Het probleem met Polen is dat ze zich niet zo aan de regels houden'","<strong>Piet</strong>, Parc Patersven"));
	quotes.push(new Array("'Wat is recre'ren? Je zit hier lekker in je tuintje voor je huisje'","<strong>Jan</strong>, Parc Patersven"));
	quotes.push(new Array("'Hier hebben we, dag voor dag, rust gekregen'","<strong>Taher</strong>, Duinrell"));
	quotes.push(new Array("'We nemen Gospel dvd's mee, zodat we ons hier thuis voelen'","<strong>Lydia</strong>, de Jachthoorn"));
	quotes.push(new Array("'Niemand hier is directeur of manager, iedereen verricht fysieke arbeid'","<strong>Radek</strong>, Parc Patersven"));
	quotes.push(new Array("'We voetballen, hangen rond en wachten af tot we ons interview krijgen'","<strong>Ibrahim</strong>, Duinrell"));
	quotes.push(new Array("'Het is een vakantiepark, maar voor mij voelt het niet als vakantie'","<strong>Kwatou</strong>, Miggelenberg"));
	quotes.push(new Array("'We zien ze met hun honden, genieten van de frisse lucht'","<strong>Jalal</strong>, Miggelenberg"));
	quotes.push(new Array("'Alle problemen van het dorp, drugs, drank, loverboys, verplaatst zich hierheen'","<strong>Thea</strong>, 't Beukenhof"));
	quotes.push(new Array("'Een huis is wel veel groter, maar een stacaravan is veel knusser'","<strong>Mattheus</strong>, 't Beukenhof"));
	quotes.push(new Array("'Een heleboel huisjes, grote bomen en vogels, het is erg mooi'","<strong>Alex</strong>, Miggelenberg."));
	quotes.push(new Array("'Je ontmoet hier mensen uit Spanje, Rusland, Afrika, Azie, Amerika, de hele wereld'","<strong>Marina</strong>, Miggelenberg"));

	quotes = $.shuffle(quotes);
	
	pages = new Array('duinrell.php','beukenhof.php','patersven.php');
	pages = $.shuffle(pages);
	
	numbers = new Array(1,2,3,4,5,6,7);
	numbers = $.shuffle(numbers);
	
	$("#go_button").click(function(){
	
		//IE6 FIX - activate png fix
		if((OS != "Windows") && (browser != "Explorer") && (version != "6")){ 
			var option = $('.jquery-selectbox-currentItem')[2].innerHTML;
		}else{
			var option = $('#house').val();
		}
		$('body').css({'background':'url("images/home_bg'+numbers[0]+'.jpg") no-repeat center top'});
		$('#home_content_block').html('<h3>Een moment geduld a.u.b. we <br />checken de beschikbaarheid</h3><img src="images/waitaminute.gif" /><h2>'+quotes[0][0]+'</h2><h4>'+quotes[0][1]+'</h4>');

		setTimeout(function(){
			if(option == '2-persoons caravan' || option == 1){
				location.href = 'beukenhof.php';
			}else if(option == '4-persoons bungalow' || option == 2){
				location.href = 'duinrell.php';
			}else if(option == '8-12 persoons chalet' || option == 3){
				location.href = 'patersven.php';
			}else{
				location.href = pages[0];
			}
		},5000);
	});
	
	$("#mini_menu .jquery-selectbox-item").click(function(){ 
		if($(this).html() != 'kies een ander park'){
			location.href = $(this).html()+'.php';
		}
	});

	
});



(function($){
  $.fn.shuffle = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shuffle(items))
        : this;
    });
  }
 
  $.shuffle = function(arr) {
    for(
      var j, x, i = arr.length; i;
      j = parseInt(Math.random() * i),
      x = arr[--i], arr[i] = arr[j], arr[j] = x
    );
    return arr;
  }
})(jQuery);


