
Ext.override(Ext.Panel, {
    onResize : function(w, h){
        if(w !== undefined || h !== undefined){
            if(!this.collapsed){
                if(typeof w == 'number'){
                    w = this.adjustBodyWidth(w - this.getFrameWidth());
                    if(this.tbar){
                        this.tbar.setWidth(w);
                        if(this.topToolbar){
                            this.topToolbar.setSize(w);
                        }
                    }
                    if(this.bbar){
                        this.bbar.setWidth(w);
                        if(this.bottomToolbar){
                            this.bottomToolbar.setSize(w);
                        }
                    }
                    if(this.fbar){
                        var f = this.fbar, fWidth = 1; strict = Ext.isStrict;
                        if(this.buttonAlign == 'left'){
                           fWidth = w - f.container.getFrameWidth('lr');
                        }else{
                            //center/right alignment off in webkit
                            if(Ext.isIE || Ext.isWebKit){
                                //center alignment ok on webkit.
                                //right broken in both, center on IE
                                if(!(this.buttonAlign == 'center' && Ext.isWebKit) && (!strict || (!Ext.isIE8 && strict))){
                                    (function(){
                                        f.setWidth(f.getEl().child('.x-toolbar-ct').getWidth());
                                    }).defer(1);
                                }else{
                                    fWidth = 'auto';
                                }
                            }else{
                                fWidth = 'auto';
                            }
                        }
                        f.setWidth(fWidth);
                    }
                    this.body.setWidth(w);
                }else if(w == 'auto'){
                    this.body.setWidth(w);
                }

                if(typeof h == 'number'){
                    h = this.adjustBodyHeight(h - this.getFrameHeight());
                    this.body.setHeight(h);
                }else if(h == 'auto'){
                    this.body.setHeight(h);
                }

                if(this.disabled && this.el._mask){
                    this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight());
                }
            }else{
                this.queuedBodySize = {width: w, height: h};
                if(!this.queuedExpand && this.allowQueuedExpand !== false){
                    this.queuedExpand = true;
                    this.on('expand', function(){
                        delete this.queuedExpand;
                        this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
                        this.doLayout();
                    }, this, {single:true});
                }
            }
            this.fireEvent('bodyresize', this, w, h);
        }
        this.syncShadow();
    }
});

// see below for recreating bug
Ext.Button.prototype.initComponent = Ext.Button.prototype.initComponent.createInterceptor(function(){
    if (this.menu){
        this.menu.ownerCt = this;
    }
});
// the above fixes toolbar/button/menu bug as seen in this code
/*
            bbar: {
                    xtype: 'toolbar',
                    hidden: false,
                    id: 'AppToolbar',
                    items: [
                        {
                            xtype: 'tbspacer',
                            width: 30
                        },
                        {
                            xtype: 'button',
                            text: 'Options',
                            id: 'tbuttonOptions',
                            ref: '../../btnOptions'
                        },
                        {
                            xtype: 'tbspacer'
                        },
                        {
                            xtype: 'button',
                            text: 'Perspective',
                            id: 'tbuttonPerspective',
                            menu: {
                                xtype: 'menu',
                                id: 'menuPerspective',
                                items: [
                                    {
                                        xtype: 'menuitem',
                                        text: 'Projects',
                                        ref: '../../../../btnProjects'
                                    },
                                    {
                                        xtype: 'menuitem',
                                        text: 'Events',
                                        ref: '../../../../btnEvents'
                                    }
                                ]
                            }
                        },
                        {
                            xtype: 'tbfill'
                        },
                        {
                            xtype: 'button',
                            text: 'Edit Gui',
                            clickEvent: 'click',
                            tooltipType: 'title',
                            tooltip: 'Add a new top level project',
                            disabled: true,
                            id: 'btnEditGui',
                            ref: '../../btnEditGui'
                        },
                        {
                            xtype: 'tbspacer'
                        },
                        {
                            xtype: 'button',
                            text: 'Rebuild',
                            clickEvent: 'click',
                            tooltipType: 'title',
                            tooltip: 'Add a new top level project',
                            disabled: true,
                            id: 'btnRebuild',
                            ref: '../../btnRebuild'
                        },
                        {
                            xtype: 'tbspacer'
                        },
                        {
                            xtype: 'button',
                            text: 'Start A Project',
                            clickEvent: 'click',
                            tooltipType: 'title',
                            tooltip: 'Add a new top level project',
                            id: 'btnAddProj',
                            ref: '../../btnAddProj'
                        },
                        {
                            xtype: 'tbspacer'
                        },
                        {
                            xtype: 'button',
                            text: 'Help',
                            clickEvent: 'click',
                            tooltipType: 'title',
                            tooltip: 'Get Snippets and helpful info about the code and solutions',
                            id: 'btnHelp',
                            ref: '../../btnHelp'
                        },
                        {
                            xtype: 'tbspacer',
                            width: 30
                        }
                    ]
                }
*/
