//打开播放后暂停首页播放
//if(window.opener.media){window.opener.media.controls.pause();}
var LplayList,s_list,cookiestr,TotalSongs,M_sid,newi,oldi;
newi = 1;
var s_list = "";
function Insertsong(musicId){
	var songstr;
	songstr=eval("u" + musicId)+"|"+musicId+"|"+eval("n" + musicId)+"|"+eval("t" + musicId)+"|"+eval("s" + musicId);
	var tstr;
	tstr = songstr.split("|");
	if(tstr.length >= 5){
		if (cookiestr == null)
			cookiestr = songstr;
		else
			cookiestr = cookiestr + "#Ylmv#" + songstr;
		InitList();
	}
};
function InitList(){
	var songarray,htmlstr,i,tstr,ttstr;
	htmlstr = "";
	songarray = cookiestr.split("#Ylmv#");
	TotalSongs = 0;
	for(var i=0;i<songarray.length;i++){
		TotalSongs+= 1;
		tstr = songarray[i].split("|");
		ttstr = "&nbsp;"+TotalSongs + ". " + tstr[2];
		htmlstr += "<li id=\"music_"+TotalSongs+"\"  title=\""+tstr[2]+"\" isdel=\"0\" singer=\""+tstr[4]+"\" mid=\""+tstr[1]+"\" mt=\""+tstr[3]+"\" url=\""+tstr[0]+"\" onMouseOver=\"COver(this);\" onMouseOut=\"COut(this);\"><span>&nbsp;<a href=\"#\" onclick=\"del(music_"+TotalSongs+")\" id=\"del_"+TotalSongs+"\" title=\"删除\/恢复\">√</a></span><a href=\"javascript:myplay(music_"+TotalSongs+")\">"+ttstr+"</a></li>";
	}
	$$("LplayList").innerHTML=htmlstr;
};
function myplay(t){
	var obj;
	obj = eval("music_"+ newi);
	obj.className="";
	obj = eval(t);
	M_sid = obj.mid;
	Player.url = s_list + obj.url;
	obj.className="selected";
	newi = obj.id.substr(6)*1;
	var ia=newi-1;
	var ib=newi+1;
	if(newi<2)ia=TotalSongs;
	if(newi>=TotalSongs)ib=1;
	document.title="歌曲连播( " + obj.title + " ) ";
	$$("songname").innerHTML = "" + obj.title;
	//$$("songtitle").innerHTML = "" + obj.title;
	//$$("lastSong").innerHTML="上一首：<a href='#none' style='color:#1B6FE0;' onClick='myplay(music_"+ia+");'>"+eval("music_"+ ia).title+"</a>";
	//$$("nextSong").innerHTML="下一首：<a href='#none' style='color:#1B6FE0;' onClick='myplay(music_"+ib+");'>"+eval("music_"+ ib).title+"</a>";
	//$$('frame_title').onclick=function(){ open_comment(M_sid); }
        //getdoHits(M_sid);
	if(((obj.id).substr(6)-1) * 25 < $$("LplayList").scrollTop)
		$$("LplayList").scrollTop=((obj.id).substr(6)-1) * 25 ;
	if(((obj.id).substr(6)) * 25 >= $$("LplayList").scrollTop+$$("LplayList").style.pixelHeight-1)
		$$("LplayList").scrollTop=((obj.id).substr(6)) * 25- $$("LplayList").style.pixelHeight-25;
	CHKPlay();
};

function CHKPlay(){
	if(Player.PlayState==1 || Player.PlayState==10){
		playn();
	}
	setTimeout("CHKPlay()",1000);
};
function playn(){	
	var obj=eval("music_"+newi);
	var N=newi;		
	do{
			N=N+1;
			if(N>TotalSongs) N=1;
			obj=eval("music_"+N);
	}while(obj.isdel==1)
	myplay(obj);
s};
function PlayModer(t){
	if($$F("playMethod")==1){
		$$("playMethod").value=2;
		t.value="随机播放";
	}else if($$F("playMethod")==2){
		$$("playMethod").value=3;
		t.value="单曲循环";
	}else{
		$$("playMethod").value=1;
		t.value="顺序播放";
	}
};
function del(t){
	var N=parseInt(t.id.substr(6));
	if(t.isdel==0){
		t.isdel=1;
		$$("del_"+N).innerHTML="×";
		$$("del_"+N).style.color="#26b100";
	}else{
		t.isdel=0;
		$$("del_"+N).innerHTML="√";
		$$("del_"+N).style.color="#f8942d";
	}
};

function playp(){
	var obj=eval("music_"+newi);
	var N=newi;
	do{
			N=N-1;
			if(N<1) N=TotalSongs;
			obj=eval("music_"+N);
		}while(obj.isdel==1)
	
	myplay(obj);
};
COver=function(t,act){
	if(t.className!="selected")	t.className="over";
};
COut=function(t,act){
	if(t.className!="selected")	t.className="out";
};