<?php
error_reporting(0);
include_once("global.php");
session_start();
islogin();
$id=$_POST["id"] ? $_POST["id"] : $_GET["id"];
$id=intval($id);
if($id)
{
	$mysql->query("select * from news where id=$id");
	$array=$mysql->fetcharray();
}
?>
<!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;
}


</script>
<body>
<form action="func/nfunc.php?action=edit" 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="32" align="center" class="normal">产品名称:</td>
      <td width="87%"><label>
        &nbsp;<input name="aid" id="aid" type="hidden" value="<?=$id?>" />
        <input name="name" type="text" class="text" id="name" value="<?=$array["title"]?>" />
      </label>
        <font color="#FF0000">*</font></td>
    </tr>
    <tr>
      <td height="33" align="center" class="normal">分类:</td>
      <td><label>
        &nbsp;
        
        <select name="category" class="text" id="category">
        <?
		$result=$mysql->query("select * from nclass");
		while($arr=$mysql->fetcharray($result))
		{
			if($array["bigclassid"]==$arr["id"])
			{
				echo "<option value=".$arr["id"]." selected='selected'>".$arr['name']."</option>";
			}
			else
			{
				echo "<option value=".$arr["id"].">".$arr['name']."</option>";
			}
		}
		?>
        </select>
      <font color="#FF0000">*</font></label></td>
    </tr>
    <tr>
      <td height="34" align="center" class="normal">作者:</td>
      <td><label>
        &nbsp;
        <input name="editor" type="text" class="text" id="editor" value="<?=$array["editor"]?>"/>
        <font color="#FF0000">*</font></label></td>
    </tr>
    <tr>
      <td height="72" align="center" class="normal">内容:</td>
      <td>
	  <? 
	  $ofckeditor->Value=$array['content'];
	  $ofckeditor->Create(); 
	 ?></td>
       </tr>
    <tr>
      <td height="34" align="center" class="normal">发布时间:</td>
      <td><label>
        &nbsp;
        <input name="datetime" type="text" class="text" id="datetime" value="<?=$array["time"]?>" readonly="readonly"/>
      </label></td>
    </tr>
    <tr>
      <td height="31" align="center" class="normal">是否允许评论:</td>
      <td class="normal"><p>
        <label>
          <input type="radio" name="comment" value="1" id="is" checked="checked" />
          允许评论</label>
   &nbsp;&nbsp;
<label>
  <input type="radio" name="comment" value="0" id="not" />
  屏蔽评论</label>
        <?
      if($array["iscomment"]==1)
	  {
		  echo "<script language='javascript'>document.getElementById('is').checked='checked';</script>";
	  }
	  else
	  {
		   echo "<script language='javascript'>document.getElementById('not').checked='checked';</script>";
	  }
	  ?>
     
	 
        <br />
      </p></td>
    </tr>
    <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>