﻿// SCOTT.CSC.LoginView

/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />

/// <reference path="jquery-1.2.6-vsdoc.js"/>

SCOTT.CSC.LoginView = function(clientId, loginId, memberStatusId, signOutUrl)
{
    this.ClientID = clientId;
    this.LoginID = loginId;
    this.MemberStatusID = memberStatusId;
    this.SignOutUrl = signOutUrl;
    this.Selector = '#' + clientId;
    this.Initialize();
};

SCOTT.CSC.LoginView.prototype =
{
    Name : 'SCOTT.CSC.LoginView',
    __typeName : 'SCOTT.CSC.LoginView',
    __class : true,
    ChangeLoginStatus : function(isAuthenticated)
    {
        var __app = this;
        
        var onSuccess = function(screenName)
        {
            var msSelector = '#' + __app.MemberStatusID;
            var lSelector = '#' + __app.LoginID;
            $(msSelector + ' a.ScreenName').text(screenName);
            $(msSelector + ' a.LoginStatus').text('Sign Out').attr('href', __app.SignOutUrl);
            $(lSelector).fadeOut(250, function()
            {
                $(msSelector).fadeIn();
            });
        };
    
        if (isAuthenticated)
        {
            this.UsersService.GetScreenName(onSuccess);
        }
    }
};

SCOTT.CSC.Extend(SCOTT.CSC.LoginView, SCOTT.CSC.UserControl);
