/* Function calculates all total fields for the order calculation */

function ComputeTotal(form)
{
/* This section rounds out the display of individual fields to show cents to 2 places */    
    BCZR_CDBK_SUB_1 = rndcents(form.field01.value * 175.00);
    BCZR_CDONLY_SUB_1 = rndcents(form.field03.value * 125.00);
	BCZR_BKONLY_SUB_1 = rndcents(form.field05.value * 90.00);

/* This section calculates true workable values for calculations */    
    BCZR_CDBK_SUB_1 = eval(form.field01.value * 275.00);
    BCZR_CDONLY_SUB_1 = eval(form.field03.value * 205.00);
	BCZR_BKONLY_SUB_1 = eval(form.field05.value * 130.00);

/* Calculate individual subtotals and format display value */	
prod_subtotal1 = BCZR_CDBK_SUB_1;
prod_subtotal2 = BCZR_CDONLY_SUB_1;
prod_subtotal3 = BCZR_BKONLY_SUB_1;

/* This section rounds out the display of individual fields to show cents to 2 places */
    form.field02.value = rndcents(prod_subtotal1);
    form.field04.value = rndcents(prod_subtotal2);
    form.field06.value = rndcents(prod_subtotal3);

/* Calculate Subtotal before taxes and format display value */	
subtotal = prod_subtotal1 + prod_subtotal2 + prod_subtotal3;
form.ordersubtotal.value = rndcents(subtotal);

/* Calculate taxes for PA and NY residents and format display value */
    form.parestax.value = rndcents(form.ordersubtotal.value * form.YesNo.options[form.YesNo.selectedIndex].value);
    form.pacotax.value = rndcents(form.ordersubtotal.value * form.NoYes.options[form.NoYes.selectedIndex].value);
    form.nycorestax.value = rndcents(form.ordersubtotal.value * form.nytax.options[form.nytax.selectedIndex].value);

/* Calculates taxes for PA and NY residents */    
	PA_ST_TAX = eval(form.ordersubtotal.value * form.YesNo.options[form.YesNo.selectedIndex].value);
	PA_CO_TAX = eval(form.ordersubtotal.value * form.NoYes.options[form.NoYes.selectedIndex].value);
	NY_TAXES = eval(form.ordersubtotal.value * form.nytax.options[form.nytax.selectedIndex].value);

/* Calculate Total and format display value */	
total = (subtotal + PA_ST_TAX + PA_CO_TAX + NY_TAXES);
form.field07.value = rndcents(total);

}

/* rounds number to 2 decimal places and outputs as string
    cannot calculate total on this value (Strictly a display feature!) */
function rndcents(n) {
cents=n*100;
cents=Math.round(cents);
strcents="" + cents;
len=strcents.length;
return strcents.substring(0,len - 2) + "." + strcents.substring(len - 2, len);
}
