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

jQuery(document).ready(function() {
	
	/* add audio player */
	
	jQuery('.audio').each(function() {
		audio_file = jQuery(this).attr('href'); 
		audio_title = jQuery(this).text();
		audio_id = jQuery(this).attr('id');
		
		div = jQuery('<div class="audio_flash" id="' + audio_id + '"></div>');		
		jQuery(this).after(div);
		//jQuery(this).after(audio_title);
		jQuery(this).remove();
		div.flash(
			{
				swf: SKIN_URL + 'flash/audioplayer.swf',
				flashvars:
				{
					soundFile: audio_file,
					titles: "'" + audio_title + "'",
					playerID: "'" + audio_id + "'",
					quality: 'high',
					lefticon: '0xFFFFFF',
					righticon: '0xFFFFFF',
					leftbg: '0x000000',
					rightbg: '0x000000',
					rightbghover: '0xCCCCCC',
					loader: '0x000000',
					wmode: 'transparent',
					transparentpagebg: 'yes',
					bg: 'transparent',
					pagebg: 'transparent'
				},
				height: 50,
				width: 448
			}
		);
	});
	
	
	/* add background sound */
	
	if (jQuery('.audioBackground').length > 0) {
		
		jQuery('.audioBackground').each(function() {
			var audio_file = jQuery(this).attr('href'); 
			var embed = jQuery('<embed src="'+audio_file+'" autostart="true" loop="true" hidden="true" height="0" width="0" class="audioBackgroundEmbed" />'); // netscape
			var bgsound = jQuery('<bgsound src="'+audio_file+'" loop="infinite" class="audioBackgroundBgsound" />'); // ie
			jQuery("body").append(embed);
			jQuery("head").append(bgsound);
			jQuery(this).remove();
		});
		
		/* add on/off option in navig dropdown */
		jQuery("#left select").append(jQuery('<option disabled="disabled">---</option>'));
		jQuery("#left select").append(jQuery("<option value='off'>"+TURNOFF_STR+"</option>"));
	}

});

