// JavaScript Document
function fill(val)
{
	document.frm.username.value = val;
}


function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) 
		  {alert(alerttxt);return false;}
		else {return true;}
	}
}

function isEmpty(Field, Name)
{
	Msg = Name+ ' is Required Field'
	if(Field.value == "")
	{
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}

function check(field,field1,alerttxt)
{
	if(field.value!=field1.value)
	{
		alert(alerttxt);return false;
	}
	else
	{	return true; }
}

function validate_mail(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
		{
			  	alert(alerttxt);
				return false;
		}
		else { return true; }
	}
}

function validate_name(field,alerttxt)
{
	if(eval(field.value.length) > 12 || eval(field.value.length) < 6)
	{
			alert(alerttxt);
			return false;
	}
	return true;
}


function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_mail(fname,"Please Enter your First Name!")==false)
		  {fname.focus();return false;}
	}
	
	with (thisform)
	{
		if (validate_mail(lname,"Please Enter your Last Name!")==false)
		  {lname.focus();return false;}
	}

	with (thisform)
	{
	if (validate_mail(email,"Please Enter your Email Address!")==false)
	  {email.focus();return false;}
	}

	with (thisform)
	{
		if (validate_email(email,"Not a valid e-mail address!")==false)
		  {email.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(orgname,"Please Enter your Organisation Name!")==false)
		  {orgname.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(title,"Please Enter your Organisation title!")==false)
		{
			  title.focus();
			  return false;
		}
	}

	with (thisform)
	{
		if (validate_mail(phone,"Please Enter your Contact Number!")==false)
		  {phone.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(address,"Please Enter your Address!")==false)
		  {address.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(city,"Please Enter your City!")==false)
		  {city.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(state,"Please Enter your State!")==false)
		  {state.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(zip,"Please Enter your Zip Code!")==false)
		  {zip.focus();return false;}
	}

	with (thisform)
	{
		if (validate_mail(username,"Please Enter Username!")==false)
		  {username.focus();return false;}
	}

/*with (thisform)
{
if (validate_name(username,"Please Enter username Between 6 to 12 characters!")==false)
  {username.focus();return false;}
}*/

	with (thisform)
	{
		if (validate_mail(password,"Please Enter Password!")==false)
		  {password.focus();return false;}
	}

/*with (thisform)
{
if (validate_name(password,"Please Enter Password Between 6 to 12 characters!")==false)
  {password.focus();return false;}
}*/

	with (thisform)
	{
		if (validate_mail(cpassword,"Please Enter Confirm Password!")==false)
		  {cpassword.focus();return false;}
	}

	with (thisform)
	{
		if (check(password,cpassword,"Your Password does not Match!")==false)
		{
			  cpassword.focus();return false;
		}
	}
	
	with(thisform)
{
if(check(email,username,"Email and Username does not Match")==false)
	{email.focus();return false;}
}
	
	with(thisform)
	{	
		if(flg.value=="False")
		{alert("Email Already Exist")
		email.focus();
		return false;}
		}
}