function addLoadEvent(func) {var oldonload = window.onload;if (typeof window.onload != 'function') {window.onload = func;} else {window.onload = function() {if (oldonload) {oldonload();}  func();}}}

var afwezig1=new Image(34,34);
afwezig1.src="images/afwezig.png"; 
afwezig1.style.display="none";
afwezig1.style.padding="7px";
afwezig1.style.paddingLeft="10px";
afwezig1.setAttribute("id","status10");

var aanwezig1=new Image(34,34);
aanwezig1.src="images/aanwezig.png"; 
aanwezig1.style.display="none";
aanwezig1.style.padding="7px";
aanwezig1.style.paddingLeft="10px";
aanwezig1.setAttribute("id","status11");

var ingesprek1=new Image(34,34);
ingesprek1.src="images/ingesprek.png"; 
ingesprek1.style.display="none";
ingesprek1.style.padding="7px";
ingesprek1.style.paddingLeft="10px";
ingesprek1.setAttribute("id","status12");

var statusStr1=document.createElement("DIV");
statusStr1.style.color="#FFF";
statusStr1.style.fontWeight="normal";
statusStr1.style.fontSize="10px";
statusStr1.style.lineHeight="20px";
statusStr1.style.position="absolute";
statusStr1.style.height="20px";
statusStr1.style.lineHeight="14px";
statusStr1.style.width="230px";
statusStr1.style.marginTop="9px";
statusStr1.style.marginLeft="50px";


addLoadEvent(function() {
  /* more code to run on page load */
  var slogan_wrap=document.getElementById("headerTD");
  var d=document.createElement("DIV");
  d.setAttribute("id","onlinestatus");
  d.style.position="absolute";
  d.style.marginLeft="750px";
  d.style.marginTop="55px";
  d.style.width="285px";
  d.style.height="42px";
  
  d.appendChild(statusStr1);

  
  d.appendChild(afwezig1);
  d.appendChild(aanwezig1);
  d.appendChild(ingesprek1);
  
  

  
  slogan_wrap.insertBefore(d,slogan_wrap.childNodes[0]);
});

jx={getHTTPObject:function(){var A=false;if(typeof ActiveXObject!="undefined"){try{A=new ActiveXObject("Msxml2.XMLHTTP")}catch(C){try{A=new ActiveXObject("Microsoft.XMLHTTP")}catch(B){A=false}}}else{if(window.XMLHttpRequest){try{A=new XMLHttpRequest()}catch(C){A=false}}}return A},load:function(url,callback,format){var http=this.init();if(!http||!url){return }if(http.overrideMimeType){http.overrideMimeType("text/json")}if(!format){var format="text"}format=format.toLowerCase();var now="uid="+new Date().getTime();url+=(url.indexOf("?")+1)?"&":"?";url+=now;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){if(http.status==200){var result="";if(http.responseText){result=http.responseText}if(format.charAt(0)=="j"){result=result.replace(/[\n\r]/g,"");result=eval("("+result+")")}if(callback){callback(result)}}else{if(error){error(http.status)}}}};http.send(null)},init:function(){return this.getHTTPObject()}}

function error(e){}

var stat1=0;
var timer;
var agentNames=new Array("Tessa");
var statusStrs=new Array(" is momenteel afwezig"," is momenteel aanwezig"," is momenteel in gesprek");

function getAgentStatus()
	{

	jx.load("/status.json.php",function(data){
	
	stat1=data.agent;
	
	for(x=0;x<3;x++) {d=document.getElementById("status1"+String(x));if (d) {d.style.display="none";}}
	
	var d1=document.getElementById("status1"+String(stat1));
	
	if (d1) {d1.style.display="block";statusStr1.innerHTML="<b>"+agentNames[0]+statusStrs[stat1]+"</b><br/><b>0909-123 123 6</b> boxnr. <b>32</b> <span style='font-size:9px;'>(&euro;0,80/p.m.)</span>";}
	
		},"jason");
	if (timer) {clearTimeout(timer); }
	timer=setTimeout ("getAgentStatus()", 1000*15);
	}
	
addLoadEvent(function() {getAgentStatus();});

