<!--{if $a == "edit"}-->
<div class="oe_comment_addto">
  <h2 style="display:none;">回复店铺留言</h2>
  <dl>
    <dt><font color="red">*</font>回复内容：</dt>
	<dd>
	  <textarea id="content" style="width:400px;height:120px;"><!--{$words.reply}--></textarea>
	  <p>回复内容，500个字以内。<em id="words_count">0</em>/500</p>
	</dd>
	<div class="clear"></div>
  </dl>
  <dl>
    <dt>&nbsp;</dt>
	<dd><i f="btn_editwords">保存回复</i>&nbsp;&nbsp;&nbsp;<span id="words_tips"></span></dd>
	<div class="clear"></div>
  </dl>
</div>
<script type="text/javascript">
$(function(){
	
	$("[f='btn_editwords']").bind("click", function(){ //保存发表
	
		$words_tips = $("#words_tips");
		$content = $("#content").val();
		if ($content.length == 0) {
			$words_tips.html("<font color='red'>请填写回复内容</font>");
			return false;
		}
		$.ajax({
			type: "POST",
			url: _ROOT_PATH + "index.php?m=shop",
			cache: false,
			data: {c:"shopwords", a:"saveedit", reply:$content, id:"<!--{$id}-->", r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;
				if ($response == "1") {
					$words_tips.html("<font color='green'>编辑成功</font>");
					setTimeout(function(){
						window.location.reload();
					}, 800);
				}
				else {
					if ($result.length > 0) {
						$words_tips.html("<font color='red'>"+$result+"</font>");
					}
					else {
						$words_tips.html("<font color='red'>编辑失败</font>");
					}
				}
			},
			error: function() {
				$words_tips.html("<font color='red'>编辑失败，请检查网络！</font>");
			}
		});

	});

});
</script>
<!--{/if}-->

<script type="text/javascript">
$(function(){
	
	//字数统计
	$("#content").bind("keydown", function(){
		$len = $(this).val().length;
		$("#words_count").html($len);
	});

	$("#content").bind("keyup", function(){
		$len = $(this).val().length;
		$("#words_count").html($len);
	});

});
</script>