/*******************************************************************************
	match-height.js
	
	Author: 
	Nathan Kelly (http://www.nathan-kelly.com)
	
	What does it do?
	Keeps selected elements the same height regardless of how much content
	they contain, very handy for columns if you don't like or can't use faux
	columns.
	
	Does it degrade gracfully?
	Yes, but this will depend on what your stylesheets are doing and how
	your HTML is structured.
	
	Licence: 
	Use this script however you like on one condition...
	
		"Don't blame me if it breaks something."
		
*******************************************************************************/
function matchHeight() {
	
	// get the parent of the elements we need to match
	matchWhere = document.getElementById('quick-links');
	
	// get the HTML elements to match
	var matchWhat = matchWhere.getElementsByTagName('div');
	
	// init the elements
	var elements = [];
	
	// init the maximum height
	var maxHeight = 0;
	
	// init height reduction, this allows us to remove any unwanted
	// native verticle padding set by the CSS
	var reduceHeight = 18;
	
	for (var i = 0; i < matchWhat.length; i++) {
		
		var matchElement = matchWhat[i];
		
		elements[elements.length] = matchElement;
		
		if (matchElement.offsetHeight) {
			
			var elementHeight = matchElement.offsetHeight - reduceHeight;
			
		} 
		
		else if (matchElement.style.pixelHeight) {
			
			var linkHeight = matchElement.style.pixelHeight;
			
		}	
		
		maxHeight = Math.max(maxHeight, elementHeight);
		
	}
	
	for (var i = 0; i < elements.length; i++) {
		
		elements[i].style.height = maxHeight + "px";
				
	}

}

// all done, run the script
function initMatchHeight() {
	
	// one last check to see if the matchWhere exists
	if (!document.getElementById("quick-links")) return;
	
	matchHeight();
	
}
Event.observe(window, 'load', initMatchHeight);
