﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("SEC");

SEC.LoginForgotSwitcher = function() {
    this._loginForm = null;
    this._forgotForm = null;
    
    this._showLoginFormButton = null;
    this._showForgotFormButton = null;

    this._loginFormShowHandler = null;
    this._forgotFormShowHandler = null;

    SEC.LoginForgotSwitcher.initializeBase(this);
}

SEC.LoginForgotSwitcher.prototype = {
    /* Propertiies begin */
    get_LoginForm: function() {
        return this._loginForm;
    },
    set_LoginForm: function(value) {
        this._loginForm = value;
    },
    get_ForgotForm: function() {
        return this._forgotForm;
    },
    set_ForgotForm: function(value) {
        this._forgotForm = value;
    },
    get_ShowLoginFormButton: function() {
        return this._showLoginFormButton;
    },
    set_ShowLoginFormButton: function(value) {
        this._showLoginFormButton = value;
    },
    get_ShowForgotFormButton: function() {
        return this._showForgotFormButton;
    },
    set_ShowForgotFormButton: function(value) {
        this._showForgotFormButton = value;
    },
    /* Properties end */

    /* Utils begin */
    ShowLogin: function() {
        Sys.UI.DomElement.setVisible(this._loginForm, true);
        Sys.UI.DomElement.setVisible(this._forgotForm, false);
    },
    ShowForgot: function() {
        
        Sys.UI.DomElement.setVisible(this._loginForm, false);
        Sys.UI.DomElement.setVisible(this._forgotForm, true);
    },
    /* Utils end */

    /* Event Handlers begin */
    _onLoginFormShow: function(e) {
        this.ShowLogin();
        e.preventDefault();
    },
    _onForgotPasswordShow: function(e) {
        this.ShowForgot();
        e.preventDefault();
    },
    /* Event Handlers end */

    initialize: function() {
        SEC.LoginForgotSwitcher.callBaseMethod(this, 'initialize');
        this._loginFormShowHandler = Function.createDelegate(this, this._onLoginFormShow);
        this._forgotFormShowHandler = Function.createDelegate(this, this._onForgotPasswordShow);
        
        Sys.Debug.trace(this.get_ShowForgotFormButton());
        $addHandlers(this.get_ShowLoginFormButton(), { click: this._loginFormShowHandler });
        $addHandlers(this.get_ShowForgotFormButton(), { click: this._forgotFormShowHandler });
    },
    dispose: function() {
        delete this._loginFormShowHandler;
        delete this._forgotFormShowHandler;


        SEC.LoginForgotSwitcher.callBaseMethod(this, 'dispose');
    }
}
SEC.LoginForgotSwitcher.registerClass('SEC.LoginForgotSwitcher', Sys.Component);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

