<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<!-- #include file="inc/function.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p13")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<HTML>
<HEAD>
<TITLE>获得投票代码</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
</style>

</HEAD>
<BODY>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#F5F5F5">
<td style="padding:10px;">
<%
dim id,act,title,optionNum,optionType,votestatus,expiresTime,voteType
id=cint(request("id"))
if(id<1) then
	response.Write("没有找到id="&id&"的记录！")
	response.End()
end if
dim voteid,tempArr
	Set rs = Server.CreateObject("Adodb.RecordSet")				 
	rs.Open "Select top 1 * from vote where id="&id,conn,3,1
	if not rs.eof then
		title=rs("title")
		optionType=rs("optionType")
		if(optionType=0) then
			voteType="radio"
		else
			voteType="checkbox"
		end if
		if(rs("status")<>1) then
			response.Write("投票已过期或暂时关闭.")
			response.End()
		end if
		If datediff("s",now(),formatdatetime(rs("expiresTime")))<0 then
			response.Write("投票已过期.")
			response.End()
		end if
	else
		response.Write("没有找到记录")
		response.End()
	end if
	rs.close
	set rs=nothing
''''''''''''''''''''''''''''''''''初使化''''''''''''''''''''''''''''
dim tempJsStr
tempJsStr=""
tempJsStr=tempJsStr&"document.write('<FORM method=""POST"" name=""VoteForm"" target=""_blank"" action="""&SiteUrl&"/vote.asp?id="&id&""" style=""margin:0 0 0 0;"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('<TABLE width=""100%"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""1"" bgcolor=""#eeeeee"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('<TR bgcolor=""#F9F9F9"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('  <TD colspan=""2""><div align=""center""><font color=""red"">"&title&"</font></div></TD>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</TR>');"&Chr(10)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim voteArr
Set rs = Server.CreateObject("Adodb.RecordSet")				 
rs.Open "Select id,itemName,clicks,colors from voteitem where voteid="&id,conn,3,1
if not rs.eof then
	voteArr=rs.GetRows()
	rs.close
	set rs=nothing
	for i=0 to ubound(voteArr,2)
		tempJsStr=tempJsStr&"document.write('<TR bgcolor=""#F9F9F9"">');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('  <TD width=""14%""><div align=""center""><font color="""&voteArr(3,i)&""">■</font></div></TD>');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('  <TD width=""86%""><div align=""left"">');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('    <input type="""&voteType&""" name=""vote"" value="""&voteArr(0,i)&"""> ');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('    "&voteArr(1,i)&"&nbsp;');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('</div></TD>');"&Chr(10)
		tempJsStr=tempJsStr&"document.write('</TR>');"&Chr(10)

	next
else
	rs.close
	set rs=nothing
end if
tempJsStr=tempJsStr&"document.write('<TR bgcolor=""#F9F9F9"">');"&Chr(10)
tempJsStr=tempJsStr&"document.write('	<TD align=right>&nbsp;</TD>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('    <TD align=right><div align=""left"">');"&Chr(10)	
tempJsStr=tempJsStr&"document.write('        <input type=image src="""&SiteUrl&"/images/voteSubmit.gif"">&nbsp;&nbsp;');"&Chr(10)
tempJsStr=tempJsStr&"document.write('        <a href="""&SiteUrl&"/vote_result.asp?id="&id&""" target=""_blank""><img src="""&SiteUrl&"/images/voteView.gif"" border=0></a>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('    </div></TD>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</TR>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</TABLE>');"&Chr(10)
tempJsStr=tempJsStr&"document.write('</FORM>');"&Chr(10)
'生成JS
call SaveTextFile(server.mappath("../vote/js_"&id&".js"),tempJsStr)

response.write("<p>投票"&title&"的调用代码为：<br><br><textarea style=""width:100%"" rows=""5"">&lt;script src="""&SiteUrl&"/vote/js_"&id&".js""&gt;&lt;/script&gt;</textarea></p>")
response.write("<p align=""center"">请将以上代码复制到您要插入投票的地方。</p>") 
response.write("<p align=""center"">><a href=""#"" onClick=""javascript:history.back()""><==返 回</a></p>") 
call connclose()
%>
</td>
</tr>
</TABLE>
</body>
</html>