/**
 * @filename eventTypeFormField.js
 * 
 * @description Class to get event type drop down 
 * 
 * @author Devon Lindse
 *
 * Copyright(c) 2008, Garmin International
 */
Ext.namespace("Garmin", "Garmin.form");
Garmin.form.EventTypeFormField = {
	/**
	 * 
	 * @param {Object} Ext.form.ComboBox config
	 * 
	 * @return {Ext.form.ComboBox}
	 */
	getEventTypesCombo: function(config, includeAll, includeUncategorized, json) {
		var store = this._getEventTypesStore(json);
		var combo = new Ext.form.ComboBox(Ext.apply(config,Ext.apply(ActivityFormFieldsConstants.COMBO_BOX_DEFAULT_CONFIG_OPTIONS, {
				name: 'eventTypeField',
		        store: store,
				mode: 'local',
		        displayField:'defaultDisplay',
				valueField:'key'
			}))
		);
		return combo;
	},

	/**
	 * 
	 * @return {Ext.data.Store}
	 */
	_getEventTypesStore : function(json) {
		//This value is populated via a call to the eventTypes tag in the usertag lib.  
		//Store it as a var called EVENT_TYPES_JSON
		if (json == null){
			json = EVENT_TYPES_JSON;
		}
		var eventTypeData = json;

		var store = new Ext.data.JsonStore({
			data: eventTypeData,
		    root: 'dictionary',
			id: 'key',
			fields: [
	            {name: 'key'},
	            {name: 'defaultDisplay', mapping: 'display'},
	            {name: 'isDefault'}
	        ]
		});
		return store;
	}
};