Ext.namespace("OM.Ext");

OM.Ext.ButtonPlugin = function() {    
    this.init = function(button) {        
        var oldOnClick = function(e) {
            if (!this.disabled){
                if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
                    this.toggle();
                }
                if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
                    this.showMenu();
                }
                this.fireEvent("click", this, e);
                if(this.handler){
                    //this.el.removeClass("x-btn-over");
                    this.handler.call(this.scope || this, this, e);
                }
            }   
        }
        
        button.onClick = function(e) {
            Ext.get(button.id).child(this.buttonSelector).dom.click(e);
            if (button.alwaysSubmit === true) {
                window.setTimeout(function() {
                    oldOnClick.call(button, e);
                }, 1);                              
            }
        }
    };
}

