/* page resize scripting */

/* Must match styles: */
var headerFooterHeight = 100 + 50;

/* 25 is somewhat arbitrary; on some level anything less than the thumbnail size is too small */
var minContentHeight = headerFooterHeight + 25;

function getHeight() {
  var h = 0;
  if (typeof(window.innerheight) == 'number') {
    h = window.innerheight;
  } else if (document.documentElement && document.documentElement.clientHeight) {
    h = document.documentElement.clientHeight;
  } else if (document.body && document.body.clientHeight) {
    h = document.body.clientHeight;
  }
  return h;
} 

function updateContentHeight()
{
  var h = getHeight();
  if (h > minContentHeight) {
    var elem = document.getElementById('content');
    elem.style.height = (h - headerFooterHeight) + 'px';
  }
}

function hideIPhoneUrlBar()
{
  window.scrollTo(0, 1);
}

function setContentHeight()
{
  if (navigator.platform == 'iPhone') {
    // scroll down a bit
    window.setTimeout(hideIPhoneUrlBar, 100);
  }

  updateContentHeight();
}

window.onload = setContentHeight;
window.onresize = updateContentHeight;
window.onorientationchange=setContentHeight;

