jQuery.fn.equalize = function(options) {
    var elements = $(this), settings = jQuery.extend({
        hw: 'height'
    }, options), max = 0, offset = 0;
    elements.height('').each( function() {
        var c = parseInt($(this).outerHeight()),
			diff = $(this).outerHeight() - $(this).height();
    	$(this).data('equalDiff', diff);
        if (c > max) {
            max = c;
            offset = diff;
        }
    });
    if (max) {
        elements.each( function() {
        	if ('none' === $(this).css('display')) {
        		return;
        	}
			var c = $(this).height(), co = offset - $(this).data('equalDiff');
			if (parseInt($(this).outerHeight()) < max) {
				$(this).height(max - co);
			}
			else if (parseInt($(this).outerHeight()) > max) {
				$(this).height(c);
			}
		}).parents().first().addClass('equal');
	}
    return $(this);
};
jQuery(document).ready( function($) {
	$('#main .box').equalize();
});
