function DisplayStatTable($startbody = 1)
{
    global $stats_tables, $tableclasses;
    DisplayStatsHeader($startbody);
    foreach (array_keys($stats_tables) as $sectionname) {
        echo "<a href='#{$sectionname}'>{$sectionname}</a><br>\n";
    }
    foreach ($stats_tables as $sectionname => $sectiondata) {
        echo "\t\t<a id='{$sectionname}'><h2>{$sectionname}</h2></a>\n\t\t<table class='display row-border' id='table-{$sectionname}' width='100%'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n";
        if ($sectionname != 'Teams') {
            echo "\t\t\t\t\t<th>Cmp</th>\n";
        }
        foreach ($sectiondata['fields'] as $fieldname => $show) {
            if (!$show) {
                continue;
            }
            echo "\t\t\t\t\t<th>{$fieldname}</th>\n";
        }
        echo "\t\t\t</tr>\n\t\t\t </thead>\n\t\t\t <tbody>\n";
        foreach ($sectiondata['items'] as $itemname => $itemdata) {
            if ($sectionname != 'Teams') {
                $sel = '';
                if (isset($_REQUEST["compare-{$sectionname}"])) {
                    $_REQUEST["compare_{$sectionname}"] = $_REQUEST["compare-{$sectionname}"];
                }
                if (isset($_REQUEST["compare_{$sectionname}"])) {
                    if (!in_array($itemname, $_REQUEST["compare_{$sectionname}"])) {
                        continue;
                    } else {
                        $sel = ' CHECKED';
                    }
                }
                echo "\t\t\t<tr><td><input type='checkbox' name='compare_{$sectionname}[]' value='{$itemname}'{$sel}></td>\n";
            }
            foreach ($sectiondata['fields'] as $fieldname => $show) {
                if (!$show) {
                    continue;
                }
                echo "\t\t\t\t<td";
                $fd = $itemdata[$fieldname];
                if ($fieldname == 'Name') {
                    if (isset($itemdata['Img'])) {
                        echo $itemdata['Img'];
                    } else {
                        echo " class='vgui'";
                    }
                    $fd = "<a href='stats.php?showitem={$itemname}&amp;showtype={$sectionname}' id='{$itemname}' target='_blank'>{$itemname}<br>{$fd}</a>";
                }
                echo ">{$fd}</td>\n";
            }
            echo "\t\t\t</tr>\n";
        }
        echo "</tbody></table>\n";
    }
}
function DisplayTheaterCompare()
{
    global $theater, $mod, $theaterfile, $theaterpath, $version, $mod_compare, $theaterfile_compare, $theaterpath_compare, $version_compare;
    $theater_compare = ParseTheaterFile("{$theaterfile_compare}.theater", $mod_compare, $version_compare, $theaterpath_compare);
    $index = "{$version}/{$theaterfile}";
    $index_compare = "{$version_compare}/{$theaterfile_compare}";
    $changes = multi_diff($index, $theater, $index_compare, $theater_compare);
    DisplayStatsHeader();
    echo "<table border='1' cellpadding='2' cellspacing='0'><tr><th>Setting</th><th>{$index}</th><th>{$index_compare}</th></tr>\n";
    $sections = array();
    foreach ($changes as $name => $data) {
        $sections[] = $name;
        if (isset($data[$index]) || isset($data[$index_compare])) {
            echo "<tr><td>" . implode("/", $sections) . "</td>";
            echo "<td>" . printval($data, $index, 0, '-') . "</td>\n";
            echo "<td>" . printval($data, $index_compare, 0, '-') . "</td>\n";
            echo "</tr>\n";
        } else {
            DisplayCompare($data, $sections, $index, $index_compare);
        }
        array_pop($sections);
    }
    closePage(1);
}