(function() {
    try {
        app.beginUndoGroup("Select Audio Layers");
        var comp = app.project.activeItem;
        if (!comp || !(comp instanceof CompItem)) {
            alert("Please select a composition");
            return;
        }
        var comp = app.project.activeItem;
        var layers = comp.layers;
        var selLayers = comp.selectedLayers;

        for (var i = 1; i <= layers.length; i++) { // Deselect all the current layers
            comp.layers[i].selected = false;
        }

        if (selLayers.length >= 1) {
            for (var l = 0; l < selLayers.length; l++) {
                
                // Select Layers
                for (var i = 1; i <= layers.length; i++) {
                    if (layers[i].parent !== null) {
                        
                        if (layers[i].parent.index == selLayers[l].index)  comp.layers[i].selected = true;
                    }
                }
            }
        }


    } catch (err) {
        alert(err);
    } finally {
        app.endUndoGroup();
    }
})();