
<!--	// hiding

//format a decimal number to 2 digits and convert to string
function fix(num){
	num = num + 0.005		//round the last digit
	string = "" + num;
	if(string.indexOf('.',0) == -1){
		return string + '.00';
	}
	separation = string.length - string.indexOf('.',0);
	if (separation > 3){
		return string.substring(0,string.length - separation + 3);
	} else if (separation == 2){
		return string + '0';
	}
	return string;
}

function shippolicy(){
	var shipp = "shipping.html";
	newWindow = open(shipp,"shippingwindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250");
}

function buypolicy(){
	var buyp = "policy.html";
	newWindow = open(buyp,"policywindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=450,height=250");
}

//Calculate New unit price, total and shipping based on quantity
function qchange(){
	//get new quantity and set other areas
	var hunitprice = 39.95;
	var runitprice = 49.95
	var quantity1 = parseInt(document.cart.quan_house.value);
	var tot_price1 = quantity1 * hunitprice;
	document.cart.tprice_house.value = fix(tot_price1);
	var quantity2 = parseInt(document.cart.quan_rocket.value);
	var tot_price2 = quantity2 * runitprice;
	document.cart.tprice_rocket.value = fix(tot_price2);

	//Set shipping price
	var shipplace = document.cart.shiparea.value;
	if (document.cart.promotion.value == "spring10"){
		var hship = 0.00;			//Free shipping promotion
		var rship = 0.00;		
	} else if (document.cart.promotion.value == "wcmh345"){
		var hship = quantity1 * 6.00;			//Wholesale shipping
		var rship = quantity2 * 7.00;
	} else if (shipplace == "portland"){
		var hship = quantity1 * 7.95;			//house
		var rship = quantity2 * 7.95;			//rocket
	//Check for Oregon-Other or Washington Area
	} else if ((shipplace == "oregon") || (shipplace == "washington")) {
		var hship = quantity1 * 7.95;			//house
		var rship = quantity2 * 7.95;			//rocket
	//Check for Other (non-listed states)
	} else if (shipplace == "other") {
		var hship = quantity1 * 12.95;			//house
		var rship = quantity2 * 12.95;			//rocket
	//Check for Canada)
	} else if (shipplace == "c") {
		var hship = quantity1 * 25.00;			//house
		var rship = quantity2 * 25.00;			//rocket
	//Check for Mexico or International
	} else if ((shipplace == "m") || (shipplace == "int")) {
		alert('For shipping to Canada/Mexico or International, please call or email us.');
	//Otherwise select one of other western states
	} else {
		var hship = quantity1 * 7.95;			//house
		var rship = quantity2 * 7.95;			//rocket
	}
	
	document.cart.ship_house.value = fix(hship);
	document.cart.ship_rocket.value = fix(rship);
	var shipcost = hship + rship;
	document.cart.shipping.value = fix(shipcost);
	
	if (document.cart.signature.checked){
		var sigprice = 3.00;
		document.cart.sigcharge.value = fix(sigprice);
	} else {
		var sigprice = 0.00;
		document.cart.sigcharge.value = fix(sigprice);
	}

	//display new prices and recalculate new total with discount if promotion code correct
	var promo_code = document.cart.promotion.value;
	if (promo_code == "wcmh345"){		//Wholesale Discount
		var hprice = 20.00;
		var rprice = 25.00;
	} else if (promo_code == "wwmag"){
		var hprice = 39.95 * .85;
		var rprice = 49.95 * .85;
	} else {
		var hprice = 39.95;
		var rprice = 49.95;
	}
	document.cart.amt_house.value = fix(hprice);
	document.cart.amt_rocket.value = fix(rprice);

	var tot_price1 = quantity1 * hprice;
	document.cart.tprice_house.value = fix(tot_price1);
	var tot_price2 = quantity2 * rprice;
	document.cart.tprice_rocket.value = fix(tot_price2);

	var tot_price = tot_price1 + tot_price2 + shipcost + sigprice;
	document.cart.total.value = fix(tot_price);

}

function checkit(){
	//set API contents for Paypal checkout

	//Check for 0 quantities of item
	var quantity1 = parseInt(document.cart.quan_house.value);
	var quantity2 = parseInt(document.cart.quan_rocket.value);
	if ((quantity1 == 0) && (quantity2 == 0)){
		alert('You must order at least 1 product.');
	//} else if (document.cart.shiparea.value == ""){
		alert ('Please enter your shipping area');
		document.cart.shiparea.focus;
	} else {
		document.cart.submit();
	}
}

function buyhouse(){
	newquan = parseInt(document.cart.quan_house.value) + 1;
	document.cart.quan_house.value = newquan;
	qchange();
}

function buyrocket(){
	newquan = parseInt(document.cart.quan_rocket.value) + 1;
	document.cart.quan_rocket.value = newquan;
	qchange();
}

// end mask -->
