window.onresize = positionContent;
window.onload   = positionContent;
var origHeight=null;
var origFooterPos=null;

//Get the top position of an element
function getTopPos(ref) {
	var pos = ref.offsetTop;
	if(ref.offsetParent) {
		pos = pos + getTopPos(ref.offsetParent);
	}
	return pos;
}

//Get the left position of an element
function getLeftPos(ref) {
	var pos = ref.offsetLeft;
	if(ref.offsetParent) {
		pos = pos + getLeftPos(ref.offsetParent);
	}
	return pos;
}

//position page elements
function positionContent() {
	if(origHeight===null) { origHeight = document.documentElement.clientHeight };
	if(origFooterPos===null) { origFooterPos = getTopPos(document.getElementById('pagefooter')) };
    var a = document.getElementById('pagefooter');
	var windowheight = document.documentElement.clientHeight;
	var contentLength = windowheight - 28 - 26;
	var documentContentHeight = document.body.scrollHeight;
	if(documentContentHeight<windowheight) {
		document.getElementById('page').style.height = contentLength + 'px';
	} else {
		//
	}
	//document.getElementById('pagefooter').style.display = 'block';
}