﻿
$.fn.exists = function () { return $(this).length !== 0; }

$(document).ready(function () {
    creatNamespace();
    $.apr.userInfo = {
        callback: {
            failed: function (result, userContext, methodName) {

                switch (methodName) {
                    default:
                        $.apr.error.callback.failed(result, userContext, methodName);
                        break;
                }
            },
            succeeded: function (result, dialog, methodName) {
                switch (methodName) {
                    case "GetCurrentUserInfo":
                        $.apr.userInfo.current = result;
                        $.apr.userInfo.trigger("userInfoChange", result);
                        break;
                    default:
                        alert(methodName + " succeeded, but wasn't handled.");
                        break;
                }
            }
        },
        current: null,
        getCurrentUserInfo: function () {
            $.apr.proxy.userService.GetCurrentUserInfo($.apr.userInfo.callback.succeeded, $.apr.userInfo.callback.failed, null);
        },
        init: function () { 
            // Get the current user info
            this.getCurrentUserInfo();
        }
    };
    $.apr.app.trigger("scriptReady", $.apr.userInfo);

});


