/*
[for shopelvis.it]
version 0.9.0
*/

/**
 * @class - global namespace
 */
var KINGMO = function() {

    return {

        /**
         * KMenu presentation platform utils namespace
         */
        util: {},

        /**
         * KMenu presentation platform widgets namespace
         */
        widget: {},

        /**
         * KMenu presentation platform examples namespace
         */
        example: {},

        /**
         * Returns the namespace specified and creates it if it doesn't exist
         *
         * KINGMO.namespace("property.package");
         * KINGMO.namespace("KINGMO.property.package");
         *
         * Either of the above would create KINGMO.property, then
         * KINGMO.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 = KINGMO;

            // KINGMO is implied, so it is ignored if it is included
            for (var i=(levels[0] == "KINGMO") ? 1 : 0; i<levels.length; ++i) {
                currentNS[levels[i]] = currentNS[levels[i]] || {};
                currentNS = currentNS[levels[i]];
            }

            return currentNS;

        }
    };

} ();

