/**
 * 
 * This JS file "sticks" the two ladies in
 * the sidebar to the bottom of the browser
 * window, regardless of the height of the
 * content.
 * 
 * Adapted for Metro OBGYN by John Whittet
 * from Bobby van der Sluis's ALA article:
 * 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+196;
			var footerElement = document.getElementById('footer');
			var footerHeight  = 4; // height + margin-top
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				if ((contentHeight-196)<(380) && (windowHeight - (contentHeight + footerHeight))<(380-(contentHeight-196))) {
					// to stop overlapping
					footerElement.style.top = 380-(contentHeight-196) + 'px';
				} else {
					footerElement.style.top = (windowHeight - (contentHeight + footerHeight)) + 'px';
				}
			} else {
				if ((contentHeight-196)<(380)) {
					footerElement.style.top = 380-(contentHeight-196) + 'px';
				} else {
					footerElement.style.top = '0px';
				}
			}
		}
	}
}
window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}