/****************************************************************
    Dynamic Web Interface - DWI
    Global namespace object
    clone for YAHOO - yui framework

    by Florin Vasilache (florin.vasilache@work.ro)
    on 7 Feb 2007
****************************************************************/


if (typeof DWI == "undefined") {
    /**
     * The DWI global namespace object
     * @class DWI
     * @static
     */
    var DWI = {};
}



/**
 * From YUI specs:
 * Returns the namespace specified and creates it if it doesn't exist
 * <pre>
 * DWI.namespace("property.package");
 * DWI.namespace("DWI.property.package");
 * </pre>
 * Either of the above would create DWI.property, then DWI.property.package
 *
 * Be careful when naming packages. Reserved words may work in some browsers
 * and not others. For instance, the following will fail in Safari:
 * <pre>
 * DWI.namespace("really.long.nested.namespace");
 * </pre>
 * This fails because "long" is a future reserved word in ECMAScript
 *
 * @method namespace
 * @static
 * @param  {String*} arguments 1-n namespaces to create
 * @return {Object}  A reference to the last namespace object created
 */
DWI.namespace = function() {
    var a = arguments, o = null, i, j, d;
    for (i = 0; i < a.length; ++i) {
        d = a[i].split(".");
        o = DWI;

        // DWI is implied, so it is ignored if it is included
        for (j=(d[0] == "DWI") ? 1 : 0; j<d.length; ++j) {
            o[d[j]] = o[d[j]] || {};
            o = o[d[j]];
        }
    }

    return o;
};



                  

