﻿//<using>
//  nui/nui.js
//  nui/prototype.js
//  nui/util.js
//</using>

/**
 * NUI.Debug.
 * Used by developers, show the debug message
 * Copyright 2007, NetRanking.cn
 *
 * @namespace NUI.Debug
 */
NUI.Debug = (function() {
    var m_dom = NUI.Util.DomService;
    
    var m_debugOn = true,
        msgBox = null;
        
    function _showException(vException) {
        if(msgBox == null) {
            msgBox = m_dom.createNode("div", {
                style : {
                    position : "absolute",
                    top : "0",
                    left : "0",
                    background : "#fff",
                    fontSize : "12px",
                    width : "300px",
                    height : "100px",
                    overflow : "auto",
                    color : "#f00"
                }
            });
            m_dom.appendNode(document.body, msgBox);
        }
        m_dom.setInnerHTML(msgBox, msgBox.innerHTML + vException + "\r\n");
    }
    
    var that = {
        setDebugOn : function() {
            m_debugOn = true;
        },
        
        setDebugOff : function() {
            m_debugOn = false;
        },
        
        showException : function(vException) {
            if(m_debugOn) {
                _showException(vException);
            }
        }
    };
    return that;
})();
