function validate_firstname(field, alerttxt)
{
	with (field)
	{
    	if(value == null || value.length == 0)
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
}
function validate_lastname(field, alerttxt)
{
	with (field)
	{
		if(value == null || value.length == 0)
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
}
function validate_acs(field, alerttxt)
{
  with(field)
  {
    if(value == null || value.length == 0)
    {
      alert(alerttxt);
      return false;
    }
    else    { return true;}
  }
}
function validate_zip(field, alerttxt)
{
  with(field)
  {
    if(value == null || value.length != 5)
    {
      alert(alerttxt);
      return false;
    }
    else    { return true;}
  }
}
function validate_year(field, alerttxt)
{
  with(field)
  {
    if(value == null || value.length != 4)
    {
      alert(alerttxt);
      return false;
    }
    else    { return true;}
  }
}
function validate_phone(field1, field2, field3, alerttxt)
{
	with (field1)
	{
		if(value == null || value.length < 3)
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
	with (field3)
	{
		if(value == null || value.length < 4)
		{
			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)
{
	with (thisform)
	{
		if (validate_email(r_email,"Not a valid e-mail address")==false)
		{
			r_email.focus();
			return false;
		}
		if (validate_firstname(r_firstname,"Please include your first name")==false)
		{
			r_firstname.focus();
			return false;
		}
		if (validate_lastname(r_lastname,"Please include your last name")==false)
		{
			r_lastname.focus();
			return false;
		}
		if (validate_phone(r_phone1, r_phone2, r_phone3,"Please include a valid phone number")==false)
		{
			r_phone1.focus();
			return false;
		}
		if (validate_year(r_yob,"Not a valid year of birth")==false)
		{
			r_yob.focus();
			return false;
		}
		if (validate_acs(r_address1,"Please provide a valid address")==false)
		{
			r_address1.focus();
			return false;
		}
		if (validate_acs(r_city,"Please provide a valid city name")==false)
		{
			r_city.focus();
			return false;
		}
		if (validate_acs(r_state,"Please provide a valid state")==false)
		{
			r_state.focus();
			return false;
		}                               
		if (validate_zip(r_zip,"Please provide a valid zip code")==false)
		{
			r_zip.focus();
			return false;
		}                               
	}
}
