<!-- #include file="include/config.asp" -->
<!-- #include file="../include/jk_em.asp" -->
<!-- #include file="include/other.asp" -->
<!-- #include file="../include/jk_emoney.asp" -->
<!-- #include file="../include/jk_frm.asp" -->
<!-- #include file="../include/jk_convert.asp" -->
<%
tit=login_username&"的点歌机"
dim musicname
dim m_emoney,m_power,words,max_num,send_true
words=trim(request("words"))
max_num=web_dim(35)

sql="select emoney,power from music_song where hidden=1 and id="&id
set rs=joekoe_cms.exec(sql,1)
m_emoney=rs("emoney")
m_power=rs("power")
rs.close
call web_head(2,0,4,0,0)
call music_load()

 
if types="chk" then
dim paymode,payrate,paynum,rssum
  sql="select username,power from user_data where username='"&trim(request("receiveuser"))&"'"
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    response.write joekoe_cms.js_put("alert(""错误提示：此人尚未注册，无法点歌给他（她）。"");window.opener=null;window.close();",1)
  else
    max_num=web_dim(35)
    call convert_load(rs("power"))
    max_num=format_convert(max_num,"+")
    rs.close
  end if
    sql="select count(id) from music_mail where r_user='"&trim(request("receiveuser"))&"'"
    set rs=joekoe_cms.exec(sql,1)
    rssum=rs(0)
    rs.close
    if rssum >= max_num then 
      response.clear
      response.write joekoe_cms.js_put("alert(""错误提示：对方的收歌箱已满，请等待对方清除多余的收歌单。"");window.opener=null;window.close();",1)
      response.end
    else
      max_num=web_dim(35)
      call convert_load(login_mode)
      max_num=format_convert(max_num,"+")
      sql="select count(id) from music_mail where s_user='"&login_username&"'"
      set rs=joekoe_cms.exec(sql,1)
      rssum=rs(0)
      rs.close
      if rssum >= max_num then 
      response.clear
      response.write joekoe_cms.js_put("alert(""错误提示：您的点歌箱已满，请清除多余的点歌单。"");window.opener=null;window.close();",1)
      response.end
      end if
    end if

  if music_se.music_free then
    send_true=true
  else
    send_true=emoney_notes(m_power,m_emoney,"music",id,0,"")
  end if
  if not send_true then
    call music_error("歌曲点播出错：\n\n您没有足够的权限或钱币进行刚才的操作！\n\n也可能您还没有注册和登陆本站。")
  end if

  sql="select * from music_song where hidden=1 and id="&id
  set rs=joekoe_cms.exec(sql,1)
  MusicName=rs("name")
  rs.close
  sql="select * from music_mail where (id is null)"
  call joekoe_cms.exec(sql,-1)     
  rs.Open sql,conn,1,3
  rs.AddNew
  rs("s_user")=login_username
  rs("r_user")=trim(request("receiveuser"))
  rs("m_name")=MusicName
  rs("m_id")=id
  rs("paynum")=0
  rs("emoney")=m_emoney
  rs("power")=m_power
  rs("words")=words
  rs("tim")=now()
  rs("isread")=false
  rs.Update 
  rs.close
  response.clear
  response.write joekoe_cms.js_put("alert(""提示：成功发送歌曲！"");window.opener=null;window.close();",1) 
   
else
  sql="select * from music_song where hidden=1 and id="&id
  set rs=joekoe_cms.exec(sql,1)
  if rs.eof then
    rs.close
    response.clear
    response.write joekoe_cms.js_put("alert(""错误提示：没有找到这首歌曲！"");window.opener=null;window.close();",1)
  else
  MusicName=rs("Name")
  rs.close

%>
<script Language="JavaScript">
<!-- 
function Form1_Validator(theForm) 
{ 
  if (theForm.receiveuser.value == "") 
    { 
    alert("您想点给谁？"); 
    theForm.receiveuser.focus(); 
    return (false); 
    } 
  if (theForm.Words.value.length > 66) 
    { 
    alert("话也太多了些吧，至多66个字符！"); 
    theForm.Words.focus(); 
    return (false); 
    } 
  return (true); 
} 
//--></script>
<script language=javascript>
function do_accept(addaccept)
{
  if (addaccept!="")
  { document.write_frm.receiveuser.value=addaccept; }
}
</script>

<table border=0 width='100%' cellspacing=1 cellpadding=1 class=mtb>
<tr>
<td colspan=2 class=td>&nbsp;<%response.write img_skin("m_user")%><%=login_username%>的点歌机</td>
</tr>             
<form method="POST" name="write_frm" action="?types=chk&Id=<%=id%>" onsubmit="return Form1_Validator(this)" >   
<tr class=bg_td>
<td width=15%>&nbsp;&nbsp;点 歌 给：</td>
<td width=*><INPUT type=text name=receiveuser size=30 maxlength=20><script language=javascript>document.write(redx);</script><=20<%response.write friend_select()%></td>
</tr>
<tr class=bg_tds>
<td width=15%>&nbsp;&nbsp;歌曲名称：</td>
<td width=*><INPUT type=text name=musicname value=<%=musicname%> size=60 maxlength=20></td>
</tr>
<tr class=bg_td>
<td><%call frm_ubb_type("class=bg_td")%></td>
<td><%call frm_ubb("write_frm","words","",0)%></td>
</tr>
<tr width=15% class=bg_td>
<td valign=center>&nbsp;&nbsp;祝福话语：</td>
<td width=*><TEXTAREA name=words rows=7 cols="60" title="内容不能超过66个字符！"></TEXTAREA></td>
</tr>
<tr class=bg_tds>
<td colspan=2 align=center><%response.write jk_em("write_frm","words")%></td>
</tr>
<tr class=bg_tds>
  <td>&nbsp;&nbsp;所需权限：</td>
  <td><%response.write format_emoney_power(""&m_emoney&"",""&m_power&"",1)%></td>
  </tr>
<tr class=bg_td>
<td>&nbsp;&nbsp;付费说明：</td><td><font class=red>点播这首歌曲需要扣除您 <%response.write m_emoney%> 个金币</font></td>
          </tr>
<tr class=bg_tds>
<td height=30 colspan=2 align=center><input type="submit" class="btn"  value="送出歌曲">&nbsp;&nbsp;<input type="reset" class="btn"  value="重新填写"></td>
</tr>
</FORM>				
</table>
<%
    end if
end if

set rs=nothing
'---------------------------------center end-------------------------------

call web_end(0,1)

function friend_select()
  dim rsf,ttt,temp1
  temp1=vbcrlf&"<select name=friend_select size=1 onchange=""javascript:do_accept(this.options[this.selectedIndex].value);"">" & _
	vbcrlf&"<option value='' class=bg_td>选择我的好友</option>"
  set rsf=joekoe_cms.exec("select username2 from user_friend where username1='"&login_username&"' order by id",1)
  do while not rsf.eof
    ttt=rsf(0)
    temp1=temp1&vbcrlf&"<option value='"&ttt&"'>"&ttt&"</option>"
    rsf.movenext
  loop
  rsf.close
  set rsf=nothing
  temp1=temp1&vbcrlf&"</select>"
  friend_select=temp1
end function
%>