function GetPageScroll() {
  var x, y;
  if(window.pageYOffset) {
    // all except IE
    y = window.pageYOffset;
    x = window.pageXOffset;
  } else if(document.documentElement 
    && document.documentElement.scrollTop) {
    // IE 6 Strict
    y = document.documentElement.scrollTop;
    x = document.documentElement.scrollLeft;
  } else if(document.body) {
    // all other IE
    y = document.body.scrollTop;
    x = document.body.scrollLeft; 
  }
  return {X:x, Y:y};
}

function GetPageSize() {
  var scrW, scrH;
  if(window.innerHeight && window.scrollMaxY) {
    // Mozilla
    scrW = window.innerWidth + window.scrollMaxX;
    scrH = window.innerHeight + window.scrollMaxY;
  } else if(document.body.scrollHeight > document.body.offsetHeight){
    // all but IE Mac
    scrW = document.body.scrollWidth;
    scrH = document.body.scrollHeight;
  } else if(document.body) { // IE Mac
    scrW = document.body.offsetWidth;
    scrH = document.body.offsetHeight;
  }

  var winW, winH;
  if(window.innerHeight) { // all except IE
    winW = window.innerWidth;
    winH = window.innerHeight;
  } else if (document.documentElement 
    && document.documentElement.clientHeight) {
    // IE 6 Strict Mode
    winW = document.documentElement.clientWidth; 
    winH = document.documentElement.clientHeight;
  } else if (document.body) { // other
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }

  // for small pages with total size less then the viewport
  var pageW = (scrW<winW) ? winW : scrW;
  var pageH = (scrH<winH) ? winH : scrH;

  return {PageW:pageW, PageH:pageH, WinW:winW, WinH:winH};
}

//////////////////////////////////////////////////////////////////////////////////
var divTop,divLeft,divWidth,divHeight,objTimer;
var divObj=document.getElementById('eMeng');

function getMsg()
{
	try
	{
		divHeight = parseInt(divObj.offsetHeight,10);
		divWidth = parseInt(divObj.offsetWidth,10);

		var pw = GetPageSize();
		var pc = GetPageScroll();

		divObj.style.top = pw.PageH + pc.Y;
		divObj.style.left = pw.WinW - divWidth - 30 + pc.X;

		divObj.style.visibility="visible";
		objTimer = window.setInterval("moveDiv()",1);
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
		divHeight = parseInt(divObj.offsetHeight,10);
		divWidth = parseInt(divObj.offsetWidth,10);

		divTop = parseInt(divObj.style.top,10);
		divLeft = parseInt(divObj.style.left,10);

		var pw = GetPageSize();
		var pc = GetPageScroll();

		if((divTop + divHeight) - pw.WinH - pc.Y > 0)
		{
			divObj.style.top = divTop - 1;
		}
		else if((divTop + divHeight) - pw.WinH - pc.Y < 0)
		{
			divObj.style.top = divTop + 1;
		}
		else
		{
			window.clearInterval(objTimer);
		}
		divObj.style.left = pw.WinW - divWidth - 30 + pc.X;

	}
	catch(e){}
}

window.onload = getMsg;
window.onresize = function(){objTimer = window.setInterval("moveDiv()",1);};
window.onscroll = function(){objTimer = window.setInterval("moveDiv()",1);};
window.onerror = function(){}
