// JavaScript Document
var xmlhttpo;
function ajaxcreateo(){
     if (window.ActiveXObject) {
        xmlhttpo = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlhttpo = new XMLHttpRequest();
    }
}
function onlinemessage(){
   ajaxcreateo(); 
    onlineuser=document.getElementById("onlineu").value;
    var url="fun/onlinelisten.php?user="+onlineuser+"&rnd="+Math.random();
   xmlhttpo.onreadystatechange=handlestatechange;
   xmlhttpo.open("GET",url,true);
   xmlhttpo.send(null);
}

function handlestatechange(){
	  if(xmlhttpo.readyState==4){
       if(xmlhttpo.status==200){
		  
	      if(xmlhttpo.responseText!='none'){
			//  alert(xmlhttpo.responseText);
		      xScroll=window.screen.width-300
              yScroll=window.screen.availHeight-300
			  message=document.createElement("div");
			  message.setAttribute("id","messagebox");
			  message.style.cssText="position:absolute;left:"+xScroll+"px;top:"+yScroll+"px;";
			  message.innerHTML="<h2 style='font-size:14px; color:#0000ff; width:100%;float:left'>您有新消息！</h2>"
			  message.innerHTML=message.innerHTML+ xmlhttpo.responseText;
		      document.body.appendChild(message);
			  message.innerHTML=message.innerHTML+ "<a href='onlinechatadmin.php' target='_blank' style='width:100%'>查看信息</a>";
			  }else{
				 if(box=document.getElementById("messagebox")){
					 document.body.removeChild(box)
					 }
				  }
	    }
	   }

	}