/**
 * Fixes the heights of all passed elements to that of the tallest one.
 * V0.4 - LR
 */
 
(function($){
			  
	$.fn.normaliseHeights = function() {
	
		var heightArray = [];
		var selectedElements = $(this);
	
		var normaliseNow = function() {
			
			// Loop through, recording outerHeight to an array
			selectedElements.each(function(i) {
				var parentElement = $(this);									   
				parentElement.data('originalHeight',parentElement.outerHeight());									   
				heightArray[i] = parentElement.outerHeight();                  	// Height with border + padding
			});
			
			heightArray.sort(function(a,b){return b - a});          	 		// Sort array numerically and descending
			selectedElements.height(heightArray[0]);                     		// Set all elements to have largest height
			
			// Loop through again, adjusting all heights accordingly
			selectedElements.each(function(i) {
										   
				parentElement = $(this);							   
	
				var heightDifference = parentElement.outerHeight() - parentElement.height();
				parentElement.height(parentElement.height() - heightDifference);
				
			});
			
			return selectedElements;
		}
	
		normaliseNow();
	
	}

})(jQuery);
