<!--
function checkEmail(emailaddress)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailaddress.value))
	{
		return (true);
	}
	alert("Please enter valid email address!");
	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(mf.username.value=="")
	{
		alert("Please enter username");
		mf.username.focus();
		return false;
	}
	if(mf.userpass.value=="")
	{
		alert("Please enter password");
		mf.userpass.focus();
		return false;
	}
	return true;
}

function checkRegistration(mf)
{
	if(mf.name.value=="")
	{
		alert("Please enter name");
		mf.name.focus();
		return false;
	}
	if(mf.phone.value=="")
	{
		alert("Please enter telephone number");
		mf.phone.focus();
		return false;
	}
	var valid= "+-()1234567890 ";
	if (mf.phone.value !="")
	{
		var string = mf.phone.value
		var length = string.length;
		for(var i=0;i<=length;i++)
		{
			var substring = string.substr(i,1);
			if(valid.indexOf(substring)== -1)
			  {
				alert("Please enter valid telephone number");
				mf.phone.select()
				return(false)
			  }
		}
	}
	if(trim(mf.email.value)=="")
	{ 
		alert("Please enter email address");
		mf.email.focus();
		return false;
	}
	if(checkEmail(mf.email)==false)
	{
		mf.email.focus();
		return false; 
	}
	if(mf.city.value=="")
	{
		alert("Please enter city");
		mf.city.focus();
		return false;
	}
	if(mf.state.value=="")
	{
		alert("Please enter state");
		mf.state.focus();
		return false;
	}
	if(mf.zipcode.value=="")
	{
		alert("Please enter postal code");
		mf.zipcode.focus();
		return false;
	}
	if(mf.country.value=="")
	{
		alert("Please select country");
		mf.country.focus();
		return false;
	}
	if(mf.username.value=="")
	{
		alert("Please enter username");
		mf.username.focus();
		return false;
	}
	var valid= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	if (mf.username.value !="")
	{
		var string = mf.username.value
		var length = string.length;
		for(var i=0;i<=length;i++)
		{
			var substring = string.substr(i,1);
			if(valid.indexOf(substring)== -1)
			  {
				alert("Username can have alphanumeric characters only, please try again");
				mf.username.focus();
				return(false)
			  }
		}
	}

	if(mf.userpass.value=="")
	{
		alert("Please enter password");
		mf.userpass.focus();
		return false;
	}
	if(mf.cuserpass.value!=mf.userpass.value)
	{
		alert("Passwords not matching, please check and try again");
		mf.cuserpass.focus();
		return false;
	}
	if(mf.terms.checked==false)
	{
		alert("Please accept the terms of services");
		mf.terms.focus();
		return false;
	}
	return true;
}

function checkContact(mf)
{
	if(mf.name.value=="")
	{
		alert("Please enter name");
		mf.name.focus();
		return false;
	}
	if(mf.phone.value=="")
	{
		alert("Please enter telephone number");
		mf.phone.focus();
		return false;
	}
	var valid= "+-()1234567890 ";
	if (mf.phone.value !="")
	{
		var string = mf.phone.value
		var length = string.length;
		for(var i=0;i<=length;i++)
		{
			var substring = string.substr(i,1);
			if(valid.indexOf(substring)== -1)
			  {
				alert("Please enter valid telephone number");
				mf.phone.select()
				return(false)
			  }
		}
	}
	if(trim(mf.email.value)=="")
	{ 
		alert("Please enter email address");
		mf.email.focus();
		return false;
	}
	if(checkEmail(mf.email)==false)
	{
		mf.email.focus();
		return false; 
	}
	if(mf.country.value=="")
	{
		alert("Please select country");
		mf.country.focus();
		return false;
	}
	if(mf.comments.value=="")
	{
		alert("Please write your message/query");
		mf.comments.focus();
		return false;
	}
	if(mf.security_code.value=="")
	{
		alert("Please enter security code");
		mf.security_code.focus();
		return false;
	}
	return true;
}



/* previously used functions */
function checkPostAd(mf)
{
    var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
	var adsdesc = mf.addesc.value;
	var memplans = mf.adtype.length;
	var checkbusinessadtype = "1";
	for(i=0; i<memplans; i++)
	{
		if(mf.adtype[i].checked==true)
		{
			checkbusinessadtype = "2";
		}
	}
	if(checkbusinessadtype=="1")
	{
		alert("Please select the type of Ad");
		mf.adtype[0].focus();
		return false;
	}
	if(mf.adcategory.value=="" || mf.adcategory.value=="0")
	{
		alert("Please select proper category for your Ad");
		mf.adcategory.focus();
		return false;
	}
	if(mf.adtitle.value=="")
	{
		alert("Please enter Ad title");
		mf.adtitle.focus();
		return false;
	}
	if(mf.desturl.value!="")
	{
		var theurl=mf.desturl.value;
		if(!tomatch.test(theurl))
		{
			alert("Please enter valid URL like http://www.himachalbeauty.com");
			mf.desturl.focus();
			return false;
		}
	}
	if(mf.addesc.value=="")
	{
		alert("Please write Ad description");
		mf.addesc.focus();
		return false;
	}
	if(adsdesc.length>200)
	{
		alert("Ad description should not exceed 200 characters.");
		mf.addesc.focus();
		return false;
	}
	if(mf.conname.value=="")
	{
		alert("Please enter Ad Contact Name");
		mf.conname.focus();
		return false;
	}
	if(mf.country.value=="")
	{
		alert("Please select country");
		mf.country.focus();
		return false;
	}
	if(trim(mf.email.value)=="")
	{ 
		alert("Please enter email address");
		mf.email.focus();
		return false;
	}
	if(checkEmail(mf.email)==false)
	{
		mf.email.focus();
		return false; 
	}
	return true;
}

function checkForgotPass(mf)
{
	if(mf.username.value=="")
	{
		alert("Please enter username");
		mf.username.focus();
		return false;
	}
	var valid= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	if (mf.username.value !="")
	{
		var string = mf.username.value
		var length = string.length;
		for(var i=0;i<=length;i++)
		{
			var substring = string.substr(i,1);
			if(valid.indexOf(substring)== -1)
			  {
				alert("Username can have alphanumeric characters only, please try again");
				mf.username.focus();
				return(false)
			  }
		}
	}
	if(trim(mf.email.value)=="")
	{ 
		alert("Please enter email address");
		mf.email.focus();
		return false;
	}
	if(checkEmail(mf.email)==false)
	{
		mf.email.focus();
		return false; 
	}
	return true;
}
//-->

