var price_array = new Array(9);
price_array[0] = 14.95; // PQ
price_array[1] = 14.95; // WNS
price_array[2] = 12.95; // EOC
price_array[3] = 12.95; // POT
price_array[4] = 14.95; // WS3D
price_array[5] = 14.95; // CV
price_array[6] = 14.95; // 1MA
price_array[7] = 14.95; // BIS
price_array[8] = 16.95; // CS


//
// N.B. document.shoppingcart syntax works in IE but not firefox; replace with document.forms["shoppingcart"]
//


function Dollarize(Number) 
{
	//return "$" + Number; // TEST

	if (Number.toFixed)
	{
		return "$" + Number.toFixed(2);
	}
	else
	{
		return "$" + Math.round(Number * 100) / 100.0;
	}
}

function OnCheck()
{
	var full_price		= new Number();
	var savings 		= new Number();
	var actual_price	= new Number();
	
	count = 0;
	savings = 0;
	for (var i = 0; i < document.forms["shoppingcart"].items.length; i++)
	{
		if (document.forms["shoppingcart"].items[i].checked)
		{
			full_price += price_array[i];
			count++;
		}
	}
	
	if (count > 1)
	{
		//savings = 0.3 * full_price;
		// Tweak the math to compensate for floating point errors
		savings = 0.29999999 * full_price;
	}

	if (count == 9)
	{
		savings = full_price - 49.95;
		document.forms["shoppingcart"].ss_coupon.value = "WOND-4WMV";
	}
	else
	{
		document.forms["shoppingcart"].ss_coupon.value = "WOND-0Q0N";
	}
	
	actual_price = full_price - savings;
	
   	document.forms["shoppingcart"].label.value 		= "Total:";
	document.forms["shoppingcart"].actual_price.value	= Dollarize(actual_price);

	if (count > 1)
	{
		document.forms["shoppingcart"].full_price.value 	= Dollarize(full_price);
		//document.forms["shoppingcart"].savings.value	= "(Saving you $" + savings + "!)";
	}
	else
	{
		document.forms["shoppingcart"].full_price.value 	= "";
		//document.forms["shoppingcart"].savings.value 		= "";
	}
}

function InitForm()
{
	OnCheck();
}