DepartureComboBox = Ext.extend(Ext.form.ComboBox, {
    doQuery : function(q, forceAll) {
        if (q === undefined || q === null) {
            q = '';
        }
        var qe = {
            query: q,
            forceAll: forceAll,
            combo: this,
            cancel:false
        };
        if (this.fireEvent('beforequery', qe)===false || qe.cancel) {
            return false;
        }
        q = qe.query;
        forceAll = qe.forceAll;
        if (forceAll === true || (q.length >= this.minChars)) {
            if (this.lastQuery != q) {
                this.lastQuery = q;
                if (this.mode == 'local') {
                    this.selectedIndex = -1;
                    if (forceAll) {
                        this.store.clearFilter();
                    } else {
                        var lcq = q.toLowerCase();
                        if (lcq.charAt(0) == '*') {
                            lcq = lcq.substring(1);
                        }
                        this.store.filterBy(function(rec, id) {
                            if (rec.get(this.valueField).toLowerCase() == lcq) {
                                return true;
                            }
                            if (rec.get(this.displayField).toLowerCase().indexOf(lcq) === 0) {
                                return true;
                            }
                            return false;
                        }, this);
                    }
                    this.onLoad();
                } else {
                    this.store.baseParams[this.queryParam] = q;
                    this.store.load({
                        params: this.getParams(q)
                    });
                    this.expand();
                }
            } else {
                this.selectedIndex = -1;
                this.onLoad();   
            }
        }
    }
});

// register xtype to allow for automatic lazy instantiation
Ext.ComponentMgr.registerType('departurecombo', DepartureComboBox);
