function refreshTotals()
{
	productcount	= document.Form1.productcount.value;
	qtycount		= 0;
	subTotal		= 0.0;

	for (i = 0; i < productcount; i++)
	{
		qty = eval('document.Form1.QTY'+i);
		
		if (!isNaN(qty.value))
		{
			qtycount += parseInt(qty.value);
		}
		else
		{
			alert('You have entered an invalid quantity');
			break;
		}
		
	}

	var priceNo = (qtycount > 11) ? 2 : 1;
	var grandTotal = 0;

	for (i = 0; i < productcount; i++)
	{
		qty 		= eval('document.Form1.QTY'+i);
		fromPrice   = eval('document.Form1.PRICE_'+priceNo+i);
		toPrice 	= eval('document.Form1.PRICE'+i);

		if (qty.value > 0)
		{
			subTotal											= Math.round((Math.ceil(parseInt(qty.value) * (parseFloat(fromPrice.value) * 100))) ) / 100 + "";

			if (subTotal.indexOf(".") == -1) subTotal += ".00";
			if (subTotal.indexOf(".") == subTotal.length - 2) subTotal += "0";

			document.getElementById("subtotal" + i).innerHTML   = "$"+subTotal;
			toPrice.value   									= fromPrice.value;
			grandTotal   										+= parseFloat(subTotal);
		}
		else
		{
			document.getElementById("subtotal" + i).innerHTML  = "$0.00";
			toPrice.value = 0.00;;
		}
	}
	deliveryTo = document.Form1.deliveryTo.value.split("$");
	document.getElementById("freightTotal").innerHTML  = "$"+deliveryTo[1];
	
	grandTotal = Math.round((Math.ceil((parseFloat(grandTotal) + parseFloat(deliveryTo[1])) * 100)) ) / 100 + "";
	if (grandTotal.indexOf(".") == -1) grandTotal += ".00";
	if (grandTotal.indexOf(".") == grandTotal.length - 2) grandTotal += "0";
	document.getElementById("grandTotal").innerHTML  = "$"+grandTotal;
	
	if (document.Form1.totalBottles) document.Form1.totalBottles.value = qtycount;
	
	
}