function price2(o2price){
	document.addtobasket.priceo2.value = o2price;
	updatePrice();
}
function price3(o3price){
	document.addtobasket.priceo3.value = o3price;
	updatePrice();
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function r2(n) { 

  ans = n * 1000 
  ans = Math.round(ans /10) + "" 
  while (ans.length < 3) {ans = "0" + ans} 
  len = ans.length 
  ans = ans.substring(0,len-2) + "." + ans.substring(len-2,len)
  return ans 
} 

function updatePrice() {
	var totalPrice
	totalPrice = eval(document.addtobasket.pricebase.value) + eval(document.addtobasket.priceo2.value) + eval(document.addtobasket.priceo3.value);
	totalPrice = r2(totalPrice);
	writeLayer('pricediv', '&nbsp;&pound;' + totalPrice);
}

function writeLayer(layerID, txt){
	if(document.getElementById){
		document.getElementById(layerID).innerHTML=txt;
	}
	else if(document.all){
		document.all[layerID].innerHTML=txt;
	}
	else if(document.layers){
		with(document.layers[layerID].document){
			open();
			write(txt);
			close();
		}
	}
}
