
function Kernel() {

    this.connected = false;
    this.widgets = [];        
    this.lastZ = 1000;
    this.currentZ = 1000;


    this.getUniqueId = function() {
        return this.widgets.length;
    }


    this.getWidget = function(id) {
        return this.widgets[id];
    }

    this.addWidget = function(widget) {
        this.widgets[widget.id] = widget;
    }
    
    
    this.freeWidget = function(id) {
        this.widgets[id] = null;
    }


    this.runWidget = function(className, parent, id, profile) {
        var code = 'var w = new ' + className + '();';
        eval(code);
        if(w) {
            profile = profile ? profile : false;
            id = id ? id : false;
            w.open(parent, id, profile);
            return w;
        }
    }
 
    this.timers = [];
    this.processTimer = function(widgetId, period, noAction) {
        if(kernel.widgets[widgetId]) {
            if(noAction != true) {
                kernel.getWidget(widgetId).timerHandler();
            }
            kernel.timers[widgetId] = setTimeout("kernel.processTimer("+widgetId+","+period+")", period);
        }
    }

    this.stopTimer = function(widgetId) {
        if(this.timers[widgetId] != undefined) {
            clearTimeout(this.timers[widgetId]);
            this.timers[widgetId] = undefined;
        }
    }

}





