// nhStandard.js: Standard functions
// (c) Niels Horn

// Start Column Script
// based on work by Paul@YellowPencil.com and Scott@YellowPencil.com
function setTall() {
	if (document.getElementById) {
		var divs = new Array(
			document.getElementById('navigation'), 
			document.getElementById('content'));
		
		// Let's determine the maximum height out of all columns specified
		var maxHeight = 0;
		for (var i = 0; i < divs.length; i++) {
			if (divs[i].offsetHeight > maxHeight) maxHeight = divs[i].offsetHeight;
		}
		
		// Let's set all columns to that maximum height
		for (var i = 0; i < divs.length; i++) {
			divs[i].style.height = maxHeight + 'px';

			// Now, if the browser's in standards-compliant mode, the height property
			// sets the height excluding padding, so we figure the padding out by subtracting the
			// old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
			if (divs[i].offsetHeight > maxHeight) {
				divs[i].style.height = (maxHeight - (divs[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}

// Set up Event Listener - the script that allows us to use the addEvent call below
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}
/*
window.onload = function() {
	setTall();
}

window.onresize = function() {
	setTall();
}
*/
addEvent(window, 'load', setTall, false);
addEvent(window, 'resize', setTall, false);