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

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

// Return the viewable height of the window.
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;
}

// Place the footer element at the bottom of the page.
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		
		if (windowHeight > 0) {
			// Get the height of the header, sidebar and content panes.
			var headerHeight = document.getElementById('header').offsetHeight;
			var sidebarHeight = document.getElementById('sidebar').offsetHeight;
			var contentHeight = document.getElementById('content').offsetHeight;
			
			// Get the id of the footer pane.
			var footerElement = document.getElementById('footer');
			var footerTopPadding = 30;
			
			if (document.URL.search(/index.php/) != -1
							|| document.URL.search('.com/dev2\/?$') != -1
							|| document.URL.search('.net/dev2\/?$') != -1) {
				var indexElementHeight = document.getElementById('indexMainContent').offsetHeight;
				var searchbarHeight = document.getElementById('searchbar').offsetHeight;
				
				contentHeight = indexElementHeight + searchbarHeight;
			}
			
			// 
			if (sidebarHeight > contentHeight)
				footerElement.style.top = (sidebarHeight + headerHeight + footerTopPadding) + 'px';
			else
				footerElement.style.top = (contentHeight + headerHeight + footerTopPadding) + 'px';
			
			// Bring the footer element back to the front.
			footerElement.style.display = 'block';
		}
	}
}

// Hides an element based upon a specified ID
function hideElement(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		} else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

// Shows an element based upon a specified ID
function showElement(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		} else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}