<!-- #include file="main.asp" -->
<%

dim fir_vote_num

sub forum_vote_type()
  dim tmp1,dim_name,dim_num,v_name,v_num,v_type,v_tim,v_day,v_username,vi,v_sum,n_num
  v_sum=0
  v_type="radio"
  tmp1=vbcrlf&"<tr><td class=bbs_td colspan=2>投票："&joekoe_cms.code_html(fir_topic,1,0)&"</td></tr>"
  sql="select top 1 v_name,v_num,v_type,v_tim,v_day,v_username from bbs_vote where reply_id="&viewid
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    v_name=rs(0)
    v_num=rs(1)
    if rs(2) then v_type="checkbox"
    v_tim=rs(3)
    v_day=rs(4)
    v_username=rs(5)
  end if
  rs.close
  if v_name="" or v_num="" then
    tmp1=tmp1&"<tr><td class=bbs_tr colspan=2 height=25>&nbsp;<font class=red>投票出现异常错误！</font></td></tr>"
  else
    tmp1=tmp1&"<tr class=tr><td><table cellspacing=1 cellpadding=4 width=100% >"&vbcrlf&"<form name=vote_frm action='vote.asp?view_id="&viewid&"' method=post>"
    dim_name=split(v_name,"|")
    dim_num=split(v_num,"|")
    for vi=0 to ubound(dim_num)
      v_sum=v_sum+dim_num(vi)
    next
    for vi=0 to ubound(dim_name)
      n_num=1
      if int(v_sum)>0 then
        n_num=cint(replace(formatpercent(dim_num(vi)/v_sum),"%",""))*3.3
        if int(n_num)<1 then n_num=1
      end if
      tmp1=tmp1&vbcrlf&"<tr class=bbs_tr height=25>" & _
		     vbcrlf&"<td><input type="&v_type&" name=vote_nid value='"&vi&"' class=bg_td>"&joekoe_cms.code_html(dim_name(vi),1,0)&"</td>" & _
		     vbcrlf&"<td width='*'><img src='"&joekoe_cms.web_dir&"images/vote/vb"&vi+1&".gif' border=0 width="&n_num&" height=8>&nbsp;"&dim_num(vi)&" 票</td>" & _
		     vbcrlf&"</tr>"
    next
    erase dim_name
    erase dim_num
  end if
  if int(v_sum)<>int(fir_vote_num) then
    call joekoe_cms.exec("update bbs_topic set vote_num="&v_sum&" where id="&viewid,0)
  end if
  tmp1=tmp1&"</table></td></tr><tr><td class=trb colspan=2 height=25>&nbsp;"
  if login_mode="" then
    tmp1=tmp1& web_nologin
  else
    tmp1=tmp1&"<input type=submit class=btn value='我来投一票'>&nbsp;&nbsp;投票信息：共<font class=red>"&v_sum&"</font>票，截止日期："
    if int(v_day)=0 then
      tmp1=tmp1&"永不过期"
    else
      tmp1=tmp1&dateadd("d",v_day,v_tim)
    end if
  end if
  tmp1=tmp1&vbcrlf&"&nbsp;&nbsp;<font class=gray>[ <a href='javascript:;' onclick=""javascript:open_win('vote_user.asp?view_id="&viewid&"','vote_user',500,400,'yes');"">查看投票用户</a> ]</font></td></tr>" & _
           vbcrlf&"</form>"
  call forum_bar_top("&nbsp;投票："&joekoe_cms.code_html(fir_topic,1,0)&"",tmp1,1)
end sub

sub forum_vote_print()
  dim tmp1,dim_name,dim_num,v_name,v_num,v_tim,v_day,v_username,vi,v_sum,n_num
  v_sum=0
  sql="select top 1 v_name,v_num,v_type,v_tim,v_day,v_username from bbs_vote where reply_id="&viewid
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    v_name=rs(0)
    v_num=rs(1)
    v_tim=rs(3)
    v_day=rs(4)
    v_username=rs(5)
  end if
  rs.close
  tmp1=vbcrlf&"<table border=0 cellspacing=0 cellpadding=2 width='99%'>"
  if v_name="" or v_num="" then
    tmp1=tmp1&vbcrlf&"<tr><td colspan=2 height=30>&nbsp;<font class=red>投票出现异常错误！</font></td></tr>"
  else
    dim_name=split(v_name,"|")
    dim_num=split(v_num,"|")
    for vi=0 to ubound(dim_num)
      v_sum=v_sum+dim_num(vi)
    next
    for vi=0 to ubound(dim_name)
      n_num=1
      if int(v_sum)>0 then
        n_num=cint(replace(formatpercent(dim_num(vi)/v_sum),"%",""))*3.3
        if int(n_num)<1 then n_num=1
      end if
      tmp1=tmp1&vbcrlf&"<tr>" & _
           vbcrlf&"<td ><font class=gray>--</font>&nbsp;<b>"&joekoe_cms.code_html(dim_name(vi),1,0)&"</b></td>" & _
           vbcrlf&"<td width='*'><img src='../images/vote/vb"&vi+1&".gif' border=0 width="&n_num&" height=8>&nbsp;"&dim_num(vi)&" 票</td>" & _
           vbcrlf&"</tr>"
    next
    erase dim_name
    erase dim_num
  end if
  tmp1=tmp1&vbcrlf&"<tr><td colspan=2>&nbsp;投票信息：共<font class=red>"&v_sum&"</font>票，截止日期："
  if int(v_day)=0 then
    tmp1=tmp1&"永不过期"
  else
    tmp1=tmp1&dateadd("d",v_day,v_tim)
  end if
  tmp1=tmp1&vbcrlf&"</table>"
  response.write tmp1
end sub

%>