function displayPlayList() {
	$("#jplayer_playlist ul").empty();
	for (i=0; i < myPlayList.length; i++) {
		var listItem = (i == myPlayList.length-1) ? "<li class='jplayer_playlist_item_last'>" : "<li>";
		listItem += "<a href='#' id='jplayer_playlist_item_"+i+"' tabindex='1'>"+ myPlayList[i].name +"</a></li>";
		$("#jplayer_playlist ul").append(listItem);
		$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
			var index = $(this).data("index");
			if (playItem != index) {
				playListChange( index );
			} else {
				$("#jquery_jplayer").jPlayer("play");
			}
			$(this).blur();
			return false;
		});
	}
}
function playListInit(autoplay) {
	if(autoplay) {
		playListChange( playItem );
	} else {
		playListConfig( playItem );
	}
}

function playListConfig( index ) {
	$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current").parent().removeClass("jplayer_playlist_current");
	$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current").parent().addClass("jplayer_playlist_current");
	playItem = index;
	$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3);
	$("#jquery_jplayer").jPlayer("play");
	//playListChange( index );
}

function playListChange( index ) {

	playListConfig( index );
	
	//Modifica clima do site de acordo com a música
	var clima = myPlayList[index].clima;
	var cor = myPlayList[index].cor;
	MudaClima(clima,cor);
	$("#jplayer_music_name").html("#NP <b>" + myPlayList[index].name + "</b>");
	$("#jplayer_playlist").parent("div").attr("scrollTop",index * 25);
}

function playListNext() {
	var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
	playListChange( index );
	EfeitoPlayer();
}

function playListPrev() {
	var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
	playListChange( index);
	EfeitoPlayer();
}

function EfeitoPlayer()
{
	$("#player-container")
	.stop()
	.animate({right : 0},{duration:1000})
	.delay(5000)
	.animate({right : -$("#tdPlayer").width()},{duration:100});
}

