function getPos(id)
{
	var obj = document.getElementById(id);
	var pos = {left:0, top:0};

	if(typeof obj.offsetLeft != 'undefined') {

		while (obj) {
			pos.left += obj.offsetLeft;
			pos.top += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else {
		pos.left = obj.left;
		pos.top = obj.top;
	}

	return pos;
}

function maxPosition()
{
	var iMaxPos = -Number.MAX_VALUE;

	for(var i = 0; i < maxPosition.arguments.length; i++) {
		if(maxPosition.arguments[i] > iMaxPos) {
			iMaxPos = maxPosition.arguments[i];
		}
	}
	return iMaxPos;
}

function setObjectTop(id, top)
{
	var obj = document.getElementById(id);
	obj.style.top = top + "px";
}

function setObjectHeight(id, height)
{
	if(id && height) {
		var obj = document.getElementById(id);
		obj.style.height = height + "px";
	}
}

function setObjectWidth(id, width)
{
	var obj = document.getElementById(id);
	obj.style.width = width + "px";
}

function getObjectHeight(id)
{
	var obj = document.getElementById(id);
	var iObjectHeight = 0;
	iObjectHeight = obj.offsetHeight;
	return parseInt(iObjectHeight);
}

function getWindowInnerSize(win)
{
	if(!win) win = window;
		var objWin = new Object();
		if(typeof win.innerWidth != 'undefined') {
			objWin.width = win.innerWidth;
			objWin.height = win.innerHeight;
		} else {
			var obj = getBody(win);
			objWin.width = parseInt(obj.clientWidth);
			objWin.height = parseInt(obj.clientHeight);
		}
		return objWin;
}

function getBody(w)
{
	return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}

function positionFooter(sMiddleColPHId, sFooterId)
{
	var iContentPos = getPos(sMiddleColPHId).top;

	var iWindowInnerHeight = getWindowInnerSize().height;
	var iWindowMinPos = iWindowInnerHeight - getObjectHeight(sFooterId);

	var iMaxValue = maxPosition(iContentPos, iWindowMinPos);

	var iContentFooterPHHeight = 0;

	if (iMaxValue > iContentPos) {
		iContentFooterPHHeight = iMaxValue - iContentPos;
	}
	if (iWindowInnerHeight > iContentPos)
	{
		setObjectHeight(sMiddleColPHId, iContentFooterPHHeight-32);
	}
}

function init()
{
	positionFooter("content-padding", "footer");
}

window.onresize = init;

//START: Fix IE 6 Text Selection Bug
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat")
{
	document.onreadystatechange = function fixIE6AbsPos() {
		if( !document.body ) { return; }
		document.body.style.height = document.documentElement.scrollHeight + 'px';
	}
}
//END: Fix IE 6 Text Selection Bug