<!--
var pic1= new Image(82,24); 
pic1.src="/images/but_try_dwn.gif"; 
var pic2= new Image(121,24); 
pic2.src="/images/but_what_dwn.gif"; 
var pic3= new Image(151,24); 
pic3.src="/images/but_how_dwn.gif"; 
var pic4= new Image(124,24); 
pic4.src="/images/but_guarantee_dwn.gif"; 
var pic5= new Image(41,24); 
pic5.src="/images/but_faq_dwn.gif"; 
var pic6= new Image(91,24); 
pic6.src="/images/but_ingredients_dwn.gif"; 
var pic7= new Image(30,24); 
pic7.src="/images/but_contact_dwn.gif"; 
var pic8= new Image(265,78);
pic8.src="/images/single_off.gif";
var pic9= new Image(265,78);
pic9.src="/images/twin_on.gif";

function swapImg(o) {
	var srcLen = o.src.length;
	if (o.src.indexOf("dwn")>-1) {
		o.src = o.src.substring(0,(srcLen-8)) + ".gif";
	}
	else {
		o.src = o.src.substring(0,(srcLen-4)) + "_dwn.gif";
	}
}

function validateContactForm() {
	var name = document.contactform.name.value;
	var sender_email = document.contactform.sender_email.value;
	var comment = document.contactform.comment.value;
	var validate = true;
	var msg = "";
	if (name.length<2) {
		msg += "Please enter your name.\n\n";
		validate = false;
	}
	if (sender_email.length<7) {
		msg += "Please enter your email in the form email@address.com.\n\n";
		validate = false;
	}
	if (comment.length<2) {
		msg += "Please enter your message.\n\n";
		validate = false;
	}
	if (!validate) alert(msg);
	return validate;
}

function validateLoginForm() {
	var email = document.loginform.email.value;
	var pass = document.loginform.pass.value;
	var validate = true;
	var msg = "";
	if (email.length<2) {
		msg += "Please enter your email address.\n\n";
		validate = false;
	}
	if (pass.length<3) {
		msg += "Please enter your password.\n\n";
		validate = false;
	}
	if (!validate) alert(msg);
	return validate;
}

function validateSampleForm() {
	var name = document.sampleform.name.value;
	var sender_email = document.sampleform.sender_email.value;
	var address1 = document.sampleform.address1.value;
	var city = document.sampleform.city.value;
	var state = document.sampleform.state.options[document.sampleform.state.selectedIndex].value;
	var zip = document.sampleform.zip.value;
	var validate = true;
	var msg = "";
	if (name.length<2) {
		msg += "Please enter your name.\n\n";
		validate = false;
	}
	if (sender_email.length<7) {
		msg += "Please enter your email in the form email@address.com.\n\n";
		validate = false;
	}
	if (address1.length<2) {
		msg += "Please enter the first line of your address.\n\n";
		validate = false;
	}
	if (city.length<2) {
		msg += "Please enter your city.\n\n";
		validate = false;
	}
	if (state.length<2) {
		msg += "Please select your state.\n\n";
		validate = false;
	}
	if (zip.length<2) {
		msg += "Please enter your ZIP code.\n\n";
		validate = false;
	}
	if (!validate) alert(msg);
	return validate;
}

function checkProduct(button) {
	if (button=="singlebutton")	{
		document.getElementById("singlebutton").style.background = "url(/images/single_on.gif) no-repeat";
		document.getElementById("twinbutton").style.background = "url(/images/twin_off.gif) no-repeat";
		document.orderform.product[0].checked = true;
		document.orderform.product[1].checked = false;

	}
	else {
		document.getElementById("singlebutton").style.background = "url(/images/single_off.gif) no-repeat";
		document.getElementById("twinbutton").style.background = "url(/images/twin_on.gif) no-repeat";
		document.orderform.product[1].checked = true;
		document.orderform.product[0].checked = false;
	}
}

function setButtonId(isInternational) {
	var product = "";
	if (document.orderform.product[0].checked) product = document.orderform.product[0].value;
	if (document.orderform.product[1].checked) product = document.orderform.product[1].value;
	if (!isInternational) {
		document.orderform.country.value = "US";
		document.orderform.os0.value = "USPS Priority Mail Domestic (2 to 5 days) - Free";
		if (product=="single") document.orderform.hosted_button_id.value = "6785973";
		if (product=="twin") document.orderform.hosted_button_id.value = "6787053";
	}
	else {
		document.orderform.country.value = "";
		document.orderform.os0.value = "USPS Priority Mail International (3 to 10 business days) - $4.95";
		if (product=="single") document.orderform.hosted_button_id.value = "6837723";
		if (product=="twin") document.orderform.hosted_button_id.value = "6837883";
	}
}

function setButtonCodes() {
	var product = "";
	if (document.orderform.product[0].checked) product = document.orderform.product[0].value;
	if (document.orderform.product[1].checked) product = document.orderform.product[1].value;
	document.orderform.os0.value = "USPS Priority Mail International (3 to 10 business days) - Free";
	if (product=="single") document.orderform.hosted_button_id.value = "6785973";
	if (product=="twin") document.orderform.hosted_button_id.value = "6787053";
}

function validateOrderForm() {
	var fields = "";
	if (document.detailsform.first_name.value=="") fields += "First name cannot be empty\n";
	if (document.detailsform.last_name.value=="") fields += "Last name cannot be empty\n";
	if (document.detailsform.email.value=="") fields += "Email cannot be empty\n";
	if (document.detailsform.address_line_1.value=="") fields += "Address line 1 cannot be empty\n";
	if (document.detailsform.country.options[0].selected) fields += "You must select a country\n";
	if (document.detailsform.city.value=="") fields += "City cannot be empty\n";
	if (document.detailsform.state.value=="") fields += "State/province cannot be empty\n";
	if (document.detailsform.post_code.value=="") fields += "Zip/postal code cannot be empty\n";
	if (!document.detailsform.same_billing.checked)	{
		if (document.detailsform.billing_first_name.value=="") fields += "Billing first name cannot be empty\n";
		if (document.detailsform.billing_last_name.value=="") fields += "Billing last name cannot be empty\n";
		if (document.detailsform.billing_address_line_1.value=="") fields += "Billing address line 1 cannot be empty\n";
		if (document.detailsform.billing_country.options[0].selected) fields += "You must select a billing country\n";
		if (document.detailsform.billing_city.value=="") fields += "Billing city cannot be empty\n";
		if (document.detailsform.billing_state.value=="") fields += "Billing state/province cannot be empty\n";
		if (document.detailsform.billing_post_code.value=="") fields += "Billing zip/postal code cannot be empty\n";
	}
	if (document.detailsform.card_type.options[0].selected) fields += "Select a card type\n";
	if (document.detailsform.card_number.value=="") fields += "Card number cannot be empty\n";
	if (document.detailsform.card_number.value.length<16) fields += "Card number must be 16 digits in length\n";
	if (document.detailsform.expiration_month.options[0].selected) fields += "Select an expiration month\n";
	if (document.detailsform.expiration_year.options[0].selected) fields += "Select an expiration year\n";
	if (document.detailsform.security_code=="") fields += "Security code cannot be empty\n";
	if (fields!="")	{
		alert("Fields are missing or have been entered incorrectly:\n\n" + fields + "\nPlease check the form before resubmitting.\n\n");
		return false;
	}
	return true;
}

function getShipping() {
	var i = document.detailsform.country.selectedIndex;
	var country = document.detailsform.country.options[i].value;
	var shipping = "";
	var shippingPrice = "";
	if (country!="") {
		if (country=="US") {
			shipping = "Shipping: USPS Priority Mail Domestic (2 to 5 days) - $4.95";
			shippingPrice = "4.95";
		}
		else {
			shipping = "Shipping: USPS Priority Mail International (3 to 10 business days) - $14.95";
			shippingPrice = "14.95";
		}
		document.getElementById("shipping_info").innerHTML = shipping;
		document.detailsform.shipping.value = shippingPrice;
		document.getElementById("pricing_info").innerHTML = " plus <b>$" + shippingPrice + "</b> for shipping";
	}
}
//-->
