(function($){

    //Ordered list of permissions available.
    var permissions = [
        {permission: 'SYS_ADMIN', name: "Sysadmin", i18nName: "System Administrator"},
        {permission: 'ADMIN', name: "Admin", i18nName: "Admin"}
    ];
    var container, spinner;

    function init(){
        container = $('#group-data');
        spinner = $('#data-loading');
        loading(false);
        drawTable();
        populateTable();
    }

    function drawTable() {
        var table = $(crowd.permissionTable({
            permissionDataList: permissions,
            grantablePermissionDataList: permissions,
            noResultsText: "No groups have been given explicit permissions to this project."
        }));
        container.append(table);
    }

    function populateTable() {
        var table = new Crowd.PermissionTable('#group-permissions-table', permissions, 'Sysadmin');

    }

    function loading(isLoading) {
        spinner.toggleClass('hidden', !isLoading);
    }

    $(init);
})(AJS.$);
