<div class="oe_words_addto">
  <h2>填写咨询、留言内容</h2>
  <dl>
    <dt><font color="red">*</font> 联系人：</dt>
	<dd><input type="text" id="words_contname" style="width:200px" value="<!--{$login.user.realname}-->" /></dd>
	<div class="clear"></div>
  </dl>
  <dl>
    <dt><font color="red">*</font> 联系电话：</dt>
	<dd><input type="text" id="words_mobile" style="width:200px" value="<!--{$login.user.mobile}-->" /></dd>
	<div class="clear"></div>
  </dl>
  <dl>
    <dt><font color="red">*</font> 咨询内容：</dt>
	<dd>
	  <textarea id="words_content"></textarea>
	  <p>请填写咨询内容，500个字以内。<em id="words_count">0</em>/500</p>
	</dd>
	<div class="clear"></div>
  </dl>
  <!--{if $config.wordscode == '1'}-->
  <dl>
    <dt><font color="red">*</font>验证码：</dt>
	<dd>
      <input type="text" id="words_checkcode" style="width:80px" />
      <img class="_checkcode" style="cursor:pointer;" title="点击换一个" id="words_img_checkcode" src="<!--{$urlpath}-->source/include/imagecode.php?act=verifycode" />
	</dd>
  </dl>
  <!--{/if}-->
  <dl>
    <dt>&nbsp;</dt>
	<dd><i f="wordspost">提交保存</i>&nbsp;&nbsp;&nbsp;<span id="words_tips"></span></dd>
	<div class="clear"></div>
  </dl>
</div>
<script type="text/javascript">
$(function(){
	
	$("[f='wordspost']").bind("click", function(){ //提交
		$words_tips = $("#words_tips");
		$contname = $("#words_contname").val();
		$contmobile = $("#words_mobile").val();
		$words = $("#words_content").val();

		$checkcode = "";
		
		if ($contname.length == 0) {
			$words_tips.html("<font color='red'>请填写联系人</font>");
			return false;
		}
		if ($contmobile.length == 0) {
			$words_tips.html("<font color='red'>请填写联系电话</font>");
			return false;
		}
		if ($words.length == 0) {
			$words_tips.html("<font color='red'>请填写咨询、留言内容</font>");
			return false;
		}
		<!--{if $config.wordscode == '1'}-->
		$checkcode = $("#words_checkcode").val();
		if ($checkcode.length == 0) {
			$words_tips.html("<font color='red'>请填写验证码</font>");
			return false;
		}
		<!--{/if}-->

		$.ajax({
			type: "POST",
			url: _ROOT_PATH + "index.php",
			cache: false,
			data: {c:"words", a:"post", contname:$contname, contmobile:$contmobile, words:$words, checkcode:$checkcode, shopid:"<!--{$shopid}-->", r:get_rndnum(8)},
			dataType: "json",
			success: function($data) {
				$json = eval($data);
				$response = $json.response;
				$result = $json.result;

				if ($response == "1") {
					<!--{if $config.approved_shopwords == "1"}-->
					$suc_txt = "<font color='green'>提交成功，请耐心等待网站审核。</font>";
					<!--{else}-->
					$suc_txt = "<font color='green'>提交成功。</font>";
					<!--{/if}-->
					$words_tips.html($suc_txt);
					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>");
			}
		});

	});


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

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

	<!--{if $config.wordscode == '1'}-->
	$("#words_img_checkcode").bind("click", function(){
		$(this).attr("src", _ROOT_PATH+"source/include/imagecode.php?act=verifycode&"+Math.random());
	});
	<!--{/if}-->

});
</script>