/* The various registration forms all use the same name frmReg for the actual
   form within the page, so that functions like ToggleDivWbstDtctnMthdDetail can
   be used on all the Reg.. pages */

function ToggleDivWbstDtctnMthdDetail()
  {
  var lcSelectedIndex = document.frmReg.cmbWbstDtctnMthd.selectedIndex
  var lcSelectedValue = document.frmReg.cmbWbstDtctnMthd.options[lcSelectedIndex].value
  var llShow = ((lcSelectedValue == "advert") || (lcSelectedValue == "brochure") || (lcSelectedValue == "referral") || (lcSelectedValue == "reseller") || (lcSelectedValue == "searchengine_other") || (lcSelectedValue == "tradeshow") || (lcSelectedValue == "other"))

  if (llShow)
    {
    idDivWbstDtctnMthdDetailCaption.style.display='block';
    idDivWbstDtctnMthdDetailText.style.display='block';
    // Show label appropriate to selected WbstDtctnMthd:
    if ((lcSelectedValue == "advert") || (lcSelectedValue == "brochure") || (lcSelectedValue == "reseller") || (lcSelectedValue == "searchengine_other") || (lcSelectedValue == "tradeshow"))
      idPWbstDtctnMthdDetailCaption.innerText = "Which one?"
    else if (lcSelectedValue == "referral")
      idPWbstDtctnMthdDetailCaption.innerText = "Referred by"
    else if (lcSelectedValue == "other")
      idPWbstDtctnMthdDetailCaption.innerText = "Detail"
    }
  else
    {
    idDivWbstDtctnMthdDetailCaption.style.display='none';
    idDivWbstDtctnMthdDetailText.style.display='none';
    document.frmReg.txtWbstDtctnMthdDetail.value="";
    }
  }

// Start of validation of Org/Person with frmReg --------------------------------------

function MissingData_frmReg_OrgPrsn()
  /* USE: If input in Org and Person fields in frmReg on current document is valid
     return "" else return indicator or missing data, in a way which can follow
     'Please specify'.
     NOTES:
     1. Because there are many checks, just report on one error at a time.
     2. This function also sets focus to the field with error - because no way to
        also return this indicator to caller.                                        */
  {
  var lcErrMsg = ""
  var lInp			// Input element to set focus to after showing alert.
  var lcAddrCountry
  var lcNA = "na"

  if (lcErrMsg.length == 0)
    {    
    lInp = document.frmReg.radOrgIs[0];
    if (!frmReg_ValidRadOrgIs())
      lcErrMsg = "what The Organisation Is";
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgName;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation's Name";
    else if (lInp.value.length < 4)
      lcErrMsg = "the Organisation's FULL Name";
    }

   if (lcErrMsg.length == 0)
    /* Only check for IDD no. if Country is specified and is not Australia
       (knowing that subsequent check ensures country is specified so, if
        if country is not specified, these checks will run again and, if
        country is then not Australia, can then check IDD). */
    {
    lcAddrCountry = document.frmReg.txtAddrCountry.value;
    lInp = document.frmReg.txtPhIDD;
    // If country is specified and not Australia
    if ((lcAddrCountry.length != 0) && (lcAddrCountry.toUpperCase() != "AUSTRALIA"))
      {
      if (lInp.value.length == 0)
        lcErrMsg = "the IDD no. for the Organisation's phone no.";
      }
    }

  if (lcErrMsg.length == 0)
    {
    if (document.frmReg.txtPhSTD.value.length == 0)
      {
      lInp = document.frmReg.txtPhSTD;
      if (document.frmReg.txtPh.value.length == 0)
        lcErrMsg = "the Organisation's phone number (including the STD code, or 'na' if an STD code is not applicable)";
      else
        lcErrMsg = "the STD code for the Organisation's phone number (or 'na' if an STD code is not applicable)";
      }
    else
      if (document.frmReg.txtPh.value.length == 0)
        {
        lInp = document.frmReg.txtPh;
        lcErrMsg = "the Organisation's phone number";
        }
    }

  // Check all Org. ph/fx numbers are numeric or, for IDD/STD, =lcNA (ie not applic).
  // Phrase ErrMsg so it can have "Please specify" ahead of it:
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtPhIDD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the IDD code for the Organisation's phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtPhSTD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the STD code for the Organisation's phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtPh;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the Organisation's phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtFx;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the Organisation's fax number with numeric characters only, and with no spaces";
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtAddrPlace;
    if (lInp.value.length == 0)
      lcErrMsg = "the Place (city/town) in which the Organisation is located";
    else if (lInp.value.length < 3)
      lcErrMsg = "the FULL name of the Place (city/town) in which the Organisation is located";
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtAddrCountry;
    if (lInp.value.length == 0)
      lcErrMsg = "the Country in which the Organisation is located";
    else if (lInp.value.length < 3)
      lcErrMsg = "the FULL name of the Country in which the Organisation is located";
    }

  if (lcErrMsg.length == 0)
    {
    if (document.frmReg.txtFirstName.value.length == 0)
      {
      lInp = document.frmReg.txtFirstName;
      if (document.frmReg.txtLastName.value.length == 0)
        lcErrMsg = "your First and Last Names";
      else
        lcErrMsg = "your First Name";
      }
    else if (document.frmReg.txtLastName.value.length == 0)
      {
      lInp = document.frmReg.txtLastName;
      lcErrMsg = "your Last Name";
      }
    else if (document.frmReg.txtFirstName.value.length < 2)
      {
      lInp = document.frmReg.txtFirstName;
      lcErrMsg = "your FULL First Name";
      }
    else if (document.frmReg.txtLastName.value.length < 2)
      {
      lInp = document.frmReg.txtLastName;
      lcErrMsg = "your FULL Last Name";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtPosition;
    if (lInp.value.length == 0)
      lcErrMsg = "your Position in the Organisation";
    }

  if (lcErrMsg.length == 0)
    {
    var lcEmailAddr
    lInp = document.frmReg.txtEmailAddr;
    if (lInp.value.length == 0)
      lcErrMsg = "your Email address";
    else
      {
      lcEmailAddr = document.frmReg.txtEmailAddr.value;
      if (!ValidEmailAddr(lcEmailAddr))
        lcErrMsg = "a VALID Email address";
      }
    }

  // Check Direct ph/fx numbers are numeric or, for IDD/STD, =lcNA (ie not applic).
  // Phrase ErrMsg so it can have "Please specify" ahead of it:
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPhIDD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the IDD code for your Direct phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPhSTD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the STD code for your Direct phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPh;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "your Direct phone number with numeric characters only, and with no spaces";
    }

  // If an error was found.
  if (lcErrMsg.length != 0)
    {
    lInp.focus();
    }

  return lcErrMsg
  }

// End of validation of Org/Person with frmReg ----------------------------------------

// Start of validation of frmReg on Reg -----------------------------------------------

function ValidFrm_Reg()
  /* USE: If input in frmReg on current document (which should be Reg.htm) is valid return True,
     else return False, display alert for user, and set focus to first field with error.
     NOTE: Because there are many checks, just report on one error at a time. */
  {
  var llValid = true
  var llOrgPrsnErr = false
  var lcErrMsg = ""
  var lInp			// Input element to set focus to after showing alert.
  var lcWbstDtctnMthd
  var lcWbstDtctnMthdDetail
  var lcProgram
  var lcExist

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgType;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation Type (eg Civil Contractor)";
    }

   if (lcErrMsg.length == 0)
    {
      lcErrMsg=MissingData_frmReg_OrgPrsn();
      llOrgPrsnErr=(lcErrMsg.length != 0)
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbWbstDtctnMthd.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbWbstDtctnMthd;
      lcErrMsg = "how you found this website";
      }
    else
      {
      lInp = document.frmReg.txtWbstDtctnMthdDetail;
      lcWbstDtctnMthdDetail = document.frmReg.txtWbstDtctnMthdDetail.value;
      // Not all WbstDtctnMthds require WbstDtctnMthdDetail, and only some are important enough to enforce.
      if (lcWbstDtctnMthdDetail.length == 0)
        if (lcWbstDtctnMthd == "referral")
          lcErrMsg = "the person or company who made the referral";
        else if (lcWbstDtctnMthd == "reseller")
          lcErrMsg = "the reseller who referred you";
        else if (lcWbstDtctnMthd == "tradeshow")
          lcErrMsg = "the tradeshow (eg 'Safety WA, 2007')";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lcProgram = document.frmReg.cmbSW.value;
    if (lcProgram == "unspecified")
      {
      lInp = document.frmReg.cmbSW;
      lcErrMsg = "the software product for which you would like an evaluation copy";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lcExist = document.frmReg.cmbTypeWbstSbmsnSltn.value;
    if (lcExist == "unspecified")
      {
      lInp = document.frmReg.cmbTypeWbstSbmsnSltn;
      lcErrMsg = "the most likely user scenario";
      }
    }

  // The ErrMsg from all tests above this point require 'Please specify' in front:
  // If an error was found.
  if (lcErrMsg.length != 0)
    lcErrMsg = "Please specify " + lcErrMsg + ".\n\nNote that other required fields may also be empty.\nRequired fields are highlighted.";
 
  // ErrMsg for tests beyond this point need to be complete in themselves.
  if (lcErrMsg.length == 0)
    {
    // If the declaration has not been made:
    if (!document.frmReg.chkConfirmEvalEligibility.checked)
      {
      lInp = document.frmReg.chkConfirmEvalEligibility;
      lcErrMsg = "Because you have requested an Evaluation, you must make the Declaration by ticking the checkbox provided."
      }
    }

// If an error was found.
  if (lcErrMsg.length != 0)
    {
    alert(lcErrMsg);
    llValid = false;
    if (!llOrgPrsnErr)
      {
      lInp.focus();
      }
    }
  else
    // Set up the hidden fields required by mailgate:
    {
    document.frmReg.realname.value = document.frmReg.txtFirstName.value + " " + document.frmReg.txtLastName.value
    document.frmReg.email.value = document.frmReg.txtEmailAddr.value
    }

  return llValid
  }

// End of validation of frmReg on Reg -------------------------------------------------

// Start of validation of frmReg on RegBsns -------------------------------------------

function ValidFrm_RegBsns()
  /* USE: If input in frmReg on current document (which should be RegBsns.htm) is valid return True,
     else return False, display alert for user, and set focus to first field with error.
     NOTE: Because there are many checks, just report on one error at a time. */
  {
  var llValid = true
  var llOrgPrsnErr = false
  var lcErrMsg = ""
  var lInp			// Input element to set focus to after showing alert.
  var lcWbstDtctnMthd
  var lcWbstDtctnMthdDetail

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgType;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation Type (eg Civil Contractor)";
    }

   if (lcErrMsg.length == 0)
    {
      lcErrMsg=MissingData_frmReg_OrgPrsn();
      llOrgPrsnErr=(lcErrMsg.length != 0)
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbWbstDtctnMthd.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbWbstDtctnMthd;
      lcErrMsg = "how you found this website";
      }
    else
      {
      lInp = document.frmReg.txtWbstDtctnMthdDetail;
      lcWbstDtctnMthdDetail = document.frmReg.txtWbstDtctnMthdDetail.value;
      // Not all WbstDtctnMthds require WbstDtctnMthdDetail, and only some are important enough to enforce.
      if (lcWbstDtctnMthdDetail.length == 0)
        if (lcWbstDtctnMthd == "referral")
          lcErrMsg = "the person or company who made the referral";
        else if (lcWbstDtctnMthd == "reseller")
          lcErrMsg = "the reseller who referred you";
        else if (lcWbstDtctnMthd == "tradeshow")
          lcErrMsg = "the tradeshow (eg 'Safety WA, 2007')";
      }
    }

  if (lcErrMsg.length == 0)
    {    
    lInp = document.frmReg.radPrtnrgEnqryRqrmnt[0];
    if (!frmReg_ValidRadPrtnrgEnqryRqrmnt())
      lcErrMsg = "your Requirements";
    }

  // The ErrMsg from all tests above this point require 'Please specify' in front:
  // If an error was found.
  if (lcErrMsg.length != 0)
    lcErrMsg = "Please specify " + lcErrMsg + ".\n\nNote that other required fields may also be empty.\nRequired fields are highlighted.";
 
  // If an error was found.
  if (lcErrMsg.length != 0)
    {
    alert(lcErrMsg);
    llValid = false;
    if (!llOrgPrsnErr)
      {
      lInp.focus();
      }
    }
  else
    // Set up the hidden fields required by mailgate:
    {
    document.frmReg.realname.value = document.frmReg.txtFirstName.value + " " + document.frmReg.txtLastName.value
    document.frmReg.email.value = document.frmReg.txtEmailAddr.value
    }

  return llValid
  }

// End of validation of frmReg on RegBsns ---------------------------------------------

// Start of validation of frmReg on Email ---------------------------------------------

function ValidFrm_Email()
  /* USE: If input in frmReg on current document (which should be Email.htm) is valid return True,
     else return False, display alert for user, and set focus to first field with error.
     NOTE: Because there are many checks, just report on one error at a time. */
  {
  var llValid = true
  var llOrgPrsnErr = false
  var lcErrMsg = ""
  var lInp			// Input element to set focus to after showing alert.
  var lcWbstDtctnMthd
  var lcWbstDtctnMthdDetail

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgType;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation Type (eg Civil Contractor)";
    }

  if (lcErrMsg.length == 0)
    {
      lcErrMsg=MissingData_frmReg_OrgPrsn();
      llOrgPrsnErr=(lcErrMsg.length != 0)
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbWbstDtctnMthd.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbWbstDtctnMthd;
      lcErrMsg = "how you found this website";
      }
    else
      {
      lInp = document.frmReg.txtWbstDtctnMthdDetail;
      lcWbstDtctnMthdDetail = document.frmReg.txtWbstDtctnMthdDetail.value;
      // Not all WbstDtctnMthds require WbstDtctnMthdDetail, and only some are important enough to enforce.
      if (lcWbstDtctnMthdDetail.length == 0)
        if (lcWbstDtctnMthd == "referral")
          lcErrMsg = "the person or company who made the referral";
        else if (lcWbstDtctnMthd == "reseller")
          lcErrMsg = "the reseller who referred you";
        else if (lcWbstDtctnMthd == "tradeshow")
          lcErrMsg = "the tradeshow (eg 'Safety WA, 2007')";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtEmailBody;
    if (lInp.value.length == 0)
      lcErrMsg = "the Details of your email";
    }

  // The ErrMsg from all tests above this point require 'Please specify' in front:
  // If an error was found.
  if (lcErrMsg.length != 0)
    lcErrMsg = "Please specify " + lcErrMsg + ".\n\nNote that other required fields may also be empty.\nRequired fields are highlighted.";
 
  // If an error was found.
  if (lcErrMsg.length != 0)
    {
    alert(lcErrMsg);
    llValid = false;
    if (!llOrgPrsnErr)
      {
      lInp.focus();
      }
    }
  else
    // Set up the hidden fields required by mailgate:
    {
    document.frmReg.realname.value = document.frmReg.txtFirstName.value + " " + document.frmReg.txtLastName.value
    document.frmReg.email.value = document.frmReg.txtEmailAddr.value
    }

  return llValid
  }

// End of validation of frmReg on Email -----------------------------------------------


// Start of validation of frmReg on Quote ---------------------------------------------

function ValidFrm_Quote()
  /* USE: If input in frmReg on current document (which should be Quote.htm) is valid return True,
     else return False, display alert for user, and set focus to first field with error.
     NOTE: Because there are many checks, just report on one error at a time. */
  {
  var llValid = true
  var llOrgPrsnErr = false
  var lcErrMsg = ""
  var lInp			// Input element to set focus to after showing alert.
  var lcWbstDtctnMthd
  var lcWbstDtctnMthdDetail

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgType;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation Type (eg Civil Contractor)";
    }

  if (lcErrMsg.length == 0)
    {
      lcErrMsg=MissingData_frmReg_OrgPrsn();
      llOrgPrsnErr=(lcErrMsg.length != 0)
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbWbstDtctnMthd.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbWbstDtctnMthd;
      lcErrMsg = "how you found this website";
      }
    else
      {
      lInp = document.frmReg.txtWbstDtctnMthdDetail;
      lcWbstDtctnMthdDetail = document.frmReg.txtWbstDtctnMthdDetail.value;
      // Not all WbstDtctnMthds require WbstDtctnMthdDetail, and only some are important enough to enforce.
      if (lcWbstDtctnMthdDetail.length == 0)
        if (lcWbstDtctnMthd == "referral")
          lcErrMsg = "the person or company who made the referral";
        else if (lcWbstDtctnMthd == "reseller")
          lcErrMsg = "the reseller who referred you";
        else if (lcWbstDtctnMthd == "tradeshow")
          lcErrMsg = "the tradeshow (eg 'Safety WA, 2007')";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbSW.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbSW;
      lcErrMsg = "the software product for which a quotation is required";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtLicenceRqrd;
    if (lInp.value.length == 0)
      lcErrMsg = "the Licence(s) Required";
    }

  // The ErrMsg from all tests above this point require 'Please specify' in front:
  // If an error was found.
  if (lcErrMsg.length != 0)
    lcErrMsg = "Please specify " + lcErrMsg + ".\n\nNote that other required fields may also be empty.\nRequired fields are highlighted.";
 
  // If an error was found.
  if (lcErrMsg.length != 0)
    {
    alert(lcErrMsg);
    llValid = false;
    if (!llOrgPrsnErr)
      {
      lInp.focus();
      }
    }
  else
    // Set up the hidden fields required by mailgate:
    {
    document.frmReg.realname.value = document.frmReg.txtFirstName.value + " " + document.frmReg.txtLastName.value
    document.frmReg.email.value = document.frmReg.txtEmailAddr.value
    }

  return llValid
  }

// End of validation of frmReg on Quote -----------------------------------------------

// Start of validation of frmReg on WishList ------------------------------------------

function ValidFrm_WishList()
  /* USE: If input in frmReg on current document (which should be WishList.htm) is valid return True,
     else return False, display alert for user, and set focus to first field with error.
     NOTE: Because there are many checks, just report on one error at a time. */
  {
  var llValid = true
  var llOrgPrsnErr = false
  var lcErrMsg = ""
  var lcNA = "na"
  var lInp			// Input element to set focus to after showing alert.

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtOrgName;
    if (lInp.value.length == 0)
      lcErrMsg = "the Organisation's Name";
    else if (lInp.value.length < 4)
      lcErrMsg = "the Organisation's FULL Name";
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtAddrPlace;
    if (lInp.value.length == 0)
      lcErrMsg = "the Place (city/town) in which the Organisation is located";
    else if (lInp.value.length < 3)
      lcErrMsg = "the FULL name of the Place (city/town) in which the Organisation is located";
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtAddrCountry;
    if (lInp.value.length == 0)
      lcErrMsg = "the Country in which the Organisation is located";
    else if (lInp.value.length < 3)
      lcErrMsg = "the FULL name of the Country in which the Organisation is located";
    }

  if (lcErrMsg.length == 0)
    {
    if (document.frmReg.txtFirstName.value.length == 0)
      {
      lInp = document.frmReg.txtFirstName;
      if (document.frmReg.txtLastName.value.length == 0)
        lcErrMsg = "your First and Last Names";
      else
        lcErrMsg = "your First Name";
      }
    else if (document.frmReg.txtLastName.value.length == 0)
      {
      lInp = document.frmReg.txtLastName;
      lcErrMsg = "your Last Name";
      }
    else if (document.frmReg.txtFirstName.value.length < 2)
      {
      lInp = document.frmReg.txtFirstName;
      lcErrMsg = "your FULL First Name";
      }
    else if (document.frmReg.txtLastName.value.length < 2)
      {
      lInp = document.frmReg.txtLastName;
      lcErrMsg = "your FULL Last Name";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtPosition;
    if (lInp.value.length == 0)
      lcErrMsg = "your Position in the Organisation";
    }

  if (lcErrMsg.length == 0)
    {
    var lcEmailAddr
    lInp = document.frmReg.txtEmailAddr;
    if (lInp.value.length == 0)
      lcErrMsg = "your Email address";
    else
      {
      lcEmailAddr = document.frmReg.txtEmailAddr.value;
      if (!ValidEmailAddr(lcEmailAddr))
        lcErrMsg = "a VALID Email address";
      }
    }

  // Check Direct ph/fx numbers are numeric or, for IDD/STD, =lcNA (ie not applic).
  // Phrase ErrMsg so it can have "Please specify" ahead of it:
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPhIDD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the IDD code for your Direct phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPhSTD;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "the STD code for your Direct phone number with numeric characters only, and with no spaces";
    }
  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtDirectPh;
    if (lInp.value.length > 0)
      if ((lInp.value!=lcNA) && (!ValidPh(lInp.value)))
        lcErrMsg = "your Direct phone number with numeric characters only, and with no spaces";
    }

  if (lcErrMsg.length == 0)
    {
    lcWbstDtctnMthd = document.frmReg.cmbSW.value;
    if (lcWbstDtctnMthd == "unspecified")
      {
      lInp = document.frmReg.cmbSW;
      lcErrMsg = "the software product for which the WishList is being submitted";
      }
    }

  if (lcErrMsg.length == 0)
    {
    lInp = document.frmReg.txtWish01;
    if (lInp.value.length == 0)
      lcErrMsg = "Wish 1";
    }

  // The ErrMsg from all tests above this point require 'Please specify' in front:
  // If an error was found.
  if (lcErrMsg.length != 0)
    lcErrMsg = "Please specify " + lcErrMsg + ".\n\nNote that other required fields may also be empty.\nRequired fields are highlighted.";
 
  // If an error was found.
  if (lcErrMsg.length != 0)
    {
    alert(lcErrMsg);
    llValid = false;
    if (!llOrgPrsnErr)
      {
      lInp.focus();
      }
    }
  else
    // Set up the hidden fields required by mailgate:
    {
    document.frmReg.realname.value = document.frmReg.txtFirstName.value + " " + document.frmReg.txtLastName.value
    document.frmReg.email.value = document.frmReg.txtEmailAddr.value
    }

  return llValid
  }

// End of validation of frmReg on WishList --------------------------------------------

function frmReg_ValidRadOrgIs()
  /* USE: If an option is selected in radOrgIs return True, else False. */
  {
  var llValid
  var grpOrgIs = document.frmReg.radOrgIs
  for (var i=0; i<grpOrgIs.length; i++)
    {
    if (grpOrgIs[i].checked) break;
    }
  llValid = (i!=grpOrgIs.length)
  return llValid
  }

function frmReg_ValidRadPrtnrgEnqryRqrmnt()
  /* USE: If an option is selected in radPrtnrgEnqryRqrmnt return True, else False. */
  {
  var llValid
  var grpPrtnrgEnqryRqrmnt = document.frmReg.radPrtnrgEnqryRqrmnt
  for (var i=0; i<grpPrtnrgEnqryRqrmnt.length; i++)
    {
    if (grpPrtnrgEnqryRqrmnt[i].checked) break;
    }
  llValid = (i!=grpPrtnrgEnqryRqrmnt.length)
  return llValid
  }

function ValidEmailAddr(pcEmailAddr)
  /* USE: Returns True if valid EmailAddr supplied, else false.
     NOTE: Intention was to test for the following but currently doesn't do it properly:
                      a minimum length of 6;
                      one and only one @;
                      name ahead of @ must start with a-z or 0-9, not a dot or space;
                      after first part of name ahead of @, can have multiple instances of (alphanumeric followed by one dot);
                      after @ must have at least one alphanumeric then 0 or more alphabetic or hyphen, and can then have multiple instances of (dot followed by alphanumeric, hyphen or underscore);
                      2 to 4 closing alphabetic characters (for .biz, .info, .tv etc).
           Spaces are allowed, except in domain name, but don't know how it is happening. */
  {
  var lregexpr = /[a-z0-9-_]{1,}(([\.]{1}[a-z0-9-_]{1,}){0,})@[a-z0-9]{1,}[a-z0-9-]{0,}[\.]{1}(([a-z0-9-_]{1,}[\.]{1}){0,})[a-z]{2,4}/;

  var llValid = (pcEmailAddr.length >= 6);
  if (llValid)
    {
    // lregexpr.ignoreCase = true;  Doesn't work. Replaced with toLowerCase:
    llValid = lregexpr.test(pcEmailAddr.toLowerCase());
    }
  return llValid;
  }

function ValidPh(pcNum)
  // Returns true if pcNum contains only numeric characters and no spaces, else false.
  {
  var lregexpr = /\D/;			//Any non-numeric char.
  return !lregexpr.test(pcNum);
  }

function SetChk(pcChkFld, pcTxtFld)
  // If there is text in the txt field, and the chkbox is not set, set the chkbox.
  {
  var elementTxtFld = document.getElementById(pcTxtFld)
  var elementChkFld = document.getElementById(pcChkFld)
  if ((elementTxtFld.value.length != 0) && (elementChkFld.checked == false))
      elementChkFld.checked = true;
  }

function ClearIfNoChk(pcChkFld, pcTxtFld)
  // If the chkbox is not set, but there is text in the txt field, clear the text in the text fld.
  {
  var elementTxtFld = document.getElementById(pcTxtFld)
  var elementChkFld = document.getElementById(pcChkFld)
  if ((elementTxtFld.value.length != 0) && (elementChkFld.checked == false))
      elementTxtFld.value="";
  }