function currency(money)
{
	money = money + ""           
	var monLen = money.length;
	var digPos = money.indexOf(".");

	if(digPos < 0)
	{
		money = money + ".00";
		return money;
	}
	else
	{
		cents = money.substring(digPos + 1, monLen + 1);
	}
		
	if(cents.length == 2)
		{return money;}

	if(cents.length == 1)
	{
		money = money + "0";
		return money;
	}
	else 
	{	if(cents.length > 2)
		{
			roundVal = cents.charAt(2);
			if(roundVal  >= 5)
			{
				money = money.substring(0,digPos+3)
				money = parseFloat(money) + .01;
				money = money + "";
				money = money.substring(0,digPos + 3)
			}
			else
			{
				money = money.substring(0,digPos + 3)
			}
		}
	}
	var monLen = money.length;
	var digPos = money.indexOf(".");

	if(digPos < 0)
	{
		money = money + ".00";
		return money;
	}
	else
	{
		cents = money.substring(digPos + 1, monLen + 1);
	}
		
	if(cents.length == 2)
		{return money;}

	if(cents.length == 1)
	{
		money = money + "0";
		return money;
	}
}

function doprice(theForm)
{
	qty = parseFloat(theForm.qty.value);
	cdqty = parseFloat(theForm.cdqty.value);

	totprice = 0;
	totprice = totprice + 24.95*qty;
	totprice = totprice + 9.95*cdqty;
	
	//shipping
	if(theForm.country[0].checked==true)
		{totprice = totprice + 5.95;
		if(qty==0 && cdqty>=1)
			{totprice = totprice - 3.00}
		}
		
	if(theForm.country[1].checked==true)
		{totprice = totprice + 14.95;
		if(qty==0 && cdqty>=1)
			{totprice = totprice - 8.00}
		}

	//quantity discounts
	if(qty>1)
		{totprice = totprice - 5.00*(qty-1)}
	if(cdqty>1)
		{totprice = totprice - 2.00*(cdqty-1)}
	if(qty>=1 && cdqty>=1)
		{totprice = totprice - 5.00}

	theForm.x_Amount.value = currency(totprice);
}



