﻿// JavaScript Document
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.email1.value == "")
  {
    alert("Please enter a value for the \"E-mail\" field.");
    theForm.email1.focus();
    return (false);
  }

  if (theForm.email1.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"E-mail\" field.");
    theForm.email1.focus();
    return (false);
  }

  if (theForm.email1.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"E-mail\" field.");
    theForm.email1.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzfS<caron>OZ<caron>s<caron>oz<caron>YÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ<ETH>ÑÒÓÔÕÖØÙÚÛÜY´<THORN>ßàáâãäåæçèéêëìíîï<eth>ñòóôõöøùúûüy´<thorn>ÿ0123456789-@-_$.";
  var checkStr = theForm.email1.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 \"E-mail\" field.");
    theForm.email1.focus();
    return (false);
  }

  if (theForm.email2.value == "")
  {
    alert("Please enter a value for the \"email2\" field.");
    theForm.email2.focus();
    return (false);
  }

  if (theForm.email2.value.length < 7)
  {
    alert("Please enter at least 7 characters in the \"email2\" field.");
    theForm.email2.focus();
    return (false);
  }

  if (theForm.email2.value.length > 40)
  {
    alert("Please enter at most 40 characters in the \"email2\" field.");
    theForm.email2.focus();
    return (false);
  }
  
    if (theForm.email2.value != theForm.email1.value)
  {
    alert("Both your email addresses must match.");
    theForm.email2.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzfS<caron>OZ<caron>s<caron>oz<caron>YÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ<ETH>ÑÒÓÔÕÖØÙÚÛÜY´<THORN>ßàáâãäåæçèéêëìíîï<eth>ñòóôõöøùúûüy´<thorn>ÿ0123456789-@$-_.";
  var checkStr = theForm.email2.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 \"email2\" field.");
    theForm.email2.focus();
    return (false);
  }

  if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }

  if (theForm.zip.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }

  if (theForm.zip.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = theForm.zip.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Zip\" field.");
    theForm.zip.focus();
    return (false);
  }
  return (true);
}
