
Type.registerNamespace("Awc.WestOnline.Rules.UI.Accounts");

Awc.WestOnline.Rules.UI.Accounts.OneOffSale = function () {
    Awc.WestOnline.Rules.UI.Accounts.OneOffSale.initializeBase(this);

    this._submitButton;
    this._validateScript;
    this._errorPanelControl;
    this._hearChoices;
}

Awc.WestOnline.Rules.UI.Accounts.OneOffSale.prototype = {
    initialize : function() 
    {
        Awc.WestOnline.Rules.UI.Accounts.OneOffSale.callBaseMethod(this, 'initialize');
        this._onSubmitHandler = Function.createDelegate(this, this.Validate);
        $addHandler(this._submitButton, "click", this._onSubmitHandler);
    },
    dispose : function() 
    {
        return;   
    },
    get_SubmitButton : function()
    {
        return this._submitButton;
    },
    set_SubmitButton : function(value)
    {
        this._submitButton = $get(value);
    },
    get_ValidateScript : function()
    {
        return this._validateScript;
    },
    set_ValidateScript : function(value)
    {
        this._validateScript = eval('(' + value + ')');
    },
    get_ErrorPanelControl : function()
    {
        return this._errorPanelControl;
    },
    set_ErrorPanelControl : function(value)
    {
        this._errorPanelControl = $find(value);
    },
    get_HearChoices : function()
    {
        return this._hearChoices;
    },
    set_HearChoices : function(value)
    {
        this._hearChoices = $get(value);
    },
       
    Validate : function(e)
    {
        var success = true;
        this._errorPanelControl.ClearList();
        for (var i=0; i < this._validateScript.length; i++)
        {
            var control = $get(this._validateScript[i].ControlId);
            if(control.tagName == "INPUT")
            {
                this._errorPanelControl.Reset(control);
                
                if (!control.checked)
                {
                    this._errorPanelControl.Add(this._validateScript[i].Error, control);
                    success = false;
                }
            }
        }
        if (!this._errorPanelControl.ValidateEmptyControl(this._hearChoices, this._validateScript[2].Error))
            success = false;
        if (!success) e.preventDefault();
    }
};

Awc.WestOnline.Rules.UI.Accounts.OneOffSale.registerClass('Awc.WestOnline.Rules.UI.Accounts.OneOffSale', Sys.Component);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();