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;
	};
	
	// visa eller gom en div
	function closetoggle(a)
	{
		var e=document.getElementById(a);
		e.style.display="none";			
		return true;
	}

//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 checkPass()
	{
		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=710px,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=710px,left=478px,top=13px,resizable=0,scrollbars=no");
		}
	}

	function PersonDataPopGroup(culture)
	{
		if(culture=="sv_SE")
		{
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=personinformation&mode=groupmail", "Ã„ndra personuppgifter", "width=472px,height=710px,left=478px,top=13px,resizable=0,scrollbars=no");
		}
		else
		{	
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=personinformation&mode=groupmail", "Change personal information", "width=472px,height=710px,left=478px,top=13px,resizable=0,scrollbars=no");
		}
	}

	function change_password(culture)
	{
		if(culture=="sv_SE")
		{
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=change_password", "Byt lÃ¶senord", "width=400px,height=200px,left=478px,top=200px,resizable=0,scrollbars=no");
		}
		else
		{	
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=change_password", "Change password", "width=400px,height=200px,left=478px,top=200px,resizable=0,scrollbars=no");
		}
	}

	function changeReg(replace, culture)
	{
		w = 460;
		h = 235;
		t = 250;
		quickstep = "&p=0";
		if(replace == "1")
		{ 		
			w = 1;
			h = 1;
			t = -300;
			quickstep = "&p=1";
		}
		if(culture=="sv_SE")
		{	titel="Ã„ndra anmÃ¤lan";}
		else
		{	titel="Change registration"; }
			
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=changeReg" + quickstep + "", titel, "width="+w+"px,height="+h+"px,left=478px,top="+t+"px,resizable=0,scrollbars=no");
	}

	function childCare(culture,sid,mode)
	{
		if(culture=="sv_SE")
		{	titel="Barnpassning"; }
		else
		{	titel="Child care"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=childCare&service="+sid+mode, 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=520px,height=600px,left=478px,top=13px,resizable=0,scrollbars=no"); //486
	}

	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 serviceInfo(culture,sid)
	{
		if(culture=="sv_SE")
		{	titel="Information om tjÃ¤nst"; }
		else
		{	titel="Service information"; }
		
		$('#serviceInfo').load("index.php?go=ServiceComment:info&id="+sid+"&cult="+culture);
	}

	function familyDraw(culture,sid,mode)
	{
		if(culture=="sv_SE")
		{	titel="Familjelottning"; }
		else
		{	titel="Family draw"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=familyDraw&service="+sid+mode, titel, "width=350px,height=250px,left=470px,top=330px,resizable=0,scrollbars=no");
	}

	function supporter(culture,sid,mode)
	{
		if(culture=="sv_SE")
		{	titel="Välj storlek"; }
		else
		{	titel="Choose size"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=supporter&service="+sid+mode, titel, "width=350px,height=150px,left=470px,top=330px,resizable=0,scrollbars=no");
	}

	function serviceComment(culture,sid,mode)
	{
		if(culture=="sv_SE")
		{	titel="Kommentar"; }
		else
		{	titel="Comment"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=serviceComment&service="+sid+mode, titel, "width=370px,height=192px,left=466px,top=330px,resizable=0,scrollbars=no");
	}

	function campingWithAnotherClub(culture,sid,mode)
	{
		if(culture=="sv_SE")
		{	titel="Bo med annan klubb"; }
		else
		{	titel="Live with another club"; }

		popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=campingWithAnotherClub&service="+sid+mode, titel, "width=370px,height=192px,left=466px,top=330px,resizable=0,scrollbars=no");
	}
	
/*
	function search_person(culture,sid)
	{
		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=520px,height=486px,left=478px,top=13px,resizable=0,scrollbars=no");
	}
*/

	function startWithAnotherClub(culture,sid,mode)
	{
		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  + "" + mode, titel, "width=268px,height=136px,left=470px,top=330px,resizable=0,scrollbars=no");
	}

	//Verify accept terms check-box 
	function validate(chk, culture, method, mode)
	{
	  obj = document.getElementById(chk);
	  if (obj.checked == 1)
	  {
	 	window.location.href = "?page=loggedIn&section=selfTransacation&method=" + method + "" + mode;
	  }
	  else
	  {
	  	if(culture=="sv_SE")
		{	text = "Du mÃ¥ste acceptera villkoren"; }
	    else
		{	text = "You have to accept the conditions"; }  	
	    alert(text);
	  	document.getElementById("confirm_button").disabled=false;
	  }
	   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,count)
	{
		v = document.forms[frm].country.value;
		v2 = $("#club_country").val();
		if (v2!="")
			v = v2;
					
		if (v == "")
			v = "sv_SE";
			
		if(count=="")
			count = 10;

		$("#club").unautocomplete();
		$("#club").autocomplete("index.php?go=Club&c=" + v, { max: eval(count), 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]); 
				obj = $(this).parent().find("#person");
				if(obj)
				{
					personauto(frm);
				}
			 }
	     } 
	    );
	}

	function personauto(frm)
	{
		c = document.forms[frm].club_id.value;
		$("#person").unautocomplete();
		$("#person").autocomplete("index.php?go=PersonList&c=" + c, { minChars:1, matchSubset:1, matchContains:1, cacheLength:10, selectOnly:1, max:6 });
		$("#person").result(function(event, data, formatted) {
			 if (data) 
			 	$(this).parent().find("#person_id").val(data[1]); 
	     } 
	    );
	}
	
	function closeit()
	{
		popwin.close();
	}

	function checkChildForm()
	{
		if(form.child_first_name.value=="a")
			alert('test');
	}
	
	function checkChildForm(form)
	{
		var err = 0;
		var errstr = "";
		var errarr = new Array();
		CHILD_FNAME_ERR = err++;
		CHILD_LNAME_ERR = err++;
		CHILD_LANG_ERR = err++;
		CHILD_NATION_ERR = err++;
		CHILD_AGE_ERR = err++;
		FORM_INCOMPLETE_ERR = err++;
		
		if(form.culture=="sv_SE")
		{
			err_str = "Det finns fel i barnets uppgifter. Kontrollera ";
			errarr[CHILD_FNAME_ERR] = "fÃ¶rnamn.";
			errarr[CHILD_LNAME_ERR] = "efternamn.";
			errarr[CHILD_LANG_ERR] = "sprÃ¥k.";
			errarr[CHILD_NATION_ERR] = "nationalitet.";
			errarr[CHILD_AGE_ERR] = "Ã¥lder.";
			errarr[FORM_INCOMPLETE_ERR] = "FÃ¶rÃ¤lder1, FÃ¶rÃ¤lder2 eller Annan anhÃ¶rig mÃ¥ste vara komplett ifyllt.";
		}
		else
		{
			err_str = "There are incorrect information about the child. Check the childs ";
			errarr[CHILD_FNAME_ERR] = "firstname.";
			errarr[CHILD_LNAME_ERR] = "lastame.";
			errarr[CHILD_LANG_ERR] = "language.";
			errarr[CHILD_NATION_ERR] = "nationality.";
			errarr[CHILD_AGE_ERR] = "age.";
			errarr[FORM_INCOMPLETE_ERR] = "Parent 1,Parent 2,or  Other .... must be completed.";
		}	

		if (form.child_first_name.value == "") 
  		{
  			alert( err_str + errarr[CHILD_FNAME_ERR] ); 
  			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( err_str + errarr[CHILD_LNAME_ERR] );
	    	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( err_str + errarr[CHILD_LANG_ERR] );
	    	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( err_str + errarr[CHILD_NATION_ERR] );
	    	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( err_str + + errarr[CHILD_AGE_ERR]);
	    	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( errarr[FORM_INCOMPLETE_ERR] );
    		return false ;
  		}
  		return true ;
	}

	function Cancel()
	{
		window.location.href='?page=loggedIn&section=addPersonGroup';
	}
	
	function CancelNewPerson()
	{
		window.location.href='?page=loggedIn&section=addPersonGroup&personid=0';
	}


	function clearPersonForm()
	{
		document.addNewPersonGroup.first_name.value = "";
		document.addNewPersonGroup.last_name.value = "";
		document.addNewPersonGroup.street.value = "";
		document.addNewPersonGroup.zip.value = "";
		document.addNewPersonGroup.city.value = "";
		document.addNewPersonGroup.country.value = "SE";
		document.addNewPersonGroup.club.value = "";
		document.addNewPersonGroup.phone_home.value = "";
		document.addNewPersonGroup.phone_work.value = "";
		document.addNewPersonGroup.phone_mobile.value = "";
		document.addNewPersonGroup.born.value = "0000-00-00";
		document.addNewPersonGroup.first_name.value = "";
		document.addNewPersonGroup.sportident.value = "";
		document.addNewPersonGroup.email.value = "";
		document.addNewPersonGroup.advertise.checked = false; 
	}

	function validateFields(form, culture)
	{
  		if (form.old_password.value == "") 
  		{
			if(culture=="sv_SE")
			{
    			alert("Ditt gamla lÃ¶senord mÃ¥ste anges.");
			}
			else
			{
				alert("Your old password must be entered.");
			}

	    form.old_password.style.backgroundColor='red';
		form.old_password.focus();
    	return false;
  		}
  		else
  		{
  			form.old_password.style.backgroundColor='white';
  		}
  		
		if (form.new_password.value == "") 
  		{
			if(culture=="sv_SE")
			{
		    	alert("Ett nytt lÃ¶senord mÃ¥ste anges.");
			}
			else
			{
		    	alert("A new password must be entered.");
			}
    	form.new_password.style.backgroundColor='red';
    	form.new_password.focus();
    	return false;
  		}
  		else
  		{
  			form.new_password.style.backgroundColor='white';
  		}
  		
		if (form.new_password_repeat.value == "")
  		{
			if(culture=="sv_SE")
			{
		    	alert("Det nya lÃ¶senordet mÃ¥ste upprepas.");
			}
			else
			{
				alert("The new password must be repeated.");
			}

    	form.new_password_repeat.style.backgroundColor='red';
    	form.new_password_repeat.focus();
    	return false;
  		}
  		else
  		{
  			form.new_password_repeat.style.backgroundColor='white';
  		}
  		
		if (form.new_password.value != form.new_password_repeat.value)
  		{
			if(culture=="sv_SE")
			{
		    	alert( "Nytt lÃ¶senord och Upprepa lÃ¶senord stÃ¤mmer inte Ã¶verens.");
			}
			else
			{
		    	alert("New password and Repeat password do not match.");
			}
    	form.new_password.style.backgroundColor='red';
    	form.new_password_repeat.style.backgroundColor='red';
    	form.new_password.focus();
    	return false;
  		}
  		else
  		{
  			form.old_password.style.backgroundColor='white';
			form.new_password.style.backgroundColor='white';
			form.new_password_repeat.style.backgroundColor='white';
  		}
		
		document.form.submit();
	}
	
	//BORT??
	function wrong_old_password()
	{
    	alert( "Gamla lÃ¶senordet Ã¤r felaktigt." );
    	document.getElementById('old_password').style.backgroundColor='red';
   		document.getElementById('old_password').focus();
    	return false;
	}

	function togInvoiceInfo()
	{
		closetoggle('info_card'); 
		closetoggle('confirm'); 
		closetoggle('checkbox'); 
		toggle('checkbox'); 
		toggle('confirm'); 
		
		return toggle('info_invoice');
	}

	function togCardInfo()
	{
		closetoggle('info_invoice'); 
		closetoggle('confirm'); 
		closetoggle('checkbox'); 
		toggle('checkbox'); 
		toggle('confirm');

		return toggle('info_card');
	}

	function faq(culture)
	{
		if(culture=="sv_SE")
		{
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=faq:sv_SE", "FrÃ¥gor och svar", "width=650px,height=550px,left=263px,top=13px,resizable=0,scrollbars=yes");

		}
		else
		{
			popwin = dhtmlwindow.open("popup", "iframe", "index.php?go=PopUp&form=faq:en_US", "Questions and answers", "width=650px,height=550px,left=263px,top=13px,resizable=0,scrollbars=yes");
		}
	}

var ivalc = 0;
var ival;
function setblinkColor()
{
	if (ivalc % 2 == 0)
	{
  		document.getElementById("blink").style.border="2px solid yellow";
	}
	else
	{
  		document.getElementById("blink").style.border="2px solid green";
	}
	ivalc = ivalc + 1;
	if (ivalc >= 15)
	{
		clearInterval(ival);
		document.getElementById("blink").style.border="2px solid white";
	}
}
function blinkColor()
{
	ivalc = 0; 
 	ival = setInterval("setblinkColor()",50);
}

function togglePulInfoVisibility()
{
	toggle('PulInfo'); 
}
