Ext.ns('Ext.ux.Desktop');
Ext.ux.Desktop.FlashWindow = function(config) {
	Ext.ux.Desktop.FlashWindow.superclass.constructor.call(this, config);
	this.animCollapse = this.animCollapse !== false ? Ext.isIE : this.animCollapse;
	this.animFloat = this.animFloat !== false ? Ext.isIE : this.animFloat;
	this.border = false;
	this.isShown = false;
	this.restoreZIndex = null;
	this._proxy = false;
}


Ext.extend(Ext.ux.Desktop.FlashWindow, Ext.Window, {

    show : function(animateTarget, cb, scope){
		this.setActive(true);
        this.beforeShow();
		if (this.isShown === false) {
			this.isShown = true;
			Ext.ux.Desktop.FlashWindow.superclass.show.call(this, animateTarget, cb, scope);	
		} else {
			this.el.setZIndex(this.restoreZIndex);
			this.restoreZIndex = false;
		}
		this.hidden = false;
        this.afterShow();
		return;
	},
	
    hide : function(animateTarget, cb, scope){
		if (this._proxy === false && this.animateTarget !== undefined) {

		}
		this.setActive(false);
		this.restoreZIndex = this.restoreZIndex === null ? this.el.zindex : this.restoreZIndex;
		this.getEl().setZIndex(-10);
		this.hidden = true;
		
		
        if(this._proxy !== false){
			if (this._proxy.rendered) {
			
			}
        }
		
		this.afterHide();
		return;
	},
	
    close : function(){
        if(this.fireEvent("beforeclose", this) !== false){
			this.fireEvent('close', this);
			this.destroy();
        }
    }
	
});

Ext.override(Ext.Window, {
    maximize : function(){
	  	if(!this.maximized){
            this.expand(false);
            this.restoreSize = this.getSize();
            this.restorePos = this.getPosition(true);
            if (this.maximizable){
                this.tools.maximize.hide();
                this.tools.restore.show();
            }
            this.maximized = true;
            this.el.disableShadow();

            if(this.dd){
                this.dd.lock();
            }
            if(this.collapsible){
                this.tools.toggle.hide();
            }

			this.setPosition(0, 0);
            this.fitContainer();
			this.doLayout();
            this.fireEvent('maximize', this);
        }
	},
	
    restore : function(){
        if(this.maximized){
            this.el.removeClass('x-window-maximized');
            this.tools.restore.hide();
            this.tools.maximize.show();
            this.setPosition(this.restorePos[0], this.restorePos[1]);
            this.setSize(this.restoreSize.width, this.restoreSize.height);
            delete this.restorePos;
            delete this.restoreSize;
            this.maximized = false;
            this.el.enableShadow(true);

            if(this.dd){
                this.dd.unlock();
            }
            if(this.collapsible){
                this.tools.toggle.show();
            }
            this.container.removeClass('x-window-maximized-ct');

            this.doConstrain();
			this.doLayout();
            this.fireEvent('restore', this);
        }
    }
});



