
function play_song(id)
{
	if (document.getElementById) 
	{
	   var http = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	   var ajld=getId("ajaxloaddiv");	   
	}
	http.open("GET", "/Ajax/Music/"+id+".htm", true);
	http.onreadystatechange=function() 
	{
		if(http.readyState == 1) 
		{
			getId("formplay").style.display="";
			try{getId("playerdivs").style.display="none";}catch(er){}
		}
		if(http.readyState == 4 && http.status==200) 
		{
			ajld.style.display="none";
			var arrdt=(http.responseText).split("(^_^)");
			getId("formplay").innerHTML=arrdt[0];
			getId("playerdiv").innerHTML=play_media(arrdt[1],"100%",45,"/");
			try{
				arrdt2=arrdt[0].split("<script>");
				arrdt3=arrdt2[1].split("</script>");
				eval(arrdt3[0]);
			}catch(er){}
		}
	 }
	 http.send(null);
	 ajld.style.display="";
}
function play_media(link,width,height,dir,auto,playlist)
{
	var e = link.split('.'); e = e[e.length-1];

	var WMP7;
	try
	{
		if ( navigator.appName != "Netscape" )
		{
			WMP7 = new ActiveXObject('WMPlayer.OCX');
		}
	}
	catch (error)
	{
		;
	}
	var HTML = '';

	// Windows Media Player 7 Code
	if ( WMP7 )
	{
		HTML +=  ('<OBJECT id="winmedia" height="'+height+'" width="'+width+'" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT>');
		HTML +=  ('<PARAM NAME="URL" VALUE="'+link+'">');
		HTML +=  ('<PARAM NAME="FileName" VALUE="'+link+'">');
		HTML +=  ('<PARAM NAME="rate" VALUE="1">');
		HTML +=  ('<PARAM NAME="balance" VALUE="0">');
		HTML +=  ('<PARAM NAME="currentPosition" VALUE="0">');
		HTML +=  ('<PARAM NAME="playCount" VALUE="999">');
		HTML +=  ('<PARAM NAME="autoStart" VALUE="'+auto+'">');
		HTML +=  ('<PARAM NAME="currentMarker" VALUE="0">');
		HTML +=  ('<PARAM NAME="enableContextMenu" VALUE="0">');
		HTML +=  ('</OBJECT>');
	}

	// Windows Media Player 6.4 Code
	else
	{
		HTML +=  ('<OBJECT id="winmedia" style="z-index: 5" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ');
		HTML +=  ('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ');
		HTML +=  ('width="'+width+'" height="'+height+'"');
		HTML +=  ('standby="Loading Microsoft Windows Media Player components..." ');
		HTML +=  ('type="application/x-oleobject" VIEWASTEXT> ');

		HTML +=  ('<PARAM NAME="FileName"           VALUE="'+link+'">');
		HTML +=  ('<PARAM NAME="ShowControls"       Value="false">');
		HTML +=  ('<PARAM NAME="playCount" VALUE="999">');

		HTML +=  ('<Embed type="application/x-mplayer2" WMODE="transparent" ');
		HTML +=  (' pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" ');
		HTML +=  (' src="'+link+'" ');
		HTML +=  (' Name=MediaPlayer  enablecontextmenu="0" showstatusbar="0"');
		HTML +=  (' transparentAtStart=1 ');
		HTML +=  (' autostart='+auto+' ');
		HTML +=  (' playcount=999 ');
		HTML +=  (' animationAtStart=1 EnableFullScreenControls="1" ');
		HTML +=  (' width="'+width+'" height="'+height+'"');
		HTML +=  ('></embed> ');
		HTML +=  ('</OBJECT>');
	}
	if(e=="flv" || e=="mp3" || e=="xml")
	{
		auto=(auto==0)?"false":"true";
		HTML = "<embed type='application/x-shockwave-flash' src='"+dir+"swf/flvplayer.swf' quality='high' ";
		HTML += " allowfullscreen='true' allowscriptaccess='always'";
		HTML += " flashvars='file="+link;
		if(playlist==1)HTML +="&displayheight=35&showplaylist=true";
		HTML += "&volume=50&&autostart="+auto+"&repeat=list&title=trinh";
		HTML += "";
		if(e=="mp3" || e=="xml")HTML += "&showeq=true";
		HTML += "' width='"+width+"' height='"+height+"' MENU='false' WMODE='transparent' >";
	}
	return HTML;
}
