$hiddenRows = "<tbody id='hiddendept' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($departments) > 5) {
        $output .= "<div class='nd-more-link'><a href=\"javascript:toggleDisplay('hiddendept');changeLinkText('showmorelinkAg','Departments')\"><div id='showmorelinkAg'>Show more Departments &#187;</div></a></div>";
    }
}
if (count($expenditureCategories) > 0) {
    $output .= "<table id='expcatfilter'>";
    $output .= "<th colspan='3'>By Expense Category</th>";
    $i = 0;
    $displayRows = NULL;
    $hiddenRows = NULL;
    foreach ($expenditureCategories as $key => $value) {
        $checked = $reqCategoryId == $value['object_class_object_class'] ? 'checked' : '';
        $categoryName = _get_shortened_text($value['object_class_object_class_object_class_name']);
        if ($i < 5) {
            $displayRows .= "<tr><td><input type='checkbox' name='fExpCategoryId' {$checked}  value='{$value['object_class_object_class']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$categoryName}</td> <td>{$value['txcount']}</td> </tr>";
        } else {
            $hiddenRows .= "<tr><td><input type='checkbox' name='fExpCategoryId' {$checked}  value='{$value['object_class_object_class']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$categoryName}</td> <td>{$value['txcount']}</td> </tr>";
        }
        $i++;
    }
    if ($displayRows) {
        $displayRows = "<tbody>" . $displayRows . "</tbody>";
    }
    if ($hiddenRows) {
        $hiddenRows = "<tbody id='hiddencat' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($expenditureCategories) > 5) {
        $hiddenRows = "<tbody id='hiddencat' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($expenditureCategories) > 5) {
        $output .= "<div class='nd-more-link'><a href=\"javascript:toggleDisplay('hiddencat');changeLinkText('showmorelinkCat','Expense Categories')\"><div id='showmorelinkCat'>Show more Expense Categories &#187;</div></a></div>";
    }
}
if (count($spendingCategories) > 0) {
    $output .= "<table id='spendexpcatfilter'>";
    $output .= "<th colspan='3'>By Expense Type</th>";
    $i = 0;
    $displayRows = NULL;
    $hiddenRows = NULL;
    foreach ($spendingCategories as $key => $value) {
        $checked = $reqSpendCatId == $value['category_category'] ? 'checked' : '';
        $spendCategoryName = _get_shortened_text($value['category_category_spending_category_name']);
        if ($i < 5) {
            $displayRows .= "<tr><td><input class='styled' type='checkbox' name='fSpendCategoryId' {$checked}  value='{$value['category_category']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$spendCategoryName}</td> <td class=\"results\"><span class=\"results\">" . number_format($value['txcount']) . "</span></td> </tr>";
        } else {
            $hiddenRows .= "<tr><td><input class='styled' type='checkbox' name='fSpendCategoryId' {$checked}  value='{$value['category_category']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$spendCategoryName}</td> <td class=\"results\"><span class=\"results\">" . number_format($value['txcount']) . "</span></td> </tr>";
        }
        $i++;
    }
    if ($displayRows) {
        $displayRows = "<tbody>" . $displayRows . "</tbody>";
    }
    if ($hiddenRows) {
        $hiddenRows = "<tbody id='hiddenspendcat' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($spendingCategories) > 5) {
        $hiddenRows = "<tbody id='hiddencat' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($revenueCategories) > 5) {
        $output .= "<div class='nd-more-link'><a href=\"javascript:toggleDisplay('hiddencat');changeLinkText('showmorelinkCat','Revenue Categories')\"><div id='showmorelinkCat'>Show more Revenue Categories &#187;</div></a></div>";
    }
}
if (count($revenueSources) > 0) {
    $output .= "<table id='revSourcefilter'>";
    $output .= "<th colspan='3'>By Revenue Source</th>";
    $i = 0;
    $displayRows = NULL;
    $hiddenRows = NULL;
    foreach ($revenueSources as $key => $value) {
        $checked = $reqRevSourceId == $value['revenue_source_revenue_source'] ? 'checked' : '';
        $revSourceName = _get_shortened_text($value['revenue_source_revenue_source_revenue_source_name']);
        if ($i < 5) {
            $displayRows .= "<tr><td><input type='checkbox' name='frevenueSourceId' {$checked}  value='{$value['revenue_source_revenue_source']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$revSourceName}</td> <td>{$value['txcount']}</td> </tr>";
        } else {
            $hiddenRows .= "<tr><td><input type='checkbox' name='frevenueSourceId' {$checked}  value='{$value['revenue_source_revenue_source']}' onClick='javascript:applyTableListFilters();'/></td>  <td>{$revSourceName}</td> <td>{$value['txcount']}</td> </tr>";
        }
        $i++;
    }
    if ($displayRows) {
        $displayRows = "<tbody>" . $displayRows . "</tbody>";
    }
    if ($hiddenRows) {
        $hiddenRows = "<tbody id='hiddencat' style='display: none;'>" . $hiddenRows . "</tbody>";
    }
    $output .= $displayRows . $hiddenRows . "</table>";
    if (count($revenueSources) > 5) {