$(document).ready( function() {
	$('#zipnieuws2 img').attr('usemap', '#Map2');
	/* $('.content').jScrollPane(); */

	$('#zippfly').effect("shake", { distance:1900,times:5}, 20000);
	// wissel afbeelding bij links en rechts
	setInterval(function(){
		xposstring = ($('#zippfly').css('left'));
		xposstring = xposstring.replace("px","")
		xpos = parseInt(xposstring);
		//$("#debug").append("</br>xpos:"+xpos);
		
		if(xpos < -1700)
		{
			//height = (Math.random()*100) + 100;
			//height = height+'px';
			// css methode, transparante background imageIE is daar natuurlijk niet blij mee, daarom met img werken
			//$('#zippfly').css({"background-image":"	url(/static/sites/campingkids/images/decorators/zippfly2.png)"})
			$('#zippflyimage').attr("src", '/static/sites/campingkids/images/decorators/zippfly2.png');
			$('#zippflyimage').attr("height", '66');
			$('#zippflyimage').attr("width", '75');
			$('#zippflyimage').attr("z-index", '0');
			//$('#zippfly').css({"top":height})
			//$("#debug").prepend("</br>(<1400):"+"zippfly2.png");
		}
		
		if( xpos > 0 )
		{
			//height = (Math.random()*100) + 100;
			//height = height+'px';
			//$('#zippfly').css({"background-image":"	url(/static/sites/campingkids/images/decorators/zippfly.png)"})
			$('#zippflyimage').attr("src", '/static/sites/campingkids/images/decorators/zippfly.png');
			$('#zippflyimage').attr("height", '112');
			$('#zippflyimage').attr("width", '151');
			$('#zippflyimage').attr("z-index", '1000000');
            //$('#zippfly').css({"top":height});
			//$("#debug").prepend("</br>(>1400)height:"+"zippfly.png");
		}
	},300);
	
	// verander de hoogte
	var timing = (Math.random()*5000)+1000;
	setInterval(function() {
		//dh = 50 + Math.random()*100;
		dh = ( 100 + Math.random()*100 );
		
		currtop = parseInt($('#zippfly').css('top'));
		var top = currtop + dh;
		
		//$("#debug").prepend("</br>currtop:"+currtop+"<br/> top:"+top);
		if( top < 0)
		{
			top = currtop+dh;
		}
		if(top > 150)
		{
			top = currtop-dh;
		}
		
		$('#zippfly').animate({"top":top}, { queue:false, duration:2000, easing:"backEaseInOut"});
		
		//$("#debug").prepend("</br>currtop:"+currtop+"<br/> top:"+top+ " timing:"+timing);
	}, timing);
	Cufon.replace('.cufon'); // Requires a selector engine for IE 6-7, see above
	
	
/**********  SET CORRECT MENU **************/
var currentmenu = $('.leftmenucontainer li.selected').index()+1;
if ($('.leftmenucontainer li.ancestor').length) {
    var currentmenu = $('.leftmenucontainer li.ancestor').index()+1;
}
if(currentmenu==0)
currentmenu=2;
if(currentmenu>4)
{
	for(i=4;i<currentmenu;i++)
	{
		$('.leftmenucontainer ul').append($('.leftmenucontainer li:first-child'));
	}
}
else if(currentmenu<4)
{
	for(i=4;i>currentmenu;i--)
	{
		$('.leftmenucontainer ul').prepend($('.leftmenucontainer li:last-child'));
	}
}
$('.leftmenucontainer ul').css({"visibility":"visible"});
/**********  SET CORRECT MENU END **********/


/**********  COOKIE CHECKING  **********/
var wolkpijltm;
if($.cookie('departure'))
{
	var now = new Date();
	var departuredate = new Date($.cookie('departure'));
	var dagen = (departuredate.getTime()- now.getTime() ) / (60*60*24*1000);
	dagen = Math.ceil(dagen);
	if(dagen>=0)
	{
		$('#dagteller').html(dagen);
		Cufon.refresh();
		$('[name=dag]').val(departuredate.getDate());
		$('[name=maand]').val(departuredate.getMonth()+1);
		$('[name=jaar]').val(departuredate.getFullYear());
	}
}
else
{
	wolkpijltm = setInterval(function() {$('#wolkpijl').effect("shake", { distance:8,times:4,direction:'up' }, 75)}, 7000);
}
/**********  COOKIE CHECKING END **********/


/**********  WOLKEN  **********/
$('#wolk2, #wolk4').effect("shake", { distance:300,times:2 }, 30000)
$('#wolk3, #wolk5').effect("shake", { distance:500,times:5 }, 50000)
/**********  WOLKEN END **********/

/********** DRAAIENDE TELLER ******************/
$().ready(function() {
	var Paths = {"arc":[]}
	var path_fns = {
	arc: function(i) {
	  return new $.path.arc({
		center: [450,0],	
			radius: 5,	
			start: 100,
			end: 6000,
			dir: 5
	  })
	}
	}
	
	for(var type in Paths) {
	
	for(var i=0; i<5; i++ ) {
	  var path = path_fns[type](i)
	  Paths[type].push(path)
	}
		
	}
	$('#teller').stop().animate({path: Paths[type][1] }, 30000)
})
/********** DRAAIENDE TELLER END **************/


/**********  KALENDER **********/
$('#teller').click(function() {
	$('#wolken #kalender').animate({"top":"+=200px" }, { queue:true, duration:500, easing:"backEaseOut"});
});
$('.voerin').click(function() {
	var dag = $('[name=dag]').val();
	var maand = $('[name=maand]').val();
	var jaar = $('[name=jaar]').val();
	$('#wolken #kalender input').css({"border":"1px solid" });
	wrong = false;
	if(dag=='' || dag>31)
	{
		$('[name=dag]').css({"border":"2px solid #F22"}).effect("shake", { distance:3,times:3 }, 50);
		wrong =  true;
	}
	if(maand=='' || maand >12)
	{
		$('[name=maand]').css({"border":"2px solid #F22"}).effect("shake", { distance:3,times:3 }, 50);
  		wrong =  true;
	}
	if(jaar=='')
	{
		wrong =  true;
		$('[name=jaar]').css({"border":"2px solid #F22"}).effect("shake", { distance:3,times:3 }, 50);
	}
	
	var now = new Date();
	var departuredate = new Date(jaar,(maand-1),dag,0,0,0,0);
	var dagen = (departuredate.getTime()- now.getTime() ) / (60*60*24*1000);
	dagen = Math.ceil(dagen);
	if(dagen<1)
	{
		wrong = true;
		$('#wolken #kalender input').css({"border":"2px solid #F22"}).effect("shake", { distance:3,times:3 }, 50);
	}

	if(!wrong)
	{
		if(wolkpijltm)
		{
			clearInterval(wolkpijltm);
		}
		$('#dagteller').text(dagen);
		Cufon.refresh();
		$.cookie('departure', departuredate, { expires: 10000, path: '/', domain: window.location.hostname, secure: false});
		$('#wolken #kalender').animate({"top":"-=200px" }, { queue:true, duration:300, easing:"backEaseIn"});
	}
});
/**********  KALENDER END **********/


/**********  SET CORRECT FLAG  **********/
var tld = window.location.hostname;
var re = new RegExp("\.([a-z,A-Z]{2,6})$");
tld = tld.match(re);
tld = tld[1];
if(tld=='com')
{
	tld = 'nl';
}
$('#languageselector div').attr('class',  'land-'+tld);
/**********  SET CORRECT FLAG END  **********/

/*********  LANGUAGE SELECT  ************/
	$('#languageselector').click(function() {
		$('#languageselectorall').css({"display":"block" });
		$('#languageselectorall').animate({"opacity":"1" }, { queue:true, duration:500, easing:""});
	});
	$('#languageselectorall').mouseleave(function() {
		setTimeout(function() {
			$('#languageselectorall').animate({"opacity":"0" }, { queue:false, duration:500, easing:"", complete:function() {$('#languageselectorall').css({"display":"none" });} });
		}, 200);
	});
	
/*********  LANGUAGE SELECT END  ************/


/**********   MENU CAROUSEL  ****************/
	$('#leftmenu ul li img').css({"height":"45px"});
	$('#leftmenu ul li:nth-child(3) img').css({"height":"65px"});
	$('#leftmenu ul li:nth-child(4) img').css({"height":"80px"});
	$('#leftmenu ul li:nth-child(5) img').css({"height":"65px"});
	
	var curmenu=0;
	$('#leftmenu #down').bind('contextmenu', function(e) {
        e.preventDefault();
    });
	
	$('#leftmenu #down').one('click', down);
 	$('#leftmenu #up').one('click', up);
 	
	function down()
	{
		if($.browser.msie) {
    		$('#leftmenu ul li:nth-child(2) img').css({"height":"25px"},{"opacity":"0.5"});
    		$('#leftmenu ul li:nth-child(3) img').css({"height":"45px"},{"opacity":"1"});
    		$('#leftmenu ul li:nth-child(4) img').css({"height":"65px"},{"opacity":"1"});
    		$('#leftmenu ul li:nth-child(5) img').css({"height":"80px"},{"opacity":"1"});
    		$('#leftmenu ul li:nth-child(6) img').css({"height":"65px"},{"opacity":"1"});
    		$('#leftmenu ul li:nth-child(7) img').css({"height":"45px"},{"opacity":"0.5"});
    		$('#leftmenu ul').append('<li class="sibling">'+$('#leftmenu ul li:first').html()+'</li>');
    		$('#leftmenu ul li:first').remove();
    		$('#leftmenu ul').stop().css({"top":"-50px"});
    		$('#leftmenu #down').one('click', down);
		} else {
            var animtime = 200;
    		$('#leftmenu ul').stop().animate({"top":"-=50px"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(2) img').stop().animate({"opacity":"0"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(3) img').stop().animate({"height":"45px"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(4) img').stop().animate({"height":"65px"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(5) img').stop().animate({"height":"80px"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(6) img').stop().animate({"height":"65px","opacity":"1"}, { queue:false, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(7) img').stop().css({"opacity":"0"});
    		$('#leftmenu ul li:nth-child(7) img').stop().animate({"opacity":"1"}, { queue:false, duration:animtime, easing:"", complete:function() {
    			$('#leftmenu ul').stop().css({"top":"-50px"});
    			$('#leftmenu ul').append('<li>'+$('#leftmenu ul li:first').html()+'</li>');
    			$('#leftmenu ul li:first').remove();
    			$('#leftmenu #down').bind('click', down);
    		} });
		}
	}
	function up()
	{
		if($.browser.msie ) {
		      //TODO IE9 werkt wel goed dus die nog eruit halen ($.browser.version)
            /*
$('#leftmenu ul li:nth-child(7) img').css({"opacity":"0"});
            $('#leftmenu ul li:nth-child(6) img').css({"opacity":"0"});
            $('#leftmenu ul li:nth-child(5) img').css({"height":"45px"},{"opacity":"1"});
            $('#leftmenu ul li:nth-child(4) img').css({"height":"65px"},{"opacity":"1"});
            $('#leftmenu ul li:nth-child(3) img').css({"height":"80px"},{"opacity":"1"});
            $('#leftmenu ul li:nth-child(2) img').css({"height":"65px"},{"opacity":"1"});
            //$('#leftmenu ul li:nth-child(1) img').css({"height":"45px"},{"opacity":"0.5"});
            $('#leftmenu ul').prepend('<li class="sibling">'+$('#leftmenu ul li:last').html()+'</li>');
            $('#leftmenu ul').stop().css({"top":"-50px"});
            $('#leftmenu ul li:last').remove();
            $('#leftmenu #up').one('click', up);
            //alert("js:up");
*/
            //$('#leftmenu ul').css({"top":"-50px"});
            
    		$('#leftmenu ul').prepend('<li>'+$('#leftmenu ul li:last').html()+'</li>');
    		
    		
    		//$('#leftmenu ul li:nth-child(7) img').css({"opacity":"1"});
    		//$('#leftmenu ul li:nth-child(6) img').css({"opacity":"1"});
    		$('#leftmenu ul li:nth-child(5) img').css({"height":"65px"});
    		$('#leftmenu ul li:nth-child(4) img').css({"height":"80px"});
    		$('#leftmenu ul li:nth-child(3) img').css({"height":"65px"});
    		$('#leftmenu ul li:nth-child(2) img').css({"height":"45px"});
    		$('#leftmenu ul li:nth-child(1) img').css({"height":"45px"});
    		
    		
    		$('#leftmenu ul li:last').remove();
    		$('#leftmenu ul').stop().css({"top":"-50px"});
    		$('#leftmenu #up').one('click', up);

		} else {
		    var animtime = 200;
        	$('#leftmenu ul').stop().animate({"top":"+=50px"}, { queue:true, duration:animtime, easing:""});
        	$('#leftmenu ul li:nth-child(7) img').stop().animate({"opacity":"0"}, { queue:true, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(6) img').stop().animate({"opacity":"0"}, { queue:true, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(5) img').stop().animate({"height":"45px"}, { queue:true, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(4) img').stop().animate({"height":"65px"}, { queue:true, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(3) img').stop().animate({"height":"80px"}, { queue:true, duration:animtime, easing:""});
    		$('#leftmenu ul li:nth-child(2) img').stop().animate({"height":"65px","opacity":"1"}, { queue:true, duration:animtime, easing:""});
    
    		$('#leftmenu ul li:nth-child(1) img').stop().css({"opacity":"0"});
    		$('#leftmenu ul li:nth-child(1) img').stop().animate({"opacity":"1"}, { queue:true, duration:animtime, easing:"", complete:function() {
			$('#leftmenu ul').stop().css({"top":"-50px"});
			$('#leftmenu #up').bind('click', up);
			$('#leftmenu ul').prepend('<li>'+$('#leftmenu ul li:last').html()+'</li>');
			$('#leftmenu ul li:last').remove();
          } });	
          }	
	}
	

/**********   MENU CAROUSEL END  ****************/

/**********   CAMPINGKIDS POST CHECK ****************/
$('.postverzenden').click( function(e) {
	e.preventDefault();
	var theForm = $(this).closest('form');
	var dag 	= $('select[name="geboortedag"]').val();
	var maand 	= $('select[name="geboortemaand"]').val();
	var jaar 	= $('select[name="geboortejaar"]').val();
	
	var datum = dag + '-' + maand + '-' +jaar;
	$(theForm).append('<input type="hidden" name="gbdatum" value="'+datum+'" />');
	var error = false;
	$('.required').each(function() {
		$('.ui-effects-wrapper').css({"display":"inline-block"});
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"})
				.effect("shake", { distance:2,times:4 }, 50)
			;
		}
	});

	if(!error)
	{
		$.getJSON('http://boeken.vacansoleil.com/relatie/savenwsbrf.pgm?callback=?', $('#postverzendenform').serialize(), function(data){
			if(data.response=='succes')
			{
				//stuur email naar ouders
				$.post('/lib/campingkids/post.php', $('#postverzendenform').serialize(), function(data){
				});
			}
			if(data=='duplicaat')
			{
				//doe niets
			}
			$('.postverzenden').remove();
			$('#postverzendenform').append('<div class="postverzendendone"><div id="sluiten"/></div>');
			$("#sluiten").css({"display":"block","top":"0", "right":"5px"});
								
		});


	}
	$(document).delegate("#sluiten",'click', function() {
		$(this).parent().hide(300);
	});
});
/**********   CAMPINGKIDS POST CHECK END ************/


/**********   CAMPINGKIDS OUDERS POST CHECK  ************/
$('.ouderspostverzenden').click( function(e) {
	e.preventDefault();
	var error = false;
	$('input.required').each(function() {
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"})
				.effect("shake", { distance:2,times:4 }, 50)
			;
		}
	});
	if(!error)
	{
		$('.postverzenden').remove();
		$.getJSON('http://boeken.vacansoleil.com/relatie/savenwsbrf.pgm?callback=?', $('#postverzendenform').serialize(), function(data){
			if(data.response=='succes')
			{
				$('#postverzendenoudersdone').show(100);
			}
			if(data.response=='duplicaat')
			{
				$('#postverzendenoudersduplicaat').show(100);
			}	
	
		});
		$('#postverzendenform').remove();
	}
});
/**********   CAMPINGKIDS OUDERS POST CHECK END ************/





/**********   ECARD CHECK ****************/
$('.ecardverzenden').click( function(e) {
	e.preventDefault();
	error = false;
	$('.required').each(function() {
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"})
				.effect("shake", { distance:2,times:4 }, 50)
			;
		}
	});
	if(!error)
	{
		$.post('/lib/campingkids/post.php',$("#ecardform").serialize(),function(data){
			if(data=='succes')
			{
				$('#ecard').html('Je E-card is verstuurd<br /><br /><div style="margin-left:55px"><img src="/static/sites/campingkids/images/decorators/correct.png" /></div>');
				$('#ecardtop').html('&nbsp;');
			}
		});
	}
	
});
/**********   ECARD CHECK END ************/


/**********   WATVOORCAMPINGKID ****************/

$("label img").live("click", function() {
	$("input").attr("checked", false);
	$(this).parent("label").find('input').attr("checked", true);
});

$('.intro .nextq').click( function() {
	$('#vragenwrapper').animate({"left":"-=540px"}, { queue:true, duration:200, easing:""});
});
$('.campingkidvraag .nextq').click( function() {
	var radio = $(this).parent().find('input[type="radio"]:checked');
	if($(radio).val()==undefined || $(radio).val()=='undefined')
	{
		alert('Kies een antwoord');
		$(radio).effect("shake", { distance:4,times:4,direction:'up' }, 75);
	}
	else
	{
		$('#vragenwrapper').animate({"left":"-=540px"}, { queue:true, duration:200, easing:""});
	}
});
$('.prevq').click( function() {
	$('#vragenwrapper').animate({"left":"+=540px"}, { queue:true, duration:200, easing:""});
});
$('.uitslag').click( function(){
	var antwoord1=0,antwoord2=0,antwoord3=0,antwoord4=0;
	for(i=1;i<=12;i++)
	{
		antwoord1 = ($('input[name=vraag'+i+']:checked').val()==1)?(antwoord1+1):antwoord1;
		antwoord2 = ($('input[name=vraag'+i+']:checked').val()==2)?(antwoord2+1):antwoord2;
		antwoord3 = ($('input[name=vraag'+i+']:checked').val()==3)?(antwoord3+1):antwoord3;
		antwoord4 = ($('input[name=vraag'+i+']:checked').val()==4)?(antwoord4+1):antwoord4;
	}
	$('.uitslagen li').css({"display":"none"});
	if(antwoord1>antwoord2 && antwoord1>antwoord3 && antwoord1>antwoord4) 
	{
		$('.uitslagen li:nth-child(1)').css({"display":"block"});
	}
	if(antwoord2>antwoord1 && antwoord2>antwoord3 && antwoord2>antwoord4) 
	{
		$('.uitslagen li:nth-child(2)').css({"display":"block"});
	}
	if(antwoord3>antwoord1 && antwoord3>antwoord2 && antwoord3>antwoord4) 
	{
		$('.uitslagen li:nth-child(3)').css({"display":"block"});
	}
	if(antwoord4>antwoord1 && antwoord4>antwoord2 && antwoord4>antwoord3) 
	{
		$('.uitslagen li:nth-child(4)').css({"display":"block"});
	}
});

$('.campingkidvraag label img').click(function() {
	$(this).closest('table').find('img').css({"opacity":"0.5"});
	$(this).css({"opacity":"1"});
	
});

/**********   WATVOORCAMPINGKID END ************/



/**********   FILMPJES   ****************/
$('#films li a').click(function(e){
	e.preventDefault();
	$('#films').hide();
	var src = $(this).attr('href');
	$('#film').show();
	$('#filmframe').attr('src', src);
	setTimeout("$('#sluiten').show()",500);
	
});

$('#sluiten').click(function(e){
	$('#film').hide();
	$('#sluiten').hide();
	$('#films').show();
	$('#filmframe').attr('src', '');
});
/**********   FILMPJES END   ************/


/**********   LIEDJES   ****************/
$('.minidisco li a').click(function(e){
	e.preventDefault();
	$('.minidisco').hide();
	$('.fullsongtekst').show().css({"overflow":"auto","height":"300px"});
	$('.tekst').append($(this).parent().find('.songtekst').html());
	$('.fullsongtekst .sluiten').css({"display":"block", "top":"70px", "right":"20px"});
});

$('.fullsongtekst .sluiten').click(function(e){
	$('.sluiten').hide();
	$('.fullsongtekst').hide();
	$('.fullsongtekst .tekst').html('');
	$('.minidisco').show();
});
/**********   LIEDJES END   ************/



/**********   LANDENLES   ****************/
$('.naarlandenles').click(function(){
	$(this).parent().parent().closest('div').fadeOut( 100, function(){$('.landenles').fadeIn(100) } );
});
$('.naarweetjes').click(function(){
	$(this).parent().parent().closest('div').fadeOut( 100, function(){$('.weetjes').fadeIn(100) } );
});
$('.naargerecht').click(function(){
	$(this).parent().parent().closest('div').fadeOut( 100, function(){$('.gerecht').fadeIn(100) } );
});
$('.naarbuitenspel').click(function(){
	$(this).parent().parent().closest('div').fadeOut( 100, function(){$('.buitenspel').fadeIn(100) } );
});
$('.naarwoordenlijst').click(function(){
	$(this).parent().parent().closest('div').fadeOut( 100, function(){$('.woordenlijst').fadeIn(100) } );
});

/**********   LANDENLES END   ************/


/**********   LANDENLES KAART   **************/
$('.landhover').mouseenter(function() {
	var href= $(this).attr('href');
	var spanje = new Array();
	spanje["x"] = "520";
	spanje["y"] = "470";
	spanje["width"] = "120";
	
	var frankrijk = new Array();
	frankrijk["x"] = "465";
	frankrijk["y"] = "532";
	frankrijk["width"] = "110";
	
	var italie = new Array();
	italie["x"] = "520";
	italie["y"] = "610";
	italie["width"] = "105";
	
	var zwitserland = new Array();
	zwitserland["x"] = "512";
	zwitserland["y"] = "607";
	zwitserland["width"] = "45";
	
	var oostenrijk = new Array();
	oostenrijk["x"] = "500";
	oostenrijk["y"] = "635";
	oostenrijk["width"] = "70";
	
	var duitsland = new Array();
	duitsland["x"] = "430";
	duitsland["y"] = "617";
	duitsland["width"] = "75";
	
	var denemarken = new Array();
	denemarken["x"] = "400";
	denemarken["y"] = "640";
	denemarken["width"] = "40";
	
	var belgie = new Array();
	belgie["x"] = "462";
	belgie["y"] = "595";
	belgie["width"] = "35";
	
	var luxemburg = new Array();
	luxemburg["x"] = "370";
	luxemburg["y"] = "608";
	luxemburg["width"] = "25";
	
	var nederland = new Array();
	nederland["x"] = "440";
	nederland["y"] = "595";
	nederland["width"] = "45";
	
	var land = $(this).attr('class');
	land = land.replace('landhover ', '');
	var landarr = new Array();
	eval('var x = '+land+'["x"]');
	eval('var y = '+land+'["y"]');
	eval('var width = '+land+'["width"]');
	// correction for page positioning
	var x = x-372;
	var y = y-462;
	if($.browser.msie)
	{
		x+=64;
	}
	var src='/static/uploads/sites/campingkids/core/country-information/'+land+'.png';
	$('#land').attr('src', src);
	$('#land').css({'top':x + "px", 'left':y + "px", 'width':width});
	$('#land').click(function() {
		window.location.href= href;
	});
});

/**********   LANDENLES KAART END ************/


/**********   MAIL ITEM NAAR OUDERS  *****************/
$('#mailnaarouders img').click( function() {
	$('#mailoudersform').show(150, "cubicEaseOut");
});
$('#mailoudersform .sluiten').click( function() {
	$('#mailoudersform').hide(150, "backEaseIn");
});
$('.mailnaarouders').click( function(e) {
	e.preventDefault();
	var error=false;
	$('input.required').each(function() {
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"})
				.effect("shake", { distance:2,times:4 }, 50);
		}
	});
	if(!error)
	{
		$.post('/lib/campingkids/post.php', $('#bestelformulier').serialize(), 
			function(data){
				if(data=='succes')
				{
					$('#mailoudersform form').html('<div style="margin:20px 0 0 25px;"><h2>Email is verstuurd!</h2></div>');
				}
			});
	}
});

/**********   MAIL ITEM NAAR OUDERS END   ************/

/**********   BESTELLEN  *****************/
$('#bestellen img').click( function() {
	$('#bestelform').show(150, "cubicEaseOut");
	pageTracker._trackPageview('/webshop/order/form');
});
$('#bestelform .sluiten').click( function() {
	$('#bestelform').hide(150, "backEaseIn");
});
$('.dobestellen').click( function(e) {
	e.preventDefault();
	var error=false;
	
	$('input[type="text"].required').each(function() {
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"});
		}
	});
	$('input[type="checkbox"].required').each(function() {
		$(this).parent().css({"background-color":"transparent"});
		if(! $(this).is(":checked"))
		{
			error = true;
			$(this).parent().css({"background-color":"#F66"});
		}
	});
	if(!error)
	{
		$.post('/lib/campingkids/post.php', $('#bestelformulier').serialize(), 
			function(data){
				if(data=='succes')
				{
				    pageTracker._trackPageview('/webshop/order/confirmed');
					$('#bestelform form').html('<div style="margin:20px 0 0 25px;"><h1>Hartelijk dank</h1><h2>Uw bestelling is correct aangekomen!</h2></div>');
				}
			});
	}
});

/**********   BESTELLEN END   ************/



/**********   MEER INFO OVER CAMPING ******************/
$('.meerinfo').click(function() {
	var elem = $(this).parent();
	scrollposition = parseInt($(".jspPane").css('top'), 10);
	scrollposition = Math.abs(scrollposition);
	newposition = scrollposition+50;
	$("#cpi #campingdivs > img").attr('src', $(elem).find('img').attr('src'));
	var camping = $(elem).find('img').attr('alt');//.replace(/\*/gi,'');
	$("#cpi .camping").html(camping);
	$("#cpi .plaats").html($(elem).find('.plaats').html());
	$("#cpi .sfeertext").html($(elem).find('.sfeertext').html());
	$("#cpi").css( 'top', newposition+'px');
	$("#cpi, #sluiten").show(250);

	var rlco =  $("#campingdivs img").attr('src');
	rlco = rlco.match(/[0-9]{7}/);
	rlco = 'http://www.vacansoleil.nl/camping/info/VAC/1/'+rlco[0]+'/';
	$('input[name=cpipage]').attr('value', rlco);
});


var cpiform = $('#cpiform').html();
$("#cpi #sluiten").click(function() {
	$(this).parent().hide(250);
	$('#cpiform').html(cpiform);
	Cufon.refresh();
	$("#campingdivs").show(100,function(){ $("#cpimailouderform").hide(250); });
});


$(".cpimailnaarouders img").click(function(){
	$(this).parent().parent().hide(100,function(){ $("#cpimailouderform").show(250); });	
});


$("#cpimailouderform").delegate(".cpimailnaaroudersimg", "click", function(e) {
	e.preventDefault();
	var error=false;
	$('input.required').each(function() {
		$(this).css({"border":"1px solid #000"});
		if(!$(this).val())
		{
			error = true;
			$(this)
				.css({"border":"1px solid #F00"})
				.effect("shake", { distance:2,times:4 }, 50);
		}
	});
	if(!error)
	{
		$.post('/lib/campingkids/post.php', $('#cpiform').serialize(), 
			function(data){
				if(data=='succes')
				{
                    pageTracker._trackPageview('/newsletter/request/completed');
					$('#cpiform').html('<div style="margin:20px 0 0 25px;"><h2>Email is verstuurd!</h2></div>');
				}
			});
	}
});

/**********   MEER INFO OVER CAMPING END   ************/

////////END///////
});




// KONAMI CODE!!!
var Konami=function(){var a={addEvent:function(b,c,d,e){if(b.addEventListener)b.addEventListener(c,d,false);else if(b.attachEvent){b["e"+c+d]=d;b[c+d]=function(){b["e"+c+d](window.event,e)};b.attachEvent("on"+c,b[c+d])}},input:"",pattern:"38384040373937396665",load:function(b){this.addEvent(document,"keydown",function(c,d){if(d)a=d;a.input+=c?c.keyCode:event.keyCode;if(a.input.length>a.pattern.length)a.input=a.input.substr(a.input.length-a.pattern.length);if(a.input==a.pattern){a.code(b);a.input=
""}},this);this.iphone.load(b)},code:function(b){window.location=b},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:false,capture:false,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){orig_keys=this.keys;a.addEvent(document,"touchmove",function(c){if(c.touches.length==1&&a.iphone.capture==true){c=c.touches[0];a.iphone.stop_x=c.pageX;a.iphone.stop_y=c.pageY;a.iphone.tap=false;a.iphone.capture=false;a.iphone.check_direction()}});
a.addEvent(document,"touchend",function(){a.iphone.tap==true&&a.iphone.check_direction(b)},false);a.addEvent(document,"touchstart",function(c){a.iphone.start_x=c.changedTouches[0].pageX;a.iphone.start_y=c.changedTouches[0].pageY;a.iphone.tap=true;a.iphone.capture=true})},check_direction:function(b){x_magnitude=Math.abs(this.start_x-this.stop_x);y_magnitude=Math.abs(this.start_y-this.stop_y);x=this.start_x-this.stop_x<0?"RIGHT":"LEFT";y=this.start_y-this.stop_y<0?"DOWN":"UP";result=x_magnitude>y_magnitude?
x:y;result=this.tap==true?"TAP":result;if(result==this.keys[0])this.keys=this.keys.slice(1,this.keys.length);if(this.keys.length==0){this.keys=this.orig_keys;this.code(b)}}}};return a};


konami = new Konami();
konami.code = function() {
	$('body>*').css({"opacity":"0.05"});
	$('body').prepend('<div id="konami"/>');
	$('#konami').show(1000, 
		function() {
			$('#konami').delay(3000).hide(1000, 
				function(){ 
					$('body>*').css({"opacity":"1"}); 
				});
		});
	
};
konami.load();


