// Calculate the total for items in the form which are selected.
function calculateTotal_reg(inputItem) {
  with (inputItem.form) {   
	
    var shipping_cost = 0;  //get this from teh radio button

    if (inputItem.type == "radio") {   // Process radio buttons.     
			shipping_cost = eval(inputItem.value);
    }

	amount.value = eval(orginal_cost.value) + eval(shipping_cost);

	// = combined_total.value; 
	calculatedTotal.value = eval(amount.value);

	//no mod made to the itemID or description
	item_name.value =  	item_name_org.value;
	item_number.value =	item_number_org.value ;

    // Return total value.
    return(formatCurrency(eval(amount.value)));
  }
}

function calculateTotal_express(inputItem) {
  with (inputItem.form) {   
	
    var shipping_cost = 0;  //get this from teh radio button

    if (inputItem.type == "radio") {   // Process radio buttons.     
			shipping_cost = eval(inputItem.value);
    }

	amount.value = eval(orginal_cost.value) + eval(shipping_cost);

	// = combined_total.value; 
	calculatedTotal.value = eval(amount.value);

	//update the itemID & description to refect expres
	item_name.value =  	item_name_org.value + ' (Express)';
	item_number.value =	item_number_org.value + '_exp';


    // Return total value.
    return(formatCurrency(eval(amount.value)));
  }
}




// Format a value as currency.
function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
     num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
      cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
      num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num + '.' + cents);
}

// This function initialzes all the form elements to default values.
function InitForm() {

   	submitit.enabled = false;
}


function formvalidation(cart)
{
	if (document.cart.Sauce[0].checked || document.cart.Sauce[1].checked)
	{
		cart.submit();
	}
	else
	{
		alert('Please make a selection.');
	}
}

