// close other audio players
// called by audio player when click on play button 
function ap_stopAll(player_id)
{
	$('.audio_flash').each(function(){
		if($(this).attr('id') != player_id)
		{
			$(this).find('object')[0].SetVariable("closePlayer", 1);
		}
		else 
		{
			$(this).find('object')[0].SetVariable("closePlayer", 0);
		}
	});
}

$(document).ready(function() {

	$('a').each(function() {
		if (this.href.indexOf('.mp3')>-1) {
			audio_file = $(this).attr('href'); 
			audio_title = $(this).text();
			audio_id = $(this).attr('id');
			
			div = $('<div class="audio_flash" id="' + audio_id + '"></div>');		
			$(this).after(div);
			$(this).after(audio_title);
			$(this).remove();
			div.flash(
				{
					swf: 'scripts/audioplayer.swf',
					flashvars:
					{
						soundFile: audio_file,
						playerID: "'" + audio_id + "'",
						quality: 'high',
						wmode: 'transparent'
					},
					height: 50
				}
			);
		}
	});

});

