//functions dealing with the absolute positioning of the wrapper
//based on ALA - exploring footer
//http://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 setPosition() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var wrapperHeight = document.getElementById('wrapper').offsetHeight;
			var wrapperDiv = document.getElementById('wrapper');
			if (windowHeight < wrapperHeight) {
				wrapperDiv.style.marginTop = '-215px';
			}
			if ((windowHeight > wrapperHeight)&&(wrapperDiv.style.marginTop == '-215px')) {
				wrapperDiv.style.marginTop = '-18em';
			}
		}
	}
}
window.onload = function() {
	if (document.getElementById) {
		//external links to open in a new window
		var anchors = document.getElementsByTagName('a');
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			if (anchor.getAttribute('href') &&  anchor.getAttribute('rel') == 'external') anchor.target = '_blank'; 
		}
	}
	setPosition();
}
window.onresize = function() {
	setPosition();
}