function createLoginCookie(loginname,pwd)
{
	setCookie('randiklubusername',loginname,300);
	setCookie('randiklubpassword',pwd,300);
}
function getCookie(c_name)
{
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	  }
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function checkCookie()
{
	randiklubusername=getCookie('randiklubusername');
	if (randiklubusername!=null && randiklubusername!="")
	  {
		  document.myform.username.value=randiklubusername;
	  }
	randiklubpassword=getCookie('randiklubpassword');
	if (randiklubpassword!=null && randiklubpassword!="")
	  {
		  document.myform.password.value=randiklubpassword;
	  }
}
function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
	return (true)
	}
	return (false)
}
function testreq()
{
	 
		var fields = document.getElementsByTagName("input");
		var hasError = 0;
		if (fields == null) return true;
		for (i = 0; i < fields.length; i++) 
		{
			var field = fields[i];
			if (field.getAttribute("required") != null)
			{
				if (field.getAttribute("numeric") != null)
				{
					if (field.value == '' || !IsNumeric(field.value))
					{
						field.setAttribute("className","szamerror");
						field.setAttribute("style","border-color: red; border-width: 1px");
						if (hasError == 0)
						{
							alert('Kérem nem negatív egész számot adjon meg!');
						}
						hasError = 1;
					}
					else
					{
						field.setAttribute("className","szam");
						field.setAttribute("style","border-top-color:#245706;border-left-color:#245706;border-right-color:#245706;border-bottom-color:#245706;border-width: 1px");
					}
				}
				if (field.value == '' || (field.name == 'email' && !checkEmail(field.value)))
				{
					field.setAttribute("className","error");
					field.setAttribute("style","border-color: red; border-width: 1px");
					if (hasError == 0)
					{
						if (field.name == 'email') alert('Kérem ellenőrizze az E-mail címének helyességét!');
						else alert('Kérem töltse ki a kötelező mezőket!');
					}
					hasError = 1;
				}
				else
				{
					field.setAttribute("className","");
					field.setAttribute("style","border-top-color:#245706;border-left-color:#245706;border-right-color:#245706;border-bottom-color:#245706;border-width: 1px");
				}
			}
		}
		return hasError;
}
function IsNumeric(sText)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	if (sText == null || sText == "") return false;
	var i = 0;
	while(i < sText.length)
	{
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			return false;
		}
		i = i + 1;
	}
	return IsNumber;
   
}
function jumpmenu(menuname, test)
{
	if (test) 
	if (testreq() == 1) 
	{
		return false;
	}
	document.myform.changemenu.value=menuname;
	document.myform.submit();
}
function jumpmenuwithaction(menuname, newaction)
{
	document.myform.action.value=newaction;
	document.myform.changemenu.value=menuname;
	document.myform.submit();
}
function setaction(newaction, test)
{
	if (test) if (testreq() == 1) 
	{
		return false;
	}
	document.myform.action.value=newaction;
	document.myform.submit();
}
function setlang(newlang)
{
	document.myform.lang.value=newlang;
	document.myform.submit();
}
function setactionvalue(newaction)
{
	document.myform.actionvalue.value=newaction;
}

