/* dimensions of current browser window */

function wWidth () {
 // the more standards compliant browsers (mozilla/netscape/opera/IE7)
 // use window.innerWidth and window.innerHeight
 if (typeof window.innerWidth != 'undefined') {
  return window.innerWidth;
 }
 // IE6 in standards compliant mode (i.e. with a valid doctype as 
 // the first line in the document)
 else if (typeof document.documentElement != 'undefined' 
  && typeof document.documentElement.clientWidth != 'undefined' 
  && document.documentElement.clientWidth != 0) {
   return document.documentElement.clientWidth;
 }
 // older versions of IE
 else if (typeof document.getElementsByTagName('body')[0].clientWidth != 'undefined' 
  && document.getElementsByTagName('body')[0].clientWidth != 0) {
   return document.getElementsByTagName('body')[0].clientWidth;
 }
 else {
  return 0;
 }
}

function wHeight () {
 if (typeof window.innerHeight != 'undefined') {
  return window.innerHeight;
 } else if (typeof document.documentElement != 'undefined' 
  && typeof document.documentElement.clientHeight != 'undefined' 
  && document.documentElement.clientHeight != 0) {
   return document.documentElement.clientHeight;
 } else if (typeof document.getElementsByTagName('body')[0].clientHeight != 'undefined' 
  && document.getElementsByTagName('body')[0].clientHeight != 0) {
   return document.getElementsByTagName('body')[0].clientHeight;
 } else {
  return 0;
 }
}


/* height of current document */

function dHeight () {
 if (typeof document.body.scrollHeight != 'undefined' 
  && document.body.scrollHeight != 0) {
   return document.body.scrollHeight;
 } else if (typeof document.body.offsetHeight != 'undefined' 
  && document.body.offsetHeight != 0) {
   return document.body.scrollHeight;
 } else if (typeof document.documentElement.clientHeight != 'undefined' 
  && document.documentElement.clientHeight != 0) {
   return document.documentElement.clientHeight;
 } else if (typeof document.getElementsByTagName('body')[0].clientHeight != 'undefined' 
  && document.getElementsByTagName('body')[0].clientHeight != 0) {
   return document.getElementsByTagName('body')[0].clientHeight;
 } else if (typeof document.height != 'undefined' 
  && document.height != 0) {
   return document.height;
 } else {
  return 0;
 }
}


/* initialise properties of current document */

function wInit() {
 var maxWidth = 900;
 var curWidth = wWidth();
 var e = document.getElementById("page");
 if (!isNaN(curWidth) || curWidth > 0) {
  if (curWidth > maxWidth) {
   curWidth = maxWidth;
  }
 e.style.width = curWidth + "px";
 }
 
 e = document.getElementById("wrapperleft");
 var winHeight = wHeight();
 var docHeight = dHeight();
 if ( (!isNaN(winHeight) || winHeight > 0) && (!isNaN(docHeight) || docHeight > 0) ) {
  if (winHeight > docHeight) {
   docHeight = winHeight;
  }
 e.style.height = docHeight + "px";
 }
}
