NCore = {
    lastId: 1,
    pmgr: null,
    pmgrCallbacks: [],
    panelManagerReady: function(pmgr) {
        this.pmgrCallbacks.each(function(callback) {
            callback(pmgr);
        });
        this.pmgr = pmgr;
    },
    
    onPMGR: function(f) {
        if (this.pmgr) {
            f(this.pmgr);
        } else {
            NCore.pmgrCallbacks.push(f);
        }
    },
    
    loc: function(url) {
        return context.currentUrl + url;
    },

    generateId: function(startAt) {
        var nextId  = startAt || $N.lastId;
        var tryThis = 'ncore-id-' + nextId;
        while ($(tryThis)) {
            nextId += 1;
            tryThis = 'ncore-id-' + nextId;
        }
        $N.lastId += 1;
        return tryThis;
    }

};

$N = NCore;

