// JavaScript Document

function GetDiscount(qty)
{
	if (qty == 1)
	{
		return 1;
	}
	if (qty >=2 && qty<10)
	{
		return 0.9;
	}
	if (qty >=11 && qty<30)
	{
		return 0.8;
	}
	if (qty >=31 && qty<50)
	{
		return 0.7;
	}
	if (qty >=51 && qty<100)
	{
		return 0.6;
	}
	
	return 0.5;
}

function GetDiscountPrice(basePrice, qty, discountAble)
{
	if (discountAble)
	{
		return basePrice*qty*GetDiscount(qty);
	}
	
	return basePrice*qty;
}

function CaculateTotal()
{
	if (isNaN(document.all.qty.value) || document.all.qty.value=="")
	{
		document.getElementById("total2").innerHTML = "0";
		document.all.Submit.disabled = true;
	}
	else
	{
		document.all.Submit.disabled = false;
		var qty = document.all.qty.value;
		var totalPrice = GetDiscountPrice(29.95, qty, true);
		if (document.all.chk_cd.select)
		{
			totalPrice = totalPrice*1 + GetDiscountPrice(9.95, qty, false)*1;
		}
		document.getElementById("total2").innerHTML =  totalPrice.toFixed(2);
	}
	return true;
}

function SubmitOrder()
{
	var url = "http://secure.emetrix.com/order/product.asp?PID=67206539&DID=44311159&Q=" + document.all.qty.value;
	window.open(url)
	return true;
}

