<!--

function calculate(field,form) {

	var itemNum = field.name.split("_");
	var qty = field.value;
	var fieldTotal = itemNum[0] + '_total';
	var fieldPrice = itemNum[0] + '_price';
	
	fieldPrice = document.getElementById(fieldPrice).value;
	
	document.getElementById(fieldTotal).value = formatDecimal(qty * fieldPrice, 2);
	
	total();
}

function total() {

	var theForm = document.forms[0];
	var grandTotal = document.getElementById('final_total');
	tot = parseInt(theForm.item1_total.value) + 
				parseInt(theForm.item2_total.value) + 
				parseInt(theForm.item3_total.value) +
				parseInt(theForm.item4_total.value) + 
				parseInt(theForm.item5_total.value) + 
				parseInt(theForm.item6_total.value) + 
				parseInt(theForm.item7_total.value) + 
				parseInt(theForm.item8_total.value) + 
				parseInt(theForm.item9_total.value) +
				parseInt(theForm.item10_total.value) +
				parseInt(theForm.item11_total.value) +
				parseInt(theForm.item12_total.value) +
				parseInt(theForm.item13_total.value) +
				parseInt(theForm.item14_total.value);
	grandTotal.value = formatDecimal(tot);
	
}

function formatDecimal(val, n) {
  n = n || 2;
  var str = "" + Math.round ( parseFloat(val) * Math.pow(10, n) );
  while (str.length <= n) str = "0" + str;
  var pt = str.length - n;
  return str.slice(0,pt) + "." + str.slice(pt);
}


/*function openwin(URL,theHeight,theWidth,addScrollBar) {
	var nXpos = (screen.availWidth - theWidth) / 2; 
	var nYpos = (screen.availHeight - theHeight) / 2; 
	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + ',scrollbars=' + addScrollBar);
	win.focus();
}*/


//-->
