<!--
function checkEmail(emailaddress)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailaddress.value))
	{
		return (true);
	}
	alert("Ange en giltig e-post adress!");
	return (false);
}

function trim(inputString) 
{
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") 
	{ 
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") 
	{
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) 
	{ 
		retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
	}
	return retValue; 
}

function checkLogin(mf)
{
	if(trim(mf.username.value)=="")
	{ 
		alert("Ange e-postadress!");
		mf.username.focus();
		return false;
	}
	if(checkEmail(mf.username)==false)
	{
		mf.username.focus();
		return false; 
	}
	if(mf.userpass.value=="")
	{
		alert("Ange lösenord");
		mf.userpass.focus();
		return false;
	}
	return true;
}

function checkRegistration(mf)
{
	if(mf.name.value=="")
	{
		alert("Vänligen ange namn");
		mf.name.focus();
		return false;
	}
	if(trim(mf.email.value)=="")
	{ 
		alert("Ange e-postadress!");
		mf.email.focus();
		return false;
	}
	if(checkEmail(mf.email)==false)
	{
		mf.email.focus();
		return false; 
	}
	if(mf.userpass.value=="")
	{
		alert("Ange lösenord");
		mf.userpass.focus();
		return false;
	}
	if(mf.cuserpass.value!=mf.userpass.value)
	{
		alert("Verifiering av lösenord misslyckades, försök igen.");
		mf.cuserpass.focus();
		return false;
	}
	return true;
}

	function checkRecipe(mf)
	{
		var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
		if(mf.recatid.value=="" || mf.recatid.value=="0")
		{
			alert("Vänligen välj rätt kategori.");
			mf.recatid.focus();
			return false;
		}
		if(mf.rectitle.value=="")
		{
			alert("Ange recept titel");
			mf.rectitle.focus();
			return false;
		}
		if(mf.desturl.value!="")
		{
			var theurl=mf.desturl.value;
			if(!tomatch.test(theurl))
			{
				alert("Vänligen ange en giltig URL adress som http://wwww.receptförmedlingen.se");
				mf.desturl.focus();
				return false;
			}
		}
		if(mf.recdesc.value=="")
		{
			alert("Skriv recept beskrivning");
			mf.recdesc.focus();
			return false;
		}
		return true;
	}

	function checkRecipeURL(mf)
	{
		var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
		if(mf.recipeurl.value!="")
		{
			var theurl=mf.recipeurl.value;
			if(!tomatch.test(theurl))
			{
				alert("Vänligen ange en giltig URL adress.");
				mf.recipeurl.focus();
				return false;
			}
		}
		return true;
	}

	function checkForgotPass(mf)
	{
		if(trim(mf.email.value)=="")
		{ 
			alert("Ange e-postadress!");
			mf.email.focus();
			return false;
		}
		if(checkEmail(mf.email)==false)
		{
			mf.email.focus();
			return false; 
		}
		return true;
	}
//-->
