//*****************************************************TICKER**********************************************/
var t;
var c1;
var text;
var pos;
var realWidth;
var tim;
var width = 600;
var delay = 40;
function TickerInit()
{
	pos = width;
	t = document.getElementById("t");
	c1 = document.getElementById("c1");
	c1.innerHTML = text;
	realWidth = c1.offsetWidth;
	tim = setInterval("updateScroll()", 20);
}
function updateScroll()
{
    if (c1 != null)
    {
	pos--;
	if(pos+realWidth < -1)
		pos = width+delay;
	c1.style['left'] = pos + "px";
	}
}
function stopScroll()
{
	clearInterval(tim);
}
function startScroll()
{
	tim = setInterval("updateScroll()", 20);
}
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''END TICKER'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function show(what)
{
	document.getElementById(what).style.visibility="visible";
}
function hide(what)
{
	document.getElementById(what).style.visibility="hidden";
}
function validate(field)
{
	with(field)
	{
		if(value==""||value==null)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
}

function validate_form(thisform)
{
	with(thisform)
	{
		if(validate(name) == true && validate(psw) == true)
		{
			return true;
		}
		else
		{
			alert("Du måste fylla i alla fält");
			return false;
		}
	}
}
function validate_comment(thisform)
{
	with(thisform)
	{
		if(validate(frmCommentFrom) != "" && validate(frmCommentText) != "")
		{
			return true;
		}
		else
		{
			alert("Du måste fylla i alla fält");
			return false;
		}
	}
}
function validate_tip(thisform)
{
	with(thisform)
	{
		if(validate_mail(mail) == true && validate(from) != "")
		{
			return true;
		}
		else
		{
			alert("Du måste fylla i alla fält");
			return false;
		}
	}
}
function validate_reg(thisform)
{
	with(thisform)
	{
		if(validate(name) == true && validate_psw(psw,psw2,lang.value) == true && validate(psw))
		{
			if(validate_mail(mail,lang.value) == true )
			{
				if(ok.checked == true)
				{
					return true;
				}
				else
				{
					with(lang.value)
					{
						if(lang.value =="" || lang.value == "sv")
						{
							alert("Du måste acceptera användaravtalet");
						}
						else
						{
							alert("You must accept the user agreement");
						}
					}
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{	
				if(lang =="" || lang == "sv")
				{
					alert("Du måste fylla i alla fält med en *");
				}
				else
				{
					alert("You must fill in all fields marked with a *");
				}
				return false;
		}
	}
}
function validate_mail(field,lang)
{
	temp = lang;
	with(field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) 
		{
			if(temp =="" || temp == "sv")
			{
				alert("Du har inte anvigit en giltig emailadress");
			}
			else
			{
				alert("The email you entered was not valid");
			}			
			return false;
		}
		else 
		{
			return true;
		}
	}
}
function validate_psw(psw1,psw2,lang)
{
	if(psw1.value==psw2.value)
	{
		if(psw1.value.length<6)
		{
			with(lang)
			{
				if(lang =="" || lang == "sv")
				{
					alert("Ditt lösenord måste vara minst 6 tecken långt");
				}
				else
				{
					alert("You password haveto be at least 6 charactes long");
				}
			}			
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
			if(lang =="" || lang == "sv")
			{
				alert("Du har inte skrivit samma lösenord");
			}
			else
			{
				alert("You didnt enter the same password in both passwordfields");
			}
		return false;
	}
}
function changeopt(what)
{
	document.search.compType.options.length=0;
	if(what=="hast")
	{
		document.search.compType.options[0] = new Option("Alla","",true,false);		
		document.search.compType.options[1] = new Option("Junior","Junior",false,false);
		document.search.compType.options[2] = new Option("Young Rider","Young Rider",false,false);
		document.search.compType.options[3] = new Option("Senior","Senior",false,false);
	}
	else if(what=="ponny")
	{
		document.search.compType.options[0] = new Option("Alla","",true,false);	
		document.search.compType.options[1] = new Option("A","A",false,false);
		document.search.compType.options[2] = new Option("B / Kat I","B",false,false);
		document.search.compType.options[3] = new Option("C / Kat II","C",false,false);
		document.search.compType.options[4] = new Option("D / Kat III","D",false,false);

	}
	else if(what=="alla")
	{
		document.search.compType.options[0] = new Option("Alla","",true,false);	
		document.search.compType.options[1] = new Option("A","A",false,false);
		document.search.compType.options[2] = new Option("B / Kat I","B",false,false);
		document.search.compType.options[3] = new Option("C / Kat II","C",false,false);
		document.search.compType.options[4] = new Option("D / Kat III","D",false,false);
		document.search.compType.options[5] = new Option("Junior","Junior",false,false);
		document.search.compType.options[6] = new Option("Young Rider","Young Rider",false,false);
		document.search.compType.options[7] = new Option("Senior","Senior",false,false);
	}
}
function showadpic(what,browse)
{
	var hide = "browse_";
	var ad = "ad_";
	if(what.src=="http://egodesk.com/ghs/img/uppic.jpg")
	{
		what.src="http://egodesk.com/ghs/img/browse.jpg";
		switch(browse)
		{
			case("browse_1"):
				document.getElementById(browse).style.visibility="visible";
				for(i=2;i<=4;i++)
				{
					ad+=i;
					document.getElementById(ad).src="http://egodesk.com/ghs/img/uppic.jpg";
					hide+=i;
					document.getElementById(hide).style.visibility="hidden";
					hide = "browse_";
					ad = "ad_";
				}
				break;
			case("browse_2"):
				document.getElementById(browse).style.visibility="visible";
				for(i=1;i<=4;i++)
				{
					ad+=i;
					hide+=i;
					if(i!=2)
					{
						document.getElementById(ad).src="http://egodesk.com/ghs/img/uppic.jpg";
						document.getElementById(hide).style.visibility="hidden";
					}
					hide = "browse_";
					ad = "ad_";
				}
				break;
			case("browse_3"):
				document.getElementById(browse).style.visibility="visible";
				for(i=1;i<=4;i++)
				{
					ad+=i;
					hide+=i;
					if(i!=3)
					{
						document.getElementById(ad).src="http://egodesk.com/ghs/img/uppic.jpg";
						document.getElementById(hide).style.visibility="hidden";
					}
					hide = "browse_";
					ad = "ad_";
				}
				break;
			case("browse_4"):
				document.getElementById(browse).style.visibility="visible";
				for(i=1;i<=4;i++)
				{
					ad+=i;
					hide+=i;
					if(i!=4)
					{
						document.getElementById(ad).src="http://egodesk.com/ghs/img/uppic.jpg";
						document.getElementById(hide).style.visibility="hidden";
					}
					hide = "browse_";
					ad = "ad_";
				}
				break;
		}
	}
}
function showlic()
{
	if(document.getElementById("userperc").style.display=="none")
	{
		document.getElementById("userperc").style.display="block";
		document.getElementById("useragree").style.display="none";
	}
	else
	{
		document.getElementById("userperc").style.display="none";
		document.getElementById("useragree").style.display="block";
	}
	
}

function rollbg(chosen, objectID) {
	if(chosen == "roll") {
		document.getElementById(objectID).className="roll";
	}
	else {
		document.getElementById(objectID).className="over";
	}
}
function showtip()
{
	if(document.getElementById("tip").style.display!="block")
	{
		document.getElementById("tip").style.display="block";
	}
	else
	{
		document.getElementById("tip").style.display="none";
	}
}
function showaccpic()
{
	if(document.getElementById("upload_pic").style.display!="block")
	{
		document.getElementById("upload_pic").style.display="block";
	}
	else
	{
		document.getElementById("upload_pic").style.display="none";
	}
}

