function Format(x) {
	var pounds, pence;
	pounds = Math.floor(x);
	pence = Math.round(x*100) % 100;
	if (pence==0) {
		pence = "00"; 
	} else { 
		if (pence<10)
			pence = "0" + pence;
	}
	return pounds + "." + pence;
}
function Update(i) {
	var qm = "q"+i;
	var cm = "c"+i;
	var pm = "p"+i;
	var q = document.OrderForm[qm];
	var c = document.OrderForm[cm];
	var p = document.OrderForm[pm];
	if(parseInt(q.value)>0)
		c.value = Format(q.value * p.value); 
	else
	{
		c.value = "";
		q.value = "";
	}
	UpdateTotal();
}
function UpdateTotal(){
	var pnp = 4.95,qm,pm,t = 0;
	c = parseInt(document.OrderForm.c.value);
	for(i=1;i<=c;i++){
	  qm = "q"+i;
	  pm = "p"+i;
	  if(parseInt(document.OrderForm[qm].value)>0){
		 t += parseFloat(document.OrderForm[qm].value*document.OrderForm[pm].value );
	  }
	}
	if(t>0)
	{
		document.OrderForm['s'].value = Format(t);
		t+=pnp;
		document.OrderForm['t'].value = Format(t);
	}
	else
	{
		document.OrderForm['s'].value = "";
		document.OrderForm['t'].value = "";
	}
}
