var xmlhttp;
var mainDocLoaded;

function update() {
	if(mainDocLoaded == 1) {
		xmlhttp=null;
		if(document.getElementById('productSelection'))
			theform = document.getElementById('productSelection'); // Mozilla
		else
			theform = getElementById('productSelection'); // IE
		calcurl = "/scripts/buy/updatelist.php?";
		calcurl += "&postage=" + theform.postage.checked;
		calcurl += "&postcode=" + theform.postcode.value;
		calcurl += "&SIGEqty=" + theform.SIGEqty.value;
		calcurl += "&SIGERESqty=" + theform.SIGERESqty.value;
		calcurl += "&YASqty=" + theform.YASqty.value;
		calcurl += "&OHYHqty=" + theform.OHYHqty.value;
		calcurl += "&OHYHRESqty=" + theform.OHYHRESqty.value;
		calcurl += "&DUMMY=2"		//REMOVE THIS!
		if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } // code for Mozilla, etc.
		else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } // code for IE
		if (xmlhttp!=null) {
		  xmlhttp.onreadystatechange=state_Change;
		  xmlhttp.open("GET",calcurl,true);
		  xmlhttp.send(null);
		} else {
		alert("Your browser does not support XMLHTTP.");
		}
	}
}

function state_Change() {
	if (xmlhttp.readyState==4) { // if xmlhttp shows "loaded"
	  if (xmlhttp.status==200) { // if "OK"
		  document.getElementById('currentPurchaseSelections').innerHTML=xmlhttp.responseText;
	  } else {
		  alert("Problem retrieving data:" + xmlhttp.statusText);
	  }
	}
}

function firstUpdate() {
	mainDocLoaded = 1;
	update();
}

