// JavaScript Document
function Validate() {
  if (Form1.FullName.value == "") {
    alert("Please enter a value for the \"FullName\" field.");
    Form1.FullName.focus();
    return (false);
  }
  if (Form1.FullName.value.length > 60) {
    alert("Please enter at most 60 characters in the \"FullName\" field.");
    Form1.FullName.focus();
    return (false);
  }
  if (Form1.CompanySchoolGuild.value == "") {
    alert("Please enter a value for the \"Company\" field.");
    Form1.CompanySchoolGuild.focus();
    return (false);
  }
  if (Form1.CompanySchoolGuild.value.length > 100) {
    alert("Please enter at most 100 characters in the \"Company\" field.");
    Form1.CompanySchoolGuild.focus();
    return (false);
  }
  if (Form1.Phone.value == "") {
    alert("Please enter a value for the \"Phone\" field.");
    Form1.Phone.focus();
    return (false);
  }
  if (Form1.Phone.value.length < 3) {
    alert("Please enter at least 3 characters in the \"Phone\" field.");
    Form1.Phone.focus();
    return (false);
  }
  if (Form1.Phone.value.length > 50) {
    alert("Please enter at most 50 characters in the \"Phone\" field.");
    Form1.Phone.focus();
    return (false);
  }
  if (Form1.email.value == "") {
    alert("Please enter a value for the \"email\" field.");
    Form1.email.focus();
    return (false);
  }
  if (isValidEmail(Form1.email.value) != true) {
    alert("Please enter a valid email address.");
    Form1.email.focus();
    return (false);
  }
  if (Form1.Add1.value == "") {
    alert("Please enter a value for the \"Address line 1\" field.");
    Form1.Add1.focus();
    return (false);
  }
  if (Form1.city.value == "") {
    alert("Please enter a value for the \"city\" field.");
    Form1.city.focus();
    return (false);
  }
  if (Form1.city.value.length > 50) {
    alert("Please enter at most 50 characters in the \"city\" field.");
    Form1.city.focus();
    return (false);
  }
  if (Form1.state.selectedIndex == 0) {
    alert("The first \"State\" option is not a valid selection.  Please choose one of the other options.");
    Form1.state.focus();
    return (false);
  }
  if (Form1.country.selectedIndex == 0) {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    Form1.country.focus();
    return (false);
  }
  if (Form1.Zip.value == "") {
    alert("Please enter a value for the \"Postal Code\" field.");
    Form1.Zip.focus();
    return (false);
  }
  return (true);
}

function ValidateAdmin() {
  if (Form2.FullName.value == "") {
    alert("Please enter a value for the \"FullName\" field.");
    Form2.FullName.focus();
    return (false);
  }
  if (Form2.FullName.value.length > 60) {
    alert("Please enter at most 60 characters in the \"FullName\" field.");
    Form2.FullName.focus();
    return (false);
  }
  if (Form2.CompanySchoolGuild.value == "") {
    alert("Please enter a value for the \"Company\" field.");
    Form2.CompanySchoolGuild.focus();
    return (false);
  }
  if (Form2.CompanySchoolGuild.value.length > 100) {
    alert("Please enter at most 100 characters in the \"Company\" field.");
    Form2.CompanySchoolGuild.focus();
    return (false);
  }
  if (Form2.Phone.value == "") {
    alert("Please enter a value for the \"Phone\" field.");
    Form2.Phone.focus();
    return (false);
  }
  if (Form2.Phone.value.length < 3) {
    alert("Please enter at least 3 characters in the \"Phone\" field.");
    Form2.Phone.focus();
    return (false);
  }
  if (Form2.Phone.value.length > 50) {
    alert("Please enter at most 50 characters in the \"Phone\" field.");
    Form2.Phone.focus();
    return (false);
  }
  if (Form2.email.value == "") {
    alert("Please enter a value for the \"email\" field.");
    Form2.email.focus();
    return (false);
  }
  if (isValidEmail(Form2.email.value) != true) {
    alert("Please enter a valid email address.");
    Form2.email.focus();
    return (false);
  }
  if (Form2.Add1.value == "") {
    alert("Please enter a value for the \"Address line 1\" field.");
    Form2.Add1.focus();
    return (false);
  }
  if (Form2.city.value == "") {
    alert("Please enter a value for the \"city\" field.");
    Form2.city.focus();
    return (false);
  }
  if (Form2.city.value.length > 50) {
    alert("Please enter at most 50 characters in the \"city\" field.");
    Form2.city.focus();
    return (false);
  }
  if (Form2.state.value == "") {
    alert("Please enter a value for the \"State\" field.");
    Form2.state.focus();
    return (false);
  }
  if (Form2.country.value == "") {
    alert("Please enter a value for the \"Country\" field.");
    Form2.country.focus();
    return (false);
  }
  if (Form2.Zip.value == "") {
    alert("Please enter a value for the \"Postal Code\" field.");
    Form2.Zip.focus();
    return (false);
  }
  return (true);
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield.value = maxlimit - field.value.length;
}

function isValidEmail(str) {
	return (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(str))
}
