function updatePrice(frm)

{

// Update total price when option is changed



var extra = 0; // extra costs



// determine which size entry form contains the price field

if (frm.name=="rmoptions") pfield = document.getElementById("price_readymade");

else pfield = document.getElementById("price_madetomeasure");



// get the basic price from the size entry form

price = parseFloat(pfield.value.substring(pfield.value.indexOf("£")+1) );



// loop through option-select elements and see if they incur extra cost

for (var i=0; i<frm.elements.length; i++)

{

	if (frm.elements[i].type == "select-one") {

	//var regex = /\(£(\d+\.\d\d)\)/;

	var regex = /\((\+\%(\d+)|£(\d+\.\d\d))\)/;

	var result = regex.exec(frm.elements[i].options[frm.elements[i].selectedIndex].text);

	if (result) {

		if (result[0].indexOf('%')>0) extra += parseInt(result[2])*price/100;

		else extra += parseFloat(result[3]);

	}

	}

}



// add the extra costs to the basic price

var total = (price + extra).toFixed(2);



// update the total price on the page

if (frm.name=="rmoptions") elem = document.getElementById("rmtotalprice");

else elem = document.getElementById("mtmtotalprice");

elem.firstChild.nodeValue = 'Total: £' + total;

}



var w = null;



function showOptionImages(option_id, frm, num_values)//option_id, option_name, images_array)

{

// open a window to show graphical representations of available option choices

var url = 'http://www.wooden-blinds-direct.co.uk/options.php?id=' + option_id;

if (frm) url += '&frm=' + frm;

if (w && !w.closed) { w.close();}

var height = num_values * 20 + 300;
if (!num_values) height=600;

if (height>600) height=600;

//var width = num_values * 30 + 300;

var width=700;

w=window.open(url, 'Options', 'width=' + width + ', height=' + height + ',left=200,top=180,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1'); 

}



function showGallery(id)

{

var url = 'http://www.wooden-blinds-direct.co.uk/gallery.php?id=' + id;

if (w && !w.closed) { w.close();}

w=window.open(url, 'Gallery', 'width=520, height=620, left=200,top=50,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0'); 

}


