<?php
error_reporting(0);
include_once("global.php");
session_start();
islogin();
$url=$_POST["url"] ? $_POST["url"] : $_GET["url"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style/index.css" />
<title></title>
</head>
<script language="javascript">
function checkform()
{
	
	if(document.getElementById("name").value=="")
	{
		alert("填写产品名称");
		return false;
	}
	if(document.getElementById("editor").value=="")
	{
		alert("请填写作者");
		return false;
	}
	if(FCKeditorAPI.GetInstance("txtDecription").GetXHTML(true)=="")
	{
		alert("填写内容");
		return false;
	}
	if(document.getElementById("date").value=="")
	{
		alert("请填写日期");
		return false;
	}
	
	if(document.getElementById("comment").checked==false)
	{
		alert("请至少选择一项");
		return false;
	}
	return true;
}

function addfile()
{
	var file=document.getElementById("fileup").firstChild.cloneNode(true);
	document.getElementById("fileup").appendChild(file);
}

function removefile()
{
 document.getElementById("fileup").childNodes.length>1 && document.getElementById("fileup").lastChild ? document.getElementById("fileup").removeChild(document.getElementById("fileup").lastChild) : 0;
}
</script>
<body>
<form action="func/pfunc.php?action=add" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return checkform()">
  <table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF" class="tableborder">
    <tr>
      <td height="36" colspan="2" align="center" class="title">产品管理</td>
    </tr>
    <tr>
      <td width="13%" height="33" align="center" class="normal">产品名称:</td>
      <td width="87%"><label>
        &nbsp;
        <input name="name" type="text" class="text" id="name" />
      </label>
        <font color="#FF0000">*</font></td>
    </tr>
    <tr>
      <td height="32" align="center" class="normal">分类:</td>
      <td><label>
        &nbsp;
        <select name="category" class="text" id="category">
        <?
		$result=$mysql->query("select * from pclass");
		while($arr=$mysql->fetcharray($result))
		{
			echo "<option value=".$arr["id"].">".$arr['name']."</option>";
		}
		?>
        </select>
      <font color="#FF0000">*</font></label></td>
    </tr>
    <tr>
      <td height="30" align="center" class="normal">作者:</td>
      <td><label>
        &nbsp;
        <input name="editor" type="text" class="text" id="editor" value="管理员"/>
        <font color="#FF0000">*</font></label></td>
    </tr>
    <tr>
      <td height="72" align="center" class="normal">内容:</td>
      <td><? $ofckeditor->Create(); ?></td>
    </tr>
    <tr>
      <td height="39" align="center" class="normal">发布时间:</td>
      <td><label>
        &nbsp;
        <input name="datetime" type="text" class="text" id="datetime" value="<?=gettime('2')?>" readonly="readonly"/>
      </label></td>
    </tr>
    <tr>
      <td height="38" align="center" class="normal">是否允许评论:</td>
      <td class="normal"><p>
        <label>
          <input type="radio" name="comment" value="1" id="comment" checked="checked" />
          允许评论</label>
   &nbsp;&nbsp;
<label>
  <input type="radio" name="comment" value="0" id="comment" />
  屏蔽评论</label>
        <br />
      </p></td>
    </tr>
    <tr>
      <td height="74" align="center" class="normal">附件上传:<br />
        <br />
      <a href="#" onclick="addfile()"><font size="4">+</font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="removefile()"><font size="4">-</font></a></td>
      <td class="normal">
         &nbsp;
        <table width="35%" border="0" cellspacing="0" cellpadding="3">
           <tr>
             <td height="30" valign="top" id="fileup"><input name="file[]" type="file"  id="file" /></td>
           </tr>
        </table>
    <tr>
      <td height="72" colspan="2" align="center" class="normal"><input type="submit" name="button" id="button" value="添加产品" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="button2" id="button2" value="重置内容" /></td>
    </table>
  </td>
    </tr>
    <tr>
      <td height="72" colspan="2" align="center" class="normal"><label>&nbsp;</label></td>
  </tr>
  </table>
</form>

</body>
</html>