/**
 * Magically convert links to .mp3 files to embedded .mp3s
 *
 * This script surrounds the .mp3 links with an appropriate span and then invokes swfobject.js methods for the real magic
 * @author Nathan White
 * @requires jQuery and swfobject.js to be loaded
 */

$(document).ready(function()
{
	index = 1;
	span_id_base_name = 'mediaAutoEmbedWrap';
	flvplayer_path = '/reason_package/flvplayer/flvplayer.swf';
	
	$("a[href$='.mp3']").each( function()
	{
		var href = $(this).attr('href');
		var span_id = span_id_base_name + index++;
		$(this).wrap('<span id="'+span_id+'"></span>');
		var swf = new SWFObject(flvplayer_path, span_id, "175", "20", "8");
		swf.addVariable('file',href);
		swf.write(span_id);
	});
});
