function checkSameAs(objForm)
{
	if(objForm.sameasbilling.checked)
	{
		objForm.shippingfirstname.value = objForm.billingfirstname.value;
		objForm.shippinglastname.value = objForm.billinglastname.value;
		objForm.shippingaddress1.value = objForm.billingaddress1.value;
		objForm.shippingaddress2.value = objForm.billingaddress2.value;
		objForm.shippingcity.value = objForm.billingcity.value;
		objForm.shippingstate.value = objForm.billingstate.value;
		objForm.shippingzipcode.value = objForm.billingzipcode.value;
		objForm.shippingphonenumber.value = objForm.billingphonenumber.value;
	}
	else
	{
		objForm.shippingfirstname.value = "";
		objForm.shippinglastname.value = "";
		objForm.shippingaddress1.value = "";
		objForm.shippingaddress2.value = "";
		objForm.shippingcity.value = "";
		objForm.shippingstate.value = "none";
		objForm.shippingzipcode.value = "";
		objForm.shippingphonenumber.value = "";
	}
}

function checkFormAdd(objForm)
{
	if(!isPositiveInteger(objForm.qty.value))
	{
		alert("Please enter a positive number for this value.");
		objForm.qty.value = "";
		objForm.qty.focus();
		return false
	}
	return true;
}

function checkCartAdd(objForm)
{
	if(!isNonnegativeInteger(objForm.qty.value))
	{
		alert("You cannot use negative numbers in this field.")
		objForm.qty.focus();
		return false;
	}
	return true;
}

function openCVV2()
{
	var NewWin = window.open('cvv2_info.asp', 'CVV2Info', 'scrollbars,status=no,width=400,height=485,left=50,top=50');
	NewWin.focus();
}

function checkOutForm(objForm)
{
	if(objForm.billingfirstname.value == "")
	{
		alert("Please enter a first name for billing.");
		objForm.billingfirstname.focus();
		return false;
	}
	if(objForm.billinglastname.value == "")
	{
		alert("Please enter a last name for billing.");
		objForm.billinglastname.focus();
		return false;
	}
	if(objForm.billingaddress1.value == "")
	{
		alert("Please enter a billing address.");
		objForm.billingaddress1.focus();
		return false;
	}
	if(objForm.billingcity.value == "")
	{
		alert("Please enter a city for billing.");
		objForm.billingcity.focus();
		return false;
	}
	if(objForm.billingstate.value == "")
	{
		alert("Please select a state for billing.");
		objForm.billingstate.focus();
		return false;
	}
	if(objForm.billingzipcode.value == "")
	{
		alert("Please enter a zip code for billing.");
		objForm.billingzipcode.focus();
		return false;
	}
	if(!isZIPCode(stripCharsInBag(objForm.billingzipcode.value, "-")))
	{
		alert("Please enter a valid zip code for billing.");
		objForm.billingzipcode.value = "";
		objForm.billingzipcode.focus();
		return false;
	}
	if(objForm.billingphonenumber.value == "")
	{
		alert("Please enter a phone number for billing.");
		objForm.billingphonenumber.focus();
		return false;
	}
	if(!isUSPhoneNumber(stripCharsInBag(objForm.billingphonenumber.value, "()-. ")))
	{
		alert("Please enter a valid phone number for billing.");
		objForm.billingphonenumber.value = "";
		objForm.billingphonenumber.focus();
		return false;
	}
	if(!isEmail(objForm.emailaddress.value))
	{
		alert("Please enter a valid email address.  A receipt will be sent to this address.");
		objForm.emailaddress.value = "";
		objForm.emailaddress.focus();
		return false;
	}
	if(objForm.paymentmethod.value == "")
	{
		alert("Please select a payment method.");
		objForm.paymentmethod.focus();
		return false;
	}
     if(objForm.paymentmethod.value == "Visa")
     {
		if(objForm.cardholdername.value == "")
		{
			alert("Please enter the cardholder's name, as it appears on the Visa card.");
			objForm.cardholdername.focus();
			return false;
		}
		if(objForm.cardnumber.value == "")
		{
			alert("Please enter the Visa card number.");
			objForm.cardnumber.focus();
			return false;
		}
		if(!isVisa(stripCharsInBag(objForm.cardnumber.value, " -")))
		{
			alert("Please enter a valid Visa card number.");
			objForm.cardnumber.value = "";
			objForm.cardnumber.focus();
			return false;	     
		}
		if(objForm.cvv2.value == "")
		{
			alert("Please enter the Visa card's CVV2 number.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.cvv2.value.length != 3)
		{
			alert("Visa CVV2 numbers are three digits long.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.value = "";
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.expmonth.value == "")
		{
			alert("Please select the Visa card's expiration month.");
			objForm.expmonth.focus();
			return false;
		}
		if(objForm.expyear.value == "")
		{
			alert("Please select the Visa card's expiration year.");
			objForm.expyear.focus();
			return false;
		}
     }
     if(objForm.paymentmethod.value == "MasterCard")
     {
		if(objForm.cardholdername.value == "")
		{
			alert("Please enter the cardholder's name, as it appears on the MasterCard.");
			objForm.cardholdername.focus();
			return false;
		}
		if(objForm.cardnumber.value == "")
		{
			alert("Please enter the MasterCard number.");
			objForm.cardnumber.focus();
			return false;
		}
		if(!isMasterCard(stripCharsInBag(objForm.cardnumber.value, " -")))
		{
			alert("Please enter a valid MasterCard card number.");
			objForm.cardnumber.value = "";
			objForm.cardnumber.focus();
			return false;	     
		}
		if(objForm.cvv2.value == "")
		{
			alert("Please enter the MasterCard's CVV2 number.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.cvv2.value.length != 3)
		{
			alert("MasterCard CVV2 numbers are three digits long.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.value = "";
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.expmonth.value == "")
		{
			alert("Please select the MasterCard's expiration month.");
			objForm.expmonth.focus();
			return false;
		}
		if(objForm.expyear.value == "")
		{
			alert("Please select the MasterCard's expiration year.");
			objForm.expyear.focus();
			return false;
		}
     }
     if(objForm.paymentmethod.value == "Discover")
     {
		if(objForm.cardholdername.value == "")
		{
			alert("Please enter the cardholder's name, as it appears on the Discover card.");
			objForm.cardholdername.focus();
			return false;
		}
		if(objForm.cardnumber.value == "")
		{
			alert("Please enter the Discover card number.");
			objForm.cardnumber.focus();
			return false;
		}
		if(!isDiscover(stripCharsInBag(objForm.cardnumber.value, " -")))
		{
			alert("Please enter a valid Discover card number.");
			objForm.cardnumber.value = "";
			objForm.cardnumber.focus();
			return false;	     
		}
		if(objForm.cvv2.value == "")
		{
			alert("Please enter the Discover card's CVV2 number.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.cvv2.value.length != 3)
		{
			alert("Discover CVV2 numbers are three digits long.\nThis is the number on the far right of the signature box on the back of the card.");
			objForm.cvv2.value = "";
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.expmonth.value == "")
		{
			alert("Please select the Discover card's expiration month.");
			objForm.expmonth.focus();
			return false;
		}
		if(objForm.expyear.value == "")
		{
			alert("Please select the Discover card's expiration year.");
			objForm.expyear.focus();
			return false;
		}
     }
     if(objForm.paymentmethod.value == "Amex")
     {
		if(objForm.cardholdername.value == "")
		{
			alert("Please enter the cardholder's name, as it appears on the American Express card.");
			objForm.cardholdername.focus();
			return false;
		}
		if(objForm.cardnumber.value == "")
		{
			alert("Please enter the American Express card number.");
			objForm.cardnumber.focus();
			return false;
		}
		if(!isAmericanExpress(stripCharsInBag(objForm.cardnumber.value, " -")))
		{
			alert("Please enter a valid American Express card number.");
			objForm.cardnumber.value = "";			
			objForm.cardnumber.focus();
			return false;	     
		}
		if(objForm.cvv2.value == "")
		{
			alert("Please enter the American Express card's CVV2 number.\nThis is the non-embossed four-digit number on the front of the card.");
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.cvv2.value.length != 4)
		{
			alert("American Express CVV2 numbers are four digits long.\nThis is the non-embossed four-digit number on the front of the card.");
			objForm.cvv2.value = "";
			objForm.cvv2.focus();
			return false;
		}
		if(objForm.expmonth.value == "")
		{
			alert("Please select the American Express card's expiration month.");
			objForm.expmonth.focus();
			return false;
		}
		if(objForm.expyear.value == "")
		{
			alert("Please select the American Express card's expiration year.");
			objForm.expyear.focus();
			return false;
		}
     }
	if(objForm.shippingcost.value == "")
	{
		alert("Please select a shipping method.");
		objForm.shippingcost.focus();
		return false;
	}
	if(objForm.shippinglastname.value == "")
	{
		alert("Please enter a last name for shipping.");
		objForm.shippinglastname.focus();
		return false;
	}
	if(objForm.shippingaddress1.value == "")
	{
		alert("Please enter a shipping address.");
		objForm.shippingaddress1.focus();
		return false;
	}
	if(objForm.shippingcity.value == "")
	{
		alert("Please enter a city for shipping.");
		objForm.shippingcity.focus();
		return false;
	}
	if(objForm.shippingstate.value == "")
	{
		alert("Please select a state for shipping.");
		objForm.ShippingState.focus();
		return false;
	}
	if(objForm.shippingzipcode.value == "")
	{
		alert("Please enter a zip code for shipping.");
		objForm.shippingzipcode.focus();
		return false;
	}
	if(!isZIPCode(stripCharsInBag(objForm.shippingzipcode.value, "- ")))
	{
		alert("Please enter a valid zip code for shipping.");
		objForm.shippingzipcode.value = "";
		objForm.shippingzipcode.focus();
		return false;
	}
	if(objForm.shippingphonenumber.value == "")
	{
		alert("Please enter a phone number for shipping.");
		objForm.shippingphonenumber.focus();
		return false;
	}
	if(!isUSPhoneNumber(stripCharsInBag(objForm.shippingphonenumber.value, "()-. ")))
	{
		alert("Please enter a valid phone number for shipping.");
		objForm.shippingphonenumber.value = "";
		objForm.shippingphonenumber.focus();
		return false;
	}
	return true;
}
