
//
if (!tuijs) {
    var tuijs = {};
}

tuijs.utils = function(){

    /* Stops Firebug logging errors in IE
     * http://paulirish.com/2008/graceful-degredation-of-your-firebug-specific-code/
     ----------------------------------------*/
    if (!("console" in window) || !("firebug" in console)) {
        var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
        window.console = {};
        for (var i = 0; i < names.length; ++i) 
            window.console[names[i]] = function(){
            };
    }
    
    
    /*
     * Dumps the contents of a javascript object
     */
    var _MAX_DUMP_DEPTH = 10;
    var dumpObj = function(obj, name, indent, depth, $elm){
        var turnOff = false; //stop the dump function from working
        if (!turnOff) {
            if (depth > _MAX_DUMP_DEPTH) {
                return indent + name + ": <Maximum Depth Reached>\n";
            }
            if (typeof obj == "object") {
                var child = null;
                var output = indent + name + "\n";
                indent += "\t";
                for (var item in obj) {
                    try {
                        child = obj[item];
                    } 
                    catch (e) {
                        child = "<Unable to Evaluate>";
                    }
                    if (typeof child == "object") {
                        output += dumpObj(child, item, indent, depth + 1, $elm);
                    }
                    else {
                        output += indent + item + ": " + child + "\n";
                    }
                }
				if ($elm != undefined) {
					$elm.text(output);//this is a DOM element warpped in jQuery object for outputting content to page
				}
                return output;
            }
            else {
                return obj;
            }
        }
    }
    
    /*
     * returns public objects
     */
    return {
        objectDump: dumpObj
    }
}();






