/*--------------------------------------------------------------------
 * JQuery Plugin: "equalHeights"
 * by:	Daniel Filzhut, daniel.filzhut@cgi.com
 *
 * Copyright (c) 2009 CGI Information Systems and Management Consultants Deutschland GmbH
 *
 * Description:   Rezises all matching elements to the size of the largest one.
 *
 * Dependencies:  jQuery library
 *
 * Usage Example: $(element).equalHeights();
 *
 * Version: 1.1,   03.08.2009 (Added IE6/7 workaround for empty elements)
 * Version: 1.0.1, 20.05.2009 (Updated comments)
 * Version: 1.0,   04.02.2009
--------------------------------------------------------------------*/

$.fn.equalHeights = function() {

	var tallest = 0;
	var height = 0;

	// Find the tallest child element
	$(this).each(function(i) {

		// Default: Use js returned height
		height = $(this).height();

		// IE6/7 workaround for empty elements
		if($.browser.msie
		  && ($.browser.version.substr(0,1) == "6" || $.browser.version.substr(0,1) == "7")
		  && $(this).html() == "") {
			height = 0;

			// Use CSS height in case there is one
			if ($(this).css("height") != "auto") {
				height = parseFloat($(this).css("height"));
			}

			// Avoid buggy height in IE6/7
			if (height == 0) {
				$(this).css("line-height", "0");
				$(this).css("font-size", "0");
			}
		}

		// Update tallest height
		if (height != "auto" && height > tallest) {
			tallest = height;
		}
	});

	// Resize all children to tallest child size
	if ($.browser.msie && $.browser.version == 6.0) { $(this).css("height", tallest); }
	$(this).css("min-height", tallest);

	return this;

};
