var xmlHttp;
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera"); 
		return ;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP";
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler ;
			return objXmlHttp;
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") ;
			return ;
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler; 
		return objXmlHttp;
	}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		function showcat()
		{
			category="category";
			category=document.getElementById(category);
			category=category.options[category.selectedIndex].value;
			if(category==-1){return;}//state=document.f1.RESIDINGSTATE.options[RESIDINGSTATE.selectedIndex].value;

			var url="showsubcat.php?cid="+category;			
			xmlHttp=GetXmlHttpObject(gsubcategory);
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		
		function gsubcategory()
		{
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
			{
				//alert (xmlHttp.responseText);
				document.getElementById("subdiv").innerHTML= xmlHttp.responseText;
			}
		}
		
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function showbrand()
		{
			device="device";
			device=document.getElementById(device);
			device=device.options[device.selectedIndex].value;
			if(device==-1){return;}//state=document.f1.RESIDINGSTATE.options[RESIDINGSTATE.selectedIndex].value;

			var url="showbrand.php?did="+device;			
			xmlHttp=GetXmlHttpObject(gsubcategory2);
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		
		function gsubcategory2()
		{
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
			{
				//alert (xmlHttp.responseText);
				document.getElementById("brand").innerHTML= xmlHttp.responseText;
			}
		}
		
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

		function showmodel(brand)
		{
		/*	brand=document.getElementById(brand);
			brand=brand.options[brand.selectedIndex].value;
			if(brand==-1){return;}//state=document.f1.RESIDINGSTATE.options[RESIDINGSTATE.selectedIndex].value;
			alert(brand);*/
			var url="showmodel.php?bid="+brand;			
			xmlHttp=GetXmlHttpObject(gsubcategory3);
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}
		
		function gsubcategory3()
		{
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete")
			{
				//alert (xmlHttp.responseText);
				document.getElementById("model").innerHTML= xmlHttp.responseText;
			}
		}		