TG.DomainOptions = Ext.extend(Ext.form.ComboBox, {
	typeAhead: true,
	triggerAction: 'all',
	lazyRender:true,
	mode: 'local',
	displayField: 'value',
	valueField: 'value',
	initComponent: function() {
		Ext.apply(this, {
			store: TG.DomainStore
		});
		TG.DomainOptions.superclass.initComponent.apply(this, arguments);
	},
	listeners: {
		beforeselect: function (combo, rec, index) {
			var v = rec.get('value');
			if (v.substr(v.length-3,3) == '...') {
				if (!TG.domain) {
					TG.domain = new TG.Domain();
				}
				Ext.getCmp('risk-rules').stopEditing();

				TG.domain.show();
				var t = this.initialConfig.type;
				var n = this.initialConfig.domainName;
				TG.domain.setDomainType(t, n);
				
				return false;
			}
		}
	},
	onLoad: function () {
		var t = this.initialConfig.type;
		TG.DomainStore.clearFilter();
		TG.DomainStore.filter('type', new RegExp('x|^'+t+'$'));
		TG.DomainOptions.superclass.onLoad.apply(this, arguments);
	}
});
Ext.reg('domain-options', TG.DomainOptions);
