
if (typeof DIGITREE == "undefined")
{

    var DIGITREE = {};
}


DIGITREE.namespace = function()
{
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; ++i)
    {
        d=a[i].split(".");
        o=DIGITREE;

        for (j=(d[0] == "DIGITREE") ? 1 : 0; j<d.length; ++j)
        {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }
    return o;
};


DIGITREE.log = function(msg, cat, src) {
    var l=YAHOO.widget.Logger;
    if (l && l.log)
    {
        return l.log(msg, cat, src);
    }
    else if (typeof console == "object" && typeof console.log == "function")
    {
        if (cat && typeof console[cat] == "function")
            console[cat](msg);
        else
            console.log(msg);
    }
    else if (typeof window.console == "function" && typeof window.console.log == "function")
    {
        window.console.log(msg);
    }
    else if (typeof opera == "object" && typeof opera.postError == "function")
    {
        opera.postError(msg);
    }
};


DIGITREE.register = function(name, mainClass, data) {
    var mods = DIGITREE.env.modules;
    if (!mods[name]) {
        mods[name] = { versions:[], builds:[] };
    }
    var m=mods[name],v=data.version,b=data.build,ls=DIGITREE.env.listeners;
    m.name = name;
    m.version = v;
    m.build = b;
    m.versions.push(v);
    m.builds.push(b);
    m.mainClass = mainClass;
    // fire the module load listeners
    for (var i=0;i<ls.length;i=i+1) {
        ls[i](m);
    }
    // label the main class
    if (mainClass) {
        mainClass.VERSION = v;
        mainClass.BUILD = b;
    } else {
        DIGITREE.log("mainClass is undefined for module " + name, "warn");
    }
};



DIGITREE.env = DIGITREE.env || {


    modules: [],


    listeners: []
};


DIGITREE.env.getVersion = function(name) {
    return DIGITREE.env.modules[name] || null;
};

DIGITREE.namespace("util", "user");

DIGITREE.util.Browser = function()
{
    // Partly from ExtJS lib
    var ua = navigator.userAgent.toLowerCase();
    var isStrict = document.compatMode == "CSS1Compat";
    var isOpera = ua.indexOf("opera") > -1;
    var isSafari = /webkit|khtml/.test(ua);
    var isIE = ua.indexOf("msie") > -1;
    var isIE7 = ua.indexOf("msie 7") > -1;
    var isGecko = !isSafari && ua.indexOf("gecko") > -1;
    var isBorderBox = isIE && !isStrict;
    var isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1);
    var isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1);
    var isLinux = /x11|linux|freebsd|netbsd/.test(ua);

    return {
        isStrict: isStrict
        ,isOpera: isOpera
        ,isSafari: isSafari
        ,isIE: isIE
        ,isIE7: isIE7
        ,isGecko: isGecko
        ,isBorderBox: isBorderBox
        ,isWindows: isWindows
        ,isMac: isMac
        ,isLinux: isLinux
    };
}();

DIGITREE.register("digitree", DIGITREE, {version: "1.0.0", build: "1"});
