var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function removeOptions1(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
	selectbox.remove(i);
	}
	var optn = document.createElement("OPTION");
	optn.text = " -- Pilih Kategori Pengaduan -- ";
	optn.value = "";
	selectbox.options.add(optn);
}

function addOption(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function getKategori(jenis) {
  
  http.abort();
  http.open("GET", "/librari/ajax/ajax_jenis.php?jenis=" + jenis, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
		
		var response = http.responseText;
		var list=document.getElementById("secId");
		removeOptions1(list);
		var subsec=response.split('|');
		for (i=0; i<(subsec.length-1); i++) {
		    var data = subsec[i].split('~~');
		    addOption(list,data[1],data[0]);
		   }
    }
  }
  http.send(null);
}
function trapError() {
	return true; // stop the yellow triangle
}
//window.onerror = trapError;
