
function Kernel() {
this.imgCache={};
for(icon in theme.icons)
{
	eval("this.imgCache."+icon+"=new Image();");
	eval("this.imgCache."+icon+".src=theme.icons."+icon+";");

}
//varpw(imgCache);
//alert(imgCache[3].src);
    this.connected = false;
    this.widgets = [];        
    this.dragging=false;
    this.trasp_drag = false;
    this.wborder_color = "#6060FF";

    this.currentWid = 0;

    this.getUniqueId = function() {
        while(this.widgets[this.currentWid]) this.currentWid++;
        return this.currentWid;
//        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 || false;
            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;
        }
    }

}
