<?xml version="1.0"?>
<labeltemplate>
   <label>
    <![CDATA[
	       
	   <link rel="stylesheet" href="{$GetSiteUrl}ks_inc/Swipebox/swipebox.css">
	   <script src="{$GetSiteUrl}ks_inc/Swipebox/jquery.swipebox.js"></script>
       <script>
			 jQuery(document).ready(function(){
			   jQuery.getScript('{$GetInstallDir}plus/mall/ProComment.ashx?action=getcommentinfo&proid={KS:Current:ItemID}&orderType={$OrderType}',function(){
			    var goodNum=parseInt(comment.goodNum);
				var averageNum=parseInt(comment.averageNum);
				var badNum=parseInt(comment.badNum);
				var totalNum=goodNum+averageNum+badNum;
				$("#totalReview").html(totalNum);
				var goodPercent=goodNum/totalNum*100;
				var averagePercent=averageNum/totalNum*100;
				var badPercent=badNum/totalNum*100;
				if (isNaN(goodPercent)) goodPercent=0;
				if (isNaN(averagePercent)) averagePercent=0;
				if (isNaN(badPercent)) badPercent=0;
			    $("#goodPercent").html(goodPercent.toFixed(2)+"%");
				$("#percent1").html(goodPercent.toFixed(2));
				$("#percent2").html(averagePercent.toFixed(2));
				$("#percent3").html(badPercent.toFixed(2));
				$("#bar1").attr("style","width:"+goodPercent+"%").attr("title",goodPercent+"%");
				$("#bar2").attr("style","width:"+averagePercent+"%").attr("title",averagePercent+"%");
				$("#bar3").attr("style","width:"+badPercent+"%").attr("title",badPercent+"%");
				$("#commentnum0").html(totalNum);
				$("#commentnum1").html(goodNum);
				$("#commentnum2").html(averageNum);
				$("#commentnum3").html(badNum);
				loadCmtContent(1,-1);
			   });
			 });
			 function loadCmt(obj,cmtType){
			  $(".cmtlist").find("li").attr("class","cmtlistnormal");
			  obj.className='cmtlistcurr';
			  loadCmtContent(1,cmtType);
			 }
			 function loadCmtContent(page,cmtType){
				  jQuery.ajax({
				   type: "POST",
				   url: "{$GetInstallDir}plus/mall/ProComment.ashx",
				   data: "frommobile=1&proid={KS:Current:ItemID}&orderType={$OrderType}&page="+page+"&action=GetCmtList&cmtType="+cmtType,
				   success: function(data){
						$("#cmtcontent").html(data);
						$(".st").swipebox();  //晒图
				   }
				});
			 }
			 function cmtSupport(id){
			  jQuery.ajax({
				   type: "POST",
				   url: "{$GetInstallDir}plus/mall/ProComment.ashx",
				   data: "id="+id+"&action=SupportCmt",
				   success: function(data){
				     if (data=="nologin"){
                        location.href='{=GetRewriteUrl(userlogin)}';
					 }else if (data.indexOf('error:')!=-1){
					  KesionJS.Alert(data.split(':')[1]);
					 }else{
						$("#support"+id).html(data);
						}
				   }
				});
			 }
			  //评论
			function quickreply(id, page) {
				var c = $("#c" + id).val();
				if (id == '') return;
				$.ajax({
				url: '{$GetInstallDir}plus/mall/ProComment.ashx?page=' + page + '&id=' + id + '&action=ShowCmt',
					success: function(data) {
						if (page != undefined) {
							$("#cmt" + id).html(data);
						} else {
							$("#cmt" + id).toggle('fast').html(data);
						}
					},
					cache: false
				});
			}
			//开始提交评论
    function dopostcmt(id) {
        var c = $("#c" + id).val();
        if (c == '' || c == '我也说一句...') {
            $.dialog.tips('你也懒了点吧,要输入评论内容哦^-^', 2, 'error.gif', function() {
                $("#c" + id).focus();
            });
            return false;
        }
        $.post("{$GetInstallDir}plus/mall/ProComment.ashx", { action: 'CmtSave', id: id, Content: c }, function(d) {
            if (d == "success") {
			   $("#Cmt"+id).html(parseInt($("#Cmt"+id).html())+1);
                $.dialog.tips('恭喜，评论成功！', 1, 'success.gif', function() { quickreply(id,1);  });
            } else {
                $.dialog.tips(unescape(d), 1, 'error.gif', function() { });
            }
        });
    }
	function ThisFocus(id) { if ($("#c" + id).val() == '我也说一句...') { $("#c" + id).val(''); } }
    function ThisBlur(id) { if ($("#c" + id).val() == '') { $("#c" + id).val('我也说一句...'); } }
var box='';
    function showWriteComment(orderId){
	  var url="/index.aspx?c=user&a=shop&sp=frame-1,f-MyComment,action-comment,orderID-"+orderId+",proid-{KS:Current:ItemID},orderType-{$OrderType}";
	   box=$.dialog.open(url,{ id:'topbox',lock: true,fixed:true, title: "商品评价", width:800, height:500, close: function() {  initialComment();
 }
      });
	}
			</script>
			<link rel="stylesheet" href="/ks_inc/Swipebox/swipebox.css">
		    <script src="/ks_inc/Swipebox/jquery.swipebox.js"></script>
			<div class="godbox" style="margin-bottom:0">
		   
				 <table width="100%" class="commentlist" cellspacing="0" cellpadding="0">
				  <tr>
					   <td style="width:5.0rem;text-align:center">
						 <span class="percent" id="goodPercent">0%</span>
						 <br/>
						 <span class="gray">好评率</span>
					   </td>
					   <td>
						 <div class="barbox">
						  <div class="barleft">好评(<span id="percent1">0</span>%)</div>
						  <div class="barright"><div class="red" id="bar1"></div></div>
						 </div>
						 <div style="clear:both;height:4px; overflow:hidden"></div>
						 <div class="barbox">
						  <div class="barleft">中评(<span id="percent2">0</span>%)</div>
						  <div class="barright"><div class="red" id="bar2"></div></div>
						 </div>
						  <div style="clear:both;height:4px; overflow:hidden"></div>
						 <div class="barbox">
						  <div class="barleft">差评(<span id="percent3">0</span>%)</div>
						  <div class="barright"><div class="red" id="bar3"></div></div>
						 </div>
					   </td>
				   </tr>
				   <tr>
					<td style="text-align:center" colspan="2">
					   <div class="cmtBox">
						   <div class="gray">您可对已购商品进行评价</div>
						   <br/>
						   <iframe src="about:blank" id="commentFrame" name="commentFrame" width="0" height="0" style="display:none"></iframe>
						   <form  name="commetform" action="{$GetSiteUrl}plus/mall/ProComment.ashx?m_id={KS:Current:ModelID}&infoid={KS:Current:ItemID}&frommobile=1" target="commentFrame" method="post">
							   <input type="hidden" name="action" value="docomment"/>
							   <input type="hidden" name="ordertype" value="{$OrderType}"/>
							   <input type="submit" value="发表评价" class="cmtBtn" />
						   </form>
						   <br/>
					   </div>
					 </td>
				  </tr>
				 </table>
		   </div>		 
		   <h3 class="shop-con-title">累计评价(<span id="totalReview">{KS:Field:CommentNum}</span>)</h3>
		  <div class="cmtbd godbox">
			  <div class="cmttop"> 
			   <div class="cmtlist clearfix">
			   <ul>
				 <li class="cmtlistcurr" onclick="loadCmt(this,-1)">全部(<span id="commentnum0">0</span>)</li>
				 <li class="cmtlistnormal" onclick="loadCmt(this,0)">好评(<span id="commentnum1">0</span>)</li>
				 <li class="cmtlistnormal" onclick="loadCmt(this,1)">中评(<span id="commentnum2">0</span>)</li>
				 <li class="cmtlistnormal" onclick="loadCmt(this,2)">差评(<span id="commentnum3">0</span>)</li>
			   </ul>
			   </div>
			</div>
		
			<div class="cmtcontent" id="cmtcontent">loading...</div>
		 </div>	
	]]>
   </label>
   <loopitem>
    <![CDATA[
	 <div class="cmtcontentlist">
	   <div class="userinfo">
	     <img src="{$UserFace}" width="40" height="40" onerror="replaceDefaultImg(this)" type="user" /><br>
	     <span>{$UserName}</span>
	   </div>
	   <div class="cmtcontent">
	     <div class="cmttitle"><span style="color:#999" class="fr"><!--用户IP：{$UserIP}-->{$AddDate}</span>
		 <img  align="absbottom" src="{$GetTemplateDir}/static/shop/images/star/star-{$StarNum}.jpg" /></div>
		 <div style=" overflow:hidden;font-size:0.6rem">
		 评价等级：{$CmtRank}<br/>
		 评价内容：{$Content}<br/>
		 <div{$ShowIsReply} class="replybox">管理员回复：{$ReplyContent}</div>
		  {$PhotoUrls}
		 <div class="clear" style="clear:both"></div>
		 <div class="date">购买时间：{$BuyDate}</div>
		 <div style="text-align:right;padding:0 0.5rem; font-size:0.7rem">
		 <a href="javascript:;" onclick="cmtSupport({$ID});">有用(<span id="support{$ID}">{$Support}</span>)</a> <a href="javascript:;" onclick="quickreply({$ID});">回复(<span id="Cmt{$ID}">{$CmtNum}</span>)</a></div>
		 </div>
		 
		 <div class="cmt" id='cmt{$ID}'>
          发表回复：
          <input type="text"  class="cmtbox" style="width:350px" id="rcontent{$ID}" />
          <input type="button" class="button" value="提交" onclick="doReply({$ID});" />
          
          </div>
		 
	   </div>
	 </div>
	]]>
   </loopitem>
</labeltemplate>