<!-- #include file="include/onlogin.asp" -->
<!--#include file ="include/conn.asp"-->
<SCRIPT language=JavaScript src="style/admin_ads.js"></SCRIPT>
<%
dim AdsCategoryID,AdsID,chk
tit=vbcrlf & "<a href='admin_adsmain.asp?'>广告管理</a>&nbsp;┋ <a href='admin_adv.asp'>论坛广告管理</a>┋&nbsp;<a href='admin_popwin.asp?nsort=popwin'>弹出广告</a>┋&nbsp;" & _
    vbcrlf & "<a href='admin_adsmain.asp?action=edit'>广告分类</a>"
response.write header(4,tit)
chk=trim(request.querystring("chk"))

select case action
case "edit"
    call ads_edit()
case else
  call ads_main()
end select

call close_conn()
response.write ender()

sub ads_edit()
dim Stat,CategoryName,PicHeight,PicWidth,Remark
	Stat=request("Stat")
    AdsCategoryID=request("AdsCategoryID")
    CategoryName=trim(request("CategoryName"))
	PicHeight=request("PicHeight")
	PicWidth=request("PicWidth")
	Remark=request("Remark")
  if chk="添加" then
	set rs=server.createobject("adodb.recordset")
	sql="select * from AdsCategory"
	rs.open sql,conn,3,3
	rs.addnew
	  rs("CategoryName")=CategoryName
	  rs("PicHeight")=PicHeight
	  rs("PicWidth")=PicWidth
	  rs("Remark")=Remark
	  rs("InputDate")=Now()
	rs.update
  elseif chk="修改" then
	set rs=server.createobject("adodb.recordset")
	sql="select * from AdsCategory where AdsCategoryID="&AdsCategoryID
	rs.open sql,conn,3,3
	  rs("CategoryName")=CategoryName
	  rs("PicHeight")=PicHeight
	  rs("PicWidth")=PicWidth
	  rs("Remark")=Remark
	rs.update
	response.redirect"admin_adsmain.asp?action=edit"
  elseif chk="删除" then
    for i=1 to request("AdsCategoryID").count
	  conn.execute("delete from AdsCategory where AdsCategoryID="&request("AdsCategoryID")(i))
	  conn.execute("delete from Ads where AdsCategoryID="&request("AdsCategoryID")(i))
	next
  end if
  set rs=conn.execute("select * from AdsCategory order by AdsCategoryID desc")
%>

<%if Stat="" then%>
<table border=1 width='100%' cellspacing=0 cellpadding=1<%response.write table1%>>
<tr><td height="18" colspan="2" align="center" bgcolor=<%response.write color3%>><strong>广告类别</strong></td></tr>
<%
while not rs.eof
%>
<form name=form1 method="post" action='?action=edit&chk=删除'>
<tr <%response.write mtr%>>
<td width="85%"><%response.write img_small("jt1")%><%=rs("CategoryName")%></td>
<td width="15%"><a href='admin_adsmain.asp?AdsCategoryID=<%=rs("AdsCategoryID")%>&action=edit&Stat=modify'>修改</a>
<input type="checkbox" name="AdsCategoryID" value="<%=rs("AdsCategoryID")%>"></td>
</tr>
<%
i=i+1
rs.movenext
wend
rs.close
set rs=nothing
%>
<tr> 
<td colspan=2 align=right>
<input type=submit name=chk value="删除" class=button onclick="return Del()">
选中所有<input type="checkbox" name="chkall" onclick="CheckAll(this.form)"></td>
</tr>
</form>
</table>

<br>
<table border=1 width='100%' cellspacing=0 cellpadding=1<%response.write table1%>>
<tr><td height="18" colspan="2" align="center" bgcolor=<%response.write color3%>><strong>添加广告类别</strong></td></tr>
<form name=form method="post" action='?action=edit&chk=添加' onsubmit="return CheckAdsCategory()">
<tr>
<td width='50%'>&nbsp;类别名<br><font color=#c0c0c0>广告类别的简单说明,如：体育频道广告</font></td>
<td><input type="text" class=form80 name="CategoryName"></td>
</tr>
<tr>
<td>&nbsp;框架长、宽<br><font color=#c0c0c0>此广告类别框架的长度、宽度</font></td>
<td>长：<input type="text" class=form80 size=5 name="PicHeight" value=80 onblur="Isvalidity(PicHeight,'长')">
宽：<input type="text" class=form80 size=5 name="PicWidth" value=468 onblur="Isvalidity(PicWidth,'宽')"></td>
</tr>
<tr>
<td>&nbsp;备注</td>
<td><textarea name=Remark rows=5 cols=30></textarea></td>
</tr>
<tr align="center"> 
<td colspan="2" ><input type="submit" class=button value="添加" name=chk></td>
</tr>
</form>
</table>

<%
else
set rs=conn.execute("select * from AdsCategory where AdsCategoryID="&AdsCategoryID)
%>

<table border=1 width='100%' cellspacing=0 cellpadding=1<%response.write table1%>>
<tr><td height="18" colspan="2" align="center" bgcolor=<%response.write color3%>><strong>修改广告类别</strong></td></tr>
<form name=form method="post" action="?action=edit&chk=修改&AdsCategoryID=<%=rs("AdsCategoryID")%>" onsubmit="return CheckAdsCategory()">
<tr>
<td width="50%">&nbsp;类别名<br>
<font color=#c0c0c0>广告类别的简单说明,如：体育频道广告</font></td>
<td><input type="text" class=form80 name="CategoryName" value="<%=rs("CategoryName")%>"></td>
</tr>
<tr>
<td>&nbsp;框架长、宽<br>
<font color=#c0c0c0>此广告类别的框架长度、宽度</font></td>
<td>长：<input type="text" class=form80 size=5 name="PicHeight" onblur="Isvalidity(PicHeight,'长')" value="<%=rs("PicHeight")%>">
宽：<input type="text" class=form80 size=5 name="PicWidth" onblur="Isvalidity(PicWidth,'宽')" value="<%=rs("PicWidth")%>"></td>
</tr>
<tr>
<td>&nbsp;备注</td>
<td><textarea name=Remark rows=5 cols=30><%=rs("Remark")%></textarea> </td>
</tr>
<tr align="center"> 
<td colspan="2">	
<input type="submit" class=button value="修改" name=chk onclick="return modify()">
<input type="reset" class=button value="还原">
<input type="button" class=button value="返回" onclick="javascript:history.back(-1)">
</td>
</tr>
</form>
</table>
<%
end if
end sub

sub left_mune()
response.write "<b>广告类别：<b><br>"
set rs=conn.execute("select * from AdsCategory order by AdsCategoryID desc")
do while not rs.eof
response.write vbcrlf&img_small("jt1")&"<a href=admin_AdsManage.asp?AdsCategoryID="&rs("AdsCategoryID")&">"&rs("CategoryName")&"</a><br>"
rs.movenext
loop
rs.close
set rs=nothing
end sub

sub ads_main()
dim rsAccessToday,rsClickToday,TodayAccessCount,TodayClickCount,AverageTodayClick,rsAccess,rsClick,AccessCount,ClickCount,AverageClick
  AdsCategoryID=request("AdsCategoryID")
  AdsID=request("AdsID")

%>
<table border=0 width='100%' cellpadding=2>
<tr>
    <td width='25%' valign="top" class=htd>
      <%call left_mune()%>
    </td>
<td width='75%' align=center>
<%call get_code()%></td></tr></table>
<%
end sub

sub get_code()
dim def
set rs=conn.execute("select * from AdsCategory order by AdsCategoryID desc")
%>
<form name="form" method="POST" action="">
<table border=1 width='100%' cellspacing=0 cellpadding=1<%response.write table1%>>
<tr><td height="18" colspan="2" align="center" bgcolor=<%response.write color3%>><strong>获取广告调用代码</strong></td></tr>
<tr><td width='50%'>&nbsp;类别名</td>
<td><select onchange=DoVoteCode(this.options[this.selectedIndex].value)>
<option value="">请选择广告类别</option>
<%while not rs.eof%>
<option value="<IFRAME marginHeight=0 marginWidth=0 noResize scrolling=no frameBorder=0 src='ShowAd.asp?AdsCategoryID=<%=rs("AdsCategoryID")%>' width=<%=rs("PicWidth")%> height=<%=rs("PicHeight")%>></IFRAME>"><%=rs("CategoryName")%></option>        
<%
rs.movenext
wend
%>
</select></td></tr>  
<tr><td>&nbsp;调用代码</td><td><textarea name="VoteCode" cols="52" rows="5"><%=Def%></textarea></td></tr>
</table>
</form>
<%
rs.close
set rs=nothing
end sub
%>