// JavaScript Document
//XMLhttp variable will hold the XMLHttpRequest object
      //XMLhttp variable will hold the XMLHttpRequest object
      var xmlhttp = false;
              
      // If the user is using Mozilla/Firefox/Safari/etc
      if (window.XMLHttpRequest) {
        //Intiate the object
        xmlhttp = new XMLHttpRequest();
        //Set the mime type
        xmlhttp.overrideMimeType('text/xml');
      }
      // If the user is using IE
      else if (window.ActiveXObject) {
        //Intiate the object
        //xmlhttp = new ActiveXObject("MSXML2.serverXMLHTTP.3.0");
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }



function emptySub(obj){
var subLen = obj.length;
for (var i = 0; i < subLen; i++) {
obj.options[0]=null;
}
}
//Get Ajax XML
	function getKota(id){
		emptySub(document.frmRegister.kotaktp);
		//document.FormName.subcategory.options[0] = new Option("Loading...");	
		//if(document.frmRegister.kotaktp<>""){
		//			document.frmRegister.kotaktp. = "";
		//	}
		if (xmlhttp){
			xmlhttp.open('GET', 'manage/queries/qrygetKota.asp?idprop='+id, true);
		
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					
					countelm = xmlhttp.responseXML.getElementsByTagName("item").length;
					//alert("Jumlah element" + countelm);
					/*
					alert("jumlah element " + countelm);
					idlok = xmlhttp.responseXML.getElementsByTagName("idl")[i].childNodes[2].nodeValue;
				nlok = xmlhttp.responseXML.getElementsByTagName("nl")[1].childNodes[0].nodeValue;
					alert("nama lokasi " + nlok);
					*/
							//document.frmRegister.kotaktp.options[i].value = "";
					
					if (countelm > 0){
						for (i=0;i<countelm;i++){
							idkota = xmlhttp.responseXML.getElementsByTagName("id_kota")[i].childNodes[0].nodeValue;
							namakota = xmlhttp.responseXML.getElementsByTagName("nama_kota")[i].childNodes[0].nodeValue;
							//combo kota
							document.frmRegister.kotaktp.options[i] = new Option(namakota);
							document.frmRegister.kotaktp.options[i].value = (idkota);

						}
					}else{
						document.FormName.subcategory.options[0].text = "Empty List...";
					}
					
					
				}//else {}
				
    		};//end function
    		xmlhttp.send(null);
		}
	}
//Get Ajax XML kota surat
function emptySub2(obj){
var subLen = obj.length;
for (var i = 0; i < subLen; i++) {
obj.options[0]=null;
}
}
	function getKotasrt(id){
		emptySub(document.frmRegister.kotasrt);
		//document.FormName.subcategory.options[0] = new Option("Loading...");
		if (xmlhttp){
			xmlhttp.open('GET', 'manage/queries/qrygetKota.asp?idprop='+id, true);
		
			xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					
					countelm = xmlhttp.responseXML.getElementsByTagName("item").length;
					//alert("Jumlah element" + countelm);
					/*
					alert("jumlah element " + countelm);
					idlok = xmlhttp.responseXML.getElementsByTagName("idl")[i].childNodes[2].nodeValue;
				nlok = xmlhttp.responseXML.getElementsByTagName("nl")[1].childNodes[0].nodeValue;
					alert("nama lokasi " + nlok);
					*/
					
					if (countelm > 0){
						for (i=0;i<countelm;i++){

							idkotasrt = xmlhttp.responseXML.getElementsByTagName("id_kota")[i].childNodes[0].nodeValue;
							namakotasrt = xmlhttp.responseXML.getElementsByTagName("nama_kota")[i].childNodes[0].nodeValue;
							//combo kota
							document.frmRegister.kotasrt.options[i] = new Option(namakotasrt);
							document.frmRegister.kotasrt.options[i].value = (idkotasrt);

						}
					}else{
						document.FormName.subcategory.options[0].text = "Empty List...";
					}
					
					
				}//else {}
				
    		};//end function
    		xmlhttp.send(null);
		}
	}
