<div id="post_<%= post.id %>" class="post">
  <div class="avatar" rowspan="2">
    <h5>
      <%= link_to post.user, post.user, class: ("admin" if post.user.admin?) %>
    </h5>

    <div class="image">
      <%= image_tag post.user.profile.avatar.url %>  
    </div>

    <% if post.user.team %>
      <strong><%= namelink post.user.team %></strong>
    <% end %>

    <dl>
      <% if post.user.groups.count > 0 %>
      <dd>
        <% if post.user.admin?%>
          <dt><%= namelink Group.find(Group::ADMINS) %></dt>
          <dd><%=  post.user.groupers.where(:group_id => Group::ADMINS).first.task %></dd>
        <% elsif post.user.staff?%>
          <dt><%= namelink Group.find(Group::STAFF) %></dt>
          <dd><%=  post.user.groupers.where(:group_id => Group::STAFF).first.task %></dd>
        <% elsif post.user.caster?%>
          <dt><%= namelink Group.find(Group::CASTERS) %></dt>
          <dd><%=  post.user.groupers.where(:group_id => Group::CASTERS).first.task %></dd>
        <% elsif post.user.ref?%>
          <dt><%= namelink Group.find(Group::REFEREES) %></dt>
          <dd><%=  post.user.groupers.where(:group_id => Group::REFEREES).first.task %></dd>
        <% else %>
          <dt><%= namelink Group.find(post.user.groupers.first.group_id) %></dt>
          <dd><%=  post.user.groupers.first.task %></dd>
      <% end %>
      </dd>
      <% end %>
      <dt>Posts</dt>
      <dd><%= post.user.posts.count %></dd>
      <dt>Location</dt>
      <dd><%= post.user.from %></dd>
      <dt>Joined</dt>
      <dd><%= longdate post.user.created_at %></dd>
    </dl>
  </div>

  <div class="content">
    <div class="header">
      <div class="time">
        <span id="post_<%= post.id %>">
          <%= longertime post.created_at %>
        </span>
      </div>
      <div class="posts">
        <%= link_to "##{post.number(@posts, n)}", "#post_#{post.id}" %>
      </div>
    </div>

    <div class="text">
      <%= post.text_parsed.html_safe %>  
    </div>
  </div>

  <div class="base">
    <div class="user">
      <%= link_to "Send PM", { controller: "messages", action: "new", id: "User", id2: post.user }, class: 'button tiny' %>  
    </div>
    
    <div class="signature">
      <%= post.user.profile.signature_parsed.html_safe if post.user.profile.signature_parsed %>
      
      <div class="controls">
        <% if post.topic.posts.build.can_create? cuser %>
          <%= link_to_function 'Quote Reply', "QuoteText(#{post.id}); $('#reply').fadeIn('slow')", class: 'button tiny' %>
        <% end %>
        <% if post.can_update? cuser %>
          <%= link_to 'Edit', edit_post_path(post), class: 'button tiny' %>
        <% end %>
        <% if post.can_destroy? cuser %>
          <%= link_to 'Delete', post, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
        <% end %>
      </div>
    </div>
  </div>
</div>
