/* Debug functies */

// We gaan een debug object beginnen
window.Debug = {
    output : null, // Het debug vensters
    div : null,
    windiv : null,
    winoutput: null, 

    popup : function () {
        debugWindow = window.open('/index/debug', 'debugWindow', 'width=550px, height=450px, menubar=false');
        window.setTimeout(function() {
                Debug.windiv    = debugWindow.$('#debug');
                Debug.winoutput = debugWindow.$('#debugscreen');
                Debug.winoutput.html(Debug.output.html());
                Debug.hide();
                }, 1000);
    
    },

    initialize : function () {
        if (!this.output) {
            $('body').append("<div id='debug'>Debug scherm <a onclick='Debug.popup()'>(window)</a><div id='debugscreen'></div></div>");
            this.div    = $('#debug');
            this.output = $('#debugscreen');
        }
    },
    
    write : function (message, label) {
        if (!this.output) this.initialize();
        var dat = new Date;
        dat = dat.toLocaleTimeString();
        this.output.prepend("<fieldset><legend>" + dat + " - " + label + "</legend><pre>" + message + "</pre></fieldset>");
        //if (this.windiv) this.windiv.html(this.div.html());
        if (this.winoutput) this.winoutput.html(this.output.html());
    },

    hide : function () {
        this.div.fadeOut();
    },
    
    close : function () {
         $('#debug').remove();
         this.output = null;
    }
    

    

}

function showlog(){
    ajax_load("/demo_debug/showlog");
}
