 function getXMLHTTP() 
{ 
	//fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
    
    function getmake(type,refine) 
	{
			
		var strURL="findmake.php?type="+type;
		var req = getXMLHTTP();
	/*	if(type=='bike' || type=='commercial')
		{      
	           
				document.getElementById("makediv").style.width = "175px";
				document.getElementById("makediv").style.margin = "5px 0";
			
		}
		if(type=='car')
		{      
	           
				document.getElementById("makediv").style.width = "175px";
				document.getElementById("makediv").style.margin = "0px 0";
			
		}
		//alert(document.getElementById("makediv").style.margin);*/
	
		if(refine=='1')
		{
						document.getElementById("used_vehicle1").style.visibility = "visible";
						document.getElementById("used_vehicle1").style.position = "";
						document.getElementById("showsearch").style.visibility = "hidden";
						document.getElementById("showsearch").style.position = "absolute";
						document.getElementById("hidesearch").style.visibility = "visible";
						document.getElementById("hidesearch").style.position = "absolute";
						document.getElementById("border").style.visibility = "hidden";
						document.getElementById("border").style.position = "absolute";
		
		}
		if (req) 
		{
			req.open("GET", strURL);
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200)
					 {						
						document.getElementById('makediv').innerHTML=req.responseText;	
						
					}
					 else
					 {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				else if (req.readyState < 4)
				{
					document.getElementById('make_id').innerHTML="<option value=load selected>Loading..</option>";
				}
				
			}			
			req.send(null);
		}		
	}
     
    function getmake_new(type,refine) 
	{
		var strURL="findmake_new.php?type="+type;
		var req = getXMLHTTP();
		
		if(refine=='1')
		{           
						document.getElementById("new_vehicle1").style.visibility = "visible";
						document.getElementById("new_vehicle1").style.position = "";
						document.getElementById("showsearch").style.visibility = "hidden";
						document.getElementById("showsearch").style.position = "absolute";
						document.getElementById("hidesearch").style.visibility = "visible";
						document.getElementById("hidesearch").style.position = "absolute";
						document.getElementById("border").style.visibility = "hidden";
						document.getElementById("border").style.position = "absolute";
		
		
		}
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200)
					 {						
						document.getElementById('makediv_new').innerHTML=req.responseText;						
					}
					 else
					 {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				else if (req.readyState < 4)
				{
					document.getElementById('make_id_new').innerHTML="<option value=load selected>Loading..</option>";
				}
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
     
	function getmodel(make_id) 
	{ 	
			
		var strURL="findmodel.php?make_id="+make_id;
		var req = getXMLHTTP();
		
	/*	if(type=='bike')
		{      
	           
				document.getElementById("modeldiv").style.width = "175px";
				document.getElementById("modeldiv").style.margin = "10px 0";
			
		}
		if(type=='car' || type=='commercial')
		{      
	           
				document.getElementById("modeldiv").style.width = "175px";
				document.getElementById("modeldiv").style.margin = "0px";
			
		}*/

		if (req) 
		{
			req.open("GET", strURL);
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200)
					 {						
						document.getElementById('modeldiv').innerHTML=req.responseText;		
					 
						
					}
					 else
					 {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				else if (req.readyState < 4)
				{
					document.getElementById('model_id').innerHTML="<option value=load selected>Loading..</option>";
				}
			}			
			req.send(null);
		}		
	}
	
	function getmodel_new(make_id) 
	{
			
		var strURL="findmodel_new.php?make_id="+make_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200)
					 {						
						document.getElementById('modeldiv_new').innerHTML=req.responseText;						
						
					}
					 else
					 {
						
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				else if (req.readyState < 4)
				{
					document.getElementById('model_id_new').innerHTML="<option value=load selected>Loading..</option>";
				}
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
	
	
	function getvariant(model_id)
	 {		
		var strURL="findvariant.php?model_id="+model_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.open("GET", strURL);
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('variantdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.send(null);
		
		
		}
			
	}
	
	
	//this one is used in registration form
	//this one is used in sell_vehicles form.. also we can use for other places too
	
	function getState(country_id)
	 {		
		
		var strURL="findstate.php?country_id="+country_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.open("GET", strURL);
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.send(null);
			
			
		}
				
	}
	
	
	
	
	function getCity(state_id)
	 {		
		 
		var strURL="findcity.php?state_id="+state_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv').innerHTML=req.responseText;	
						
						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
				else if (req.readyState < 4)
				{
					 
					document.getElementById("reg_city").innerHTML="<option value=load selected>Loading..</option>";
					}
			}	
		
			req.open("GET", strURL, true);
			req.send(null);
			
			
		}
				
	}
	 
	//dealer registration  starts: registration form
	
	
		function getStated(country_id)
	 {		
		
		 
		var strURL="findstated.php?country_id="+country_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statedivd').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
			
			
		}
				
	}
	
	
	
	
	function getCityd(state_id)
	 {		
		 
		 	 	 
		var strURL="findcity.php?state_id="+state_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydivd').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
			
			
		}
				
	}
	
	//dealer registration  ends
	function getCity_new(state_id)
	 {		
		 
		 	 	 
		var strURL="findcity_new.php?state_id="+state_id;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('citydiv_new').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
				else if (req.readyState < 4)
				{
					document.getElementById('city_new').innerHTML="<option value=load selected>Loading..</option>";
				}
			}			
			req.open("GET", strURL, true);
			req.send(null); 
			
		}
				
	}
	
	
	
	
	
	
	