
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Company.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.Company.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Company Name\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Please enter a value for the \"E-mail Address\" field.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"E-mail Address\" field.");
    theForm.email.focus();
    return (false);
  }
  
  if (theForm.email.value.indexOf("@") == -1)
  {
    alert("Please enter a valid E-mail Address.");
    theForm.email.focus();
    return (false);
  }
  
  if (theForm.email.value.indexOf(".") == -1)
  {
    alert("Please enter a valid E-mail Address.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.KeyNumber.value == "")
  {
    alert("Please enter a value for the \"Key Number\" field.");
    theForm.KeyNumber.focus();
    return (false);
  }
  
  if (theForm.KeyNumber.value.indexOf("E") == -1 && theForm.KeyNumber.value.indexOf("e") == -1)
  {
    alert("Please enter a valid Key Number.");
    theForm.KeyNumber.focus();
    return (false);
  }

  if (theForm.KeyNumber.value.indexOf("EDI") == -1 && theForm.KeyNumber.value.indexOf("edi") == -1)
  {
    alert("Please enter a valid Key Number.");
    theForm.KeyNumber.focus();
    return (false);
  }
  
  if (theForm.KeyNumber.value.length < 6)
  {
    alert("Please enter a valid Key Number.");
    theForm.KeyNumber.focus();
    return (false);
  }

  if (theForm.KeyNumber.value.length > 8)
  {
    alert("Please enter at most 8 characters in the \"Key Number\" field.");
    theForm.KeyNumber.focus();
    return (false);
  }

  if (theForm.KeyNumber.value != theForm.KeyNumber2.value)
  {
    alert("The key numbers do not match. Please reenter");
    theForm.KeyNumber.value = "";
    theForm.KeyNumber2.value = "";
    theForm.KeyNumber.focus();
    return (false);
  }
  

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-";
  var checkStr = theForm.KeyNumber.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 and digit characters in the \"Key Number\" field. No blanks are allowed.");
    theForm.KeyNumber.focus();
    return (false);
  }

  return (true);
}
