<?php
$subject_id = $PowerBB->_CONF['template']['id'];
$SubjectInfReplyNum = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE subject_id='$subject_id' "));
if ($SubjectInfReplyNum <= $PowerBB->_CONF['info_row']['perpage'])
{
$perpage = '0';
}
else
{
$ss_r = $PowerBB->_CONF['info_row']['perpage']/2;
$roun_ss_r = round($ss_r, 0);
$reply_number = $SubjectInfReplyNum-$roun_ss_r;
$pagenum = $reply_number/$PowerBB->_CONF['info_row']['perpage'];
$round0 = round($pagenum, 0);
$perpage = $round0*$PowerBB->_CONF['info_row']['perpage'];
}
?>
{if {$SectionGroup['write_reply']} == '1'}
{if {$_CONF['info_row']['fastreply_allow']} == 1}
{if {$_CONF['info_row']['ajax_freply']}}
{if {$_CONF['member_permission']}}
<script type='text/javascript'>
//<![CDATA[
function AjaxReply()
{

	var AjaxState = {ajaxSend : $("#status").html("<div class='info_bar'> <img border='0' src='{$image_path}/loading.gif'></div>")};

	var data = {};

	data['title']	=	$("#title_id").val();
	data['text']	=	$("#box_text").val();
	data['icon']	=	$("#fp1").val();
	data['count']	=	$("#count_id").val();
	data['guest_name']	=	$("#guest_name").val();
	data['ajax']	=	1;

	$.post("index.php?page=new_reply&start=1&id={$id}{$password}&count=<?php echo $perpage; ?>",data,function Success(xml) { $("#status").html(xml); });
	data['text']	=	$("#box_text").val('');
	comm._toggle();
}


function Wait()
{
	$("#status").html("{$lang['Ongoing_process']}");
}

function Ready()
{
	$("#reply_id").click(AjaxReply);

}

$(document).ready(Ready);

//]]>
</script>
{/if}

{/if}

<br />

<form name="topic" method="post" action="index.php?page=new_reply&amp;start=1&amp;id={$id}{$password}&amp;count=<?php echo $perpage; ?>">
<table border="0" cellspacing="1" width="98%" class="border" align="center">
	<tr>
		<td class="tcat">
{$lang['fast_reply']}
		</td>
	</tr>
	{if !{$_CONF['member_permission']}}
<tr align="center">
		<td class="row1 rows_space" colspan="2">
		{$lang['Image_Verification']}:&nbsp;&nbsp;
<font size="1">{$lang['Verification']}</font>
<br />
<input name="code" id="code_confirm" type="text" size="7"/>

	&nbsp;&nbsp;<img id="turing" src="includes/captcha.php" width="87" height="17"/>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="updateImg();">{$lang['Image_replacement']}</a>
<script type='text/javascript'>
//<![CDATA[
     var clicks = 0;
     function updateImg()
     {
      clicks++
     var doc = document.getElementById("turing");
     doc.src = "includes/captcha.php" + "?act=" + clicks;
     }
//]]>
</script>
		</td>
	</tr>
<tr align="center">
		<td class="row1 rows_space" colspan="2">
{$lang['Your_name']} <input name="guest_name" id="guest_name" type="text" size="35"/>
		</td>
	</tr>
	{/if}
	<tr align="right">
		<td class="row1">
		{if {$_CONF['info_row']['title_quote']} == 1}
			<input TYPE="hidden"  name="title" id="title_id" type="text" value="{$reply_title}" />
			{else}
			<input TYPE="hidden"  name="title" id="title_id" type="text" value="" />
			{/if}
		</td>
	</tr>
	<tr align="right">
		<td class="row1 rows_space">
	<table border="0" cellspacing="1" width="65%" class="border" cellspacing="1" style="border-collapse: collapse" align="center">
	<tr>
		<td class="row1" valign="top" align="right">
		{if {$_CONF['info_row']['toolbox_show']} == 1}
	{if {$_CONF['info_row']['icons_show']} == 0}
{template}editor_simple{/template}
	{else}
{template}fast_reply_js{/template}
	{/if}

{/if}

<textarea name="text" id="box_text" style="display:block;" class="editoriframemini" tabindex="3"></textarea>
   <script type="text/javascript">
   //<![CDATA[
    comm._toggle();
//]]>
</script>
{if {$_CONF['info_row']['ajax_freply']} == '0'}
	{if {$_CONF['info_row']['allowed_emailed']} == '1' AND {$_CONF['member_permission']}}
			<input name="emailed" type="checkbox" /> <label for="emailed_id">{$lang['Enabled_to_be_notified_by_the_existence_of_new_replies']}</a>
	{/if}
	{/if}
{if {$_CONF['info_row']['smiles_show']} == 1}
<fieldset>
<legend>{$lang['smiles']}</legend>
			{Des::while}{SmileRows}
				<img src="{$SmileRows['smile_path']}" OnClick="AddSmileyIcon('{$SmileRows['smile_path']}');" alt="{$SmileRows['smile_path']}" border="0" cellspacing="1" />
			{/Des::while}
</fieldset>
{/if}
			<input TYPE="hidden" type="radio" value="{$_CONF['info_row']['icon_path']}i1.gif" checked="checked" name="icon" id="fp1" />
			<input TYPE="hidden" name="count" id="count_id" value="<?php echo $perpage; ?>" />
		</td>
	</tr>
</table>

	</tr>
	<tr align="right">
		<td class="row1 rows_space" align="center" valign="top">

			{if {$_CONF['info_row']['ajax_freply']} AND {$_CONF['member_permission']}}
			<input name="insert" class="button" type="button" id="reply_id" value="{$lang['Add_fast_reply']}" onclick="comm._submit();" />
			<input class="button" type="submit" value="{$lang['Jump_to_advanced_editor']}" name="preview" onclick="comm._submit();" />
			{else}
			<input class="button" name="insert" type="submit" value="{$lang['Add_fast_reply']}" onClick="comm._submit();" />
			<input class="button" type="submit" value="{$lang['Jump_to_advanced_editor']}" name="preview" onclick="comm._submit();" />
			{/if}
			</tr>
</table>
 <br />
{if {$_CONF['info_row']['ajax_freply']} == '0'}
{if {$_CONF['info_row']['activate_closestick']} == 1}
{if {$Admin}}
<table border="0" cellspacing="1" width="98%" class="border" align="center">
    <tr>
       <td class="tcat" colspan="2">
       {$lang['Management_options_subject']}
       </td>
    </tr>
    <tr>
       <td class="row2" colspan="2">
          {if {$Info_row['stick']}}
          <input name="unstick" id="stick_id" type="checkbox" /> <label for="stick_id">
          {$lang['unstick_Subject']}
          </label>
          {else}
          <input name="stick" id="stick_id" type="checkbox" /> <label for="stick_id">
          {$lang['Sticky_Topic']}
          </label>
          {/if}
          <br />
          {if {$close}}
          <input name="unclose" id="close_id" type="checkbox" /> <label for="close_id">
          {$lang['open_Subject']}
          </label>
          {else}
          <input name="close" id="close_id" type="checkbox" /> <label for="close_id">
          {$lang['locked_Topic']}
          </label>
          {/if}


       </td>
    </tr>
</table>
{/if}
{/if}
{/if}
<br />
</form>
{/if}
{/if}
<br />
