<!--#include file="vote/conn.asp"-->
<%
'调用方式：<Script Language="JavaScript" SRC="vote/Vote.asp?top=3"></Script>
  color1="#003399"	'投票说明字体颜色
  color2="#000000"	'投票项字体颜色
  color3="FF9900"	'投票按钮背景颜色
  
  Set conn=Server.CreateObject("ADODB.Connection")
  conn.open ConnStr
  IF Request.Form("IsSub")="YES" THEN
    SS=Request.Form("SS")  '投票序号
    Set rs=conn.execute("Select Vote_Limit From Vote_list Where ID="&SS) 
	Limit=Cint(rs(0))
    rs.close
    Vote_Ok=False
    IF Limit=2 THEN
      IF Request.Cookies("cycoo_vote_"&SS)="DONE" THEN
	       Vote_Ok=True

      ELSE
			Response.Cookies("cycoo_vote_"&SS) = "DONE" 
			Response.Cookies("cycoo_vote_"&SS).Expires = date()+1 '设置cookie的过期日
      END IF
    END IF

    IF Vote_Ok=True THEN
       Response.write "<Script language=JavaScript>alert('你今天已经投过票了\n\n请再过24小时才能投票！')</Script>;" '这里自己可以设置下面基本上都不用改了
    ELSE
      FOR EACH name IN Request.Form("rc")
        conn.execute "Update Vote_Answer Set VoteResult=VoteResult+1 Where ID="&name
      NEXT  
    END IF
    Response.write "<Script language=JavaScript>window.open('VoteView.asp?ID="&SS&"','','width=420,height=350,scrollbars=yes');window.close();</Script>"
  Response.end
END IF

  Response.write "document.write("""
  top=Cint(Request.QueryString("top"))
  IF top<1 THEN top=1
  Set rs=conn.execute("Select Top "&top&" ID,Project,MultiSelect From Vote_List Where online=True Order By ID DESC")
  IF rs.eof THEN
    Response.write "<font color=red>目前还没有投票项目</font>"
  ELSE
    Set rs2=Server.Createobject("ADODB.RecordSet")
    While NOT rs.eof
      Response.write "<table border=0 cellspadding=0><form method=POST action='vote/Vote.asp' target=_blank><tr><td><input type=hidden name=IsSub value=YES><input type=hidden name=SS value="&rs(0)&">"
      Response.write "<font color="&color1&">"&rs(1)&"</font><br>"
      rs2.open "Select ID,VoteContent From Vote_Answer Where ListID="&rs(0),conn,1,1
      i=1
      While NOT rs2.eof
        Response.write "<tr><td><input type="
        IF rs(2)=True THEN
          Response.write "checkbox"
        ELSE
          Response.write "radio"
        END IF
        Response.write " name=rc value="&rs2(0)&"> <font color="&color2&">"&rs2(1)&"</font></td></tr>"
        rs2.MoveNext
        i=i+1
      WEND
      rs2.close
      Response.write "<tr><td align=center><input type=submit value=投票 style=background-color:"&color3&"> <input type=button value=查看 style=background-color:"&color3&" onclick=javascript:window.open('vote/VoteView.asp?ID="&rs(0)&"\',\'\',\'width=420,height=350,scrollbars=yes\')></td></tr>"
      Response.write "</td></tr></form></table>"
      rs.MoveNext
    WEND
    Set rs2=nothing
  END IF
  Response.write """);"
  rs.close
  Set rs=nothing
  conn.close
  Set conn=nothing
%>