App.Search.SearchPanel = Ext.extend(App.Search.SearchPanelUi, {
  nSearchPanels: 0,
	resultPagerSize: 15,

	// keep references to the criteria and results handler so that
	// the search function can access them
	searchCriteriaPanel: null,
	searchResultsPanel: null,
		
  initComponent: function() {
    App.Search.SearchPanel.superclass.initComponent.call(this);

    this.constructor.prototype.nSearchPanels++;
    this.searchPanelNo = this.constructor.prototype.nSearchPanels;
    this.title = 'Search ' + this.searchPanelNo;
  },

  // returns the query spec generated by its embedded SearchCriteriaPanel
  getQuerySpec: function() {
    return this.items.getAt(0).getQuerySpec();
  },

	// perform a search
	// used by search button handlers
	search: function(corpus, spec) {
		// reset the queryId before getting a new result
		this.searchResultsPanel.queryId = '0';
			
		var store = this.searchResultsPanel.getStore();

		store.setBaseParam('query', Ext.encode(spec));
		store.setBaseParam('corpus', corpus);
		store.setBaseParam('caseInsensitive', false);
		
		store.load({ params: {
			start: 0,
			limit: this.resultPagerSize
		}});
	}
});
Ext.reg("searchpanel", App.Search.SearchPanel);


App.Search.SearchPanel = Ext.extend(App.Search.SearchPanelUi, {
  nSearchPanels: 0,
	resultPagerSize: 15,

	// keep references to the criteria and results handler so that
	// the search function can access them
	searchCriteriaPanel: null,
	searchResultsPanel: null,

  initComponent: function() {
    if(this.constructor.prototype.nSearchPanels > 0) {
      Ext.apply(this, Ext.apply(this.initialConfig, {closable: true}));
    }
    App.Search.SearchPanel.superclass.initComponent.call(this);

    this.constructor.prototype.nSearchPanels++;
    this.searchPanelNo = this.constructor.prototype.nSearchPanels;
    this.title = 'Search ' + this.searchPanelNo;
  },

  // returns the query spec generated by its embedded SearchCriteriaPanel
  getQuerySpec: function() {
    return this.items.getAt(0).getQuerySpec();
  },

	// perform a search
	// used by search button handlers
	search: function(corpus, spec) {
		// reset the queryId before getting a new result
		this.searchResultsPanel.queryId = '0';
			
		var store = this.searchResultsPanel.getStore();

		store.setBaseParam('query', Ext.encode(spec));
		store.setBaseParam('corpus', corpus);
		store.setBaseParam('caseInsensitive', false);
		
		store.load({ params: {
			start: 0,
			limit: this.resultPagerSize
		}});
	}
});
Ext.reg("searchpanel", App.Search.SearchPanel);


Make Search Panels other than the first one closable
Make Search Panels other than the first one closable
