// Original concept from: http://willswonders.myip.org:8085/php/Multiple%20Players.html
var cmlh = '';	// Current M3U Link HTML
var ceid = '';	// Current Element ID
var embedStatus = false;

function outputStatus(e)
{
	embedStatus = ! e.success;
}

function loadButtonPlayer_1(e)
{
	// Account for "MP3 download whole song, hi-fi" option
	if($('#'+e.id).attr('href').match(/.mp3$/))
	{
		return true;
	}

	var music_file	= encodeURIComponent($('#'+e.id).attr('href').replace(/.m3u$/, '.mp3'));
	var button_path	= 'tracks/buttons/negative_small';
	var swf			= 'tracks/audioplay.swf';

	// Restore original button span and m3u anchor link of previous button player.
	if(cmlh !== '')
	{
		$('#'+ceid).parent().html(cmlh);
	}
	// Save the original button span and m3u anchor html
	cmlh = $('#'+e.id).parent().html();
	// Save current page element's id
	ceid = e.id;

	var flashvars = {
		auto:			'yes',			// auto - autostart (yes|no), default no
		bgcolor:		'0xf1f1f1',		// bgcolor - background color (color in hex format, 0xff0000 for red for example), default 0x000000 (black)
		repeat:			'1',			// repeat - how many times music will be played, 0 - infinite loop, default setting
		file:			music_file,		// file - music file path, default 'music.mp3'
		buttondir:		button_path,	// buttondir - path to button directory, default 'buttons/classic'
		usebgcolor:		'yes',			// usebgcolor - disables transparency if set to 'yes', 'bgcolor' will be used as background, default 'no' (NEW !)
		mastervol:		'100'			// mastervol - master volume (0-100), default 100 (NEW !)
	};
	var params = { wmode: 'transparent' };
	var attributes = { };

	swfobject.embedSWF(swf, 'button_'+e.id, '15', '15', '9', false, flashvars, params, attributes, outputStatus);

	// if true, prevents the .m3u from being downloaded.
	// else, no Flash, so offer the .m3u file.
	return embedStatus;
}






function loadButtonPlayer_2(e)
{
	// Account for "MP3 download whole song, hi-fi" option
	if($('#'+e.id).attr('href').match(/.mp3$/))
	{
		return true;
	}

	var music_file	= encodeURIComponent($('#'+e.id).attr('href').replace(/.m3u$/, '.mp3'));
	var button_path	= 'tracks/buttons/negative_small';
	var swf			= 'tracks/audioplay.swf';

	// Restore original button span and m3u anchor link of previous button player.
	if(cmlh !== '')
	{
		$('#'+ceid).parent().html(cmlh);
	}
	// Save the original button span and m3u anchor html
	cmlh = $('#'+e.id).parent().html();
	// Save current page element's id
	ceid = e.id;

	var flashvars = {
		auto:			'yes',			// auto - autostart (yes|no), default no
		bgcolor:		'0xffffff',		// bgcolor - background color (color in hex format, 0xff0000 for red for example), default 0x000000 (black)
		repeat:			'1',			// repeat - how many times music will be played, 0 - infinite loop, default setting
		file:			music_file,		// file - music file path, default 'music.mp3'
		buttondir:		button_path,	// buttondir - path to button directory, default 'buttons/classic'
		usebgcolor:		'yes',			// usebgcolor - disables transparency if set to 'yes', 'bgcolor' will be used as background, default 'no' (NEW !)
		mastervol:		'100'			// mastervol - master volume (0-100), default 100 (NEW !)
	};
	var params = { wmode: 'transparent' };
	var attributes = { };

	swfobject.embedSWF(swf, 'button_'+e.id, '15', '15', '9', false, flashvars, params, attributes, outputStatus);

	// if true, prevents the .m3u from being downloaded.
	// else, no Flash, so offer the .m3u file.
	return embedStatus;
}

