// 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) { // Checks to see if Browser is capable of writing script
		var windowHeight = getWindowHeight(); 
		var divs,contDivs,maxHeight,divHeight,d;
		
		divs=document.getElementsByTagName('div');
		contDivs=[];
		
		
		maxHeight=windowHeight;
		
		var mfElement = document.getElementById('mfDynamic');
		var mfTop = mfElement.offsetTop;
		
		var tdgElement = document.getElementById('footer');
		var tdgHeight = tdgElement.offsetHeight;
		
		for(var i=0;i<divs.length;i++) {
			if(/\bcolumn\b/.test(divs[i].className)) { // Test to see if Class Column
				d=divs[i];
				contDivs[contDivs.length]=d; // Counts how many Divs are in array
				
				var dTop = d.offsetTop; // Offset top of every Div on page
				
				if(d.offsetHeight) { // Offset height - Div height
					divHeight=d.offsetHeight + dTop; // Combine Div height & Div top
				} else if(d.style.pixelHeight) {
					divHeight=d.style.pixelHeight + dTop;
				}
				
				maxHeight=Math.max(maxHeight, divHeight); // Compare maxheight to Div height. larger element becomes maxheight			
				
			}
		}
		
		mfElement.style.height = (maxHeight - mfTop + 3) + 'px';
		tdgElement.style.visibility="visible"; //
		tdgElement.style.top = (maxHeight - 38) + 'px';
		
	}
}	
