function openAWindow( pageToLoad, winName, width, height, center) {
  xposition=0; yposition=0;
  if ((parseInt(navigator.appVersion) >= 4 ) &&(center)) {
   xposition = (screen.width - width) / 2;
   yposition = (screen.height - height) / 2;
  }
  args = "width=" + width + ","
  + "height=" + height + ","
  + "location=0,"
  + "menubar=0,"
  + "resizable=0,"
  + "scrollbars=0,"
  + "status=0,"
  + "titlebar=0,"
  + "toolbar=0,"
  + "hotkeys=0,"
  + "screenx=" + xposition + "," //NN Only
  + "screeny=" + yposition + "," //NN Only
  + "left=" + xposition + "," //IE Only
  + "top=" + yposition; //IE Only
  window.open( pageToLoad, winName, args );
}

function checkShippingState(obj) {
	if (obj.options[obj.selectedIndex].value == 36) {
		alert("Tax 7.5% will apply for Ohio!");
	}
}

var clicked = false;
var products = 0;
function buynow() {

	// under construction
	//alert("Under Construction");
	//return false;
	

	if (clicked == true) {
		alert("You can only click once!");
	} else {


		var returnval = true;
		var f = document.main;
		var d = new Date();
		var year = d.getFullYear()-2000;	// should be valid for another 100 years ;)
		var month = d.getMonth()+1;

		if (returnval == true) {
			if (f.firstname.value.length<2) {
				alert("Please enter your first name!");
				f.firstname.focus();
				returnval = false;
			} else if (f.lastname.value.length<2) {
				alert("Please enter your last name!");
				f.lastname.focus();
				returnval = false;
			} else if (f.billingaddress1.value.length<2) {
				alert("Please enter your billing address!");
				f.billingaddress1.focus();
				returnval = false;
			} else if (f.city.value.length<2) {
				alert("Please enter your city!");
				f.city.focus();
				returnval = false;
			} else if (f.state.selectedIndex==0) {
				alert("Please select your state!");
				f.state.focus();
				returnval = false;
			} else if (f.zip.value.length<5) {
				alert("Please enter a zip code that is at least 5 digits");
				f.zip.focus();
				returnval = false;
			} else if (f.email.value.indexOf('@') == -1) {
				alert("Please enter your e-mail address!");
				f.email.focus();
				returnval = false;
			} else if (f.email.value != f.email2.value) {
				alert("The e-mail addresses do not match!");
				f.email2.focus();
				returnval = false;
			} else if (f.thecreditcardtype.selectedIndex == 0) {
				alert("Please select credit card type!");
				f.thecreditcardtype.focus();
				returnval = false;
			} else if (f.thecreditcardtype.selectedIndex==1 && f.creditcard.value.length!=15) {
				alert("Please enter your credit card number (15 digits without spaces)!");
				f.creditcard.focus();
				returnval = false;
			} else if (((f.thecreditcardtype.selectedIndex!=1) && (f.thecreditcardtype.selectedIndex != 0)) && f.creditcard.value.length!=16) {
				alert("Please enter your credit card number (16 digits without spaces)!");
				f.creditcard.focus();
				returnval = false;
			} else if (f.expirationmonth.selectedIndex==0) {
				alert("Please select a credit card expiration month!");
				f.expirationmonth.focus();
				returnval = false;
			} else if (f.expirationyear.selectedIndex==0) {
				alert("Please select a credit card expiration year!");
				f.expirationyear.focus();
				returnval = false;
			} else if (f.cvv.value.length != 3) {
				alert("For your protection, the 3-digit CCV (Credit Card Verification) number on your credit card is required for processing.\nAll credit card cards now being released have a three digit Credit Card Verification number issued on them.\nThe 3-digit CCV is usually printed on the signature panel on the back of the card immediately after the card number or partial card number.\nFor simplicity, the CCV is always the last 3 digits shown on the signature panel.");
				f.cvv.focus();
				returnval = false;
			} else if (f.shipaddress1.value.length<2) {
				alert("Please enter your shipping address!");
				f.shipaddress1.focus();
				returnval = false;
			} else if (f.shipcity.value.length<2) {
				alert("Please enter your shipping city!");
				f.shipcity.focus();
				returnval = false;
			} else if (f.shipstate.selectedIndex==0) {
				alert("Please select your shipping state!");
				f.shipstate.focus();
				returnval = false;
			} else if (f.shipzip.value.length<5) {
				alert("Please enter a zip code that is at least 5 digits");
				f.shipzip.focus();
				returnval = false;
			}
		}

		if (returnval) {
			// buy now!
			if (confirm("Your order will be processed at this time.")) {
				clicked = true;
				f.submit();
			}
		}

	}
}

function duplicateshipping(obj) {
	var f = document.main;
	if (obj.checked) {
		f.shipaddress1.value = f.billingaddress1.value;
		f.shipaddress2.value = f.billingaddress2.value;
		f.shipcity.value = f.city.value;
		f.shipstate.selectedIndex = f.state.selectedIndex;
		f.shipzip.value = f.zip.value;
	
		// check for Ohio
		checkShippingState(f.shipstate);
	} else {
		// do nothing
	}
}