<%@ Import Namespace="Globals=Spaces.Globals" %>
<div style="display: none">
    <object id="player" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" > 
 <param name="uiMode" value="invisible" /> 
 <param name="autoStart" value="true" /> 
 <param name="volume" value="0"> 
 <param name="playCount" value="1"> 
 <param name="balance" value="0"> 
 '<param name="baseURL" value=""> 
 <param name="currentPosition" value="0"> 
 <param name="currentMarker" value="0"> 
 <param name="enableContextMenu" value="false"> 
 <param name="enableErrorDialogs" value="false"> 
 <param name="fullScreen" value="false"> 
 <param name="invokeURLs" value="false"> 
 <param name="mute" value="false"> 
 <param name="rate" value="1"> 
 <param name="animationAtStart" value="false"> 
 </object> 
</div>


<script language="JavaScript">
function ShowPlayList(){
		var ctl_play_list = document.getElementById('div_music_play_list');
		var ctl_show_music_list = document.getElementById('img_show_music_list');
		
		if(ctl_play_list.style.display != 'none'){
			ctl_play_list.style.display = 'none';
			ctl_show_music_list.src = "<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_33.gif";
			ctl_show_music_list.alt = "显示播放列表";
			
		}else{
			ctl_play_list.style.display = '';
			ctl_show_music_list.src = "<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_32.gif";
			ctl_show_music_list.alt = "隐藏播放列表";
		}
	}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
"abcdefghijklmnopqrstuvwxyz" + //all lowercase
"0123456789+/="; // all numbers plus +/=

//Heres the encode function
function encode64(inp){
	var out = ""; //This is the output
	var chr1, chr2, chr3 = ""; //These are the 3 bytes to be encoded
	var enc1, enc2, enc3, enc4 = ""; //These are the 4 encoded bytes
	var i = 0; //Position counter

	do { //Set up the loop here
	chr1 = inp.charCodeAt(i++); //Grab the first byte
	chr2 = inp.charCodeAt(i++); //Grab the second byte
	chr3 = inp.charCodeAt(i++); //Grab the third byte

	//Here is the actual base64 encode part.
	//There really is only one way to do it.
	enc1 = chr1 >> 2;
	enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	enc4 = chr3 & 63;

	if (isNaN(chr2)) {
		enc3 = enc4 = 64;
	} else if (isNaN(chr3)) {
		enc4 = 64;
	}

	//Lets spit out the 4 encoded bytes
	out = out + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) +
	keyStr.charAt(enc4);

	// OK, now clean out the variables used.
	chr1 = chr2 = chr3 = "";
	enc1 = enc2 = enc3 = enc4 = "";

	} while (i < inp.length); //And finish off the loop

	//Now return the encoded values.
	return out;
}

//Heres the decode function
function decode64(inp){
	var out = ""; //This is the output
	var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes
	var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded
	var i = 0; //Position counter

	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	var base64test = /[^A-Za-z0-9\+\/\=]/g;

	if (base64test.exec(inp)) { //Do some error checking
	alert("There were invalid base64 characters in the input text.\n" +
	"Valid base64 characters are A-Z, a-z, 0-9, ?+?, ?/?, and ?=?\n" +
	"Expect errors in decoding.");
	}
	inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");

	do { //Here the decode loop.

	//Grab 4 bytes of encoded content.
	enc1 = keyStr.indexOf(inp.charAt(i++));
	enc2 = keyStr.indexOf(inp.charAt(i++));
	enc3 = keyStr.indexOf(inp.charAt(i++));
	enc4 = keyStr.indexOf(inp.charAt(i++));

	//Heres the decode part. There閿熸枻鎷穝 really only one way to do it.
	chr1 = (enc1 << 2) | (enc2 >> 4);
	chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
	chr3 = ((enc3 & 3) << 6) | enc4;

	//Start to output decoded content
	out = out + String.fromCharCode(chr1);

	if (enc3 != 64) {
		out = out + String.fromCharCode(chr2);
	}
	if (enc4 != 64) {
		out = out + String.fromCharCode(chr3);
	}

	//now clean out the variables used
	chr1 = chr2 = chr3 = "";
	enc1 = enc2 = enc3 = enc4 = "";

	} while (i < inp.length); //finish off the loop

	//Now return the decoded values.
	return out;
}
function chk_broswer(){
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		return(true);
	}
	else{
		return(false);
	}
}

var player=null;
var current = 0;
var timer=null;


//window.onload=init;

function musicInit(){
	player=document.getElementById("player");
	if(titles.length>0){
		player.attachEvent("EndOfStream", onPlayEnd);
		connect();
		play();
		setPlayList();
	}
}
function connect(){
	if(titles.length==0) return;
	player.Filename = decode64(musics[current]);
	if(chk_broswer() == true){
		if( titles.length > 0){
		music_title.innerText = aritsts[current] + " - " + titles[current];
			//top.frmBGM.str_music_title.value = aritsts[current] + " - " + titles[current];
			//if(top.ps_main && top.ps_main.music_title){
			//	top.ps_main.music_title.innerText = top.frmBGM.str_music_title.value;
			//}
		}
	}

}
function play(){
	stopped=false;
	player.Play();
}
function pause(){
	player.Pause();
}
function stop(){
	stopped=true;
	player.Stop();
}
function next(){
	current++;
	if(current>=titles.length){
		current = 0;
	}
	connect();
}
function prev(){
	current--;
	if(current < 0){
		current = titles.length - 1;
	}
	connect();
}
function jump(index){
	index = Math.min(index,titles.length);
	index = Math.max(index,0);
	current = index;
	if(timer) clearTimeout(timer);
	connect();
}

function onPlayEnd(){
	timer=setTimeout('next()', 5000);
}

</script>

<asp:Literal runat="server" ID="musicList"></asp:Literal>
<asp:Literal runat="server" ID="playList"></asp:Literal>

<table border="0" cellpadding="0" cellspacing="0" width="98%" align="center">
    <tr>
        <td height="1">
        </td>
    </tr>
    <tr>
        <td   colspan="2" height="20" style="padding-right: 0px;
            padding-left: 0px; padding-bottom: 0px; padding-top: 2px">
            <marquee direction="left" onmouseout="this.start()" onmouseover="this.stop()" scrollamount="2">
                <span id="music_title"></span>
            </marquee>
        </td>
    </tr>
    <tr>
        <td height="1">
        </td>
    </tr>
    <tr  class="PicTab">
        <td height="17" valign="bottom" width="27">
            <span onclick="ShowPlayList()" style="padding-right: 0px; padding-left: 0px; padding-bottom: 0px;
                width: 20px; cursor: hand; padding-top: 5px; height: 15px">
                <img id="img_show_music_list" alt="显示播放列表" height="4" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_33.gif"
                    style="margin: 0px 0px 3px 7px" width="7" /></span></td>
        <td valign="top" width="75" align=center>
            <img alt="上一首" height="14" onclick=" prev();" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_next2.gif"
                style="margin: 2px 3px 0px 0px; cursor: hand" width="12" /><img alt="播放" height="14"
                    onclick="play();" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_paly.gif"
                    style="margin: 0px 3px 0px 0px; cursor: hand" width="12" /><img alt="暂停" height="14"
                        onclick="pause();" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_pause.gif"
                        style="margin: 0px 3px 0px 0px; cursor: hand" width="12" /><img alt="停止" height="14"
                            onclick="stop();" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_stop.gif"
                            style="margin: 0px 3px 0px 0px; cursor: hand" width="12" /><img alt="下一首" height="14"
                                onclick="next();" src="<%=Spaces.Globals.GetSkinPath() %>/images/play/musicpaly_next.gif"
                                style="cursor: hand" width="12" /></td>
    </tr>
</table>
<div id="div_music_play_list" style="display: none; margin: 2px 0px">
    <table border="0" cellpadding="0" cellspacing="0" width="98%" align="center">
        <tr>
            <td>
                <div id="music_play_list" >
                </div>
            </td>
        </tr>
    </table>
   
</div>
 <script>
    musicInit();
    </script>