function getPageSize(ignoreContents)
{
  var scrollX, scrollY;
  var windowWidth, windowHeight;
  var pageWidth, pageHeight;

  if(window.innerHeight && window.scrollMaxY)
  {
    scrollX = window.innerWidth + window.scrollMaxX;
    scrollY = window.innerHeight + window.scrollMaxY;
  }
  else if(document.body.scrollHeight > document.body.offsetHeight)
  {
    scrollX = document.body.scrollWidth;
    scrollY = document.body.scrollHeight;
  }
  else
  {
    scrollX = document.body.offsetWidth;
    scrollY = document.body.offsetHeight;
  }

  if(self.innerHeight)
  {
    if(document.documentElement.clientWidth)
    {
      windowWidth = document.documentElement.clientWidth;
    }
    else
    {
      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;
  }

  if(scrollY < windowHeight
  || ignoreContents)
  {
    pageHeight = windowHeight;
  }
  else
  {
    pageHeight = scrollY;
  }

  if(scrollX < windowWidth)
  {
    pageWidth = scrollX;
  }
  else
  {
    pageWidth = windowWidth;
  }

  return {width:pageWidth, height:pageHeight};
}
