//	core.js
//	License: none
//		Use as you will but I'd appreciate an
//		email at tkegan@greenneondesign.com if 
//		you find a way to improve the code

//	Code shamelessly copied from Simon Willison's weblog
//		(http://simon.incutio.com/archive/2004/05/26/addLoadEvent)
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//	Code by T.K.Egan - 19 Oct 2005
//		from code published @ A List Apart (http://www.alistapart.com/articles/footers)
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 setFooter() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
			var contentHeight=document.getElementById('content').offsetHeight + 
									document.getElementById('banner').offsetHeight;
			var footerElement=document.getElementById('footer');
			var footerHeight=footerElement.offsetHeight;
			if (windowHeight-(contentHeight+footerHeight)>=0) {
				footerElement.style.position='relative';
				footerElement.style.top=(windowHeight-(contentHeight+footerHeight))+'px';
			} else {
				footerElement.style.position='static';
			}
		}
	}
}

addLoadEvent(setFooter);

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