/*
 * Copyright (c) 2007, Harley Davidson Inc. All rights reserved.
 * NOTE: This file borrows elements from YUI's namespace declaring javascript.
 */

/**
 * The HD object is the single global object used by HD Library.  It
 * contains utility function for setting up namespaces & inheritance.
 * 
 * @module hd.js
 * @title  HD
 */
var HD = {};


/**
 * Initializes the HD singleton.
 * @method init
 * @static
 */
HD.init = function() {
	// do nothing
};


/**
 * Registers a module with the HD object
 * @method register
 * @static
 * @param {String} n  the name of the module (event, slider, etc)
 * @param {String} v  the version number of the module being registered
 */
HD.register = function(n,v) {
    var mods = HD.env.modules;
	v = v || "1.0";
	// cache the modules loaded
    mods[n] = {name : n , version : v};
	
    // fire the module load listeners
	var ls = HD.env.listeners;
    for (var i=0;i<ls.length;i=i+1) {
        ls[i](m);
    }
};


/**
 * HD.env is used to keep track of what is known about the HD library.
 * @class HD.env
 * @type Object
 * @static
 */
HD.env = HD.env || {
    /**
     * Keeps track of HD modules that have reported themselves
     * @property modules
     * @type Object[]
     */
    modules: [],
    
    /**
     * List of functions that should be executed every time a YUI module
     * reports itself.
     * @property listeners
     * @type Function[]
     */
    listeners: []

};


// init and register
HD.init();
HD.register("HD","1.0");




/**
 * HD.util is the namespace used for all common Harley Davidson utility functions.
 * @class HD.util
 * @type Object
 * @static
 */
if (typeof HD.util == "undefined") {
    HD.util = {};
	// registers the user object with HD
	HD.register("util", "1.0");
}

/**
 * HD.ui is the namespace used for all common Harley Davidson user interface objects
 * @class HD.ui
 * @type Object
 * @static
 */
if (typeof HD.ui == "undefined") {
    HD.ui = {};
	// registers the user object with HD
	HD.register("ui", "1.0");
}

/**
 * HD.constants is the namespace used for all common Harley Davidson constants
 * @class HD.ui
 * @type Object
 * @static
 */
if (typeof HD.constants == "undefined") {
    HD.constants = {};
	// registers the user object with HD
	HD.register("constants", "1.0");
}

// General Constants
HD.constants.CONTEXT_PATH = CONTEXT_PATH;
HD.constants.MEDIA_PATH = MEDIA_PATH;
HD.constants.DEFAULT_LOCALE = DEFAULT_LOCALE;
HD.constants.LOCALE = LOCALE;

