<!--评论开始-->
<div >
<form method="post" id="comment_form"  >
<input type="hidden" name="pid" id="comment_pid" value="0" />
<input type="hidden" name="object_id" id="comment_object_id" value="<?php echo $this->_var['comment_object_id']; ?>" />
<input type="hidden" name="type_id" id="comment_type_id" value="<?php echo $this->_var['comment_type_id']; ?>" />
<input type="hidden" name="f_userid" id="comment_object_userid" value="<?php echo $this->_var['comment_object_userid']; ?>" />
<input type="hidden" name="referer" id="comment_referer" value="<?php if ($this->_var['comment_referer']): ?><?php echo $this->_var['comment_referer']; ?><?php else: ?><?php echo $_SERVER['REQUEST_URI']; ?><?php endif; ?>" />
 <textarea name="content" id="comment_content"  style="width:90%; height:60px;"></textarea>
    <br /> 
    <input type="button" name="button" id="comment_submit" value="评论" class="btn btn-success" /> 
   

</form>
</div>

<div class="breadcrumb">评论列表：</div>
<div id="comment_list">
<?php if ($this->_var['comment_list']): ?>
<?php $_from = $this->_var['comment_list']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'c');if (count($_from)):
    foreach ($_from AS $this->_var['c']):
?>
<table width="100%" border="0" class="table table-bordered">

	<tr>
    	<td><span class="comment_sortkey red"></span>.<?php if ($this->_var['c']['nickname']): ?> 
        <a href="<?php echo R("/index.php?m=member&a=home&userid=".$this->_var["c"]["userid"]."");?>" target="_blank"><?php echo $this->_var['c']['nickname']; ?> </a><?php else: ?>游客<?php endif; ?>  <span style="float:right">时间：<?php echo date("Y-m-d",$this->_var['c']['dateline']); ?> <a href="javascript:;" class="comment_reply_btn" reply_text="@回复<?php if ($this->_var['c']['nickname']): ?><?php echo $this->_var['c']['nickname']; ?><?php else: ?>游客<?php endif; ?>" pid="<?php echo $this->_var['c']['id']; ?>">回复</a></span></td>
    </tr>
   <tr>
    <td><?php echo $this->_var['c']['content']; ?></td>
   </tr>
   <?php if ($this->_var['c']['child']): ?>
   <?php $_from = $this->_var['c']['child']; if (!is_array($_from) && !is_object($_from)) { $_from=array();}; $this->push_vars('', 'cc');if (count($_from)):
    foreach ($_from AS $this->_var['cc']):
?>
   <tr>
   <td><a href="<?php echo R("/index.php?m=member&a=home&userid=".$this->_var["c"]["userid"]."");?>" target="_blank"><?php echo $this->_var['cc']['nickname']; ?></a>::<?php echo $this->_var['cc']['content']; ?></td>
   </tr>
   <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
   <?php endif; ?>
  
</table>

<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
<?php echo $this->_var['pagelist']; ?>
<?php else: ?>
<h2 id="comment_none">暂无评论</h2>
<?php endif; ?>
</div> 
<script language="javascript">
$(".comment_sortkey").each(function(i){
	$(this).html(i+1);
});
$(function(){
	$("#comment_submit").click(function(){
		$.post("<?php echo $this->_var['comment_post_url']; ?>",$("#comment_form").serialize(),function(data){
			if(data.error==0){
				str='<table width="100%" border="0" class="table table-bordered">'
				+'<tr><td><span class="comment_num red">1</span>.'+(data.message.nickname)+'  <span style="float:right">刚刚</span></td></tr>'
				+'<tr><td>'+data.message.content+'</td></tr></table>';
				$("#comment_list").prepend(str);
				$("#comment_content").val("");
				if($("#comment_none")){
					$("#comment_none").remove();
				}
				$(".comment_sortkey").each(function(i){
					$(this).html(i+2);
				});
			}else{
				alert(data.message)
			}
		},"json")
	})
	
	$(".comment_reply_btn").bind("click",function(){
		
		$("#comment_pid").val($(this).attr("pid"));
		$("#comment_content").focus().val($(this).attr("reply_text") + " ");
	});

});
</script>
<!--评论结束-->