var xmlHttp = null;

function requestData(url) {
  	if (window.XMLHttpRequest) {
    	try { 
			xmlHttp = new XMLHttpRequest();
    	} 
		catch(e) { 
			xmlHttp = false; 
		}
  	} 
	else if(window.ActiveXObject) {
    	try { 
			xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
    	} 
		catch(e) {
    		try { 
				xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
    		} 
			catch(e) { 
				xmlHttp = false; 
			}
  		} 	
  	}
  	if(xmlHttp) {
		xmlHttp.open('GET',url,true);
    	xmlHttp.onreadystatechange = function processReqChange() {
			if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
				option_list();
			}
	    }
		xmlHttp.send(null);
    } 
}

function option_list() {
	var i;
	var array1=new Array();
	var array2=new Array();
	array1=xmlHttp.responseText.split(",");
	for(i in array1){
		array2=array1[i].split("|");
		var op="<option value=\""+array2[0]+"\">"+array2[1]+"</option>"
		$("#jobname").append(op);
	}
	$("#jobname")[0].selectedIndex = 0;
}

function changetype() {
	var size=document.getElementById("jobname").options.length;
	if (document.getElementById("jobtype").value == "0"){
		document.getElementById("jobname").options.length=0;
		var op="<option value=\"0\">-------请选择职位名称------</option>"
		$("#jobname").append(op);
	}
	else {
		if (size>0) {
			document.getElementById("jobname").options.length=0;
		}
		requestData("index.php?controller=job&action=getjobname&a="+Math.random()+"&jobtype="+document.getElementById("jobtype").value);
	}
}

function changetype_search() {
	var size=document.getElementById("jobname").options.length;
	if (document.getElementById("jobtype").value == "0"){
		document.getElementById("jobname").options.length=0;
		var op="<option value=\"0\">全部职位名称</option>"
		$("#jobname").append(op);
	}
	else {
		if (size>0) {
			document.getElementById("jobname").options.length=0;
			var op="<option value=\"0\">全部职位名称</option>"
			$("#jobname").append(op);
		}
		requestData("index.php?controller=job&action=getjobname&a="+Math.random()+"&jobtype="+document.getElementById("jobtype").value);
	}
}