
function FormValidator(theForm)
{


  if (theForm.name == "AuthCodeForm") {

    if (theForm.txtCSHO.value.length <= 0 )
    {
      alert("Please enter a value for the \"Chain Store Head Office\" field.");
      theForm.txtCSHO.focus();
      return (false);
    }

    if (theForm.txtRSBS.value.length <= 0 )
    {
      alert("Please enter a value for the \"Remote Store Base Systems\" field.");
      theForm.txtRSBS.focus();
      return (false);
    }

    if (theForm.txtSSBS.value.length <= 0 )
    {
      alert("Please enter a value for the \"Single Store Base Systems\" field.");
      theForm.txtSSBS.focus();
      return (false);
    }

    if (theForm.txtNSPT.value.length <= 0 )
    {
      alert("Please enter a value for the \"Network Software/P.O.S Terminals\" field.");
      theForm.txtNSPT.focus();
      return (false);
    }


     
		
  } // end if
       

  if (theForm.txtName.value.length <= 0 )
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.txtName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Company Name\" field.");
    theForm.txtName.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'- \t\r\n\f";
  var checkStr = theForm.txtName.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace and \"'-\" characters in the \"Customer Name\" field.");
    theForm.txtName.focus();
    return (false);
  }

  if (theForm.name == "VARAppForm") {
   if (theForm.txtTitle.value == "")
   {
      alert("Please enter a value for the \"Title\" field.");
      theForm.txtTitle.focus();
      return (false);
   }
  } // end if

  if (theForm.name == "VARAppForm") {
   if (theForm.txtBusiness.value == "")
   {
      alert("Please enter a value for the \"Legal Name of Business\" field.");
      theForm.txtBusiness.focus();
      return (false);
   }
  } // end if

  if (theForm.txtAddress.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.txtAddress.focus();
    return (false);
  }

  if (theForm.txtAddress.value.length > 150)
  {
    alert("Please enter at most 150 characters in the \"Address\" field.");
    theForm.txtAddress.focus();
    return (false);
  }

  if (theForm.txtCity.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.txtCity.focus();
    return (false);
  }

  if (theForm.txtCity.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"City\" field.");
    theForm.txtCity.focus();
    return (false);
  }

  if (theForm.sltProvince.selectedIndex < 0)
  {
    alert("Please select one of the \"Province/State\" options.");
    theForm.sltProvince.focus();
    return (false);
  }

  if (theForm.sltProvince.selectedIndex == 0)
  {
    alert("The first \"Province/State\" option is not a valid selection.  Please choose one of the other options.");
    theForm.sltProvince.focus();
    return (false);
  }

  if (theForm.txtPostal.value == "")
  {
    alert("Please enter a value for the \"Postal Code\" field.");
    theForm.txtPostal.focus();
    return (false);
  }

  if (theForm.txtPostal.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Postal Code\" field.");
    theForm.txtPostal.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-- \t\r\n\f";
  var checkStr = theForm.txtPostal.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit, whitespace and \"-\" characters in the \"Postal Code\" field.");
    theForm.txtPostal.focus();
    return (false);
  }
  
  if (theForm.txtPhone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.txtPhone.focus();
    return (false);
  }

  if (theForm.txtPhone.value.length > 20)
  {
    alert("Please enter at most 20 characters in the \"Phone\" field.");
    theForm.txtPhone.focus();
    return (false);
  }

  var checkOK = "0123456789--()+ \t\r\n\f";
  var checkStr = theForm.txtPhone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"-()+\" characters in the \"Phone\" field.");
    theForm.txtPhone.focus();
    return (false);
  }

  if (theForm.name == "AuthCodeForm") {


     if ((theForm.txtFax.value == "") && (theForm.txtEmail.value == ""))
     {
      alert("Please enter either a fax number or an email address to receive your authorization codes.");
      theForm.txtFax.focus();
      return (false);
     }

    if (theForm.txtEmail.value.length > 0 && !checkemail(theForm.txtEmail.value))
    {
    alert("Please enter an valid email address in the \"Email\" field.");
    theForm.txtEmail.focus();
    return (false);
    }


  } // end if

if (theForm.name == "VARAppForm") {
  if (theForm.txtFax.value == "")
  {
    alert("Please enter a value for the \"Fax\" field.");
    theForm.txtFax.focus();
    return (false);
  }
} // end if

  var checkOK = "0123456789--()+ \t\r\n\f";
  var checkStr = theForm.txtFax.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"-()+\" characters in the \"Fax\" field.");
    theForm.txtFax.focus();
    return (false);
  }

if (theForm.name == "VARAppForm") {
  if (theForm.txtEmail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.txtEmail.focus();
    return (false);
  }
} // end if

if (theForm.name == "VARAppForm") {
   var segment = false;
   for (var i = 0; i < theForm.elements.length; i++) {
      if ((theForm.elements(i).name.substring(0,5)) == "chkRS") {
         if (theForm.elements(i).checked == true) 
            segment = true;
         // end if 
      } // end if
   } // end for
   if (segment == false)
   {
      alert("Please select at least one of the \"Reseller Segment\" options.");
      theForm.chkRSConsultant.focus();
      return (false);
   }

} // end form if
  
if (theForm.name == "VARAppForm") {
   var market = false;
   for (var i = 0; i < theForm.elements.length; i++) {
      if ((theForm.elements(i).name.substring(0,5)) == "chkPM") {
         if (theForm.elements(i).checked == true) 
            market = true;
         // end if 
      } // end if
   } // end for
   if (market == false)
   {
      alert("Please select at least one of the \"Principal Markets\" options.");
      theForm.chkPMApparel.focus();
      return (false);
   }
   
} // end form if

if (theForm.name == "AuthCodeForm") {
   
  if (theForm.txtContactName.value == "")
  {
   alert("Please enter a value for the \"Store Owner\" field.");
   theForm.txtContactName.focus();
   return(false);
  }

  if (theForm.txtContactName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Store Owner\" field.");
    theForm.txtContactName.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ-' \t\r\n\f";
  var checkStr = theForm.txtContactName.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace and \"-'\" characters in the \"Store Owner\" field.");
    theForm.txtContactName.focus();
    return (false);
  }

  var checkOK = "0123456789--()+ \t\r\n\f";
  var checkStr = theForm.txtResellerPhone.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"-()+\" characters in the \"Reseller Phone\" field.");
    theForm.txtResellerPhone.focus();
    return (false);
  }

  var checkOK = "0123456789--()+ \t\r\n\f";
  var checkStr = theForm.txtResellerFax.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"-()+\" characters in the \"Reseller Fax\" field.");
    theForm.txtResellerFax.focus();
    return (false);
  }

  if (theForm.txtSecCode.value == "")
  {
    alert("Please enter a value for the \"Security Code\" field.");
    theForm.txtSecCode.focus();
    return (false);
  }

  if (theForm.txtSecCode.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Security Code\" field.");
    theForm.txtSecCode.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789--";
  var checkStr = theForm.txtSecCode.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit, and \"-\" characters in the \"Security Code\" field.");
    theForm.txtSecCode.focus();
    return (false);
  }

} // end form if
  
if (theForm.name == "VARAppForm") {
  var checkOK = "0123456789";
  var checkStr = theForm.txtNumberYears.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Number of years in business\" field.");
    theForm.txtNumberYears.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.txtNumberEmps.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Total number of employees\" field.");
    theForm.txtNumberEmps.focus();
    return (false);
  }

} // end form if
  
  return (true);
}
