
<!--
function openScript(url, width, height) {
 var Win = window.open(url, "openScript", 'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=0,status=yes');
}

function getRadioValue(radioButtons) {
 bFoundValue = false
 i=0
 foundValue = "";
 while (i < radioButtons.length) {
    bFoundValue = radioButtons[i].checked;
    if (bFoundValue) {
       foundValue = radioButtons[i].value;
    }
    i++;
 }
 if (bFoundValue) {
 
 }
 else {
    return false;
 }
}

function shipToBillPerson(inputForm) {
 if (inputForm.shipSameAsBill.checked) {
    inputForm.ShipFirstName.value = inputForm.BillFirstName.value;
    inputForm.ShipLastName.value = inputForm.BillLastName.value;
    inputForm.ShipAddress1.value = inputForm.BillAddress1.value;
    inputForm.ShipAddress2.value = inputForm.BillAddress2.value;
    inputForm.ShipCity.value = inputForm.BillCity.value;
    inputForm.ShipState.value = inputForm.BillState.value;
    inputForm.ShipZip.value = inputForm.BillZip.value;
    inputForm.ShipZipPlusFour.value = inputForm.BillZipPlusFour.value;
    inputForm.ShipTelephone.value = inputForm.BillTelephone.value;
    inputForm.ShipTelephone2.value = inputForm.BillTelephone2.value;
    inputForm.ShipTelephone3.value = inputForm.BillTelephone3.value;
 }
 return true;
}

//check to see if Quantity is valid
function validateQuantity(inputForm) {
	//if (!isInteger(inputForm.Quantity.Value)) {
	//	alert("The Quantity entered for each product must be a whole number.");
	//	inputForm.Quantity.focus();
	//	return false;
	//}
	return true;
}

function validateFormNewCustomer(inputForm) {
 // Check all billing address information
 if (isEmpty(inputForm.BillFirstName.value)) {
    alert("The first name of the billing address cannot be blank.");
    inputForm.BillFirstName.focus();
    return false;
 }
 if (isEmpty(inputForm.BillLastName.value)) {
    alert("The last name of the billing address cannot be blank.");
    inputForm.BillLastName.focus();
    return false;
 }
 if (isEmpty(inputForm.BillAddress1.value)) {
    alert("The first line of the billing address cannot be blank.");
    inputForm.BillAddress1.focus();
    return false;
 }
 if (isEmpty(inputForm.BillCity.value)) {
    alert("The city of the billing address cannot be blank.");
    inputForm.BillCity.focus();
    return false;
 }
 if (isEmpty(inputForm.BillState.value)) {
    alert("The state or province of the billing address cannot be blank.");
    inputForm.BillState.focus();
    return false;
 }
// alert ("state code: " & inputForm.BillState.value);
 
if (!isStateCode(inputForm.BillState.value))
{
    alert("The value you entered is not a valid state Code.");
    inputForm.BillState.focus();
    return false;
 }

 //if (isInteger(inputForm.BillZip.value)) {
 //   alert("The postal code of the billing address must be numeric.");
 //   inputForm.BillZip.focus();
 //   return false;
 //  }
 
 if (isEmpty(inputForm.BillTelephone.value)) {
    alert("The phone number of the billing address cannot be blanks.");
    inputForm.BillTelephone.focus();
    return false;
 }
 
 
 // Check all shipping address information if the checkbox is not checked.
 //if (inputForm.shipSameAsBill.checked == false) {
    if (isEmpty(inputForm.ShipFirstName.value)) {
       alert("If the shipping and billing addresses are different, the first name of the shipping address cannot be blank.");
       inputForm.ShipFirstName.focus();
       return false;
    }
    if (isEmpty(inputForm.ShipLastName.value)) {
       alert("If the shipping and billing addresses are different, the last name of the shipping address cannot be blank.");
       inputForm.ShipLastName.focus();
       return false;
    }
    if (isEmpty(inputForm.ShipAddress1.value)) {
       alert("If the shipping and billing addresses are different, the first line of the shipping address cannot be blank.");
       inputForm.ShipAddress1.focus();
       return false;
    }
    if (isEmpty(inputForm.ShipCity.value)) {
       alert("If the shipping and billing addresses are different, the city of the shipping address cannot be blank.");
       inputForm.ShipCity.focus();
       return false;
    }
    if (isEmpty(inputForm.ShipState.value)) {
       alert("If the shipping and billing addresses are different, the state or province of the shipping address cannot be blank.");
       inputForm.ShipState.focus();
       return false;
    }
	if (!isStateCode(inputForm.ShipState.value))
   {
    alert("The value you entered is not a valid state Code.");
    inputForm.ShipState.focus();
    return false;
   }

    if (isEmpty(inputForm.ShipZip.value)) {
       alert("If the shipping and billing addresses are different, the postal code of the shipping address cannot be blank.");
       inputForm.ShipZip.focus();
       return false;
    }
    if (isEmpty(inputForm.ShipTelephone.value)) {
       alert("If the shipping and billing addresses are different, the phone number of the shipping address cannot be blank.");
       inputForm.ShipTelephone.focus();
       return false;
    }
 //}
 
 // Validate miscellaneous information
 if (!isEmail(inputForm.BillEmail.value)) {
    alert("A valid email address must be entered.");
    inputForm.BillEmail.focus();
    return false;
 }
 
 // Validate payment information
 var today = new Date();
 if (isEmpty(inputForm.CreditCardName.value)) {
       alert("The cardholder name must be entered.");
       inputForm.CreditCardName.focus();
       return false;
    }
 if (inputForm.CreditCardType.value == "CC-AMEX") {
    inputForm.CreditCardNumber.value = stripCharsInBag(inputForm.CreditCardNumber.value,"-");
    if (!isAmericanExpress(stripWhitespace(inputForm.CreditCardNumber.value))) {
       alert("The payment number is not a valid American Express number.");
       inputForm.CreditCardNumber.focus();
       return false;
    }
    if (isEmpty(inputForm.CreditCardExpDateMM.value) | isEmpty(inputForm.CreditCardExpDateYYYY.value)) {
       alert("The expiration date cannot be blank when using a credit card.");
       inputForm.CreditCardExpDateMM.focus();
       return false;
    }
	if (inputForm.CreditCardExpDateYYYY.value < today.getFullYear()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateYYYY.focus();
       	return false;
	  }
	if (inputForm.CreditCardExpDateYYYY.value == today.getFullYear() & ((inputForm.CreditCardExpDateMM.value) - 1) < today.getMonth()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateMM.focus();
       	return false;
	  }
 }
 if (inputForm.CreditCardType.value == "CC-Discover") {
    inputForm.CreditCardNumber.value = stripCharsInBag(inputForm.CreditCardNumber.value,"-");            
    if (!isDiscover(stripWhitespace(inputForm.CreditCardNumber.value))) {
       alert("The payment number is not a valid Discover number.");
       inputForm.CreditCardNumber.focus();
       return false;
    }
    if (isEmpty(inputForm.CreditCardExpDateMM.value) | isEmpty(inputForm.CreditCardExpDateYYYY.value)) {
       alert("The expiration date cannot be blank when using a credit card.");
       inputForm.CreditCardExpDateMM.focus();
       return false;
    }
	if (inputForm.CreditCardExpDateYYYY.value < today.getFullYear()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateYYYY.focus();
       	return false;
	  }
	if (inputForm.CreditCardExpDateYYYY.value == today.getFullYear() & ((inputForm.CreditCardExpDateMM.value) - 1) < today.getMonth()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateMM.focus();
       	return false;
	  }
 }
 if (inputForm.CreditCardType.value == "CC-MC") {
    inputForm.CreditCardNumber.value = stripCharsInBag(inputForm.CreditCardNumber.value,"-");            
    if (!isMasterCard(stripWhitespace(inputForm.CreditCardNumber.value))) {
       alert("The payment number is not a valid MasterCard number.");
       inputForm.paymentNumber.focus();
       return false;
    }
    if (isEmpty(inputForm.CreditCardExpDateMM.value) | isEmpty(inputForm.CreditCardExpDateYYYY.value)) {
       alert("The expiration date cannot be blank when using a credit card.");
       inputForm.CreditCardExpDateMM.focus();
       return false;
    }
	if (inputForm.CreditCardExpDateYYYY.value < today.getFullYear()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateYYYY.focus();
       	return false;
	  }
	if (inputForm.CreditCardExpDateYYYY.value == today.getFullYear() & ((inputForm.CreditCardExpDateMM.value) - 1) < today.getMonth()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateMM.focus();
       	return false;
	  }
 }
 if (inputForm.CreditCardType.value == "CC-Visa") {
    inputForm.CreditCardNumber.value = stripCharsInBag(inputForm.CreditCardNumber.value,"-");            
    if (!isVisa(stripWhitespace(inputForm.CreditCardNumber.value))) {
       alert("The payment number is not a valid Visa number.");
	   inputForm.paymentNumber.focus();
       return false;
    }
    if (isEmpty(inputForm.CreditCardExpDateMM.value) | isEmpty(inputForm.CreditCardExpDateYYYY.value)) {
       alert("The expiration date cannot be blank when using a credit card.");
       inputForm.CreditCardExpDateMM.focus();
       return false;
    }
	if (inputForm.CreditCardExpDateYYYY.value < today.getFullYear()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateYYYY.focus();
       	return false;
	  }
	if (inputForm.CreditCardExpDateYYYY.value == today.getFullYear() & ((inputForm.CreditCardExpDateMM.value) - 1) < today.getMonth()) {
		alert("The expiration date on the credit card has passed.");
       	inputForm.CreditCardExpDateMM.focus();
       	return false;
	  }
 }         
             
 return true;
}

function validateFormOldCustomer(inputForm) {
 if (isEmpty(inputForm.firstName.value)) {
    alert("The customer's first name cannot be blank.");
    inputForm.firstName.focus();
    return false;
 }
 if (isEmpty(inputForm.lastName.value)) {
    alert("The customer's last name cannot be blank.");
    inputForm.lastName.focus();
    return false;
 }         
 if (isEmpty(inputForm.emailAddress.value)) {
    alert("The customer's email address cannot be blank.");
    inputForm.emailAddress.focus();
    return false;
 }
 if (inputForm.radioCC[inputForm.radioCC.length-1].checked) {
    if (isEmpty(inputForm.paymentNumber.value)) {
       if (inputForm.paymentType.value == "PO") {
       alert("In order to use a purchase order, you must fill in the purchase order number.");
            inputForm.paymentNumber.focus();
            return false;
         }
      }
   }          
   return true;
}          

  //-->

