/**
 * jQuery.synchHeights plugin v1.0
 * Copyright 2010, Roger Padilla - @rogerjose81@gmail.com
 * Dual licensed under the MIT or LGPL Version 2 licenses.
 * This plugin is intended to synchronize the heights of the elements matched
 * by the given CSS selector. The functionality of this plugin is very simple,
 * it just assigns the tallest element's height to all the elements in the set.
 */
$.fn.synchHeights = function() {

    // the 'this' object is a jQuery object which keep reference to DOM-elements in the set
    var self = this;
    var item;
    var maxHeight = 0;

    // loops through each element in the set in order to obtain the height of the
    // tallest element in the set
    this.each(function(index){
        item = $(this);
        if (item.height() > maxHeight) {
            maxHeight = item.height();
        }
    });

    // call the function used to synchronize the heights
    synchHeights();

    /*
     * Synchronizes the heights of the elements in the set by using
     * the calculated maximun-height
     */
    function synchHeights() {
        // for ie6, set height since min-height isn't supported
        if ($.browser.msie && $.browser.version == 6.0) {
            self.css({'height': maxHeight});
        }
        self.css({'min-height': maxHeight});
    }

    // returns 'this' to be able to use chaining selectors
    return this;
};

