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

function showSubCat(url){ 
	xmlHttp1=GetXmlHttpObject()
	if (xmlHttp1==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		
	var catId = document.searchAuto.category.options[document.searchAuto.category.selectedIndex].value;
	
	var url=url+"includes/com/search/getCatData.php?catId="+catId;
	url=url+"&sid="+Math.random();
	xmlHttp1.onreadystatechange=dispSubCat 
	xmlHttp1.open("GET",url,true)
	xmlHttp1.send(null)
}

function dispSubCat(){ 
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){
		document.getElementById("searchModel").style.display = "none";
		document.getElementById("searchMake").style.display = "none";
		document.getElementById("searchSubCat2").style.display = "none";
		document.getElementById("odometer").style.display = "none";
		document.getElementById("searchSubCat").style.display = "block";
		document.getElementById("searchSubCat").innerHTML=xmlHttp1.responseText 
	} 
}

function getMake(url){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		
	var catId = document.searchAuto.categorySub.options[document.searchAuto.categorySub.selectedIndex].value;
	var Stype = document.searchAuto.Stype.value;
	
	var url=url+"includes/com/search/getCatData.php?catId="+catId+"&Stype="+Stype;
	
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=dispMake 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function dispMake(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		var Stype = document.searchAuto.Stype.value;
	
		if(Stype == "A"){
			document.getElementById("searchModel").style.display = "none";
			document.getElementById("searchMake").style.display = "block";
			document.getElementById("searchMake").innerHTML=xmlHttp.responseText 
		}
		if(Stype == "G"){
			document.getElementById("searchSubCat2").style.display = "block";
			document.getElementById("searchSubCat2").innerHTML=xmlHttp.responseText 
		}
	} 
}

function getModel(url){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		
	var makeId = document.searchAuto.make.options[document.searchAuto.make.selectedIndex].value;
	
	var url=url+"includes/com/search/getCatData.php?make="+makeId;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=dispModel 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function dispModel(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("searchModel").style.display = "block";
		document.getElementById("searchModel").innerHTML=xmlHttp.responseText 
	}
}



function getodo(url){
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)	{
		alert ("Browser does not support HTTP Request")
		return
	} 
		
	var odoId = document.searchAuto.make.options[document.searchAuto.make.selectedIndex].value;
	
	var url=url+"includes/com/search/getCatData.php?odo="+odoId;
	url=url+"&sid="+Math.random();
	xmlHttp2.onreadystatechange=dispodo
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)
}

function dispodo(){ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete"){
		document.getElementById("odometer").style.display = "block";
		document.getElementById("odometer").innerHTML=xmlHttp2.responseText
		
	
	}
}


function searchValidate(){
	from_price = document.searchAuto.from_price.value;
	to_price = document.searchAuto.to_price.value;
	if(!isNumeric(from_price)){
		alert("Price Can Have Only Numeric Value!");
		document.searchAuto.from_price.value = "";
		return false;
	}
	
	if(!isNumeric(to_price)){
		alert("Price Can Have Only Numeric Value!");
		document.searchAuto.to_price.value = "";
		return false;
	}


	
	if(isNumeric(from_price) && isNumeric(to_price)){
		return true;
	}
}


function two(url)
{
	getModel(url);
	getodo(url);
	

}

