/**
 * Set all passed elements to the same height as the highest element.
 * 
 * Copyright (c) 2010 Ewen Elder Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * @author: Ewen Elder <glomainn at yahoo dot co dot uk> <ewen at jainaewen dot
 *          com>
 * @version: 1.0
 */
(function($) {
	$.fn.equalHeightColumns = function(e) {
		var J, a;
		e = $.extend( {}, $.equalHeightColumns.defaults, e);
		a = $(this);
		J = e.height;
		$(this).each(function() {
			if (e.children)
				a = $(this).children(e.children);
			if (!e.height) {
				if (e.children) {
					a.each(function() {
						if ($(this).height() > J)
							J = $(this).height()
					})
				} else {
					if ($(this).height() > J)
						J = $(this).height()
				}
			}
		});
		if (e.minHeight && J < e.minHeight)
			J = e.minHeight;
		if (e.maxHeight && J > e.maxHeight)
			J = e.maxHeight;
		a.animate( {
			height : J
		}, e.speed);
		return $(this)
	};
	$.equalHeightColumns = {
		version : 1.0,
		defaults : {
			children : false,
			height : 0,
			minHeight : 0,
			maxHeight : 0,
			speed : 0
		}
	}
})(jQuery);
