function getLayer(index) {

        // Get layer, create if necessary
        var layer = layers[index];
        if (!layer) {

            // Create layer based on index
            if (index === 0)
                layer = display.getDefaultLayer();
            else if (index > 0)
                layer = display.createLayer();
            else
                layer = display.createBuffer();
                
            // Add new layer
            layers[index] = layer;

        }

        return layer;

    }
Returns the layer with the given index, creating it if necessary.
Positive indices refer to visible layers, an index of zero refers to
the default layer, and negative indices refer to buffers.

@param {Number} index The index of the layer to retrieve.
@return {Guacamole.Display.VisibleLayer|Guacamole.Layer} The layer having the given index.