function doUpdate(productID, qtyID)
{
	qty = document.getElementById(qtyID).value;
	window.location = "CartUpdate.asp?Action=Update&OrderTempItemID=" + productID + "&ItemQuantity=" + qty;
}

function doUpdateMultiple()
{
	var frm = document.forms.frmCart;
	frm.action = "CartUpdate.asp?Action=UpdateMultiple";
	frm.submit();
}

function doDelete(productID, itemtitle) 
{
	if (confirm("Really remove " + itemtitle + " from your shopping cart?")) 
	{
		window.location = "CartUpdate.asp?Action=Delete&OrderTempItemID=" + productID;	
	}
}

function doClear()
{
	if (confirm("Really remove all items from your shopping cart?")) 
	{
		window.location = "CartUpdate.asp?Action=Cancel";	
	}
}


// check to see if the total quantity of products ordered is 12
// or after that a multiple of 6
function checkTotalQty()
{
	var MIN_BOTTLES = 6;
	var BOTTLE_INCREMENT = 6;

	var maxItems = parseInt(document.getElementById("maxItems").value);
	var totalBottles = 0;

	for (var i = 0; i < maxItems; i++)
	{
		itemQty = parseInt(document.getElementById("ItemQuantity_" + i).value);
		uomMultiplier = parseInt(document.getElementById("UOMMultiplier_" + i).value);

		totalBottles += itemQty * uomMultiplier;		
	}

	if (totalBottles < MIN_BOTTLES)
	{
		alert("You must order at least " + MIN_BOTTLES + " bottles. You currently have " + totalBottles + " in your shopping cart.");
	} 
	else
	{
		var remainder = parseInt(totalBottles % BOTTLE_INCREMENT);

		if (remainder > 0)
		{
			var moreBottles = parseInt(BOTTLE_INCREMENT - remainder);

			alert("Your shopping cart has more than " + MIN_BOTTLES + " bottles. You must order in increments of 6 from now on. You currently have " + totalBottles + " bottles in your shopping cart. Please order " + moreBottles + " more bottles, or discard " + remainder + ".");
		}
		else
		{
			var frm = document.forms.frmCart;
			frm.action = "CartUpdate.asp?Action=Complete";
			frm.submit();
		}
	}
}