function setDivSize() {
var x, y, h;
var pos = 0;
//
//Get browser size
//
if (self.innerWidth) {
  x = self.innerWidth;
  y = self.innerHeight;
} 
else if (document.documentElement.clientWidth) {
  x = document.documentElement.clientWidth;
  y = document.documentElement.clientHeight;
}
else if (document.body) {
  x = document.body.clientWidth;
  y = document.body.clientHeight;
}
//
// Set size and position of main
//
if (y > 724) {
  pos = (y-724)/2;
  y = 700;
  h = 724+pos;
}
else if (y < 574) {
  y = 550;
}
else {
  y = y-24;
}
//
// Set body height for IE
//
if (h) {
  document.body.style.height = h + 'px';
}
else {
  document.body.style.height = 'auto';
}
document.getElementById('main').style.height = y + 'px';
document.getElementById('main').style.top = pos + 'px';
//
// Turn scrolling off if browser is larger than min-width/height
//
if (x > 619 && y > 550) {
  document.body.style.overflow = 'hidden';
}
else {
  document.body.style.overflow = 'auto';
}
//
// Set height of contentPanel
//
y = y-196-50;
var panel=document.getElementById('contentPanel');
panel.style.height = y + 'px';
//
//
// Set visibility of child elements in contentPanel
//
function findPosY(obj)  // Get full top offset
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}
function setVisibility(node, y, panel) {
   var children=node.childNodes;
   for (var i=0; i < children.length; i++) {
   if (children[i].className && (children[i].className == 'toggle' || children[i].className.search('toggle'))) {
    var top=findPosY(children[i])
       var height = children[i].offsetHeight;
    var panelTop = findPosY(panel);
    //alert("offsetTop = " + top + " offsetHeight = " + height);
       if ( (top+height) > (y+panelTop) )
             children[i].style.visibility = 'hidden';
       else
            children[i].style.visibility = 'visible';
        }
  else
       setVisibility(children[i], y, panel);
   }
}
if (panel.className == 'noScroll') {
   panel.style.overflow = 'hidden';
   setVisibility(panel, y, panel);
}

}
function resizeHandler() {
  setDivSize();
}
function onLoadHandler() {
  setDivSize();
}
window.onload = onLoadHandler;
window.onresize = resizeHandler;

