// Magic Footer for The Abor Group

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;
}

// A few numbers used in the function below refer to the height of various objects on the page itself
// A height of 360 refers to the space from the top of the page to the top of the mf_dynamic div
// A height of 308 refers to the space from the top of the page to the top of the main_text div
// A height of 321 refers to the space from the top of the page to the top of the form div

function newDivs() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var maintextHeight = document.getElementById('main_text').offsetHeight;
		var formHeight = document.getElementById('form').offsetHeight;
		if (windowHeight > 0) {
			var mfElement = document.getElementById('mf_dynamic');
			if (((maintextHeight + 308)  > (windowHeight)) && ((maintextHeight + 308)  > (formHeight + 321))) {
				mfElement.style.height = (maintextHeight - 20) + 'px';
			} else if (((formHeight + 312) > (windowHeight)) && ((formHeight + 321) > (maintextHeight + 308))) {
				mfElement.style.height = (formHeight - 10) + 'px';
			} else {
				mfElement.style.height = (windowHeight - 360) + 'px';
			}
		}
	}
}			