jQuery(function(){

// Add an mp3 player
jQuery('a').each(function(){
  
  // Selection:
  if ( this.href.substr(-4).toLowerCase().indexOf('.mp3') < 0 ) return;

  // Definitions:
  var $this = jQuery(this);
  var flash_container_id;
  var flash_container;
  var player_swf;
  var flash_vars = {};
  var flash_param = { wmode: 'transparent' };
  var attributes = {};
  var width = 0;
  var height = 0;
  
  // create a new object
  // find a unique object name
  do {
    flash_container_id = 'flash_container_' + Math.round( Math.random() * 10000 );
  } while( jQuery('#' + flash_container_id).length > 0 );
  
  // generate an object code
  flash_container = '<span id="' + flash_container_id + '"></span>';
  
  // decide which player
  if( $this.text() != $this.parent().text() && $this.find('img').length == 0 ) {
    // the link is an inline element in a floating text
    
    // position
        $this.replaceWith(flash_container);
        
    // Build a flash app
    player_swf = 'http://headphonespresident.com/wp-content/plugins/audio-link-player/xspf/player.swf'; 
    flash_vars.song_url = encodeURIComponent(this.href);
    flash_vars.b_bgcolor = 'BA600';
    flash_vars.b_fgcolor = 'C0000';
    flash_vars.b_colors = 'F0000,F0000,FB00C,9A801';
    flash_vars.autoplay = false;
    
    // in the xspf player these values are not variable
    width = 17;
    height = 17;
    
    // Add the player
    swfobject.embedSWF(player_swf, flash_container_id, width, height, "9.0.0", null, flash_vars, flash_param, attributes);    
  }
  

    

  
}); // End of Each loop 
}); // End of DOM Ready Sequence
/* End of File */
