// JavaScript Document
var xmlHttp; 
createXmlHttp=function createXmlHttp() {

    if (window.XMLHttpRequest) {
       xmlHttp = new XMLHttpRequest();                 
    } else {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
};
getmesg=function getmesg() { 
     sendRequest();
	//window.alert("ok!");
	
};
function init() {
    getmesg();
    setInterval("getmesg()", 10000);//每隔十秒发送一次请求
}
sendRequest=function sendRequest() {
    createXmlHttp();                    
    xmlHttp.onreadystatechange = showInfo;
    xmlHttp.open("post", "../web/ChatAjax.asp", true);
    xmlHttp.send(null);
};
showInfo=function showInfo() {
    if (xmlHttp.readyState == 4) {
        document.getElementById("$mesgs").innerHTML = xmlHttp.responseText;
		getMsg('eMeng');//执行DIV上升
    }
};



window.onresize = resizeDiv;
		window.onerror = function(){}
		//短信提示使用(asilas添加)
		var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
		function getMsg(Divname)
		{
		try{
		divTop = parseInt(document.getElementById(Divname).style.top,10)
		divLeft = parseInt(document.getElementById(Divname).style.left,10)
		divHeight = parseInt(document.getElementById(Divname).offsetHeight,10)
		divWidth = parseInt(document.getElementById(Divname).offsetWidth,10)
		//docWidth = document.screen.clientWidth;
		//docWidth = document.screen.clientHeight;
		docWidth = document.documentElement.clientWidth;
		docHeight = document.documentElement.clientHeight;
		//window.alert(docWidth+","+docHeight);
		//document.write(docWidth+","+docHeight);
		document.getElementById(Divname).style.top = parseInt(document.body.scrollTop,10) + docHeight;// divHeight
		document.getElementById(Divname).style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
		document.getElementById(Divname).style.visibility="visible"
		objTimer = window.setInterval("moveDiv('"+Divname+"')",10)
		}
		catch(e){}
		} 
		function resizeDiv(Divname)
		{
		i+=1
		//if(i>300) closeDiv(Divname) //客户想不用自动消失由用户来自己关闭所以屏蔽这句
		try{
		divHeight = parseInt(document.getElementById(Divname).offsetHeight,10)
		divWidth = parseInt(document.getElementById(Divname).offsetWidth,10)
		docWidth = document.window.clientWidth;
		docHeight = document.window.clientHeight;
		document.getElementById(Divname).style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)
		document.getElementById(Divname).style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
		}
		catch(e){}
		}
		
		function moveDiv(Divname)
		{
		try
		{
		if(parseInt(document.getElementById(Divname).style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
		{
		window.clearInterval(objTimer)
		objTimer = window.setInterval("resizeDiv('"+Divname+"')",150)
		}
		divTop = parseInt(document.getElementById(Divname).style.top,10)
		document.getElementById(Divname).style.top = divTop - 1
		}
		catch(e){}
		}
		function closeDiv(Divname)
		{
		document.getElementById(Divname).style.visibility='hidden';
		if(objTimer) window.clearInterval(objTimer)
		}