var DEBUGKUBBE = new DebugClass();

function DebugClass() {    
    this.visible = false;    
    this.debugPanel = document.createElement("div");   
    this.dataPanel = null;
    this.actives = new Object();
    this.style = "font-size:10px;text-align:left;background-color:#FFF;border:1px solid #000;position:absolute;top:0px;right:0px;width:300px;height:350px;overflow:auto";
    this.setActive = function(name, state) {        
        this.actives[name]=state;
    }
    
    this.viewDebug = function (style) {
        if (typeof style=="undefined") style=this.style;
        $(this.debugPanel).empty()
                          .append("<div><a href='#'>Clear</a></div><div style='"+style+"' id='data'></data>")
                
        $(document.body).append(this.debugPanel); 
        this.dataPanel = $("div[@id=data]", this.debugPanel).get(0);
        
        $("a", this.debugPanel).click(function() {
            this.component.clear();
        }).get(0).component = this;
        this.visible = true;
    } 
    
    this.clear = function() {
        $(this.dataPanel).empty();
    }
    
    this.hideDebug = function() {
        this.visible = false;
        $(this.debugPanel).empty().remove();
    }
            
    this.println = function(name, mensaje) {
        if (this.visible && this.actives[name]) $(this.dataPanel).append("<b>["+name+"]</b>"+mensaje+"<br style='border: 1px solid #000'/>");
    }
    
    this.initTime = function() {
        this.time = new Date();        
    }
    
    this.printTime = function(msj) {
        if (this.visible) {
            var time = new Date();
            $(this.dataPanel).append("<b>Time["+msj+"]:</b> "+((time.getTime()-this.time.getTime())/1000)+" sg.");
        }
    }
}