var queryCnt=0;
var XMLHTTP;

function HandleMsg()
{
	if (XMLHTTP.readyState==4)
	{
		var rp = XMLHTTP.responseText;
		
		if(rp!=null&&rp.substr(0,1)>0)
			PopupMsgWin(rp);
	}
}

function PopupMsgWin(RemindCntString)
{
    var top=window.screen.availHeight-50;
    var left=window.screen.availWidth-200;
    var winstyle="titlebar=no,status=no,scrollbars=no,resizable=no,location=no,menubar=no,top="+top+",left="+left+",width=200,height=50;"
    window.open(ApplicationPath+"Common/PopupMsg.aspx?RemindCnt="+RemindCntString,"_blank",winstyle);
}

function QueryNewMsg(uid)
{
	var sid="&sid="+Math.random();
	var strURL,strMsgCnt;
	if((queryCnt % 3)==0)
	{
			XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			strURL = ApplicationPath+"Common/Data_Flow_Cnt.aspx?NoHandler=true&UserId="+uid+sid;
			XMLHTTP.open("POST",strURL,true);
			XMLHTTP.onreadystatechange=HandleMsg;
			XMLHTTP.send();
	}
	queryCnt++;
}

function startMon(uid)
{
	if(uid>0)
		window.setInterval("QueryNewMsg("+uid+")", 20000);
	fmtimg();
}

function fmtimg()
{
	var aImgs = document.body.getElementsByTagName("IMG");
	if(aImgs!=null)
	{
		for(var i=0;i<aImgs.length;i++)
		{
		    if(aImgs[i].id==null)
		    {
			    if(aImgs[i].offsetWidth>window.screen.availWidth*.85)
				    aImgs[i].width=window.screen.availWidth*.85;
			}
		}
	}
}
