var serverurl='http://music.aobo.com';

//ÒôÁ¿³õÊ¼»¯
//var gobalVol=80;
var aobo_curObj = null;

var aobo_stateInterval = null;

var aobo_waitInterval = null;

var aobo_bufferInterval = null;

var aobo_loadInterval = null;

var aobo_aobo_realStateInterval = null;

var aobo_globalVol = 100;
//
var aobo_certID = 0;
var aobo_tmpID = 1;
//
var aobo_realEnable = true;
var aobo_mediaEnable = true;

var aobo_realState = -1;

var aobo_stopBool = false;

var aobo_mediaType = ".mpg;.mpeg;.mpe;.mp2;.mp3;.avi;.wmv;.dat;.asf;.mid;.midi;.wav;.wma;.aif;.aifc;.aiff;.au;";
var aobo_realType = ".rmj;.rmvb;.ra;.rm;.ram;";

var aobo_explorerEnable = false;
if (navigator.appName.indexOf("Microsoft") !=-1) {
       aobo_explorerEnable = true;
}else{

}

function addMusic(s) {
    aobo_thisMovie("miniplayer").addNewMusic(s);
}

function aobo_thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") !=-1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}
//------------------------------
function setFLashStageWidth(bool) {


	var curURL = document.URL;

	var urlStr = "playxml.php";

	var paraStr = curURL.split("id=")

	addMusic(serverurl+'/'+urlStr+"?id="+paraStr[1]);


	aobo_thisMovie("miniplayer").addLRCCSS("FlashMp3Player.css");
} 
function setDiv(bool){
	if(bool){
		document.getElementById("Javascript.DivPlayer").style.height = "156px";
	}else{
		document.getElementById("Javascript.DivPlayer").style.height = "340px";
	}	
}
//-----------------------------

function outputMedia(){
	document.writeln('<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="mediaObj"');
	document.writeln('  width="100%" height="100%" onerror="MediaPlayerOnError()"');
	document.writeln('    <param name="rate" value="-1">');
	document.writeln('    <param name="balance" value="0">');
	document.writeln('    <param name="currentPosition" value="0">');
	document.writeln('    <param name="playCount" value="1">');
	document.writeln('    <param name="autoStart" value="-1">');
	document.writeln('    <param name="currentMarker" value="0">');
	document.writeln('    <param name="invokeURLs" value="0">');
	document.writeln('    <param name="volume" value="80">');
	document.writeln('    <param name="mute" value="0">');
	document.writeln('    <param name="uiMode" value="full">');
	document.writeln('    <param name="stretchToFit" value="-1">');
	document.writeln('    <param name="windowlessVideo" value="0">');
	document.writeln('    <param name="enabled" value="-1">');
	document.writeln('    <param name="enableContextMenu" value="0">');
	document.writeln('    <param name="fullScreen" value="0">');
	document.writeln('    <param name="enableErrorDialogs" value="0">');
	document.writeln('  </object>');
}

function outputReal(){
	
	document.writeln('<object TYPE="audio/x-pn-realaudio-plugin" name="realObj" id="realObj"');
	document.writeln('  width="100%" height="100%" onerror="realOnError()">');
	document.writeln('    <param name="AUTOSTART" value="-1">');
	document.writeln('    <param name="SHUFFLE" value="0">');
	document.writeln('    <param name="PREFETCH" value="0">');
	document.writeln('    <param name="NOLABELS" value="-1">');
	document.writeln('    <param name="CONTROLS" value="ControlPanel,StatusBar">');
	document.writeln('    <param name="LOOP" value="0">');
	document.writeln('    <param name="NUMLOOP" value="0">');
	document.writeln('    <param name="CENTER" value="0">');
	document.writeln('    <param name="MAINTAINASPECT" value="0">');
	document.writeln('  </object>');
	
	/*
	document.writeln('  <EMBED TYPE="audio/x-pn-realaudio-plugin" NAME=realObj SRC="" WIDTH=220 HEIGHT=180 CONSOLE=ONE BACKGROUNDCOLOR=white CENTER=TRUE>');
	*/
}

function chkType(_s,url){

	trace("error:"+_s);
	trace("error:"+url);
	if(aobo_curObj!=null && aobo_curObj!=undefined){
		aobo_curObj.stop();
	}
	aobo_curObj = null;
	aobo_stopBool=false;
	clearInterval(aobo_aobo_realStateInterval);
	clearInterval(aobo_waitInterval);
	if(!aobo_explorerEnable||_s==undefined){
		return;
	}
	//var tp = "none";
	var tp = "media";
	if(aobo_mediaType.indexOf("."+_s+";")!= -1){
		tp = "media";
	}else if(aobo_realType.indexOf("."+_s+";")!=-1){
		tp = "real";
	}
	switch(tp){
		case "media":
			if(aobo_mediaEnable){
				aobo_certID = Math.random();
				aobo_curObj =  new MediaPlayer;
				aobo_curObj.open(url);
				aobo_curObj.volume(aobo_globalVol);
				aobo_waitInterval = setInterval("aobo_waiting()",10000);
				break;
			}else{
				broadcastEvent({op:"skip"});
			}
		case "real":
			if(aobo_realEnable){
				aobo_curObj = new RealPlayer;
				aobo_curObj.open(url);
				aobo_curObj.volume(aobo_globalVol);
				aobo_waitInterval = setInterval("aobo_waiting()",10000);
				break;
			}else{
				broadcastEvent({op:"skip"});
			}
		case "none" :

			broadcastEvent({op:"skip"});
			break;
		default:
	}
	//
	//aobo_curObj.volume(gobalVol);
	aobo_curObj.volume(aobo_globalVol);
}
function aobo_waiting(){
	aobo_curObj.stop();
	clearInterval(aobo_stateInterval);
	clearInterval(aobo_waitInterval);
	broadcastEvent({op:"skip"});
}

function MediaPlayer(){

	this.aobo_obj = null;
	this.aobo_obj = document.mediaObj;
	if(this.aobo_obj==null){
		trace("null");
	}

	this.open = function(url){
		this.aobo_obj.URL = url;
		//this.stop();
		//this.play();
		trace("playing");
	}
	this.play = function(){this.aobo_obj.controls.play();}
	this.pause = function(){this.aobo_obj.controls.pause();}
	this.stop = function(){
		this.aobo_obj.controls.stop();
		//this.aobo_obj.controls.currentPosition = 0;
	}
	this.go = function(s){trace(s);this.aobo_obj.controls.currentPosition = s;}
	this.pos = function(){return this.aobo_obj.controls.currentPosition;}
	this.length = function(){return this.aobo_obj.currentMedia.duration;}
	this.state = function(){
		var ps = this.aobo_obj.PlayState;
		return ps;
	}
	this.volume = function(s){
		this.aobo_obj.settings.volume = s;
	}
	this.mute = function(s){ 
		this.aobo_obj.settings.mute = s;
	}	
}

function MediaPlayerOnError(){
	//alert("MediaPlayerOnError");
	if(aobo_curObj==null || aobo_curObj.constructor != MediaPlayer){
		alert("media Player 9.0");
		aobo_mediaEnable = false;
		return;
	}
	clearInterval(aobo_stateInterval);
	clearInterval(aobo_waitInterval);
	clearInterval(aobo_loadInterval);
	broadcastEvent({op:"skip"});
}

function MediaPlayerState(state){
	switch  (state) {
        case  1:
			   trace("");
			   //updatetime(aobo_curObj.pos());
			   clearInterval(aobo_stateInterval);
			   clearInterval(aobo_loadInterval);
			   clearInterval(aobo_bufferInterval);
			   //trace("media aobo_stopBool:"+aobo_stopBool);
			   if(aobo_stopBool){
					broadcastEvent({op:"stop"});
			   }
               break;
        case  2:
				trace("");
				clearInterval(aobo_stateInterval);
				//broadcastEvent({op:"pause"});
                break;
        case  3:
				trace("");
				clearInterval(aobo_bufferInterval);
				clearInterval(aobo_stateInterval);
				aobo_stateInterval = setInterval("updatetime(aobo_curObj.pos())",100);
				broadcastEvent({op:"play"});
				clearInterval(aobo_waitInterval);
                break;
        case  6:
				if(aobo_certID != aobo_tmpID){
					var infoObj = {title:mediaObj.currentMedia.getItemInfo("Title"),
									singer:mediaObj.currentMedia.getItemInfo("Author"),
									copyright:mediaObj.currentMedia.getItemInfo("Copyright"),
									description:mediaObj.currentMedia.getItemInfo("Description"),
									duration:mediaObj.currentMedia.getItemInfo("Duration"),
									filetype:mediaObj.currentMedia.getItemInfo("FileType"),
									sourceurl:mediaObj.currentMedia.getItemInfo("sourceURL"),
									filesize:mediaObj.currentMedia.getItemInfo("FileSize")};
					broadcastEvent({op:"info", value:infoObj});
					aobo_tmpID = aobo_certID;
				}
				//trace("æ­£åœ¨ç¼“å†²...");
				clearInterval(aobo_stateInterval);
				broadcastEvent({op:"buffer"});
				clearInterval(aobo_waitInterval);
				//showBufferPercent();
				clearInterval(aobo_bufferInterval);
				aobo_bufferInterval = setInterval("showBufferPercent()",100);
				trace("...");
                break;
        case  9:

				clearInterval(aobo_stateInterval);
				broadcastEvent({op:"connect"});
				//
				clearInterval(aobo_bufferInterval);
				clearInterval(aobo_loadInterval);
				aobo_loadInterval = setInterval("showDownloadPercent()",100);
                break;
        case  10:

				//clearInterval(aobo_loadInterval);
                break;
        default: 
	} 
}
//
function showDownloadPercent(){
	var downpct = mediaObj.network.downloadProgress;
	if(downpct==null || downpct==undefined)return;
	
	if(downpct<200){
		broadcastEvent({op:"downloadprogress", num:downpct});
	}else{
		broadcastEvent({op:"downloadprogress", num:100});
		clearInterval(aobo_loadInterval);
	}
}
//
function showBufferPercent(){
	var bufpct = mediaObj.network.BufferingProgress;
	if(bufpct==null || bufpct==undefined)return;

	if(bufpct<100){
		broadcastEvent({op:"bufferprogress", num:bufpct});
	}else{
		clearInterval(aobo_bufferInterval);
	}
}

function RealPlayer(){

	this.aobo_obj = null;
	this.aobo_obj = document.realObj;
	if(this.aobo_obj==null){
		trace("null");
	}

	this.open = function(url){
		this.aobo_obj.SetSource(url);
		this.play();
		aobo_aobo_realStateInterval = setInterval("getRealState()",100);
	}
	this.play = function(){
		//if(this.aobo_obj.CanPlay()){
			this.stop();
			this.aobo_obj.DoPlay();
		//}
	}
	this.pause = function(){this.aobo_obj.DoPause();}
	this.stop = function(){
		if(this.aobo_obj.CanStop()){
			this.aobo_obj.DoStop();
			//this.aobo_obj.SetPosition(0);
		}
	}
	this.go = function(s){this.aobo_obj.SetPosition(s*1000);}
	this.pos = function(){return this.aobo_obj.GetPosition()/1000;}
	this.length = function(){return this.aobo_obj.GetLength()/1000;}
	this.state = function(){return this.aobo_obj.GetPlayState();}
	this.volume = function(s){this.aobo_obj.SetVolume(s);}
	this.mute = function(s){this.aobo_obj.SetMute(s);}
}

function realOnError(){
	//alert("realOnError");
	if(aobo_curObj==null || aobo_curObj.constructor != RealPlayer){

		aobo_realEnable = false;
		return;
	}
	clearInterval(aobo_stateInterval);
	clearInterval(aobo_waitInterval);
	broadcastEvent({op:"skip"});
}

function RealPlayerState(state){
	switch  (state) {
        case  0:
			   trace("Realåœæ­¢");
			   clearInterval(aobo_stateInterval);
			   trace("real aobo_stopBool:"+aobo_stopBool);
			   if(aobo_stopBool){
					broadcastEvent({op:"stop"});
			   }
               break;
        case  4:
				trace("Realæš‚åœ");
				clearInterval(aobo_stateInterval);
                break;
        case  3:
				trace("Realæ­£åœ¨æ’­æ”¾");
				clearInterval(aobo_stateInterval);
				aobo_stateInterval = setInterval("updatetime(aobo_curObj.pos())",100);
				broadcastEvent({op:"play"});
				clearInterval(aobo_waitInterval);
                break;
        case  2:
				//trace("Realæ­£åœ¨ç¼“å†²...");
				clearInterval(aobo_stateInterval);
				broadcastEvent({op:"buffer"});
				clearInterval(aobo_waitInterval);
                break;
        case  1:
				trace("Realæ­£åœ¨è¿žæŽ¥...");
				clearInterval(aobo_stateInterval);
				broadcastEvent({op:"connect"});
                break;
        default: 
	}
}
//èŽ·å–REALçŠ¶æ€?
function getRealState(){
	if(aobo_curObj==null || aobo_curObj==undefined){
		return;
	}
	if(aobo_realState!=aobo_curObj.state()){
		aobo_realState = aobo_curObj.state();
		RealPlayerState(aobo_realState);
	}
}
//ä¼ ç»™FLASHå½“å‰æ’­æ”¾æ—¶é—´å’Œæ€»æ—¶é—?
function updatetime(_n){
	if(aobo_curObj==null || aobo_curObj==undefined){
		return;
	}
	//trace(_n);
	if(_n>=1 && aobo_curObj.length()>1 && (aobo_curObj.length()-_n)<=1){
		aobo_stopBool=true;
	}
	broadcastEvent({op:"total",num:aobo_curObj.length()});
	broadcastEvent({op:"pos",num:_n});
	broadcastEvent({op:"test",obj:{n1:mediaObj.network.downloadProgress,n2:0,n3:0}});
}
//å‘é€ä¿¡æ¯ç»™FLASH
function broadcastEvent(_event){
	//ç»™Flashä¼ å€?
	aobo_thisMovie("miniplayer").getMsgFromJS(_event);
}
//ä»ŽFLASHèŽ·å–æŽ§åˆ¶ä¿¡æ¯
function setMusicState(obj){
	trace("æŽ¥æ”¶åˆ°çš„å‘½ä»¤:"+obj.state);
	if(obj.state=="ns"){
		trace(obj.bool);
	}
	if(obj.state=="testIE"){
		trace("å‘½ä»¤:"+obj.state);
		broadcastEvent({op:"ns", bool:aobo_explorerEnable});
	}
	if(obj.state=="setvol"){
		aobo_globalVol = obj.num;
		trace(aobo_globalVol);
	}
	if (!aobo_explorerEnable||aobo_curObj==null || aobo_curObj == undefined) {
		return;
	}
	
	switch(obj.state){
		case "play":
			aobo_curObj.play();
			break;
		case "pause":
			aobo_curObj.pause();
			break;
		case "stop":
			aobo_curObj.stop();
			break;
		case "setvol":
			aobo_curObj.volume(obj.num);
			break;
		case "setmute":
			aobo_curObj.mute(obj.bool);
			break;
		case "setpos":
			aobo_curObj.go(obj.num);
			break;	
		case "trace":
			trace("***"+obj.str+"***");
		default:
	}
}
//ä»ŽFLASHèŽ·å–æ’­æ”¾åœ°å€
function setMusicURL(_s,url){
	trace("ä»ŽFLASHèŽ·å–æ’­æ”¾åœ°å€");
	if (aobo_explorerEnable) {
       chkType(_s,url);
    }else {
		trace("ç•¥è¿‡");
		broadcastEvent({op:"skip"});
    }
}
//è°ƒè¯•ç”¨æ–¹æ³?
function trace(_s){
	//document.getElementById("out_put").value += _s+"\n";
	//document.getElementById("out_put").scrollTop = document.getElementById("out_put").scrollHeight;
}
//æ¸…é™¤è°ƒè¯•ç”¨æ–‡æœ¬å†…å®?
function clearTxt(){
	//document.getElementById("out_put").value = "";
}

//é•¿æ¡æ’­æ”¾å™¨è®¾ç½?------
var newwindow;
var child_array;
var select_num;
//ç‚¹å‡»FLASHä¸­çš„åˆ—è¡¨å›¾æ ‡æ—¶ï¼Œä¼šè°ƒç”¨openListå‡½æ•°ï¼Œæ‰“å¼€æ–°é¡µé¢ï¼Œå¹¶ä¼ å€?
function openList(list_array, num){

	child_array=list_array;
	select_num=num;
	if(child_array==undefined){child_array=new Array();}
	if(select_num==undefined){select_num=0;}
	newwindow=window.open(serverurl+'/mini/list.html','newwindows');
	newwindow.focus();
}
//æŽ¥æ”¶æ¥è‡ªæ–°é¡µé?åˆ—è¡¨é¢é¢)çš„æ•°å€¼ï¼Œé€šçŸ¥FLASHæ’­æ”¾çš„æ­Œæ›²é¡¹
function selecteCell(num){
	aobo_thisMovie("miniplayer").selectMusic(num);
}
//
function getArrayData(){
	return {a:child_array, n:select_num};
}

function moveIFrame(x,y,w,h) {
    var frameRef=document.getElementById("myFrame");
    frameRef.style.left=x+'px';
    frameRef.style.top=y+'px';
    frameRef.style.display='block';

	document.getElementById("mediaObj").style.width = w+'px';
	document.getElementById("mediaObj").style.height = h+'px';
	//
    var videoRef=document.getElementById("myMovieFrame");
    videoRef.style.left=x+'px';
    videoRef.style.top=y+'px';
	videoRef.style.width = w+'px';
	videoRef.style.height = h+'px';
}

function moveAFrame(x,y,w,h) {

    var articleRef=document.getElementById("myArticleFrame");
    articleRef.style.left=x+'px';
    articleRef.style.top=y+'px';
	articleRef.style.width = w+'px';
	articleRef.style.height = h+'px';
}

function hideIFrame(){
    document.getElementById("myFrame").style.visibility="hidden";
	document.getElementById("myMovieFrame").style.display="none";
}
	
function showIFrame(){
    document.getElementById("myFrame").style.visibility="visible";
	var obj = document.getElementById("myMovieFrame");
	if(obj.innerHTML != ""){
		obj.style.display="block";
	}
}
function hideAFrame(){
	document.getElementById("myArticleFrame").style.display="none";
}
	
function showAFrame(){
	var objArticle = document.getElementById("myArticleFrame");
	if(objArticle.innerHTML != ""){
		objArticle.style.display="block";
	}
}

function loadIFrame(url){
	//Ð´MEDIA
	var tmp = '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="mediaObj"'+
	'	width="232" height="300" onerror="MediaPlayerOnError()">'+
	'    <param name="rate" value="-1">'+
	'    <param name="balance" value="0">'+
	'    <param name="currentPosition" value="0">'+
	'    <param name="playCount" value="1">'+
	'    <param name="autoStart" value="-1">'+
	'    <param name="currentMarker" value="0">'+
	'    <param name="invokeURLs" value="0">'+
	'    <param name="volume" value="80">'+
	'    <param name="mute" value="0">'+
	'    <param name="uiMode" value="None">'+
	'    <param name="stretchToFit" value="-1">'+
	'    <param name="windowlessVideo" value="1">'+
	'    <param name="enabled" value="1">'+
	'    <param name="enableContextMenu" value="1">'+
	'    <param name="fullScreen" value="0">'+
	'    <param name="enableErrorDialogs" value="0">'+
	//'    <param name="URL" value="http://202.116.70.209/bbsupload/twentwen/theday.wma">'+
	'  </object>';
	
	document.getElementById("myFrame").innerHTML = tmp;
}
<!-- SWF player container: -->
function hideVideoFrame(){
	document.getElementById("myMovieFrame").style.visibility="hidden";
}	
function showVideoFrame(){
	document.getElementById("myMovieFrame").style.visibility="visible";
}
function preMedia(){
	hidePlaySWFMovie();
	broadcastEvent({op:"playmedia",value:"pre"});
}

function nextMedia(){
	hidePlaySWFMovie();
	broadcastEvent({op:"playmedia",value:"next"});
}

//show the SWF file in the DIV container;
function showPlaySWFMovie(src, bool) {
	var htmlReg = /\.shtml|\.html|\.htm|\.jpg|\.gif|\.jpeg|\.gif/;
	if(htmlReg.test(src)){
		alert("ÕýÔÚÇëÇó²»Ö§³ÖµÄSWFÊÓÆµÔ´");
		src = "";
	}
    var frameRef=document.getElementById("myMovieFrame");
	changeZindex("video");
	//frameRef.innerHTML = "<iframe onload='hideLoadDiv();' name='flash' src='"+src+"' frameborder='0' scrolling='yes' width='100%' height='100%' style='background:#000000;'></iframe>";
	//frameRef.innerHTML = "<div id='flvplayer' style='width:100%;height:100%;'><embed src='"+src+"' type='application/x-shockwave-flash' width='100%' height='100%' allowFullScreen='true' wmode='transparent' allowScriptAccess='always' bgcolor='#000000'></embed></div>";
	frameRef.innerHTML = "<div id='flvplayer' style='width:100%;height:100%;'>"+"<table width='100%' height='100%'>"+"<tr>"+"<td colspan='4' align='center' valign='middle'>"+"<embed src='"+src+"' type='application/x-shockwave-flash' width='450' height='400' allowFullScreen='true' wmode='transparent' allowScriptAccess='always' bgcolor='#000000'>"+"</embed>"+"</td>"+"</tr>"+"</table>"+"</div>";
	//alert(frameRef.innerHTML);
	if(bool){
		 frameRef.style.display="block";
	}else{
		 frameRef.style.display="none";
	}
}
//hide the SWF file in the DIV container;
function hidePlaySWFMovie(){
	var frameRef=document.getElementById("myMovieFrame");
 	frameRef.style.display="none";
	frameRef.innerHTML = "";
} 
//change the DIV deep(z-index)
function changeZindex(type){
	//alert(type);
	var videoRef=document.getElementById("myMovieFrame");
	var articleRef=document.getElementById("myArticleFrame");
	var containerRef=document.getElementById("PlayerContainer");
	if(articleRef.style.zIndex != 110)
	{
		//containerRef.click();
		//containerRef.focus();
		//aobo_thisMovie("miniplayer").click();
		//aobo_thisMovie("miniplayer").focus();
	}
	if(type=="video"){
		videoRef.style.zIndex = 110;
		containerRef.style.zIndex = 100;
		articleRef.style.zIndex = 90;
	}else if(type=="article"){
		videoRef.style.zIndex = 90;
		containerRef.style.zIndex = 100;
		articleRef.style.zIndex = 110;
	}else if(type=="over"){
		containerRef.style.zIndex = 120;
	}else if(type=="back"){
		containerRef.style.zIndex = 100;
	}else if(type=="none"){
		videoRef.style.zIndex = 90;
		articleRef.style.zIndex = 89;
	}
}

// The article process functions *****************************************

//show the article frame div in the DIV container;
function showArticle(src, bool) {
    var frameRef=document.getElementById("myArticleFrame");
	changeZindex("article");
	if(frameRef.innerHTML == ""){
		frameRef.innerHTML = "<iframe name='articleFrame' src='"+src+"' frameborder='0' scrolling='yes' width='100%' height='100%' style='background:#000000;'></iframe>";
	}
	if(bool){
		 frameRef.style.display="block";
	}else{
		 frameRef.style.display="none";
	}
}
//hide the article frame in the DIV container;
function hideArticle(){
	var frameRef=document.getElementById("myArticleFrame"); 
 	frameRef.style.display="none";
	//frameRef.innerHTML = "";
	
	changeZindex("video");
} 

<!-- --------------------- -->
function openNewWindow(url, type){
	//alert("url");
	var testURL = document.createElement('a');
	if(type==null||type==undefined||type==""){
		type="_blank";
	}
	testURL.target=type; 
	testURL.href=url; 
	document.body.appendChild(testURL); 
	testURL.click();
}