Type.registerNamespace("Common");

Common.SelectAccountEx = function () 
{
    this.ddAccounts = null;
    
    this.OnChangeCurrentAccountSucceeded = null;
}

Common.SelectAccountEx.prototype =
{
    ChangeCurrentAccount : function()
    {
        var arg = this.ddAccounts.options[this.ddAccounts.selectedIndex].value;
        var context = 'ChangeCurrentAccount';

        SelectAccountEx_CallServer(arg, context);
    },
    
    currentAccountIsSelected : function() {
        return (this.ddAccounts != null);
    }
}

Common.SelectAccountEx.registerClass('Common.SelectAccountEx');

// ==================================================================================================

var selectAccountEx = new Common.SelectAccountEx();

// ==================================================================================================

function SelectAccountEx_ReceiveServerData(data, context)
{
        var args = data.split(';');

        if (args.length > 0)
        {
            var callbackResult = args[0];
            
            if (callbackResult == 'SUCCESS')
            {
                if (selectAccountEx.OnChangeCurrentAccountSucceeded != null)
                {
                    selectAccountEx.OnChangeCurrentAccountSucceeded();
                }
            }
            else if (callbackResult == 'ERROR')
            {
                var errMsg = args[1];
                alert(errMsg);
            }
        }
}

// ==================================================================================================

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();