﻿var m_iResizeMainDivTimer = null;
function onLoadBody() 
{
  // schedule regular resizing of the main div, to adapt it to the available window height
  if (m_iResizeMainDivTimer == null) {
    resizeMainDiv();
    m_iResizeMainDivTimer = window.setInterval("resizeMainDiv()",500);
  }
}
function onLoadPool() 
{
  // schedule regular resizing of the main div, to adapt it to the available window height
  if (m_iResizeMainDivTimer == null) {
    resizePoolDiv();
    m_iResizeMainDivTimer = window.setInterval("resizePoolDiv()",500);
  }
}
function isprinter()
{
  var oMain = document.getElementById("main");
  var oContainer = document.getElementById("container");
  if (oMain && oContainer)
    return ((getTop(oMain) - getTop(oContainer)) < 20);
  return false;
}
function beforeprint()
{
  if (m_iResizeMainDivTimer != null) {
    window.clearInterval(m_iResizeMainDivTimer);
    m_iResizeMainDivTimer = null;
  }
  var oMain = document.getElementById("main");
  var oContainer = document.getElementById("container");
  if (oMain && oContainer) {
    oMain.style.height = "5000px";
    oContainer.style.height = "5000px";
  }
}
function afterprint()
{
  onLoadBody();
}
function resizeMainDiv()
{
  var oMain = document.getElementById("main");
  if (oMain) {
    var iTop = 98; //getTop(oMain);
    var iHeight = Math.max(Math.floor((getWindowHeight() - iTop)),100);
    oMain.style.height = iHeight+"px";
  }
}
function resizePoolDiv()
{
  var oMain = document.getElementById("main");
  if (oMain) {
    var iTop = 30; //getTop(oMain);
    var iHeight = Math.max(Math.floor((getWindowHeight() - iTop)),100);
    oMain.style.height = iHeight+"px";
  }
}
function getWindowHeight()
{
  var windowHeight;
  windowHeight = 0;
  if (self.innerHeight) {		
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) {		
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) {		
    windowHeight = document.body.clientHeight; 
  }
  return windowHeight;
}
function getTop(obj) 
{ 
  var curtop = 0; 
     
  if (obj.offsetParent) { 
    while (obj.offsetParent) { 
      curtop += obj.offsetTop;
      obj = obj.offsetParent; 
    } 
  } else if (obj.y) 
    curtop += obj.y; 
  return curtop; 
}
