var body = null;

function loadBorder(){
	var docHeight = getDocumentHeight();
	if(docHeight < document.viewport.getHeight()) docHeight = document.viewport.getHeight();
	//alert('Document height: '+docHeight);
	borderHeight = (docHeight-($('border').positionedOffset().top))+'px';
	//alert($('nav-container').positionedOffset().top);
	//$('border').setStyle({height: borderHeight});
	
	//alert($('nav-container').positionedOffset());
	
	$('border').morph('height:' + borderHeight + ';');
	
}

function setBodyBgColor(){
	
	// Main content area
	contentElements = $('content').childElements();
	color = contentElements.last().getStyle('background-color');
	//document.body.setStyle({backgroundColor: color });
	body = document.getElementsByTagName('body')[0];
	// to add all the prototype methods to this object
	//Element.extend(body);
	$(body).setStyle({backgroundColor: color });
}

function setTeaserBgColor(){
	
	// Teaser column
	tContentElements = $('border').childElements();
	if(tContentElements && (tContentElements.size() > 1)){
		color = tContentElements.last().getStyle('background-color');
		$('border').setStyle({backgroundColor: color });
	}
}

function getDocumentHeight() {
	/*
	if (typeof document.height != 'undefined') {
		return document.height;
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
		return document.documentElement.scrollHeight;
	}
	else if (document.body && typeof document.body.scrollHeight != 'undefined') {
		return document.body.scrollHeight;
	}
	else{
		return '0';
	}
	*/
	return body.getHeight();
};


document.observe("dom:loaded", function() {
	init();
});
