function searchdata(url,div) {
					/*var results = $(frmsearch).serialize().replace(/&/g, ',');
					results = decodeURI(results);
					//prompt("aa",results);
					
				  if(results.indexOf(",")>0){
					var tempcat="";
					var poscat="";
					var mytool_array=results.split(",");
                     for (i=0;i<mytool_array.length;i++){
						     var acat= mytool_array[i];
							 alert(acat);							
					     if(acat.indexOf("ategory")>0){
							 var cat_arr=acat.split("=");
							 alert(cat_arr[0]+"---"+cat_arr[1]);
							 if(cat_arr[1] != ""){
						 	 tempcat+=cat_arr[1]+',';
							 }
						 }
						 if(acat.indexOf("osition")>0){
							 var pos_arr=acat.split("=");
							 alert(pos_arr[0]+"---"+pos_arr[1]);
							 if(pos_arr[1] != ""){
						 	 poscat+=pos_arr[1]+',';
							 }
						 }
					 }  
						alert(tempcat + "-----" + poscat); 
				   }*/
	    var byall,byposition,bycompany;
	    var str=Math.random();
		var keyword = document.getElementById("keyword").value;
		if (document.getElementById("byall").checked) { byall="Y"; } else { byall="N"; }
		if (document.getElementById("byposition").checked) { byposition="Y"; } else { byposition="N"; }
		if (document.getElementById("bycompany").checked) { bycompany="Y"; } else { bycompany="N"; }	
		var category = document.getElementById("category").value ;
		var subcat = document.getElementById("subcat").value ;
		var province = document.getElementById("province").value;
		var position = document.getElementById("position").value;	
		var department = document.getElementById("department").value;
		var req;
			if (window.XMLHttpRequest)
				req=new XMLHttpRequest();
			else if (window.ActiveXObject)
				req=new ActiveXObject("Microsoft.XMLHTTP");
			else{
				alert("Browser not support");
				return false;
			}
		if(url.indexOf("?")>0){url+="&pop="+str;}else{url+="?pop="+str;} 
		url+="&keyword="+keyword;
		url+="&byall="+byall;
		url+="&byposition="+byposition;
		url+="&bycompany="+bycompany;
		url+="&category="+category;
		url+="&province="+province;
		url+="&position="+position;
		url+="&department="+department;
		url+="&subcat="+subcat;
		//alert(url);
        req.onreadystatechange = function () { 
           if (req.readyState==4 ) { 
		        // alert(req.responseText);
                document.getElementById(div).innerHTML= req.responseText ; 
            }else{
			   	document.getElementById(div).innerHTML= "<img src='images/load.gif' width='170' height='60' />"
			}
          } 
        req.open("GET", url, true); 
        req.send(null); 
    } 

function chksearchby(){
			if(document.getElementById("byall").checked==true){
				document.getElementById("byposition").checked=false;
				document.getElementById("bycompany").checked=false;
			}
}

function chksearchbyall(){
	if(document.getElementById("byposition").checked==true || document.getElementById("bycompany").checked==true){
		  document.getElementById("byall").checked=false;
	}
}

function searchlocation(location,name){
	document.getElementById("location").value= location;
	document.getElementById("cat").value= "";
	document.getElementById("pos").value= "";
	document.getElementById("subcat").value= "";
	document.getElementById("value").value= name;
	
	//document.searchpopup.cat.value = category;
	//document.searchpopup.pos.value = '';
	//document.searchpopup.subcat.value = '';
	document.searchpopup.submit();
}

function searchtype(category,name){
	document.getElementById("cat").value= category;
	document.getElementById("pos").value= "";
	document.getElementById("subcat").value= "";
	document.getElementById("location").value= "";
	document.getElementById("value").value= name;
	//document.searchpopup.cat.value = category;
	//document.searchpopup.pos.value = '';
	//document.searchpopup.subcat.value = '';
	document.searchpopup.submit();
}

function searchtypical(url,div,name,value){
	document.getElementById("category").value="";
	document.getElementById("position").value="";
	document.getElementById("subcat").value="";
	document.getElementById("department").value="";
	document.getElementById("province").value="";
	if(name=="category"){
		document.getElementById("category").value = value;
		Loadtextbox('search/loadboxshow.php?cat='+value,'Textshow');
	}
	if(name=="position"){
		document.getElementById("position").value = value;
	 //   Loadtextbox('search/loadboxshow.php?pos='+value,'Textshow');
	}
	if(name=="department"){
		document.getElementById("department").value = value;
	    Loadtextbox('search/loadboxshow.php?dep='+value,'Textshow');
	}
	if(name=="subcat"){
		document.getElementById("subcat").value = value;
		Loadtextbox('search/loadboxshow.php?subcat='+value,'Textshow');
	}
	if(name=="province"){
		document.getElementById("province").value = value;
		Loadtextbox('search/loadboxshow.php?province='+value,'Textshow');
	}
	
	//document.searchpopup.cat.value = category;
	//document.searchpopup.pos.value = '';
	//document.searchpopup.subcat.value = '';
	searchdata(url,div);
}

function searchposition(position,name){
	document.getElementById("pos").value= position;
    document.getElementById("cat").value= "";
	document.getElementById("subcat").value= "";
	document.getElementById("location").value= "";
	document.getElementById("value").value= name;
	//document.searchpopup.pos.value = position;
	//document.searchpopup.cat.value = '';
    //document.searchpopup.subcat.value = '';
	document.searchpopup.submit();
}

function searchposition1(position){
	document.getElementById("position").value= position;
    document.getElementById("category").value= "";
	document.getElementById("subcat").value= "";
	//document.searchpopup.pos.value = position;
	//document.searchpopup.cat.value = '';
    //document.searchpopup.subcat.value = '';
	document.searchpopup.submit();
}

function searchsubcat(subcat,name){
	document.getElementById("subcat").value= subcat;
	document.getElementById("cat").value= "";
	document.getElementById("pos").value= "";
	document.getElementById("location").value= "";
	document.getElementById("value").value= name;
    //document.searchpopup.subcat.value = subcat;
	//document.searchpopup.pos.value ='';
	//document.searchpopup.cat.value = '';
	document.searchpopup.submit();
}

function searchsubcat1(subcat){
	document.getElementById("subcat").value= subcat;
	document.getElementById("category").value= "";
	document.getElementById("position").value= "";
    //document.searchpopup.subcat.value = subcat;
	//document.searchpopup.pos.value ='';
	//document.searchpopup.cat.value = '';
	document.searchpopup.submit();
}

function searchsubposition(position){
	document.frmsearch.position.value = position;
	searchdata('search/searchdata.php','serchresult');
	searchdata('search/searchhotjob.php','hotjobresult');
}

function searchsubcategory(subcat){
	document.frmsearch.subcat.value = subcat;
	searchdata('search/searchdata.php','serchresult');
}

function confirmApply(idjob,idcompany) {
	if (confirm("ยืนยันการสมัครงาน")) {
        window.open('popup/sendresume.php?jid='+idjob+'&cid='+idcompany, 'pr', 'left=20,top=20,width=500,height=250,toolbar=0,resizable=yes, scrollbars=0, status=0, menubar=0, location=0');
		// window.location.href = "popup/resumepreview.php";
    }
}

function confirmApplyjob(idjob,idcompany) {
	if (confirm("ยืนยันการสมัครงาน")) {
        window.open('popup/sendresume.php?jid='+idjob+'&cid='+idcompany, 'pr', 'left=20,top=20,width=500,height=250,toolbar=0,resizable=yes, scrollbars=0, status=0, menubar=0, location=0');
		// window.location.href = "popup/resumepreview.php";
    }
}

function Loadpos(url,div) { 
	    var curdate  = new Date();
        var expdate = curdate.getTime();
	    var department = document.getElementById("department").value ;
		var lang = document.getElementById("lang").value ;
		var obj;
			if (window.XMLHttpRequest)
				obj=new XMLHttpRequest();
			else if (window.ActiveXObject)
				obj=new ActiveXObject("Microsoft.XMLHTTP");
			else{
				alert("Browser not support");
				return false;
			}
		url+="?id="+department+"&gtime="+expdate+"&lang="+lang;
        obj.onreadystatechange = function () { 
           if (obj.readyState==4 ) { 
		        //alert(obj.responseText);
                document.getElementById(div).innerHTML= obj.responseText ; 
            }else{
			    document.getElementById(div).innerHTML= " <img src='images/wait.gif' />";	
			}
          } 
		//alert(url);
        obj.open("GET", url, true); 
        obj.send(null); 
    } 
	
function Loadsub(url,div) { 
	    var curdate  = new Date();
        var expdate = curdate.getTime();
	    var category = document.getElementById("category").value ;
		var lang = document.getElementById("lang").value ;
		//alert(lang);
		var obj;
			if (window.XMLHttpRequest)
				obj=new XMLHttpRequest();
			else if (window.ActiveXObject)
				obj=new ActiveXObject("Microsoft.XMLHTTP");
			else{
				alert("Browser not support");
				return false;
			}
		url+="?id="+category+"&gtime="+expdate+"&lang="+lang;
        obj.onreadystatechange = function () { 
           if (obj.readyState==4 ) { 
		        //alert(obj.responseText);
                document.getElementById(div).innerHTML= obj.responseText ; 
            }else{
			    document.getElementById(div).innerHTML= " <img src='images/wait.gif' />";	
			}
          } 
		//alert(url);
        obj.open("GET", url, true); 
        obj.send(null); 
    }
	
function Loadtextbox(url,div) { 
	    var curdate  = new Date();
        var expdate = curdate.getTime();
		var obj;
			if (window.XMLHttpRequest)
				obj=new XMLHttpRequest();
			else if (window.ActiveXObject)
				obj=new ActiveXObject("Microsoft.XMLHTTP");
			else{
				alert("Browser not support");
				return false;
			}
		url+="&gtime="+expdate;
        obj.onreadystatechange = function () { 
           if (obj.readyState==4 ) { 
		        //alert(obj.responseText);
                document.getElementById(div).innerHTML= obj.responseText ; 
            }else{
			    document.getElementById(div).innerHTML= " <img src='images/wait.gif' />";	
			}
          } 
		//alert(url);
        obj.open("GET", url, true); 
        obj.send(null); 
    } 	