getLayerIndex = function getLayerIndex(layer) {

        // Avoid searching if there clearly is no such layer
        if (!layer)
            return null;

        // Search through each layer, returning the index of the given layer
        // once found
        for (var key in layers) {
            if (layer === layers[key])
                return parseInt(key);
        }

        // Otherwise, no such index
        return null;

    }
Returns the index passed to getLayer() when the given layer was created.
Positive indices refer to visible layers, an index of zero refers to the
default layer, and negative indices refer to buffers.

@param {Guacamole.Display.VisibleLayer|Guacamole.Layer} layer
    The layer whose index should be determined.

@returns {Number}
    The index of the given layer, or null if no such layer is associated
    with this client.