﻿/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="MicrosoftAjaxTimer.debug.js" />
/// <reference name="MicrosoftAjaxWebForms.debug.js" />

/// <reference path="jquery.intellisense.js"/>

/// <reference path="Kleenex.Core.js"/>

Kleenex.HeaderMemberLinks = function(clientId, signOutUrl, myAccountUrl)
{
    this.ClientID = clientId;
    this.Selector = "#" + clientId;
    this.SignOutUrl = signOutUrl;
    this.MyAccountUrl = myAccountUrl;
    this.Initialize();
};
Kleenex.HeaderMemberLinks.prototype =
{
    Name : 'Kleenex.HeaderMemberLinks',
    __typeName : 'Kleenex.HeaderMemberLinks',
    __class : true,
    AttachEvents : function()
    {
        var __app = this;
        var context = $(this.Selector);
        
    },
    Display : function()
    {
        var __app = this;
    },
    ChangeLoginStatus : function(isAuthenticated)
    {
        var __app = this;
        
        if (isAuthenticated)
        {
            var context = $(this.Selector);
            $('a.SignIn', context).text('Log Out').attr('onclick', '').attr('href', __app.SignOutUrl).unbind('click');
    
            $('a.Register', context).text('Mein Account').attr('onclick', '').attr('href', __app.MyAccountUrl).unbind('click');
            
            var onSuccess = function(screenName)
            {
                $('span.ScreenName', context).text('Willkommen, ' + screenName + '!');
            };
            
            this.MemberService.GetScreenName(onSuccess);
            
        }
    }
};

Kleenex.Extend(Kleenex.HeaderMemberLinks, Kleenex.UserControl);

