<?xml version="1.0"?>
<labeltemplate>
   <label>
    <![CDATA[
	       <style type="text/css">
		    .askshowlist{border-bottom:1px solid #f1f1f1}
			.askshowlist li{line-height:26px;}
            .askshowlist span.question{font-weight:bold}
			
			.askpiclist .askimg img{width:50px;height:50px;boarder:1px solid #f1f1f1;}
			.askpiclist dd.askimg{float:left;width:55px;}
			 ul.askpiclist{padding-left:40px;clear:both;}
			 .pageList td a{padding:5px;border:1px solid #ccc;dispaly:block;float:left;margin-right:5px;}
		   </style>

            <script>
			
			 $(document).ready(function(){
			   loadAskForm(1);
			 });
		
			 function loadAskForm(page){
				  jQuery.ajax({
				   type: "POST",
				   url: "{$GetInstallDir}shop/ProComment.ashx",
				   data: "page="+page+"&proid={KS:Current:ItemID}&action=LoadAskForm",
				   success: function(data){
				        var d=data.split("$#$");
						$("#askform").html(d[0]);
						$("#showasklist").html(d[1]);
						$("#totalAskNum").html(d[2]);
						$(".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}shop/ProComment.ashx",
				   data: "proid={KS:Current:ItemID}&action=SaveAsk&content="+content+"&askPic="+askPic,
				   success: function(data){
					 if (data=="nologin"){
					  showuserlogin();
					 }else if (data.indexOf('error:')!=-1){
					  KesionJS.Alert(data.split(':')[1]);
					 }else if (data=='success'){
					  loadAskForm(1);
					   KesionJS.Message('success.gif','恭喜，您的咨询已提交，请耐心等待商家的回复！','');
					 }else{
					  KesionJS.Alert('出错！');
					 }
				   }
				});
	  
	 }
	 function showAskPic(s){
	  var d=unescape(s).split('|');
	  var str="<img src='"+d[0]+"' width='50' height='50' style='margin:5px;border:1px solid #ccc;padding:1px'/>";
	  $("#showaskpic").append(str);
	 }
	 </script>

	       <div style="height:34px;line-height:34px;padding:15px;font-size:15px; font-family:'微软雅黑'">商家问答列表</div>
		   <table width="100%" class="commentlist" cellspacing="0" cellpadding="0">
		    <tr>
			 <td>
			    <div id="showasklist"></div>
			 </td>
			</tr>
		   </table>
		 
		<div class="cmtcontent" id="askform">loading...</div>

	]]>
   </label>
   
   <askform>
    <![CDATA[
	 
	  <strong>问商家问题：</strong><span style="color:#999">（问题提交后显示可能会延迟，请耐心等待）限制255个字符</span>
	 <br/>
	 <textarea name="askcontent" id="askcontent" onkeydown="limitLength(this)" style="width:100%;height:100px;border:1px solid #ddd;border-top:1px solid #ccc;margin-top:10px"></textarea>
	 
	 <table border="0" cellspacing="0"  cellpadding="0">
		  <tr{$DisplayAskPic}>
		   <td width="75"><strong>上传图片：</strong></td>
		  <td>
		                     <style>
							 /*晒图*/
							.imagebox .upshow li{float:left;width:55px;margin-top:10px;}
							.imagebox .upshow li img{width:49px;height:49px;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="../../user/include/autoupload.aspx?channelid=41&fun=top.uploadOk" width="60" height="60" scrolling="no" frameborder="0"></iframe>
								 <span class="tips"></span>
					   </div> 
		 </td>
		</tr>
	 <tr>
	  <td colspan="2" valign="top" style="text-align:left"><input type="button" onclick="checkAsk()" value=" 提 交 咨 询 " class="askbtn" style="font-weight:bold;width:150px;height:44px; background:#fff url(/images/shop/bg12.png) repeat-x 0 100%;border:1px solid #ddd;border-radius: 3px;margin-top:15px;color:#fff;font-size:18px;
	  font-family:微软雅黑" />
	 </td>
	</tr>
	</table>
		
	]]>
   </askform>
   
   <loopitem>
    <![CDATA[
	 
	 <div class="askshowlist">
	   <li><span style="float:right;color:#999">{KS:Field:Adddate}</span> <img src='{$GetInstallDir}sysimg/shop/ask.gif' align="middle"/><span class="question">问：{KS:Field:Content}</span>
	   {KS:Field:ShowPics}
	   </li>
	   <li id="Reply{KS:Field:ID}"><span style="float:right;color:#999">{KS:Field:Replydate}</span> <img src='{$GetInstallDir}sysimg/shop/answer.gif' align="middle"/>答：{KS:Field:ReplyContent}</li>
	 </div>
	 
	]]>
   </loopitem>
   
   
   
</labeltemplate>