<!--#include file="../include/DBConn.asp"-->
<!--#include file="BenbenInc/Functions.asp"-->
<%
'response.write request.form("content") &"<BR>" '######## 内容字段
'response.write request.form("level1") & "<BR>"
'response.write request.form("level2")&"<BR>"
Call DBConnBegin()
Dim id,rs,rs2,big,sma,L1,tempID,L2,MsgStr

	id=request.QueryString("ID")
	if not IsNum(id) then
		Call Msg("参数类型不正确!","News_List.asp")
	end if
	
  'response.Write(Session("AdminLogin"))
  'response.End()


'#################Add Action######################################
if request.form("title")<>"" then
	Set rs = Server.CreateObject("ADODB.RecordSet")
	rs.open "select * from News where Nid="&id,conn,3,3
	rs("Ntitle")=left(request.form("title"),100)
	rs("Ncontent")=replace(request.form("content") & " ","http://"&request.ServerVariables("HTTP_HOST"),"")
	rs("Ndatetime")=request.form("datetime")
	'rs("state")=true 'Default=true
	
	rs("NbigSort")=request.form("level1")
	rs("NsmaSort")=request.form("level2")
	
		rs("NtitlePic")=request.form("url")
	Nrecommend=request.form("Nrecommend")
	if Nrecommend="1" then 
	Nrecommend=1
	else
	Nrecommend=0
	end if
	rs("Nrecommend")=Nrecommend
	Norder=request.form("Norder")
	if Norder<>"" then 
	Norder=Norder
	else
	Norder=0
	end if

	rs("Norder")=Norder
	rs("Nurl")=request.form("Nurl")
	rs("Nkey")=request.form("Nkey")
	'rs("Nnum")=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)
	rs.update()
	response.write"<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />"
	'Call Msg("新闻编辑成功!","News_List.asp")
	response.Write"<script>opener.location.reload();</script>" 
	Call ShowClose("新闻编辑成功!")
end if
'#################End Action######################################
set rs2=server.createobject("adodb.recordset")
rs2.open "select * from News where Nid = " & id,conn,1,1
if not rs2.eof then
  big=rs2("NbigSort")
  sma=rs2("NsmaSort")
else
  Call Msg("未找到记录!","News_List.asp")
end if

  'response.Write(Session("AdminLogin"))
  'response.End()

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="BenbenInc/css.css" rel="stylesheet" type="text/css">
<link href="../stylecss/style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="/Themes/My97DatePicker2/WdatePicker.js"></script>
<script language="javascript" src="../jscript/function.js"></script>
<script type="text/javascript" src="../xheditor8899/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../xheditor8899/xheditor-zh-cn.min.js?v=1.1.3"></script>
<script type="text/javascript">
$(pageInit);
function pageInit()
{
	$('#content').xheditor({upLinkUrl:"../xheditor8899/demos/upload12345654321.asp",upLinkExt:"zip,rar,txt",upImgUrl:"../xheditor8899/demos/upload12345654321.asp",upImgExt:"jpg,jpeg,gif,png",upFlashUrl:"../xheditor8899/demos/upload12345654321.asp",upFlashExt:"swf",upMediaUrl:"../xheditor8899/demos/upload12345654321.asp",upMediaExt:"wmv,avi,wma,mp3,mid"});
	
}
</script>
<title>==新闻添加==</title>
<style type="text/css">
<!--
input.c {
	border: 1px dotted #000000;
	height: 20px;
	width: 250px;
}
.style2 {color: #FF0000}
.style3 {color: #666666}
.style4 {color: #0066FF}
-->
</style>
<script language=vbscript>
Function CheckForm()
	CheckForm=true
	if document.f.datetime.value="" then CheckForm=false
	if document.f.title.value="" then CheckForm=false
	if CheckForm=false then
		Msgbox "带红色星号的项为必需填写的项,请填写完整再提交!",16,"提示"
		call sc("FALSE")
	else
	    call sc("TRUE")
		CheckForm=true
	end if
End Function
</script>
<script language=javascript>
function sc(s)
{
	Editor.SetSubmit=s;
	document.f.content.value=Editor.eWebEditor.document.body.innerHTML;
	if(s=="TRUE")document.f.submit();
}
</script>
<script language=javascript>
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadimages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadimages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" class="Title_bg">新闻编辑</td>
  </tr>
</table>
<table width="820"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#DAEFFF" style="margin-top:15px;">
<form method=post name="f" id="f" onSubmit="javascript:return CheckForm();">
  <tr bgcolor="#efeddf">
    <td colspan="2" bgcolor="#DAEFFF"> <span class="style4"><span class="t34 style5">4</span> 编 辑 新 闻 </span></td>
  </tr>
  <tr>
    <td width="10%" align="right" bgcolor="#FFFFFF"><span class="style2">*</span>类别：</td>
    <td width="90%" bgcolor="#FFFFFF"><table width="300" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="37"><select name="level1" id="level1" onChange="vbscript:change1(document.f.level1.value)">
                <%
	Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select * from News_Sort where Stype=0 and Stid=0 order by Sid asc",conn,1,1
if rs.eof then
	response.write "<script language=vbscript>" & chr(13)
	response.write "msgbox ""对不起,请先填加""""一级栏目""""后再进行添加！"",64,""提示""" & chr(13)
	response.write "window.location.href=""News_Sort.asp""" & chr(13)
	response.write "</script>"
	Response.End
end if
L1=""
n=1
do while not rs.eof
  if rs("Sid")=big then
    L1=L1 & "<option value="&rs("Sid")&" selected>"&rs("Sname")&"</option>" 
  else
    L1=L1 & "<option value="&rs("Sid")&">"&rs("Sname")&"</option>"  
  end if
  if n=1 then tempID=rs("Sid")
rs.movenext
n=n+1
loop
rs.close
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open "select * from News_Sort where Stype=1 and Stid=0 order by Sid asc",conn,1,1
if rs.eof then
	response.write "<script language=vbscript>" & chr(13)
	response.write "msgbox ""对不起,请先填加""""二级栏目""""后再进行添加！"",64,""提示""" & chr(13)
	response.write "window.location.href=""News_Sort.asp""" & chr(13)
	response.write "</script>"
	Response.End
end if
L2=""
do while not rs.eof
  L2=L2 & "<option value="&rs("Sid")&">"&rs("Sname")&"&haosmallfgf;"&rs("Spid")&"</option>&haobigfgf;"
rs.movenext
loop
rs.close

%>
<%=L1%>
<script language=vbscript>
l2="<%=L2%>"
function change1(num)
a=split(l2,"&haobigfgf;")
tempA=""
For n=0 to ubound(a)
  if instr(a(n),"&haosmallfgf;"&cstr(num)&"<")>0 then
     tempA=tempA & replace(a(n),"&haosmallfgf;"&cstr(num)&"<","<")
  end if
NEXT
xx="<select name=level2 id=level2>" & tempA & "</select>"
select2.innerhtml=xx
end function
</script>
              </select></td>
            <td width="263" id=select2 name=select2>
<%
rs.open "select * from News_Sort where Stype=1 and Spid="&big,conn,1,1
%>
<select name="level2" id="level2">
<%
do while not rs.eof
  if rs("Sid")=sma then
    response.write "<option value="&rs("Sid")&" selected>"&rs("Sname")&"</option>"  
  else
    response.write "<option value="&rs("Sid")&">"&rs("Sname")&"</option>"  
  end if
rs.movenext
loop
rs.close
%>
</select>

			</td>
          </tr>
        </table></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF"><span class="style2">*</span>时间：</td>
    <td bgcolor="#FFFFFF"><input name="datetime" type="text" id="datetime" value="<%=rs2("Ndatetime")%>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly"></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF"><span class="style2">*</span>标题：</td>
    <td bgcolor="#FFFFFF"><input name="title" type="text" id="title" value="<%=rs2("Ntitle")%>" size="40" maxlength="100">
      <span class="style3">(最长100个字符,超过则自动截取掉..)</span></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#FFFFFF">内容：</td>
    <td bgcolor="#FFFFFF"><textarea id="content" name="content" rows="20" cols="80" style="width: 100%"><%=rs2("Ncontent")%></textarea><!--<iframe id="Editor" name="Editor" src="../Edit8899/editor.htm?id=content&ReadCookie=0" frameborder="0" scrolling="no" width="100%" height="350"></iframe>--></td>
  </tr>
<tr>
    <td align="right" bgcolor="#FFFFFF" height="30">跳转地址：</td>
    <td bgcolor="#FFFFFF"><input name="Nurl" type="text" value="<%= rs2("Nurl") %>" size="50">
    用于url跳转，如友情链接或文章跳转</td>
  </tr>
  <tr>
    <td align="right"  height="30" bgcolor="#FFFFFF">图片：</td>
    <td bgcolor="#FFFFFF"><input name="url" type="text" id="url" value="<%= rs2("NtitlePic") %>" size="60">
        <span id="UpBtn" onClick="javascript:OpenUrl('UpPhoto.asp?InputForm=f&InputName=url&SavePath=/uploadfiles/Newsimages&PathWithYearMonth=0&MaxSize=500000','450','150','yes','UpPhoto');" style="cursor:pointer"><u>上传图片</u></span></td>
  </tr><!--
  <tr>
    <td align="right"  height="30" bgcolor="#FFFFFF">推荐：</td>
    <td bgcolor="#FFFFFF"><input name="Nrecommend" type="checkbox" value="1" style="border:0px;" <%if rs2("Nrecommend")=True then response.Write("checked")  %>>是否推荐</td>
  </tr>
  <tr>
    <td align="right" height="30" bgcolor="#FFFFFF">排序：</td>
    <td bgcolor="#FFFFFF"><input name="Norder" value="<%= rs2("Norder") %>" type="text">
    请输入数字，数字越大越靠前！ </td>
  </tr>-->
  <tr>
    <td align="right" height="30" bgcolor="#FFFFFF">关键字：</td>
    <td bgcolor="#FFFFFF"><input name="Nkey" value="<%= rs2("Nkey") %>" type="text">
    多个关键字请用空格分开</td>
  </tr>
  
  <tr align="center">
    <td colspan="2" bgcolor="#FFFFFF"><input type=image src="../images/Edit_1.gif" onMouseOut="javascript:MM_swapImgRestore()" onMouseOver="javascript:MM_swapImage('Image1','','../images/Edit_2.gif',1)" name="Image1" class="imgbtn">
&nbsp;&nbsp;<img src="../images/Reset_1.gif" name="Image2" width="51" height="23" border="0"  onmouseout="javascript:MM_swapImgRestore()" onMouseOver="javascript:MM_swapImage('Image2','','../images/Reset_2.gif',1)" onClick="vbscript:document.f.reset" style="cursor:hand"> </td>
  </tr>
</form>
</table>
<%
rs2.close
set rs2=nothing
%>
</body>
</html>
