{include file="page_header.htm"}
{insert_scripts files="../js/utils.js"}

<form name="theForm" method="post" action="wx_reply.php" onsubmit="return validate()">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_form">

  {if $reply.keyword != 'welcome'} 
  <tr>
	<td class="label">名称:</td>
	<td><input type="text" class="FormSmall" name="name" size="20" value="{$reply.name}"/> <span class="required">&nbsp;</span> 
	</td>
  </tr>
  
  <tr>
	<td class="label"><a href="#" title="对应自定义菜单中下拉框为“点击”要填写的关键词" style="margin-right:5px;" ><img src="images/help.gif" border="0" alt=""/></a>	 关键词:</td>
	<td>
	<input type="text" class="FormSmall" name="keyword" size="20" value="{$reply.keyword}"/> <span class="required">&nbsp;</span>
	</td>
  </tr> 
  {/if}
  <tr>
	<td class="label">类型:</td>
	<td>
	<select name="type" onchange="get_content(this.options[this.options.selectedIndex].value);" class="select_input">
	{foreach from=$reply_type item=name key=k}
	<option value="{$k}" {if $reply.type == $k} selected="selected"{/if}>{$name}</option>
	 {/foreach}
	</select>    
	</td>
  </tr>
  
 <tr>
	<td colspan="2" id="html_content" style="padding:0px; margin:0px; border:none;"></td>
  </tr>

  <tr>
	<td class="label">状态:</td>
	<td>
		<select name="status" class="select_input">
		<option value="1" {if $reply.status == 1} selected="selected"{/if}>显示</option>
		<option value="0" {if $reply.status == 0} selected="selected"{/if}>隐藏</option>
		</select>      
	</td>
  </tr>  

<tr>
<td style="border:none;"></td>
<td style="border:none;">
	<input type="hidden" name="act" value="{$form_action}" />
	<input type="hidden" name="id" value="{$reply.id}" />
	<input type="submit" value="提交" class="bginput" />
	<input type="reset" value="重置" class="bginput" />
</td>
</tr>		
</table>
</form>
<script language="JavaScript">
var reply_id = {$reply.id|default:0};
{literal}
function validate(){
{/literal}
	{if $reply.keyword != 'welcome'} 
{literal}	
		var validator = new Validator('theForm');
		validator.required('name', '名称不能为空。');
		validator.required('keyword', '关键词不能为空。');
		return validator.passed();
{/literal}			
	{else}
		return true;
	{/if}
{literal}	
}

function get_content(type){
    if (type == ''){
        return;
    }
	$.ajax({ 
		url:"wx_reply.php?is_ajax=1&act=get_content", 
		type:"get",
		dataType:"json",
		data:{"id":reply_id,"type":type},
		beforeSend:function(){
			$("#loading").fadeIn("fast");
		},
		complete:function(){
			$("#loading").stop();
			$("#loading").fadeOut("fast");
		},
		success: function(result){
			if(result.error == 1){
				alert(result.message);
				return false;
			}else{
				$('#html_content_tr').show();
				$('#html_content').html(result.content);
				return true;
			}
		}
	 });	
}

if(reply_id!=0){
	{/literal}
	get_content('{$reply.type}');
	{literal}
}else{
	get_content('text');
}
{/literal}
</script>

{include file="page_footer.htm"}