//
// WindowSize(reserveWidth, reserveHeight) ;
//
// Returns an object that includes "width" and "height" members that provide
// the available window size in pixels.  "reserveWidth" and "reserveHeight"
// specify the number of pixels to be excluded from the return values.
//

function WindowSize(reserveWidth, reserveHeight)
{
  var win    = new Object ;
  win.width  = 640 + reserveWidth ;
  win.height = 480 + reserveHeight ;
  
  if (false)
  {
	document.write("document.body.offsetWidth = " + document.body.offsetWidth + "<BR>") ;  
	document.write("document.body.offsetHeight = " + document.body.offsetHeight + "<BR>") ;
	document.write("document.body.clientWidth = " + document.body.clientWidth + "<BR>") ;  
	document.write("document.body.clientHeight = " + document.body.clientHeight + "<BR>") ;
	document.write("document.documentElement.offsetWidth = " + document.documentElement.offsetWidth + "<BR>") ;  
	document.write("document.documentElement.offsetHeight = " + document.documentElement.offsetHeight + "<BR>") ;
	document.write("document.documentElement.clientWidth = " + document.documentElement.clientWidth + "<BR>") ;  
	document.write("document.documentElement.clientHeight = " + document.documentElement.clientHeight + "<BR>") ;
	document.write("window.innerWidth = " + window.innerWidth + "<BR>") ;
	document.write("window.innerHeight = " + window.innerHeight + "<BR>") ;
	document.write("window.outerWidth = " + window.outerWidth + "<BR>") ;
	document.write("window.outerHeight = " + window.outerHeight + "<BR>") ;
	document.write("screen.availWidth = " + screen.availWidth + "<BR>") ;
	document.write("screen.availHeight = " + screen.availHeight + "<BR>") ;
  }
  
  if (document.all)
  {
  	// MSIE
  	if (document.documentElement && document.documentElement.clientWidth)
  	{
  	  // MSIE 6
  	  win.width  = document.documentElement.clientWidth - 24 ;
  	  win.height = document.documentElement.clientHeight ;
  	}
  	else if (document.body)
  	{
  	  // MSIE < 6
  	  if (document.body.clientWidth)
  	  {
  	  	win.width  = document.body.clientWidth ;
  	  	win.height = document.body.clientHeight ;
  	  }
  	  else
  	  {
  	  	win.width  = document.body.offsetWidth ;
  	  	win.height = document.body.offsetHeight ;
  	  }
  	}

	reserveHeight += 20 ;
  }
  else if (window.innerWidth && window.innerHeight)
  {
  	// Netscape, Mozilla, Safari, etc.
  	if (document.body && document.body.bodyWidth)
  	{
  	  win.width = document.body.bodyWidth ;
  	}
  	else
  	{
	  win.width = window.innerWidth - 20 ;
	}
	
	win.height = window.innerHeight ;
  }
  
  win.width  -= reserveWidth ;
  win.height -= reserveHeight ;
  win.width   = Math.max(win.width,  320) ;
  win.height  = Math.max(win.height, 240) ;

  return win ;
}
