/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
 
(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 * 
	 * NOTE: the top/bottom borders/padding calculations assume
	 * the document is using the W3C box model and that units are px. 
	 * The IE "quirks" box model is not supported, nor are em and %!
	 *
	 * requires: dimensions plugin
	 * (http://dev.jquery.com/browser/trunk/plugins/dimensions/)
	 */
	 
	$.fn.equalizeCols = function(){
		var height = 0;
	  
		function normalize(el) {
			return (parseInt(el.css("paddingTop"), 10) || 0)
				+ (parseInt(el.css("paddingBottom"), 10) || 0)
				+ (parseInt(el.css("borderTopWidth"), 10) || 0)
				+ (parseInt(el.css("borderBottomWidth"), 10) || 0);
  		};
  
		return this
			.css("height", "auto")
			.each(function() {
				height = Math.max(height, $(this).outerHeight());
			})
			.css("height", function() {
				return height - normalize($(this));
			});
	};
	
})(jQuery);