<?xml version="1.0"?>
<labeltemplate>
   <label>
    <![CDATA[
	       <style type="text/css">
		    .askshowlist{border-bottom:1px solid #f1f1f1}
			.askshowlist li{line-height:1.5rem;}
			
			.askshowlist li img{position:relative;width:0.75rem;height:0.75rem;margin-right:0.4rem;vertical-align: middle;}
			.askpiclist{ padding:10px 0;overflow:hidden}
            .askshowlist span.question{font-weight:bold;font-size:0.7rem; }
			.askpiclist dd {width:33.333%;float:left;}
			.askpiclist img{ width:92%; height:5.0rem}
			
		   </style>
      <script>
			 jQuery(document).ready(function(){
			   loadAskForm(1);
			 });
		
			 function loadAskForm(page){
				  jQuery.ajax({
				   type: "POST",
				   url: "{$GetInstallDir}plus/mall/ProComment.ashx",
				   data: "frommobile=1&page="+page+"&proid={KS:Current:ItemID}&producttype={KS:Current:ProductType}&action=LoadAskForm",
				   success: function(data){
				        var d=data.split("$#$");
						$("#askform").html(d[0]);
						$("#showasklist").html(d[1]);
						$("#totalAskNum").html(d[2]);
						$(".askimg").find("a").swipebox();  //晒图
				   }
				});
			 }
			
			
	 function limitLength(obj){
	   if(obj.value.length >= 255) 
			  event.returnValue = false; 
	 }
	 function checkAsk(){
	  var content=$("#askcontent").val();
	  if (content==''){
	   KesionJS.Alert('请输入要咨询的内容!',"$('#askcontent').focus()");
	   return false;
	  }
	  var askPic='';
	  $("#showaskpic").find("img").each(function(){
	     if (askPic==''){
		  askPic=$(this).attr("src")+"###"+$(this).attr("bigsrc");
		 }else{
		   askPic+="|"+$(this).attr("src")+"###"+$(this).attr("bigsrc");
		 }
	  });
	  
	  jQuery.ajax({
				   type: "POST",
				   cache:false,
				   url: "{$GetInstallDir}plus/mall/ProComment.ashx",
				   data: "frommobile=1&proid={KS:Current:ItemID}&producttype={KS:Current:ProductType}&action=SaveAsk&askPic="+askPic+"&content="+content,
				   success: function(data){
					 if (data=="nologin"){
					  location.href='{=GetRewriteUrl(userlogin)}';
					 }else if (data.indexOf('error:')!=-1){
					  KesionJS.Alert(data.split(':')[1]);
					 }else if (data=='success'){
					  loadAskForm(1);
					   KesionJS.Message('success.gif','恭喜，您的咨询已提交，请耐心等待商家的回复！','');
					 }else{
					  KesionJS.Alert('出错！');
					 }
				   }
				});
	  
	 }
	 </script>
	 <div class="godbox shopAskBox">
		   <table width="100%" class="commentlist" cellspacing="0" cellpadding="0">
		    <tr>
			 <td>
			    <div id="showasklist"></div>
			 </td>
			</tr>
		   </table>
	</div>	   
	<div class="cmtcontent" id="askform">loading...</div>

	]]>
   </label>
   <askform>
    <![CDATA[
	 问商家问题：<span style="color:#999">（问题提交后显示可能会延迟，请耐心等待）限制255个字符</span>
	 <br/>
	 <textarea name="askcontent" id="askcontent" onkeydown="limitLength(this)" style="width:100%;height:5rem;border:1px solid #ddd;border-top:1px solid #ddd;margin-top:0.5rem; box-sizing:border-box;resize: none;"></textarea>
	 <div{$DisplayAskPic}>
		<strong>上传图片：</strong> 
		 <style>
		 /*晒图*/
		.imagebox .upshow li{float:left;width:2.75rem;margin-top:0.5rem;}
		.imagebox .upshow li img{width:2.5rem;height:2.5rem;border:1px solid #ccc;}
		 </style>
		 <input type="hidden" name="files" id='files'/>
		 <!--上传图片开始-->
		 <div class="imagebox">
			 <script type="text/javascript">
				 function doSubmit(obj) { box = $.dialog({ title: false, content: '请稍等，正在上传文件...' }); }
				 function uploadOk(v,s) {
					 box.close();
					 if (s==undefined) s=v;
					 $("#showaskpic").append("<li><img bigsrc='"+v+"' src='" + s + "'/></li>");
				 }
			 </script>
			 <div id="showaskpic" class="upshow"></div>
			 <iframe  src="/plus/include/autoupload.aspx?channelid=41&fun=top.uploadOk" width="60" height="60" scrolling="no" frameborder="0"></iframe>
			 <span class="tips"></span>
		 </div> 
	 </div>
	 
	 <div style="clear:both;"><input type="button" onclick="checkAsk()" value="提交咨询" class="askbtn" /></div>
	]]>
   </askform>
   <loopitem>
    <![CDATA[

	 <div class="askshowlist">
	 <span style="float:right;color:#999">{KS:Field:Adddate}</span>
	  <ul>
	   <li><img src='{$GetTemplateDir}/static/shop/images/ask.gif' align="middle"/><span class="question">问：{KS:Field:Content}</span>
	   </li>
	   {KS:Field:ShowPics}
	   <li id="Reply{KS:Field:ID}" style="clear:both"><span style="float:right;color:#999;font-size:0.6rem">{KS:Field:Replydate}</span> <img src='{$GetTemplateDir}/static/shop/images/answer.gif' align="middle"/>答：{KS:Field:ReplyContent}</li>
	   </ul>
	 </div>
     ]]>
   </loopitem>   
</labeltemplate>