{% extends 'dinette/base.html' %}

{% block title %}
{{ topic.subject }} - {{ block.super }}
{% endblock %}

{% block content %}

{% load thumbnail %} 
{% load pagination_tags %}
{% autopaginate reply_list reply_page_size %}
 
<div id="replybox">
  <div id="actionbox">
  </div>
</div>


<div id="brd-wrap" class="brd">
<div id="brd-index" class="brd-page basic-page">

  {% include 'dinette/header_frag.html' %}
  {% include 'dinette/announce_frag.html' %}

  <p></p>

  <div class="hr"><hr/></div>
  <div id="errorbox"> <span>  </span>  </div>

  <!-- bread crumbs begin -->
  <div id="brd-crumbs-top" class="crumbs gen-content">
    <p>
	  <span class="crumb crumbfirst">
	    <a href="{% url dinette_category %}">{{ config.name }}</a>
	  </span> 
	  <span class="crumb">
		<span> &raquo; </span>
		<a href="{{ topic.category.get_absolute_url }}">{{ topic.category.name }}</a>
	  </span> 
	  <span class="crumb crumblast">
		<span> &raquo; </span>
		<a href="{{ topic.get_absolute_url }}">{{ topic.subject }} </a>
	  </span> 
	  
	  &nbsp; &nbsp;
	  {% if not topic.is_closed %}
	  {% if user.is_authenticated %}
		<a href="" onclick="return isUserAuthenticated(1)">Post Reply</a> &nbsp; &nbsp;
	  {% else %}
		(<a href="{% url dinette_login %}?next={{ topic.get_absolute_url }}">Login to Post Reply</a>) &nbsp; &nbsp;
	  {% endif %}
	  {% endif %}
         
	  {% if reply_list.has_next %}
		<a href="{% url dinette_reply_detail_paged  topic.category.slug topic.slug   reply_list.next_page_number %}"> Next </a>              
	  {% endif %}
         
	  {% if reply_list.has_previous %}
		<a href="{% url dinette_reply_detail_paged  topic.category.slug topic.slug  reply_list.previous_page_number %}"> Previous </a>
	  {% endif %}   &nbsp;
	</p>  
  </div>
  <!-- bread crumbs end -->
	
  <!-- main head begins -->
  <div class="main-head">
	<p class="options">
	  <span class="feed first-item">
		<a class="feed-option" href="{% url dinette_topic_url topic.getTopicString %}">RSS Topic Feed</a>
	  </span>
	</p>
	<h2 class="hn"><span><span class="item-info">Posts </span></span></h2>
	{% if show_moderation_items %}
	  {% include 'dinette/moderation_frag.html' %}
	{% endif %}
  </div>
  <!-- main head ends -->
	
  <!-- reply list begins -->
  <div id="replylist" class="main-content main-topic">
	{% ifequal request.page 1 %}
	  <!--post odd reply list begins -->
	  <div class="post odd replypost">
	    <div id="p{{ topic.pk }}" class="posthead">
		  <h3 class="hn post-ident">
			<span class="post-num"> </span> 
			<span class="post-byline">
			  <span>Reply by </span>
			  <a title="" href=""></a>
			</span> 
			<span class="post-link" id="t{{topic.id}}">
			  <a class="permalink" rel="bookmark" title="Permanent link to this post" href="#t{{ topic.id }}">{{ topic.created_on|date:"jS F Y H:i A" }}</a>
			</span>   &nbsp; &nbsp; &nbsp; 
		  </h3>
		</div>
			
		<!-- post body begins -->
		<div class="postbody">
		  <!-- author details begins -->
		  <div class="post-author">
			<ul class="author-ident">
			  <li>
				<table class="authortable">
				  <tr><td >
					{% if topic.posted_by.photo  %}
					  <img src="{% thumbnail topic.posted_by.get_profile.photo 80x80 %}" />                                                    
					{% else %}                                                        
					  <img src="http://www.gravatar.com/avatar/{{topic.posted_by.get_profile.getMD5}}.jpg" alt="" />
					{% endif %}  
				  </td></tr>
				  <tr><td>
					<a href="{{ topic.posted_by.get_profile.get_absolute_url }}">{{topic.posted_by.username}}</a>
				  </td></tr>
				</table>                                                        
			  </li>
                                                
			  <li class="usertitle"><span>{{ topic.posted_by.get_profile.userrank }}</span></li>
			  <li class="userstatus"><span>
			  {% if topic.posted_by.get_profile.is_online %}
				Online
			  {% else %}
				Offline
			  {% endif %}
			  </span></li>
			</ul>
			<ul class="author-info">
			  <li><span>Registered: <strong> {{ topic.posted_by.date_joined|date:"jS F Y H:i A" }}</strong></span></li>
			  <li><span>Posts: <strong> {{ topic.posted_by.get_profile.get_total_posts  }}</strong></span></li>
			</ul>
		  </div>
		  <!-- author details ends -->

		  <div class="post-entry">
			<h4 id="pc{{ reply.pk }}" class="entry-title hn">Re: {{reply.topic.subject}}</h4>
			<div class="entry-content">
			  <p>  {{ topic.message }} </p>
			  {% with topic as rtopic %}    
				{% include 'dinette/attachement_frag.html' %}     
			  {% endwith %}     
			</div>
		  </div>
		</div>
		<!-- post body ends -->
	  </div>
	  <!-- post odd reply list ends -->
	{% endifequal %}    

	{% for reply in reply_list %}
	  {% include 'dinette/replydetail_frag.html' %}
	{% endfor %}
  </div>
		
  <div  id="belowpostreplybox" class="crumbs gen-content">	
  	
	{% if not topic.is_closed %}
	  {% if user.is_authenticated %}
		<a href="#" onclick="return isUserAuthenticated(2)">Post Reply</a> &nbsp; &nbsp;
	  {% else %}
		(<a href="{% url dinette_login %}?next={{ topic.get_absolute_url }}">Login to Post Reply</a>) &nbsp; &nbsp;
	  {% endif %}
	  {% endif %}
	
	<span style='float: right;'>
	 {% paginate %}
	</span>
  </div>
  
  {% if not topic.is_closed and user.is_authenticated %}
  <!-- formbox begins -->
  <div id="formbox" class="magicbox">
	<form action="{% url dinette_postreply %}" method="POST" id="fpostreply"  >            
	  <table>
		<tbody> 
		  {{ replyform.as_table }}
		  <tr>
			<th> </th>
			<td>
			  <input type="submit" value="Post Reply" onClick="return check_errors_in_Replyform()" />
			  &nbsp; <span class="closebutton"> <a href="" onclick="return hideForm()">close</a>  </span>
			</td>
		  </tr>
		</tbody>
	  </table>
	  <input type="hidden" name="authenticated"  value="{{ user.is_authenticated }}" />
	  <input type="hidden"  name="topicid"  value="{{topic.id}}" />
	</form>
  </div>   
  <!-- formbox ends -->
  {% endif %}
	
  <div class="hr"><hr /></div>
  {{ block.super }}
</div>
</div>
{% endblock %}
