function GetXmlHttpObject(handler)
{
   var objXMLHttp=null
   if (window.XMLHttpRequest)
   {
       objXMLHttp=new XMLHttpRequest()
   }
   else if (window.ActiveXObject)
   {
       objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
   }
   return objXMLHttp
}

function stateChanged()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           document.getElementById("txtResult").innerHTML= xmlHttp.responseText;
   }
   else {
           //alert(xmlHttp.status);
   }
}

function setSearch()
{

	var sel = document.getElementById("make");
	var make = sel.options[sel.selectedIndex].text;
	var sear = document.getElementById("search");
	sel = document.getElementById("prod");
	var prod = sel.options[sel.selectedIndex].text;	
	

	if(make != null)
	{

		sel = document.getElementById("model");
		var model = sel.options[sel.selectedIndex].text;	

		sear.value = sear.value + " " + make;
		if(model != null && model != '- Select Make -')
		
		sear.value = sear.value + " " + model;
	}

	if(prod != null)
	{
		sel = document.getElementById("prodSG");
		var prodSG = sel.options[sel.selectedIndex].text;	
		
		sear.value = sear.value + " " + prod;
		if(prodSG != null && prodSG != "- Product Sub Group -")
			sear.value = sear.value + " " + prodSG;	
	}

	return false;
}

function stateChanged2()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           document.getElementById("txtResult2").innerHTML= xmlHttp.responseText;
   }
   else {
           //alert(xmlHttp.status);
   }
}
function stateChanged3()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           document.getElementById("txtResult3").innerHTML= xmlHttp.responseText;
   }
   else {
           //alert(xmlHttp.status);
   }
}
function stateChanged4()
{
   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
   {
           document.getElementById("result").innerHTML= xmlHttp.responseText;
   }
   else {
           //alert(xmlHttp.status);
   }
}
// Will populate data based on input
function htmlData(url, qStr)
{
   if (qStr == "ch=")
   {
       document.getElementById("txtResult").innerHTML="<select style=\"width: 150px\" name=\"model\" disabled id=\"model\"><option value=\"\">- Select Make -</option></select>";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}

function htmlData2(url, qStr)
{
  if (qStr == "ch=")
   {
       document.getElementById("txtResult2").innerHTML="<select style=\"width: 150px\" name=\"series\" disabled id=\"series\"><option value=\"\">- Select Model -</option></select>";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged2;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}

function htmlData3(url, qStr)
{
    if (qStr == "ch=")
   {
       document.getElementById("txtResult3").innerHTML="<select style=\"width: 150px\" disabled name=\"prodSubGroup\" id=\"prodSubGroup\"><option value=\"\">- Product Sub Group -</option></select>";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged3;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}

function query(url)
{
document.getElementById("result").innerHTML="Searching...";
	qStr = "make=" + document.getElementById("make").value + "&model=" + document.getElementById("model").value  + "&series=" + document.getElementById("series").value  + "&prodGroup=" + document.getElementById("prodGroup").value + "&prodSubGroup=" + document.getElementById("prodSubGroup").value + "&partNum=" + document.getElementById("partNum").value  + "&desc=" + document.getElementById("desc").value;
   if (url.length==0)
   {
       document.getElementById("result").innerHTML="";
       return;
   }
   xmlHttp=GetXmlHttpObject()
   if (xmlHttp==null)
   {
       alert ("Browser does not support HTTP Request");
       return;
   }

   url=url+"?"+qStr;
   url=url+"&sid="+Math.random();
   xmlHttp.onreadystatechange=stateChanged4;
   xmlHttp.open("GET",url,true) ;
   xmlHttp.send(null);
}