/**
A class containing custom extensions methods to the jQuery framework.
@class $
@namespace ProspectDirector
*/
(function ($) {

    /**
    Creates a namespace.
    @method namespace
    */
    $.namespace = function (fqn) {

        var root = window,
            names = fqn.split("."),
            i = 0;

        for (i = 0; i < names.length; i++) {

            if (root[names[i]] === undefined) {
                root[names[i]] = {};
            }

            root = root[names[i]];

        }

        return root;

    },

    /**
    Disables a HTML element.
    @method disable
    */
    $.fn.disable = function () {
        return $(this).each(function () {
            $(this).attr('disabled', 'disabled');
        });
    };

    /**
    Enables a HTML element.
    @method enable
    */
    $.fn.enable = function (not) {

        return $(this).each(function () {
            $(this).removeAttr('disabled');
        });

    };

    /**
    Enables or Disables a HTML element.
    @method enable
    */
    $.fn.enabled = function (not) {

        if (not !== undefined && not === false) {

            return $(this).each(function () {
                $(this).attr('disabled', 'disabled');
            });

        }
        else {

            return $(this).each(function () {
                $(this).removeAttr('disabled');
            });

        }

    };

    /**
    Prevents selections of HTML elements.
    @method disableSelection
    */
    $.fn.disableTextSelection = function () {
        return this
            .attr('unselectable', 'on')
            .css({
                userSelect: 'none',
                cursor: "default"
            })
            .on('selectstart', function (e) { return false; });
    };

    /**
    Enables selections of HTML elements.
    @method enableSelection
    */
        $.fn.enableTextSelection = function () {
        return this
            .removeAttr('unselectable', 'on')
            .css({
                userSelect: "",
                cursor: "default"
            })
            .on('selectstart', function (e) { e.stopPropagation(); return true; });
    };

    $.fn.reverse = [].reverse;

})(jQuery);

/* Extend built-in prototypes */

String.format = function () {
    var s = arguments[0];
    for (var i = 0; i < arguments.length - 1; i++) {
        var reg = new RegExp("\\{" + i + "\\}", "gm");
        s = s.replace(reg, arguments[i + 1]);
    }
    return s;
};

Array.prototype.peek = function (index) {

    if (this.length > index) {
        return this[index];
    }
    else {
        return undefined;
    }

};

window.isNullOrUndefined = function (item) {
    return item === undefined || item === null;
};

/* Prospect Director Types Namespace */

$.namespace("ProspectDirector");
$.namespace("ProspectDirector.Modules");
$.namespace("ProspectDirector.Modules.Common");
$.namespace("ProspectDirector.Modules.Core");
$.namespace("ProspectDirector.Modules.Documents");
$.namespace("ProspectDirector.Modules.EntityTypes");
$.namespace("ProspectDirector.Modules.Explorer");
$.namespace("ProspectDirector.Modules.Explorer.Contents");
$.namespace("ProspectDirector.Modules.Explorer.Entity");
$.namespace("ProspectDirector.Modules.Explorer.Forms");
$.namespace("ProspectDirector.Modules.Explorer.FormFields");
$.namespace("ProspectDirector.Modules.ExplorerModel");
$.namespace("ProspectDirector.Modules.ExplorerModel.Folders");
$.namespace("ProspectDirector.Modules.ExplorerModel.Forms");
$.namespace("ProspectDirector.Modules.ExplorerModel.FormElements");
$.namespace("ProspectDirector.Modules.Extensions");
$.namespace("ProspectDirector.Modules.Extensions.ExtensionColumns");
$.namespace("ProspectDirector.Modules.Extensions.SelectionLists");
$.namespace("ProspectDirector.Modules.Framework");
$.namespace("ProspectDirector.Modules.Repositories.File");
$.namespace("ProspectDirector.Modules.Personalization");
$.namespace("ProspectDirector.Modules.Processes");
$.namespace("ProspectDirector.Modules.Processes.ProcessNodes");
$.namespace("ProspectDirector.Modules.Extensions.SelectionListItems");
$.namespace("ProspectDirector.Modules.Reports");
$.namespace("ProspectDirector.Modules.Security");
$.namespace("ProspectDirector.Modules.Sys.AppSettings");
$.namespace("ProspectDirector.Modules.Views"); 
$.namespace("ProspectDirector.Modules.Extensions");
$.namespace("ProspectDirector.Types");
$.namespace("ProspectDirector.Types.Core");
$.namespace("ProspectDirector.Types.KendoExtensions");
$.namespace("ProspectDirector.Types.View");
$.namespace("ProspectDirector.Util");


$.extend(Tipped.Skins, {
    'locations': {
        border: { size: 1, color: '#AAAAAA' },
        background: '#FFFFFF',
        radius: { size: 0, position: 'border' },
        shadow: false,
        closeButtonSkin: 'light'
    }
});