if (top.sound.soundLib && typeof soundLib == 'undefined') soundLib = top.sound.soundLib;
else {
    function SoundLib()
    {
      this.playStack = [];
      this.onplayfinish = null;

      return this;
    }

    SoundLib.prototype = {
      play: function(src, volume)
      {
        if (typeof(volume) != 'undefined')
          this.setVolume(volume);
        if (typeof src == 'string') this.playStack = [src];
        else this.playStack = src;
            
        this.playNext();
      },
      
      playNext: function()
      {
        if (this.playStack && this.playStack.length > 0)
            this.sndElement.src = this.playStack.shift();
        
        if (typeof this.onplayfinish == 'function')
            try {
              this.onplayfinish(this.sndElement.src);
            } catch (e) {
              this.onplayfinish = null;
            };
      },
      
      playThemeWord: function(theme, word, volume)
      {
        var w = (typeof word == 'string') ? [word] : word;
        for (var i = 0; i < w.length; i++) w[i] = '/code/content/_audio/' + w[i] + '.mp3';
        
        this.play(w, volume);
      },

      setVolume: function(val)
      {
        this.sndElement.volume = val;
      }
    };

    var soundLib = new SoundLib();
    
    window.onload = function() {
      soundLib.sndElement = snd;
    };
};
