﻿/// <reference path="../External/jquery-1.3.2-vsdoc.js" />

if (typeof (window.Agility) == "undefined") {
    window.Agility = {};
}

(function(Agility, $) {
    Agility.RegisterNamespace = function(space) {
        /// <summary>
        /// Register a javascript namespace.
        /// </summary>
        /// <param name="space" type="String">The namespace (dot-separated) to register.</param>
        /// <returns type="object">Object representing the created namespace.</returns>

        var spaces = space.split("."),
            root = window;

        for (var i = 0; i < spaces.length; i++) {
            if (typeof (root[spaces[i]]) == "undefined") {
                root = root[spaces[i]] = {};
            } else {
                root = root[spaces[i]];
            }
        }

        return root;
    }

    Agility.ResolveUrl = function(url) {
        /// <summary>
        /// Resolve "~/" to the application's base url. *Requires that global var "Edentity_BaseUrl" has been set.
        /// </summary>
        /// <param name="url" type="String">The URL whose path to resolve.</param>
        /// <returns type="string">String representing the resolved URL.</returns>

        var baseUrl = window.Agility_BaseUrl || "/";
        return url.replace(/^~\//, baseUrl);
    }
	

})(Agility, jQuery);




