// JavaScript Document
;
startList = function() {

	//todo:afhankelijk maken van ie6
	var srch;
	var part
	var chapter; 
	if(window.location.href.split('?')[1]!=undefined){
		srch = window.location.href.split('?')[1];
		if(srch.indexOf('&')>-1){
			part = srch.split("&")[0];
			chapter = srch.split("&")[1];
		}else{
			part = srch;
		}
	}
	
	showContent(part, chapter)
}
window.onload=startList;

function toggleData(part, el1){
		document.getElementById('volwassenendata').style.display="none";
		document.getElementById('kinderdata').style.display="none";
		document.getElementById(part).style.display="block";
		//el1.getAttributeNode('class').nodeValue="selected";

	}

function showContent(part, chapter){
	
	var thisDoc = document.body.id;
//	alert(part)
	if(part!='' && part!=undefined){
		switch(thisDoc){
			
			case "informatie":
					document.getElementById('locatie').style.display="none";
					document.getElementById('cursusgeld').style.display="none";
					document.getElementById('lesdata').style.display="none";
					document.getElementById('kledingadvies').style.display="none";
					document.getElementById('contact').style.display="none";
		
					document.getElementById(part).style.display="block";
					
					break;
			case "workshops":
					
					document.getElementById('zomerdansweek').style.display="none";
					//document.getElementById('kinderdansweekend').style.display="none";
					document.getElementById('flex').style.display="none";
					document.getElementById(part).style.display="block";
					break;
			
			case "lesinhoud":
					
					//if(chapter=='vol'||chapter=='kids'){
					var i=0;
						while(document.getElementById('content').childNodes[i]){
						
								var child = document.getElementById('content').childNodes[i];
							
								if(child.tagName=="DIV"){
										
									
											var j=0;
											while(child.getElementsByTagName('DIV')[j]){
													var child2 = child.getElementsByTagName('DIV')[j];
														if(child2.tagName=="DIV"){
															if(part!='kinderlessen' && part!='volwassenenlessen'){
																
																child2.style.display="none";
															}else{
																child2.style.display="block";
															}
														}
														
													j++;
											}
										
									child.style.display="none";
								}
								i++;
						}
					//}
					if(chapter=='kids'){
						$('.kinderlessen').css("display","block");
						$(".volwassenenlessen").css("display","none");
					}else if(chapter=='vol'){
						$(".volwassenenlessen").css("display","block");
						$('.kinderlessen').css("display","none");
					}
				
					$('.'+part).css("display","block");					
					break;
		    case "inschrijf":

				//	document.getElementById(part).checked=true;
				
					break;
			default: 
				//nothing
				
				;
		}
	}
	part="";
	
	
}

//form
	
	function showSubscription(part,el){
				
				//document.getElementById('weekendworkshops').style.display = 'none';
			  try{	document.getElementById('zomerdansweek').style.display = 'none';
				document.getElementById('kinderdansweekend').style.display = 'none';
              	document.getElementById('jaarcursus').style.display = 'none';
				
				//document.getElementById('juni').getAttributeNode('class').nodeValue ='';
			  	document.getElementById('10augustus').getAttributeNode('class').nodeValue ='';
				//document.getElementById('15augustus').getAttributeNode('class').nodeValue ='';
              	document.getElementById('september').getAttributeNode('class').nodeValue ='';
				if(el){
						el.getAttributeNode('class').nodeValue ='selected';
				}else if(!part || part=='zomerdansweek'){
					part = 'zomerdansweek';
					document.getElementById('10augustus').getAttributeNode('class').nodeValue ='selected';
				}
			 
				document.getElementById(part).style.display = 'block';
				 }catch(e){}
		
		}

$(document).ready(function(){
	
		workshops.initWorkshops();
		all.init();
		//inschrijving.init();

		
});

all={
		init:function(){
		var ref = window.location.href;
		ref = ref.split(".php")[0];
		ref = ref.split("/");
		ref = ref[ref.length-1];
		$("#menu-"+ref).addClass("selected");
	}
}
workshops={
	
	initWorkshops : function(){

		if(navigator.userAgent.indexOf("Firefox")!=-1){
			$(".explanation").css("height","245px");
		}
		$(".explanation").addClass("hideblock explanationabsolute");
		$("#soleares").removeClass("hideblock")	;
		$("#soleares").addClass("slidden");
		$("#table-soleares").find("td").css("background",'#CC9933');
		
		$("#workshoplist").find('tr').mouseenter(
		
		function(){
				
			el = "#"+this.id.split("-")[1];
			if(this.id!=''){
				$("#table-soleares").find("td").css("background", "");
				$("#table-tangos").find("td").css("background", "");
				$("#table-bulerias").find("td").css("background", "");
				$("#table-alegrias").find("td").css("background", "");
				
				$(".slidden").fadeOut(300);
				$(".slidden").removeClass("slidden");
				$(el).addClass("slidden");
				setTimeout('$(el).fadeIn(600)',500);
				$(this).find("td").css("background", "#CC9933");
			}
		}
		
		);
/*		$(".workshopsTable").mouseleave(
			function(){
				
					$(".Soleares").fadeTo("fast",1);
					$(".Fandango").fadeTo("fast",1);
					$(".farruca").fadeTo("fast", 1);
					$(".sevillanas").fadeTo("fast", 1);
			 });	
		$(".Soleares").mouseenter(
			function(){
					$(".Soleares").fadeTo("fast",1);
					$(".farruca").fadeTo("fast", 0.3);
					$(".sevillanas").fadeTo("fast", 0.3);
					$(".Fandango").fadeTo("fast", 0.3);
		
		 });
		$(".farruca").mouseenter(
			function(){
				
	$(".farruca").fadeTo("fast", 1);
						$(".Soleares").fadeTo("fast",0.3);
					$(".farruca").fadeTo("fast", 1);
					$(".sevillanas").fadeTo("fast", 0.3);
					$(".Fandango").fadeTo("fast", 0.3);
			
			 });
		$(".sevillanas").mouseenter(
			function(){
				$(".sevillanas").fadeTo("fast", 1);
						$(".Soleares").fadeTo("fast",0.3);
					$(".farruca").fadeTo("fast", 0.3);					
					$(".Fandango").fadeTo("fast", 0.3);
			
			 });
			 $(".fandangos").mouseenter(
			function(){
				$(".sevillanas").fadeTo("fast", 0.3);
						$(".Soleares").fadeTo("fast",0.3);
					$(".farruca").fadeTo("fast", 0.3);					
					$(".Fandango").fadeTo("fast", 1);
			
			 });

	*/
		
	}
}


inschrijving={
	
	init: function(){

		$("#inschrijving-submit").click(function(){
			  		
				var options = {
					beforeSubmit: before,
					success: succes,
					error: error,
					complete: complete,
					url: 'php/mail.php',
					type: 'post',
					clearForm: false,
					resetForm: false,
					timeout: 3000,
					async: false
				};
			
				$('#inschrijving-form').ajaxSubmit(options); 
				return false;
			
				function before(formData, jqForm, options) { 
				
			
				} 
				

				function succes(data){    
					 data = data.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
					
					if(data==""){
		
					}else{
						
						
					}
				};	

				function error(data){
				
				};
				
				function complete(data){
	
						window.location = "./bedankt/bedankt.html";

				}
			
		});
		
		$("#inschrijving-reset").click(function(){

			this.reset;
		});
	},
	checkemail:function(evalue)
	{
		var r = new RegExp(/^.+@.+\..{2,}$/);
		return evalue.match(r);
	},
	
	checkfields:function(frm)
	{
	
		var l = '';
		if (frm.naam.value == '')
		{ 
			l = l + 'Vul a.u.b. uw Naam in\n'; 
			frm.naam.focus(); 
		}
		if (frm.email.value == '')
		{ 
			l = l + 'Vul a.u.b. uw email in\n'; 
			if(l.length == 0 ) frm.email.focus(); 	
		}
		else if( ! checkemail(frm.email.value) )
		{
			l = l + 'Het emailadres is ongeldig in\n'; 
			if(l.length == 0 ) frm.email.focus(); 	
		}
		
		if (frm.telefoon.value == '')
		{ 
			l = l + 'Vul a.u.b. uw telefoonnummer in\n'; 
			if(l.length == 0 ) frm.telefoon.focus(); 
		}
		if (l.length > 0)
		{
			alert(l);
			return false;
		}
		frm.mailfrom.value = frm.email.value;
		return true;
	},
	
	tglKidsOrNot:function(partId, part){
		
		if(partId =='rdVol'){
			document.getElementById('inschrijfKids').style.display = 'none';
			document.getElementById(part).style.display = 'block';
			document.getElementById("thnksPage").value = "http://britafalk.nl/volwassenen/bedankt.html";
		} else if(partId =='rdKids'){
			document.getElementById('inschrijfVolw').style.display = 'none';
			document.getElementById(part).style.display = 'block';
			document.getElementById("thnksPage").value = "http://britafalk.nl/kinderen/bedankt.html";
		}
	}
	
	
}
