<div id="table_title"><%= table.title %></div>
<div id="deck"><%= table.deck %></div>
<div id="controls">
  <% if !table.faceted? %>
    <% if !table.hard_paginate? %>
      <div id="filter">Filter: <input type="text"></div>
    <% end %>
    <div id="pager" class="pager">
      <form>
        <a href="<%= url_for "/#{table.slug}/#{table.prev_page}" if !table.prev_page.nil? %>" class="prev">prev</a>
        <span class="pagedisplay"/><%= "#{table.page} / #{table.total_pages}" if table.hard_paginate? %></span>
        <a href="<%= url_for "/#{table.slug}/#{table.next_page}" if !table.next_page.nil? %>" class="next">next</a>
        <% if !table.hard_paginate? %>
          <select class="pagesize">
            <% (1..4).each do |count|%>
              <option value="<%= table.per_page * count%>">
              <%= table.per_page * count%></option>
            <% end %>
          </select>
        <% end %>
      </form>
    </div>
  <% end %>
</div>
  <table id="data" class="tabular">
    <thead>
      <tr>
      <% if table.faceted? %>
        <th></th>
      <% end %>
      <% table.data.headers.each do |header| %>
        <% unless header.ignored? %>
          <th<%= " style=\"#{header.style}\"" %>><%= header %></th>
        <% end %>
      <% end %>
      </tr>
    </thead>
    <tbody>
      <% if table.faceted? %>
        <% table.facets.each do |facet| %>
          <tr>
            <th style="text-align:left;"><%= facet.faceted_on %></th>
            <% facet.headers.each_with_index do |header, i| %>
              <% unless i == 0 %>
                <th style="<%= header.style %>">
                  <%= facet.total_for(header.to_s).to_s if header.total? %>
                </th>
              <% end %>
            <% end %>
          </tr>
          <% facet.rows.each do |row| %>
            <tr>
              <td></td>
              <% row.columns.each do |column| %>
                <% unless column.ignored? %>
                  <td <%= "style=\"#{column.style}\"" %>><%= column %></td>
                <% end %>
              <% end %>
            </tr>
          <% end %>
        <% end %>
      <% else %>
        <% table.data.rows.each do |row| %>
          <tr>
            <% row.columns.each do |column| %>
              <% unless column.ignored? %>
                <td<%= " style=\"#{column.style}\"" %>><%= column %></td>
              <% end %>
            <% end %>
          </tr>
        <% end %>
      <% end %>
    </tbody>
     <tfoot>
     </tfoot>
  </table>
  <div><%= table.footer %></div>
</div>