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

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 validate_form(thisform)
{		
	valid = true;
	
	with (thisform)
  	{
  	if (validate_required(FirstName,"Please enter your first name in the field below.")==false)
  	{FirstName.focus(); valid = false; return valid;}
  	if (validate_required(LastName,"Please enter your last name in the field below.")==false)
  	{LastName.focus(); valid = false; return valid;}
  	if (validate_required(Company,"Please enter your company in the field below.")==false)
  	{Company.focus(); valid = false; return valid;}
  	if (validate_required(OfficePhoneNumber,"Please enter your phone number in the field below.")==false)
  	{OfficePhoneNumber.focus(); valid = false; return valid;}
  	if (valid==validate_email(Email,"Please enter a valid email address in the field below.")==false)
    {email.focus(); valid = false; return valid;}
  	if (validate_required(Passwordx,"Please enter your password in the field below.")==false)
  	{Passwordx.focus(); valid = false; return valid;}
	}

  	  	
  	return valid;
}
