document.write("<script type=\"text/javascript\" src=\"js/funcs.js\"></script>");
document.write("<script type=\"text/javascript\" src=\"js/ajax.js\"></script>");
document.write("<script type=\"text/javascript\" src=\"js/json.js\"></script>");
var dontInclude = new Array();
dontInclude["candidate"] = "";
dontInclude["client"] = "";
dontInclude["hotJob"] = "";
var delay = 30*1000;
	function getTestimonial2()
	{
		setInterval('getTestimonial("candidate")',delay);
		//setInterval('getTestimonial("client")',delay);
	}

	function getTestimonial(type)
	{
		//showLoading();
		 var ajax = new Ajax(showTestimonial, failed);
		 type = "candidate";
		ajax.post('ajax/getTestimonial.php', "type="+type+"&dontInclude="+dontInclude[type]);
		var ajax = new Ajax(showTestimonial, failed);
		type = "client";
		ajax.post('ajax/getTestimonial.php', "type="+type+"&dontInclude="+dontInclude[type]);
	}
	function getHotJobs2()
	{
		setInterval('getHotJobs()',delay/2);
		//setInterval('getTestimonial("client")',delay);
	}
	function getHotJobs()
	{
		//showLoading();
		 var ajax = new Ajax(showHotJobs, failed);
		 type = "hotJob";
		 ajax.post('ajax/getHotJobs.php', "dontInclude="+dontInclude[type]);
		
	}
	function showHotJobs(ajax,result)
	{
		//alert('here');
		result = JSON.parse(result);
		var showArea = new getObj("hotJobs");
		
			
		if(dontInclude[type].length=="")
		{
			//dontInclude[type]=result["pId"].join(",");
		}
		else
		{
			//dontInclude[type]+=","+result["pId"].join(",");
		}
		
	//	alert(showArea.obj.innerHTML);
		var jobs = result["jobs"];
		var jobHTML;
		var job;
		var html = "";
		for(var i=0;i<jobs.length;i++)
		{
			
			job = jobs[i];
			
			var description = ((job["description"] && job["description"].length>0)?job["description"]:" ");
			
			html+='<p class="highlight"><a href="positionDoc.php?pId='+job["pId"]+'&name='+job["title"]+": "+description+'">'+job["title"]+": "+description+'</a> - Posted on '+job["postDate"]+'&nbsp;&nbsp;<a href="hotJobs.php?action=recommend&pId='+job["pId"]+'">Consider me for this job.</a></p>';
				
		}	
		
		showArea.obj.innerHTML = html;
		
	
	}
	function showTestimonial(ajax,result)
	{
		//alert('here');
		result = JSON.parse(result);
		
		var type = result['type'];
		var showArea = new getObj(type+"-testimonial");
		
		
		
		if(dontInclude[type].length=="")
		{
			dontInclude[type]+=result["testimonialId"];
		}
		else
		{
			dontInclude[type]+=","+result["testimonialId"];
		}
		
		
		
		var html = "<h3 >"+result["name"]+", "+result["company"]+": "+result["position"]+"</h3>";
		
		
		
		
		showArea.obj.innerHTML = html;
		
	
	}
	var intervalSet = false;
	var intervalSet2 = false;
	var intervalIds = new Array();
	intervalIds["candidate"] = new Array();
	intervalIds["client"]= new Array();
	function initialize()
	{
		initializeHotJobs();
		initializeTestimonial();
		hideMenu("about");
		hideMenu("candidates");
	}
	function initializeHotJobs()
	{
		if(!intervalSet2)
		{
			setTimeout('getHotJobs2()',1000);
			//intervalIds["candidate"].push(setInterval('getTestimonial("candidate")',5000));
			//intervalIds["client"].push(setInterval('getTestimonial("client")',5000));
			intervalSet2 = true;
		}
	}
	function initializeTestimonial()
	{
		if(!intervalSet)
		{
			setTimeout('getTestimonial2("candidate")',1000);
			//intervalIds["candidate"].push(setInterval('getTestimonial("candidate")',5000));
			//intervalIds["client"].push(setInterval('getTestimonial("client")',5000));
			intervalSet = true;
		}
	}
	function failed()
	{
		//hideLoading();
		alert('error loading');
	}
	function hideLoading()
					  {
					  
					  	var a = new getObj("loading"); a.style.visibility = "hidden";
					  }
					  function showLoading()
					  {
					  		var a = new getObj("loading"); a.style.visibility = "visible";
					  }
	window.onLoad = initialize();