

var Debugger =
{
    window : null,
    enabled: true,
    
    
    init : function()
        {
            if (!Debugger.enabled)
                return;
                
            this.window = window.open('', 'MT2DBG', 'width=800,height=600');
            var body = this.window.document.createElement('body');
            this.window.document.appendChild(body);
        },
        
    write : function(iStr)
        {
            if (!Debugger.enabled)
                return;
                        
            if (!this.window || this.window.closed)
                this.init();
                
            var win = window.open('', 'MT2DBG');
            win.document.body.innerHTML = iStr.replace('\n', '<br/>\n') + '<br/>' + this.window.document.body.innerHTML;
        },

    clear : function()
        {
            if (!Debugger.enabled)
                return;        
        
            if (!this.window || this.window.closed)
                this.init();
                
            var win = window.open('', 'MT2DBG');
            win.document.body.innerHTML = '';        
        }
        
};
