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 headerHeight = document.getElementById('header-div').offsetHeight;
			var contentHeight = document.getElementById('content-middle').offsetHeight;
			var LEFTcontentHeight = document.getElementById('content-left').offsetHeight;
			var RIGHTcontentHeight = document.getElementById('content-right').offsetHeight;
			if((LEFTcontentHeight > RIGHTcontentHeight) && LEFTcontentHeight > contentHeight) {
			    contentHeight = LEFTcontentHeight;
			} else if (RIGHTcontentHeight > contentHeight) {
			    contentHeight = RIGHTcontentHeight;
			}
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight + headerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
				footerElement.style.left = '220px';
			}
			else {
				footerElement.style.position = 'absolute';
				footerElement.style.left = '220px';
                if(document.getElementById("content-banner")) {
                    var bannerHeight = document.getElementById('content-banner').offsetHeight;
				    footerElement.style.top = (contentHeight + headerHeight + bannerHeight + 32) + 'px';
                } else {
				    footerElement.style.top = (contentHeight + headerHeight + 32) + 'px';
                }
			}
            footerElement.style.visibility = 'visible';
		}
	}
}

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

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

