function EditItem(_grid,_itemId) {
    if (!acos.fr_edit) return;
	var name = new Ext.form.TextField({
		maxLength:70,
        maxLengthText:str_replace('{n}',70,jsModule.max_chars),
        fieldLabel: jsModule.name,
        allowBlank: false,
		name: 'data[Repository][name]',
		dataIndex: 'name',
        width:650
    });
	
	var description = new Ext.ux.TinyMCE({
		name: 'data[Repository][description]',
		tinymceSettings: mceConfig[0],
		fieldLabel: jsModule.description,
		width: 650,
		height: 450,
		dataIndex: 'description'
	});
	
	var statusField = new Ext.form.ComboBox({
		id:'pubStatus',
		name:'pubStatus',
		dataIndex: 'status',
		value: '0',
		fieldLabel: jsModule.status,
		store: statusStoreWithoutTesting,
		displayField:'txt',
		typeAhead: false,
		selectOnFocus:true,
		valueField: 'idx',
		hiddenName: 'data[Repository][status]',
		triggerAction: 'all',
		width: 150,
		editable: false,
		mode: 'local'
	});
	
	var pubUp = new Ext.form.DateField({
        fieldLabel: 'Publish Date',
        allowBlank: true,
        dataIndex: 'publish_up',
        name: 'data[Repository][publish_up]',
        width: 150
    });

	var pubDn = new Ext.form.DateField({
        fieldLabel: 'Expire Date',
        allowBlank: true,
        dataIndex: 'publish_down',
        name: 'data[Repository][publish_down]',
        width: 150
    });
	
    var reqEmail = new Ext.form.Checkbox({
    	boxLabel: 'Require Email Address for Download',
    	fieldLabel:'Require Email',
    	checked: false,
    	dataIndex: 'req_email',
    	name: 'data[Repository][req_email]'
    });
    
	var commenting = getCommentingFields('Repository');

//	var fromData = new Ext.data.Store({
//        proxy: new Ext.data.HttpProxy({
//            url: '/tags/getAvailableTags/'+_itemId
//        }),
//		autoLoad:false,
//        reader: new Ext.data.JsonReader({
//            root: 'results',
//            id: 'id'
//        }, [
//            {name: 'id'},
//            {name: 'name'}
//        ]),
//        remoteSort: true
//    });
//    fromData.setDefaultSort('name', 'ASC');
//    fromData.load({params:{model:'Repository', aco:null}});
//
//	var toData = new Ext.data.Store({
//        baseParams: { id: _itemId },
//		proxy: new Ext.data.HttpProxy({
//             url: '/repositories/getTags/'+_itemId
//        }),
//		autoLoad:true,
//        reader: new Ext.data.JsonReader({
//            root: 'results',
//            id: 'id'
//        }, [
//            {name: 'id'},
//            {name: 'name'}
//        ]),
//        remoteSort: true
//    });
//    toData.setDefaultSort('name', 'ASC');
	
	var formPanel = new Ext.FormPanel({
		id: 'EditItemForm',
		url: '/repositories/edit',
		reader: new Ext.data.JsonReader({
					root: 'results'
				}, ['id','site_id','breadcrumbs','name','description','status','commenting','com_access','com_publish','com_email','publish_up','publish_down','req_email','com_req_email']
        ),
		method: 'POST',
		baseCls: 'x-plain',
		items: [
		    new Ext.form.Hidden({
		        name: 'data[Repository][id]',
				value: _itemId
		    }),
			name,
			description,
			statusField,
			pubUp, pubDn,
			commenting.field,
        	commenting.fieldset,
        	reqEmail,
			new AddonTags({
				site_id: site_id,
				hiddenName: 'data[Repository][tags]',
				item_type: 'Repository',
				item_id: _itemId
			})
		]
	});
	
	formPanel.form.load({url:'/repositories/getOne/'+_itemId,
                         waitMsg:'Loading'});
	
	formPanel.form.on('actioncomplete', function(form, action){
		if(action.type=='load'){
    		createBreadcrumbs(action.result.data.breadcrumbs);
		}
	});
                         
    var EditItemPanel = new Ext.Panel({
    	id: 'repositoryEditFile',
		title: jsModule.edit_file,
		border: false,
		bodyStyle:'padding:15px;',
		autoScroll: true,
		buttonAlign: 'center',
		buttons: [{
			text: 'Save',
			handler: function() {
				Ext.getCmp('EditItemForm').getForm().submit({
					waitMsg: jsModule.processing_data,
					params: {},
					success: function() {
						Ext.History.add(_itemId+TD+Tokens.details+TD+name.getValue());
					},
					failure: function() {
						
					}
				});
			}
		},{
			text: 'Cancel',
			handler: function() {
				Ext.History.add(_itemId+TD+Tokens.details+TD+name.getValue());
			}
		}],
		items: [formPanel],
		listeners:{
			'render':{
				fn: function() {
					_grid.hide();
				}
			}
		}
	});
	if (repositoryFrontend) {
		EditItemPanel.render('repository_container');
	} else {
		viewport.add(EditItemPanel);
		alert('added');
		viewport.doLayout();
	}
};