/* Requires flash.js detector */


// ----------------------------------------------------------------------------
// AudioPlayer Class

var AudioPlayer = {
  players: [],
  
  check: function () {
    if (Flash.hasVersion(8)) {
      return true;
    }
    else {
      return false;
    }
  },
  
  init: function (p_name, p_mp3, p_type) {
    this.players.push(p_name);
    
    switch (p_type) {
      case 'rail':
        filename = 'http://media.ljworld.com/flash/audio_players/rail_audioplayer.swf';
        width = '210';
        height = '50';
        break;
      case 'inline':
        filename = 'http://media.ljworld.com/flash/audio_players/inline_audioplayer.swf';
        width = '180';
        height = '50';
        break;
      default:
        filename = 'http://media.ljworld.com/flash/audio_players/audioplayer.swf';
        width = '450';
        height = '60';
        break;
    }

    tag = new FlashTag(8, filename, width, height, p_name);
    tag.addProperty('scale', 'noscale');
  	tag.addProperty('wmode', 'transparent');
  	tag.addProperty('allowScriptAccess', 'always');
  	tag.addVariable('mp3', p_mp3);
  	tag.writeHTML();
  },
  
  play: function (p_player, p_anchor) {
    this.pauseAll();
    document[p_player].load_audio(p_anchor.href, p_anchor.id)
  },
  
  pauseAll: function () {
    for (i=0; i<this.players.length; i++) {
      document[this.players[i]].pause_audio();
    }
  }
}


// ----------------------------------------------------------------------------
// Highlight function - Called from within the SWF to highlight current track.

function highlight (p_item) {
  item = document.getElementById(p_item);
  items = item.parentNode.parentNode.getElementsByTagName('a');
  for (i=0; i<items.length; i++) {
    Dom.removeClass(items[i], 'active');
  }
  Dom.addClass(item, 'active');
}