<h4><%= t('.title') %></h4>

<%= form_tag update_multiple_advertisements_path do |f| %>
  <% ads = [] %>
  <table>
    <thead>
      <tr>
        <th class="center"><%= check_box_tag('check_all', 'check_all', false, :onClick => "checkbox_toggle(this, 'advertisement_ids[]');") %></th>
        <th>#</th>
        <th><%= Advertisement.human_attribute_name :image_url %></th>
        <th><%= Advertisement.human_attribute_name :referral_url %></th>
        <th><%= Advertisement.human_attribute_name :width %></th>
        <th><%= Advertisement.human_attribute_name :height %></th>
        <th><%= Advertisement.human_attribute_name :ad_type %></th>
        <th><%= Advertisement.human_attribute_name :status %></th>
        <th><%= Advertisement.human_attribute_name :hit_count %></th>
        <th></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @ads.each do |ad| %>
        <tr>
          <td class="center"><%= check_box_tag 'advertisement_ids[]', ad.id %></td>
          <td><%= link_to(ad.id, ad) %></td>
          <td><%= link_to(ad.image_url, ad.image_url) %></td>
          <td><%= link_to(ad.referral_url, ad.referral_url) %></td>
          <td><%= ad.width %></td>
          <td><%= ad.height %></td>
          <td><%= ad.ad_type %></td>
          <td><%= ad.status %></td>
          <td><%= ad.hit_count %></td>
          <td><%= link_to t('buttons.edit'), edit_advertisement_path(ad) %></td>
          <td><%= link_to t('buttons.delete'), ad, :data => { :confirm => t('confirmations.is_sure') }, :method => :delete %></td>
        </tr>
      <% end %>
    </tbody>
  </table>

  <%= submit_tag t('.reset_hit_count'), :name => 'do_reset_hit_count' %>
  <%= submit_tag t('buttons.delete'), :name => 'do_delete' %>
<% end %>

<%= link_to t('buttons.add'), new_advertisement_path %>
<%= will_paginate(@ads) %>

<script type="text/javascript">
  function checkbox_toggle(source, name) {
    checkboxes = document.getElementsByName(name);
    for(var i in checkboxes)
      checkboxes[i].checked = source.checked;
  }
</script>
