// JavaScript Document
	//========AJAX creator to support browser============================
function getHTTPObject() { 
	  	var xmlhttp; 	
	  	if(window.XMLHttpRequest){ 
			xmlhttp = new XMLHttpRequest(); 
	  	} 
	  	else if (window.ActiveXObject){ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			if (!xmlhttp){ 
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
			}     
		}
  		return xmlhttp; 
	}
	
	var http = getHTTPObject();

//=========End AJAX creator to support browser===========================

//=================================== District ==========================
function handleCountryHttpResponse() {	
	
	if (http.readyState == 4) { 
		if(http.status == 200) { 	
			var results=http.responseText;
			document.getElementById("divDistrict").innerHTML = results;
		//	document.getElementById("divLeftLoading").innerHTML = "";
		
		} 
	} 
} 

function getDistrict(dataSource,divID,myId,myType){
	//========GET or POSt=====
	//document.getElementById("divLeftLoading").innerHTML = "<img src='Loading.gif' border='0'/>";
	var contid = document.getElementById("cboProvince").value;
	var country = dataSource+"?cmd=getDistrict&contid=" + contid + "&id=" + myId + "&type=" + myType;
	http.open("GET",country,true);
	//=========End GET or POSt ==
	http.onreadystatechange = handleCountryHttpResponse;
	http.send(null);
	
	
}
//================================== End District ========================

//================================== Commune =============================
function handleCommuneHttpResponse() {	
	
	if (http.readyState == 4) { 
		if(http.status == 200) { 	
			var results=http.responseText;			
			document.getElementById("divCommune").innerHTML = results;
			document.getElementById("divLeftLoading").innerHTML = "";
		
		} 
	} 
} 

function getCommune(dataSource,divID,myId,myType){
	//document.getElementById("divLeftLoading").innerHTML = "<img src='Loading.gif' border='0'/>";
	//========GET or POSt=====
	var contid = document.getElementById("cboDistrict").value;
	var country = dataSource+"?cmd=getCommune&contid=" + contid + "&id=" + myId + "&type=" + myType;
	http.open("GET",country,true);
	//=========End GET or POSt ==
	http.onreadystatechange = handleCommuneHttpResponse;
	http.send(null);
	
}
//============================= End Commune ==============================

// ============================ Village ==================================
function handleVillageHttpResponse() {	
	
	if (http.readyState == 4) { 
		if(http.status == 200) { 	
			var results=http.responseText;			
			document.getElementById("divVillage").innerHTML = results;
			//document.getElementById("divLeftLoading").innerHTML = "";
		
		} 
	} 
} 

function getVillage(dataSource,divID,myId,myType){
	//========GET or POSt=====
	//document.getElementById("divLeftLoading").innerHTML = "<img src='Loading.gif' border='0'/>";
	var contid = document.getElementById("cboVillage").value;
	var country = dataSource+"?cmd=getVillage&contid=" + contid + "&id=" + myId + "&type=" + myType;
	http.open("GET",country,true);
	//=========End GET or POSt ==
	http.onreadystatechange = handleVillageHttpResponse;
	http.send(null);
}
//============================== End Village ==============================

// ============================ Village ==================================
function handleDateHttpResponse() {	
	
	if (http.readyState == 4) { 
		if(http.status == 200) { 	
			var results=http.responseText;			
			document.getElementById("divDate").innerHTML = results;	
		} 
	} 
} 

function getExpDate(dataSource,val,myExpDate){
	//========GET or POSt=====
	var ExpDate = dataSource+"?val=" + val + "&exp=" + myExpDate;
	http.open("GET",ExpDate,true);
	//=========End GET or POSt ==
	http.onreadystatechange = handleDateHttpResponse;
	http.send(null);
}

