window.onload = function() {
	setContent();
	initScrollLayer()
}

window.onresize = function() {
	setContent();
}

//beginning of vertical centering
function getWindowHeight() {
var windowHeight = 0;
if (typeof(window.innerHeight) == 'number') {
	windowHeight = window.innerHeight;
}
else {
	if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight;
	}
	else {
		if (document.body && document.body.clientHeight) {
			windowHeight = document.body.clientHeight;
		}
	}
}
return windowHeight;
}
function getWindowWidth() {
var windowHeight = 0;
if (typeof(window.innerWidth) == 'number') {
	windowWidth = window.innerWidth;
}
else {
	if (document.documentElement && document.documentElement.clientWidth) {
		windowWidth = document.documentElement.clientWidth;
	}
	else {
		if (document.body && document.body.clientWidth) {
			windowWidth = document.body.clientWidth;
		}
	}
}
return windowWidth;
}
function setContent() {
if (document.getElementById) {
	var windowHeight = getWindowHeight();
	if (windowHeight > 0) {
		var contentElement = document.getElementById('main');
		var contentHeight = contentElement.offsetHeight;
		if (windowHeight - contentHeight > 0) {
			contentElement.style.position = 'relative';
			contentElement.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
		}
		else {
			contentElement.style.position = 'static';
		}
	}
}
}
//end of vertical centering


/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initScrollLayer() {
  // arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll, 
  // if horizontal scrolling, id of element containing scrolling content (table?)
  var wndo = new dw_scrollObj('wn', 'lyr1');
  
  // bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
  // wndo.bSizeDragBar = false;
  
  // arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
  // (x/y offsets of dragBar in track)
  wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);
  
  var outer = document.getElementById("wn");
  var inner = document.getElementById("lyr1");
  var dragBar = document.getElementById("dragBar");
  var scrollbar = document.getElementById("scrollbar");
  if(inner.offsetHeight < outer.offsetHeight) {
	scrollbar.style.visibility = "hidden";
  }
  else {
	if(scrollbar.style.visibility != "hidden"){
		scrollbar.style.visibility = "visible";
	}
  }

  
  // pass id('s) of scroll area(s) if inside table(s)
  // i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
  //dw_scrollObj.GeckoTableBugFix('wn'); 
}
