/**
 * The SIDJA global namespace
 * @constructor
 */
var SIDJA = window.SIDJA || {};

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

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

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

    var currentNS = SIDJA;

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

    return currentNS;
};

/**
 * Global log method.
 */
SIDJA.log = function(sMsg,sCategory) {
    if(SIDJA.widget.Logger) {
        SIDJA.widget.Logger.log(null, sMsg, sCategory);
    } else {
        return false;
    }
};

SIDJA.namespace("util");
SIDJA.namespace("widget");
SIDJA.namespace("example");
