// 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,biggestDiv,divHeight,d;
		
		var footerElement = document.getElementById('footer');
		var footerHeight = footerElement.offsetHeight;
		var footerPosition = 0;
		
		divs=document.getElementsByTagName('div');
		contDivs=[];
		
		maxHeight=windowHeight;
		biggestDiv=0;
		
		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;
				} else if(d.style.pixelHeight) {
					divHeight=d.style.pixelHeight + dTop;
				}
				
				maxHeight=Math.max(maxHeight, divHeight);
				biggestDiv=Math.max(divHeight, biggestDiv);
				
			}
		}
		
		if ((biggestDiv + footerHeight) > windowHeight) {
			footerPosition = (biggestDiv + 20) + 'px';
		} else {
			footerPosition = (maxHeight - footerHeight) + 'px';
		}
		
		footerElement.style.top = footerPosition;
		footerElement.style.visibility = "visible";
		
	}
}	