/**
 * The Bearcode global namespace
 * @constructor
 */
var BC = window.BC || {};
if(typeof(window.YAHOO) != 'undefined') YAHOO.bearcode = BC;
/**
 * Returns the namespace specified and creates it if it doesn't exist
 *
 * BC.namespace("property.package");
 * BC.namespace("BC.property.package");
 *
 * Either of the above would create BC.property, then
 * BC.property.package
 *
 * @param  {String} ns The name of the namespace
 * @return {Object}    A reference to the namespace object
 */
BC.namespace = function(ns) {

    if (!ns || !ns.length) {
        return null;
    }

    var levels = ns.split(".");
    var nsobj = BC;

    // YAHOO is implied, so it is ignored if it is included
    for (var i=(levels[0] == "BC") ? 1 : 0; i<levels.length; ++i) {
        nsobj[levels[i]] = nsobj[levels[i]] || {};
        nsobj = nsobj[levels[i]];
    }

    return nsobj;
};
