﻿/*jQuery.fn.vjustify = function() {
    var maxHeight = 0;
    this.each(function() {
        if (this.offsetHeight > maxHeight) { maxHeight = this.offsetHeight; }
    });
    this.each(function() {
        $(this).height(maxHeight + "px");
        if (this.offsetHeight > maxHeight) {
            $(this).height((maxHeight - (this.offsetHeight - maxHeight)) + "px");
        }
    });
};*/

(function($) {
    /**
    * equalizes the heights of all elements in a jQuery collection
    * thanks to John Resig for optimizing this!
    * usage: $("#col1, #col2, #col3").vjustify();
    */

    $.fn.vjustify = function() {
        var height = 0,
			reset = $.browser.msie ? "1%" : "auto";

        return this
			.css("height", reset)
			.each(function() {
			    height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
			    var h = this.offsetHeight;
			    if (h > height) {
			        $(this).css("height", height - (h - height));
			    };
			});

    };

})(jQuery);
