function calcPrice(id) {
	var quantityid = "quantity" + id;
	var currencyid = "currency_code" + id;
	var priceid = "displayamount" + id;
	var amountid = "amount" + id;
	var qty = document.getElementById(quantityid).selectedIndex + 1;
	
	//select the currency and retrieve the base price via the form's hidden fields
	var symbol, selCurrencyIndex = document.getElementById(currencyid).selectedIndex;
	
	if(selCurrencyIndex == 0) {
		price = "us" + id;
		symbol = "$";
		}
	else {
		price = "uk" + id;
		symbol = "&pound;";
		}
	price = document.getElementById(price).value;
	document.getElementById(amountid).value = price;
	
	var priceid = "displayamount" + id;
	
	
	
	price = currency(price * qty);
	
	document.getElementById(priceid).innerHTML = "<b>" + symbol + price + "</b>";
	}

function currency(anynum) {
        //returns number as string in $xxx,xxx.xx format.
        anynum = "" + eval(anynum)  //evaluate (in case an expression sent)
        intnum = parseInt(anynum)  //isolate integer portion
        intnum = Math.abs(intnum)
        intstr = ""+intnum
        
        //add comma in thousands place.
        if (intnum >= 1000) {
                intlen = intstr.length
                temp1=parseInt(""+(intnum/1000))
                temp2=intstr.substring(intlen-3,intlen)
                intstr = temp1+","+temp2
        	}
        if (intnum >= 1000000) {
                intlen = intstr.length
                temp1=parseInt(""+(intnum/1000000))
                temp2=intstr.substring(intlen-7,intlen)
                intstr = temp1+","+temp2
        	}

        decnum = Math.abs(parseFloat(anynum)-parseInt(anynum)) //isolate decimal portion
        decnum = decnum * 100 // multiply decimal portion by 100.
        decstr = "" + Math.abs(Math.round(decnum))
        if (decstr.length>2) {decstr=decstr.substring(0,2)}
        while (decstr.length < 2) {decstr="0"+decstr}
        retval = intstr + "." + decstr 
        if (anynum < 0) {
                retval="("+retval+")"
        	}
        return retval;
	}
