var gMessage;
var gDivName;
var giWidth;
var gHeight;
var gTimeout;

function ClampingMsgBox()
{
  var WindowSize;
  WindowSize = GetWindowSize();
  iLeft = Math.floor((WindowSize[0] - giWidth)/2);
  iTop = GetYScroll()+Math.floor((WindowSize[1] - giHeight)/2);
  strStyle = "position:absolute; left: " + iLeft + "px; top: " + iTop + "px; display: block;z-index:10";
  document.getElementById(gDivName).style.cssText=strStyle;
  gTimeout = setTimeout("ClampingMsgBox()",500);
}

function ShowMsgBox(DivName,IframeName,iWidth,iHeight,msg)
{
  gDivName = DivName;
  giWidth = iWidth;
  giHeight = iHeight;
  ClampingMsgBox();
  gMessage=msg;
  try
  {
    window.frames[IframeName].document.getElementById("SysMessage").innerHTML =msg;
  }
  catch(err){}
  
}

function DisableMsgBox(DivName)
{
  var WindowSize;
  WindowSize = GetWindowSize();
  iLeft = -10 - WindowSize[0];
  iTop = -10 -WindowSize[1];
  str = "position:absolute; left:" + iLeft + "px; top:" + iTop + "px;display: none;"
  document.getElementById(DivName).style.cssText=str;
  clearTimeout(gTimeout);
}

function GetWindowSize()
{
  var windowWidth, windowHeight;
  if (self.innerHeight)
  {
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  }
  else if (document.body)
  {
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }
  
  arrWindowSize = new Array(windowWidth,windowHeight);
  return arrWindowSize;
  
}

function GetYScroll(){ 
  var yScroll; 
  if (self.pageYOffset)
  { 
    yScroll = self.pageYOffset; 
  }
  else if (document.documentElement && document.documentElement.scrollTop)
  {
    yScroll = document.documentElement.scrollTop; 
  }
  else if (document.body)
  { 
      yScroll = document.body.scrollTop; 
  } 
  return yScroll; 
} 
