// arts|generate JavaScript
// Copyright 2005 Stdio 24. http://www.studio24.net
// Last update: 11 May 2005.

function setFooter() {
	if (document.getElementById) {
		// Get height of window
		var windowHeight = getWindowHeight();
		if (windowHeight>0) {
			// get hight of the 'main' div
			var mainHeight = document.getElementById('main').offsetHeight;
			// get height of the 'footer' div
			var footerElement = document.getElementById('footer');
			var footerHeight = footerElement.offsetHeight;
			if (windowHeight - (mainHeight) >= 0) {
				// IF the hight of the main div is less than the hight of the window (e.g. page WITHOUT scrolling)
				//Footer is places 'absolutley' at the bottom of the page (+5 is to account for footers bottom margin)
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) - 5 +'px';
			}
			else {
				// ELSE the height of the main div is greater than that of hte window (e.g. page with scrolling)
				// Footer is places staticly into the bottom on main div as normal
				footerElement.style.position='static';
			}
		}
	}
}

function getWindowHeight() {
//Returns hight of browser viewing pain	
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		// Most modern browsers except Internet Explorer
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement&&document.documentElement.clientHeight) {
			// Internet Explorer 6
			windowHeight=document.documentElement.clientHeight;
		}
		else {
			if (document.body&&document.body.clientHeight) {
			// Internet Explorer 4+
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

window.onload = function() {
	setFooter();
}

window.onresize = function() {
	setFooter();
}