﻿/**
*   Function to set defined properties of items to maximum.
*   Properties are function of dom object in jquery as width(), height()
*   or in 1.3.x outerWidth(), etc.
*   Use: To set the height of divs to the heightest to align nicely
*   
*   by Balazs Suhajda @ Valtech [31/10/2009]
*/

(function($){  
 $.fn.equate = function(options) {
    var elms = this;
    var defaults = {
        compare : 'height' //comma seperated properties to compare and set to max
    };
    var options = $.extend(defaults, options);
    var max = [];
    var properties = options.compare.split(',');
    $.each(properties, function(i, prop) {
        max[prop] = 0;
        $.each(elms, function(i, el) {
            if ($(el)[prop]() > max[prop]) max[prop] = $(this)[prop]();
        });
    });
    return $.each(properties, function(i, prop) {
        $.each(elms, function(i, el) {
            $(el)[prop](max[prop]);
        });
    });  
 };  
})(jQuery);