<p id="notice"><%= notice %></p>

<h1>Listing messages</h1>
<div class="container">
  <div class="input-append">
    <%= form_for(Message.new) do |f| %>
      <%= f.text_field :message, :autofocus => true %>
      <%= f.hidden_field :date, :value => DateTime.now %>
      <%= f.hidden_field :senderID, :value => current_user.id %>
      <%= f.hidden_field :recipientID, :value => @recipient %>
      <%= f.hidden_field :username, :value => User.select("name").where("id = ?",@recipient).map(&:name)[0] %>
      <%= f.submit "Send", :class=>"btn" %>
    <% end %>
  </div>

  <% @set_of_msg.each do |message| %>
    <div class="span2">
      <%= message.date.strftime("%b %d %I:%M%p") %>:
    </div>
    <div class="span10">
      <%= message.message %> <br>
      <span style="font-size:.7em; color:#a9a9a9;">Sent by: <%= User.select("name").where("id = ?",message.senderID).map(&:name)[0] %></span>
      <br>
    </div>
  <% end %>

</div>

<br />


<%= link_to 'Back', messages_path %>
