<!--#include file="Head.asp"-->

<table width="950" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="240" height="500" valign="top">
<!--#include file="tabmenu.asp"-->
	</td>
    <td width="1" bgcolor="#000000"></td>
    <td width="680" valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="26" height="32" align="center" bgcolor="#FFFFFF">&nbsp;</td>
          <td width="674" bgcolor="#FFFFFF" class="Location"><a href="../index.asp">首页</a><img src="../Images/Arrow_02.gif" width="13" height="12" align="absmiddle">排行榜</td>
          <td width="80" bgcolor="#FFFFFF" class="Location"></td>
        </tr>
      </table>
<%
response.Write"<table border=0 cellpadding=0 cellspacing=0 width='100%' align=center bgcolor=#FFFFFF ><tr><td valign=top >"
				Const MaxPerPage=25
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
				dim SortPath,rsTotle,sqlTotle
   				dim j
    				if Not isempty(request.QueryString("page")) then
      				currentPage=Cint(request.QueryString("page"))
   				else
      				currentPage=1
   				end if 
				Set rs=server.CreateObject("Adodb.Recordset")
				sql="select * from ameav_Products where ViewFlag  order by ClickNumber desc"
				rs.Open sql,conn,1,1
		  

  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' class='contents'> 对不起，此分类暂时还没有排行！</p>"
   				else
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"Producttotal.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookmark
            				bookmark=rs.bookmark
            				showContent
             				showpage totalput,MaxPerPage,"Producttotal.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"Producttotal.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0

			set rsTotle=server.CreateObject("adodb.recordset")
			sqlTotle="select SUM(ClickNumber) from ameav_Products where ViewFlag  "
			rsTotle.open sqlTotle,connstr
			if rsTotle(0)=0 then
			   response.write "目前还没有投票数!"
			else
			do while not rs.eof
			%>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1">
            <tr>
              <td width="19%" height="25" class='ListTitlv'><%=rs("ProductName")%></td>
              <td width="61%" class='ListTitlv'><img src="../images/dot1.gif" width="<%=int(100*rs("ClickNumber")/rsTotle(0))%>%" height="15"></td>
              <td width="9%" class='ListTitlv'><div align="right"><span class="style4"><%=int(100*rs("ClickNumber")/rsTotle(0))%></span>%</div></td>
              <td width="11%" class='ListTitlv'><div align="right"><span class="style4"><%=rs("ClickNumber")%></span>票</div></td>
            </tr>
</table>
                  <%
			i=i+1
			if i>=MaxPerPage then Exit Do
			rs.movenext
			loop
			rs.close
			set rs=nothing
			end if 
				End Sub   
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If %>
				<form method=Post action=<% = filename %>?page=<% = page %>>
              <%
				If CurrentPage<2 Then  %><div align="center">
              首页 上页 
              <% Else  %><div align="center">
              <a href=<% = filename %>?page=1>首页</a> 
			  <a href=<% = filename %>?page=<% = CurrentPage-1 %>>上页</a> 
              <%
				End If
				If n-currentpage<1 Then  %>
              下页 尾页 
              <%	Else  %>
              <a href=<% = filename %>?page=<% = (CurrentPage+1) %>>下页</a> 
              <a href=<% = filename %>?page=<% = n %>>尾页</a> 
              <%	End If  %>
              第 <b> 
              <% = CurrentPage %>
              </b>页 共 <b> 
              <% = n %>
              </b>页 共 <b> 
              <% = totalnumber %>
              </b>条 每页 <b> 
              <% = maxperpage %>
			  条
				</form>
				<%
				End Function  
			%>	</td>
    <td width="10" valign="top">&nbsp;</td>
  </tr>
</table>
	</td>
  </tr>
</table>
<!--#include file="Foot.asp"-->