<form id="formAdd" method="post" action="?action=add">
<input type="hidden" name="dosubmit" value="1">
{?if $row.cid>0?}<input type="hidden" name="cid" value="{?$row.cid?}">{?/if?}
<fieldset>
	<legend>基本设置</legend>
	<table width="100%" class="grid">
		{?if $pid>0?}
		<tr>
			<td class="tdleft">父分类：</td>
			<td>{?$pname?}<input type="hidden" name="pid" value="{?$pid?}"></td>
		</tr>
		{?/if?}
		<tr>
			<td class="tdleft" width="100"><span class="red">*</span> 分类名称：</td>
			<td><input type="text" class="text" name="cname" id="cname" size="20" maxlength="20" value="{?$row.cname?}" /></td>
		</tr>
		<tr>
			<td class="tdleft"><span class="red">*</span> 英文别名：</td>
			<td><input type="text" class="text" name="alias" id="alias" size="20" value="{?$row.alias?}" /></td>
		</tr>
		<tr>
			<td class="tdleft">列表每页显示：</td>
			<td><input type="text" class="text" name="pnum" id="pnum" size="20" value="{?$row.pnum?}" /></td>
		</tr>
		{?if $pid==0?}
		<tr>
			<td class="tdleft">自定义频道页：</td>
			<td>
				<select name="showchannel" onchange="tempchange(this.value)">
					<option value="0"{?if 0==$row.showchannel?} selected{?/if?}>否</option>
					<option value="1"{?if 1==$row.showchannel?} selected{?/if?}>是</option>
				</select>
			</td>
		</tr>
		{?/if?}
	</table>
</fieldset>
<div style="height:15px;"></div>
<fieldset>
	<legend>模版设置</legend>
	<table width="100%" class="grid">
		<tr>
			<td class="tdleft" width="100">频道/列表模版：</td>
			<td><select name="templist" id="templist"><option value="">默认模版</option>{?if 1==$row.showchannel?}{?section name=i loop=$temps['channel']?}<option value="{?$i['value']?}"{?if $i['value']==$row.templist?} selected{?/if?}>{?$i['value']?}</option>{?/section?}{?else?}{?section name=i loop=$temps['list']?}<option value="{?$i['value']?}"{?if $i['value']==$row.templist?} selected{?/if?}>{?$i['value']?}</option>{?/section?}{?/if?}</select></td>
		</tr>
		<tr>
			<td class="tdleft">内容页模版：</td>
			<td><select name="tempdetail"><option value="">默认模版</option>{?section name=i loop=$temps['detail']?}<option value="{?$i['value']?}"{?if $i['value']==$row.tempdetail?} selected{?/if?}>{?$i['value']?}</option>{?/section?}</select></td>
		</tr>
		<tr>
			<td class="tdleft">目录页模版：</td>
			<td><select name="tempcatalog"><option value="">默认模版</option>{?section name=i loop=$temps['catalog']?}<option value="{?$i['value']?}"{?if $i['value']==$row.tempcatalog?} selected{?/if?}>{?$i['value']?}</option>{?/section?}</select></td>
		</tr>
		<tr>
			<td class="tdleft">章节页模版：</td>
			<td><select name="tempchapter"><option value="">默认模版</option>{?section name=i loop=$temps['chapter']?}<option value="{?$i['value']?}"{?if $i['value']==$row.tempchapter?} selected{?/if?}>{?$i['value']?}</option>{?/section?}</select></td>
		</tr>
	</table>
<div><input type="submit" name="submit" id="submit" class="button dodialog" value="提 交"/></div>
</form>
<script type="text/javascript">
function tempchange(ischannel){
	var temp = "<option value=''>默认模版</option>";
	if (ischannel==1) {
		temp += "{?section name=i loop=$temps['channel']?}<option value='{?$i['value']?}'{?if $i['value']==$row.templist?} selected{?/if?}>{?$i['value']?}</option>{?/section?}";
	} else {
		temp += "{?section name=i loop=$temps['list']?}<option value='{?$i['value']?}'{?if $i['value']==$row.templist?} selected{?/if?}>{?$i['value']?}</option>{?/section?}";
	}
	$("#templist").html(temp)
}
$(function(){
	$.formValidator.initConfig({formid:"formAdd",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'250',height:'50'}, function(){this.close();$(obj).focus();})}});
	$("#cname").formValidator({onshow:"请输入分类名称",onfocus:"请输入分类名称",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入分类名称"});
	$("#alias").formValidator({empty:true,onshow:"请输入英文别名",onfocus:"英文别名不超过20个字符",oncorrect:"输入正确"}).regexValidator({regexp:"username",datatype:"enum",param:'i',onerror:"只能包括数字、字母、下划线三种类型。"});
	$("#formAdd").ajaxForm({
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				doTip(data.msg);
			}else{
				window.top.mainframe.location.reload();
				doDialogClose();
			}
        }
    });
})
</script>