// Magic Footer v2

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 newDivs() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		var divs,contDivs,maxHeight,divHeight,d;
		
		var pageElement = document.getElementById('page_width_components');
		
		var footerElement = document.getElementById('footer');
		var footerHeight = footerElement.offsetHeight;
		var footerPosition = 0;
		
		var contentElement = document.getElementById('main-content-noimage');
		var contentTop = contentElement.offsetTop;
		
		divs=document.getElementsByTagName('div');
		contDivs=[];
		
		maxHeight=windowHeight;
		
		for(var i=0;i<divs.length;i++) {
			if(/\bcolumn\b/.test(divs[i].className)) {
				d=divs[i];
				contDivs[contDivs.length]=d;
				
				var dTop = d.offsetTop;
				
				if(d.offsetHeight) {
					divHeight=d.offsetHeight + dTop + footerHeight;
				} else if(d.style.pixelHeight) {
					divHeight=d.style.pixelHeight + dTop + footerHeight;
				}
				
				maxHeight=Math.max(maxHeight, divHeight);			
				
			}
		}
		
		footerPosition = (maxHeight - footerHeight);
		
		footerElement.style.top = footerPosition + 'px';
		footerElement.style.visibility = "visible";
		
		pageElement.style.height = footerPosition + 'px';
		//contentElement.style.height = (footerPosition - contentTop) + 'px';
		
		
	}
}	