<%

'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

dim fir_vote_num

Function bbs_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,is_gq
  fir_vote_num=dim_topic(8,0)
  v_sum=0
  v_type="radio"
  sql="select top 1 v_name,v_num,v_type,v_tim,v_day,v_username from AsaiMHBbsVote where reply_id="&viewid
  set rs=Cls.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)
	if v_day = 0 then
	  is_gq = false
	else
	  if tmp1&dateadd("d",v_day,v_tim)<cls.now_time then
	     is_gq = true
	  else
	     is_gq = false
	  end if
	end if
  end if
  rs.close
  if v_name="" or v_num="" then
    tmp1=tmp1&vbcrlf&"<tr><td colspan=2 height=30>&nbsp;<font class=red>投票出现异常错误！</font></td></tr>"
  else
    tmp1=tmp1&vbcrlf&"<tr class=bbs_tr><td colspan=2><table border=0 width='100%'>"
    if (not is_gq and Is_LoginTrue) then tmp1=tmp1&vbcrlf&"<form name=vote_frm action='Vote.asp?id="&viewid&"' method=post onsubmit=""javascript:frm_submitonce(this);"">"
    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 height=25>" & _
           vbcrlf&"<td width='50%'>"&vi+1&".<input type="&v_type&" name=vote_nid value='"&vi&"'>"&Cls.code_html(dim_name(vi),1,0)&"</td>" & _
           vbcrlf&"<td width='50%'><img src='"&Cls.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
    tmp1=tmp1&vbcrlf&"</table>" & _
         vbcrlf&"</td></tr>"
  end if
  if int(v_sum)<>int(fir_vote_num) then
    call Cls.exec("update AsaiMHBbsTopic set vote_num="&v_sum&" where id="&viewid,0)
  end if
  tmp1=tmp1&vbcrlf&"<tr class=bbs_trb><td colspan=2>"
  if Is_LoginTrue then
    if is_gq then
        tmp1=tmp1&"&nbsp;<b>[ <font class=red>此投票已过期</font> ]</b>&nbsp;"
    else
        tmp1=tmp1&"&nbsp;<input type=submit class=btn value='我来投一票'>&nbsp;"
    end if
  else
    if is_gq then
        tmp1=tmp1&"&nbsp;[ <font class=red><b>此投票已过期！</b></font>&nbsp;"
    else
        tmp1=tmp1&"&nbsp;[ 投票请先 <a href='"&Cls.Web_Dir&"User/Register.asp'><b>注册</b></a> 或 <a href='"&Cls.Web_Dir&"User/Login.asp?old_url=back'><b>登陆</b></a> 本站！]&nbsp;"
    end if
  end if
  tmp1=tmp1&"&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
  'if is_gq then tmp1=tmp1&vbcrlf&" [已过期] "
  tmp1=tmp1&"&nbsp;&nbsp;<font class=Gys>[ <a style=""cursor: hand;"" onclick=""javascript:open_win('VoteUser.asp?id="&viewid&"','vote_user',500,450,'yes');"">查看投票用户</a> ]</font></td></tr>"
   if (not is_gq and Is_LoginTrue) then tmp1=tmp1&vbcrlf&"</form>"
 bbs_vote_type = vbcrlf&"<table cellspacing=1 cellpadding=4 class=bbs_table>" & _
         vbcrlf&"<tr><td class=bbs_td colspan=2> 投票："&Cls.code_html(dim_topic(1,0),1,0)&"</td></tr>" & _
         vbcrlf&tmp1 & _
         vbcrlf&"</table>"
end Function

sub bbs_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 AsaiMHBbsVote where reply_id="&viewid
  set rs=Cls.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='100%'>"
  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 width='50%'><font class=Gys>--</font>&nbsp;<b>"&Cls.code_html(dim_name(vi),1,0)&"</b></td>" & _
           vbcrlf&"<td width='50%'><img src='"&Cls.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
  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
%>
