/* HIGHLIGHT SELECTED ITEM */
function changeclass(cb,elem) {
	if(cb.checked == true) {
		document.getElementById(elem).className = 'checked';
	} else if(cb.checked == false) {
		document.getElementById(elem).className = 'unchecked';
	}
}

/* CALCULATOR SCRIPT */
var subTotal = parseFloat (0.00)
var itemCount = parseInt (0)
var Ship = parseFloat (0.00)
var Total = parseFloat (0.00)
var tax = parseFloat (0.00)
var numString = ""
var ilTax = false
function fixNum(theNum) {
	numString = String(theNum)
	if (numString.indexOf('.') == -1) {
		numString = numString + ".00"
	} else {
		numString = numString + "000"
		numString = numString.substring(0, (numString.indexOf('.') + 3))
	}
}
function calcOrder(btnName, isChecked, price) {
	var myPrice = parseFloat(price)
	if (isChecked==true) {
		subTotal = subTotal + myPrice
		itemCount = itemCount + 1
		if (btnName=="PayCOD") {
			itemCount = itemCount - 1
		}
	} else {
		subTotal = subTotal - myPrice
		itemCount = itemCount - 1
		if (btnName=="PayCOD") {
			itemCount = itemCount + 1
		}
	}
	fixNum(subTotal)
	document.mailorder.subtotal.value = numString
	document.mailorder.items.value = itemCount
	calcTotal()
}
function calcShip(shipType, price1, price2) {
	var tempCount = itemCount
	var priceA = parseFloat(price1)
	var priceB = parseFloat(price2)
	var addShip = parseFloat (0.00)
	switch (shipType) {
		case "fourth" :
				document.mailorder.shipMeth.value = "US 4th Class"
				break
		case "first" :
				document.mailorder.shipMeth.value = "US 1st Class"
				Ship = priceA
				tempCount = tempCount - 1
				Ship = Ship + (tempCount * priceB)
				fixNum(Ship)
				document.mailorder.shipAmt.value = numString
				break	
		case "overair" :
				document.mailorder.shipMeth.value = "Overseas Air"
				Ship = priceA
				tempCount = tempCount - 1
				Ship = Ship + (tempCount * priceB)
				fixNum(Ship)
				document.mailorder.shipAmt.value = numString
				break
		case "pacair" :
				document.mailorder.shipMeth.value = "Pacific Air"
				Ship = priceA
				tempCount = tempCount - 1
				Ship = Ship + (tempCount * priceB)
				fixNum(Ship)
				document.mailorder.shipAmt.value = numString
				break
		case "canmex" :
				document.mailorder.shipMeth.value = "Canada/Mexico"
				Ship = tempCount * priceA
				fixNum(Ship)
				document.mailorder.shipAmt.value = numString
				break
		case "oversurf" :
				document.mailorder.shipMeth.value = "Overseas Surface"
				Ship = tempCount * priceA
				fixNum(Ship)
				document.mailorder.shipAmt.value = numString
				break
		default: 
	}
	calcTotal()
}
function flagTax(myIndex) {
	if (myIndex==22) {
		ilTax = true
	}
	calcTotal()
}
function calcTax() {
	if (ilTax==true) {
		tax = subTotal * 0.0875
		tax = tax * 100
		tax = Math.round(tax)
		tax = tax/100
		fixNum(tax)
		document.mailorder.tax.value = numString
	}
}
function calcTotal() {
	calcTax()
	Total = subTotal + tax
	Total = Total + Ship
	fixNum(Total)
	document.mailorder.total.value = numString
}