
var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 

function ereg(objText, spCh)
{
  if(spCh == null || spCh == "") spCh = "@._-";

  var rx=/[^A-Za-z\d @._-]/;

  if(rx.test(objText.value) == true)
  {
    objText.value = "";
    alert("You may enter only spaces, alphanumeric and/or these special characters: " + spCh);
    objText.focus();
    return (false);
  } 
  return (true);
}

function ValidateThis(theForm)
{

  if (theForm.FirstName != null && theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName != null && theForm.FirstName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName != null && theForm.FirstName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"First Name\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName != null && theForm.LastName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }


  if (theForm.Email != null && theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

    if (theForm.Harea != null && theForm.Harea.value == "")
  {
    alert("Home Phone # cannot be blank");
    //theForm.Harea.focus();
    return (false);
  }

  if (theForm.Hnum1 != null && theForm.Hnum1.value == "")
  {
    alert("Home Phone # cannot be blank");
    //theForm.Hnum1.focus();
    return (false);
  }

  if (theForm.Hnum2 != null && theForm.Hnum2.value == "")
  {
    alert("Home Phone # cannot be blank");
    //theForm.Hnum2.focus();
    return (false);
  }


  if (theForm.Address != null && theForm.Address.value == "")
  {
    alert("Please enter a value for the \"Street Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.Address != null && theForm.Address.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Street Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.Address != null && theForm.Address.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Street Address\" field.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.City != null && theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City != null && theForm.City.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City != null && theForm.City.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.State != null && theForm.State.value == "" || theForm.State.value == "0")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.ZipCode != null && theForm.ZipCode.value == "")
  {
    alert("Please enter a value for the \"Zip Code\" field.");
    theForm.ZipCode.focus();
    return (false);
  }

  if (theForm.ZipCode != null && theForm.ZipCode.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Zip Code\" field.");
    theForm.ZipCode.focus();
    return (false);
  }

  if (theForm.ZipCode != null && theForm.ZipCode.value.length > 12)
  {
    alert("Please enter at most 12 characters in the \"Zip Code\" field.");
    theForm.ZipCode.focus();
    return (false);
  }


  if (theForm.dobVerifier != null && theForm.dobVerifier.checked == false)
  {
    alert("You must affirm that you are 18 or older!");
    theForm.dobVerifier.focus();
    return (false);
  }

  if (!theForm.becomeDist.checked && !theForm.bookParty.checked && !theForm.requestCat.checked )
  {
    alert("You must select an Area of Interest!");
    theForm.becomeDist.focus();
    return (false);
  }
  
 
  return (true);
}


 
 function autoTab( input,len, e ) { 
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 
	var filter	= ( isNN ) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if( input.value.length >= len && !containsElement( filter, keyCode )) { 
	input.value = input.value.slice( 0, len ); 
	input.form[( getIndex( input ) + 1 ) % input.form.length].focus(); 
	} 
	return true; 
} 
 
