$(document).ready(function(){
	/*
	 *  The poupose of this JavaScript is to dynamicly position the
	 *  footerPanel.  The value contentPanelHeight in tiles.xml must 
	 *  be set to 0.
	 */

	var contentPanel = $('div#contentPanel');
	var leftPanel = $('div#leftPanel');
	var rightPanel = $('div#rightPanel');
	var footerPanel = $('div#footerPanel');

	/*
	 *  Adjust the height of the leftPanel by the height of
	 *	leftAccreditations.
	 */

	if(leftPanel.size()) {
		var leftAccreditations = $('div#leftAccreditations');
		if(leftAccreditations.size())
			leftPanel.height(leftPanel.height() + leftAccreditations.height());
	}

	/*
	 *  This event handler will position the footer below the leftPanel, 
	 *  contentPanel or rightPanel, whichever is lower.
	 */

	contentPanel.resize(function(event) {
		var contentPanelTop = parseInt(contentPanel.css('top'), 10);
		var maxHeight = contentPanel.height();
		if(leftPanel.size())
			maxHeight = maxHeight < leftPanel.height() ? leftPanel.height() : maxHeight;
		if(rightPanel.size())
			maxHeight = maxHeight < rightPanel.height() ? rightPanel.height() : maxHeight;
		var footerPanelTop = contentPanelTop + maxHeight + 10;
		footerPanel.css('top', footerPanelTop + 'px');
	});

	contentPanel.trigger('resize');
	footerPanel.css('display', 'block');
});
