// JavaScript Document
var xmlHttp

function showModel(str){ 	
	if (str.length > 0){				
		var url="includes/select.php";
		var post_data = "q=" + str;
		xmlHttp=GetXmlHttpObject(stateChangedModel);				
		xmlHttp.open("POST", url , true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		xmlHttp.send(post_data);
	} 
	else{
		document.getElementById("txtModel").innerHTML = "<select style=\"WIDTH: 150px\" name=select2><option value=0 selected>- S&#7843;n ph&#7849;m -</option></select>";
	} 
}
function showDistrict(str){ 	
	if (str.length > 0){				
		var url="includes/select_district.php";
		var post_data = "q=" + str;
		xmlHttp=GetXmlHttpObject(stateChangedDistrict);				
		xmlHttp.open("POST", url , true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		xmlHttp.send(post_data);
	} 
	else{
		document.getElementById("txtDistrict").innerHTML = "<select style=\"WIDTH: 160px\" name=district_id><option value=NO selected>- Ch&#7885;n qu&#7853;n/huy&#7879;n -</option></select>&nbsp;*";
	} 
}
function showArea(str){ 	
	if (str.length > 0){				
		var url="includes/select_area.php";
		var post_data = "q=" + str;
		xmlHttp=GetXmlHttpObject(stateChangedArea);				
		xmlHttp.open("POST", url , true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		xmlHttp.send(post_data);
	} 
	else{
		document.getElementById("txtArea").innerHTML = "<select style=\"WIDTH: 160px\" name=province_id><option value=NO selected>- Ch&#7885;n t&#7881;nh\th&agrave;nh ph&#7889; -</option></select>";
	} 
}

function selectModel(str){ 	
	if (str.length > 0){				
		var url="includes/select_model.php";
		var post_data = "q=" + str;
		xmlHttp=GetXmlHttpObject(stateChangedModel2);				
		xmlHttp.open("POST", url , true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		xmlHttp.send(post_data);
	} 
	else{
		document.getElementById("slModel").innerHTML = "&nbsp;";
	} 
}
function stateChangedModel2(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("slModel").innerHTML=xmlHttp.responseText 		
	} 
}

function stateChangedModel(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("txtModel").innerHTML=xmlHttp.responseText 		
	} 
}

function stateChangedArea(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("txtArea").innerHTML=xmlHttp.responseText 		
	} 
}
function stateChangedDistrict(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		document.getElementById("txtDistrict").innerHTML=xmlHttp.responseText 		
	} 
}



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
	}
} 