(function()
{
	
	var PLAYER_PATH = tacoBell.swfPath + 'shared/audio_player.swf';
	var PLAYER_WIDTH = 32;
	var PLAYER_HEIGHT = 32;
	var PLAYER_PARAMS = {
		wmode: 'transparent',
		scale: 'noscale',
		allowscriptaccess: 'always',
		menu: 'false',
		salign: 'tl'
	};
	
	var _players = [];
	var _callbacks = {};
	
	function newInstance(node, file, play_callback)
	{
		swfobject.embedSWF(
			PLAYER_PATH,
			node,
			PLAYER_WIDTH,
			PLAYER_HEIGHT,
			tacoBell.constants.REQUIRED_FLASH_PLAYER_VERSION,
			null,
			{
				file: tacoBell.audioPath + file,
				player_id: node,
				stopOtherAudio: 'TacoBellAudioPlayer.stopOtherAudio'
			},
			PLAYER_PARAMS
		);
		
		_players.push(node);
		_callbacks[node] = play_callback || function(){};
	}
	
	function stopOtherAudio(exclude_id)
	{
		for (var i = 0, l = _players.length; i<l; i++)
			if (_players[i] != exclude_id && swfobject.getObjectById(_players[i]) && swfobject.getObjectById(_players[i]).stopAudio)
				swfobject.getObjectById(_players[i]).stopAudio();
		
		_callbacks[exclude_id]();
	}
	
	window.TacoBellAudioPlayer = {
		newInstance: newInstance,
		stopOtherAudio: stopOtherAudio
	};
})();
