/*
// ----------------------------------------------------------------------------------------------------------------------------------------------
// SOUNDAWESOME
//
// V3 PLAYER JQUERY SCRIPT v2.0
//
// Versions:
// v2.0 allows for multiple players on a page, and keeps them grouped together in an object array
//
// (c) 2011 Marc Jones, Jon Slack
// ----------------------------------------------------------------------------------------------------------------------------------------------
 */

	var v3playerData = function() {
		this.containerid = null;
		this.autoplay = false;
		this.playall = false;
		this.usertype = null; // type of user listening to the track ( null / B / U / V )
		this.isradio = false;
		this.eventid = null;
		this.protocol = null; // used to save us from facebook api breaking https
		this.style = null; // the player style
		this.hasprogress = null; // the DOM ID of a progress bar (optional)
		this.hasticker = null; // the DOM ID of a ticker bar (optional)
		this.tickerbias = -1; // the movement bias of the ticker bar (optional)
		this.tickerinterval = null; // interval to re-call the ticker (optional)
	}

	var v3player = new Array();


// ----------------------------------------------------------------------------------------------------------------------------------------------
// this is where we quickly close everything down before the page unloads
	
	$(document).unload(function() { 
		for(var n = 0; n < v3player.length; n++) {
			if(v3player[n] != null) {
				jwplayer(v3player[n].containerid+'jwp').stop();
				$('#'+v3player[n].containerid).html('');
			}
		}
	});


// ----------------------------------------------------------------------------------------------------------------------------------------------
// Initialising a main page player

	// containerid is the dom id of the holder for the player
	// memberid is the id of the profile owner
	// usertype is it user_type of the currently logged in member
	// autoplay true/false
	// playerstyle is the style of the player to be used

	// optional fileurl is an absolute url - used in stand-alone mode
	// optional trackid the id of a track - used for profile players to autoplay a specific track id within a playlist

	function v3player_init(containerid, memberid, usertype, autoplay, playerstyle, playercolours, fileurl, imgurl, trackid, eventid) {
		// build a new player data record
		var index = v3player.length;
		v3player[index] = new v3playerData();
		// fill the record with info
		v3player[index].containerid = containerid;
		v3player[index].memberid = memberid;
		v3player[index].usertype = usertype;
		v3player[index].autoplay = autoplay;
		v3player[index].eventid = eventid;
		v3player[index].protocol = parent.location.protocol;
		v3player[index].style = playerstyle;
		v3player[index].tickerbias = -1;

		// build random number for the shuffled playlist - so player playlist order can be the same as the active playlist order
		var randnum = new Date().getTime();
		// build the correct player for the playerstyle
		switch(playerstyle) {

			
			// this is an invisible player used by the music search pages [no playlist] [never play all]
			case 'hidden':
				var html = '<div id="'+containerid+'jwp"></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'height'				: 16,
					'width'					: 300,
				});
				break;


			// this is an invisible player used by profile pages
			case 'javascriptwide':
				var html = '<div id="'+containerid+'jwp" style="position:fixed;top:0px;left:0px;width:0px;height:0px;overflow:hidden;"></div><div id="v3playerdiv3" style="margin:0px;padding:0px;"></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rss&rd='+randnum,
					'height'				: 1,
					'width'					: 1,
					'events'				: {
						onReady: function() {
							if(!trackid) { // if we're not autoplaying a specific track, show info for the first track in the playlist
								var item = this.getPlaylistItem(0);
								v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
							}
						},
						onPlaylist: function() {
							if(trackid) { // if we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
						onTime: function(obj) {
							var index = _v3player_get_playerdata_index(containerid);
							if(index > -1) {
								var v = (obj.position / obj.duration) * 100.0;
								var b = this.getBuffer();
								v3player_progressbar_set(containerid, v3player[index].hasprogress, v, b);
								//v3player_ticker_move(containerid, v3player[index].hasticker);
							}
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=javascriptwide&rd='+randnum, 'v3playerdiv3');
				break;


			// the carousel player for profiles (mainly for use in listener playlists) [no playlist] [never play all]
			case 'carousel': /* finished and tested */
				var html = '<div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rssfull&rd='+randnum,
					'skin'					: '/assets/v3player/modieus.zip',
					'plugins'				: '/assets/v3player/carousel.swf',
					'carousel.reflections'	: 'true',
					'carousel.glow'			: 'true',
					'carousel.outside'		: 'true',
					'dock'					: 'true',
					'height'				: 270,
					'width'					: 586,
					'backcolor'				: '#000000',
					'frontcolor'			: '#000000',
					'lightcolor'			: '#000000',
					'screencolor'			: '#000000',
					'wmode'					: 'transparent',
					'events'				: {
						onPlaylist: function() {
							if(trackid) { // is we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
					}
				});
				break;


			// visualisation player for profiles (does not work with videos) [right hand playlist] [auto play all]
			case 'visual': /* finished and tested */
				var html = '<table border="0" cellpacing="0" cellpadding="0"><tr><td width="400" valign="top"><div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div></td><td width="230" valign="top"><div id="v3playerdiv3" style="height:278px; max-height:278px; overflow:auto;"></div></td></tr></table></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rssfull&rd='+randnum,
					'skin'					: '/assets/v3player/modieus.zip',
					'plugins'				: { '/assets/v3player/revolt-1.swf' : { } },
					'dock'					: 'true',
					'repeat'				: 'list',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'false',
					'height'				: 248,
					'width'					: 400,
					'backcolor'				: 'transparent',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: 'transparent',
					'wmode'					: 'transparent',
					'events'				: {
						onReady: function() {
							if(!trackid) { // if we're not autoplaying a specific track, show info for the first track in the playlist
								var item = this.getPlaylistItem(0);
								v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
							}
						},
						onPlaylist: function() {
							if(trackid) { // is we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=activefull&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 278, '#777777', '#444444', 'transparent', '#A854F5');
				break;


			// equalizer player for profiles (does not work with videos) [right hand playlist]
			case 'equalizer': /* finished and tested */
				var html = '<table border="0" cellpacing="0" cellpadding="0"><tr><td width="400" valign="top"><div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div></td><td width="230" valign="top"><div id="v3playerdiv3" style="height:278px; max-height:278px; overflow:auto;"></div></td></tr></table></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rssfull&rd='+randnum,
					'skin'					: '/assets/v3player/modieus-no-loading-black.zip',
					'plugins'				: { '/assets/v3player/subeq-1h.swf' : {'soundonly' : 'true', 'noofbars' : '24', 'channels' : 'both', 'reverseright' : 'true'} },
					'dock'					: 'true',
					'repeat'				: 'list',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'false',
					'height'				: 248,
					'width'					: 400,
					'backcolor'				: 'transparent',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: 'transparent',
					'wmode'					: 'transparent',
					'events'				: {
						onReady: function() {
							if(!trackid) { // if we're not autoplaying a specific track, show info for the first track in the playlist
								var item = this.getPlaylistItem(0);
								v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
							}
						},
						onPlaylist: function() {
							if(trackid) { // is we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=activefull&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 278, '#777777', '#444444', 'transparent', '#A854F5');
				break;


			// mini player used on group pages (does not show videos) [bottom playlist]
			case 'mini':
				var html = '<div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div><div id="v3playerdiv3" style="height:200px; max-height:200px; overflow:auto; width:302px;"></div><br style="clear:both;"/>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'allowFullScreen'		: 'false',
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rss&rd='+randnum,
					'skin'					: '/assets/v3player/modieus-no-loading.zip',
					'displayHeight'			: '0',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'true',
					'height'				: 31,
					'width'					: 304,
					'backcolor'				: '#000000',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: '#0000000',
					'wmode'					: 'opaque',
					'events'				: {
						onReady: function() {
							var item = this.getPlaylistItem(0);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
						onComplete: function() { 
							if(v3player_playall) { jwplayer(containerid+'jwp').playlistNext(); }
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=mini&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 290, '#777777', '#444444', 'transparent', '#A854F5');
				break;


			// mini player used on events pages (does not show videos) [bottom playlist]
			case 'events_p3_player':
				var html = '<div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div><div id="v3playerdiv3" style="height:200px; max-height:200px; overflow:auto; width:302px;"></div><br style="clear:both;"/>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'allowFullScreen'		: 'false',
					'playlistfile'			: '/assets/v3player/playlist-events.php?eid='+eventid+'&cid='+containerid+'&st=rss&rd='+randnum,
					'skin'					: '/assets/v3player/modieus-no-loading.zip',
					'displayHeight'			: '0',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'true',
					'height'				: 31,
					'width'					: 304,
					'backcolor'				: '#000000',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: '#0000000',
					'wmode'					: 'opaque',
					'events'				: {
						onReady: function() {
							var item = this.getPlaylistItem(0);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
						onComplete: function() { 
							if(v3player_playall) { jwplayer(containerid+'jwp').playlistNext(); }
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-events.php?eid='+eventid+'&cid='+containerid+'&st=mini&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 290, '#777777', '#444444', 'transparent', '#A854F5');
				break;


			// compact equalizer player for profiles (not suitable for videos) [bottom playlist]
			case 'equalizer-compact': /* finished and tested */
				var html = '<div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div><div id="v3playerdiv3" style="height:278px; max-height:278px; overflow:auto;"></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rssfull&rd='+randnum,
					'skin'					: '/assets/v3player/modieus.zip',
					'plugins'				: { '/assets/v3player/subeq-1h.swf' : {'soundonly' : 'true', 'noofbars' : '24', 'channels' : 'both', 'reverseright' : 'true'} },
					'dock'					: 'true',
					'repeat'				: 'list',
					//'controlbar.position'	: 'bottom',
					//'controlbar.idlehide'	: 'true',
					'height'				: 80,
					'width'					: 586,
					'backcolor'				: 'transparent',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: 'transparent',
					'wmode'					: 'transparent',
					'events'				: {
						onReady: function() {
							if(!trackid) { // if we're not autoplaying a specific track, show info for the first track in the playlist
								var item = this.getPlaylistItem(0);
								v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
							}
						},
						onPlaylist: function() {
							if(trackid) { // is we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=activefull&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 278, '#777777', '#444444', 'transparent', '#A854F5');
				break;


			// standalone player for one off applications [no playlist] [no autoplay]
			case 'stand-alone': /* finished and tested */
				jwplayer(containerid).setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: 'false',
					'image'					: imgurl,
					'file'					: fileurl,
					'skin'					: '/assets/v3player/modieus.zip',
					'dock'					: 'true',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'false',
					'height'				: 392,
					'width'					: 640,
					'backcolor'				: 'transparent',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: 'transparent',
					'wmode'					: 'transparent'
				});
				break;


			// default player for profiles - if given a track id, plays that track, else loads a playlist [right hand playlist] [autoplay for single track]
			default: /* finished and tested */
				var html = '<table border="0" cellpacing="0" cellpadding="0"><tr><td width="400" valign="top"><div id="v3playerdiv1" style="border:1px solid #777777; background:url(/assets/v3player/player-bar-bg.png); color:#ffffff; font-family:arial,helvetica; font-size:8pt; position:relative;"></div><div id="'+containerid+'jwp"></div></td><td width="220" valign="top"><div id="v3playerdiv3" style="height:278px; max-height:278px; overflow:auto;"></div></td></tr></table></div>';
				$('#'+containerid).html(html);
				jwplayer(containerid+'jwp').setup({
					'flashplayer'			: '/assets/v3player/player.swf',
					'autostart'				: autoplay,
					'playlistfile'			: '/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rssfull&rd='+randnum,
					'skin'					: '/assets/v3player/modieus.zip',
					'dock'					: 'true',
					'repeat'				: 'list',
					'controlbar.position'	: 'bottom',
					'controlbar.idlehide'	: 'false',
					'height'				: 248,
					'width'					: 400,
					'backcolor'				: 'transparent',
					'frontcolor'			: '#00ff00',
					'lightcolor'			: '#ff0000',
					'screencolor'			: 'transparent',
					'wmode'					: 'transparent',
					'events'				: {
						onReady: function() {
							if(!trackid) { // if we're not autoplaying a specific track, show info for the first track in the playlist
								var item = this.getPlaylistItem(0);
								v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
							}
						},
						onPlaylist: function() {
							if(trackid) { // is we are autoplaying a specific track, go to it
								var list = this.getPlaylist();
								var trackindex = _v3player_get_track_index(trackid, list);
								this.playlistItem(trackindex);
							}
						},
						onPlaylistItem: function(obj) {
							var item = this.getPlaylistItem(obj.index);
							v3player_force_infobar(containerid, item.mediaid, item.ttitle, item.band);
						},
					}
				});
				dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=activefull&rd='+randnum, 'v3playerdiv3');
				//dom_scrollbar_add('v3playerdiv3', 'v3playerdiv4', 278, '#777777', '#444444', 'transparent', '#A854F5');
				break;
		}
		// set the z-index
		$('#'+containerid).css('zIndex', '0');
		$('#'+containerid+'jwp').css('zIndex', '0');
		$('#'+containerid+'jwp_wrapper').css('zIndex', '0');
	}


// ----------------------------------------------------------------------------------------------------------------------------------------------
// forcing the player to play something new


	//function v3player_force_play_single_mini(containerid, trackid, tracktype, title, band) { /* the mini style uses this */
	//	var furl = 'http://www.soundawesomestream.com/'+trackid+'.mp3';
	//	v3player_playall = false;
	//	v3player_isradio = false;
	//	if(tracktype == 'V') {
	//		furl = 'http://www.soundawesomestream.com/'+trackid+'.flv';
	//		jwplayer(containerid+'jwp').load({file:furl, provider:'http', 'http.startparam':'starttime'});
	//	} else {
	//		jwplayer(containerid+'jwp').load({file:furl});
	//	}
//
//		jwplayer(containerid+'jwp').play();
//		v3player_curplaying_trackid = trackid;
//		v3player_curplaying_tracktitle = title;
//		v3player_curplaying_bandname = band;
//		v3player_force_infobar(containerid, trackid, title, band);
//	}


	// force a player to play a single track within a playlist - used when you click on a playlist item
	function v3player_force_play_single_track(containerid, trackid) {
		var list = jwplayer(containerid+'jwp').getPlaylist();
		var trackindex = _v3player_get_track_index(trackid, list);
		jwplayer(containerid+'jwp').playlistItem(trackindex);
		//jwplayer(containerid+'jwp').play();
		//if(v3player_style != 'hidden') v3player_force_infobar(containerid);
	}


	// force a player to play a single track - used when you need to load and play a single item (the music search pages use this)
	function v3player_force_load_single_track(containerid, trackid, tracktype) {
		var ftype = 'audio';
		var furl = 'http://www.soundawesomestream.com/'+trackid+'.mp3';
		var fimg = '/user_track_images/'+trackid+'.jpg';
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			v3player[index].isradio = false;
			if(v3player[index].style == 'equalizer-compact' || v3player[index].style == 'hidden') fimg = '';

			if(tracktype == 'V') {
				ftype = "video";
				furl = 'http://www.soundawesomestream.com/'+trackid+'.flv';
				jwplayer(containerid+'jwp').load({file:furl, provider:'http', 'http.startparam':'starttime'});
			} else {
				jwplayer(containerid+'jwp').load({image:fimg, file:furl});
			}

			jwplayer(containerid+'jwp').play();
			//if(v3player_style != 'hidden') v3player_force_infobar(containerid);
		}
	}


	// force a player to play the radio
	function v3player_force_play_radio(containerid) {
		jwplayer(containerid+'jwp').load({file:'http://soundawesome.com:9000/;listen.pls', provider:'http', 'http.startparam':'starttime'});
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			v3player[index].isradio = true;
			setTimeout('v3player_force_play("'+containerid+'")', 2000);
			v3player_force_infobar(containerid);
		}
	}


	// force playing a specific member's playlist
	function v3player_force_new_playlist(containerid, memberid, playlist_style) {
		var randnum = new Date().getTime();		
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			v3player[index].isradio = false;
			jwplayer(containerid+'jwp').load('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=rss&rd='+randnum);
			dom_ajax('/assets/v3player/playlist-profiles.php?id='+memberid+'&cid='+containerid+'&st=mini&rd='+randnum, 'v3playerdiv3');
			setTimeout('v3player_force_play("'+containerid+'")', 3000);
		}
	}


	// start playing
	function v3player_force_play(containerid) { jwplayer(containerid+'jwp').play(); }

	
	// stop playing
	function v3player_force_stop(containerid) { jwplayer(containerid+'jwp').stop(); }


	// pause playing
	function v3player_force_pause(containerid) { jwplayer(containerid+'jwp').pause(); }


// ----------------------------------------------------------------------------------------------------------------------------------------------
// write the player information bar

	function v3player_force_infobar(containerid, trackid, tracktitle, bandname) {
		var tlen = tracktitle.length;
		var blen = bandname.length;
		var text = tracktitle + ' By ' + bandname;
		var index = _v3player_get_playerdata_index(containerid);
		safetracktitle = tracktitle.replace(/\'/g, "\\\'");
		//safetracktitle = safetracktitle.replace(/\"/g, "\\\"");
		var safebandname = bandname.toLowerCase();
		safebandname = safebandname.replace(/ /g, '-');

		if(index > -1) {
			if(text.length > 44) text = tracktitle.substr(0, 34 - blen) + '... By ' + bandname;
			if(v3player[index].style == 'mini') text = tracktitle.substr(0, 24);
			if(v3player[index].isradio) text = 'SoundAwesome.FM Radio';

			var html = '<table border="0" cellspacing="0" cellpadding="4" width="100%"><tr>';
			html += '<td class="secondary" width="400" align="center" style="color:#ffffff;font-family:arial,helvetica;font-size:9pt;" title="'+tracktitle+'">'+text+'</td>';
			if(!v3player[index].isradio) {
				html += '<td nowrap="nowrap" align="right"><a id="but1" href="#" onclick="v3player_force_review(\''+tracktitle+'\',\''+bandname+'\');return false;" title="Write A Review"><img src="/assets/v3player/player-button-review.png" border="0"></a></td>';
				html += '<td nowrap="nowrap" align="right"><a id="but2" href="#" onclick="v3player_force_addtoplaylist(\''+trackid+'\');return false;" title="Add To Playlist"><img src="/assets/v3player/player-button-addpl.png" border="0"></a></td>';
				html += '<td nowrap="nowrap" align="right"><a id="but3" href="#" onclick="v3player_force_vote(\''+trackid+'\');return false;" title="Vote For This Track"><img src="/assets/v3player/player-button-vote.png" border="0"></a></td>';
				if(v3player[index].style == 'mini') html += '<td nowrap="nowrap" align="right"><a href="#" onclick="v3player_force_play_radio(\''+containerid+'\');return false;" title="Listen To SA.FM Radio"><img src="/assets/v3player/player-button-radio.png" border="0"></a></td>';
				if(v3player[index].protocol == "http:") html += '<td nowrap="nowrap" align="right"><iframe src="http://www.soundawesome.com/og.php?t='+trackid+'" scrolling="no" frameborder="0" framespacing="0" style="border:0px; overflow:hidden; width:18px; height:18px; margin:0px; padding:0px; position:relative; top:0px;" allowTransparency="true"></iframe></td>';

				//html += '<td nowrap="nowrap" align="right"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F'+bandname.replace(' ','-')+'.soundawesome.com%2Ftrack%2F'+escape(tracktitle)+'%2F'+trackid+'&amp;send-true&amp;layout=button&amp;width=100&amp;show_faces=false&amp;action=like&height=21" scrolling="no" frameborder="0" style="border:none;overflow:hidden;width:100px;height:21px;" allowTransparency="true"></iframe></td>';
				//var fb_m = 'http://'+safebandname+'.soundawesome.com/track/'+escape(tracktitle.replace(/ /g,'+'))+'/'+trackid;//'Here\\\'s a great track on SoundAwesome...';
				//var fb_n = safetracktitle+' By '+bandname;
				//var fb_c = safebandname+'.soundawesome.com';
				//var fb_l = 'http://'+safebandname+'.soundawesome.com/track/'+escape(tracktitle.replace(/ /g,'+'))+'/'+trackid;
				//var fb_d = 'Some description';
				//html += '<td nowrap="nowrap" align="right"><a href="#" onclick="facebook_post(\''+fb_m+'\',\''+fb_n+'\',\''+fb_c+'\',\''+fb_l+'\',\''+fb_d+'\',\''+fb_p+'\');return false;" title="Share this track on facebook"><img src="/images/icon-facebook-tiny.png" border="0"></a></td>';

				var fb_u = 'http://www.soundawesomestream.com/'+trackid+'.mp3';
				var fb_t = safetracktitle;
				var fb_a = safebandname;
				var fb_h = 'http://'+safebandname+'.soundawesome.com/track/'+escape(tracktitle.replace(/ /g,'+'))+'/'+trackid;
				var fb_d = 'Some description';
				//html += '<td nowrap="nowrap" align="right"><a href="#" onclick="facebook_post_audio(\''+fb_u+'\',\''+fb_t+'\',\''+fb_a+'\',\''+fb_h+'\',\''+fb_d+'\');return false;" title="Share this track on facebook"><img src="/images/icon-facebook-tiny.png" border="0"></a></td>';
				//facebook_post_audio(fb_url, fb_title, fb_artist, fb_href, fb_description);
			}
			html += '<td> &nbsp; </td>';
			html += '</tr></table>';
			$('#v3playerdiv1').html(html);
		}
	}


	function v3player_progressbar_init(containerid, progressid) {
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			v3player[index].hasprogress = progressid;
			if($('#'+progressid).length > 0) {
				$('#'+progressid+'bar').width(0);
				$('#'+progressid+'buffer').width(0);
			}
		}
	}


	function v3player_progressbar_set(containerid, progressid, value, buffer) {
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			var maxwidth = $('#'+progressid).width() - 2;
			var curwidth = $('#'+progressid+'bar').width();
			var newwidth = parseInt((maxwidth / 100.0) * (value + 1));
			var buffcurwidth = $('#'+progressid+'buffer').width();
			var buffnewwidth = parseInt((maxwidth / 100.0) * (buffer + 1));

			if(buffnewwidth < 1) buffnewwidth = 1;
			if(buffnewwidth > maxwidth) buffnewwidth = maxwidth;
			if(buffnewwidth == 0 || buffnewwidth > buffcurwidth)
				$('#'+progressid+'buffer').width(buffnewwidth);

			if(newwidth < 1) newwidth = 1;
			if(newwidth > maxwidth) newwidth = maxwidth;
			if(newwidth == 0 || newwidth > curwidth)
				$('#'+progressid+'bar').width(newwidth);
		}
	}


	function v3player_ticker_init(containerid, tickerid) {
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			// stop any current ticker and reset it
			if(v3player[index].tickerinterval) {
				$('#'+tickerid+'bar').css('left', '0px');
				clearInterval(v3player[index].tickerinterval);
				v3player[index].tickerinterval = null;
			}
			v3player[index].hasticker = tickerid;
			if($('#'+tickerid).length > 0) $('#'+tickerid+'bar').css('left', '0px');
			v3player[index].tickerinterval = setInterval('v3player_ticker_roll("'+containerid+'","'+tickerid+'")', 25);
			
		}
	}


	function v3player_ticker_stop(containerid, tickerid) {
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			clearInterval(v3player[index].tickerinterval);
			v3player[index].tickerinterval = null;
		}
	}


	function v3player_ticker_roll(containerid, tickerid) {
		var index = _v3player_get_playerdata_index(containerid);
		if(index > -1) {
			var tickerwidth = $('#'+tickerid).width();
			var tickerbarwidth = $('#'+tickerid+'bar').width();
			if(tickerbarwidth > tickerwidth) {
				var curleft = parseInt($('#'+tickerid+'bar').css('left'));
				if(v3player[index].tickerbias == -1) {
					if(tickerbarwidth + curleft > tickerwidth) {
						// still going -1
						$('#'+tickerid+'bar').css('left', (curleft-1)+'px');
					} else {
						// reached minimum
						v3player[index].tickerbias = 1;
					}
				} else {
					if(curleft <= 0) {
						// still going +1
						$('#'+tickerid+'bar').css('left', (curleft+1)+'px');
					} else {
						// reached maximum
						v3player[index].tickerbias = -1;
					}
				}
			}
		}
	}


// ----------------------------------------------------------------------------------------------------------------------------------------------
// player functionality for the icon buttons

	function v3player_force_vote(trackid) { dom_bubble_open('Voting', '/ajax/iframe-voting.php?tid='+trackid, 'small', TYPE_AJAX, '', 'ok'); }

	function v3player_force_review(tracktitle, bandname) { dom_bubble_open('Write Review', '/ajax/iframe-forum-add-topic.php?f=902&amp;rb='+bandname+'&amp;rt='+tracktitle, 'xlarge', TYPE_IFRAME, '', 'cancel|post'); }

	function v3player_force_addtoplaylist(trackid) { dom_bubble_open('Add To Playlist', '/ajax/iframe-account-playlistadd.php?tid='+trackid, 'small', TYPE_AJAX, '', 'ok'); }


// ----------------------------------------------------------------------------------------------------------------------------------------------
// helper functions

	// get the v3playerData index for a given containerid
	function _v3player_get_playerdata_index(containerid) {
		var l = v3player.length;
		var found = -1;
		for(var n = 0; n < l; n++) {
			if(v3player[n].containerid == containerid) {
				found = n;
				break;
			}
		}
		return found;
	}


	// is this the last track in the playlist
	function _v3player_is_last_track_in_playlist(trackid, tracksarray) {
		var l = tracksarray.length;
		if(tracksarray[l-1].mediaid == trackid) return true;
		return false;
	}


	// find index of a specific track in a playlist
	function _v3player_get_track_index(trackid, tracksarray) {
		var l = tracksarray.length;
		var found = -1;
		for(var n = 0; n < l; n++) {
			if(tracksarray[n].mediaid == trackid) {
				found = n;
				break;
			}
		}
		return found;
	}


// ----------------------------------------------------------------------------------------------------------------------------------------------

