//functions that calculates the vertical position for each element in a page in order to return the height of the page

function getObjectBottom(obj)
{
  var bottom = obj.offsetHeight+obj.offsetTop;
  if(isNaN(bottom))
    bottom = 0;

  var cur = obj.offsetParent;
  while(cur)
  {
    bottom += cur.offsetTop;
    cur = cur.offsetParent;
  }
  return bottom;
}

function getObjectTop(obj)
{
  var top = obj.offsetTop;
  if(isNaN(top))
    top = 0;

  var cur = obj.offsetParent;
  while(cur)
  {
    top += cur.offsetTop;
    cur = cur.offsetParent;
  }
  return top;
}

function recursiveGetHighestBottom(obj)
{
  var bottom = getObjectBottom(obj);

    for(var i = 0; i < obj.childNodes.length; i++)
    {
      bottom = Math.max(bottom,recursiveGetHighestBottom(obj.childNodes[i]));
    }
  
  return bottom;
}

var lastUpdateContentHeight = new Date().getTime();
var isRunningUpdateContentHeight = false;

var bLoaded = false;

function updateContentHeight()
{
  if(isRunningUpdateContentHeight || !bLoaded)
  {
    lastUpdateContentHeight = new Date().getTime();
    return;
  }	
  var now = new Date().getTime();
  if(now-lastUpdateContentHeight > 100)
  {
    updateContentHeightImpl();
    isRunningUpdateContentHeight = false;
  }
  else
  {
    window.setTimeout("updateContentHeight()",50);
  }
  lastUpdateContentHeight = new Date().getTime();
}

function updateContentHeightImpl(obj)
{
    var content_view = document.getElementById('content_view');
    var obj = obj!=null?obj:document.getElementById('content_view_inner');					
    content_view.style.height = (recursiveGetHighestBottom(obj)-getObjectTop(content_view))+'px';
    var footer = document.getElementById('footer');
    footer.style.visibility = "visible";
}