// JScript File

var digits = "0123456789";
var lLetters = "abcdefghijklmnopqrstuvwxyz"
var uLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var alphanum = lLetters + uLetters + digits;
var whitespace = " \t\n\r ";

var ProvinceDelimiter = "|";
var Provinces = new Array();
Provinces["US"] = "AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY|AE|AA|AE|AE|AP";
Provinces["CA"] = "AB|BC|MB|NB|NF|NT|NS|NU|ON|PI|QC|SK|YT";

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

function isWhitespace(s) {
	var i;
	if (isEmpty(s)) return true;
		for (i = 0; i < s.length; i++)
		{   
			var c = s.charAt(i);
			if (whitespace.indexOf(c) == -1) return false;
		}
	return true;
}

function StripIn (s, bag) {
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function StripNotIn (s, bag) {
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++) {
		 var c = s.charAt(i);
		 if (bag.indexOf(c) != -1) returnString += c;
	}
	return returnString;
}

function isLetter (c) {
	return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c) {
	return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c) {
	return (isLetter(c) || isDigit(c))
}

function isInteger (s) {
	var i;
	if (isEmpty(s)) return false;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}

function AlphaNumeric(s) {
	var i;
	if (isEmpty(s)) return false;
	for (i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if (!isLetterorDigit(c)) return false;
	}
	return true;
}

function isLength(s, lMin, lMax) {
	if ((s.length >= lMin) && (s.length <= lMax)) return true;
	return false;
}

function isProvinceCode(sCode, sCountry) {
	if (Provinces[sCountry] != null) {
		if (!isLength(sCode, 2, 2)) return false;
		return ((Provinces[sCountry].indexOf(sCode.toUpperCase()) != -1) && (sCode.indexOf(ProvinceDelimiter) == -1));
	}
	return true;
}

function isZipCode(sZip, sCountry) {
	if (sCountry=="US") return isUSZipCode(sZip);
	if (sCountry=="CA") return isCAZipCode(sZip);
	return true
}

function isUSZipCode(sZip) {
	return (isInteger(sZip) && ((sZip.length==5) || (sZip.length==9)));
//	return (isInteger(sZip) && ((sZip.length==5) || (sZip.length==9)));
}

function isCAZipCode(sZip) {
	var re = new RegExp();
	re = /^[a-zA-z]\d[a-zA-z]( |-)?\d[a-zA-z]\d$/;
	return re.test(sZip);
}

function isEmail (s) {
	if (isEmpty(s)) return false;
	if (isWhitespace(s)) return false;
	var i = 1;
	var sLength = s.length;
	while ((i < sLength) && (s.charAt(i) != "@")) {i++}
	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;
	while ((i < sLength) && (s.charAt(i) != ".")) { i++ }
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}

function isURL(s) {
	if (isWhitespace(s)) return false;
	return true;
}

function warnInvalid (theField, s) {
	theField.focus();
	theField.select();
	alert(s);
	myForm.btnBuyNow.disabled = false;
	return false;
}

/*************************************************************************\
boolean isExpiryDate([int year, int month])
return true if the date is a valid expiry date,
else return false.
\*************************************************************************/
function isExpiryDate(mth, yr) {
//	var argv = isExpiryDate.arguments;
//	var argc = isExpiryDate.arguments.length;

//	year = argc > 0 ? argv[0] : this.year;
//	month = argc > 1 ? argv[1] : this.month;

	if (!isInteger(yr))
	return false;
	if (!isInteger(mth))
	return false;
	today = new Date();
	expiry = new Date(yr, mth);
//	window.alert(mth + ' - ' + yr + ' - ' + expiry)
	if (today.getTime() > expiry.getTime())
		return false;
	else
		return true;
}

function Validate(myForm) {
	myForm.btnBuyNow.disabled = true;

// sri03282006 : added the check for product selection
//if (objToTest == null || objToTest == undefined) {<
	if (myForm.selProduct) {
		if (myForm.selProduct.selectedIndex == "0") 
			{
				window.alert("Please select a product to purchase");
				myForm.selProduct.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
	}
	
	if (!isLength(myForm.txtFirstName.value, 1, 30)) 
//		return warnInvalid(myForm.txtFirstName, "Billing first name must be between 1 and 30 characters in length");
		{
			window.alert("Billing first name must be between 1 and 30 characters in length");
			myForm.txtFirstName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		
	if (!isLength(myForm.txtLastName.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastName, "Billing last name must be between 1 and 50 characters in length");
		{
			window.alert("Billing last name must be between 1 and 50 characters in length");
			myForm.txtLastName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtAddress1.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1, "Billing Street address must be between 1 and 255 characters in length");
		{
			window.alert("Billing Street address must be between 1 and 255 characters in lengt");
			myForm.txtAddress1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCity.value, 1, 50)) 
//	return warnInvalid(myForm.txtCity, "Billing City must be between 1 and 50 characters in length");
		{
			window.alert("Billing Caty must be between 1 and 50 characters in length");
			myForm.txtCity.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtPhone.value, 1, 15)) 
//	return warnInvalid(myForm.txtCity, "Billing Phone must be between 1 and 15 characters in length");
		{
			window.alert("Billing Phone must be between 1 and 15 characters in length");
			myForm.txtPhone.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.state.selectedIndex == "0") 
		{
			window.alert("Billing State must be selected");
			myForm.state.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	myForm.txtPostalCode.value = StripNotIn(myForm.txtPostalCode.value, digits)
	if (myForm.txtPostalCode.value.length == 9) {
		myForm.txtPostalCode.value = myForm.txtPostalCode.value.slice(0,5) + "-" + myForm.txtPostalCode.value.slice(5)
	}

	if (!isEmail(myForm.txtEmail.value, 1, 255)) 
//	return warnInvalid(myForm.txtEmail, "Please enter a valid email address (xxx@xxx.xxx)");
		{
			window.alert("Please enter a valid email address (xxx@xxx.xxx)");
			myForm.txtEmail.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtFirstNameShip.value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("Child's first name must be between 1 and 30 characters in length");
			myForm.txtFirstNameShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtLastNameShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("Child's last name must be between 1 and 50 characters in length");
			myForm.txtLastNameShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtAddress1Ship.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("Child's shipping address must be between 1 and 255 characters in length");
			myForm.txtAddress1Ship.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCityShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("Child's city must be between 1 and 50 characters in length");
			myForm.txtCityShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.stateShip.selectedIndex == "0") 
		{
			window.alert("Child's State must be selected");
			myForm.stateShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

//	if (myForm.stateShip.selectedIndex == "0") return warnInvalid(myForm.stateShip, "Child's State must be selected");

	myForm.txtPostalCodeShip.value = StripNotIn(myForm.txtPostalCodeShip.value, digits)
	if (!isUSZipCode(myForm.txtPostalCodeShip.value)) 
//	return warnInvalid(myForm.txtPostalCodeShip, "You must enter a valid US zip code. (e.g. #####) in shipping address.");
		{
			window.alert("You must enter a valid US zip code. (e.g. #####) in shipping address.");
			myForm.txtPostalCodeShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (myForm.txtPostalCodeShip.value.length == 9) {
		myForm.txtPostalCodeShip.value = myForm.txtPostalCodeShip.value.slice(0,5) + "-" + myForm.txtPostalCodeShip.value.slice(5)
	}

	if (myForm.chkBillLater) {
// if Bill Me Later exists then check to see if it is False
	 if (myForm.chkBillLater.checked == false) {

		if (!isLength(myForm.txtAccountName.value, 1, 30)) 
		{
			window.alert("Name on card must be between 1 and 30 characters in length");
			myForm.txtAccountName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
		{
			window.alert("Card Number must be provided");
			myForm.txtAccountNumber.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (myForm.selYear.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Year for the Credit Card");
			myForm.selYear.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (myForm.selMonth.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Month for the Credit Card");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
		{
			window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	  } 
	} else {
// else if the Account Number field exists then check the expiry date
		if (myForm.txtAccountNumber) {
			if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
			{
				window.alert("Card Number must be provided");
				myForm.txtAccountNumber.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (!isLength(myForm.txtAccountName.value, 1, 30)) 
			{
				window.alert("Name on card must be between 1 and 30 characters in length");
				myForm.txtAccountName.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (myForm.selYear.selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Year for the Credit Card");
				myForm.selYear.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (myForm.selMonth.selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Month for the Credit Card");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
			{
				window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
		}
	}
	
	return true;
}

function Validate2(myForm) {
	//window.alert("Validating");
	//return false;
	//myForm.btnBuyNow.disabled = true;
	// sri03282006 : added the check for product selection
	if (document.getElementById('selProduct')) {
		if (document.getElementById('selProduct').selectedIndex == "0") 
			{
				window.alert("Please select a product to purchase");
				document.getElementById('selProduct').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
			}
	}
	
	if (!isLength(document.getElementById('txtFirstName').value, 1, 30)) 
		{
			window.alert("Billing first name must be between 1 and 30 characters in length");
			document.getElementById('txtFirstName').focus;
			//myForm.txtFirstName.focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
		
	if (!isLength(document.getElementById('txtLastName').value, 1, 50)) 
		{
			window.alert("Billing last name must be between 1 and 50 characters in length");
			document.getElementById('txtLastName').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

	if (!isLength(document.getElementById('txtAddress1').value, 1, 255)) 
		{
			window.alert("Billing Street address must be between 1 and 255 characters in lengt");
			document.getElementById('txtAddress1').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
	if (!isLength(document.getElementById('txtCity').value, 1, 50)) 
		{
			window.alert("Billing City must be between 1 and 50 characters in length");
			document.getElementById('txtCity').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

	if (!isLength(document.getElementById('state').value, 1, 50)) 
		{
			window.alert("Billing State must be entered");
			document.getElementById('state').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

	//if (myForm.selCountry.value = "US") {
	//	myForm.txtPostalCode.value = StripNotIn(myForm.txtPostalCode.value, digits);
	//	if (!isUSZipCode(myForm.txtPostalCode.value)) 
	//		{
	//			window.alert("You must enter a valid US zip code. (e.g. #####) in shipping address.");
	//			myForm.txtPostalCode.focus();
	//			myForm.btnBuyNow.disabled = false;
	//			return false;
	//		}
	//	if (myForm.txtPostalCode.value.length == 9) {
	//		myForm.txtPostalCode.value = myForm.txtPostalCode.value.slice(0,5) + "-" + myForm.txtPostalCode.value.slice(5)
	//	}
	//} else {
		if (!isLength(document.getElementById('txtPostalCode').value, 1, 15)) {
				window.alert("Billing Zip code must be between 1 and 15 characters in length");
				document.getElementById('txtPostalCode').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
		}
	//}

	if (!isEmail(document.getElementById('txtEmail').value, 1, 255)) 
		{
			window.alert("Please enter a valid email address (xxx@xxx.xxx)");
			document.getElementById('txtEmail').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

	if (!isLength(document.getElementById('txtFirstNameShip').value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("Child's first name must be between 1 and 30 characters in length");
			document.getElementById('txtFirstNameShip').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
	if (!isLength(document.getElementById('txtLastNameShip').value, 1, 50)) 
//	return warnInvalid(document.getElementById('txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("Child's last name must be between 1 and 50 characters in length");
			document.getElementById('txtLastNameShip').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
	if (!isLength(document.getElementById('txtAddress1Ship').value, 1, 255)) 
//	return warnInvalid(document.getElementById('txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("Child's shipping address must be between 1 and 255 characters in length");
			document.getElementById('txtAddress1Ship').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
	if (!isLength(document.getElementById('txtCityShip').value, 1, 50)) 
//	return warnInvalid(document.getElementById('txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("Child's city must be between 1 and 50 characters in length");
			document.getElementById('txtCityShip').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

	if (!isLength(document.getElementById('stateShip').value, 1, 50)) 
	//if (document.getElementById('stateShip.selectedIndex == "0") 
		{
			window.alert("Child's State must be selected");
			document.getElementById('stateShip').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}


	//if (myForm.selCountryShip.value = "US") {
	//	myForm.txtPostalCodeShip.value = StripNotIn(myForm.txtPostalCodeShip.value, digits);
	//	if (!isUSZipCode(myForm.txtPostalCodeShip.value)) 
	//		{
	//			window.alert("You must enter a valid US zip code. (e.g. #####) in shipping address.");
	//			myForm.txtPostalCodeShip.focus();
	//			myForm.btnBuyNow.disabled = false;
	//			return false;
	//		}
	//	if (myForm.txtPostalCodeShip.value.length == 9) {
	//		myForm.txtPostalCodeShip.value = myForm.txtPostalCodeShip.value.slice(0,5) + "-" + myForm.txtPostalCodeShip.value.slice(5)
	//	}
	//} else {
		if (!isLength(document.getElementById('txtPostalCodeShip').value, 1, 15)) {
				window.alert("Child's Zip code must be between 1 and 15 characters in length");
				document.getElementById('txtPostalCodeShip').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
		}
	//}

	if (document.getElementById('chkBillLater')) {
// if Bill Me Later exists then check to see if it is False
	 if (document.getElementById('chkBillLater').checked == false) {

		if (!isLength(document.getElementById('txtAccountName').value, 1, 30)) 
		{
			window.alert("Name on card must be between 1 and 30 characters in length");
			document.getElementById('txtAccountName').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

		if (!isLength(document.getElementById('txtAccountNumber').value, 1, 30)) 
		{
			window.alert("Card Number must be provided");
			document.getElementById('txtAccountNumber').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}

		if (document.getElementById('selYear').selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Year for the Credit Card");
			document.getElementById('selYear').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
		if (document.getElementById('selMonth').selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Month for the Credit Card");
			document.getElementById('selMonth').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
		if (!isExpiryDate(document.getElementById('selMonth').value, document.getElementById('selYear').value)) 
		{
			window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
			document.getElementById('selMonth').focus();
			document.getElementById('btnBuyNow').disabled = false;
			return false;
		}
	  } 
	} else {
// else if the Account Number field exists then check the expiry date
		if (document.getElementById('txtAccountNumber')) {
			if (!isLength(document.getElementById('txtAccountName').value, 1, 30)) 
			{
				window.alert("Name on card must be between 1 and 30 characters in length");
				document.getElementById('txtAccountName').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
			}

			if (document.getElementById('selYear').selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Year for the Credit Card");
				document.getElementById('selYear').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
			}
			if (document.getElementById('selMonth').selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Month for the Credit Card");
				document.getElementById('selMonth').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
			}
			if (!isExpiryDate(document.getElementById('selMonth').value, document.getElementById('selYear').value)) 
			{
				window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
				document.getElementById('selMonth').focus();
				document.getElementById('btnBuyNow').disabled = false;
				return false;
			}
		}
	}
	
	return true;
}

function ValidateWithRadio(myForm) {
	myForm.btnBuyNow.disabled = true;

// sri03282006 : added the check for product selection
//if (objToTest == null || objToTest == undefined) {<
//	if (myForm.selProduct) {
//		if (myForm.selProduct.selectedIndex == "0") 
//			{
//				window.alert("Please select a product to purchase");
//				myForm.selProduct.focus();
//				myForm.btnBuyNow.disabled = false;
//				return false;
//			}
//	}
	
	// set var radio_choice to false
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < myForm.selProduct.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (myForm.selProduct[counter].checked)
			radio_choice = true; 
	}

	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert("Please select a product to purchase");
		myForm.btnBuyNow.disabled = false;
		return (false);
	}
	
	if (myForm.freeoffer.checked == false)
		{
			alert("You must say yes to the offer by checking the box");
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtFirstName.value, 1, 30)) 
//		return warnInvalid(myForm.txtFirstName, "Billing first name must be between 1 and 30 characters in length");
		{
			window.alert("Billing first name must be between 1 and 30 characters in length");
			myForm.txtFirstName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		
	if (!isLength(myForm.txtLastName.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastName, "Billing last name must be between 1 and 50 characters in length");
		{
			window.alert("Billing last name must be between 1 and 50 characters in length");
			myForm.txtLastName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtAddress1.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1, "Billing Street address must be between 1 and 255 characters in length");
		{
			window.alert("Billing Street address must be between 1 and 255 characters in lengt");
			myForm.txtAddress1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCity.value, 1, 50)) 
//	return warnInvalid(myForm.txtCity, "Billing City must be between 1 and 50 characters in length");
		{
			window.alert("Billing City must be between 1 and 50 characters in length");
			myForm.txtCity.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtPhone.value, 1, 15)) 
//	return warnInvalid(myForm.txtCity, "Billing Phone must be between 1 and 15 characters in length");
		{
			window.alert("Billing Phone must be between 1 and 15 characters in length");
			myForm.txtPhone.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
 	if (myForm.state.selectedIndex == "0") 
		{
			window.alert("Billing State must be selected");
			myForm.state.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	myForm.txtPostalCode.value = StripNotIn(myForm.txtPostalCode.value, digits)
	if (myForm.txtPostalCode.value.length == 9) {
		myForm.txtPostalCode.value = myForm.txtPostalCode.value.slice(0,5) + "-" + myForm.txtPostalCode.value.slice(5)
	}

	if (!isEmail(myForm.txtEmail.value, 1, 255)) 
//	return warnInvalid(myForm.txtEmail, "Please enter a valid email address (xxx@xxx.xxx)");
		{
			window.alert("Please enter a valid email address (xxx@xxx.xxx)");
			myForm.txtEmail.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtFirstNameShip.value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("Child's first name must be between 1 and 30 characters in length");
			myForm.txtFirstNameShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtLastNameShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("Child's last name must be between 1 and 50 characters in length");
			myForm.txtLastNameShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtAddress1Ship.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("Child's shipping address must be between 1 and 255 characters in length");
			myForm.txtAddress1Ship.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCityShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("Child's city must be between 1 and 50 characters in length");
			myForm.txtCityShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.stateShip.selectedIndex == "0") 
		{
			window.alert("Child's State must be selected");
			myForm.stateShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

//	if (myForm.stateShip.selectedIndex == "0") return warnInvalid(myForm.stateShip, "Child's State must be selected");

	myForm.txtPostalCodeShip.value = StripNotIn(myForm.txtPostalCodeShip.value, digits)
	if (!isUSZipCode(myForm.txtPostalCodeShip.value)) 
//	return warnInvalid(myForm.txtPostalCodeShip, "You must enter a valid US zip code. (e.g. #####) in shipping address.");
		{
			window.alert("You must enter a valid US zip code. (e.g. #####) in shipping address.");
			myForm.txtPostalCodeShip.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (myForm.txtPostalCodeShip.value.length == 9) {
		myForm.txtPostalCodeShip.value = myForm.txtPostalCodeShip.value.slice(0,5) + "-" + myForm.txtPostalCodeShip.value.slice(5)
	}

	if (myForm.chkBillLater) {
// if Bill Me Later exists then check to see if it is False
	 if (myForm.chkBillLater.checked == false) {

		if (!isLength(myForm.txtAccountName.value, 1, 30)) 
		{
			window.alert("Name on card must be between 1 and 30 characters in length");
			myForm.txtAccountName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
		{
			window.alert("Card Number must be provided");
			myForm.txtAccountNumber.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (myForm.selYear.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Year for the Credit Card");
			myForm.selYear.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (myForm.selMonth.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Month for the Credit Card");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
		{
			window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	  } 
	} else {
// else if the Account Number field exists then check the expiry date
		if (myForm.txtAccountNumber) {
			if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
			{
				window.alert("Card Number must be provided");
				myForm.txtAccountNumber.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (!isLength(myForm.txtAccountName.value, 1, 30)) 
			{
				window.alert("Name on card must be between 1 and 30 characters in length");
				myForm.txtAccountName.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (myForm.selYear.selectedIndex == "") 
			{				window.alert("You must select a valid Expiry Year for the Credit Card");
				myForm.selYear.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (myForm.selMonth.selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Month for the Credit Card");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
			{
				window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
		}
	}
	
	return true;
}

function ValidateWithRadioTwoForOne(myForm) {
	myForm.btnBuyNow.disabled = true;

// sri03282006 : added the check for product selection
//if (objToTest == null || objToTest == undefined) {<
//	if (myForm.selProduct) {
//		if (myForm.selProduct.selectedIndex == "0") 
//			{
//				window.alert("Please select a product to purchase");
//				myForm.selProduct.focus();
//				myForm.btnBuyNow.disabled = false;
//				return false;
//			}
//	}
	
	// set var radio_choice to false
	var radio_choice1 = false;
	var radio_choice2 = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < myForm.selProduct1.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (myForm.selProduct1[counter].checked)
			radio_choice1 = true; 
	}

	for (counter = 0; counter < myForm.selProduct2.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (myForm.selProduct2[counter].checked)
			radio_choice2 = true; 
	}

	if (!radio_choice1)
	{
		// If there were no selections made display an alert box 
		alert("Please select a subscription for Child Recipient #1");
		myForm.btnBuyNow.disabled = false;
		return (false);
	}
	
	if (!radio_choice2)
	{
		// If there were no selections made display an alert box 
		alert("Please select a subscription for Child Recipient #2");
		myForm.btnBuyNow.disabled = false;
		return (false);
	}

	if (!isLength(myForm.txtFirstName.value, 1, 30)) 
//		return warnInvalid(myForm.txtFirstName, "Billing first name must be between 1 and 30 characters in length");
		{
			window.alert("Billing first name must be between 1 and 30 characters in length");
			myForm.txtFirstName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		
	if (!isLength(myForm.txtLastName.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastName, "Billing last name must be between 1 and 50 characters in length");
		{
			window.alert("Billing last name must be between 1 and 50 characters in length");
			myForm.txtLastName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtAddress1.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1, "Billing Street address must be between 1 and 255 characters in length");
		{
			window.alert("Billing Street address must be between 1 and 255 characters in lengt");
			myForm.txtAddress1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCity.value, 1, 50)) 
//	return warnInvalid(myForm.txtCity, "Billing City must be between 1 and 50 characters in length");
		{
			window.alert("Billing City must be between 1 and 50 characters in length");
			myForm.txtCity.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtPhone.value, 1, 15)) 
//	return warnInvalid(myForm.txtCity, "Billing Phone must be between 1 and 15 characters in length");
		{
			window.alert("Billing Phone must be between 1 and 15 characters in length");
			myForm.txtPhone.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
 	if (myForm.state.selectedIndex == "0") 
		{
			window.alert("Billing State must be selected");
			myForm.state.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	myForm.txtPostalCode.value = StripNotIn(myForm.txtPostalCode.value, digits)
	if (myForm.txtPostalCode.value.length == 9) {
		myForm.txtPostalCode.value = myForm.txtPostalCode.value.slice(0,5) + "-" + myForm.txtPostalCode.value.slice(5)
	}

	if (!isEmail(myForm.txtEmail.value, 1, 255)) 
//	return warnInvalid(myForm.txtEmail, "Please enter a valid email address (xxx@xxx.xxx)");
	{
		window.alert("Please enter a valid email address (xxx@xxx.xxx)");
		myForm.txtEmail.focus();
		myForm.btnBuyNow.disabled = false;
		return false;
	}

//ship address 1
	if (!isLength(myForm.txtFirstNameShip1.value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("First child's first name must be between 1 and 30 characters in length");
			myForm.txtFirstNameShip1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtLastNameShip1.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("First child's last name must be between 1 and 50 characters in length");
			myForm.txtLastNameShip1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtAddress1Ship1.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("First child's shipping address must be between 1 and 255 characters in length");
			myForm.txtAddress1Ship1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCityShip1.value, 1, 50)) 
//	return warnInvalid(myForm.txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("First child's city must be between 1 and 50 characters in length");
			myForm.txtCityShip1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.stateShip1.selectedIndex == "0") 
		{
			window.alert("First child's State must be selected");
			myForm.stateShip1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

//	if (myForm.stateShip.selectedIndex == "0") return warnInvalid(myForm.stateShip, "Child's State must be selected");

	myForm.txtPostalCodeShip1.value = StripNotIn(myForm.txtPostalCodeShip1.value, digits)
	if (!isUSZipCode(myForm.txtPostalCodeShip1.value)) 
//	return warnInvalid(myForm.txtPostalCodeShip, "You must enter a valid US zip code. (e.g. #####) in shipping address.");
		{
			window.alert("You must enter a valid US zip code. (e.g. #####) in first shipping address.");
			myForm.txtPostalCodeShip1.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (myForm.txtPostalCodeShip1.value.length == 9) {
		myForm.txtPostalCodeShip1.value = myForm.txtPostalCodeShip1.value.slice(0,5) + "-" + myForm.txtPostalCodeShip1.value.slice(5)
	}

//ship address 2
	if (!isLength(myForm.txtFirstNameShip2.value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("Second child's first name must be between 1 and 30 characters in length");
			myForm.txtFirstNameShip2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtLastNameShip2.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("Second child's last name must be between 1 and 50 characters in length");
			myForm.txtLastNameShip2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtAddress1Ship2.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("Second child's shipping address must be between 1 and 255 characters in length");
			myForm.txtAddress1Ship2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCityShip2.value, 1, 50)) 
//	return warnInvalid(myForm.txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("Second child's city must be between 1 and 50 characters in length");
			myForm.txtCityShip2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.stateShip2.selectedIndex == "0") 
		{
			window.alert("Second child's State must be selected");
			myForm.stateShip2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

//	if (myForm.stateShip.selectedIndex == "0") return warnInvalid(myForm.stateShip, "Child's State must be selected");

	myForm.txtPostalCodeShip2.value = StripNotIn(myForm.txtPostalCodeShip2.value, digits)
	if (!isUSZipCode(myForm.txtPostalCodeShip2.value)) 
//	return warnInvalid(myForm.txtPostalCodeShip, "You must enter a valid US zip code. (e.g. #####) in shipping address.");
		{
			window.alert("You must enter a valid US zip code. (e.g. #####) in second shipping address.");
			myForm.txtPostalCodeShip2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (myForm.txtPostalCodeShip2.value.length == 9) {
		myForm.txtPostalCodeShip2.value = myForm.txtPostalCodeShip2.value.slice(0,5) + "-" + myForm.txtPostalCodeShip2.value.slice(5)
	}

//check if address1 and 2 are same
	if ((myForm.txtAddress1Ship1.value == myForm.txtAddress1Ship2.value) && 
			(myForm.txtAddress2Ship1.value == myForm.txtAddress2Ship2.value) && 
				(myForm.txtCityShip1.value == myForm.txtCityShip2.value) && 
					(myForm.stateShip1.value == myForm.stateShip2.value) && 
						(myForm.txtPostalCodeShip1.value == myForm.txtPostalCodeShip2.value))
	{
			window.alert("You must enter a different shipping address for Child #2.");
			myForm.txtAddress1Ship2.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
	}



	if (myForm.chkBillLater) {
// if Bill Me Later exists then check to see if it is False
	 if (myForm.chkBillLater.checked == false) {

		if (!isLength(myForm.txtAccountName.value, 1, 30)) 
		{
			window.alert("Name on card must be between 1 and 30 characters in length");
			myForm.txtAccountName.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
		{
			window.alert("Card Number must be provided");
			myForm.txtAccountNumber.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (myForm.selYear.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Year for the Credit Card");
			myForm.selYear.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (myForm.selMonth.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Month for the Credit Card");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
		{
			window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
			myForm.selMonth.focus();
			myForm.btnBuyNow.disabled = false;
			return false;
		}
	  } 
	} else {
// else if the Account Number field exists then check the expiry date
		if (myForm.txtAccountNumber) {
			if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
			{
				window.alert("Card Number must be provided");
				myForm.txtAccountNumber.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (!isLength(myForm.txtAccountName.value, 1, 30)) 
			{
				window.alert("Name on card must be between 1 and 30 characters in length");
				myForm.txtAccountName.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (myForm.selYear.selectedIndex == "") 
			{				window.alert("You must select a valid Expiry Year for the Credit Card");
				myForm.selYear.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (myForm.selMonth.selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Month for the Credit Card");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
			{
				window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
				myForm.selMonth.focus();
				myForm.btnBuyNow.disabled = false;
				return false;
			}
		}
	}
	
	return true;
}



function ValidatePopup(myForm) {

//myForm.btnBuyNow.disabled = true;
// sri03282006 : added the check for product selection
//if (objToTest == null || objToTest == undefined) {<
//	if (myForm.selProduct) {
//		if (myForm.selProduct.selectedIndex == "0") 
//			{
//				window.alert("Please select a product to purchase");
//				myForm.selProduct.focus();
//				myForm.btnBuyNow.disabled = false;
//				return false;
//			}
//	}
	
	// set var radio_choice to false
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < myForm.selProduct.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (myForm.selProduct[counter].checked)
			radio_choice = true; 
	}

	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert("Please select a product to purchase");
		//myForm.btnBuyNow.disabled = false;
		return (false);
	}
	
	if (!isLength(myForm.txtFirstName.value, 1, 30)) 
//		return warnInvalid(myForm.txtFirstName, "Billing first name must be between 1 and 30 characters in length");
		{
			window.alert("Billing first name must be between 1 and 30 characters in length");
			myForm.txtFirstName.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
		
	if (!isLength(myForm.txtLastName.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastName, "Billing last name must be between 1 and 50 characters in length");
		{
			window.alert("Billing last name must be between 1 and 50 characters in length");
			myForm.txtLastName.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtAddress1.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1, "Billing Street address must be between 1 and 255 characters in length");
		{
			window.alert("Billing Street address must be between 1 and 255 characters in lengt");
			myForm.txtAddress1.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCity.value, 1, 50)) 
//	return warnInvalid(myForm.txtCity, "Billing City must be between 1 and 50 characters in length");
		{
			window.alert("Billing City must be between 1 and 50 characters in length");
			myForm.txtCity.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.state.selectedIndex == "0") 
		{
			window.alert("Billing State must be selected");
			myForm.state.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

	myForm.txtPostalCode.value = StripNotIn(myForm.txtPostalCode.value, digits)
	if (myForm.txtPostalCode.value.length == 9) {
		myForm.txtPostalCode.value = myForm.txtPostalCode.value.slice(0,5) + "-" + myForm.txtPostalCode.value.slice(5)
	}

	if (!isEmail(myForm.txtEmail.value, 1, 255)) 
//	return warnInvalid(myForm.txtEmail, "Please enter a valid email address (xxx@xxx.xxx)");
		{
			window.alert("Please enter a valid email address (xxx@xxx.xxx)");
			myForm.txtEmail.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (!isLength(myForm.txtFirstNameShip.value, 1, 30)) 
//	return warnInvalid(myForm.txtFirstNameShip, "Child's first name must be between 1 and 30 characters in length");
		{
			window.alert("Child's first name must be between 1 and 30 characters in length");
			myForm.txtFirstNameShip.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtLastNameShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtLastNameShip, "Child's last name must be between 1 and 50 characters in length");
		{
			window.alert("Child's last name must be between 1 and 50 characters in length");
			myForm.txtLastNameShip.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtAddress1Ship.value, 1, 255)) 
//	return warnInvalid(myForm.txtAddress1Ship, "Child's shipping address must be between 1 and 255 characters in length");
		{
			window.alert("Child's shipping address must be between 1 and 255 characters in length");
			myForm.txtAddress1Ship.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (!isLength(myForm.txtCityShip.value, 1, 50)) 
//	return warnInvalid(myForm.txtCityShip, "Child's city must be between 1 and 50 characters in length");
		{
			window.alert("Child's city must be between 1 and 50 characters in length");
			myForm.txtCityShip.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

	if (myForm.stateShip.selectedIndex == "0") 
		{
			window.alert("Child's State must be selected");
			myForm.stateShip.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

//	if (myForm.stateShip.selectedIndex == "0") return warnInvalid(myForm.stateShip, "Child's State must be selected");

	myForm.txtPostalCodeShip.value = StripNotIn(myForm.txtPostalCodeShip.value, digits)
	if (!isUSZipCode(myForm.txtPostalCodeShip.value)) 
//	return warnInvalid(myForm.txtPostalCodeShip, "You must enter a valid US zip code. (e.g. #####) in shipping address.");
		{
			window.alert("You must enter a valid US zip code. (e.g. #####) in shipping address.");
			myForm.txtPostalCodeShip.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	if (myForm.txtPostalCodeShip.value.length == 9) {
		myForm.txtPostalCodeShip.value = myForm.txtPostalCodeShip.value.slice(0,5) + "-" + myForm.txtPostalCodeShip.value.slice(5)
	}

	if (myForm.chkBillLater) {
// if Bill Me Later exists then check to see if it is False
	 if (myForm.chkBillLater.checked == false) {

		if (!isLength(myForm.txtAccountName.value, 1, 30)) 
		{
			window.alert("Name on card must be between 1 and 30 characters in length");
			myForm.txtAccountName.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
		{
			window.alert("Card Number must be provided");
			myForm.txtAccountNumber.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}

		if (myForm.selYear.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Year for the Credit Card");
			myForm.selYear.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (myForm.selMonth.selectedIndex == "") 
		{
			window.alert("You must select a valid Expiry Month for the Credit Card");
			myForm.selMonth.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
		if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
		{
			window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
			myForm.selMonth.focus();
			//myForm.btnBuyNow.disabled = false;
			return false;
		}
	  } 
	} else {
// else if the Account Number field exists then check the expiry date
		if (myForm.txtAccountNumber) {
			if (!isLength(myForm.txtAccountNumber.value, 1, 30)) 
			{
				window.alert("Card Number must be provided");
				myForm.txtAccountNumber.focus();
				//myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (!isLength(myForm.txtAccountName.value, 1, 30)) 
			{
				window.alert("Name on card must be between 1 and 30 characters in length");
				myForm.txtAccountName.focus();
				//myForm.btnBuyNow.disabled = false;
				return false;
			}

			if (myForm.selYear.selectedIndex == "") 
			{				window.alert("You must select a valid Expiry Year for the Credit Card");
				myForm.selYear.focus();
				//myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (myForm.selMonth.selectedIndex == "") 
			{
				window.alert("You must select a valid Expiry Month for the Credit Card");
				myForm.selMonth.focus();
				//myForm.btnBuyNow.disabled = false;
				return false;
			}
			if (!isExpiryDate(myForm.selMonth.value, myForm.selYear.value)) 
			{
				window.alert("Your expiry date indicates the Credit Card has expired. Please check and enter again");
				myForm.selMonth.focus();
				//myForm.btnBuyNow.disabled = false;
				return false;
			}
		}
	}
	
	return true;
}


function validateRadio() {
	// set var radio_choice to false
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < frmProduct.selProduct.length; counter++)
	{
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (frmProduct.selProduct[counter].checked)
			radio_choice = true; 
	}

	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert("Please select a product to purchase");
		return (false);
	}
	return (true);
}