var xmlHttp
function updateFS(str)
 { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)  {
  alert ("Browser does not support HTTP Request")
  return
 } 
 
 var url="process/dropdown_fs.php"
 url=url+"?q="+str
 url=url+"&sid="+Math.random()
 url=url+"type=fs";
 xmlHttp.onreadystatechange=stateChangedThickness 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 }
 
function updateBacking(str)  { 
 xmlHttp=GetXmlHttpObject()
 if (xmlHttp==null)  {
  alert ("Browser does not support HTTP Request")
  return
 } 
 
 var url="process/dropdown_backing.php"
 url=url+"?q="+str;
 url=url+"&sid="+Math.random()
 url=url+"type=backing";
 xmlHttp.onreadystatechange=stateChangedBacking 
 xmlHttp.open("GET",url,true)
 xmlHttp.send(null)
 }
 
function stateChangedThickness() { 
			updateMessage   = "Updating FoilSeals with Matching Thickness . . .";
			completeMessage = "FoilSeal List Updated.";
			updateStatus(updateMessage,completeMessage);
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
				xmlDoc=xmlHttp.responseXML; 
				var root = xmlHttp.responseXML;
				var dataArrayLen = xmlDoc.getElementsByTagName('foilseal').length;
				document.getElementById("foilseal").length = 0;
				sel = document.getElementById("foilseal");
				for (var i=0; i<dataArrayLen; i++){
					var result = root.getElementsByTagName('foilseal')[i];
					if (result != null) {
						sel.options[i] = new Option(result.childNodes[1].childNodes[0].nodeValue,result.childNodes[0].childNodes[0].nodeValue);			
					}
				}
			}
}

function stateChangedBacking() { 
			updateMessage   = "Updating Backing with Matching Backing Types . . .";
			completeMessage = "Backing List Updated.";
			updateStatus(updateMessage,completeMessage);
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
				xmlDoc=xmlHttp.responseXML; 
				var root = xmlHttp.responseXML;
				var dataArrayLen = xmlDoc.getElementsByTagName('backing').length;
				document.getElementById("backing").length = 0;
				sel = document.getElementById("backing");
				for (var i=0; i<dataArrayLen; i++){
					var result = root.getElementsByTagName('backing')[i];
					if (result != null) {
						sel.options[i] = new Option(result.childNodes[1].childNodes[0].nodeValue,result.childNodes[0].childNodes[0].nodeValue);			
					}
				}
			}
}


function updateStatus(updateMessage,completeMessage) {
	if(xmlHttp.readyState !=4) {
   	  	var statusDIV = document.getElementById('statusUpdate');
		if(statusDIV.firstChild) {
			statusDIV.removeChild(statusDIV.firstChild);
			statusDIV.innerHTML = updateMessage;
		} else {
			statusDIV.appendChild(document.createTextNode('Processing . . . ' + http_request.readyState));
		}
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var statusDIV = document.getElementById('statusUpdate');
		if(statusDIV.firstChild) {
			statusDIV.removeChild(statusDIV.firstChild);
			statusDIV.innerHTML = completeMessage;
		} else {
			statusDIV.appendChild(document.createTextNode('FoilSeal List Updated.'));
		}
	}

}




function GetXmlHttpObject() { 
 var objXMLHttp=null
 if (window.XMLHttpRequest)
  {
  objXMLHttp=new XMLHttpRequest()
  }
 else if (window.ActiveXObject)
  {
  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
 return objXMLHttp
 }