var afwezig1=new Image(41,41);
afwezig1.src="/local/images/afwezig.png"; 
afwezig1.style.display="none";
afwezig1.setAttribute("id","status10");

var aanwezig1=new Image(41,41);
aanwezig1.src="/local/images/aanwezig.png"; 
aanwezig1.style.display="none";
aanwezig1.setAttribute("id","status11");

var ingesprek1=new Image(41,41);
ingesprek1.src="/local/images/ingesprek.png"; 
ingesprek1.style.display="none";
ingesprek1.setAttribute("id","status12");

var afwezig2=new Image(41,41);
afwezig2.src="/local/images/afwezig.png"; 
afwezig2.style.display="none";
afwezig2.setAttribute("id","status20");

var aanwezig2=new Image(41,41);
aanwezig2.src="images/aanwezig.png"; 
aanwezig2.style.display="none";
aanwezig2.setAttribute("id","status21");

var ingesprek2=new Image(41,41);
ingesprek2.src="/local/images/ingesprek.png"; 
ingesprek2.style.display="none";
ingesprek2.setAttribute("id","status22");

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


var statusStr2=document.createElement("DIV");
statusStr2.style.color="#FFF";
statusStr2.style.fontWeight="normal";
statusStr2.style.fontSize="13px";
statusStr2.style.lineHeight="20px";
statusStr2.style.position="absolute";
statusStr2.style.height="20px";
statusStr2.style.width="130px";
statusStr2.style.marginTop="49px";
statusStr2.style.marginLeft="50px";


$(document).ready(function() {

  /* more code to run on page load */
  var slogan_wrap=document.getElementById("onlinestatuswrap");
    
  var d=document.createElement("DIV");
  d.setAttribute("id","onlinestatus");
  d.style.position="absolute";
  d.style.marginLeft="0px";
  d.style.marginTop="0px";
  d.style.width="108px";
  d.style.height="41px";


  d.appendChild(statusStr1);
//  d.appendChild(statusStr2);
  
  d.appendChild(afwezig1);
  d.appendChild(aanwezig1);
  d.appendChild(ingesprek1);
  d.appendChild(afwezig2);
  d.appendChild(aanwezig2);
  d.appendChild(ingesprek2);
  
  
  //slogan_wrap.insertBefore(nr,slogan_wrap.childNodes[0]);
  slogan_wrap.appendChild(d);
 // 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()}}


var stat=0;
var timer;
var agentNames=new Array("Monica");
var statusStrs=new Array("Afwezig","Aanwezig","In gesprek");

function getAgentStatus()
	{
	jx.load("/status.json.php",function(data){

	stat1=data.agent[0]['status'];
//	stat2=data.agent[1]['status'];
	
	for(x=0;x<3;x++) {d=document.getElementById("status1"+String(x));if (d) {d.style.display="none";}}
//	for(x=0;x<3;x++) {d=document.getElementById("status2"+String(x));if (d) {d.style.display="none";}}
	
	var d1=document.getElementById("status1"+String(stat1));
//	var d2=document.getElementById("status2"+String(stat2));
	
	if (d1) {d1.style.display="block";statusStr1.innerHTML=statusStrs[stat1];}
//	if (d2) {d2.style.display="block";statusStr2.innerHTML=agentNames[1]+statusStrs[stat2];}
	
		},"jason");
	if (timer) {clearTimeout(timer); }
	timer=setTimeout ("getAgentStatus()", 1000*15);
	}
$(document).ready(function() {getAgentStatus();});	

