/* Copyright (c) 2006 ATUM! Inc. All rights reserved. */

/**
 * @class The ATUM global namespace
 */
var ATUM = function() {

    return {

        /**
         * ATUM presentation platform UI namespace
         */
        UI: {},

        /**
         * ATUM presentation platform Utility namespace
         */
        Utility: {},

        /**
         * ATUM presentation platform examples namespace
         */
        example: {},

        /**
         * Returns the namespace specified and creates it if it doesn't exist
         *
         * ATUM.namespace("property.package");
         * ATUM.namespace("ATUM.property.package");
         *
         * Either of the above would create ATUM.property, then
         * ATUM.property.package
         *
         * @param  {String} sNameSpace String representation of the desired 
         *                             namespace
         * @return {Object}            A reference to the namespace object
         */
        namespace: function( sNameSpace ) {

            if (!sNameSpace || !sNameSpace.length) {
                return null;
            }

            var levels = sNameSpace.split(".");

            var currentNS = ATUM;

            // ATUM is implied, so it is ignored if it is included
            for (var i=(levels[0] == "ATUM") ? 1 : 0; i<levels.length; ++i) {
                currentNS[levels[i]] = currentNS[levels[i]] || {};
                currentNS = currentNS[levels[i]];
            }

            return currentNS;

        }
    };

} ();


