﻿if(!document.getElementById)
{
	if(document.all)
	{
		document.getElementById = function()
		{
			if(typeof document.all[arguments[0]]!="undefined")
			{
				return document.all[arguments[0]];
			} 
			else 
			{
				return null;
			}
		};
	}
	else if(document.layers)
	{
		document.getElementById = function()
		{
			if(typeof document[arguments[0]]!="undefined")
			{
				return document[arguments[0]];
			} 
			else 
			{
				return null;
			}
		};
	}
};

// visa eller gom en div
	function toggle(a){
	var e=document.getElementById(a);
	if(!e) {return true;}
	if(e.style.display=="none"){
	e.style.display="block";
	} else {
	e.style.display="none";
	}
	return true;
	};
	


//Banner Slide Show - sponsors
	
	//set image paths
	src = ["images/banner/image1.gif", "images/banner/image2.gif", "images/banner/image3.gif", "images/banner/image4.gif"];

	//set corresponding urls
	url = ["#", "#", "#", "#"];
	
	//set duration for each image
	duration = 5;
	
	//Please do not edit below
	ads=[]; ct=0;
	function switchAd() {
		var n=(ct+1)%src.length;
		if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
			document["Ad_Image"].src = ads[ct=n].src;
		}
		ads[n=(ct+1)%src.length] = new Image;
		ads[n].src = src[n];
		setTimeout("switchAd()",duration*1000);
	}
	function doLink(){
		location.href = url[ct];
	} 
	$(document).ready(function () {
		if (document.images)
		{switchAd();}
	});

//Banner Slide Show - partners
	
//Banner Slide Show - supplier

// Validera formular

	//Tomma fÃ¤lt
	function checkEmail()
	{
		document.getElementById("emailError").style.display		= "none";
	}
	
	function checkLogin(frm)
	{
		document.getElementById("emailError").style.display 	= "none";
		document.getElementById("passError").style.display 		= "none";
		if(frm.email.value == "")
		{	document.getElementById("emailError").style.display 		= "block"; }
		if(frm.pass.value == "")
		{	document.getElementById("passError").style.display 		= "block"; }
		if(frm.email.value == ""||frm.pass.value == "")
		{	return false; }		
	}
	function mandatoryMobile(frm)
	{
		if(frm.phone_mobile.value!="")
		{	return true; }
		
		alert('Som anmï¿½lare av en grupp mï¿½ste du ha registrerat ett mobilnummer. Detta mobilnummer anvï¿½nds som kontaktnummer under tï¿½vlingen.');
		return false;
	}
	
	function checkPass()
	{
		if	(pass != "") 
		{
			return false;
		}
		else
		{
			document.getElementById("passError").style.display 		= "none";
		}
	}
	
	function checkRePass()
	{
		document.getElementById("rePassError").style.display	= "none";
	}
	
	//Validera input
	function checkForm() 
	{
		email	= document.getElementById("email").value;
		pass	= document.getElementById("pass").value;
		rePass	= document.getElementById("rePass").value;
				
		var splitted = email.match(/^([\w\-%~\.]+)@([\w\-\.]+\.[\w]{2,4})$/);
    	    	
    	if(splitted  == null) 
    		{
    		document.getElementById("emailError").style.display	= "none"; ShowEmailError(); return false;
    		}

		else if (pass == "") 
		{
		hideAllErrors();
		document.getElementById("passError").style.display = "inline";
		document.getElementById("pass").select();
		document.getElementById("pass").focus();
		return false;
		} 
		
		else if (rePass != pass) 
		{
		hideAllErrors();
		document.getElementById("rePassError").style.display = "inline";
		document.getElementById("rePass").select();
		document.getElementById("rePass").focus();
		return false;
		}
		return true;
	}

	function ShowEmailError() 
	{
		hideAllErrors();
		document.getElementById("emailError").style.display = "inline";
		document.getElementById("email").select();
		document.getElementById("email").focus();
		return false;
	} 
	 
	function hideAllErrors() 
	{
		document.getElementById("emailError").style.display		= "none";
		document.getElementById("passError").style.display 		= "none";
		document.getElementById("rePassError").style.display	= "none";
	}
	
	//PopUp windows
	var popwin = null; // används av closeit
	
	function PersonDataPop(culture)
	{
		if(culture=="sv_SE")
		{
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=personinformation", "Ã„ndra personuppgifter", "width=472px,height=620px,left=478px,top=13px,resizable=0,scrollbars=no");
		}
		else
		{	
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=personinformation", "Change personal information", "width=472px,height=620px,left=478px,top=13px,resizable=0,scrollbars=no");
		}
	}

	function changeReg(replace, culture)
	{
		if(replace == 0)
		{	location.href="?page=loggedIn&section=register"; }
		
		if(culture=="sv_SE")
		{	titel="Ã„ndra anmÃ¤lan";}
		else
		{	titel="Change registration"; }
			
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=changeReg", titel, "width=460px,height=220px,left=478px,top=250px,resizable=0,scrollbars=no");
	}

	function childCare(culture,sid)
	{
		if(culture=="sv_SE")
		{	titel="Barnpassning"; }
		else
		{	titel="Child care"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=childCare&service="+sid, titel, "width=712px,height=624px,left=300px,top=13px,resizable=0,scrollbars=no");
	}

	function addGroupMember(culture)
	{
		if(culture=="sv_SE")
		{ titel="GruppanmÃ¤lan";}
		else
		{ titel="Group registration";}
			
		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=addGroupMember", "GruppanmÃ¤lan", "width=500px,height=638px,left=440px,top=13px,resizable=1,scrollbars=yes");
	}

	function classInformation(culture)
	{
		if(culture=="sv_SE")
		{	titel="Information om klasser"; }
		else
		{	titel="Class information"; }
		
		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=classInformation", titel, "width=594px,height=460px,left=440px,top=215px,resizable=1,scrollbars=yes");
	}


	function familyDraw(culture,sid)
	{
		if(culture=="sv_SE")
		{	titel="Familjelottning"; }
		else
		{	titel="Family draw"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=familyDraw&service="+sid, titel, "width=268px,height=96px,left=470px,top=330px,resizable=0,scrollbars=no");
	}

	function startWithAnotherClub(culture,sid)
	{
		if(culture=="sv_SE")
		{	titel="Lottning med annan klubb"; }
		else
		{	titel="Club draw"; }
		
		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=startWithAnotherClub&service="+sid, titel, "width=268px,height=236px,left=470px,top=330px,resizable=0,scrollbars=no");
	}


	//Verify accept terms check-box 
	function validate(chk,culture){
	  obj = document.getElementById(chk);
	  if (obj.checked == 1)
	  {
	 	window.location.href = "?page=loggedIn&section=selfTransacation";
	  }
	  else
	  {
	  	if(culture=="sv_SE")
		{	text = "Du mÃ¥ste acceptera villkoren"; }
	    else
		{	text = "You have to accept the conditions"; }
	    	
	    alert(text); return false;
	  }
	}

	function enableClubfield(checkBool, textID)
	{
		textFldObj = document.getElementById(textID);
		//Disable the text field
		textFldObj.disabled = checkBool;
		//Clear value in the text field
		if (checkBool) 
		{ 
	  		textFldObj.value = ''; 
		}
	}
 
	// autocomplete klubbar
	function clubauto(frm)
	{
		v = document.forms[frm].country.value;
		if (v == "")
			v = "sv_SE";
			
		$("#club").unautocomplete();
		$("#club").autocomplete("index.php?go=Club&c=" + v, { minChars:1, matchSubset:1, matchContains:1, cacheLength:10, selectOnly:1 });
		$("#club").result(function(event, data, formatted) {
			 if (data) 
			 { 
			 	$(this).parent().find("#clubid").val(data[1]); 
			 }
	     } 
	    );
	}
	
	function closeit()
	{
		popwin.close();
	}

	function checkChildForm()
	{
		if(form.child_first_name.value=="a")
			alert('hej');
	}
	
	function checkChildForm(form)
	{
  		if (form.child_first_name.value == "") 
  		{
    	alert( "Det finns fel i barnets uppgifter. Kontrollera förnamn." );
    	form.child_first_name.style.backgroundColor='red';
    	form.child_first_name.focus();
    	return false ;
  		}
  		else
  		{
  			form.child_first_name.style.backgroundColor='white';
  		}
  		if (form.child_last_name.value == "") 
  		{
    	alert( "Det finns fel i barnets uppgifter. Kontrollera efternamn." );
    	form.child_last_name.style.backgroundColor='red';
    	form.child_last_name.focus();
    	return false ;
  		}
   		else
  		{
  			form.child_last_name.style.backgroundColor='white';
  		}
   		if (form.child_language.value == "") 
  		{
    	alert( "Det finns fel i barnets uppgifter. Kontrollera språk." );
    	form.child_language.style.backgroundColor='red';
    	form.child_language.focus();
    	return false ;
  		}
  		else
  		{
  			form.child_language.style.backgroundColor='white';
  		}
    	if (form.child_nationality.value == "") 
  		{
    	alert( "Det finns fel i barnets uppgifter. Kontrollera nationalitet." );
    	form.child_nationality.style.backgroundColor='red';
    	form.child_nationality.focus();
    	return false ;
  		}
  		else
  		{
  			form.child_nationality.style.backgroundColor='white';
  		}
    	if (form.child_age.value == "") 
  		{
    	alert( "Det finns fel i barnets uppgifter. Kontrollera ålder." );
    	form.child_age.style.backgroundColor='red';
    	form.child_age.focus();
    	return false ;
  		}
	 		else
  		{
  			form.child_age.style.backgroundColor='white';
  		}
		
		var complete = 3;
		for (i=0; i<3; i++)
		{
	    	if ( (form['parent_first_name['+i+']'].value == "") || (form['parent_last_name['+i+']'].value == "") || (form['parent_mobile['+i+']'].value == "") || (form['parent_club['+i+']'].value == "") || (form['parent_class['+i+']'].value == "")) 
			{	complete -= 1; }
			
		}
    	if(!complete)
    	{
    		alert( "Förelder1, Förelder2 eller Annan anhörig måste vara komplett ifyllt." );
    		return false ;
  		}
  		return true ;
	}
	
$(document).ready(function(){
	  $('li.headlink').hover(
	   function() { $('ul', this).css('display', 'block'); },
	   function() { $('ul', this).css('display', 'none'); });
	 });