function UpdateAmount(frm)
{

	var fr = 0;

var plx = "";
var x = "";


	for(i=0; i<document.store.elements.length; i++) 	{
		if (document.store.elements[i].name.indexOf("product_") >= 0) {
			if (document.store.elements[i].name.length == 9) {
				plx = document.store.elements[i].name.substr(8,1);
			} else {
				plx = document.store.elements[i].name.substr(8,2);
			}
			x = document.getElementById("numberof_"+plx);
			if (document.store.elements[i].checked) {
				if (x.value == 0) {
					x.value = 1;
					x.disabled=false;
				}
			} else {
				x.value = 0;
				x.disabled=true;
			}
		}
	}

	UpdateProductTotal(frm);
	UpdateShipping();
	UpdateTotal();
}

function UpdateProductTotal(frm)
{
	var total = 0;
	var x = "";
	var y = "";


	for(i=0; i<document.store.elements.length; i++) 	{
		if (document.store.elements[i].name.indexOf("product_") >= 0) {
			if (document.store.elements[i].name.length == 9) {
				plx = document.store.elements[i].name.substr(8,1);
			} else {
				plx = document.store.elements[i].name.substr(8,2);
			}
			x = document.getElementById("numberof_"+plx);
			y = document.getElementById("amount_"+plx);
			if (document.store.elements[i].checked) {
				total = total + (x.value * y.value);
			}
		}
	}

	document.store.producttotal.value = total.toFixed(2);
	UpdateTax();
	UpdateTotal();
}

function UpdateTax()
{
	var tax = 0;
	if (document.store.state.options[document.store.state.options.selectedIndex].value == "IL") {
		tax = document.store.producttotal.value * .1;
		document.store.tax_cart.value = tax.toFixed(2);
	} else {
		tax = 0;
		document.store.tax_cart.value = tax.toFixed(2);
	}
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function checkIfNumber(inputObj){
	var ok = 'Y';
	var msg = '';
	var val = trim(inputObj.value);

		if (isNaN(val) || val < 0) {
			ok = 'N';
			msg = "You must enter a number";
		}
		if (ok == 'N') {
			inputObj.value ='0';
			return false;
		}
	UpdateProductTotal(inputObj.form);
	UpdateShipping();
	UpdateTotal();
}

function UpdateShipping()
{

	var shipping = 0;

		if (document.store.expedite.checked) {
			shipping = 25;
		}

	document.store.shipping.value = shipping.toFixed(2);

	UpdateTotal();
}

function UpdateTotal()
{
	var total = 0;

	total = Math.abs(document.store.shipping.value) + Math.abs(document.store.tax_cart.value) + Math.abs(document.store.producttotal.value);
	document.store.total.value = total.toFixed(2);

}

function setcustom(frm)
{

var included_fields = "|title|organization|ext|cellphone|member_id|";
var productlist = "";
var alreadychecked = 1;
var count = 1;
var plx = "";
var x = "";
var y = "";
var z = "";

document.store.custom.value = "";
document.store.business.value = "djohansson@hfma.org";

	for(i=0; i<document.store.elements.length; i++) 	{
		if (document.store.elements[i].name.length == 10) {
			plx = document.store.elements[i].name.substr(9,1);
		} else {
			plx = document.store.elements[i].name.substr(9,2);
		}
		if (document.store.elements[i].name.indexOf("numberof_") >= 0 && document.store.elements[i].value != '0') {

			x = document.getElementById("product_"+plx);
			y = document.getElementById("item_name_"+count);
			z = document.getElementById("quantity_"+count);

			z.value = document.store.elements[i].value;
			y.value = x.value
			count++;
		}

		if (included_fields.indexOf("|" + document.store.elements[i].name + "|") >= 0 && document.store.elements[i].value != '') {
			if (document.store.elements[i].name != "shippingmethod") {
				document.store.custom.value = document.store.custom.value + "|" + document.store.elements[i].name + "=" + document.store.elements[i].value;
			}

		}
	}

			document.store.handling_cart.value = document.store.shipping.value;
document.store.submit();

}

function setProducts(frm)
{

var plx = "";
var x = "";


	for(i=0; i<document.store.elements.length; i++) 	{
		if (document.store.elements[i].name.indexOf("product_") >= 0) {
			plx = document.store.elements[i].name.substr(8,1);
			if (document.store.elements[i].checked) {
				x = document.getElementById("numberof_"+plx);
				x.value = 1;
				x.disabled=false;
			} else {
				x.value = 0;
				x.disabled=true;
			}
		}
	}
}
