window.addEvent('domready', function(){
	var willoughby_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/sarg001_01_Intentions.mp3',title:'Intentions',artist:'Willoughby'},
	{url:'audio/sarg001_02_Story.mp3',title:'Story',artist:'Willoughby'},
	{url:'audio/sarg001_03_Frankenstein.mp3',title:'Frankenstein',artist:'Willoughby'},
	{url:'audio/sarg001_04_Wonder.mp3',title:'Wonder',artist:'Willoughby'},
	{url:'audio/sarg001_05_DustBunnies.mp3',title:'Dust Bunnies',artist:'Willoughby'},
	{url:'audio/sarg001_06_LosingYou.mp3',title:'Losing You',artist:'Willoughby'},
	{url:'audio/sarg001_07_WishIWasYours.mp3',title:'Wish I Was Yours',artist:'Willoughby'},
	{url:'audio/sarg001_08_LongTime.mp3',title:'Long Time',artist:'Willoughby'},
	{url:'audio/sarg001_09_Uzzell.mp3',title:'Uzzell',artist:'Willoughby'},
	{url:'audio/sarg001_10_IKnowWhatYoureUpTo.mp3',title:'I Know What You\'re Up To',artist:'Willoughby'},
	{url:'audio/sarg001_11_Sign.mp3',title:'Sign',artist:'Willoughby'},
	{url:'audio/sarg001_12_YouDontLove.mp3',title:'You Don\'t Love',artist:'Willoughby'},
	{url:'audio/sarg001_13_Ok.mp3',title:'OK',artist:'Willoughby'},
];

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

willoughby_player.addEvent('ready', function() {
	$('willoughby_playerspc').getElement('div.title').set('html',willoughby_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'0.85em','list-style-type':'none'}}).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',{
				html: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($('willoughby_playlistspc'));
});

var electrocute_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/sarg002_01_OnTheBeat.mp3',title:'On The Beat',artist:'Electrocute'},
	{url:'audio/sarg002_02_UhOh.mp3',title:'Uh Oh',artist:'Electrocute'},
	{url:'audio/sarg002_03_TigerToy.mp3',title:'Tiger Toy',artist:'Electrocute'},
	{url:'audio/sarg002_04_Bad_Legs.mp3',title:'Bad Legs',artist:'Electrocute'},
	{url:'audio/sarg002_05_Saturn_Rings.mp3',title:'Saturn Rings',artist:'Electrocute'},
	{url:'audio/sarg002_06_JustLikeIAm.mp3',title:'Just Like I Am',artist:'Electrocute'},

];

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

electrocute_player.addEvent('ready', function() {
	$('electrocute_playerspc').getElement('div.title').set('html',electrocute_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'0.85em','list-style-type':'none'}}).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',{
				html: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($('electrocute_playlistspc'));
});

var wadhams_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/sarg003_01_SomeoneToKiss.mp3',title:'Someone To Kiss',artist:'Charlie Wadhams'},
	{url:'audio/sarg003_02_Darkness.mp3',title:'Darkness',artist:'Charlie Wadhams'},
	{url:'audio/sarg003_03_BlindasaBat.mp3',title:'Blind As A Bat',artist:'Charlie Wadhams'},
	{url:'audio/sarg003_04_MastersinChina.mp3',title:'Masters In China',artist:'Charlie Wadhams'},

];

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

wadhams_player.addEvent('ready', function() {
	$('wadhams_playerspc').getElement('div.title').set('html',wadhams_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'0.85em','list-style-type':'none'}}).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',{
				html: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($('wadhams_playlistspc'));
});

var volumeone_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/SargentSinglesVol1_A_InaraGeorge_Q.mp3',title:'Q :: Inara George ',artist:'Willoughby'},
	{url:'audio/SargentSinglesVol1_B_CharlieWadhams_ArrangingMyLife.mp3',title:'Arranging My Life :: Charlie Wadhams',artist:'Willoughby'},

];

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

volumeone_player.addEvent('ready', function() {
	$('volumeone_playerspc').getElement('div.title').set('html',volumeone_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'1.25em','list-style-type':'none'}}).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',{
				'html':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($('volumeone_playlistspc'));
});

var volumetwo_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/SargentSinglesVol2_A_BenjiHughes_CountryLove.mp3',title:'Country Love :: Benji Hughes ',artist:'Benji Hughes'},
	{url:'audio/SargentSinglesVol2_B_Willoughby_MidnightMorning.mp3',title:'Midnight Morning :: Willoughby',artist:'Willoughby'},

];

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

volumetwo_player.addEvent('ready', function() {
	$('volumetwo_playerspc').getElement('div.title').set('html',volumetwo_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'1.25em','list-style-type':'none'}}).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',{
				'html':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($('volumetwo_playlistspc'));
});


var volumethree_playlist = [
	// object {url:string url, title:string title, artist: string artist]
	// or
	// string url
	{url:'audio/SargentSinglesVol3_A_MikeAndrews_SunBurn.mp3',title:'Sun Burn :: Mike Andrews',artist:'Mike Andrews'},
	{url:'audio/SargentSinglesVol3_B_JakeBlanton_AllYouGet.mp3',title:'All You Get :: Jake Blanton',artist:'Jake Blanton'},

];

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

volumethree_player.addEvent('ready', function() {
	$('volumethree_playerspc').getElement('div.title').set('html',volumethree_playlist[0]['title']);
		
	var mainUl = new Element('ol',{'styles':{'padding':0,'margin':0,'font-size':'1.25em','list-style-type':'none'}}).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',{
				'html':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($('volumethree_playlistspc'));
});


addPauseOnPlay(willoughby_player,electrocute_player);
addPauseOnPlay(willoughby_player,wadhams_player);
addPauseOnPlay(willoughby_player,volumeone_player);
addPauseOnPlay(willoughby_player,volumetwo_player);
addPauseOnPlay(willoughby_player,volumethree_player);
addPauseOnPlay(electrocute_player,wadhams_player);
addPauseOnPlay(electrocute_player,willoughby_player);
addPauseOnPlay(electrocute_player,volumeone_player);
addPauseOnPlay(electrocute_player,volumetwo_player);
addPauseOnPlay(electrocute_player,volumethree_player);
addPauseOnPlay(wadhams_player,willoughby_player);
addPauseOnPlay(wadhams_player,electrocute_player);
addPauseOnPlay(wadhams_player,volumeone_player);
addPauseOnPlay(wadhams_player,volumetwo_player);
addPauseOnPlay(wadhams_player,volumethree_player);
addPauseOnPlay(volumeone_player,electrocute_player);
addPauseOnPlay(volumeone_player,wadhams_player);
addPauseOnPlay(volumeone_player,willoughby_player);
addPauseOnPlay(volumeone_player,volumetwo_player);
addPauseOnPlay(volumeone_player,volumethree_player);
addPauseOnPlay(volumetwo_player,electrocute_player);
addPauseOnPlay(volumetwo_player,wadhams_player);
addPauseOnPlay(volumetwo_player,willoughby_player);
addPauseOnPlay(volumetwo_player,volumeone_player);
addPauseOnPlay(volumetwo_player,volumethree_player);
addPauseOnPlay(volumethree_player,electrocute_player);
addPauseOnPlay(volumethree_player,wadhams_player);
addPauseOnPlay(volumethree_player,willoughby_player);
addPauseOnPlay(volumethree_player,volumeone_player);
addPauseOnPlay(volumethree_player,volumetwo_player);

});

function addPauseOnPlay(player,otherplayer){
	player.addEvent('ready', function() {
		player.addEvent('play',function() {
			if (otherplayer.currentSound !== null) {
				otherplayer.stopCurrentSound();
			}
		});
	});
}

