/**
 * Librex Javascript Styling
 * 
 * @since 01/10/2007
 * @copyright Profitmaster Systems Ltd.
 * @author Pete Hurst <peterh@profitmaster.co.uk>
 */

/**
 * Fix the height of various page elements
 */
var fixHeight = function(){
	// Get reference to footer element
	var footer = $("#footer");
	// If there's no footer, don't bother trying to fix the page height. This
	// will be Image page or Drill page.
	if (footer.length>0) {
		// Stretch page so footer rests at bottom with a small gap (and account 30 for menu bar)
//		var offsetHeight = footer.height()+16;
//		$("#page").fillPage(offsetHeight);
		// Stretch the content to be at least the height of the groups
		$("#content").fillHeight("#groups",0);
		// Stretch the content to be at least the height of the news
		//$("#content").fillHeight("#news",0);
	}
	// Also stretch its last list item, -6px to account for padding
//	$("#tree>li:last-child").fillHeight("#tree",4);
};

$(function() {
	// Set up the tree expanders/collapsers
	var treeCallback;
	// On anything other than IE6, the expander callback needs to move the footer with fixHeight.
	if (!($.browser.msie) || (parseInt($.browser.version)!=6)) {
		treeCallback = fixHeight;
	}
	$("#tree").treeExpander("open","closed",treeCallback);
	
	// Call standard PM load functions
	PMWeb.OnLoad();
});

// Call fix routines
if ($.browser.msie && parseInt($.browser.version)==6) {
}
// Only fix height on non-IE6
// Causes various problems on IE6, not worth it since MS are discontinuing support very soon...
else {
	$(window).load(fixHeight);
}

//$(window).resize(fixHeight);
