// Create user extension namespace (Application)
Ext.namespace('Application');

/**
  *  Application.guestTovarPagePanel Extension class
  * 
  *  @author Seabor
  *  @version 1.0
  *  
  *  @class Application.guestTovarPagePanel
  *  @extends Ext.Panel
  *  @constructor
  *  @param {Object} config Configuration options
  */

Application.guestTovarPagePanel = function(config) {

    // call parent constructor
    Application.guestTovarPagePanel.superclass.constructor.call(this, config);

}; // end of Application.guestTovarPagePanel constructor

Ext.extend(Application.guestTovarPagePanel, Ext.Panel, {

    // configurables
    // anything what is here can be configured from outside
    id: 'tovar_page'
    ,closable: true
    ,autoScroll: true
    ,style: 'background: #142f4c;padding-right:0px'
    ,layout: 'border'
    ,tovarId: ''
    
    ,initComponent: function() {
    	var that = this;
        // Ext.apply {{{
    	Ext.apply(this, {
    	   items: [{
                region: 'center'
                ,xtype: 'guestTovarDescrPanel'
            },{
                region: 'west'
                //,title: 'Характеристики'
                ,width: 300
                ,split: true
                ,style: "padding: 5px; background:#142f4c;"
                ,xtype: 'guestTovarPropGrid'
            }]
    	}); // }}} e/o Ext.apply
    	
    	// call parent
    	Application.guestTovarPagePanel.superclass.initComponent.apply(this, arguments);
    	
    	this.tovarProp = this.items.itemAt(1);
    	this.tovarDescr = this.items.itemAt(0);
    	
    	this.on({
    	   scope: this
    	   ,render: function() {
    	       this.on({
                    scope: this
                    ,deactivate: function() {
                        unFocus.History.addHistory('/');
                    }
                    ,activate: function() {
                        unFocus.History.addHistory('/tovar/' + this.tovarId);
                    }
                    ,destroy: function() {
                        this.fireEvent('deactivate', this);
                    }
                    ,bodyresize: function() {
                        this.doLayout();
                    }
                });
    	   }
    	});
    }
    ,afterRender: function() {
        // call parent
        Application.guestTovarPagePanel.superclass.afterRender.apply(this, arguments);
    }
	
});

// register new xtype
Ext.reg('guestTovarPagePanel', Application.guestTovarPagePanel);
