if (typeof fitbit == "undefined") {
	var fitbit = {};
}

/**
 * Returns the namespace specified and creates it if it doesn't exist
 * <pre>
 * fitbit.namespace("property.package");
 * fitbit.namespace("fitbit.property.package");
 * </pre>
 * Either of the above would create YAHOO.property, then
 * fitbit.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>
 * fitbit.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
 */
fitbit.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=fitbit;

        // fitbit is implied, so it is ignored if it is included
        for (j=(d[0] == "fitbit") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};
