 function _select() {
    		JsHttpRequest.query(
            '../products.select.php', // backend
            {
                'product_name': document.getElementById("product").value
            },
            function(result, errors) {
                document.getElementById("option_test").innerHTML = result["q"]
            },
            false  // do not disable caching
        );
    }

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function flvFPW1(){//v1.44
// Copyright 2002-2004, Marja Ribbers-de Vroed, FlevOOware (www.flevooware.nl/dreamweaver/)
var v1=arguments,v2=v1[2].split(","),v3=(v1.length>3)?v1[3]:false,v4=(v1.length>4)?parseInt(v1[4]):0,v5=(v1.length>5)?parseInt(v1[5]):0,v6,v7=0,v8,v9,v10,v11,v12,v13,v14,v15,v16;v11=new Array("width,left,"+v4,"height,top,"+v5);for (i=0;i<v11.length;i++){v12=v11[i].split(",");l_iTarget=parseInt(v12[2]);if (l_iTarget>1||v1[2].indexOf("%")>-1){v13=eval("screen."+v12[0]);for (v6=0;v6<v2.length;v6++){v10=v2[v6].split("=");if (v10[0]==v12[0]){v14=parseInt(v10[1]);if (v10[1].indexOf("%")>-1){v14=(v14/100)*v13;v2[v6]=v12[0]+"="+v14;}}if (v10[0]==v12[1]){v16=parseInt(v10[1]);v15=v6;}}if (l_iTarget==2){v7=(v13-v14)/2;v15=v2.length;}else if (l_iTarget==3){v7=v13-v14-v16;}v2[v15]=v12[1]+"="+v7;}}v8=v2.join(",");v9=window.open(v1[0],v1[1],v8);if (v3){v9.focus();}document.MM_returnValue=false;return v9;}


function getQuote()
{
	var result = 0;
	var vmatrix = 0;
	var vwidth = 0;
	var vproduct = 0;
	var vdrop = 0;	
	var vqty = 1;
	var x;
	var msg;
	var showmsg = false; 
	var foundresult = false;
	var getPrice = true;
	
	MM_showHideLayers('sideformbottom','','hide');
	
//	var selProduct = document.getElementById('product');
	var selProduct = document.quoteform.product;
	var txtWidth = document.getElementById('width');
	var txtDrop = document.getElementById('drop');
	var txtQty = document.getElementById('quantity');
	//var selIndex = selProduct.selectedIndex;
	var selIndex = document.quoteform.product.selectedIndex;

	vproduct = selProduct.options[selIndex].value;	
	vwidth = txtWidth.value;
	vdrop = txtDrop.value;	
	vqty = txtQty.value;
	
	if (vproduct == 0) {
		msg = "Please select a product\n";		
		showmsg = true;
		getPrice = false;			
	}
	if (vwidth == 0) {
	//	msg = msg + "Please enter a width (in cm)\n";
		getPrice = false;		
	}
	if (vdrop == 0) {
	//	msg = msg + "Please enter a drop (in cm)\n";		
		getPrice = false;		
	}	
	
	if (getPrice) {
		for (x in aProdMatrix) {
			if (aProdMatrix[x][0] == vproduct) {
				vmatrix = aProdMatrix[x][1];	
			}		
		}
		
		for (x in aMatrix) {		
			if (foundresult == false) {
				if (aMatrix[x][0] == vmatrix) {				
					if (aMatrix[x][1] >= vwidth) {
						if (aMatrix[x][2] >= vdrop) {
							result = aMatrix[x][3];
							// now multiply by qty
							result = result * vqty;
							result = result.toFixed(2);
							foundresult = true;
						}	
					}						
				} 		
			}	
		}	// end for	
		if (foundresult) {
	//		alert ("price found");
			document.quoteform.priceresult.value = "£" + result;
			document.quoteform.price.value = result;	
			MM_showHideLayers('sideformbottom','','show');
			fake_basket = document.getElementById('fakesubmit');
			fake_basket.style.display = "none";
			_select();
//			MM_showHideLayers('fakesubmit','','hide');
		} else {
			alert ("No price found for this width/drop combination");		
		}
	} else {
		if (showmsg) {
			alert (msg);
		}
	} // end getprice		
		
}

function confirmTerms() {
	var chkIagree = document.getElementById('iagree');
	var butValidSubmit = document.getElementById('validsubmit');
	alert('tratat');
	if(chkIagree.value == 'checked') {document.confirmform.validsubmit.disabled = false }
	
//	if(document.confirmform.iagree.checked == true) {document.confirmform.validsubmit.disabled = false }
//	if(document.confirmform.iagree.checked == false) {document.confirmform.validsubmit.disabled = true }

}

function validateConfirm(nextloc) {
	var chkIagree = document.getElementById('iagree');	
	var chkHowhear = document.getElementById('howhear').value;	
	var nextLink = nextloc + '?hear=' + chkHowhear;
	if(chkIagree.checked == true) {
		if(chkHowhear != '0') {
				document.MM_returnValue = true;
  			window.location = nextLink;
			} else {		
				alert ("Please select how did you hear about us");	
				document.MM_returnValue = false;
			}		
	} else {		
		alert ("Please indicate that you agree to our terms and conditions");	
		document.MM_returnValue = false;
	}
	return document.MM_returnValue;
}