<!--#Include File="../../Include.asp"--><%
'--------------------------------------
'Power By 580Web @2010-2014 f02
'URL:http://www.580Web.Cn/
'EMail:wsok85@qq.com
'QQ:253819801
'版权所有 未经允许不得去除本版权信息
'--------------------------------------

Dim Fk_Vote_Name,Fk_Vote_Content,Fk_Vote_Ticket
Dim Vote_Record,Vote_Ticket,VoteProportion,ChooseRecord

Types=Clng(Request.QueryString("Type"))

Id=Clng(Request.QueryString("Id"))

'读取投票信息
Sqlstr="Select Fk_Vote_Name,Fk_Vote_Content,Fk_Vote_Ticket From [Fk_Vote] Where Fk_Vote_Id=" & Id
Rs.Open Sqlstr,Conn,1,1
If Not Rs.Eof Then
	Fk_Vote_Name=Rs("Fk_Vote_Name")
	Fk_Vote_Content=Rs("Fk_Vote_Content")
	Fk_Vote_Ticket=Rs("Fk_Vote_Ticket")
Else
	Rs.Close
	Call FKFun.PageEnd()
End If
Rs.Close

If Types=1 Then '读取投票
%>
document.writeln("<form id=\"vote<%=Id%>\" name=\"vote<%=Id%>\" method=\"post\" target=\"_blank\" action=\"<%=SiteDir%>Plugin/Vote/Vote.asp?Type=2&Id=<%=Id%>\">");
document.writeln("    <p><%=Fk_Vote_Name%></p>");
<%
	TempArr=Split(Fk_Vote_Content,"|VoteList|")
	i=1
	For Each Temp In TempArr
		If Temp<>"" Then
			Vote_Record=FKFun.GetSub(Temp,"Vote_Record:","|;|","")
			Vote_Ticket=FKFun.GetSub(Temp,"Vote_Ticket:","|;|","")
			If Fk_Vote_Ticket>0 Then
				VoteProportion=Left(Vote_Ticket/Fk_Vote_Ticket*100,4)
			Else
				VoteProportion=0
			End If
%>
document.writeln("    <p><input type=\"checkbox\" name=\"voteChoose<%=Id%>\" id=\"voteChoose<%=Id%>\" value=\"<%=i%>\" /><%=Vote_Record%></p>");
<%
			i=i+1
		End If
	Next
%>
document.writeln("    <p><input type=\"hidden\" name=\"Id\" value=\"<%=Id%>\" /><input type=\"submit\" name=\"button\" id=\"button\" value=\"投票\" />&nbsp;&nbsp;<input type=\"button\" onclick=\"window.open(\'<%=SiteDir%>Plugin/Vote/Vote.asp?Type=3&Id=<%=Id%>\',\'newwindow\',\'width=700,heigh=100,scrollbars=1\')\" name=\"button\" id=\"button\" value=\"查看结果\" /></p>");
document.writeln("</form>");
<%	
ElseIf Types=2 Or Types=3 Then '执行投票
	If Types=2 Then
		ChooseRecord=","&FKFun.HTMLEncode(Trim(Replace(Request.Form("voteChoose"&Id)," ","")))&","
		If ChooseRecord=",," Then
			Call FKFun.AlertInfo("至少需要选择一个选项！",1)
		End If
		Fk_Vote_Ticket=Fk_Vote_Ticket+1
		i=1
		TempArr=Split(Fk_Vote_Content,"|VoteList|")
		Fk_Vote_Content=""
		For Each Temp In TempArr
			If Temp<>"" Then
				Vote_Record=FKFun.GetSub(Temp,"Vote_Record:","|;|","")
				Vote_Ticket=FKFun.GetSub(Temp,"Vote_Ticket:","|;|","")
				If Instr(ChooseRecord,","&i&",")>0 Then
					Vote_Ticket=Vote_Ticket+1
				End If
				Fk_Vote_Content=Fk_Vote_Content&"Vote_Record:"&Vote_Record&"|;|Vote_Ticket:"&Vote_Ticket&"|;||VoteList|"
				i=i+1
			End If
		Next
		Sqlstr="Update [Fk_Vote] Set Fk_Vote_Content='"&Fk_Vote_Content&"',Fk_Vote_Ticket="&Fk_Vote_Ticket&" Where Fk_Vote_Id=" & Id
		Application.Lock()
		Conn.Execute(Sqlstr)
		Application.UnLock()
	End If
	Call PageTop(Fk_Vote_Name)
%>
<div class="pool_wrap">
	<div class="pool">
		<div class="pool_tit"><h3><%=Fk_Vote_Name%></h3></div>
		<ul class="poll_view">
<%
	TempArr=Split(Fk_Vote_Content,"|VoteList|")
	i=1
	j=1
	For Each Temp In TempArr
		If Temp<>"" Then
			Vote_Record=FKFun.GetSub(Temp,"Vote_Record:","|;|","")
			Vote_Ticket=FKFun.GetSub(Temp,"Vote_Ticket:","|;|","")
			If Fk_Vote_Ticket>0 Then
				VoteProportion=Left(Vote_Ticket/Fk_Vote_Ticket*100,4)
			Else
				VoteProportion=0
			End If
%>
			<li class="list_item_0<%=j%>"><span class="list_name"><%=i%>.<%=Vote_Record%></span><div class="plan"><div class="plan_l" style="width:<%=VoteProportion%>%;"><div class="plan_r"><div class="plan_m"></div></div></div></div><div class="number"><%=Vote_Ticket%>(<%=VoteProportion%>%)</div></li>
<%
			i=i+1
			If j=6 Then
				j=1
			Else
				j=j+1
			End If
		End If
	Next

%>
		</ul>
	</div>
</div>
<%
	Call PageBottom()
End If


Call FKFun.PageEnd()

Function PageTop(pTitle)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=pTitle%></title>
<style type="text/css"> 
*{ margin:0; padding:0;}
body { font:12px/1.8 Arial; color:#666; margin-top:50px;}
ul,li{ list-style:none;}

.pool_wrap{border:1px solid #ffe896;width:674px; margin:0 auto;}
.pool{ background:#fff;border:3px solid #fff8de; padding:30px 30px;}
.pool_tit{ text-align:center; color:#444;}
.poll_view{ padding:30px 10px;}
.poll_view li{ line-height:16px; height:16px; margin-bottom:10px;}
.poll_view .list_name{ float:left; width:180px; height:16px; overflow:hidden; text-align:right; padding-right:10px;}
.poll_view .plan{ background:#fff6cb; width:285px; height:16px; float:left;}
.poll_view .number{ float:right; padding-left:5px; text-align:right; width:66px;}
.plan_l,.plan_r,.plan_m{ background:url(plan.gif) -999em -999em no-repeat; height:16px;}
.plan_r{ margin-left:2px; padding-right:2px;}
.list_item_01 .plan_l{ background-position:0 0;}
.list_item_01 .plan_r{ background-position:right -26px;}
.list_item_01 .plan_m{ background-position:0 -312px; background-repeat:repeat-x;}
.list_item_02 .plan_l{ background-position:0 -52px;}
.list_item_02 .plan_r{ background-position:right -78px;}
.list_item_02 .plan_m{ background-position:0 -339px; background-repeat:repeat-x;}
.list_item_03 .plan_l{ background-position:0 -104px;}
.list_item_03 .plan_r{ background-position:right -130px;}
.list_item_03 .plan_m{ background-position:0 -367px; background-repeat:repeat-x;}
.list_item_04 .plan_l{ background-position:0 -156px;}
.list_item_04 .plan_r{ background-position:right -182px;}
.list_item_04 .plan_m{ background-position:0 -395px; background-repeat:repeat-x;}
.list_item_05 .plan_l{ background-position:0 -208px;}
.list_item_05 .plan_r{ background-position:right -234px;}
.list_item_05 .plan_m{ background-position:0 -420px; background-repeat:repeat-x;}
.list_item_06 .plan_l{ background-position:0 -260px;}
.list_item_06 .plan_r{ background-position:right -286px;}
.list_item_06 .plan_m{ background-position:0 -447px; background-repeat:repeat-x;}
</style>
</head>

<body>
<%
End Function

Function PageBottom()
%>
</body>
</html>
<%
End Function
%>
