<!-- //...  Hide from old browsers...

function chkReset(theForm) {
   //...  Check to reset this form...
   var retval;         //...  return value...
   
   //...  Prompt the user wish to reset the form...
   retval = confirm("Do you REALLY wish to reset this form?");
   
   //...  Return to the caller...
   return retval;
}

function validate(theForm) {
   //...  Validate the entire form...
   var retval;         //...  return value...
   var errnum;         //...  error count...
   var errmsg;         //...  error message(s)...
   var i;              //...  just a counter...
   var reply;          //...  user reply to order confirmation...
   var user_specs;     //...  the user\'s order...

   //...  Initialize error indicators...
   retval = true;
   errnum = 0;
   errmsg = "";
   user_specs = "";

   //...  Validate the first name...
   if (isEmpty(theForm.fname.value)) {
      errnum++;
      errmsg += "\n" + errnum + ")  First name MUST be entered.";
      if (errnum == 1) {
         theForm.fname.focus();
         theForm.fname.select();
      }
   } else {

      //...  Add to order confirmation...
      user_specs += "\nFirst Name: " + trim(theForm.fname.value);
   }

   //...  Validate the last name...
   if (isEmpty(theForm.lname.value)) {
      errnum++;
      errmsg += "\n" + errnum + ")  Last name MUST be entered.";
      if (errnum == 1) {
         theForm.lname.focus();
         theForm.lname.select();
      }
   } else {

      //...  Add to order confirmation...
      user_specs += "\nLast Name: " + trim(theForm.lname.value);
   }

   //...  Validate the email address...
   theForm.email.value = trim(theForm.email.value);
   if (isEmpty(theForm.email.value)) {
      errnum++;
      errmsg += "\n" + errnum + ")  Email MUST be entered.";
      if (errnum == 1) {
         theForm.email.focus();
         theForm.email.select();
      }
   } else {
      if (!validEmail(theForm.email.value)) {
         errnum++;
         errmsg += "\n" + errnum + ")  Email is illegal.";
         if (errnum == 1) {
            theForm.email.focus();
            theForm.email.select();
         }
      } else {
         //...  Add to registration confirmation...
         user_specs += "\nEmail: " + trim(theForm.email.value);
      }
   }

   //...  Check for any errors...
   if (errnum > 0) {
      
      //...  Indicate errors and display all messages...
      retval = false;
      errmsg = "Please correct the following errors:\n" + errmsg
      alert(errmsg);
   } else {
   
      //...  Display the order for confirmation...
      user_specs = "Please confirm your email\n" + user_specs;
      retval = confirm(user_specs);
   }

   //...  Return to the caller...
   return retval;
}

function trim(fld) {
   //...  Remove leading and trailing blanks from a field...
   var retval;                //...  return value...
   var i;                     //...  just a counter...
   var done;                  //...  indicates non-blank found...

   //...  Copy the field to trim...
   retval = fld;

   //...  Remove leading blanks...
   i = 0;
   done = false;
   while (i < retval.length  &&  !done) {
      if (retval.charAt(i) != " ") {
         done = true;
      } else {
         i++;
      }
   }
   retval = retval.substring(i);

   //...  Remove trailing blanks...
   i = retval.length - 1;
   done = false;
   while (i >= 0  &&  !done) {
      if (retval.charAt(i) != " ") {
         done = true;
      } else {
         i--;
      }
   }
   retval = retval.substring(0,i+1);

   //...  Return to the caller...
   return retval;
}

function isNum(fld) {
   //...  Check for a field of numbers...
   var retval;                //...  return value...
   var i;                     //...  just a counter...
   var done;                  //...  indicates non-number found...

   //...  Assume field contains all numbers...
   retval = true;

   //...  Check for field of length 0...
   if (fld.length == 0) {
      retval = false;
   } else {

      //...  Scan field for a non-number...
      for (i=0; i<fld.length && retval; i++) {
         if (fld.charAt(i) < "0"  ||  fld.charAt(i) > "9") {
            retval = false;
         }
      }
   }

   //...  Return to the caller...
   return retval;
}

function isEmpty(fld) {
   //...  Check for an empty field...
   var retval;         //... return value...
   
   retval = false;
   if (fld == ""  ||  fld == null) {
      retval = true;
   }
   return retval;
}

function validEmail(fld) {
   //...  Validate an Email field...
   //...  modified from "JavaScript Quickstart", page 131...
   var retval;                //... return value...
   var invalidChars=" /:,;";  //... list of invalid characters...
   var i;                     //... just a counter...
   var atPos;                 //...  position of \'@\' character...
   var periodPos;             //...  position of \'.\' character...

   //...  Assume email address is valid...
   retval = true;

   //...  Check for empty email field...
   if (fld == "") {
      retval = false;
   } else {

      //...  Check for embedded illegal characters...
      for (var i=0; i<invalidChars.length; i++) {
         if (fld.indexOf(invalidChars.charAt(i)) > -1) {
            retval = false;
         }
      }
      if (retval = true) {

         //...  Check for illegal placement of \'@\' character...
         atPos = fld.indexOf("@",1)
         if (atPos == -1) {
            retval = false;
         } else {

            //...  Check for existence of \'@\' character...
            if (fld.indexOf("@",atPos+1) > -1) {
               retval = false;
            } else {

               //...  Check for period after \'@\' character...
               periodPos = fld.indexOf(".",atPos);
               if (periodPos == -1) {
                  retval = false;
               } else {

                  //...  Check for period within 3 characters of email length...
                  if (periodPos > fld.length-3) {
                     retval = false;
                  }
               }
            }
         }
      }
   }

   //...  Return to the caller...
   return retval;
}
//-->