<table width="100%" class="topmenu">
	<tr><td>
		<a href="index.php?catid={?$catid?}"><em>栏目内容</em></a><span>|</span>
		<a href="post.php?catid={?$catid?}" class="on"><em>添加文章</em></a><span>|</span>
		<a href="{?$saxue_admin_url?}/move.php?catid={?$catid?}"><em>批量移动</em></a>
	</td></tr>
</table>
<form id="formAdd" method="post">
<input type="hidden" name="dosubmit" value="1">
<input type="hidden" name="catid" value="{?$catid?}">
{?if $row.id>0?}<input type="hidden" name="id" value="{?$row.id?}">{?/if?}
<table width="100%" class="grid">
	<tr>
		<td class="tdleft" width="80">语言：</td>
		<td>
			<select name="lang" id="lang">
				<option value="">选择语言</option>{?section name=i loop=$lang?}<option value="{?$i['key']?}"{?if $i['key']==$row.lang?} selected{?/if?}>{?$lang[i].name?}</option>{?/section?}
			</select>
		</td>
	</tr>
	<tr>
		<td class="tdleft">文章标题：</td>
		<td>
			<input name="title" id="title" type="text" value="{?$row.title?}" size="80" class="text" />&nbsp;
			<label><input type="checkbox" name="islink" id="islink" value="1" onclick="setlinkurl();"{?if 1==$row.islink?} checked{?/if?} /><span class="red">转向链接</span><label>
		</td>
	</tr>
	<tr id="linkshow"{?if 0==$row.islink?} style="display:none"{?/if?}>
		<td class="tdleft">转向链接：</td>
		<td><input name="linkurl" id="linkurl" type="text" value="{?if 1==$row.islink?}{?$row.url?}{?/if?}" size="80" class="text" /></td>
	</tr>
	<tr>
		<td class="tdleft">内容：</td>
		<td>{?function saxue_geteditor:'content':680:380:'':1:array('Flash','Media')?}<textarea name="content" id="content">{?$row.content?}</textarea></td>
	</tr>
	<tr>
		<td class="tdleft">内容选项：</td>
		<td>
			<label><input name="auto_remote" type="checkbox" value="1" checked />下载非本站图片到本地</label>&nbsp;
			<label><input name="auto_intro" type="checkbox" value="1" checked />截取内容</label> <input name="intro_length" type="text" size="2" value="240" class="text"/> 字符至简介&nbsp;
			<label><input name="auto_thumb" type="checkbox" value="1" checked />设置内容第</label> <input name="thumb_no" type="text" size="1" value="1" class="text"/> 张图片为标题图
			<label><input name="auto_link" type="checkbox" value="1" checked />清除非本站链接</label>&nbsp;
		</td>
	</tr>
	<tr>
		<td class="tdleft">标题图片：</td>
		<td><input name="thumb" id="thumb" type="text" size="80" value="{?$row.thumb?}" class="text" readonly>&nbsp;<input type="button" class="button" id="imagethumb" value="选择图片" /></td>
	</tr>
	<tr>
		<td class="tdleft">摘要：</td>
		<td><textarea name="intro" id="intro" rows="2" style="width:670px;" class="textarea">{?$row.intro?}</textarea></td>
	</tr>
	<tr>
		<td class="tdleft">状态：</td>
		<td>
			<label><input name="display" type="checkbox" value="1"{?if '1'==$row.display || ''==$row.display?} checked{?/if?} />发布<label>&nbsp;
			<label><input name="istop" type="checkbox" value="1"{?if '1'==$row.istop?} checked{?/if?} />置顶<label>
		</td>
	</tr>
	<tr>
		<td class="tdleft"></td>
		<td><input type="submit" name="submit" id="submit" class="button" value="提 交"/></td>
	</tr>
</table>
</form>
<br><br>
<script type="text/javascript">
function setlinkurl() {
	if($('#islink').attr('checked')) {
		$('#linkshow').show(); 
	} else {
		$('#linkshow').hide(); 
	}
}
KindEditor.ready(function(K) {
	var editor = K.editor({
		langType : 'zh_CN',
		urlType  : 'domain',
		uploadJson : '{?$saxue_url?}/api/upload_json.php',
		fileManagerJson : '{?$saxue_url?}/api/file_manager_json.php',
		allowFileManager : true
	});
	K('#imagethumb').click(function() {
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				imageUrl : K('#thumb').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#thumb').val(url);
					editor.hideDialog();
				}
			});
		});
	});
});
$(function(){
	$("#formAdd").ajaxForm({
		beforeSubmit : function(){
			if ($("#lang").val()=='') {
				doTip('请选择语言');
				$("#lang").focus();
				return false;
			} 
			if ($("#title").val()=='') {
				doTip('请输入标题');
				$("#title").focus();
				return false;
			} 
			if($('#islink').attr('checked')) {
				if ($("#linkurl").val()=='') {
					doTip('请输入转向链接');
					$("#linkurl").focus();
					return false;
				} 
			} else if(e_content.isEmpty()) {
				doTip('内容不能为空');
				return false;
			}
		},
        dataType: "json",
        success : function(data){
			if(data.flag == 0){
				doTip(data.msg);
			}else{
				doTip('内容保存成功');
				window.top.mainframe.location.href='index.php?catid={?$catid?}';
				doDialogClose();
			}
        }
    });
})
</script>