(function ($) {

    var methods = {
        ajaxifyLinks: function (callback) {
            this.each(function () {
                var control = $(this);
                var links = control.find("a");

                $.each(links, function (i, link) {
                    link.onclick = callback;
                });
            });

            return false;
        },

        updateContent: function (partialControlContainerType, params, callback) {
            var settings = { IsAjaxRequest: true, PartialControlContainerType: partialControlContainerType };

            if (params) {
                $.extend(settings, params);
            }

            this.each(function () {
                var control = $(this);

                $.post(window.location.url, settings, function (result) {
                    if (callback) callback(control);
                    control.html('');
                    control.html(result);
                });
            });

            return false;
        },

        postData: function (partialControlContainerType, params, callback) {
            var settings = { IsAjaxRequest: true, PartialControlContainerType: partialControlContainerType };

            if (params) {
                $.extend(settings, params);
            }

            $.post(window.location.url, settings, function (result) {
                if (callback) callback(control);
            });

            return false;
        }
    };

    $.fn.pulseUI = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist in jQuery.pulseUI.');
        }
    }

})(jQuery);
