{% extends "django_messages/base.html" %}
{% load i18n %}
{% load avatar_tags %}

{% block body %}
 <div class="prefix_1 grid_10">
    <h2>
        {{ thread.subject }}
    </h2>
     <span class="sub-page-header">
        {% blocktrans with participant.user.get_absolute_url as sender_url %}
        A message between <a href="{{ sender_url }}">You</a> and
        {% endblocktrans %}
         {% for participant in participant.others %}
            <a href="{{ participant.user.get_absolute_url }}">{{ participant.user }}</a>
         {% endfor %}
     </span>
    <div style="clear: both;"></div>
    <div class="inbox-bar">
        <div class="page-search">
          <form action="{% url messages_search %}" method="GET">
            <input name="q" type="text" title="{% trans 'Search Messages' %}" />
            <button type="submit" class="lupe-on-white"></button>
          </form>
        </div>
        <a href="{% url modal_messages_compose %}" class="small-green-button" rel="facebox">
           {% trans "create message" %}
        </a>

        <a href="{% url messages_delete thread.pk %}" class="small-green-button">
           {% trans "delete" %}
        </a>
        
        <div style="clear: left;"></div>
        <a href="{% url messages_inbox %}" class="back">
             &lt; {% trans "back to inbox" %}
        </a>
        <div style="clear: both;"></div>
    </div>
    <hr />


    <div class="message-thread">
      <div class="message-list">
        {% for message_tuple in message_list %}
          {% with message_tuple.0 as message %}
            {% include "django_messages/message_list_view.html" %}
          {% endwith %}
        {% endfor %}
      </div>
      <div class="messageReplyForm message-form">
        <div class="avatar">{% avatar request.user 50 %}</div>
        <form method="POST" class="reply-form" action="{% url message_reply thread.pk %}">
          {% csrf_token %}
          <h3>{% trans "Reply" %}</h3>

          {{ form.body }}
          <button class="green-button">{% trans "Reply" %}</button>
          <div style="clear: both;"></div>
        </form>
        <div style="clear: both;"></div>
      </div>
      <a href="{% url messages_inbox %}" class="back">
        &lt; {% trans "back to inbox" %}
      </a>
    </div>
</div>
{% endblock %}

{% block extra_body %}
    {{ block.super }}
    <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}js/jquery.form.js"></script>
     <script type="text/javascript">
         $(document).ready(function(){
             $('.reply-form').ajaxForm({
                 //target: "target",
                 beforeSubmit: function (){
                     $('.reply-form').addClass("ajax-form-disabled")
                 },
                 success: function(data){
                     $('.reply-form').removeClass("ajax-form-disabled")
                     $('.message-list').append(data)
                     resetForm()
                 }
             })
         })
     </script>
{% endblock %}