function isTotal(name)
{
	if (name.match("_total")) return true;
	else return false;
}

function stripTotal(value)
{
	return parseFloat(value.replace(/\$/,"0"));
}

function UpdateValue(item)
{
	// update price of clicked item
	input = document.getElementsByName(item + "_input");
	price = document.getElementsByName(item + "_price");
	total = document.getElementsByName(item + "_total");
	total[0].value = "$" + price[0].value * Math.round(input[0].value);

	// update price of total purchase
	sum = 0;
	i = 0;
	for( i=0; i<document.meatform.length; i++ )
		if (isTotal(document.meatform[i].name))
			sum += stripTotal(document.meatform[i].value);
	total = document.getElementsByName("total_grand");
	total[0].value = "$" + sum;
}

function OnSubmit()
{
    if ( document.meatform.name.value  == "" ) { alert("Please specify a name");         return; }
    if ( document.meatform.email.value == "" ) { alert("Please specify an email");       return; }
    if ( document.meatform.phone.value == "" ) { alert("Please specify a phone number"); return; }
    if ( document.meatform.total_grand.value == "$0.00" ||
         document.meatform.total_grand.value == "$0")
     { alert("Your order is empty!"); return; }

    document.meatform.submit();
}        

