var http;// = getHTTPObject();
var gmode;
var sel_val;
var GCallModelFun;
var GiModelId;
var Gcondition;
var GiVehicleTypeId;
function handleHttpResponse_make() 
{ 
	if (http.readyState == 4) 
	{	
     	isWorking = false;
    	if (http.responseText.indexOf('invalid') == -1) 
		{
			//alert(http.responseText);
		  	var xmlDocument = http.responseXML; 
			var no = xmlDocument.getElementsByTagName('tot').item(0).firstChild.data;
			//var sel_val = xmlDocument.getElementsByTagName('sel_val').item(0).firstChild.data;
			var Prod_Obj;
			//alert(gmode);
			
			if(gmode == "AdvSearch")
				Prod_Obj=document.getElementById("AdviMakeId");
			else if(gmode == "NewCars")
				Prod_Obj=document.getElementById("NewiMakeId");
			else if(gmode == "SearchRes")
				Prod_Obj=document.getElementById("SearchResiMakeId");
			else
				Prod_Obj=document.getElementById("iMakeId");
			if(document.getElementById("iModelId"))
			{
				document.getElementById("iModelId").length=1;
			}
			Prod_Obj.length = 1;
			if(parseInt(no)>0)
			{			
				Prod_Obj.length=parseInt(no)+1;
				for(j=0,i=1;i<Prod_Obj.length;i++,j++)
				{
		   			var iPId = xmlDocument.getElementsByTagName('id').item(j).firstChild.data;
	   		   		var PName =xmlDocument.getElementsByTagName('text').item(j).firstChild.data;
					var SelVal = (sel_val == iPId)? true : false ;
	   				Prod_Obj[i].value	= iPId;
	   				Prod_Obj[i].text 	= PName;
					Prod_Obj[i].selected=SelVal;
   					isWorking = false;
  				}
    		}
			if(GCallModelFun && GCallModelFun == 'Yes')
			{
				getmodel(sel_val,GiModelId,'SearchRes','',Gcondition);
				setTimeout("getSearchRes(1)", 3000);
			}
		}
  	}
}
function getmake(altval,selval,mode,CallModelFun,iModelId,condition,Searchmode) 
{
	GiVehicleTypeId=altval;
	sel_val=selval;
	GCallModelFun = CallModelFun;
	gmode = mode;
	GiModelId = iModelId;
	Gcondition=condition;
	var url = dealersite_url+"getmake.php?iVehicleTypeId=";
	var isWorking = false;
	if (!isWorking)
	{
		isWorking = true;
		url += altval;
		url += "&iCategoryId="+selval;
		if(condition)
			url += "&vCondition="+condition;
		if(Searchmode!='')
			url += "&searchMode="+Searchmode;
		
		//alert(url)
		if (window.XMLHttpRequest)
	  	{
	  		http=new XMLHttpRequest()
	  		http.open("GET",url, true);
	  		http.onreadystatechange=handleHttpResponse_make
		  	http.send(null)
	  	}
		// code for IE
		else if (window.ActiveXObject)
	  	{
	  		http=new ActiveXObject("Microsoft.XMLHTTP")
	    	if (http)
	    	{
	    		http.open("GET",url, true);
	    		http.onreadystatechange=handleHttpResponse_make
	    		http.send()
	    	}
	  	}
  	}
}

