<!--
//require form "form1", fields Q[], P[], totalCost, destination, nextTarget
function doTotal() {
	//loop through all form objects... If QX then PX --> QX * PX = subtotal
	//QX = quantity field PX = price field
	
	var subtotal, i, Qname, Pname, Qobj, Pobj, obj, totalCost
	i=1;
	subtotal=0;
	totalCost=0;
	//Possible Quote Item handled first
	quotePriceField = "quotePrice";
	Qobj = MM_findObj(quotePriceField);
	if (Qobj) { 
		totalCost = parseFloat(Qobj.value);
//alert("totalCost after Quote item is" + totalCost);
	}	
	//All other items
	Qname = "Q" + i;
	Qobj = MM_findObj(Qname);
	while (Qobj) { //while Qobj is a defined object
		Pname = "P" + i;
		Pobj = MM_findObj(Pname);
		if (Pobj) { 
			subtotal = Pobj.value * Qobj.value;
//alert("subtotal for Item "+i+" is: "+subtotal);
			totalCost = totalCost + subtotal;
//alert("totalCost after Item "+i+" is: "+totalCost);
		}
		i=i+1;
		Qname = "Q" + i;
		Qobj = MM_findObj(Qname);
	}//while
	totalCost = formatCurrency(totalCost);
	obj = MM_findObj("totalCost");
	obj.value = totalCost;
}
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num) || num=="" || num==" " || num=="  " || num=="   " || num=="    " || num=="     " || num=="      ")
		return "0.00";
	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);
}
function check_number(objname) { 
var obj;
	obj=MM_findObj(objname);
	if (isNaN(obj.value)) {
		obj.value=0;
	} else {
		if (obj.value < 0) {
			obj.value = 0;
		}
	}
	doTotal();
return true;
}
function additem(i, total) {
var objname, obj
	objname = "Q" + i;
    obj = MM_findObj(objname);
	obj.value = parseInt(obj.value) + parseInt(1);
	if (total){ doTotal(); }
return true;
}	
function removeitem(i, total) {
var objname, obj
	objname = "Q" + i;
    	obj = MM_findObj(objname);
	if (obj.value > 0) {
		obj.value = obj.value - 1;
	}
	if (total){ doTotal(); }
return true;	
}
function jumptoTarget(page) {
	var obj;
	obj = MM_findObj("destination");
	obj.value = page;
	obj = MM_findObj("form1");
	obj.submit();
}
function setDestination(nextTarget) {
	document.form1.nextTarget.value = nextTarget
	return true;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//-->