<table id="matches" class="<%= 'contest' if contest %>">
  <tr>
    <% if contest %>
      <th class="contest">Contest</th>
      <th class="opponent">Opponent</th>
    <% else %>
      <th class="opponent">Opponent</th>
    <% end %>
    <th class="date">Date</th>
    <% unless defined? exclude_maps %>
      <th class="maps">Maps</th>
    <% end %>
    <th class="score">Score</th>
    <% if matches.first and matches.first.contest.contest_type == Contest::TYPE_LADDER %>
      <th class="points">Points</th>
    <% end %>
  </tr>

  <% matches.each do |match| %>
    <% match.friendly = friendly %>
    <tr>
      <% if contest %>
        <td>
          <%= namelink match.contest %>
        </td>
      <% end %>
      <td>
        <%= namelink (match.get_opponent.team) %>
      </td>
      <td>
        <%= shorttime match.match_time %>
      </td>
      <% unless defined? exclude_maps %>
        <td>
          <%= match.map1 %>, <%= match.map2 %>
        </td>
      <% end %>
      <td class="score">
        <%= link_to match, :class => "bold #{match.score_color}" do %>
          <% if friendly == match.contester1.team %>
            <%=h match.score1 %> - <%=h match.score2 %>
          <% else %>
            <%=h match.score2 %> - <%=h match.score1 %>
          <% end %>
        <% end %>
      </td>
      <% if match.contest.contest_type == Contest::TYPE_LADDER %>
        <td>
          <% if match.get_friendly(:points) > 0 %>
            <%= icon 'chevron-up' %>
          <% elsif match.get_friendly(:points) < 0 %>
            <%= icon 'chevron-down' %>
          <% end %>
          <%= match.get_friendly(:points) %>
        </td>
      <% end %>
    </tr>
  <% end %>
</table>
