function currentNav(section) { $('#' +section).addClass('current'); }

$(document).ready(function() {
	
	// MENU HOVER
	$("#menu img, #leukelinks img").each(function () {
		rollsrc = $(this).attr("src");
		rollON = rollsrc.replace(/.png$/gi, "-hover.png");
		$("<img>").attr("src", rollON);
	});

	$("#menu a, #leukelinks a").mouseover(function () {
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/-hover/);
		if (!matches) {
			imgsrcON = imgsrc.replace(/.png$/gi, "-hover.png");
			$(this).children("img").attr("src", imgsrcON);
		}
	});

	$("#menu a, #leukelinks a").mouseout(function () {
		$(this).children("img").attr("src", imgsrc);
	});
		
	// REFERENTIES CAROUSEL	
	if ( $("#front").length != 0 ) {
		myAnimSpeed = 800; //if ($.browser.msie) { myAnimSpeed = 1; }
		$(".carousel").carousel({ animSpeed: myAnimSpeed, loop: true, autoSlide: true, delayAutoSlide: 1500, autoSlideInterval: 4500 });
	}
	
	// UITKLAPPER
	$("h4").prepend('&raquo; ');
	$("h4").next().css("padding-left","10px");
	$("h4").next("ol,ul").css("padding-left","20px");
	$("h4").next().hide();
	$("h4").click(function(){ 
		if( $(this).next().is(':visible') ) {
			$(this).next().slideToggle('fast'); 
		}
		else {
			$("h4").next().slideUp('fast');
			$(this).next().slideToggle('fast'); 
		}
	});
	

	// INSCHRIJFFORMULIER OUDERS	
	if ( $(".wpcf7-form").length != 0 ) {
		
		function oudersButtons($aantal) {
			if($aantal < 2) { $('#ouders .addButton').show(); $('#ouders .delButton').hide(); } 
			else if ($aantal > 1) { $('#ouders .addButton').hide(); $('#ouders .delButton').show(); }	
		}
		
		function kinderenButtons($aantal) {
			$('#kinderen .addButton').hide(); $('#kinderen .delButton').hide();
			if($aantal < 5) { $('#kinderen .addButton').show(); } 
			if ($aantal > 1) { $('#kinderen .delButton').show(); }	
		}
		
		function dataButtons($aantal) {
			$('#wanneernodig .addButton').hide(); $('#wanneernodig .delButton').hide();
			if($aantal < 3) { $('#wanneernodig .addButton').show(); } 
			if ($aantal > 1) { $('#wanneernodig .delButton').show(); }	
		}
		
		$kids = 1; $ouders = 2; $data = 1;
		oudersButtons($ouders); kinderenButtons($kids); dataButtons($data);
		
		$('#ouder' +$ouders).addClass('noborder');
		$('#kind' +$kids).addClass('noborder');

		$('#ouders .addButton').click(function() {
			$ouders ++; $('#ouder' +$ouders).show();
			oudersButtons($ouders); $('#ouders .itemsep2').removeClass('noborder'); $('#ouder' +$ouders).addClass('noborder');
		});
		
		$('#ouders .delButton').click(function() {
			$('#ouder' +$ouders).hide(); $('#ouder' +$ouders+ ' input').attr("value",""); $ouders --;
			oudersButtons($ouders); $('#ouders .itemsep2').removeClass('noborder'); $('#ouder' +$ouders).addClass('noborder');
		});
		
		$('#kinderen .addButton').click(function() { 
			$kids ++; $('#kind' +$kids).show(); 
			kinderenButtons($kids); $('#kinderen .itemsep2').removeClass('noborder'); $('#kind' +$kids).addClass('noborder');
		});
		
		$('#kinderen .delButton').click(function() { 
			$('#kind' +$kids).hide(); $('#kind' +$kids+ ' input').attr("value",""); $('#kind' +$kids+ ' input[type="radio"]').attr("checked", false); $kids --; 
			kinderenButtons($kids); $('#kinderen .itemsep2').removeClass('noborder'); $('#kind' +$kids).addClass('noborder');
		});
		
		$('#wanneernodig .addButton').click(function() { 
			$data ++; $('#datum' +$data).show(); 
			dataButtons($data); $('#wanneernodig .itemsep2').removeClass('noborder'); $('#datum' +$data).addClass('noborder');
		});
		
		$('#wanneernodig .delButton').click(function() { 
			$('#datum' +$data).hide(); $('#datum' +$data+ ' input').attr("value",""); $('#datum' +$data+ ' select').attr("value","---"); $data --; 
			dataButtons($data); $('#wanneernodig .itemsep2').removeClass('noborder'); $('#datum' +$data).addClass('noborder');
		});
		/*
			$('#wanneernodig .delButton').click(function() { 
			$('#datum' +$data).hide(); $('#datum' +$data+ ' input').attr("value",""); $('#datum' +$data+ ' select').attr("value","00"); $data --; 
			dataButtons($data); $('#wanneernodig .itemsep2').removeClass('noborder'); $('#datum' +$data).addClass('noborder');
		});
		*/
		
		$('input[name$="stad"]').change(function() {
			$value = $(this).attr("value");
			switch($value){
				case 'Utrecht': $('input[name$="hiddenstad"]').attr("value", "utrecht"); $('input[name$="hiddenafzender"]').attr("value", "Freekje."); $kees = 'utr'; break;
				default: $('input[name$="hiddenstad"]').attr("value", "info"); $('input[name$="hiddenafzender"]').attr("value", "Lotte en Anne."); $kees = 'asd';
			}
		});	
	
	}
	
	
	$(".wpcf7-form").FormNavigate({
		message: "Het formulier op deze pagina is al gedeeltelijk ingevuld. \n Weet u zeker dat u deze pagina wilt verlaten? \n \n The form has been partially filled in. \n Are you sure you want to leave this page?" ,
		aOutConfirm: "#menu a, #extramenu a, #title a"
	});	


	// REFERENTIEFORM
	//if ( $(".referenties").length != 0 ) {
		$('#referentieformulier').hide();
		$('#referentieButton').click(function() {
			$('#referentieformulier').slideToggle('fast');
		});
	//}
	
	

				
	// BETAALFORMULIER

	if ( $("#betalenForm").length != 0 ) {

		//vars
		var ouderWat;
		//var ouderHoevaak;
		var stad;
		var rekening;	
		
		//routing
		function hideCheckout() { $('#checkout, #checkoutideal, #checkoutincasso, #checkoutoverschrijven, #checkoutmail').hide(); }
		
		$('#betalenForm .button').click(function() {
			$(this).siblings().addClass('disabled');
			$(this).parent().next(".item").children().addClass('disabled');
			$(this).removeClass('disabled');
		});
		
		$('#AmsterdamOfUtrecht .button').click(function() {
			$('.studentItem, .ouderItem').hide(); hideCheckout();
			$('#studentOfOuder').show();
		});
		
		$('#ikBenOuder').click(function() {
			$('.studentItem').hide(); hideCheckout();
			$('#ouderWat').show();
		});
		
		$('#ouderInschrijfgeld').click(function() {
			$('#ouderPoetsstudent, #ouderLidmaatschapHoe').hide(); hideCheckout();
			$('#ouderPoetsstudent').show();
			ouderWat = 'ouderInschrijfgeld';
		});
		
		$('#ouderInschrijfgeldLidmaatschap').click(function() {
			$('#ouderPoetsstudent, #ouderZojuistHoe, #ouderLidmaatschapHoe').hide(); hideCheckout();
			$('#ouderPoetsstudent').show();
			ouderWat = 'ouderInschrijfgeldLidmaatschap';
		});	
		
		$('#ouderLidmaatschap').click(function() {
			$('#ouderPoetsstudent, #ouderZojuistHoe').hide(); hideCheckout();
			$('#ouderLidmaatschapHoe').children().addClass('disabled');
			$('#ouderLidmaatschapHoe').show();
			ouderWat = 'ouderLidmaatschap';
		});
		
		$('#ouderPoetsstudent').click(function() {
			 hideCheckout();
			$('#ouderZojuistHoe').show();
		});	
		
		$('#ikBenStudent').click(function() {
			$('.ouderItem').hide(); hideCheckout();
			$('#studentPoetsstudent').show();
		});
		
		$('#studentPoetsstudent .button').click(function() {
			 hideCheckout();
			$('#studentHoe').show();
		});
	
		//checkout
		$('#ouderLidmaatschapHoeIncasso').click(function() {
			hideCheckout();
			$('#checkout, #checkoutmail, #checkoutincasso').show();
		});
	
		$('#studentHoeOverschrijven, #ouderZojuistHoeOverschrijven, #ouderLidmaatschapHoeOverschrijven').click(function() {
			hideCheckout();
			$('#checkout, #checkoutmail, #checkoutoverschrijven').show();
		});
		
		$('#studentHoeIdeal, #ouderZojuistHoeIdeal, #ouderLidmaatschapHoeIdeal').click(function() {
			hideCheckout();
			$('#checkout, #checkoutideal').show();
		});
		
		
		//set values
		
		//AmsterdamOfUtrecht
			//ikBetaalVoorAmsterdam
			$('#ikBetaalVoorAmsterdam').click(function() {
				$("input[name=hiddenstad]").val("Amsterdam");
				$("input[name=hiddenafzender]").val("Lotte en Anne.");
				stad = 'Amsterdam';
			
				$("input[name=merchantID]").val("002028621");		
			
				$("#checkout #stad").html("");
				$("input[name=stad]").val("");
				$("#checkout #rekening").html("1551.37.506");
				$("input[name=rekening]").val("1551.37.506");
				rekening = '1551.37.506';
			});
			
			//ikBetaalVoorUtrecht
			$('#ikBetaalVoorUtrecht').click(function() {
				$("input[name=hiddenstad]").val("Utrecht");
				$("input[name=hiddenafzender]").val("Freekje.");
				stad = 'Utrecht';
			
				$("input[name=merchantID]").val("002040526");		
			
				$("#checkout #stad").html("Utrecht");
				$("input[name=stad]").val("Utrecht");
				$("#checkout #rekening").html("1550.14.277");
				$("input[name=rekening]").val("1550.14.277");
				rekening = '1550.14.277';
			});
			
			//ikBetaalVoorHaarlem
			$('#ikBetaalVoorHaarlem').click(function() {
				$("input[name=hiddenstad]").val("Haarlem");
				$("input[name=hiddenafzender]").val("Lotte en Anne.");
				stad = 'Haarlem';
			
				$("input[name=merchantID]").val("002028621");		
			
				$("#checkout #stad").html("");
				$("input[name=stad]").val("");
				$("#checkout #rekening").html("1551.37.506");
				$("input[name=rekening]").val("1551.37.506");
				rekening = '1551.37.506';
			});
		
		//ouder Lidmaatschap
		$('#ouderLidmaatschap').click(function() {
			$("input[name=description]").val("OppasStudent Lidmaatschap Ouder");		
	
			$("input[name=itemNumber1]").val("11");		
			$("input[name=amount], input[name=itemPrice1]").val("6600");
		
			$("#checkout #omschrijving").html("OppasStudent Lidmaatschap Ouder");
			$("#checkout #bedrag").html("&euro; 66,-");
			$("input[name=bedrag]").val("&euro; 66,-");		
		});
		
		$('#ouderLidmaatschapHoeIncasso').click(function() {
			$("#checkout #bedrag").html("&euro; 5,50 per maand");
			$("input[name=bedrag]").val("&euro; 5,50 per maand");
		});		
		
		$('#ouderLidmaatschapHoeOverschrijven, #ouderLidmaatschapHoeIdeal').click(function() {
			$("#checkout #bedrag").html("&euro; 66,-");
			$("input[name=bedrag]").val("&euro; 66,-");	
		});	
			
			
		//ouder inschrijving
		
			//ouderNietPoetsstudent
			$('#ouderNietPoetsstudent').click(function() {
				$("input[name=description]").val("OppasStudent Registratie Ouder");
				$("#checkout #omschrijving").html("OppasStudent Registratie Ouder");
	
				if (ouderWat == 'ouderInschrijfgeldLidmaatschap') {
					$("input[name=itemNumber1]").val("18");		
					$("input[name=amount], input[name=itemPrice1]").val("8600");
					$("#checkout #bedrag").html("&euro; 86,-");
					$("input[name=bedrag]").val("&euro; 86,-");	
					
				}; 
				if (ouderWat == 'ouderInschrijfgeld') {
					$("input[name=itemNumber1]").val("08");		
					$("input[name=amount], input[name=itemPrice1]").val("2000");
					$("#checkout #bedrag").html("&euro; 20,-");
					$("input[name=bedrag]").val("&euro; 20,-");						
				}; 			
			});
			
			//ouderOokPoetsstudent
			$('#ouderOokPoetsstudent').click(function() {
				$("input[name=description]").val("OppasStudent Registratie Ouder");
				$("#checkout #omschrijving").html("OppasStudent Registratie Ouder (met korting)");
			
				if (ouderWat == 'ouderInschrijfgeldLidmaatschap') {
					$("input[name=itemNumber1]").val("19");		
					$("input[name=amount], input[name=itemPrice1]").val("7600");
					$("#checkout #bedrag").html("&euro; 76,-");
					$("input[name=bedrag]").val("&euro; 76,-");						
				}; 
				if (ouderWat == 'ouderInschrijfgeld') {
					$("input[name=itemNumber1]").val("09");		
					$("input[name=amount], input[name=itemPrice1]").val("1000");
					$("#checkout #bedrag").html("&euro; 10,-");
					$("input[name=bedrag]").val("&euro; 10,-");						
				}; 			
			});
				
		
		//student inschrijving
			//studentNietPoetsstudent
			$('#studentNietPoetsstudent').click(function() {
				$("input[name=description]").val("OppasStudent Registratie Student");
			
				$("input[name=itemNumber1]").val("21");		
				$("input[name=amount], input[name=itemPrice1]").val("1500");
			
				$("#checkout #omschrijving").html("OppasStudent Registratie Student");
				$("#checkout #bedrag").html("&euro; 15,-");
				$("input[name=bedrag]").val("&euro; 15,-");
			});
			
			//studentOokPoetsstudent
			$('#studentOokPoetsstudent').click(function() {
				$("input[name=description]").val("OppasStudent Registratie Student");
			
				$("input[name=itemNumber1]").val("22");		
				$("input[name=amount], input[name=itemPrice1]").val("1000");
			
				$("#checkout #omschrijving").html("OppasStudent Registratie Student (met korting)");
				$("#checkout #bedrag").html("&euro; 10,-");
				$("input[name=bedrag]").val("&euro; 10,-");
			});	
			
			
			//mails		
			$('#ouderLidmaatschapHoeIncasso').click(function() {
				$("input[name=hoe]").val("Automatische Incasso");
				$("input[name=mailuitleg]").val("Dit bedrag zal vanaf de eerste dag van de eerstvolgende maand maandelijks van je rekening worden afgeschreven.");
			});	
	
			$('#studentHoeOverschrijven, #ouderLidmaatschapHoeOverschrijven, #ouderZojuistHoeOverschrijven').click(function() {
				$("input[name=hoe]").val("Overschrijven");
				$("input[name=mailuitleg]").val("Zelf overschrijven naar: OppasStudent " + stad + ". Bankrekeningnummer: " + rekening + " te Amsterdam (Rabobank). Zodra wij het bedrag op onze rekening ontvangen hebben, is de inschrijving compleet.");
			});	


	}
		
	
	// ALGMENE VOORWAARDEN BOX
	$('#scroll-pane').jScrollPane({showArrows:true, scrollbarWidth: '12'});
	
	$("#algemenevoorwaardenBox").draggable({ containment: 'html' });
	$("#algemenevoorwaardenBoxKnop").click(function () {
		$top = $(this).position().top - $("#algemenevoorwaardenBox").height();
		$("#algemenevoorwaardenBox").css("top",""+$top+"px"); 
		$("#algemenevoorwaardenCloser").css("display","block"); 
	});
	
	$(".close").click(function () { 
		$(this).parent().css("top","-2000px"); 
		$("#algemenevoorwaardenCloser").css("display","none"); 
	});
	
	$("#algemenevoorwaardenCloser").click(function () { 
		$("#algemenevoorwaardenBox").css("top","-2000px"); 
		$(this).css("display","none"); 
	});
	
});

