<!--#include file ="include/config.asp"-->
<!--#include file ="include/conn.asp"-->
<%
dim AdsCategoryID,CurrentSCount,AdsID,AdsType,PicUrl,PicHeight,PicWidth,rs1
AdsCategoryID=request("AdsCategoryID")
if AdsCategoryID<>"" then

set rs=server.createobject("Adodb.recordset")
sql="select CurrentSCount,SProportion from Ads where AdsState=1 and AdsCategoryID="&AdsCategoryID
rs.open sql,conn,1,3
if rs.eof then response.end
CurrentSCount=0
while not rs.eof
  CurrentSCount=rs("CurrentSCount")+CurrentSCount
rs.movenext
wend
if CurrentSCount<=0 then
  rs.MoveFirst
  while not rs.eof
    rs("CurrentSCount")=rs("SProportion")
	rs.update
  rs.movenext
wend
end if

set rs=server.createobject("Adodb.recordset")
sql="select AdsID,AdsType,PicUrl,PicHeight,PicWidth,CurrentSCount,ShowState,ShowCount,AdsState,ShowFiltrationIP,ShowTime from Ads where AdsState=1 and AdsCategoryID="&AdsCategoryID&" order by CurrentSCount desc"
rs.open sql,conn,1,3
if rs.eof then response.end
AdsID=rs("AdsID")
AdsType=rs("AdsType")
PicUrl=rs("PicUrl")
PicHeight=rs("PicHeight")
PicWidth=rs("PicWidth")
rs("CurrentSCount")=rs("CurrentSCount")-1

select case AdsType
case "flash"
%>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="<%=PicWidth%>" height="<%=PicHeight%>"><param name=movie value="<%=PicUrl%>"><param name=quality value=high><embed src="<%=PicUrl%>" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="<%=PicWidth%>" height="<%=PicHeight%>"></embed></object>
<%
case "pic"
%>
<table width="100%" height="100%" border=0 cellpadding=0 cellspacing=0>
  <tr>
    <td align="center"><a href="adsurl.asp?AdsID=<%=AdsID%>" target=_blank><img src="<%=PicUrl%>" border=0 width="<%=PicWidth%>" height="<%=PicHeight%>"></a></td>
  </tr></table>
<%
end select
end if
call close_conn()
%>