<?php
session_start();
require_once "../init.php";
require_once "../authority.inc.php";

$ClassName = $_POST['ClassName'];
$Title = $_POST['Title'];
$Content = $_POST['Content'];
$Add = $_POST['Add'];
$hot="add";

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>增加技术支持文档</title>
<LINK href="../share/style.css" rel=stylesheet>
<script>
function GetHtml() {
	if (editor.bTextMode)
		return editor.Composition.document.body.innerText
	else {
		editor.cleanHtml;
		return editor.Composition.document.body.innerHTML;
	}
}
function check(form){
   if(form.Title.value==""){
       alert("请输入标题");
	   form.Title.focus();
	   return false;
   }
   form.Content.value = GetHtml();
   if(form.Content.value==""){
       alert("请输入内容");
	   return false;
   }
   form.submit();
}
function ChangeClass(val, form){
	form.ClassName.value=val;
}
function init(){
    var form = document.forms["mainform"];
    editor.Composition.document.body.innerHTML = form.Content.value;
}
window.onload = init;
</script>
<script src='../share/global.js'></script>
<script src="../share/jquery.js"></script>
<script src="../share/editor/kindeditor.js"></script>
</head>
<body>
<? include "../share/top.php"?>
<div id="topLink">
<div id="topInfo">
	<span class="tTitle">技术支持文档</span>
	<span class="sarr"> >> </span><a href="<?=$GLOBALS["parentpath"]?>">返回到管理首页</a>
</div>
</div>
<!--子导航-->
<? include "doc_nav.inc.php"?>
<!--结束-->


	<?
	 if($Add==1){
		  $sql="insert into doc set ClassName='$ClassName',UserName='$UserName', Title='$Title',Content='".$Content."',dtCreate=now()";
		  $DB->query($sql);
		  $DocID = $DB->insert_id();
		  echo "<center>";
		  echo "<br><br><br>技术支持文档发布成功</font>";
		  echo "<br><br><br><a href='doc_list.php'>[ 返 回 ]</a>";

	 }else{?>
      <form action="doc_add.php" method="post" name='mainform' onSubmit="return check(this)">
        <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="table" class="table">
          <tr id="tr">
            <td colspan="2">发布技术支持文档</td>
          </tr>
		  <tr height="30">
            <td align="right" width="150">文档类别:</td>
            <td>
			<select name="" onChange="ChangeClass(this.options[this.selectedIndex].value,this.form)">
				<option value="">不分类别</option>
				
			</select>
			<input name="ClassName" type="text" class="inputline" size='20' maxlength='20' value=""><font color='red'>*</font></td>
          </tr>
          <tr height="30">
            <td align="right">文档标题:</td>
            <td><input name="Title" type="text" class="inputline" size='50' maxlength='50'><font color='red'>*</font></td>
          </tr>
          <tr height="30">
            <td valign='top' align="right">文档内容:</td>
            <td>
				<textarea id="editor" name="Content"  style="width:70%;height:400px"></textarea>
			</td>
          </tr>
          <tr>
            <td colspan='2' align='center'>
			    <input name="Add" type="hidden" value="1">
				<input name="submit" type="submit" class="bt2" value="提 交">&nbsp;
                <input name="reset" type="reset" class="bt2" value="重 填">&nbsp;<input onClick=" window.location.href='/admin/doc/doc_list.php';" type="button" class="bt2" value="返回列表"></td>
          </tr>
        </table>
    </form>
	<script>		
		loadEditor('editor');
	</script>
	<?}?>
<br><br>
<? 
@$DB->close();
include "../share/bottom.php"?>
</body>
</html>
