function padNumber(pNum)
	{
	var xv="hello"; 
	var x2="";
	var value1=0;
	var cnt=0;
	var cv=1000;

	x=pNum;
		
	while (x.length > 0)
		{
		tmp=x.charAt(0);
		if (tmp >= "0" && tmp <="9" || tmp==".")
			{			
			if (tmp == ".") 
				{
				if (cv>=1000) {cv=0;}
				if (cnt<1) {x2=x2+x.charAt(0);}
				cnt++;
				}
			else				
				{
				if (cv<1000) {cv++;}
				x2=x2+x.charAt(0);
				}
			}
		x=x.substring(1,x.length);
		}

	if (cv>=1000) {cv=0;}

	if (cv==0) {x2=x2+".00";}
	if (cv==1) {x2=x2+"0";}

	if (cv>=3) 
		{
		tmp=x2.length;
		tmp-=cv;
		tmp+=2;
		
		x2=x2.substring(0,tmp);
		}

	if (x2.charAt(0)==".") {x2="0"+x2;}

	return(x2);
	} 

function addUp()
	{
	BedPrices = new Array(5)
	BedPrices [0] = new Array(2)
	BedPrices [1] = new Array(2)
	BedPrices [2] = new Array(2)
	BedPrices [3] = new Array(2)
	BedPrices [4] = new Array(2)
	BedPrices [5] = new Array(2)

	BedPrices[0][0]="699";
	BedPrices[0][1]="1049";
	
	BedPrices[1][0]="699";
	BedPrices[1][1]="1049";

	BedPrices[2][0]="949";
	BedPrices[2][1]="1399";
	
	BedPrices[3][0]="949";
	BedPrices[3][1]="1399";
	
	BedPrices[4][0]="1099";
	BedPrices[4][1]="1599";
	
	BedPrices[5][0]="1299";
	BedPrices[5][1]="1849";
	
	var myindex  = document.CFORM.BedSize.selectedIndex
	var myindex2  = document.CFORM.BedType.selectedIndex
	var myindex3  = document.CFORM.Zip.selectedIndex

	if (myindex2==0) {document.getElementById('bt').innerHTML="COST OF YOUR DIAMOND MATTRESS";}
	else {document.getElementById('bt').innerHTML="COST OF YOUR DIAMOND BED";}
		
	document.getElementById('bp').innerHTML="£"+BedPrices[myindex][myindex2]+".00";
	document.CFORM.BEDCOST.value=BedPrices[myindex][myindex2];

	var myext  = (document.CFORM.Drawers.selectedIndex*50)+(myindex3*100);
	document.getElementById('ep').innerHTML="£"+myext+".00";	
	document.CFORM.EXTRACOST.value=myext;

	var mytot=Number(BedPrices[myindex][myindex2])+Number(myext);

	if (document.CFORM.SALEON.value=="Y")
		{
		mytot=mytot*((100-25)/100);
		}
	mytot=Math.floor(mytot);
	
	var tmp="";
	tmp=mytot.toString();
	tmp=padNumber(tmp);
		
	document.getElementById('tt').innerHTML="£"+tmp;	
	}
