/*
Footer alignment script
Liran Oz - 24/11/2007
*/

var alignId = "footer_js_align";
var footerId = "footer";
var footerHeight = 63;


function getAbsoluteLeft(objectId) {
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft;
	while(o.offsetParent!=null) {
		oParent = o.offsetParent;
		oLeft += oParent.offsetLeft;
		o = oParent;
	}
	return oLeft;
}

function getAbsoluteTop(objectId) {
	o = document.getElementById(objectId);
	oTop = o.offsetTop;
	while(o.offsetParent!=null) { 
		oParent = o.offsetParent;
		oTop += oParent.offsetTop;
		o = oParent;
	}

	return oTop;
}


function alignMe()
{
	var align = document.getElementById(alignId);
	var curPos = getAbsoluteTop(footerId);
	var alignPos = getAbsoluteTop(alignId);
	
	var windowHeight = document.documentElement.clientHeight;

	if (windowHeight < curPos) {		//means footer is already at the bottom
		align.style.height = "30px";
	}
	else {								//calculate how much space is needed for footer to be at the bottom
		newHeight = windowHeight - curPos - footerHeight;
		align.style.marginTop = newHeight + "px";
		
	}
	document.getElementById(footerId).style.visibility = "visible";	
}


