<style type="text/css">
.connect_box{ display:none;}
.event_key{ display:none;}
</style> 
<div class="main">
	<table width="100%" class="etable"> 
		<{if $row.cid}><input type="hidden" value="<{$row.cid}>" name="cid" id="cid"><{/if}>
		<tr>
			<td width="110">分类：</td>
			<td> 
			<select name="pcid">
				<option value="0" <{if $row.pcid == '0'}>selected="selected"<{/if}>>一级分类</option> 
				<{foreach item=c from=$menu}>
			 		<option value="<{$c.cid}>" <{if $c.cid == $row.pcid}>selected="selected"<{/if}>><{$c.name}></option>
				<{/foreach}>
			</select> </td>
	  	</tr> 
	  	<tr>
			<td>名称：</td>
			<td><input name="name" type="text" size="38" id="name" value="<{$row.name}>"></td>
	  	</tr> 
	  	<tr>
			<td>事件方式：</td>
			<td>
				<label><input name="event" class="event_type" type="radio" checked="checked" value="view">跳转URL </label>	
				<label><input name="event" class="event_type" type="radio" value="click">点击推事件 </label>
			</td>
	  	</tr>
		<tr class="event_url">
			<td>填写地址：</td>
			<td><input name="url" type="text" size="38" value="<{$row.view_url}>" id="url"></td>
	  	</tr> 
		<tr class="event_key">
			<td>回复名称：</td>
			<td>
				<span style="float:left; font-size:12px;">
				<select name="key" id="select">
					<{section name=k loop=$key}>
				  		<option value="<{$key[k].name}>" <{if $key[k].name == $row.click_key}>selected="selected"<{/if}>><{$key[k].name}></option>
					<{/section}>
				 </select>
				 </span><p>自动回复事件</p>
			</td>
	  	</tr>
	</table>
</div> 
<script type="text/javascript">
$(function(){
	$('.event_type').click(function(){
		var val = $('input:radio[name="event"]:checked').val(); 
		if(val == 'view'){
			$(".event_url").show(); 
			$(".event_key").hide(); 
		}else if(val == 'click'){
			$(".event_url").hide(); 
			$(".event_key").show(); 
		}else{
			alert('错误');
		} 
	});
});
function ajax_submit(){
	var cid = $('#cid').val();
	var pcid = $('select[name="pcid"]').val();
	var name = $("#name").val();
	var event = $('input[type="radio"]:checked').val();
	var url = $("#url").val();
	var key = $("#select").val(); 
	$.post('?m=wchat&a=menu_save',{cid:cid, pcid:pcid, name:name, event:event, url:url, key:key},function(data){ 
		if(data == true){
			alert('保存成功');
			parent.ajax_flush();
			parent.ajax_close();
		}else{
			alert(data);
		} 
	});
} 
</script> 