function updatesubtotal() {
	var intTotalProducts = document.getElementById( "totalproducts" ).value;
	var dblPricePerPack;
	var intQuantity;
	var dblSubTotal = 0.00;

	for ( var i = 1; i <= intTotalProducts; i++ ) {
		dblPricePerPack = document.getElementById( "price_" + i ).value;
		intQuantity = document.getElementById( "qty_" + i ).value;
		if ( intQuantity > 0 ) {
		    dblSubTotal = dblSubTotal + ( intQuantity * dblPricePerPack );
		}
	}

	document.getElementById( "subtotal" ).innerHTML = "<span class='price'>&pound;" + formatSubTotal( dblSubTotal ) + "</span>";
}

function formatSubTotal(n) {
	var s = "" + Math.round(n * 100) / 100;
	var i = s.indexOf('.');
	if (i < 0) return s + ".00";
	var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3);
	if (i + 2 == s.length) t += "0";
	return t;
}

function swapProduct( strFilename, strHeight, strWidth ) {
    var objProductLarge = document.getElementById("large");
    
    objProductLarge.innerHTML = "<img src='" + strFilename + "' height='" + strHeight + "' width='" + strWidth + "' />"
}

function openTerms() {

    //  Open new window.
    var objWindow = window.open( "terms.shtml", "name", "scrollbars=1, height=600, width=940" );
    objWindow.focus();
}