/**
 * PTV namespace.  To avoid cluttering the window namespace, all functions
 * and constants should be defined within a member of the PTV namespace
 * which can be created using the PTV.namespace function.
 *
 * Note: This object implements the yahoo module pattern.  See:
 * http://yuiblog.com/blog/2007/06/12/module-pattern/ for details.
 */
if (!window.PTV) {
  var PTV = function() {
    return {
      /**
       * Creates additional namespaces within the PTV namespace,
       * returning existing namespaces rather than overwriting them.
       *
       * For example PTV.namespace("ajax.get") creates PTV.ajax.get
       * Repeating the call returns the object that was created initially
       * so namespaces can be added without fear of overwriting any existing
       * objects.
       *
       * Note that PTV.namespace("foo") produces the same result as
       * PTV.namespace("PTV.foo")
       *
       * @param {String} name Namespace to create (e.g. "ajax.get").
       */
      namespace: function(name) {
        var space = PTV;
        var args = name.split(".");
        for (var ii = (args[0] == "PTV" ? 1 : 0); ii < args.length; ++ii) {
          space = space[args[ii]] = space[args[ii]] || {};
        }
        return space;
      }
    };
  }();
}
