{template 'header.html'}
<link href="{$skin_path}/css/comment.css" rel="stylesheet">
<!-- 面包屑导航开始 -->
{template 'position.html'}
<!-- 面包屑导航结束 -->
{if config::get('reply_comment')=='1'}
<!-- 评论框开始 -->
 
<script src="{$base_url}/js/layer/layer.js"></script>
<script type="text/javascript" src="{$base_url}/js/pagenav1.1.cn.js"></script>
<script type="text/javascript">

function getcommentdata(p){
	$.ajax({
	   type: "get",
	   url: "<?php echo url('comment/ajax/aid/'.$aid); ?>",
	   dataType: 'json',
	   data: "p="+p,
	   success: function(msg){
		 //console.log(msg);
		 $('#comment_list').empty();
		 for(row in msg){
			//console.log(msg[row]); 
			$('#comment_list').append("<li><div class='h'><span class='name'>"+msg[row].username+"</span><span class='date'>"+msg[row].adddate+"</span></div><div class='p'>"+msg[row].content+"</div><div class='f'><span class='zan_btn' data-aid='<?php echo $aid; ?>' data-cid='"+msg[row].id+"'>{lang(praise)}[<i id='zan_"+msg[row].id+"'>"+msg[row].zannum+"</i>]</span><span class='reply_btn' id='reply_btn_"+msg[row].id+"' data-raid='<?php echo $aid; ?>' data-rcid='"+msg[row].id+"'>{lang(reply)}</span></div><div class='clear'></div></li>");
			//<div style='display:none;' id='rcid_"+msg[row].id+"'><textarea id='trid_"+msg[row].id+"' name='content' rows='6' cols='50'></textarea><br /><input name='submit' value='发表回复' type='button' data-baid='<?php echo $archive['aid']; ?>' data-brid='"+msg[row].id+"' class='re_btn' /></div>
		 }
		 $('.zan_btn').click(function(e) {
			var id = $(this).data('cid');
			var aid = $(this).data('aid');
			$.get("{url('comment/zan')}",{"id":id,"aid":aid},function(data){
				if(data != "unsign"){
					alert('{lang(point-like)}{lang(success)}');
					$('#zan_'+id).html(data);	
				}else{
					alert('{lang(not_logged)}');	
				}
			});
			//console.log(aid);
		});
		
		$('.reply_btn').click(function(){
			var rcid = $(this).data('rcid');
			var raid = $(this).data('raid');
			
			layer.open({
				type: 1,
				skin: 'layui-layer-rim', //加上边框
				 title: '{lang(submit_on)}{lang(reply)}',
				area: ['300px', '300px'], //宽高
				content: "<div class='reply-info'><form id='frmreply' action='<?php echo url('comment/reply');?>' method='post' name='frmreply'><textarea name='content' class='reply-textarea' style='width:256px;height:120px; padding:10px; '></textarea><input name='aid' value='"+raid+"' type='hidden' /><input name='rid' value='"+rcid+"' type='hidden' /><div class='blank10'></div><input name='button' value='{lang(submit_on)}{lang(reply)}' type='submit' class='btn' style='width:278px;' id='re_btn' /></div>"
			});
			
		});
		$('.re_btn').click(function(e) {
            var brid = $(this).data('brid');
			var baid = $(this).data('baid');
			var content = $('#trid_'+brid).val();
			if(content == ''){
				alert('{lang(please_fill_in_the_content)}');
				$('#trid_'+brid).focus();
				return;	
			}else{
				$.post("{url('comment/reply')}",{"rid":brid,"aid":baid,"content":content},function(data){
					if(data != "unsign"){
						alert('{lang(reply)}{lang(success)}');
						//$('#zan_'+id).html(data);	
						getcommentdata(1);
					}else{
						alert('{lang(not_logged)}');	
					}
				});
			}
        });
	   }
	});
}

//$(function(){ //for jquery
$(function(){
	//getcommentdata(1);
	//optional set
	pageNav.pre="{lang(uppage)}";
	pageNav.next="{lang(downpage)}";
	

	 //  p,当前页码,pn,总页面
	pageNav.fn = function(p,pn){
		//document.getElementById("test").innerHTML ="当前页:"+p+"  ,  总页: "+pn;
		//$("#test").text("Page:"+p+" of "+pn + " pages."); // jquery调用方式
		getcommentdata(p);
	};
	
	//重写分页状态,跳到第三页,总页33页
	pageNav.go(1,{$pages});
	
	

});

  </script>
<script src="{$base_url}/js/mobilechk.js"></script>

<div class="blank30"></div>


<!-- 页面标题开始 -->
<div class="title">
	<div class="container">
	<h3>{lang(comment)}</h3>
	<p>Comment</p>
	</div>
</div>
<!-- 页面标题结束 -->



<div class="container">
<?php
if(front::$user['userid']){
?>

<div class="comm">
<form action="<?php echo url('comment/add'); ?>" method="POST" name="comment_form" id="comment">
<div class="blank10"></div>
<input type="hidden" name="aid" value="{$aid}"/>
<input type="hidden" name="username" class="comm_name" value="<?php echo front::$user['userid'];?>" />
<input type="hidden" name="username" class="comm_name" value="<?php echo front::$user['username'];?>" />
<div class="blank10"></div>
{if config::get('mobilechk_enable') && config::get('mobilechk_comment')}
<script src="{$base_url}/js/mobilechk.js"></script>
{lang(tel)} Tel
<div class="blank10"></div>
<input type="text" class="comm_name" name="telphone" id="telphone" />
<div class="blank10"></div>
{lang(phone_verification_code)}
<div class="blank10"></div>
<input id="btm_sendMobileCode" onclick="sendMobileCode('{url('tool/smscode')}',$('#telphone'));" type="button" value="{lang(send_cell_phone_verification_code)}" />
<input type='text' id="mobilenum"  tabindex="4" placeholder="	{lang(please_enter_the_phone_verification_code)}	"  name="mobilenum" />
<div class="blank10"></div>
{/if}

<div class="blank10"></div>
{lang(comment)} Comment
<div class="blank10"></div>
<textarea name="content" id="textarea"  ></textarea>



<div class="blank30"></div>
<input name="submit" class="btn" value=" {lang('submit_on')} " type="submit" />
<div class="blank30"></div>

<div class="comment_info">
<span class="commentnumber">{lang('have')}({comment::countcomment($aid)}){lang(bitofcommenters)}{lang('clicktoview')}</span>
</div>
</form>
<div class="blank60"></div>
</div>
</div>
<?php
}else{
?>
<div class="blank60"></div>
<input type="button" value=" {lang(please)}{lang(login)} " onclick="window.open('{url('user/login')}')" class="btn" />
<?php
}
?>


<div class="blank30"></div>
{if config::get('comment_list')=='1'} 
<!-- 页面标题开始 -->


<!-- 页面标题开始 -->
<div class="title">
	<div class="container">
	<h3>{lang('commentlist')}</h3>
	<p>Comment List</p>
	</div>
</div>
<!-- 页面标题结束 -->


<div class="clear blank30"></div>
<div class="container">
<!-- 评论列表开始 -->
<div id="comment_list"></div>
<div id="pageNav"></div>
<!-- 评论列表结束 -->
<div class="clear blank30"></div>
</div>
{else}
<!-- 页面标题开始 -->
<div class="title">
	<div class="container">
<h3>{lang(commentlist)}{lang(close)}</h3>
<p>Comment List</p>
	</div>
</div>
<!-- 页面标题结束 -->

{/if}
<div class="clear blank30"></div>

{else}



<!-- 评论框开始 -->



<!-- 页面标题开始 -->
<div class="title">
	<div class="container">
	<h3>{lang(comment)}</h3>
	<p>Comment</p>
	</div>
</div>

<!-- 页面标题结束 -->

<div class="container">

<div class="blank30"></div>

<form action="<?php echo url('comment/add'); ?>" method="POST" name="comment_form" id="comment">
<div class="comm">


<div class="blank10"></div>
		<input type="hidden" name="aid" value="{$aid}"/>

		<div class="form-group">
<label for="{lang(ordertel)}">{lang('username')}</label>
<input type="text" class="form-control comm_name" name="username" value="<?php echo get('username');?>" placeholder="" />
</div>


		{if config::get('mobilechk_enable') && config::get('mobilechk_comment')}
		<script src="{$base_url}/js/mobilechk.js"></script>
		{lang(tel)} Tel
		<div class="blank10"></div>
		<input type="text" class="comm_name" name="telphone" id="telphone" />
		<div class="blank10"></div>
		{lang(phone_verification_code)}
		<div class="blank10"></div>
		<input id="btm_sendMobileCode" onclick="sendMobileCode('{url('tool/smscode')}',$('#telphone'));" type="button" value="{lang(send_cell_phone_verification_code)}" />
		<input type='text' id="mobilenum"  tabindex="4" placeholder="	{lang(please_enter_the_phone_verification_code)}	"  name="mobilenum" />
		<div class="blank10"></div>
		{/if}

<div class="form-group">
<label for="{lang(ordertel)}">{lang(comment)}</label>
<textarea name="content" id="textarea" class="form-control" rows="3" ></textarea>
</div>


{if config::get('verifycode')=='1'}
		<div class="balnk10"></div>
		{lang('verifycode')}
		<div class="blank20"></div>
		<input type='text' id="verify"  tabindex="3"  name="verify" />{verify()}
		<div class="balnk10"></div>
		{/if}

		{if config::get('verifycode')=='2'}
		<div class="blank20"></div>
		<div id="verifycode_embed"></div>
		<script src="http://api.geetest.com/get.php"></script>
		<script>
		var loadGeetest = function(config) {
			window.gt_captcha_obj = new window.Geetest({
				gt : config.gt,
				challenge : config.challenge,
				product : 'float',
				offline : !config.success
			});
			gt_captcha_obj.appendTo("#verifycode_embed");
		};

		$.ajax({
			url : '{url('tool/geetest',0)}',
			type : "get",
			dataType : 'JSON',
			success : function(result) {
				//console.log(result);
				loadGeetest(result)
			}
		});
		</script>
		{/if}

		<div class="blank30"></div>
		<input name="submit" class="btn" value=" {lang('submit_on')} " type="submit" />
		<div class="blank30"></div>

		<div class="comment_info">
		{if $topid==0}{else}<a rel="nofollow" href="<?php echo url('comment/list/aid/'.$archive['aid']); ?>">{/if}{lang('have')}<span class="commentnumber">({comment::countcomment($archive['aid'])})</span>{lang(bitofcommenters)}&nbsp;&nbsp;<strong>{lang('clicktoview')}</strong></a>
		</div>

	</div><!-- /comm -->
	</form>

<!-- 评论框结束 -->
<div class="clear blank30"></div>

<?php 
if(config::get('comment_user')){ 
?>

<!-- 评论列表开始 -->
{comment_js($aid)}
<!-- 评论列表结束 -->

<?php
}else{
?>

<?php
if(front::$user['userid']){
?>


<!-- 评论列表开始 -->
{comment_js($aid)}
<!-- 评论列表结束 -->

<?php
}else{
?>
<div class="container">
<input type="button" value=" {lang(please)}{lang(login)} " onclick="window.open('{url('user/login')}')" class="btn" />
</div>
<?php
}
?>

<?php  } ?>

{/if}

<div class="clear"></div>
</div>
<div class="clear blank30"></div>
<div class="clear blank30"></div>

</div>


<div class="clear blank30"></div>

{template 'footer.html'}