$(document).ready(function(){

	var playItem = 0;

	var myPlayList = [
		{name:"End Titles (Playing the Part, Short Film)",mp3:"http://www.noellachoi.com/Music/audio/Playing the Part - End Titles.mp3",ogg:"http://www.noellachoi.com/Music/audio/Playing the Part - End Titles.ogg"},
		{name:"No Frills 2010 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/Loblaws NoFrills 2010 Q2 B v3.mp3",ogg:"http://www.noellachoi.com/Music/audio/Loblaws NoFrills 2010 Q2 B v3.ogg"},
		{name:"Loblaws Superstore 2010 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/Loblaws Superstore 2010 Q2 C.mp3",ogg:"http://www.noellachoi.com/Music/audio/Loblaws Superstore 2010 Q2 C.ogg"},
		{name:"Tridel Hullmark (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/AviaPro Tridel Hullmark V4.mp3",ogg:"http://www.noellachoi.com/Music/audio/AviaPro Tridel Hullmark V4.ogg"},
		{name:"Telus CNY 2010 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/Telus%20CNY%20v3%20FluteLead.mp3",ogg:"http://www.noellachoi.com/Music/audio/Telus%20CNY%20v3%20FluteLead.ogg"},
		{name:"Loblaws 2010 CNY (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/B-Loblaws CNYa Ruan.mp3",ogg:"http://www.noellachoi.com/Music/audio/B-Loblaws CNYa Ruan.ogg"},
		{name:"Rogers Wireless 2008 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/China Syndrome - Q2 Rogers Wireless.mp3",ogg:"http://www.noellachoi.com/Music/audio/China Syndrome - Q2 Rogers Wireless.ogg"},
		{name:"Rogers Wireless CNY 2010 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/Rogers Cable CNY 2010 v1b.mp3",ogg:"http://www.noellachoi.com/Music/audio/Rogers Cable CNY 2010 v1b.ogg"},
		{name:"Rogers Christmas 2009 (Commercial)",mp3:"http://www.noellachoi.com/Music/audio/Rogers Q4 Revised A.mp3",ogg:"http://www.noellachoi.com/Music/audio/Rogers Q4 Revised A.ogg"},
		{name:"Christmas (Commercial Demo)",mp3:"http://www.noellachoi.com/Music/audio/Rogers Q4 - Xmas D.mp3",ogg:"http://www.noellachoi.com/Music/audio/Rogers Q4 - Xmas D.ogg"},
		{name:"English Horn (Virtues of Harmony I, TV Series)",mp3:"http://www.noellachoi.com/Music/audio/NoellaChoi_Virtues_EnglishHorn.mp3",ogg:"http://www.noellachoi.com/Music/audio/NoellaChoi_Virtues_EnglishHorn.ogg"},
		{name:"Sneaky Cello (Virtues of Harmony I, TV Series)",mp3:"http://www.noellachoi.com/Music/audio/NoellaChoi_Virtues_SneakyCello.mp3",ogg:"http://www.noellachoi.com/Music/audio/NoellaChoi_Virtues_SneakyCello.ogg"},
		{name:"Father & Son (The Town, TV Series)",mp3:"http://www.noellachoi.com/Music/audio/03 Father & Son.mp3",ogg:"http://www.noellachoi.com/Music/audio/03 Father & Son.ogg"},
		{name:"Under the Tree (The Town, TV Series)",mp3:"http://www.noellachoi.com/Music/audio/24 Under the Tree.mp3",ogg:"http://www.noellachoi.com/Music/audio/24 Under the Tree.ogg"},
	];

	// Local copy of jQuery selectors, for performance.
	var jpPlayTime = $("#jplayer_play_time");
	var jpTotalTime = $("#jplayer_total_time");

	$("#jquery_jplayer").jPlayer({
		ready: function() {
			displayPlayList();
			playListInit(true); // Parameter is a boolean for autoplay.
		},
		oggSupport: true
	})
	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		jpPlayTime.text($.jPlayer.convertTime(playedTime));
		jpTotalTime.text($.jPlayer.convertTime(totalTime));
	})
	.jPlayer("onSoundComplete", function() {
		playListNext();
	});

	$("#jplayer_previous").click( function() {
		playListPrev();
		$(this).blur();
		return false;
	});

	$("#jplayer_next").click( function() {
		playListNext();
		$(this).blur();
		return false;
	});

	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, myPlayList[playItem].ogg);
	}

	function playListChange( index ) {
		playListConfig( index );
		$("#jquery_jplayer").jPlayer("play");
	}

	function playListNext() {
		var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
		playListChange( index );
	}

	function playListPrev() {
		var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
		playListChange( index );
	}
});
-->
