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

<% if @dmails.empty? %>
  <p><%= t('.empty') %></p>
<% else %>
  <div class="mail">
    <table width="100%" class="highlightable">
      <thead>
        <tr>
          <th width="15%"><%= t('.table.from') %></th>
          <th width="15%"><%= t('.table.to') %></th>
          <th width="55%"><%= t('.table.title') %></th>
          <th width="15%"><%= t('.table.when') %></th>
        </tr>
      </thead>
      <tbody>
        <% @dmails.each do |dmail| %>
          <tr class="<%= cycle 'even', 'odd' %>" id="row-<%= dmail.id %>">
            <td><%= h dmail.from.name %></td>
            <td><%= h dmail.to.name %></td>
            <td>
              <% if dmail.from_id == @current_user.id %>
                <%= link_to(h(dmail.title), {:action => "show", :id => dmail.id}, :class => "sent") %>
              <% else %>
                <% if dmail.has_seen? %>
                  <%= link_to(h(dmail.title), {:action => "show", :id => dmail.id}, :class => "received") %>
                <% else %>
                  <strong><%= link_to(h(dmail.title), {:action => "show", :id => dmail.id}, :class => "received") %></strong>
                <% end %>
              <% end %>
            </td>
            <td><%= t('time.x_ago', :t => time_ago_in_words(dmail.created_at)) %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
<% end %>

<div id="paginator" style="margin-bottom: 1em;">
  <%= will_paginate(@dmails) %>
</div>

<%= render :partial => "footer" %>
