var s_list,cookiestr,TotalSongs,M_sid,newi,oldi;
newi = 1;
var s_list = "";
function showItem(o1,o2){
	$("itemtHIS").className="";
	$("itemtTOP").className="";
	$("LList").style.display = "none";
	$("classTop").style.display = "none";
	o2.className="this";
	$(o1).style.display = "block";
};
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 >= 4){
		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><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;
	Ylmv_Player.url = s_list + obj.url;
	obj.className="f";
	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;
	$("doFAV_Down").innerHTML ="<a class=\"abuts\" target=\"box\" href=\""+web_url+"musicadd.php?aid="+M_sid+"\">收藏歌曲</a> <a class=\"abuts\" target=\"box\" href=\""+web_url+"Down.php?aid="+M_sid+"\">下载歌曲</a>";
	$("lastSong").innerHTML="上一首：<a href='#none' onClick='myplay(music_"+ia+");'>"+eval("music_"+ ia).title+"</a>";
	$("nextSong").innerHTML="下一首：<a href='#none' onClick='myplay(music_"+ib+");'>"+eval("music_"+ ib).title+"</a>";
	$("doHits").innerHTML="<iframe marginwidth=\"0\" marginheight=\"0\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" scrolling=\"no\" src=\"/plus/ajax.php?aid="+M_sid+"\" height=\"45px\" width=\"250px\">";
	$("doError").innerHTML="<a target=\"error\" href=\""+web_url+"Djerr.php?aid="+M_sid+"\"><img src=\""+web_url+"skin/img/play_ad.gif\" border=0></a>";
	$("itemtTOP").innerHTML ="<span id=\"itemtTOP\" onClick=\"showItem('classTop',this);playTopLista("+obj.mt+");\">试听排行</span>"
	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();
	do1Hits(M_sid);
};
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!="f")	t.className="over";
};
COut=function(t,act){
	if(t.className!="f")	t.className="out";
};

var xmlHttp;
function createXMLHttpRequest(){
	if(window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	}
};
function playTopLista(_id){
	$("classTopList").innerHTML = "<li class=\"tC\"><img src=\""+web_url+"skin/skin_02/Images/loading.gif\" /> 正在读取中....</li>";
	createXMLHttpRequest();
	xmlHttp.open("get",""+web_url+"Skin/Skin_02/Ajax.asp?action=playTopList&l=d&musicType="+_id);
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				$("classTopList").innerHTML = unescape(xmlHttp.responseText);
			}else alert("网络链失败!");
		}
	}
	xmlHttp.send(null);
};
function doHits(_Id,_do){
	createXMLHttpRequest();
	xmlHttp.open("post",""+web_url+"Skin/Skin_02/Ajax.asp",true);
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState == 4){
			if(xmlHttp.status == 200){
				$("doHits").innerHTML = unescape(xmlHttp.responseText);
			}else alert("网络链接失败");
		}
	}
	xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlHttp.send("action=doHits&id="+escape(_Id)+"&dowhat="+escape(_do));
};
function do1Hits(_Id){
	createXMLHttpRequest();
	xmlHttp.open("post",""+web_url+"Skin/Skin_02/Ajax.asp",true);
	xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlHttp.send("action=do1Hits&id="+escape(_Id));
};