$li_classes = array(1 => 'first', 2 => 'second', 3 => 'third');
for ($i = 0; $i < 3; ++$i) {
    ?>
	<div class="column top-<?php 
    echo $formats[$i] . 'v' . $formats[$i];
    ?>
">
		<h2><a href="<?php 
    echo WoW::GetWoWPath() . '/wow/' . WoW_Locale::GetLocale() . '/pvp/arena/' . mb_strtolower($bg['name']) . '/' . $formats[$i] . 'v' . $formats[$i] . '/';
    ?>
"><?php 
    echo sprintf(WoW_Locale::GetString('template_team_type_format'), $formats[$i], $formats[$i]);
    ?>
</a></h2>
        <?php 
    $top_teams = WoW_Arena::GetTopTeams($formats[$i], $active_bg['id']);
    if (is_array($top_teams)) {
        echo '<ul>';
        foreach ($top_teams as &$team) {
            echo '<li class="' . $li_classes[$team->GetTeamRank()] . '">
                <span class="ranking">' . $team->GetTeamRank() . '</span>
                
                <div class="name">
                    <a href="' . $team->GetTeamURL() . '">' . $team->GetTeamName() . '</a>
                </div>
                <div class="rating-realm">
                    <span class="rating">' . $team->GetTeamRating() . '</span>
                    <span class="realm">' . $team->GetTeamRealmName() . '</span>
                </div>
                <div class="members">
                ';
/<?php 
echo WoW_Template::GetPageData('teamFormatS');
?>
"><?php 
echo WoW_Locale::GetString('template_guild_roster_reset_filter');
?>
</a>
		</div>
			</form>
	<div id="ladders">
	<div class="table-options">
    <div class="option">

            <?php 
$teams = WoW_Arena::GetTopTeams($format, $bg['id'], 50, $offset);
$total_count = WoW_Arena::GetTopTeams($format, $bg['id'], 0, 0, true);
$pagination = '<ul class="ui-pagination">';
$start = ($page - 1) * 50;
$prev = $page - 1;
$next = $page + 1;
$total_pages = ceil($total_count / 50);
$pagination = '';
$display_min = ($page - 1) * 50 + 1;
$display_max = min($page * 50, $total_count);
if ($page > 1) {
    $pagination .= sprintf('<li class="cap-item">
                    <a href="%spage=%d">
                        %s
                    </a>
                </li>
            ', $global_url, $prev, WoW_Locale::GetString('template_item_table_prev'));