function GetTapeQuantity() {
	var quantity = 0;
	var camcorderTapeQuantity = parseInt(document.reelDupesTape.camcorderTape.value);
	var vhsTape2Quantity = parseInt(document.reelDupesTape.vhsTape2.value);
	var vhsTape2PlusQuantity = parseInt(document.reelDupesTape.vhsTape2Plus.value);
	var betaMaxQuantity = parseInt(document.reelDupesTape.betaMax.value);
	var UMATICQuantity = parseInt(document.reelDupesTape.UMATIC.value);
	var BETACAMQuantity = parseInt(document.reelDupesTape.BETACAM.value);
	 
	if (isNaN(camcorderTapeQuantity)) {camcorderTapeQuantity = 0};
	if (isNaN(vhsTape2Quantity)) {vhsTape2Quantity = 0};
	if (isNaN(vhsTape2PlusQuantity)) {vhsTape2PlusQuantity = 0};
	if (isNaN(betaMaxQuantity)) {betaMaxQuantity = 0};	
	if (isNaN(UMATICQuantity)) {UMATICQuantity = 0};
	if (isNaN(BETACAMQuantity)) {BETACAMQuantity = 0};	
	
	quantity = camcorderTapeQuantity + vhsTape2Quantity + vhsTape2PlusQuantity + betaMaxQuantity + UMATICQuantity + BETACAMQuantity;
	return quantity;
}

function GetTransferSubtotal() {
	var totalcost = 0;
	var camcorderTapeCost = 15;
	var vhsTape2Cost = 15;
	var betaMaxCost = 25;
	var vhsTape2PlusCost = 30;
	var UMATICCost = 30;
	var BETACAMCost = 40;
	var camcorderTapeQuantity = parseInt(document.reelDupesTape.camcorderTape.value);
	var vhsTape2Quantity = parseInt(document.reelDupesTape.vhsTape2.value);
	var vhsTape2PlusQuantity = parseInt(document.reelDupesTape.vhsTape2Plus.value);
	var betaMaxQuantity = parseInt(document.reelDupesTape.betaMax.value);
	var UMATICQuantity = parseInt(document.reelDupesTape.UMATIC.value);
	var BETACAMQuantity = parseInt(document.reelDupesTape.BETACAM.value);
	var transferSubtotal = document.reelDupesTape.transferSubtotal;
	
	if (isNaN(camcorderTapeQuantity)) {camcorderTapeQuantity = 0};
	if (isNaN(vhsTape2Quantity)) {vhsTape2Quantity = 0};
	if (isNaN(vhsTape2PlusQuantity)) {vhsTape2PlusQuantity = 0};
	if (isNaN(betaMaxQuantity)) {betaMaxQuantity = 0};	
	if (isNaN(UMATICQuantity)) {UMATICQuantity = 0};
	if (isNaN(BETACAMQuantity)) {BETACAMQuantity = 0};
	
	totalcost = (camcorderTapeCost * camcorderTapeQuantity) + (vhsTape2Cost * vhsTape2Quantity) + (vhsTape2PlusCost * vhsTape2PlusQuantity);
	totalcost = totalcost + (betaMaxQuantity * betaMaxCost) + (UMATICQuantity * UMATICCost) + (BETACAMQuantity * BETACAMCost);
	totalcost = totalcost.toFixed(2) 
	transferSubtotal.value = totalcost;
	document.reelDupesTape.orderEstimate.value = "";
	return totalcost;
}

function GetPackageTotal() {
		var packageBasicCost = 10;
		var packageDeluxeCost = 20;
		var tapeQuantity = GetTapeQuantity();
		var logoCost = 10;
		var transferSubtotal = GetTransferSubtotal();
		var packageSubtotal = document.reelDupesTape.packageSubtotal;
		
		var addLogo = document.reelDupesTape.addLogo;
		var totalcost;
		
		
		totalcost = parseFloat(transferSubtotal);
		if (isNaN(totalcost)) {totalcost = 0;}
		
		if (document.reelDupesTape.packageChoice[0].checked) {
			totalcost = totalcost + (packageBasicCost * tapeQuantity);
		} else if(document.reelDupesTape.packageChoice[1].checked) {
			totalcost = totalcost + (packageDeluxeCost * tapeQuantity);
		}	
				
		if (addLogo.checked) {
			totalcost = totalcost + (logoCost * tapeQuantity);
		} 
		
		totalcost = totalcost.toFixed(2);
		packageSubtotal.value = totalcost;	
		document.reelDupesTape.orderEstimate.value = "";
		return totalcost;
}

function GetCopiesTotal() {
	var Cost1 = 7.5;
	var Cost2 = 6;
	
	var tapeQuantity = GetTapeQuantity();
	var CopiesQuantity = parseFloat(document.reelDupesTape.dvdCopies.value);
	var totalcost = GetPackageTotal();
	var copiesSubtotal = document.reelDupesTape.copiesSubtotal;

	if (isNaN(CopiesQuantity)) {CopiesQuantity = 0;}
	CopiesQuantity = tapeQuantity * CopiesQuantity;
	
	totalcost = parseFloat(totalcost);
	if (isNaN(totalcost)) {totalcost = 0;}
	
	if (CopiesQuantity > 0 && CopiesQuantity <= 5) {
		totalcost = totalcost + (CopiesQuantity * Cost1);
	} else if (CopiesQuantity > 5) {
		totalcost = totalcost + (CopiesQuantity * Cost2);
	}
	
	totalcost = totalcost.toFixed(2);
	copiesSubtotal.value = totalcost;
	document.reelDupesTape.orderEstimate.value = "";
	return totalcost;	
}

function GetRushTotal() {
	var totalcost = GetCopiesTotal();
	var rushCost = 0;
	var rushOrder = document.reelDupesTape.rushOrder;
	var rushSubtotal = document.reelDupesTape.rushSubtotal;
	
	totalcost = parseFloat(totalcost);
	if (isNaN(totalcost)) {totalcost = 0;}
	
	if (rushOrder.checked) {rushCost = totalcost * 0.5}
	totalcost = totalcost + rushCost;	
	totalcost = totalcost.toFixed(2);
	rushSubtotal.value = totalcost;
	document.reelDupesTape.orderEstimate.value = "";
	return totalcost;	
}

function GetShipTotal() {
	var totalcost = GetRushTotal();
	var shipCostStandard = 10;
	var shipCostOvernight = 25;
	var shipCostRegistered = 20;
	var shipCost = 0;
	var shipSubtotal = document.reelDupesTape.shipSubtotal;
	var quantity = 0;
	
	totalcost = parseFloat(totalcost);
	if (isNaN(totalcost)) {totalcost = 0;}
	
	quantity = GetTapeQuantity();
	if (isNaN(quantity)) {quantity = 0;}
	if (document.reelDupesTape.shipOption[0].checked) {
		if (quantity > 4) {shipCostStandard = shipCostStandard * 1.5;}
		totalcost = totalcost + shipCostStandard;
	} else if(document.reelDupesTape.shipOption[1].checked) {
		if (quantity > 4) {shipCostOvernight = shipCostOvernight * 1.5;}
		totalcost = totalcost + shipCostOvernight;
	} else if(document.reelDupesTape.shipOption[2].checked) {
			if (quantity > 4) {shipCostRegistered = shipCostRegistered * 1.5;}
			totalcost = totalcost + shipCostRegistered;
	}		
	totalcost = totalcost.toFixed(2);
	shipSubtotal.value = totalcost;
	document.reelDupesTape.orderEstimate.value = "";
	return totalcost;	
}

function UpdateTotals() {
	var totalcost = 0;
	totalcost = GetShipTotal();
	totalcost = parseFloat(totalcost);
	if (isNaN(totalcost)) {totalcost = 0;}
	totalcost = totalcost.toFixed(2);
	return totalcost;	
}

function FinalEstimate() {
	var orderEstimate = document.reelDupesTape.orderEstimate;
	var finalTotal = UpdateTotals();
	orderEstimate.value = finalTotal;
}
