function formatTables() {
    var largest = new Array();
    
    $('.tablediv table tr th').each(function() {
        var th = $(this).attr('columnNumber');
        if (largest[th] < $(this)[0].offsetWidth || largest[th] == null)
            largest[th] = $(this)[0].offsetWidth;
    });

    $('.tablediv table tr th').each(function() { $(this).removeAttr('width'); });
    var totalWidth = 0;
    largest.forEach(function(el, i, array) {
    totalWidth += el;
    $('.tablediv table tr th').each(function() {
            if ($(this).attr('columnNumber') == i) 
                $(this).width(el);
        });
    });

    $('.tablediv table').each(function() { $(this).width(totalWidth); });
}

window.afterInitTable = function () {    
    InitResizableGrid('table.resizable-grid', getHeightTableHolder(160));
    InitGridMenu = function($menu) {
        if ($menu) {
            $menu.find('li.grid-filter').remove();
            $menu.find('li.grid-column-settings').remove();
            $menu.prepend($('<li class="grid-column-settings" onclick="return loadSettings();">' + GridMenuResources.ReportOptions + '</li>'));
        }
    };

    var isFilterShow = $.cookie("tb_taskfiltersetting");
    if (isFilterShow == undefined) {
        isFilterShow = $("#defaultfilterfortasklist").val();
    }

    if (isFilterShow != undefined) {
        if (isFilterShow != "True") {
            $('#pagination').css("right", "35px");
        }
    }
};

function editReportSettings(stateId, isCommonFilter) {
    $('#filtercontrol').remove();

    if ($('#reportfilterholder #filter').length > 0) {
        $('#reportfilterholder #filter').remove();
    }
    if ($('#reportfilterholder #columns').length > 0) {
        $('#reportfilterholder #columns').remove();
    }

    if ($('#reportfilterholder #groups').length > 0) {
        $('#reportfilterholder #groups').remove();
    }

    var urlf = base + tableController() + 'EditFilter';
    $('#rfilterholder').load(urlf, { timestamp: new Date().toDateString(), customPath: true, stateid: stateId, fill: true }, function () {
        initFilter(true);

        if (isCommonFilter != 'undefined' && isCommonFilter)
            $('#filter form').append('<input class="hidden" id="commonfilter" name="commonfilter">');
    });

    var urlg = base + tableController() + 'EditGroup';
    $('#rgroupholder').load(urlg, { timestamp: new Date().toString(), stateid: stateId }, initGroup);    

    var urlc = base + tableController() + 'EditColumns';
    $('#rcolumnsholder').load(urlc, { timestamp: new Date().toDateString(), customPath: true, stateid: stateId }, function () { initColumns(); $('#tb_group_field').change(checkForDate); $('#reportfilterholder').show(); });
    return false;
}