// <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
// JavaScript Document
function activeProvince() {
	var id_province = document.getElementById("id_province").value;
	if(id_province != 0) {
		postDataReturnXML("index/php/posPorvince.php", "id_province=" + id_province, moveProvince);
		create_sel_amphur();
	}
}

//
function moveProvince(dataXML) {
	var nodeLat = dataXML.getElementsByTagName("lat");
	var nodeLng = dataXML.getElementsByTagName("lng");
	var positionLat = nodeLat[0].firstChild.nodeValue;
	var positionLng = nodeLng[0].firstChild.nodeValue;
	
	// ยกเลิกการระบุพื้นที่การค้นหา
	default_select_bounds();
	
	// สร้างแผนที่
	buildMap(positionLat, positionLng, 14);
}

//
function create_sel_amphur() {
	var id_province = document.getElementById("id_province").value; // alert(id_province);
	postDataReturnText("index/php/createAmphur.php", "id_province=" + id_province, createSelAmphur);
}

//
function createSelAmphur(data) { 
	var selAmphur = document.getElementById("selAmphur");
	selAmphur.innerHTML = data;
}

//
function moveAmphur(dataXML) {
	var nodeLat = dataXML.getElementsByTagName("lat");
	var nodeLng = dataXML.getElementsByTagName("lng");
	var positionLat = nodeLat[0].firstChild.nodeValue;
	var positionLng = nodeLng[0].firstChild.nodeValue;
	
	// ยกเลิกการระบุพื้นที่การค้นหา
	default_select_bounds();
	
	// สร้างแผนที่
	buildMap(positionLat, positionLng, 14);
}

//
function activeAmphur() {
	var id_amphur = document.getElementById("id_amphur").value;
	if(id_amphur != 0) {
		postDataReturnXML("index/php/posAmphur.php", "id_amphur=" + id_amphur, moveAmphur);
	}
}