<!-- #include file="include/con_music.asp" -->
<!-- #include file="include/jk_em.asp" -->
<!-- #include file="include/jk_convert.asp" -->
<!-- #include file="include/jk_pagecute.asp" -->
<!-- #include file="include/jk_page_cute.asp" -->
<%
tit_fir="音乐频道"
tit=login_username&"的音乐收藏夹"
dim favname,singer,t_name,t_type,actions,max_num,numusic_perent,f_num,favpic,favtim,favcom,favlang
dim nummer,nums,rssum,page,viewpage,thepages,pageurl,li,tmp:li=0 
max_num=music_dim(11)
actions=trim(request.form("actions"))
call web_head(2,0,0,0,0)
call convert_load(login_mode)
max_num=format_convert(max_num,"+")
call music_load()
%>
<TABLE width=777 border=0 align="center" cellPadding=0 cellSpacing=0 
background="image/music/j7.gif">
  <TBODY>
    <TR> 
      <TD width=58 height=38><IMG height=38 
      src="image/music/j8.gif" width=107 border=0> 
      <TD vAlign=center align=middle width=672> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR> 
              <TD vAlign=center align=middle width="100%"> 
                <%
			  call music_head()
			  %>
              </td>
            </tr>
          </TBODY>
        </TABLE>
      <TD width=10 height=38> <P align=right><IMG height=38 src="image/music/j9.gif" 
      width=6 border=0></P></TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=777 align=center border=0>
  <TBODY>
    <TR> 
      <TD width=176 vAlign=top bgcolor="#eef7fd"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR> 
              <TD> </TD>
            </TR>
            <TR> 
              <TD bgColor=#eef7fd><IMG height=52 
            src=image/music/left04.jpg width=176 
            border=0> <TABLE  cellSpacing=4 cellPadding=0 width="86%" 
            align=center bgColor=EEF7FD border=0>
                  <TBODY>
                    <TR> 
                      <TD> 
                        <%
					  call music_fav()
					  %>
                      </TD>
                    </TR>
                  </TBODY>
                </TABLE></TD>
            </TR>
            <TR> 
              <TD bgColor=#eef7fd><IMG height=52 
            src=image/music/left06.jpg width=176 
            border=0><BR> <TABLE height=134 cellSpacing=4 cellPadding=0 width="86%" 
            align=center bgColor=EEF7FD border=0>
                  <TBODY>
                    <TR> 
                      <TD height=76> <DIV align=center><IMG class=imgb height=60 
                  src="image/music/foto.gif" width=140 
                  border=0></DIV></TD>
                    </TR>
                    <TR> 
                      <TD height=46> 
                        <%
					  call music_top(10,10)
					  %>
                      </TD>
                    </TR>
                  </TBODY>
                </TABLE></TD>
            </TR>
            <TR> 
              <TD><IMG height=57 src="image/music/left03.jpg" 
            width=176 border=0></TD>
            </TR>
            <TR> 
              <TD> <TABLE cellSpacing=0 cellPadding=0 width=173 bgColor=#eef7fd 
            border=0>
                  <TBODY>
                    <TR> 
                      <TD> <TABLE height=117 cellSpacing=4 cellPadding=0 width="87%" 
                  align=center bgColor=EEF7FD border=0>
                          <TBODY>
                            <TR> 
                              <TD height="66" valign="top"><div align="center"><IMG class=imgb height=60 
                        src="image/music/newcd.jpg" 
                        width=140></div></TD>
                            </TR>
                            <TR> 
                              <TD> 
                                <%
					  call disk_top(10,10)
					  %>
                              </TD>
                            </TR>
                          </TBODY>
                        </TABLE></TD>
                    </TR>
                  </TBODY>
                </TABLE></TD>
            </TR>
          </TBODY>
        </TABLE></TD>
      <TD vAlign=top bgcolor="A0CAED"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR> 
              <TD bgColor=#ffffff height=5></TD>
            </TR>
          </TBODY>
        </TABLE>
        <TABLE cellSpacing=0 cellPadding=0 width="100%" bgColor=#ffffff 
        border=0>
          <TBODY>
            <tr> 
              <TD width=593><div align="right"><IMG src="image/music/m16.gif" width=593 height=37 border=0></div></TD>
            </tr>
            <TR> 
              <TD> <TABLE width="593" border=0 align="right" cellPadding=0 cellSpacing=0>
                  <TBODY>
                    <TR> 
                      <TD 
                background="image/music/middlebg02.gif" 
                height=182> 
                        <%
response.write joekoe_cms.js_put("style/joekoe_select.js",0)
    select case action
case "song"
      sql_add=" where f_type='song' and username='"&login_username&"'"
      t_name="歌曲"
        pageurl="?action=song&"
      call music_fav_list()
case "disk"
      sql_add=" where f_type='disk' and username='"&login_username&"'"
      t_name="专辑"
        pageurl="?action=disk&"
      call music_fav_list()
case "add"
      if types="song" then
        t_name="歌曲"
        t_type="song"
        sql_add="music_song"
      else
        t_name="专辑"
        t_type="disk"
        sql_add="music_disk"
      end if
      call music_add_fav()
case "delete"
      call music_del_fav()
case "mana"
      if types="song" then
        t_name="歌曲"
        t_type="song"
pageurl="?action=mana&types=song&"
        sql_add=" where f_type='song' and username='"&login_username&"'"
      else
        t_name="专辑"
        t_type="disk"
pageurl="?action=mana&types=disk&"
        sql_add=" where f_type='disk' and username='"&login_username&"'"
      end if
      call music_mana_fav()
    case else
      call music_fav_disk()
      call music_fav_song()
    end select
   %>
                      </TD>
                    </TR>
                  </TBODY>
                </TABLE></TD>
            </TR>
          </TBODY>
        </TABLE>
        <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR> 
              <TD bgColor=A0CAED 
height=5></TD>
            </TR>
          </TBODY>
        </TABLE></TD>
    </TR>
  </TBODY>
</TABLE>
<%
call web_end(0,0)
'------------------------------------------收藏夹列表------------------------------------
sub music_fav_list()   
  nummer=dim_num(0)
  nums=nummer
  pageurl="?"
  sql="select count(id) from music_fav"&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  numusic_perent=formatpercent(rssum/max_num,1)
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from music_fav"&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    n_topic=rs("name")
    n_topic=joekoe_cms.code_js(n_topic,1)
    if t_name="歌曲" then
    tmp=tmp&music_list(i,rs("f_id"),rs("c_id"),rs("s_id"),rs("n_id"),n_topic,rs("singer"),"fav")
    else
    if (li mod 2)=0 then tmp=tmp&"<tr valign=top>"
	tmp=tmp&"<td width='50%'>"&music_disk_list(rs("pic"),rs("id"),rs("c_id"),rs("s_id"),rs("n_id"),rs("name"),rs("singer"),rs("company"),rs("lang"),rs("tim"))&"</td>"
    if (li mod 2)>0 then tmp=tmp&"</tr>"
    end if
    rs.movenext
	li=li+1
  next
  rs.close
  set rs=nothing  
  if t_name="专辑" then tmp=tmp&"<td width='50%'></td></tr>" 
  if t_name="歌曲" then 
    response.write music_list_top("center_song_fav",1,"fav")
    response.write tmp
    response.write music_list_end()
  else
    response.write music_bar_top("center_disk_fav",1)
    response.write tmp
    response.write music_bar_end()
  end if
  call music_fav_end()
end sub

sub music_fav_song()
  i=0
  sql="select top 10 * from music_fav where f_type='song' and username='"&login_username&"' order by id desc"
  set rs=joekoe_cms.exec(sql,1)
  response.write vbcrlf&music_list_top("center_song_fav",1,"fav")
  do while not rs.eof
  i=i+1
    n_topic=rs("Name")
    n_topic=joekoe_cms.code_js(n_topic,1)
	response.write music_list(i,rs("f_id"),rs("c_id"),rs("s_id"),rs("n_id"),n_topic,rs("singer"),"fav")
  rs.movenext
  loop
  rs.close 
  response.write vbcrlf&music_list_end()
end sub

sub music_fav_disk()
  sql="select top 6 * from music_fav where f_type='disk' and username='"&login_username&"' order by id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if (li mod 2)=0 then tmp=tmp&"<tr valign=top>"
    n_id=rs("id")
	n_pic=rs("pic")
    n_topic=rs("Name")
    n_topic=joekoe_cms.code_js(n_topic,1)
    n_topic2=rs("singer")
    n_topic2=joekoe_cms.code_js(n_topic2,1)
	tmp=tmp&"<td width='50%'>"&music_disk_list(n_pic,n_id,rs("c_id"),rs("s_id"),rs("n_id"),n_topic,n_topic2,rs("company"),rs("lang"),rs("tim"))&"</td>"
     if (li mod 2)>0 then tmp=tmp&"</tr>"
  rs.movenext
  li=li+1
  loop
  rs.close
  tmp=tmp&"<td width='50%'></td></tr>"

  response.write music_bar_top("center_disk_fav",1)
  response.write tmp
  response.write music_bar_end()
end sub

sub music_fav_end()
  response.write"<table><tr height=30><td colspan=5 align=center>" & _
             vbcrlf&"<table cellpadding=0 border=0 cellspacing=0><tr>" & _
             vbcrlf&"<td><font class=red><b>[注]：</b></font>您可以收藏的"&t_name&"数为&nbsp;<font class=red>"&max_num&"</font>&nbsp;，目前已有&nbsp;<font class=red>"&rssum&"</font>&nbsp;条，占<font class=red>"&numusic_perent&"</font>：</td>" & _
             vbcrlf&"<td><table cellpadding=0 border=0 cellspacing=0 style='background-color:white; border: #104a7b 1px solid; padding-right: 0px; padding-left: 0px; padding-bottom: 2px; padding-top: 2px;'>" & _
             vbcrlf&"<tr><td width=120><div style='height:5px; width:"&numusic_perent&"; font-size:1px; background-color:#76D769'></div></td></tr>" & _
             vbcrlf&"</table></td>" & _
             vbcrlf&"</tr></table>" & _
             vbcrlf&"</td></tr></table>" & _
             vbcrlf&"<table class=mtb>" & _
             vbcrlf&"<tr>" & _
             vbcrlf&"<td>&nbsp;<img src='images/music/s_fav_left.gif' align=absMiddle border=0>&nbsp;<font class=blue><b>音乐收藏夹</b></font>&nbsp;&nbsp;&nbsp;现有<font class=red>"&rssum&"</font>个收藏，页次：<font class=red>"&viewpage&"</font>/<font class=red>"&thepages&"</font>分页："&jk_pagecute(nummer,thepages,viewpage,pageurl,10,"#ff0000")&"</td>" & _
             vbcrlf&"</tr>" & _
             vbcrlf&"</table>"
end sub
'---------------------------------------添加收藏夹------------------------------------
sub music_add_fav()
  sql="select * from music_fav where username='"&login_username&"' and f_id="&id
  set rs=joekoe_cms.exec(sql,1)
  if not rs.eof then
    response.clear
    response.write joekoe_cms.js_put("alert(""错误提示：您已经收藏过此"&t_name&"！"");window.opener=null;window.close();",1)
  else
    rs.close
    sql="select count(id) from music_fav where username='"&login_username&"'"
    set rs=joekoe_cms.exec(sql,1)
    f_num=rs(0)
    rs.close
    max_num=music_dim(11)
    call convert_load(login_mode)
    max_num=format_convert(max_num,"+")
    if f_num >= max_num then 
      response.clear
      response.write joekoe_cms.js_put("alert(""错误提示：很抱歉的通知您，您的"&t_name&"收藏夹已满，不能再收藏"&t_name&"。"");window.opener=null;window.close();",1)
      response.end
    end if
    sql="select * from "&sql_add&" where id="&id
    set rs=joekoe_cms.exec(sql,1)
    if (rs.EOF and rs.BOF) then
      response.clear
      response.write joekoe_cms.js_put("alert(""错误提示：请正确选择"&t_name&"！"");window.opener=null;window.close();",1)
    else
      favname=rs("name")
      singer=rs("Singer")
      c_id=rs("c_id")
      s_id=rs("s_id")
      n_id=rs("n_id")
	  if t_type="disk" then
      favpic=rs("pic")
      favtim=rs("ptim")
      favcom=rs("pcom")
      favlang=rs("lang")
      end if
    end if
    rs.close
    sql="select * from music_fav"
    call joekoe_cms.exec(sql,-1)
    rs.open sql,conn,1,3
    rs.AddNew
    rs("userName")=login_username
    rs("f_id")=id
    rs("name")=favname
    rs("singer")=singer
    rs("c_id")=c_id
    rs("s_id")=s_id
    rs("n_id")=n_id
    rs("f_type")=t_type
	if t_type="disk" then
    rs("pic")=favpic
    rs("tim")=favtim
    rs("company")=favcom
    rs("lang")=favlang
    end if
    rs.Update
    response.clear
    response.write joekoe_cms.js_put("alert(""恭喜您，已成功收藏"&t_name&"！"");window.opener=null;window.close();",1)
  end if
  rs.Close
  response.end
end sub
'---------------------------------------删除收藏夹------------------------------------
sub music_del_fav()
  dim sel_id,sdim,snum,del_type
    sel_id=trim(request.form("sel_id"))
    sel_id=replace(sel_id," ","")
    if sel_id="" then
      call web_js_msg(1,"收藏夹中没有可删除的收藏！","?action=mana&types="&types)
    end if
  sdim=split(sel_id,",")
  snum=ubound(sdim)
  for i=0 to snum
    if isnumeric(sdim(i)) then
      sql="delete from music_fav where id="&sdim(i)
      call joekoe_cms.exec(sql,0)
    end if
  next
  erase sdim
  call web_js_msg(1,"已从收藏夹中成功删除"&(snum+1)&"条收藏！","?action=mana&types="&types)
end sub
'--------------------------------------管理收藏夹------------------------------------
sub music_mana_fav()
  nummer=dim_num(0)
  nums=nummer
  pageurl="?"
  response.write music_bar_top("center_disk_fav",1)
  response.write "<tr><td height=0><table border=0 cellspacing=1 cellpadding=1 class=mtable>" & _
             vbcrlf&"<form name=del_form action='?action=delete&types="&types&"' method=post>" & _
             vbcrlf&"<tr height=24 align=center>" & _
             vbcrlf&"<td width='7%' class=mtd>序号</td>" & _
             vbcrlf&"<td width='66%' class=mtd>"&t_name&"名称</td>" & _
             vbcrlf&"<td width='20%' class=mtd>歌手</td>" & _
             vbcrlf&"<td width='7%' class=mtd>选择</td>" & _
             vbcrlf&"</tr>"
  sql="select count(id) from music_fav"&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from music_fav"&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
    n_topic=rs("name")
    n_topic=joekoe_cms.code_js(n_topic,1)
    response.write "<tr height=24 align=center class=mbg_td>" & _
             vbcrlf&"<td class=tims>"&i&"</td>" & _
             vbcrlf&"<td align=left>"&n_topic&"</td>" & _
             vbcrlf&"<td>"&rs("singer")&"</td>" & _
             vbcrlf&"<td><input type=checkbox name=sel_id value='"&rs("id")&"'></td>" & _
             vbcrlf&"</tr>"
    rs.movenext
  next
  rs.close
  set rs=nothing
  response.write "<tr class=bg_tds height=30>" & _
             vbcrlf&"<td colspan=2>现有<font class=red>"&rssum&"</font>个收藏，页次：<font class=red>"&viewpage&"</font>/<font class=red>"&thepages&"</font>分页："&jk_pagecute(nummer,thepages,viewpage,pageurl,10,"#ff0000")&"</td>" & _
             vbcrlf&"<td colspan=2 align=center><input type=checkbox name=sel_all value='yes' onclick='javascript:select_all(this.form);' class=bg_tds>所有<input type=submit value='删除所选' onclick=\""return sel_click(this.form);\""></td>" & _
             vbcrlf&"</tr>" & _
             vbcrlf&"</form>" & _
             vbcrlf&"</table></td></tr>" 
  response.write music_bar_end()
end sub
%>