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+"\" class=\"\" 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>";
		htmlstr += "<li id=\"music_"+TotalSongs+"\" class=\"\" title=\""+tstr[2]+"\" isdel=\"0\" singer=\""+tstr[4]+"\" mid=\""+tstr[1]+"\" mt=\""+tstr[3]+"\" url=\""+tstr[0]+"\" onMouseOver=\"COver(this);\" onMouseOut=\"COut(this);\"><div class=\"del\"><a href=\"#\" onclick=\"del(music_"+TotalSongs+")\" id=\"del_"+TotalSongs+"\" title=\"删除\/恢复\">√</a></div><div class=\"mname\"><a href=\"javascript:myplay(music_"+TotalSongs+")\">"+ttstr+"</a></div></li>";
	}
	$("LplayList").innerHTML=htmlstr;
};
function myplay(t){
	var obj;
	obj = eval("music_"+ newi);
	obj.className="";
	obj = eval(t);
	M_sid = obj.mid;
	Ylmv_Player.url = s_list + obj.url;
	obj.className="n 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' onClick='myplay(music_"+ia+");'>上一首</a>";
	$("nextSong").innerHTML="<a href='#none' onClick='myplay(music_"+ib+");'>下一首</a>";
	//$("gc").innerHTML="<iframe scrolling='no' frameborder='0' width='326' height='238' src='/skins/chshpf_01/lrcshow.asp?id=" + obj.title + "'>对不起，你的浏览器不支持框架。</iframe>";
	//$('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+24;
	CHKPlay();
};
function CHKPlay(){
	if(Ylmv_Player.PlayState==1 || Ylmv_Player.PlayState==10)
		playn();
	setTimeout("CHKPlay()",1000);
};
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";
	}
};
playn = function(){
	var obj=eval("music_"+newi);
	var N=newi;
	if($F("playMethod")!=3){
		obj.className="";
		if($F("playMethod")==2) N=Math.floor(Math.random()*TotalSongs+1);
		do{
			N=N+1;
			if(N>TotalSongs) N=1;
			obj=eval("music_"+N);
		}while(obj.isdel==1)
	}
	myplay(obj);
};
playp = function(){
	var obj=eval("music_"+newi);
	var N=newi;
	if($F("playMethod")!=3){
		obj.className="";
		if($F("playMethod")==2) N=Math.floor(Math.random()*TotalSongs+1);
		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!="n selected")	t.className="over";
};
COut=function(t,act){
	if(t.className!="n selected")	t.className="out";
};