function Form_Validator(theForm)
  {
    if (theForm._GIFTstrFirstName.value == "")
      {
        alert("Please enter a value for the \"First Name\" field.");
        theForm._GIFTstrFirstName.focus();
        return (false);
      }
    if (theForm._GIFTstrLastName.value == "")
      {
        alert("Please enter a value for the \"Last Name\" field.");
        theForm._GIFTstrLastName.focus();
        return (false);
      }
    if (theForm._GIFTstrAddress.value == "")
      {
        alert("Please enter a value for the \"Address\" field.");
        theForm._GIFTstrAddress.focus();
        return (false);
      }
    if (theForm._GIFTstrCity.value == "")
      {
        alert("Please enter a value for the \"City\" field.");
        theForm._GIFTstrCity.focus();
        return (false);
      }

    var str = theForm._strgiftDummy1.options[theForm._strgiftDummy1.selectedIndex].value;
    if (theForm._strgiftDummy1.options[theForm._strgiftDummy1.selectedIndex].value == "--")
      {
        alert("Please select a valid \"State\".");
        theForm._strgiftDummy1.focus();
        return (false);
      }
    if (str.substring(2) == "061") 
      {
        if (
          ((theForm._GIFTstrZip.value.substring(0, 3) > "089") && (theForm._GIFTstrZip.value.substring(0, 3) < "093")) ||
          ((theForm._GIFTstrZip.value.substring(0, 3) > "093") && (theForm._GIFTstrZip.value.substring(0, 3) < "100"))
          ) 
          {
          }
        else 
          {
            alert("Your postal code does not match the selected state")
            theForm._GIFTstrZip.focus();
            return (false);
          }
      }
    else if (str.substring(2) == "062") 
      {
        if (theForm._GIFTstrZip.value.substring(0, 3) != "093") 
          {
            alert("Your postal code does not match the selected state")
            theForm._GIFTstrZip.focus();
            return (false);
          }
      }
    else if (str.substring(2) == "063") 
      {
        if ((theForm._GIFTstrZip.value.substring(0, 3) < "962") || (theForm._GIFTstrZip.value.substring(0, 3) > "966")) 
          {
            alert("Your postal code does not match the selected state")
            theForm._GIFTstrZip.focus();
            return (false);
          }
      }
    else if (str.substring(2) == "064") 
      {
        if (theForm._GIFTstrZip.value.substring(0, 3) != "340") 
          {
            alert("Your postal code does not match the selected state")
            theForm._GIFTstrZip.focus();
            return (false);
          }
      }

    if (str.substring(2) > "079")
      {
        alert("Please select a valid \"State\" for USA address.");
        theForm._strgiftDummy1.focus();
        return (false);
      }
    // Set strState (left 2) and lngForeignStCodes (right 3) from strDummy1 values
    theForm._GIFTstrState.value = str.substring(0,2);
    theForm._GIFTlngForeignStCode.value = str.substring(2);
    //alert ("State = " + theForm._GIFTstrState.value + " Code " + theForm._GIFTlngForeignStCode.value);

    // Validate Zip Code
    if (theForm._GIFTstrZip.value == "")
      {
        alert("Please enter a value for the \"Zip Code\" field.");
        theForm._GIFTstrZip.focus();
        return (false);
      }
    if (theForm._GIFTstrZip.value.length != 5)
      {
        alert("Please enter 5 characters in the \"Zip Code\" field.");
        theForm._GIFTstrZip.focus();
        return (false);
      }

    var checkOK = "0123456789";
    var checkStr = theForm._GIFTstrZip.value;
    var allValid = true;
    var validGroups = 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 Code\" field.");
        theForm._GIFTstrZip.focus();
        return (false);
      }
    if (theForm._GIFTstrPhone.value.length > 10)
      {
        alert("Please enter at most 10 digits in the \"Phone\" field.  Enter only numbers, no spaces or dashes.");
        theForm._GIFTstrPhone.focus();
        return (false);
      }

    if (theForm.strExpDemo1.options[theForm.strExpDemo1.selectedIndex].value == "099")
      {
        if (theForm.strMiscLit10A.value == "")
          {
            alert("The Other field cannot be blank when Other is chosen for How you heard about us.");
            theForm.strMiscLit10A.focus();
            return (false);
          }   
      }
	
    if (theForm.strFirstName.value == "")
      {
        alert("Please enter a value for the Recipient's First Name field.");
        theForm.strFirstName.focus();
        return (false);
      }
    if (theForm.strFirstName.value.length > 35)
      {
        alert("Please enter at most 35 characters in the Recipient's First Name field.");
        theForm.strFirstName.focus();
        return (false);
      }
    if (theForm.strLastName.value == "")
      {
        alert("Please enter a value for the Recipient's Last Name field.");
        theForm.strLastName.focus();
        return (false);
      }
    if (theForm.strLastName.value.length > 35)
      {
        alert("Please enter at most 35 characters in the Recipient's Last Name field.");
        theForm.strLastName.focus();
        return (false);
      }
    if (theForm.strAddress1_1.value == "")
      {
        alert("Please enter a value for the Recipient's Address field.");
        theForm.strAddress1_1.focus();
        return (false);
      }
    if (theForm.strAddress1_1.value.length > 35)
      {
        alert("Please enter at most 35 characters in the Recipient's Address field.");
        theForm.strAddress1_1.focus();
        return (false);
      }
    if (theForm.strCity.value == "")
      {
        alert("Please enter a value for the Recipient's City field.");
        theForm.strCity.focus();
        return (false);
      }
    if (theForm.strCity.value.length > 35)
      {
        alert("Please enter at most 35 characters in the  Recipient'sCity field.");
        theForm.strCity.focus();
        return (false);
      }

    var str = theForm.strDummy1.options[theForm.strDummy1.selectedIndex].value;
    if (theForm.strDummy1.options[theForm.strDummy1.selectedIndex].value == "--")
      {
        alert("Please select a valid State for the  Recipient.");
        theForm.strDummy1.focus();
        return (false);
      }
    if (str.substring(2) > "079")
      {
        alert("Please select a valid State for USA address.");
        theForm.strDummy1.focus();
        return (false);
      }
    theForm.strState.value = str.substring(0,2);
    theForm.lngForeignStCode.value = str.substring(2);
    if (theForm.strZip.value == "")
      {
        alert("Please enter a value for the Recipient's Zip Code field.");
        theForm.strZip.focus();
        return (false);
      }
    if (theForm.strZip.value.length != 5)
      {
        alert("Please enter 5 characters in the Recipient's Zip Code field.");
        theForm.strZip.focus();
        return (false);
      }

     var checkOK = "0123456789";
     var checkStr = theForm.strZip.value;
     var allValid = true;
     var validGroups = 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 Recipient's Zip Code field.");
         theForm.strZip.focus();
         return (false);
       }

    if(theForm._ecard.checked == true)
      {
        if (theForm.strEmail.value == "")
          {
            alert("Please enter a value for the Recipient's Email field.");
            theForm.strEmail.focus();
            return (false);
          }
        if (theForm.strEmail.value.length > 65)
          {
            alert("Please enter at most 65 characters in the Recipient's Email field.");
            theForm.strEmail.focus();
            return (false);
          }
        var strEmail = theForm.strEmail.value;
        var i=strEmail.indexOf("@");	//see if there's an @ sign
        var x=strEmail.indexOf("@",i+1); //make sure there's not more @ signs
        var p=strEmail.indexOf(".",i);  //there must be a period 
        if ( (i==-1) || (p<(i+2)) || (x>i) || (p >=(strEmail.length - 2)))
          {
            alert("Please enter a valid Email Address.");
            theForm.strEmail.focus();
            return(false);
          }
      }

    if(theForm.lngSubType[0].checked == true)
      {
        theForm.blnRequirePayment.value = 1;
        if (theForm.CCstrName.value == "")
          {
            alert("Please enter a value for the \"Name on Card\" field.");
            theForm.CCstrName.focus();
            return (false);
          }
        if (theForm.CClngPaymentTypeID.options[theForm.CClngPaymentTypeID.selectedIndex].value == "1")
          {
            alert ("Please select a credit card type.");
            theForm.CClngPaymentTypeID.focus();
            return (false);
          }
        var CardType = theForm.CClngPaymentTypeID.options[theForm.CClngPaymentTypeID.selectedIndex].value;
        var objCardNum = theForm.CCstrCardNumber;
        var blnValidCC = isValidCreditCardNumber(objCardNum,CardType,"Credit Card Number",true);
        if (blnValidCC == false)
          {
            return (false);
          }
        if (theForm.CCstrExpMonth.options[theForm.CCstrExpMonth.selectedIndex].value == "")
          {
            alert("Please select a value for the \"Expiration Month\" field.");
            theForm.CCstrExpMonth.focus();
            return (false);
          }
        if (theForm.CCstrExpYear.options[theForm.CCstrExpYear.selectedIndex].value == "")
          {
            alert("Please select a value for the \"Expiration Year\" field.");
            theForm.CCstrExpYear.focus();
            return (false);
          }
        var ccMonth = parseInt(theForm.CCstrExpMonth.options[theForm.CCstrExpMonth.selectedIndex].value, 10);
        var ccYear = 2000 +  parseInt(theForm.CCstrExpYear.options[theForm.CCstrExpYear.selectedIndex].value, 10);
        var now = new Date();
        var nowMonth = now.getMonth() + 1;
        var nowYear = now.getFullYear();
        if ( (ccYear < nowYear) || ((nowYear == ccYear) && (nowMonth > ccMonth)) )   
          {
            alert("Please select a valid Expiration Date for you credit card." );
            theForm.CCstrExpMonth.focus();
            return (false);
          }
      }
    else if (theForm.lngSubType[1].checked == true)
      {
        notifyForCheckPmts()
        return (false);
      }
    else
      {
        alert ("Please select a payment option.");
        theForm.lngSubType[0].focus()
        return (false);
      }

    theForm.blnProcess.value = 1;
    theForm.action = "../process.asp";
    return (true);
  }


function notifyForCheckPmts()
  {
    alert("When paying by check, print out this page and MAIL your completed order with payment information to: \n\n  KIWI Magazine\n   P.O. Box 5103\n   Brentwood, TN 37024-9900")
  }
