Ext.app.SearchField_for_Manager_search = Ext.extend(Ext.form.TwinTriggerField, {
    initComponent : function(){
        Ext.app.SearchField_for_Manager_search.superclass.initComponent.call(this);
        this.on('specialkey', function(f, e){
            if(e.getKey() == e.ENTER){
                this.onTrigger2Click();
            }
        }, this);
    },

    validationEvent:false,
    validateOnBlur:false,
    trigger1Class:'x-form-clear-trigger',
    trigger2Class:'x-form-search-trigger',
    hideTrigger1:true,
    width:180,
    hasSearch : false,
    paramName : 'query',

    onTrigger1Click : function(){
    	//alert('onTrigger1Click');
    	Ext.getCmp('admin_user_group').reset();
    	admin_user_grid_store.removeAll();
    	admin_user_grid_store.on('beforeload', function() {
		     admin_user_grid_store.baseParams = {
		          'sort':'last_name',
		          'dir':'ASC',
		          'search_string':document.getElementById('search_string').value
		     };
		});
    	
        if(this.hasSearch){
            this.el.dom.value = '';
            var o = {start: 0};
            this.store.baseParams = this.store.baseParams || {};
            this.store.baseParams[this.paramName] = '';
            this.store.reload({params:o});
            this.triggers[0].hide();
            this.hasSearch = false;
        }
    },

    onTrigger2Click : function(){
    	//alert('onTrigger2Click');
    	//alert(document.getElementById('search_string').value);
    	Ext.getCmp('admin_user_group').reset();
    	admin_user_grid_store.removeAll();
    	admin_user_grid_store.on('beforeload', function() {
		     admin_user_grid_store.baseParams = {
		          'sort':'last_name',
		          'dir':'ASC',
		          'search_string':document.getElementById('search_string').value
		     };
		});
		
        var v = this.getRawValue();
        if(v.length < 1){
            this.onTrigger1Click();
            return;
        }
        var o = {start: 0};
        this.store.baseParams = this.store.baseParams || {};
        this.store.baseParams[this.paramName] = v;
        this.store.reload({params:o});
        this.hasSearch = true;
        this.triggers[0].show();
    }
});








Ext.app.SearchField_for_Lead_search = Ext.extend(Ext.form.TwinTriggerField, {
    initComponent : function(){
        Ext.app.SearchField_for_Lead_search.superclass.initComponent.call(this);
        this.on('specialkey', function(f, e){
            if(e.getKey() == e.ENTER){
                this.onTrigger2Click();
            }
        }, this);
    },

    validationEvent:false,
    validateOnBlur:false,
    trigger1Class:'x-form-clear-trigger',
    trigger2Class:'x-form-search-trigger',
    hideTrigger1:true,
    width:180,
    hasSearch : false,
    paramName : 'query',

    onTrigger1Click : function(){
    	//alert('onTrigger1Click');
    	//Ext.getCmp('admin_user_group').reset();
    	lead_list_grid_store.removeAll();
    	lead_list_grid_store.on('beforeload', function() {
		     lead_list_grid_store.baseParams = {
		          'sort':'last_name',
		          'dir':'ASC',
		          'search_string_lead':document.getElementById('search_string_lead').value
		          ,todo:'getAllLeads'
		          ,user_id:_loggedInuserId 
		          ,role_id:_loggedInRight_id
		          ,prog_lang: params.lang
		     };
		});
    	
        if(this.hasSearch){
            this.el.dom.value = '';
            var o = {start: 0};
            this.store.baseParams = this.store.baseParams || {};
            this.store.baseParams[this.paramName] = '';
            this.store.reload({params:o});
            this.triggers[0].hide();
            this.hasSearch = false;
        }
    },

    onTrigger2Click : function(){
    	//alert('onTrigger2Click');
    	//alert(document.getElementById('search_string').value);
    	//Ext.getCmp('admin_user_group').reset();
    	lead_list_grid_store.removeAll();
    	lead_list_grid_store.on('beforeload', function() {
		     lead_list_grid_store.baseParams = {
		          'sort':'last_name',
		          'dir':'ASC',
		          'search_string_lead':document.getElementById('search_string_lead').value
		          ,todo:'getAllLeads'
		          ,user_id:_loggedInuserId 
		          ,role_id:_loggedInRight_id
		          ,prog_lang: params.lang
		     };
		});
		
        var v = this.getRawValue();
        if(v.length < 1){
            this.onTrigger1Click();
            return;
        }
        var o = {start: 0};
        this.store.baseParams = this.store.baseParams || {};
        this.store.baseParams[this.paramName] = v;
        this.store.reload({params:o});
        this.hasSearch = true;
        this.triggers[0].show();
    }
});







Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
    initComponent : function(){
        Ext.app.SearchField.superclass.initComponent.call(this);
        this.on('specialkey', function(f, e){
            if(e.getKey() == e.ENTER){
                this.onTrigger2Click();
            }
        }, this);
    },

    validationEvent:false,
    validateOnBlur:false,
    trigger1Class:'x-form-clear-trigger',
    trigger2Class:'x-form-search-trigger',
    hideTrigger1:true,
    width:180,
    hasSearch : false,
    paramName : 'query',

    onTrigger1Click : function(){
        if(this.hasSearch){
            this.el.dom.value = '';
            var o = {start: 0};
            this.store.baseParams = this.store.baseParams || {};
            this.store.baseParams[this.paramName] = '';
            this.store.reload({params:o});
            this.triggers[0].hide();
            this.hasSearch = false;
        }
    },

    onTrigger2Click : function(){
        var v = this.getRawValue();
        if(v.length < 1){
            this.onTrigger1Click();
            return;
        }
        var o = {start: 0};
        this.store.baseParams = this.store.baseParams || {};
        this.store.baseParams[this.paramName] = v;
        this.store.reload({params:o});
        this.hasSearch = true;
        this.triggers[0].show();
    }
});