var playlist = {
	music_index : 0,
	playID : "#jquery_jplayer_1",
	music_list : [],
	music_list_tmp : [],
	init:function(m){
		d = this;
		d.music_list = m;
		d.set_playlist();
		$(d.playID).jPlayer({
			ready: function () {
				d.play();
			},
			ended: function() {				
				d.next();
			},
			timeupdate: function(event) {
				var curt = event.jPlayer.status.currentTime;
				var totalt = event.jPlayer.status.duration;
				var t = totalt - curt;
				var fen = '00';
				var miao = '00';
				if (parseInt(t % 60) < 10) {
					miao = "0" + parseInt(t % 60)
				} else {
					miao = parseInt(t % 60)
				}
				if ((Math.floor(t / 60)) < 10) {
					fen = "0" + (Math.floor(t / 60))
				} else {
					fen = (Math.floor(t / 60))
				}
				$("p.my-current-time").text(fen + ':' + miao)
			},
			swfPath: web_url+"skins/index/hanmai/js",
			supplied: "mp3",
			wmode: "window",
			smoothPlayBar: true,
			keyEnabled: true
		});
	},

	set_playlist:function(){
		var html = '';
		for(i in this.music_list){
			html += '<li id="plist'+i+'"><span class="num tip">'+(parseInt(i)+1)+'</span><span class="m_p"><a href="javascript:void(0)" onclick="playlist.go('+i+');">'+this.music_list[i]['title']+'</a></span><span class="m_cz"><a href="javascript:void(0)" onclick="playlist.go('+i+');" title="ÊÔÌý" class="play">ÊÔÌý</a></span></li>'
		}
		$('#playlist').html(html);
	},

	go:function(i){
		this.music_index = i;
		this.play();
	},

	play:function(){
		$('#wrfplaytitle marquee').html(this.music_list[this.music_index]['title']);
		$(this.playID).jPlayer("setMedia", {mp3:this.music_list[this.music_index]['mp3']}).jPlayer('play');
		$('#playlist').find('li').removeClass('current').eq(this.music_index).addClass('current');
                SetCookie("open_player", "", null, "/", DomainUrl, false);
	},

	pause:function(){
		$(this.playID).jPlayer('pause');
	},

	prev:function(){
		this.music_index--;
		if(this.music_index < 0){
			this.music_index = this.music_list.length;
		}
		this.play();
	},
	
	next:function(){
		this.music_index++;
		if(this.music_index > this.music_list.length){
			this.music_index = 0;
		}
		this.play();
	}
};
playlist.init(Music);
function chk_open() {
    if( 'Y' == get_cookie('open_player') )
    {
        playlist.pause();
    }else {
        setTimeout('chk_open()', 3000);
    }
};
chk_open();