var player = {
    t : null,
    playList : [],
    status : 'play',
    cnt : 0,
    
    init: function() {
        //return;
        if ( playList.length != 0 ) {
            player.playList = playList;
        }
        if ( flash == true ) {
            $('#jP').jPlayer({
    		swfPath: doc_root+'swf/',
    		volume: 20,
    		solution: "flash",
    		customCssIds: true
            });
            player.t = setTimeout(function(){player.play();},2500);
        }
        else {
            $('#jP').jPlayer({
   		swfPath: doc_root+'swf/',
   		volume: 20,
   		solution: "html",
   		customCssIds: true
            });
        }
    },
    
    play : function() {
        if ( player.playList.length == 0 ) {
            player.stop();
            return;
        }
        if ( player.status == 'pause'){
            player.status = 'play';
            $('#jP').jPlayer( "play" );
            $('#m').attr('src',img+'pause.png');
	}
	else if ( $('#m').attr('src') == img+'pause.png' && player.status == 'play' ) {
            $('#jP').jPlayer( "pause" );
            player.status = 'pause';
            $('#m').attr('src',img+'play.png');
	}
	else {
            player.status = 'play';
            $('#jP').jPlayer("setFile",player.playList[player.cnt][3]);
            $('#jP').jPlayer( "play" );
            $("#jP").jPlayer("onSoundComplete", function() {
                player.t = setTimeout(function(){player.next();},500);
            });
            //$('.a_art').html(player.playList[player.cnt][1]);
            //$('.a_name').html(player.playList[player.cnt][2]);
            $('#m').attr('src',img+'pause.png');
	}
    },
    
    pause : function(){
        $('#jP').jPlayer( "pause" );
        $('#m').attr('src',img+'play.png');
        player.status = 'pause';
    },
    
    next : function() {
        player.status = 'next';
        $('#jP').jPlayer( "stop" );
        $("#jP").jPlayer( "clearFile" );
        player.cnt++;
        if ( player.playList[player.cnt] == undefined ) player.cnt = 0;
        player.t = setTimeout(function(){player.play();},500);
    },
    
    prev : function() {
        player.status = 'prev';
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	if ( player.cnt == 0 ) player.cnt = (player.playList.length)-1;
	else player.cnt--;
	player.t = setTimeout(function(){player.play();},500);
    },
    
    stop : function() {
        $('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	player.status = 'stop';
	player.cnt = 0;
        //$('.a_art').html('&nbsp;');
        //$('.a_name').html('&nbsp;');
	$('#m').attr('src',img+'play.png');
    },
    
    callMusic : function(id) {
        for(var i= 0;i!=player.playList.length;i++){
            if ( player.playList[i][0] == id ) break;
        }
	player.cnt = i;
	player.status = 'next';
	$('#jP').jPlayer( "stop" );
	$("#jP").jPlayer( "clearFile" );
	player.t = setTimeout(function(){player.play();},500);
    }
    
};
