﻿function getBrowserWH()
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' )
  {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
  {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
  }
  
  return [ myWidth, myHeight ];
}

function getBrowserScrollXY()
{
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' )
  {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  }
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
  {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  }
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
  {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

/*
Page height - the height of the total page (usually the body element).
This is a tricky one, some browsers require scrollHeight, others offsetHeight, but all browsers support both properties.
Therefore I see which property has the larger value.
This means the page height the script below gives is never sm aller than the window height.
*/
function getBrowserPageWH()
{
  var x,y;
  var test1 = document.body.scrollHeight;
  var test2 = document.body.offsetHeight;
  if (test1 > test2) // all but Explorer Mac
  {
	x = document.body.scrollWidth;
	y = document.body.scrollHeight;
  }
  else // Explorer Mac;
       //would also work in Explorer 6 Strict, Mozilla and Safari
  {
	x = document.body.offsetWidth;
	y = document.body.offsetHeight;
  }
  
  return [x, y];
}