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","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."); break;
				default: $('input[name$="hiddenstad"]').attr("value", "info"); $('input[name$="hiddenafzender"]').attr("value", "Lotte en Anne.");
			}
		});			
			
	}

	
	$(".wpcf7-form").FormNavigate({
		message: "Het formulier op deze pagina is al gedeeltelijk ingevuld. \n \n Weet u zeker dat u deze pagina wilt verlaten? \n" ,
		aOutConfirm: "#menu a, #extramenu a, #title a"
	});	


	// REFERENTIEFORM
	if ( $(".referenties").length != 0 ) {
		$('#referentieformulier').hide();
		$('#referentieButton').click(function() {
			$('#referentieformulier').slideToggle('fast');
		});
	}
	
	// IDEALFORM
	$('#iDealForm .button').click(function() {
		$(this).siblings().addClass('disabled');
		$(this).parent().next(".item").children().addClass('disabled');

		$(this).removeClass('disabled');
	});
	
	$('#AmsterdamOfUtrecht .button').click(function() {
		$('.studentItem, .ouderItem, #checkout').hide();
		$('#studentOfOuder').show();
	});
		
	$('#ikBenOuder').click(function() {
		$('.studentItem, #checkout').hide();
		$('#ouderInschrijfgeldLidmaatschap').show();
	});
	
	$('#ouderLidmaatschap').click(function() {
		$('#ouderPoetsstudent').hide();
	});
	
	$('#ouderInschrijfgeld').click(function() {
		$('#checkout').hide();
		$('#ouderPoetsstudent').show();
	});
	
	$('#ikBenStudent').click(function() {
		$('.ouderItem, #checkout').hide();
		$('#studentPoetsstudent').show();
	});
	
	$('#ouderPoetsstudent .button, #ouderVaakPoetsstudent .button, #studentPoetsstudent .button, #ouderLidmaatschap').click(function() {
		$('#checkout').show();
	});
	
	
	//set values
	$('#ikBetaalVoorAmsterdam').click(function() {
		$("input[name=merchantID]").val("002028621");		
	});
	
	$('#ikBetaalVoorUtrecht').click(function() {
		$("input[name=merchantID]").val("002040526");		
	});
	
	$('#ouderLidmaatschap').click(function() {
		$("input[name=itemNumber1]").val("43");		
		$("input[name=amount], input[name=itemPrice1]").val("1000");
		$("input[name=description]").val("PoetsStudent Lidm. Huishouden");
		$("#checkout #omschrijving").html("PoetsStudent Lidmaatschap Huishouden");
		$("#checkout #bedrag").html("&euro; 10,-");
	});
	
	$('#ouderOokPoetsstudent').click(function() {
		$("input[name=itemNumber1]").val("42");		
		$("input[name=amount], input[name=itemPrice1]").val("1000");
		$("input[name=description]").val("PoetsStudent Registr. Huishouden");
		$("#checkout #omschrijving").html("PoetsStudent Registratie Huishouden (met korting)");
		$("#checkout #bedrag").html("&euro; 10,-");
	});
	
	$('#ouderNietPoetsstudent').click(function() {
		$("input[name=itemNumber1]").val("41");		
		$("input[name=amount], input[name=itemPrice1]").val("2000");
		$("input[name=description]").val("PoetsStudent Registr. Huishouden");
		$("#checkout #omschrijving").html("PoetsStudent Registratie Huishouden");
		$("#checkout #bedrag").html("&euro; 20,-");
	});
	
	$('#studentOokPoetsstudent').click(function() {
		$("input[name=itemNumber1]").val("52");		
		$("input[name=amount], input[name=itemPrice1]").val("1000");
		$("input[name=description]").val("PoetsStudent Registratie Student");
		$("#checkout #omschrijving").html("PoetsStudent Registratie Student (met korting)");
		$("#checkout #bedrag").html("&euro; 10,-");
	});
	
	$('#studentNietPoetsstudent').click(function() {
		$("input[name=itemNumber1]").val("51");		
		$("input[name=amount], input[name=itemPrice1]").val("1500");
		$("input[name=description]").val("PoetsStudent Registratie Student");
		$("#checkout #omschrijving").html("PoetsStudent Registratie Student");
		$("#checkout #bedrag").html("&euro; 15,-");
	});
	
	
	// 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"); 
	});
	
	

});

