﻿//Switchbox nieuws op homepage

function doNothing(){}

function checkNummers(waarde, myfield, e, dec)
{
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if (((waarde).indexOf(keychar) > -1))
	   return true;
	
	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}


$(document).ready(function(){

	$("a[href^='http']").attr('target','_blank');


if ($('h1:contains("Dave")').length > 0) {
    
}



//Foto slider in header home
	$("#makeMeScrollable .scrollingHotSpotLeft a").click(function() {
		if($(".scrollableArea").css("left") == "-320px" || $(".scrollableArea").css("left") == "-640px"|| $(".scrollableArea").css("left") == "-960px" || $(".scrollableArea").css("left") == "-1280px" || $(".scrollableArea").css("left") == "-1600px") {										 
			$(".scrollableArea").animate({
			left: '+=320'
			}, 500, function() {
				
				if ($(this).css("left") == "0px"){
					$(".scrollingHotSpotLeft a").fadeOut("fast");	
				} 
				
				$(".scrollingHotSpotRight a").fadeIn("fast");			
			});
		}
		
		return false;
		
	});



	$("#makeMeScrollable .scrollingHotSpotRight a").click(function() {									 
												 
		if($(".scrollableArea").css("left") == "auto" || $(".scrollableArea").css("left") == "0px" || $(".scrollableArea").css("left") == "-320px" || $(".scrollableArea").css("left") == "-640px"|| $(".scrollableArea").css("left") == "-960px" || $(".scrollableArea").css("left") == "-1280px") {										 
			$(".scrollableArea").animate({
			left: '-=320'
			}, 500, function() {
				
				if ($(this).css("left") == "-320px"){
					$(".scrollingHotSpotLeft a").fadeIn("fast");	
				}	
				
				if ($(this).css("left") == "-1600px"){
					$(".scrollingHotSpotRight a").fadeOut("fast");	
				}				
			});
		}
		
		return false;
	});
	
	
//Foto slider in header detail
	$("#makeMeScrollable2 .scrollingHotSpotLeft a").click(function() {
		if($("#makeMeScrollable2 .scrollableArea").css("left") == "-160px" || $("#makeMeScrollable2 .scrollableArea").css("left") == "-320px") {										 
			$("#makeMeScrollable2 .scrollableArea").animate({
			left: '+=160'
			}, 500, function() {
				
				if ($(this).css("left") == "0px"){
					$(".scrollingHotSpotLeft a").fadeOut("fast");	
				} 
				
				$(".scrollingHotSpotRight a").fadeIn("fast");			
			});
		}
		
		return false;
		
	});



	$("#makeMeScrollable2 .scrollingHotSpotRight a").click(function() {								 
												 
		if($("#makeMeScrollable2 .scrollableArea").css("left") == "auto" || $("#makeMeScrollable2 .scrollableArea").css("left") == "0px" || $("#makeMeScrollable2 .scrollableArea").css("left") == "-160px") {										 
			$("#makeMeScrollable2 .scrollableArea").animate({
			left: '-=160'
			}, 500, function() {
				
				if ($(this).css("left") == "-160px"){
					$(".scrollingHotSpotLeft a").fadeIn("fast");	
				}	
				
				if ($(this).css("left") == "-320px"){
					$(".scrollingHotSpotRight a").fadeOut("fast");	
				}				
			});
		}
		
		return false;
	});
	

//Opacity change foto's
	
	
	//fix voor IE
	$(".scrollableArea img").animate({
		opacity: 0.20
		}, 0, function() {
		// Animation complete.
	});
	
	$(".scrollableArea img.active").animate({
		opacity: 1
		}, 0, function() {
		// Animation complete.
	});	
	//
	
	//Img actives
	
		if ($('h1:contains("Chanelfa")').length > 0) {
			$("img#chanelfa").addClass("active");
		}	
		else
		{
			if ($('h1:contains("Alexander")').length > 0) {
				$("img#alexander").addClass("active");
			}
			else
			{
			if ($('h1:contains("Thomas")').length > 0) {
				$("img#thomas").addClass("active");
				}
				else
				{
				if ($('h1:contains("Huissen")').length > 0) {
					$("img#juliette").addClass("active");
					}
					else
					{
						if ($('h1:contains("Jamie")').length > 0) {
							$("img#jamie").addClass("active");
						}
						else
						{
							if ($('h1:contains("Niek")').length > 0) {
								$("img#niek").addClass("active");
							}
							else
							{
								if ($('h1:contains("Jaleesa")').length > 0) {
									$("img#jaleesa").addClass("active");
									$("#makeMeScrollable2 .scrollableArea").css("left","-160px");
									$(".scrollingHotSpotLeft a").show();			
								}
								else
								{
									if ($('h1:contains("Dave")').length > 0) {
										$("img#dave").addClass("active");
										$("#makeMeScrollable2 .scrollableArea").css("left","-320px");
										$(".scrollingHotSpotLeft a").show();
										$(".scrollingHotSpotRight a").hide();		
									}	
									else
									{
										$("img#chanelfa").addClass("active");
									}
								}
							}
						}
					}
				}
			}
		}

	





	//
	
	if($(".scrollableArea img").hasClass("active")) {
		$(".scrollableArea img.active").animate({"opacity" : 1}, 0);	
	}
				
	else {
		$("#.scrollableArea img").animate({"opacity" : .2}, 400);
	}
	
	$(".scrollableArea img").mouseenter(function() {
		if (!($(this).attr("class") =="active")){												  
			$(this).stop().animate({"opacity" : 1}, 400);
			$(".scrollableArea img.active").animate({"opacity" : .2}, 400);
			$(".scrollableArea img.active").removeClass("active");
			$(this).addClass("active")
		}
	});
	
	$(".scrollableArea img").mouseout(function() {
		if (!($(this).attr("class") =="active")){
			$(this).stop().animate({"opacity" : .2}, 400);
		}
	});	
	
	
	
	
	
/*	$("#makeMeScrollable img").hover(function() {

	
		if($(this).hasClass("active")) {
			$(this).animate({
				opacity: 1
				},400, function() {
				// Animation complete.
			});
		}
		
		else {
			$(this).animate({
				opacity: 1
				},400, function() {
				// Animation complete.
			});
			
			$("#makeMeScrollable img.active").animate({
			opacity: 0.20
				}, 400, function() {
				// Animation complete.
			});
		}
	});
	*/	

//Nieuws en actie toggle

	$('a#button-acties').click(function(){
		$('.nieuwsberichten ul').hide();
		$('.actieberichten ul').show();
		$(this).removeClass("inactive");
		$(this).addClass("active");
		$("a#button-nieuws").removeClass("active");
		$("a#button-nieuws").addClass("inactive");
		Cufon.refresh();
	});
	  
	$('a#button-nieuws').click(function(){
		$('.actieberichten ul').hide();
		$('.nieuwsberichten ul').show();
		$(this).removeClass("inactive");
		$(this).addClass("active");
		$("a#button-acties").removeClass("active");
		$("a#button-acties").addClass("inactive");
		Cufon.refresh();
	});

//501 dropdown

	$("ul.main-nav").superfish({ 
	    delay:       800,                               // 0 second delay on mouseout 
	    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
	    autoArrows:  true,                            // enable generation of arrow mark-up 
	    dropShadows: false                            // disable drop shadows 
	});


//Accordion menu

	$('#accordion-menu li.submenu').click(function(){
		if ($(this).children('ul').css("display") == "none")
		{
				//$('#accordion-menu li ul').hide();
				$(this).children('ul').slideDown('normal');
		}
	});

	
	function openSubmenu()
	{
	
		if ($(this).children('ul').css("display") == "none")
			{
				
				//slideup or hide all the Submenu  
				$('#accordion-menu li').children('ul').slideUp('normal');
				
				//show the selected submenu  
				$(this).children('ul').slideDown('normal');
			}	
 	}


//Form functions

	$('#donateur-15').change(function() {
	   // assign the value to a variable, so you can test to see if it is working
	    var selectVal = $('#donateur-15 :selected').val();
	    
	    if (selectVal == "anders") {
			$("form fieldset ul li.hidden").show();
			$("ul li.hidden input").attr("disabled", "");
	    }    
	    
	    else {
			$("form fieldset ul li.hidden").hide();	
	    }
	});

	$('#donateur-wijziging-14').change(function() {
	   // assign the value to a variable, so you can test to see if it is working
	    var selectVal = $('#donateur-wijziging-14 :selected').val();
	    
	    if (selectVal == "anders") {
			$("form fieldset ul li.hidden").show();
	    }    
	    
	    else {
			$("form fieldset ul li.hidden").hide();	
	    }
	});
	
	$('#actie-01').change(function() {
	   // assign the value to a variable, so you can test to see if it is working
	    var selectVal = $('#actie-01 :selected').val();
	    
	    if (selectVal == "anders") {
			$("form fieldset ul li.hidden").show();
			$("ul li.hidden input").attr("disabled", "");			
	    }    
	    
	    else {
			$("form fieldset ul li.hidden").hide();	
			$("ul li.hidden input").attr("disabled", "disabled");	
	    }
	});

	$('#wenskind-37').change(function() {
	   // assign the value to a variable, so you can test to see if it is working
	    var selectVal = $('#wenskind-37 :selected').val();
	    
	    if (selectVal == "anders") {
			$("form fieldset ul li.hidden").show();
	    }    
	    
	    else {
			$("form fieldset ul li.hidden").hide();	
	    }
	});


	if($("#donateursgegevens-wijziging-06").is(":checked")){
		$("fieldset.wijzigingen-01").show()
		$('fieldset.wijzigingen-01 input').attr("disabled", "");	
	}
	
	$("#donateursgegevens-wijziging-06").click(function() {				
		if($("#donateursgegevens-wijziging-06").is(":checked")){
			$("fieldset.wijzigingen-01").show();
			$('fieldset.wijzigingen-01 input').attr("disabled", "");
		}
		else {
			$("fieldset.wijzigingen-01").hide();
			$('fieldset.wijzigingen-01 input').attr("disabled", "disabled");			
		}			
	});
	
	if($("#donateursgegevens-wijziging-07").is(":checked")){
		$("fieldset.wijzigingen-02").show()
		$('fieldset.wijzigingen-02 input').attr("disabled", "");		
	}
	
	$("#donateursgegevens-wijziging-07").click(function() {				
		if($("#donateursgegevens-wijziging-07").is(":checked")){
			$("fieldset.wijzigingen-02").show();
			$('fieldset.wijzigingen-02 input').attr("disabled", "");			
		}
		else {
			$("fieldset.wijzigingen-02").hide();
			$('fieldset.wijzigingen-02 input').attr("disabled", "disabled");			
		}			
	});
	
	if($("#donateursgegevens-wijziging-08").is(":checked")){
		$("fieldset.wijzigingen-03").show()
		$('fieldset.wijzigingen-03 input').attr("disabled", "");		
	}
	
	$("#donateursgegevens-wijziging-08").click(function() {				
		if($("#donateursgegevens-wijziging-08").is(":checked")){
			$("fieldset.wijzigingen-03").show();
			$('fieldset.wijzigingen-03 input').attr("disabled", "");			
		}
		else {
			$("fieldset.wijzigingen-03").hide();
			$('fieldset.wijzigingen-03 input').attr("disabled", "disabled");			
		}			
	});	
	




	$("#donateur-eenmalig-14").click(function() {	
		if($("#donateur-eenmalig-14").is(":checked")){
			$('#donateur-17').attr("disabled", "disabled");
			$("li.eenmalig-hidden").hide();
		}	
		
		else {
			$('#donateur-17').attr("disabled", "");		
			$("li.eenmalig-hidden").show();
		}
	});

	
	$("#donateur-eenmalig-15").click(function() {	
		if($("#donateur-eenmalig-15").is(":checked")){
			$('#donateur-17').attr("disabled", "");
			$("li.eenmalig-hidden").show();
		}	
		
		else {
			$('#donateur-17').attr("disabled", "disabled");		
			$("li.eenmalig-hidden").hide();
		}
	});


	$('#pyjama-30').change(function() {
	   // assign the value to a variable, so you can test to see if it is working
	    var selectVal = $('#pyjama-30 :selected').val();
	    
	    if (selectVal == "piraten_baby" || selectVal == "prinsessen_baby") {
			$("select#pyjama-31 option.maat01").text("50-56").val("50-56");
			$("select#pyjama-31 option.maat02").text("62-68").val("62-68");
			$("select#pyjama-31 option.maat03").text("74-80").val("74-80");		
	    }    		
		
	    if (selectVal == "piraten_jongen" || selectVal == "prinsessen_meisje") {
			$("select#pyjama-31 option.maat01").text("98-104").val("98-104");
			$("select#pyjama-31 option.maat02").text("110-116").val("110-116");
			$("select#pyjama-31 option.maat03").text("122-128").val("122-128");			
	    }      
	});	

});
