
function applyHandlingFee(){
}

function applyShippingFee() {
}

function addToCart(theForm){
	//alert("here");
	
	var pkgQtyList = theForm.pkgQuantity;
	var selectedPkgQty = pkgQtyList.options[pkgQtyList.selectedIndex].value;
	
	var amount = calculateAmount(theForm.productNumber.value, selectedPkgQty);
	//alert("amount="+amount);
	theForm.amount.value=amount;
	//theForm.quantity.value=;
	var shippingOption = "Yes";
	for (var i=0; i < theForm.shippingoption.length; i++) {
		if (form.shippingoption[i].checked) {
			shippingOption = form.shippingoption[i].value;
		}
	}
	
	if (shippingOption == "Yes"){
		applyShippingFee();
	}
	applyHandlingFee();
}


function calculateAmount(productNumber, selectedPkgQty) {
	var amount = 0;
	var product = products[productNumber];
	if (selectedPkgQty > product.packages.length - 1) {
		var package = product.packages[0];
		selectedPkgQty = selectedPkgQty*1 + 1;//multiplied by 1 to convert var back to integer.
		amount = package.price * selectedPkgQty;
	} else {
		var package = product.packages[selectedPkgQty];
		
		amount = package.price;
	}
	return amount;
}


