
// Call functions after DOM has loaded before page display
document.observe("dom:loaded", function() {
	adjustNav();
	adjustColumns();
});

// Recall adjustColumns after images have loaded
Event.observe(window, 'load', function() {
	adjustColumns();
});

// Evenly space primary navigation horizontally.
var adjustNav = function() {
/*
	var totalWidth = $('pNav').getWidth();

	var usedWidth = 0;
	$$('#pNav a').each(function(elm) {
		usedWidth += elm.getWidth();
	});

	var extraWidthPerLink = Math.floor((totalWidth - usedWidth) / $$('#pNav a').length);

	$('pNav').style.width = totalWidth + 100 + 'px';

	$$('#pNav a').each(function(elm) {
		elm.style.width = elm.getWidth() + extraWidthPerLink + 'px';
	});
*/
}

// Adjust page columns to be of equal height to the tallest column on the page.
var adjustColumns = function() {
	var columns = $$('#columnOne, #columnTwo, #columnThree');

	var maxHeight = columns.max(function(elm) {
		if (elm) {
			elm.style.height = 'auto';
			return elm.getHeight();
		} else {
			return 0;
		}
	});

	columns.each(function(elm) {
		if (elm)
			elm.style.height = maxHeight + 'px';
	});

	if ($('columnTwo') && !$('columnThree')) {
		$('columnTwo').style.borderRight = '0px';
	}
}