<!-- #include file="include/con_video.asp" -->
<!-- #include file="include/jk_emoney.asp" -->
<%
dim id,fid
id=trim(request.querystring("id"))
fid=trim(request.querystring("fid"))
if not(isnumeric(id)) or not(isnumeric(fid)) then call video_error("")

dim power,emoney,vname,vtype,username,tim,vserver,downs_url,fname,furl,isfree,is_down
is_down=int(mid(video_dim(3),1,1))
if is_down=1 then iframe=true

sql="select video.username,video.name,video.emoney,video.power,video.viewtype,video.tim,video.isfree,video.server_id" & _
	",video_url.url,video_url.urlname from video_url inner join video on video_url.nameid=video.id" & _
	" where video.hidden=1 and video_url.id="&fid&" and video.id="&id
set rs=joekoe_cms.exec(sql,1)
if rs.eof then
  rs.close
  call video_error("")
end if
power=rs("power")
emoney=int(rs("emoney"))
vname=joekoe_cms.code_html(rs("name"),1,0)
vtype=int(rs("viewtype"))
username=rs("username")
tim=rs("tim")
fname=rs("urlname")
furl=rs("url")
isfree=rs("isfree")
vserver=int(rs("server_id"))
rs.close

tit="影视下载"
if vtype=1 then call video_error("nodown")

downs_url=video_skin.video_server(vserver,1,furl)
if instr(downs_url,"://")=0 then downs_url=joekoe_cms.web_url&downs_url

call web_head(0,0,4,0,0)
'----------------------------影片下载 开始----------------------------
if not video_skin.video_free then response.write video_skin.chk_user_power(power,"下载")
if action="download" then
  call chk_download()
  response.clear
  response.write "nodownload"
  response.redirect downs_url
  response.end
elseif action="downloads" then
  call chk_download()
  response.clear
%>
<SCRIPT LANGUAGE="JavaScript">
var JetCar_Err="您的机器并未安装 FlashGet！\n\n是否立即下载 FlashGet ？";
var JetCar_Url="http://www.amazesoft.com/cn/download.htm";
</script>
<script language="vbscript">
function FlashGet(nL,nT)
  set JetCarCatch=CreateObject("JetCar.Netscape")
  if err<>0 then
    if window.confirm(JetCar_Err) then
		window.location = JetCar_Url
	end if
  else
    call JetCarCatch.AddUrl(nL,nT,nL)
    window.close
  end if
End function
</script>
<SCRIPT LANGUAGE="JavaScript">
FlashGet("<%response.write downs_url%>","<%response.write vname%>")
</script>
<%
  response.end
end if

if is_down=1 then
%>
<SCRIPT LANGUAGE="JavaScript">
function video_down(url)
{
  var t1=note_emoney('下载此影片','<%response.write emoney%>','<%response.write power%>');
  if (t1)
  {
    document.down_frm.video_url.value=url;
    document.down_frm.submit();
  }
}
</SCRIPT>
<form name=down_frm action='?action=download&id=<%response.write id%>&fid=<%response.write fid%>' method=post target=hiddenframe>
<input type=hidden name=video_url value=''>
</form>
<%end if%>
<table cellspacing=1 cellpadding=4 class=table>
<tr height='22'><td class=td0 colspan=2><b><%response.write tit%> --> <%response.write vname%></b></td></tr>
<tr height='22'><td class=bg_tds colspan=2><font class=red>注意：有些地址中带有中文字符可能会造成无法下载！请尽量用软件下载！</font></td></tr>
<tr height='22' class=bg_td><td width='20%' align=center><font class=blue>下载地址：</font></td><td>&nbsp;
  <%if is_down=1 then
      response.write "<b>只能直接点击下载</b>：  <a href='javascript:;' onclick=""javascript:video_down('');"""
    else
      if lcase(left(downs_url,7))="http://" or lcase(left(downs_url,6))="ftp://" then
        response.write "<b>直接点击可用Flashget下载</b>： <a href='?action=download&id="&id&"&fid="&fid&"'"
      else
        response.write "<font class=red><b>该影片可能是流媒体格式，直接点击调用Flashget下载</b></font>： <a href='?action=downloads&id="&id&"&fid="&fid&"'"
      end if
    end if
  %>><%response.write fname%></a></td></tr>
<tr height='20'><td class=bg_tds align=center colspan=2>发布人：<%response.write format_user_name(username,0,"")%>&nbsp;&nbsp;发布时间：<%response.write joekoe_cms.time_type(tim,1)%></font></td></tr>
</table>
<%
call video_end()
'----------------------------影片下载 结束----------------------------
call web_end(0,1)

sub chk_download()
  dim down_true
  response.clear
  if not joekoe_cms.post_chk() then
    call video_error("nopost")
  end if
  if video_skin.video_free then
    down_true=true
  else
    down_true=emoney_notes(power,emoney,n_sort,fid,0,"")
  end if
  call video_end()
  if not down_true then
    call video_error("nopower")
  end if
  sql="update video set counter=counter+1 where id="&id
  call joekoe_cms.exec(sql,0)
  call web_clear(0)
end sub
%>