//radioCol = new Ext.grid.RadioColumn({header: 'Assign', dataIndex: 'assign'});   
SD.calendar.addPopup('myEvents', new Ext.Window({
	layout: 'fit',
	title: 'My Events',
	width: 700,
	height: 500,
	closeAction: 'hide',
	modal: true,
	tools: [{
		id: 'help'
	}],
	items: [{
		border: false,
		layout: 'fit',
		tbar: [{
			xtype: 'button',
			text: 'Edit event',
			iconCls: '',
			style: 'margin-left: 5px;',
			handler: function() {
				jsLoader.load('main_menu/' + modulizerPath + '/calendar_categories_category_grid.js');
				jsLoader.load('main_menu/' + modulizerPath + '/calendar_schedule_event.js');
				jsLoader.loadedCall(
				function() {
					record = this.ownerCt.ownerCt.items.items[0].getSelectionModel().getSelected();
					schedShowAs = Ext.getCmp('schedShowAs');
					schedShowAs.disable();
					if (record.data.approval == 'Personal') {
						Ext.Ajax.request({
							url: 'main_menu/calendar_data.json.php',
							success: function(r, o) {
								schedEventPopup = Ext.getCmp('calendarCatPopup');
								schedEventPopup.show();
								schedShowAs.doChange('Personal');
								schedEventForm = schedEventPopup.items.items[0].getForm();
								formValues = Ext.decode(r.responseText).results[0];
								schedEventForm.setValues(formValues);
							},
							params: {
								command: 'getPersonalEvent',
								itemID: (record.get('itemno')).replace(':Personal', "")
							}
						});
					} else {
						Ext.Ajax.request({
							url: 'main_menu/calendar_data.json.php',
							success: function(r, o) {
								schedEventPopup = Ext.getCmp('calendarCatPopup');
								schedEventPopup.show();
								schedEventForm = schedEventPopup.items.items[0].getForm();
								formValues = Ext.decode(r.responseText).results[0];
								if (formValues.needTransp == '1') {
									Ext.getCmp('transpFieldset').expand();
								} else {
									Ext.getCmp('transpFieldset').collapse();
								}
								schedEventForm.setValues(formValues);
								schedShowAs.doChange(formValues.showAs);
								Ext.getCmp('schedCatID').setValue(formValues.selCatID);
								Ext.getCmp('schedEventCats').items.items[0].store.getCatID();
							},
							params: {
								command: 'getEvent',
								itemID: (record.get('itemno')).replace(':Calendar', "")
							}
						});
					}
				}, this);
			}
		},
		{
			text: 'Delete event(s)',
			iconCls: 'date_delete',
			style: 'margin-left: 5px;',
			handler: function() {
				grid = this.ownerCt.ownerCt.items.items[0];
				selRecords = grid.getSelectionModel().getSelections();
				grid.store.batchRemove(selRecords);
				calendarstore.reload();
			}
		}],
		items: new SD.calendar.classes.approvalGrid([0, 1, 2, 3, 6], true, true)
	}],
	buttons: [{
		text: 'Close',
		handler: function(btn) {
			this.ownerCt.ownerCt.hide();
		}
	}],
	listeners: {
		show: function() {
			this.items.items[0].items.items[0].store.load()
		}
	}
})
);

