﻿jQuery(document).ready(function () {
    jQuery('#fgTable .fgRow').each(function () {

        if (jQuery(this).children().find('.u_autoheightadjust').length > 0) {
            var maxHeightForRow = 0;

            jQuery(this).children().each(function () {
                var webpartHeight = jQuery(this).height();
                if (webpartHeight > maxHeightForRow)
                    maxHeightForRow = webpartHeight;
            });

            if (maxHeightForRow > 0) {
                jQuery(this).children().each(function () {
                    var webpart = jQuery(this).find('.u_autoheightadjust');
                    var webpartHeight = webpart.height();
                    if (webpartHeight != maxHeightForRow) {
                                    
                        var minHeightAdjustment = 0;
                        if (jQuery(this).hasClass('beige') || jQuery(this).hasClass('gray'))
                            minHeightAdjustment = 8;

                        jQuery(webpart).css('min-height', parseInt(maxHeightForRow) - minHeightAdjustment);
                    }
                });
            }
        }
    });
});        
