
var totalnewjobcount = 0;
var currentnewjobcount = 0;


function hideNewJobCountTable() {
	document.getElementById("newJobCountTableWrap").style.position = "absolute"; 
	document.getElementById("newJobCountTableWrap").style.visibility = "hidden";
	document.getElementById("newJobCountTableWrap").style.top = "-800px";
}

function setTotalNewJobCount(count) {
	totalnewjobcount = count;
}

function runNextNewJobCount() {
	if(totalnewjobcount == 0) {
		clearTimeout();
		return;
	} 
	
	if(totalnewjobcount == currentnewjobcount) {
		clearTimeout();
		return;
	}
	
	var serverparams = document.getElementById("newjobcountparam" + currentnewjobcount).innerHTML;
	
	var serverScript = "/recruitnet/get_new_job_count.jsp?" + serverparams;
	// alert(serverScript);
//	var serverScript = "/recruitnet/get_new_job_count.jsp?query=java&location=&regionCode=all&locale=en&date=20061120";
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", serverScript , true);
	xmlHttp.send(null);
	
	return;	
}


function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("newjobcount" + currentnewjobcount).innerHTML = xmlHttp.responseText;
		currentnewjobcount = currentnewjobcount + 1;
		setTimeout('runNextNewJobCount();',250);
	} 
} 

function GetXmlHttpObject(handler) { 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0) {
		return; 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0) { 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP"
		} 
		try { 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 