var playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Slippershell/Slippershell_128.mp3',title:'Slippershell',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Torque/Torque_128.mp3',title:'Torque',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/AroundDusk/AroundDusk_128.mp3',title:'Around Dusk',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/MorningBirds/MorningBirds_128.mp3',title:'Morning Birds',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Speedbath/Speedbath_128.mp3',title:'Speedbath',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Krait/Krait_128.mp3',title:'Krait',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Static/Static_128.mp3',title:'Static',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Moan/Moan_128.mp3',title:'Moan',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/ElizabethJune/ElizabethJune_128.mp3',title:'Elizabeth June',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/MississippiKite/MississippiKite_128.mp3',title:'Mississippi Kite',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Fortune/Fortune_128.mp3',title:'Fortune',artist:'Kristin Hersh'},
	{url:'http://s3.amazonaws.com/cash_users/kristinhersh/Speedbath/Rubidoux/Rubidoux_128.mp3',title:'Rubidoux',artist:'Kristin Hersh'}
];

var player = new SoundPlayer({
	playlist:playlist,
	swfLocation:"../scripts/SoundPlayer.swf",
	controlImages:{previous:"../images/previous.png",next:"../images/next.png",play:"../images/play.png",pause:"../images/pause.png"},
	seekbarSpcStyle: {'position':'relative','background-color':'#c7f5ff','height':'3px','width':'100%','margin-top':'4px','overflow':'hidden'},
	seekbarStyle: {'position':'absolute','background-color':'#8ab3fe','height':'3px','width':'0%','cursor':'pointer','z-index':'10'},
	positionStyle: {'position':'absolute','left':'0%','width':'3px','height':'3px','background-color':'#000','z-index':'15'}
});

player.addEvent('ready', function() {
	$('soundplayerspc').getElement('div.title').set('html','Press Play');
	$('photostrip2').setStyles({
	    visibility: 'hidden',
	    opacity: 0
	});
	
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'list-style-type':'decimal-leading-zero'}}).inject(this.controls);
	this.options.playlist.each(function(track,index) { 
		var tmpLi = new Element('li',{'styles':{'list-style-position':'inside'}}).inject(mainUl);
		var tmpSpan = new Element('span',{
			text:track.title,
			'styles':{'cursor':'pointer'},
			'events':{
				'click': function(){
					if (this.currentSound) {
						this.stopCurrentSound();
					}
		        	allSoundKeys = this.sounds.getKeys();
					sound = this.sounds.get(track.url);
					this.currentKey = allSoundKeys.indexOf(track.url);
					this.currentSound = sound;
					this.currentSound.sound.position = 0;
					this.playCurrentSound();
		        }.bind(this)
			}
		}).inject(tmpLi);;
	},this);
	mainUl.inject($('soundplayer_playlist'));
});

player.addEvent('play', function() {
	if ($('photostrip2').getStyle('visibility') == 'hidden') {
		$('photostrip2').setStyle('background-image','url(../images/speedbath_player/strips/'+player.currentKey+'.jpg)');
		$('photostrip2').fade('in');
	} else {
		$('photostrip1').setStyle('background-image','url(../images/speedbath_player/strips/'+player.currentKey+'.jpg)');
		$('photostrip2').fade('out');
	}
	$('track_content').set('html',$('trackdata_'+player.currentKey).get('html'));
});