var edicionx;
var edicionx2;
var edicionx3;
var edicionx4;
var edicionx5;
var edicionx6;
var edicionx7;
var edicionx8;
var edicionx9;
var edicionx10;

var imagenx;
var up_imgsx;
var sel_imgx;
var nodo_selx;

function editar(modelo, id){
	if(edicionx.config.visible == 'false'&&edicionx3.config.visible == 'false'&&edicionx3.config.visible == 'false'&&edicionx4.config.visible == 'false'&&edicionx5.config.visible == 'false'&&edicionx6.config.visible == 'false'&&edicionx7.config.visible == 'false'&&edicionx8.config.visible == 'false'&&edicionx9.config.visible == 'false'&&edicionx10.config.visible == 'false'){
		if(modelo == 'contenidos' || modelo == 'noticias') edicionx.show(modelo,id);
		else if(modelo == 'galerias') edicionx2.show(modelo,id);
		else if(modelo == 'eventos') edicionx3.show(modelo,id);
		else if(modelo == 'administracion') edicionx4.show();
		else if(modelo == 'videos') edicionx5.show();
		else if(modelo == 'productos') edicionx6.show(modelo,id);
		else if(modelo == 'enlaces') edicionx7.show(modelo,id);
		else if(modelo == 'menus') edicionx8.show(modelo,id);
		else if(modelo == 'encuestas') edicionx9.show(modelo,id);
		else if(modelo == 'descargas') edicionx10.show(modelo,id);
	}
}
function editar2(modelo, id,tipo,otro){
	edicionx2.show(modelo,id,tipo,otro);
}



Ext.onReady(function(){
	Ext.QuickTips.init();

	var categorias = function(config){
		this.config = config;
	}
	
	categorias.prototype = {
		show : function(modelo,compo_id,store_id){//Modelo y id del componente
			this.interface = false;
			if(!this.interface){
				this.interface = new Object();
				var interface = this.interface;
				this.interface.modelo = modelo;
				this.interface.compo_id = compo_id;
				this.interface.store_id = store_id;
				
				this.interface.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.interface.store2.load();
				
				var ccidioma_id = new Ext.form.Hidden({
					name:'ccidioma_id',
					id:'ccidioma_id'
				});
				
				this.interface.formulario01 = new Ext.FormPanel({
					bodyStyle:'padding: 10px',
					height:'100%',
					width:'100%',
					autoHeight : true,
					autoScroll: true,
					layout: 'form',
					defaults: {
						bodyStyle:'padding:5px'
					},
					items:[{ 
						xtype:'textfield',
						fieldLabel:'Nombre',  
						name: 'ccnombre', 
						id: 'ccnombre',
						width:164
					},{ 
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'ccidioma', 
						id:'ccidioma' ,
						hiddenName: 'ccidioma_id',
						forceSelection:true,   
						store: this.interface.store2,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id',
						mode: 'local'
					}] ,
					tbar: this.interface.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(interface.modelo); }.createDelegate(this)},{text:'Salir',handler: function(){ this.interface.tableWindow3.close(); }.createDelegate(this)}]
				});
				this.interface.tableWindow3 = new Ext.Window({
					title: 'Nueva categoria de '+ modelo,
					closeAction: 'close',
					width:400,
					items: this.interface.formulario01,
					listeners: {
						close: function() {
							interface = null;
						}
					}
				});
				this.interface.tableWindow3.show();
			}
		},
		save_contenido: function(modelo){
			var interface = this.interface;
			
		
			interface.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarcjson/',
				//waitMsg: 'Grabando...',
				success: function () {
					interface.store_id.load();
					var categoria = interface.formulario01.getForm().findField('ccnombre').getValue();
					Ext.Ajax.request({
						url : urlbase+'0/'+interface.modelo+'/vercjson/'+categoria,
						method: 'GET',
						success: function ( result, request ) { 
							interface.compo_id.setValue(result.responseText);
							interface.compo_id.el.dom.value = categoria;
						}
					});
										
					interface.tableWindow3.close();
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		}
	};
	
	var edicion = function(config){
		this.config = config;
	}
	
	var edicion = function(config){
		this.config = config;
	}
	
	edicion.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			this.interface = false;
			if(!this.interface){
				this.interface = new Object();
				var interface = this.interface;
				this.interface.modelo = modelo;
				this.interface.store1 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/'+modelo+'/vista5json/',
					fields: ['cid', 'cnombre']
				});
				this.interface.store1.load();
				
				this.interface.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.interface.store2.load();
				
				var categoria_id = new Ext.form.Hidden({
					name:'categoria_id',
					id:"categoria_id"
				});
				
				var idioma_id = new Ext.form.Hidden({
					name:'idioma_id',
					id:"idioma_id"
				});
				
				this.interface.toolbar01 = new Ext.Toolbar({
					items: [{
						iconCls: 'add',
						tooltip: 'Adicionar',
						handler: function(){ this.new_contenido(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar',
						handler: function(){ this.del_contenido(); }.createDelegate(this)
					}]
				});
				this.interface.panel03 = new Ext.Panel({
					border: true,
					height:460,
					columnWidth: '.38',
					layout: 'form',
					items:[{
						xtype:'combo',
						allowBlank: false,
						fieldLabel:'Categoria',
						name:'categoria',
						id:'categoria',
						hiddenName: 'categoria_id',
						forceSelection: true,
						store: this.interface.store1,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						listeners: {
							select : function(combo,record,index ){
								if(record.get('cid')== '-1') categoriasx.show(interface.modelo,this,interface.store1);
							}
						}
					}, {
						columnWidth: '.5',
						border: false,
						layout: 'form',
						items: [{
							xtype:'datefield',
							fieldLabel:'Fecha de Publicacion',  
							name:'creacion', 
							id:'creacion',
							format:'Y-m-d',
							emptyText: fecha_actual,
							value: fecha_actual
						}]

					},{ 
						xtype:'textfield',
						allowBlank: false,
						fieldLabel:'Titulo',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '90%'
					},{ 
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'imagen_id', 
						id: 'imagen_id',
						value:'0'
					},{ 
						xtype:'combo',
						allowBlank: false,
						fieldLabel:'Idioma',  
						name:'idioma', 
						id:'idioma' ,
						hiddenName: 'idioma_id',
						forceSelection:true,   
						store: this.interface.store2,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id'
					},{
						xtype: 'textarea',
						width : 250,   
						height: 100,
						fieldLabel:'Introduccion', 
						name:'introduccion', 
						id:'introduccion'
					}, {
						fieldLabel:'Foto', 
						xtype:'box',
						autoEl: {
							tag: 'div',
							html: '<img id="pic" onclick="edicionx.sel_contenido();" width="90" height="90" src="'+ Ext.BLANK_IMAGE_URL+'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
						}
					},{   
						xtype: 'checkbox',
						fieldLabel:'Comentarios', 
						name:'comentarios', 
						id:'comentarios'    
					}, {
						columnWidth: '.5',
						border: false,
						layout: 'form',
						items: [{
							xtype: 'checkbox',
							fieldLabel:'Principal',  
							name:'principal', 
							id:'principal'  
						}]
					}]
				});	
				this.interface.panel04 = new Ext.Panel({
					columnWidth: '.62',
					height:460,
					border: true,
					items: [{
						xtype:'fckeditor',
						name:'fck_description',
						id:'fck_description',
						height:'100%',
						width:'100%',
						value:''
					}]
				});
				this.interface.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','categoria','creacion','nombre','idioma','introduccion','imagen','imagen_id','comentarios','principal','fck_description']);
				
			
				this.interface.formulario01 = new Ext.FormPanel({
					reader : this.interface.formjreader01,
					title:'Formulario',
					bodyStyle:'padding: 10px',
					height:460,
					width:'100%',
					autoHeight : true,
					autoScroll: true,
					layout: 'column',
					defaults: {
						bodyStyle:'padding:5px',
						iconAlign: 'top'
					},
					items:[   
						this.interface.panel03,this.interface.panel04
					] ,
					//tbar: this.interface.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{
						iconCls: 'add',
						tooltip: 'Adicionar',
						handler: function(){ this.new_contenido(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar',
						handler: function(){ this.del_contenido(); }.createDelegate(this)
					},'&nbsp;',{text:'Guardar',handler: function(){ this.save_contenido(modelo,mid); }.createDelegate(this)},{text:'Salir',handler: function(){ this.interface.tableWindow3.close(); }.createDelegate(this)}]
				});
				//************************************************
				this.interface.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista7json/',
					fields: ['mid','categoria','creacion','nombre','idioma','comentarios','principal'],
					remoteSort: true
				});
				this.interface.colModel = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid'},
					{header: 'Publicacion', width: 80, sortable: true, dataIndex: 'creacion'},
					{header: 'Categoria', width: 100, sortable: true, dataIndex: 'categoria'},
					{header: 'Nombre', width: 420, sortable: true, dataIndex: 'nombre'},
					{header: 'Idioma', width: 100, sortable: true, dataIndex: 'idioma'}
				]);

				this.interface.selModel = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							interface.formulario01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
							interface.formulario01.getForm().findField('mid').setValue(selRecordStore.data.mid);
							interface.tabs.setActiveTab(0);
						}
					}

				});

				this.interface.searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar en '+modelo
				});

				this.interface.grid = new Ext.grid.GridPanel({
					store: this.interface.store3,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.interface.colModel,                                       
					selModel: this.interface.selModel,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:510,
					width:'100%',
					tbar:[interface.searchField, '-',{
						text:'Buscar',
						handler : function(){
							store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						//pageSize: 20,
						store: this.interface.store3,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
				//***************************************************
				this.interface.formulario02 = new Ext.Panel({
					title:'Consulta',
					height:520,
					items: [this.interface.grid]
				});
				
				this.interface.tabs = new Ext.TabPanel({
					activeTab: 0,
					height:'100%',
					items: [this.interface.formulario01,this.interface.formulario02], //le agregamos el primer tab
					
					listeners: {
						beforetabchange: function() {
							interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
						}
					}
				});
				
				var config = this.config;

				this.interface.tableWindow3 = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					maximized: true,
					width:780,
					height:'100%',
					
					items: this.interface.tabs,
					listeners: {
						close: function() {
							config.visible = 'false';
							interface = null;
							window.location = window.location;
						},
						maximize: function() {
							//document.styleSheets = '';
						}
					}
				});
				this.interface.tableWindow3.show();
				
				this.interface.formulario01.getForm().load({ 
					method:'GET',
					url : urlbase+'0/'+modelo+'/vista6json/'+mid
				});
				this.interface.formulario01.getForm().on({
					actioncomplete: function(form, action){
						if(action.type == 'load'){
							var contact = action.result.data;
							Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.imagen;
						}
					}
				});
				scrollTo(0,0);
				document.body.scroll = "no";
				document.documentElement.style.overflowY = 'hidden';
				//scroll_clipper.scrollTop = 0;
				
			}
		},
		save_contenido: function(modelo,mid){
			var interface = this.interface;
			this.interface.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarjson/'+mid,
				waitMsg: 'Grabando...',
				success: function () {
					interface.formulario01.getForm().reset();
					Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
					interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		new_contenido: function(){
			this.interface.formulario01.getForm().reset();
			Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
		},
		del_contenido: function(){
			var interface = this.interface;
			if(interface.formulario01.getForm().findField('mid').getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+interface.modelo+'?',function(btn){
					if(btn === 'yes'){
						Ext.Ajax.request({
							url : urlbase+'0/'+interface.modelo+'/eliminarjson/'+interface.formulario01.getForm().findField('mid').getValue(),
							method: 'GET',
							waitMsg: 'Eliminando...',
							success: function ( result, request ) { 
								Ext.MessageBox.alert('Success', 'El contenido ha sido eliminado'); 
							}
						});
						interface.formulario01.getForm().reset();
					}
				});
			}
		},
		sel_contenido: function(){
			editar2('galerias','0','1');
		}
	};
	
	
	//**************************************************************************************************************
	//**************************************************************************************************************
	//
	//													IMAGENES
	//
	//**************************************************************************************************************
	//**************************************************************************************************************
	
	
	var edicion2 = function(config){
		this.config = config;
	}
	
	edicion2.prototype = {
		lookup2 : {},
		show : function(modelo,mid,tipo,otro){
			if(this.win){
				this.win = null;
			}
			if(!this.win){
				this.initTemplates();
				this.NodoSelX = '0';
				this.tipo = tipo;
				this.store1 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store1.load();
				
				this.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/fotos/vertodosjson/',
					fields: ['id', 'archivo','detalle'],
					remoteSort: true
				});
				
				this.formatData2 = function(data){
					this.lookup2[data.id] = data;
					return data;
				};
				
				this.dataview2 = new Ext.DataView({
					store: this.store2,
					tpl: this.tpl2,
					autoHeight: true,
					singleSelect: true,
					overClass:'x-view-over',
					itemSelector:'div.thumb-wrap',
					emptyText: '',
					listeners: {
						'dblclick': {fn:this.showDetails, scope:this, buffer:100},
						'click': {fn:this.showDetails, scope:this, buffer:100}
					},
					prepareData: this.formatData2.createDelegate(this)
				});
												
				var idioma_id2 = new Ext.form.Hidden({
					name:'idioma_id2',
					id:"idioma_id2"
				});
				
				this.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','nombre2','idioma2','detalle2']);
				this.formulario01 = new Ext.FormPanel({
					reader : this.formjreader01,
					border: true,
					width:'100%',
					height: 213,
					labelAlign: 'top',
					items:[{ 
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{ 
						xtype:'textfield',
						fieldLabel:'<b>Nombre</b>',  
						name: 'nombre2', 
						id: 'nombre2',
						width : '95%'
					},{ 
						xtype:'combo',
						fieldLabel:'<b>Idioma</b>',  
						name:'idioma2', 
						id:'idioma2' ,
						hiddenName: 'idioma_id2',
						forceSelection:true,   
						store: this.store1,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id',
						width : 155
					},{ 
						xtype: 'textarea',
						fieldLabel:'<b>Descripcion</b>',
						name: 'detalle2', 
						id: 'detalle2',
						width : '95%',   
						height: 50
					}] ,
					defaults:{
						iconAlign: 'top'
					},
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_galeria(); }.createDelegate(this)}]
				});
				var form01 = this.formulario01;
				this.formulario01.disable();
				this.toolbar01 = new Ext.Toolbar({
					items: [
						{
							iconCls: 'add',
							tooltip: 'Adicionar una galeria',
							handler: function(){ this.new_galeria(); }.createDelegate(this)
						},{
							iconCls: 'remove',
							tooltip: 'Eliminar la galeria seleccionada',
							handler: function(){ 
								this.NodoSelX = NodoSelX; 
								this.delete_galeria(); 
							}.createDelegate(this)
						}
					]
				});
				this.tree = new Ext.tree.TreePanel({ 		//Paso 2
					border: true,
					autoScroll:true,
					enableDD: true,
					containerScroll: true,
					width:'100%',
					height: 216,
					tbar: this.toolbar01,
					dataUrl: urlbase+'0/galerias/vista2json/',
					root:{
						nodeType: 'async',
						text: 'Galerias',
						draggable: false,
						id: 'algun_id'
					},
					listeners: {
						expandnode: function(node) {
							var root = this.getRootNode();
							var selModel = this.getSelectionModel();
							var currentNode = root.findChild("id", "1");
							selModel.select(currentNode);
							node = currentNode;
							st2.removeAll();
							st2.load({params:{start:node.attributes.id}});
							NodoSelX = node.attributes.id;
							if(NodoSelX > 19){
								form01.getForm().load({ 
									method:'GET',
									url : urlbase+'0/galerias/vista3json/'+NodoSelX
								});
								form01.enable();
							}
							else{
								form01.getForm().reset();
								form01.disable();
								form01.getComponent('mid').value = node.attributes.id;
							}
							form02.getForm().reset();
							Ext.getDom('picx').src = Ext.BLANK_IMAGE_URL;
							Ext.getDom('picx').width = 1;
							Ext.getDom('picx').height = 1;
							form02.disable();
						}
					}
				});
				this.tree.expandAll();
				

				var st2 = this.store2;
				var NodoSelX = this.NodoSelX;
				this.tree.on('click', function(node, event){
					if(node.isLeaf()){
						st2.removeAll();
						st2.load({params:{start:node.attributes.id}});
						NodoSelX = node.attributes.id;
						if(NodoSelX > 19){
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/galerias/vista3json/'+NodoSelX
							});
							form01.enable();
						}
						else{
							form01.getForm().reset();
							form01.disable();
							form01.getComponent('mid').value = node.attributes.id;
						}
						form02.getForm().reset();
						Ext.getDom('picx').src = Ext.BLANK_IMAGE_URL;
						Ext.getDom('picx').width = 1;
						Ext.getDom('picx').height = 1;
						form02.disable();
					}
				});
				
				this.panel01 = new Ext.Panel({
					columnWidth: '.22',
					border: false,
					defaults: {
						bodyStyle:'padding:5px'
					},
					layout: 'anchor',
					items: [
						this.tree,
						this.formulario01
					]
				});
				
				this.toolbar02 = new Ext.Toolbar({
					items: [
						{
							text: 'Cargador Simple',								
							handler: function(){ 
								if(this.formulario01.getComponent('mid').value != 0) up_img.show(this.formulario01.getComponent('mid').value,2);
								else alert('No');
							}.createDelegate(this)
						},{
							text: 'Cargador Compuesto',
							handler: function(){ 
								if(this.formulario01.getComponent('mid').value != 0) up_imgs.show(this.formulario01.getComponent('mid').value,2);
								else alert('No');
							}.createDelegate(this)
						}
					]
				});
				
				this.panel02 = new Ext.Panel({
					columnWidth: '.48',
					id: 'img-chooser-view',
					autoScroll: true,
					width:'80%',
					height: 430,
					tbar: this.toolbar02,
					items: this.dataview2
				});
				
				this.formjreader02 = new Ext.data.JsonReader({root: 'data'}, ['imid','iarchivo','inombre','iautor','idetalle','iw','ih']);
				this.formulario02 = new Ext.FormPanel({
					reader : this.formjreader02,
					width:'100%',
					height: 403,
					labelAlign: 'top',
					items:[{ 
						xtype: 'hidden',
						name: 'imid', 
						id: 'imid',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'iarchivo', 
						id: 'iarchivo',
						value:'0'
					},{
						xtype:'box',
						autoEl: {
							tag: 'div',
							style:'text-align:center;',
							html: '<div style="width:210px;height:160px;margin-bottom:10px;"><img id="picx" onclick="edicionx.sel_contenido();" width="1" height="1" src="'+ Ext.BLANK_IMAGE_URL+'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" /></div>'
						}
					},{
						xtype:'textfield',
						fieldLabel:'Nombre',  
						name: 'inombre', 
						id: 'inombre',
						width : '95%'
					},{
						xtype:'textfield',
						fieldLabel:'Autor',  
						name: 'iautor', 
						id: 'iautor',
						width : '95%'
					},{ 
						xtype: 'textarea',
						fieldLabel:'Descripcion',  
						name: 'idetalle', 
						id: 'idetalle',
						width : '95%',   
						height: 70
					}] ,
					defaults:{
						iconAlign: 'top'
					},
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{
						text:'Guardar',handler: function(){ this.save_foto(); }.createDelegate(this)
					},{
						text:'Eliminar',handler: function(){ this.delete_foto(); }.createDelegate(this)
					}]
				});
				var form02 = this.formulario02;
				this.formulario02.disable();
				
				this.toolbar03 = new Ext.Toolbar({
					height: 26,
					items: 'Informaci&oacute;n de la foto'
				});
				
				this.panel03 = new Ext.Panel({
					columnWidth: '.3',
					height: 430,
					defaults: {
						bodyStyle:'padding:5px'
					},
					tbar: this.toolbar03,
					items: this.formulario02
				});

				this.formulario02.getForm().on({
					actioncomplete: function(form, action){
						if(action.type == 'load'){
							var contact = action.result.data;
							Ext.getDom('picx').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.iarchivo;
							Ext.getDom('picx').width = contact.iw;
							Ext.getDom('picx').height = contact.ih;
						}
					}
				});
				
				this.win = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					height:500,
					layout: 'column',
					items:[
						this.panel01,	
						this.panel02,
						this.panel03
					],
					
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Salir',handler: function(){ this.win.close(); }.createDelegate(this)}]
				});
				if(tipo == '1'){
					this.win.addButton({text:'Seleccionar imagen',disabled:true}, function(){ 
						if(otro == null){
							//console.debug(edicionx.config.visible);
							if(edicionx.config.visible == 'true') edicionx.interface.panel03.getComponent('imagen_id').setValue(form02.getComponent('imid').getValue());
							else if(edicionx3.config.visible == 'true') edicionx3.panel03.getComponent('pimagen_id').setValue(form02.getComponent('imid').getValue());
							else if(edicionx6.config.visible == 'true') edicionx6.panel03.getComponent('imagen_id').setValue(form02.getComponent('imid').getValue());
							else if(edicionx7.config.visible == 'true') edicionx7.panel03.getComponent('imagen_id').setValue(form02.getComponent('imid').getValue());
							Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+form02.getComponent('iarchivo').getValue();
						}
						else{
							if(otro == '1'){ 
								edicionx4.interface.panel12.getForm().findField('id_imagen').setValue(form02.getComponent('imid').getValue());
								Ext.getDom('pic1').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+form02.getComponent('iarchivo').getValue();
							}
						}
						this.win.close();
					},this);
				}
			}else{
				this.win.getEl().frame();
			}
			this.win.show();
		},
		initTemplates : function(){
			this.tpl2 = new Ext.XTemplate(
				'<tpl for=".">',
					'<div class="thumb-wrap" id="{id}">',
					'<div class="thumb"><img src="'+urlbase+'tmp/sol_'+nav_id+'/thumbnails/{archivo}" title="{detalle}"></div>',
					'</div>',
				'</tpl>',
				'<div class="x-clear"></div>'
			);
			this.tpl2.compile();
		},
		showDetails: function(){
			var tipo = this.tipo;
			var win = this.win;
			if(this.formulario02.getForm().findField('imid').getValue() != '0') this.save_foto();
			if(tipo == 1) win.buttons[1].disable();
			var selNode = this.dataview2.getSelectedNodes();
			if(selNode && selNode.length > 0){
				selNode = selNode[0];
				var data = this.lookup2[selNode.id];
				data.id;
				this.formulario02.getForm().load({ 
					method:'GET',
					url : urlbase+'0/fotos/vista1json/'+data.id,
					success: function () {
						if(tipo == 1) win.buttons[1].enable();
					}
				});
				this.formulario02.enable();
			}
		},
		new_galeria: function(){
			this.formulario01.getForm().reset();
			this.formulario01.enable();
		},
		save_galeria: function(){
			var tree = this.tree;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/galerias/guardarjson/',
				//waitMsg: 'Grabando...',
				success: function () {
					tree.getLoader().dataUrl = urlbase+'0/galerias/vista2json/';
					tree.getRootNode().reload();
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		delete_galeria: function(){
			if(this.NodoSelX > 19){
				var form01 = this.formulario01;
				var store2 = this.store2;
				var form02 = this.formulario02;
				var tree = this.tree;
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar esta Galeria?',function(btn){
					if(btn === 'yes'){
						Ext.Ajax.request({
							url : urlbase+'0/galerias/eliminarjson/'+form01.getComponent('mid').value,
							method: 'GET'
						});
						store2.removeAll();
						store2.load({params:{start:0}});
						form01.getForm().reset();
						form01.disable();
						
						form02.getForm().reset();
						Ext.getDom('picx').src = Ext.BLANK_IMAGE_URL;
						Ext.getDom('picx').width = 1;
						Ext.getDom('picx').height = 1;
						form02.disable();
						tree.getLoader().dataUrl = urlbase+'0/galerias/vista2json/';
						tree.getRootNode().reload();
					}
				});
				
			}
			else alert('Esta galeria no se puede borrar '+this.NodoSelX);
		},
		save_foto: function(){
			this.formulario02.getForm().submit({
				method: 'post',
				url : urlbase+'0/fotos/guardarjson/',
				//waitMsg: 'Grabando...',
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		delete_foto: function(){
			var form02 = this.formulario02;
			var store2 = this.store2;
			Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar esta Foto?',function(btn){
				if(btn === 'yes'){
					Ext.Ajax.request({
						url : urlbase+'0/fotos/eliminarjson/'+form02.getComponent('imid').value,
						method: 'GET'
					});
					store2.reload();
					//this.store2.load({params:{start:0}});
						
					form02.getForm().reset();
					Ext.getDom('picx').src = Ext.BLANK_IMAGE_URL;
					Ext.getDom('picx').width = 1;
					Ext.getDom('picx').height = 1;
					form02.disable();
				}
			});
		}
	}
	
	var edicion3 = function(config){
		this.config = config;
	}
	
	edicion3.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			this.modelo = modelo;
			this.mid = mid;
			this.rid = -1;
			var rid = this.rid;
			if(this.win){
				this.win = null;
			}
			if(!this.win){
				
				this.store01 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista7json/',
					fields: ['mid','categoria','nombre'],
					remoteSort: true
				});
				this.colModel01 = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid', hidden:true},
					{header: 'Categoria', width: 100, sortable: true, dataIndex: 'categoria'},
					{header: 'Nombre', width: 220, sortable: true, dataIndex: 'nombre'}
				]);
				this.selModel01 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							rid = selRecordStore.data.mid;
							store02.load({params:{rid: rid, start:0, limit:5, sort: 'nombre', dir: 'asc', like: searchField02.getValue()}});
							
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
							
							//store5.load({params:{start:0, limit:0, like: panel03.getComponent('galerias').getValue()}});
							if(panel03.getComponent('galerias').getValue().length > 0) store5.load({params:{start:0, limit:0, like: panel03.getComponent('galerias').getValue()}});
							else store5.removeAll();
						}
					}
				});
				var searchField01 = new Ext.form.TextField({
					name: 'searchField1',
					id: 'searchField1',
					emptyText: 'Buscar en '+modelo
				});
				var store01 = this.store01;
				
				this.grid01 = new Ext.grid.GridPanel({
					border: false,
					store: this.store01,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel01,                                       
					selModel: this.selModel01,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:250,
					width:'100%',
					tbar:[{
						xtype:'textfield',
						name: 'searchField1', 
						id: 'searchField1' ,
						emptyText: 'Buscar en '+modelo,
						width : 100,
						listeners:{
							specialkey:function(elem,evnt){
								if(evnt.getKey() == 13) store01.load({params:{start:0, limit:5, sort: 'nombre', dir: 'asc', like: elem.getValue()}});
							},
							scope: this
						}
					},'-',{
						iconCls: 'add',
						tooltip: 'Adicionar un evento',
						handler: function(){ this.new_contenido('e',0); this.grid01.getSelectionModel().clearSelections(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar el evento seleccionado',
						handler: function(){ this.del_contenido('e'); }.createDelegate(this)
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 5,
						store: this.store01,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.store01.load({params:{start:0, limit:5, sort: 'nombre', dir: 'asc', like: ''}});
				
				
				this.store02 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista8json/',
					fields: ['mid','nombre'],
					remoteSort: true
				});
				this.colModel02 = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid', hidden:true},
					{header: 'Nombre', width: 220, sortable: true, dataIndex: 'nombre'}
				]);
				this.selModel02 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							rid = selRecordStore.data.mid;
					
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
							panel03.getComponent('pmid').setValue(rid);
							
							//store5.load({params:{start:0, limit:0, like: panel03.getComponent('galerias').getValue()}});
						}
					}
				});
				var searchField02 = new Ext.form.TextField({
					name: 'searchField2',
					id: 'searchField2',
					emptyText: 'Buscar en '+modelo
				});
				var store02 = this.store02;
				this.grid02 = new Ext.grid.GridPanel({
					border: false,
					store: this.store02,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel02,                                       
					selModel: this.selModel02,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:250,
					width:'100%',
					tbar:[{
						xtype:'textfield',
						name: 'searchField2', 
						id: 'searchField2' ,
						emptyText: 'Buscar en sub'+modelo,
						width : 100,
						listeners:{
							specialkey:function(elem,evnt){
								if(evnt.getKey() == 13) store02.load({params:{rid: rid, start:0, limit:5, sort: 'nombre', dir: 'asc', like: elem.getValue()}});
							},
							scope: this
						}
					},'-',{
						iconCls: 'add',
						tooltip: 'Adicionar un subevento',
						handler: function(){ 
							if(this.grid01.getSelectionModel().getSelected()){ 
								this.new_contenido('s',this.grid01.getSelectionModel().getSelected().data.mid); 
								this.grid02.getSelectionModel().clearSelections(); 
							}
							else alert('No hay un evento seleccionado!!!');
						}.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar el subevento seleccionado',
						handler: function(){ this.del_contenido('s'); }.createDelegate(this)
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 5,
						store: this.store02,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.store02.load({params:{rid: rid, start:0, limit:5, sort: 'nombre', dir: 'asc', like: ''}});
				
				this.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/'+modelo+'/vista5json/',
					fields: ['cid', 'cnombre']
				});
				var store3 = this.store3;
				this.store3.load();
				
				this.store4 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store4.load();
				
				var pcategoria_id = new Ext.form.Hidden({
					name:'pcategoria_id',
					id:"pcategoria_id"
				});
				
				var idioma_id = new Ext.form.Hidden({
					name:'idioma_id',
					id:"idioma_id"
				});
				
				
				//***************************************************************
				this.initTemplates();
				this.store5 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/galerias/vista4json/',
					fields: ['nombre'],
					remoteSort: true
				});
				
				this.store5.load({params:{start:0, limit:0, like: ''}});
				
				var store5 = this.store5;
				
				this.dataview1 = new Ext.DataView({
					store: this.store5,
					tpl: this.tpl1,
					autoHeight:true,
					multiSelect: true,
					overClass:'x-view-over',
					itemSelector:'div.thumb-wrap',
					emptyText: ''
				});
				//***************************************************************
				
				
				this.panel05 = new Ext.Panel({
					title: '<a onmouseover="this.style.cursor = \'pointer\';" onclick="sel_imgx.show();">Asociar galerias</a>',
					width : 200,   
					height: 100,
					border: true,
					autoScroll: true,
					items: [this.dataview1]
				});
				
				this.panel03 = new Ext.Panel({
					border: false,
					bodyStyle:'padding:5px',
					layout: 'form',
					items:[{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'combo',
								width:140,
								fieldLabel:'Categoria',
								name:'pcategoria',
								id:'pcategoria',
								hiddenName: 'pcategoria_id',
								forceSelection: true,
								store: this.store3,
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'cnombre',
								valueField: 'cid',
								selectOnFocus: true,
								mode: 'local',
								listeners: {
									select : function(combo,record,index ){
										if(record.get('cid')== '-1') categoriasx.show(modelo,this,store3);
									}
								}
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'combo',
								width:140,
								fieldLabel:'Idioma',  
								name:'pidioma', 
								id:'pidioma' ,
								hiddenName: 'idioma_id',
								forceSelection:true,   
								store: this.store4,   
								emptyText:'Seleccione',   
								triggerAction: 'all',   
								editable:false,
								displayField:'nombre',   
								valueField: 'id'
							}]
						}]
					},{
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name: 'pnombre', 
						id: 'pnombre' ,
						width : '95%'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'datefield',
								fieldLabel:'Comienza',  
								name:'pdesde', 
								id:'pdesde',
								format:'Y-m-d',
								emptyText: fecha_actual
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'datefield',
								fieldLabel:'Finaliza',  
								name:'phasta', 
								id:'phasta',
								format:'Y-m-d',
								emptyText: fecha_actual
							}]
						}]
					},{
						xtype: 'hidden',
						name: 'pmid', 
						id: 'pmid',
						value:'0'
					},{
						xtype: 'hidden',
						name: 'peventos_main', 
						id: 'peventos_main',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'pimagen_id', 
						id: 'pimagen_id',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'galerias', 
						id: 'galerias',
						value:''
					},{ 
						xtype: 'checkbox',
						fieldLabel:'Permite comentarios', 
						name:'pcomentarios', 
						id:'pcomentarios'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'box',
								fieldLabel:'Imagen principal', 
								autoEl: {
									tag: 'div',
									html: '<img id="pic" onclick="edicionx3.sel_contenido();" width="90" height="90" src="'+ Ext.BLANK_IMAGE_URL +'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
								}

							}]
						},{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: this.panel05
						}]
					},{ 
						xtype: 'textarea',
						width : 400,   
						height: 100,
						fieldLabel:'Introduccion', 
						name:'pintroduccion', 
						id:'pintroduccion'
					}]
				});
				var panel03 = this.panel03;
				this.panel04 = new Ext.Panel({
					border: false,
					items: [{
						xtype:'fckeditor',
						name:'fck_description',
						id:'fck_description',
						height:370,
						width:'100%',
						value:''
					}]
				});
				
				
				
				this.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['pmid','pcategoria','pdesde','phasta','pnombre','pidioma','pintroduccion','pimagen','pimagen_id','pcomentarios','fck_description','peventos_main','galerias']);
				this.formulario01 = new Ext.FormPanel({
					border: false,
					reader: this.formjreader01,
					title:'Datos del evento',
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{
						text:'Guardar',handler: function(){ this.save_contenido(modelo) }.createDelegate(this)
					}],
					layout: 'anchor',
					defaults: {
						bodyStyle:'padding:5px'
					},
					items: [this.panel03,this.panel04]
				});
				var form01 = this.formulario01;
				this.formulario01.getForm().on({
					actioncomplete: function(form, action){
						if(action.type == 'load'){
							var contact = action.result.data;
							Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.pimagen;
							if(contact.galerias.length > 0) store5.load({params:{start:0, limit:0, like: contact.galerias}});
							else store5.removeAll();

						}
					}
				});
				this.panel01 = new Ext.Panel({
					columnWidth: '.302',
					border: true,
					defaults: {
						bodyStyle:'padding:0px'
					},
					layout: 'anchor',
					items: [{
						title: 'Eventos',
						layout: 'anchor',
						items: this.grid01
					},{
						title: 'SubEventos',
						layout: 'anchor',
						items: this.grid02
					}]
				});
				
				this.panel02 = new Ext.Panel({
					border: false,
					columnWidth: '.698',
					items: this.formulario01
				});
				var config = this.config;
				this.win = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					//height:600,
					layout: 'column',
					items:[
						this.panel01,	
						this.panel02
					],
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Salir',handler: function(){ this.win.close(); }.createDelegate(this)}],
					listeners: {
						close: function() {
							config.visible = 'false';
						}
					}
				});
			} else{
				this.win.getEl().frame();
			}
			this.win.show();
		},
		initTemplates : function(){
			this.tpl1 = new Ext.XTemplate(
				'<tpl for=".">',
					'<div style="padding:5px;"><span class="x-editable"><b>{nombre}</b></span></div>',
				'</tpl>',
				'<div class="x-clear"></div>'
			);
			this.tpl1.compile();
		},
		sel_contenido: function(){
			editar2('eventos','0','1');
		},
		new_contenido: function(tipo,rid){
			this.formulario01.getForm().reset();
			Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
			if(tipo=='e'){
				this.panel03.getComponent('peventos_main').setValue(0);
			}
			else if(tipo=='s'){
				this.panel03.getComponent('peventos_main').setValue(rid);
			}
		},
		del_contenido: function(tipo){
			var form01 = this.formulario01;
			var form01x = this.panel03;
			
			var modelo = this.modelo;
			var tabs = this.tabs;
			var store01 = this.store01;
			var store02 = this.store02;
			var grid01 = this.grid01;
			var rid = 0;
			if(form01x.getComponent('pmid').value != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+modelo+'?',function(btn){
					if(btn === 'yes'){
						rid = form01x.getComponent('pmid').value;
						Ext.Ajax.request({
							url : urlbase+'0/'+modelo+'/eliminarjson/'+form01x.getComponent('pmid').value,
							method: 'GET',
							success: function ( result, request ) { 
								Ext.MessageBox.alert('Success', 'El contenido ha sido eliminado'); 
							}
						});
						
						form01.getForm().reset();
						tabs.setActiveTab(0);
						Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
						this.store5.load({params:{start:0, limit:0, like: ''}});
						if(tipo == 'e'){ 
							store01.reload();
							store02.load({params:{rid: -1, start:0, limit:5, sort: 'nombre', dir: 'asc', like: ''}});
							form01x.getComponent('peventos_main').setValue(0);
						}
						else if(tipo == 's'){ 
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+grid01.getSelectionModel().getSelected().data.mid
							});
							form01x.getComponent('pmid').setValue(rid);
							tabs.setActiveTab(0);
							
							store02.reload();
							form01x.getComponent('peventos_main').setValue(rid);
						}
					}
				});
			}
		},
		save_contenido: function(modelo){
			this.panel04.show();
			var formulario01 = this.formulario01;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarjson/',
				//waitMsg: 'Grabando...',
				success: function () {
					formulario01.getForm().reset();
					Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		}
		
	};		
	
	
	//********************************************************************************************************************
	//
	//
	//
	//													N O D O S
	//
	//
	//
	//********************************************************************************************************************
	
	
	var edicion4 = function(config){
		this.config = config;
	}
	
	edicion4.prototype = {
		lookup2 : {},
		show : function(){
			this.interface = false;
			if(!this.interface){
				this.interface = new Object();
				var interface = this.interface;
				var cargo = 0;
				this.searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar',
					listeners:{
						specialkey:function(elem,evnt){
							if(evnt.getKey() == 13){ 
								this.interface.store02.load({params:{start:0, limit:17, sort: 'nombre', dir: 'asc', like: this.searchField.getValue()}});
							}
						},
						scope: this
					}
				});
				
				var searchField = this.searchField;
				
				this.interface.store02 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/prestadores/vista2json/',
					fields: ['id','nivel','nombre','alias','pnombre'],
					remoteSort: true,
					listeners: {
						load: function(){
							if(cargo == 0){ 
								interface.grid02.getSelectionModel().selectFirstRow();
								cargo = 1;
							}
						}
					}
				});

				this.interface.store02.load({params:{start:0, limit:17, sort: 'nivel', dir: 'asc', like: this.searchField.getValue()}});
				
				this.interface.colModel02 = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'id', hidden:true},
					{header: 'Nivel', width: 40, sortable: true, dataIndex: 'nivel'},
					{header: 'Nombre', width: 120, sortable: true, dataIndex: 'nombre'},
					{header: 'Alias', width: 100, sortable: true, dataIndex: 'alias'},
					{header: 'Padre', width: 250, sortable: true, dataIndex: 'pnombre', hidden:true}
				]);
				this.interface.selModel02 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							interface.panel12.getForm().load({ 
								method:'GET',
								url : urlbase+'0/prestadores/vista3json/'+selRecordStore.data.id
							});
							interface.panel09.getComponent('mid').setValue(selRecordStore.data.id);
						}
					}
				});
				
								
				this.interface.grid02 = new Ext.grid.GridPanel({
					border: false,
					store: this.interface.store02,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.interface.colModel02,                                       
					selModel: this.interface.selModel02,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:476,
					width:'100%',
					tbar:[this.searchField,{
						text:'Buscar',
						handler : function(){
							interface.store02.load({params:{start:0, limit:17, sort: 'nivel', dir: 'asc', like: searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 17,
						store: this.interface.store02,
						displayInfo: true,
						displayMsg: 'mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				
				//this.interface.store02.load({params:{start:0, limit:17, sort: 'nivel', dir: 'asc', like: ''}});
				
				
				this.interface.panel07 = new Ext.Panel({
					columnWidth: '.3',
					border: true,
					defaults: {
						bodyStyle:'padding:0px'
					},
					layout: 'anchor',
					items: this.interface.grid02
				});
				
				this.interface.storee01 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/prestadores/vistae01json/',
					fields: ['id', 'nombre']
				});
				
				this.interface.storee01.load();
				
				this.interface.storee02 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/prestadores/vistae02json/',
					fields: ['id', 'nombre']
				});
				
				this.interface.storee02.load();
				
				this.interface.storee03 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/prestadores/vistae03json/',
					fields: ['id', 'nombre']
				});
				
				this.interface.storee03.load();
				
				this.interface.storee04 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/prestadores/vistae04json/',
					fields: ['id', 'nombre']
				});
				
				this.interface.storee04.load();
				
				this.interface.panel10 = new Ext.Panel({
					title: 'Empresa',
					height:380,
					border: true,
					bodyStyle:'padding:10px',
					layout: 'form',
					items:[{
						xtype:'textfield',
						fieldLabel:'Nit',  
						name: 'nit', 
						id: 'nit'
					},{
						xtype:'textfield',
						fieldLabel:'Razon social',  
						name: 'razonsocial', 
						id: 'razonsocial',
						width : '95%'
					},{
						xtype:'combo',
						fieldLabel:'Sector',  
						name: 'sol_nodos_empresas_sectores_id', 
						id: 'sol_nodos_empresas_sectores_id',
						hiddenName: 'sol_nodos_empresas_sectores_id2',
						forceSelection: true,
						store: this.interface.storee01,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local'
					},{
						xtype:'combo',
						fieldLabel:'Tipo',  
						name: 'sol_nodos_empresas_tipos_id', 
						id: 'sol_nodos_empresas_tipos_id',
						hiddenName: 'sol_nodos_empresas_tipos_id2',
						forceSelection: true,
						store: this.interface.storee02,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local'
					},{
						xtype:'combo',
						fieldLabel:'Tamaño',  
						name: 'sol_nodos_empresas_tamano_id', 
						id: 'sol_nodos_empresas_tamano_id',
						hiddenName: 'sol_nodos_empresas_tamano_id2',
						forceSelection: true,
						store: this.interface.storee03,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local'
					},{
						xtype:'combo',
						fieldLabel:'Actividad',  
						name: 'sol_nodos_empresas_actividades_id', 
						id: 'sol_nodos_empresas_actividades_id',
						hiddenName: 'sol_nodos_empresas_actividades_id2',
						forceSelection: true,
						store: this.interface.storee04,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local'
					}]
				});
				
				this.interface.panel11 = new Ext.Panel({
					title: 'Persona',
					height:380,
					border: true,
					bodyStyle:'padding:10px',
					layout: 'form',
					items:[{
						xtype:'textfield',
						fieldLabel:'Nombre',  
						name: 'nombrep', 
						id: 'nombrep',
						width : '95%'
					},{
						xtype:'textfield',
						fieldLabel:'Apellidos',  
						name: 'apellidosp', 
						id: 'apellidosp',
						width : '95%'
					},{
						xtype:'combo',
						fieldLabel:'Sexo',
						name:'sexo',
						id:'sexo',
						hiddenName: 'sexo2',
						forceSelection: true,
						store: new Ext.data.SimpleStore({fields:['cid','cnombre'], data:[['1','Hombre'],['2','Mujer']]}),
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						mode: 'local'
					},{
						xtype:'datefield',
						format: 'Y-m-d',
						fieldLabel:'Fecha de nacimiento',  
						name: 'fecha_nacimiento', 
						id: 'fecha_nacimiento'
					},{
						xtype: 'textarea',
						width : 250,   
						height: 60,
						fieldLabel:'Actividades', 
						name:'actividades', 
						id:'actividades'
					},{
						xtype: 'textarea',
						width : 250,   
						height: 60,
						fieldLabel:'Profesiones', 
						name:'profesiones', 
						id:'profesiones'
					},{
						xtype: 'textarea',
						width : 250,   
						height: 60,
						fieldLabel:'Cargos', 
						name:'cargos', 
						id:'cargos'
					}]
				});
				
			
				this.store_idi = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/idiomas/vista2json/',
					fields: ['id', 'nombre']
				});
				
				this.store_idi.load({params:{start:0, limit:0, like: ''}});
				
				var store_idi = this.store_idi;
				
				var conf_nivel_id = new Ext.form.Hidden({
					name:'conf_nivel_id',
					id:"conf_nivel_id"
				});
				
				this.interface.panel15 = new Ext.Panel({
					title: 'Configuracion',
					height:380,
					border: false,
					bodyStyle:'padding:10px',
					layout: 'form',
					items:[{
						xtype:'combo',
						fieldLabel:'Nivel',
						name:'conf_nivel',
						id:'conf_nivel',
						hiddenName: 'conf_nivel_id',
						forceSelection: true,
						store: new Ext.data.SimpleStore({fields:['cid','cnombre'], data:[['1','Nivel 1'],['2','Nivel 2'],['3','Nivel 3'],['4','Nivel 4']]}),
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						mode: 'local'
					},{
						xtype:'textfield',
						width : '90%',
						fieldLabel:'Dominios',
						name: 'conf_dominio', 
						id: 'conf_dominio' ,
						value : ''
					},{
						xtype:'textfield',
						fieldLabel:'Numero de nodos',
						name: 'conf_nodos', 
						id: 'conf_nodos' ,
						value : ''
					},{ 
						xtype: 'checkbox', 
						fieldLabel: 'Cambiar plantilla',
						name: 'conf_plantillas',
						id: 'conf_plantillas',
						inputValue: 1
					},{
						xtype:'textfield',
						fieldLabel:'Idiomas',
						name: 'conf_idiomas', 
						id: 'conf_idiomas' ,
						value : 'es'
					}]
				});
				
				
				this.interface.store04 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/prestadores/vista4json/',
					fields: ['cid', 'cnombre']
				});
				
				this.interface.store04.load();
				
				var nodo_nivel = nodo_nivel;
				this.interface.panel09 = new Ext.Panel({
					title: 'Datos basicos',
					border: true,
					layout: 'form',
					bodyStyle:'padding:10px',
					height:380,
					items:[{
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'idiomas', 
						id: 'idiomas',
						value:'es'
					},{ 
						xtype: 'hidden',
						name: 'id_imagen', 
						id: 'id_imagen',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'id_imagen2', 
						id: 'id_imagen2',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'nivel', 
						id: 'nivel',
						value: (nodo_nivel + 1)
					},{
						xtype:'hidden',
						name: 'dominio', 
						id: 'dominio' ,
						value : ''
					},{
						xtype:'hidden',
						name: 'plantillas', 
						id: 'plantillas' ,
						value : 'false'
					},{
						xtype:'hidden',
						name: 'nodos', 
						id: 'nodos' ,
						value : '0'
					},{
						xtype:'textfield',
						fieldLabel:'Nombre',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '95%'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Subdominio',  
								name: 'alias', 
								id: 'alias',
								allowBlank:false,
								vtype:'alphanum'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Titulo para subnodos',  
								name: 'alias2', 
								id: 'alias2'
							}]
						}]
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Email',  
								name: 'email', 
								id: 'email'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Passwd',  
								name: 'password', 
								id: 'password'
							}]
						}]
					},{
						
						xtype:'box',
						fieldLabel:'Imagen principal', 
						autoEl: {
							tag: 'div',
							html: '<img id="pic1" onclick="edicionx4.sel_contenido(\'1\');" width="60" height="60" src="'+ Ext.BLANK_IMAGE_URL +'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
						}

					},{
						xtype:'combo',
						fieldLabel:'Modelo de negocio',
						name:'sol_nodos_modelo_negocio_id',
						id:'sol_nodos_modelo_negocio_id',
						hiddenName: 'sol_nodos_modelo_negocio_id2',
						forceSelection: true,
						store: this.interface.store04,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true
					},{ 
						xtype: 'checkbox', 
						fieldLabel: 'Visible',
						name: 'visibilidad',
						id: 'visibilidad',
						inputValue: 1
					}]
				});
				
				this.interface.store10 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/prestadores/vista10json/',
					fields: ['cid', 'cnombre'],
					listeners:{
						load:function(store, records, ooptions){
							if(interface.panel12.getForm().findField("sol_core_ciudades_id").getValue() != ''){
								a = interface.panel12.getForm().findField("sol_core_ciudades_id").getValue();
								for(i = 0; i < records.length;i++){
									if(records[i].data.cid == a){ 
										interface.panel12.getForm().findField("sol_core_ciudades_id").el.dom.value = records[i].data.cnombre;
										i = records.length;
									}
								}
							}
						},
						scope: this
					}
				});
				
				this.interface.store08 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/prestadores/vista8json/',
					fields: ['cid', 'cnombre'],
					listeners:{
						load:function(store, records, ooptions){
							if(interface.panel12.getForm().findField("sol_core_regiones_id").getValue() != ''){
								a = interface.panel12.getForm().findField("sol_core_regiones_id").getValue();
								for(i = 0; i < records.length;i++){
									if(records[i].data.cid == a){ 
										interface.panel12.getForm().findField("sol_core_regiones_id").el.dom.value = records[i].data.cnombre;
										i = records.length;
									}
								}
							}
						},
						scope: this
					}
				});
				
				this.interface.store07 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/prestadores/vista7json/',
					fields: ['cid', 'cnombre']
				});
				
				this.interface.store07.load();
				
				this.interface.panel13 = new Ext.Panel({
					title: 'Datos de ubicacion',
					border: true,
					height:380,
					bodyStyle:'padding:10px',
					layout: 'form',
					items:[{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Telefono',  
								name: 'telefono', 
								id: 'telefono'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Fax',  
								name: 'fax', 
								id: 'fax'
							}]
						}]
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Celular',  
								name: 'celular', 
								id: 'celular'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Email 2',  
								name: 'email2', 
								id: 'email2'
							}]
						}]
					},{
						xtype:'textfield',
						fieldLabel:'Direccion',  
						name: 'direccion', 
						id: 'direccion' ,
						width : '95%'
					},{
						xtype:'textfield',
						fieldLabel:'Barrio',  
						name: 'barrio', 
						id: 'barrio'
					},{
						xtype:'combo',
						fieldLabel:'Pais',  
						name: 'sol_core_paises_id', 
						id: 'sol_core_paises_id',
						hiddenName: 'sol_core_paises_id2',
						forceSelection: true,
						store: this.interface.store07,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						listeners:{
							select:function(combo, record, index){
								this.interface.store08.load({params:{start:0, sel:record.data.cid}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Region',  
						name: 'sol_core_regiones_id', 
						id: 'sol_core_regiones_id',
						hiddenName: 'sol_core_regiones_id2',
						forceSelection: true,
						store: this.interface.store08,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						mode: 'local',
						listeners:{
							select:function(combo, record, index){
								this.interface.store10.load({params:{start:0, sel:record.data.cid}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Ciudad',  
						name: 'sol_core_ciudades_id', 
						id: 'sol_core_ciudades_id',
						hiddenName: 'sol_core_ciudades_id2',
						forceSelection: true,
						store: this.interface.store10,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						mode: 'local'
					}]
				});
				
				
				
				this.interface.panel08 = new Ext.TabPanel({
					height:'100%',
					width:'100%',
					activeTab: 0,
					items:[this.interface.panel09,this.interface.panel13,this.interface.panel10,this.interface.panel11,this.interface.panel15]
				});
				
				this.interface.paneljreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','sol_nodos_main_id','nivel','visibilidad','creacion','nombre','dominio','alias','alias2','email','password','email2','telefono','fax','celular','direccion','barrio','sol_core_paises_id','sol_core_regiones_id','sol_core_ciudades_id','sol_nodos_modelo_negocio_id','id_imagen','imagen','id_imagen2','imagen2','idiomas','archivo1','sol_nodos_main_id1','archivo2','sol_nodos_main_id2','nodos','plantillas','nit','razonsocial','sol_nodos_empresas_sectores_id','sol_nodos_empresas_tipos_id','sol_nodos_empresas_tamano_id','sol_nodos_empresas_actividades_id','nombrep','apellidosp','sexo','fecha_nacimiento','actividades','profesiones','cargos']);
				this.interface.panel12 = new Ext.FormPanel({
					columnWidth: '.7',
					reader: this.interface.paneljreader01,
					border: false,
					disabled: true,
					defaults: {
						bodyStyle:'padding:0px'
					},
					items: this.interface.panel08,
					tbar: [{
						id: 'addBoton',
						iconCls: 'add',
						tooltip: 'Adicionar',
						handler: function(){ this.new_contenido(); }.createDelegate(this)
					},{
						id: 'delBoton',
						iconCls: 'remove',
						tooltip: 'Eliminar',
						handler: function(){ this.del_contenido(); }.createDelegate(this)
					}],
					buttons:[
						{text:'Guardar', handler: function(){ this.save_contenido() }.createDelegate(this)},{text:'Salir',handler: function(){ this.interface.win.close(); }.createDelegate(this)}
					]
				});
				
				var dataview_idi = this.dataview_idi;
				
				this.interface.panel12.getForm().on({
					actioncomplete: function(form, action){
						if(action.type == 'load'){
							var contact = action.result.data;
							if(contact.sol_nodos_main_id1 != 0) Ext.getDom('pic1').src = urlbase+'tmp/sol_'+contact.sol_nodos_main_id1+'/thumbnails/'+contact.archivo1;
							else Ext.getDom('pic1').src = Ext.BLANK_IMAGE_URL;
							interface.store08.load({params:{start:0, sel:contact.sol_core_paises_id}});
							interface.store10.load({params:{start:0, sel:contact.sol_core_regiones_id}});
							interface.panel12.getForm().findField("conf_nivel").setValue(interface.panel12.getForm().findField("nivel").getValue());
							interface.panel12.getForm().findField("conf_idiomas").setValue(interface.panel12.getForm().findField("idiomas").getValue());
							interface.panel12.getForm().findField("conf_dominio").setValue(contact.dominio);
							interface.panel12.getForm().findField("conf_nodos").setValue(contact.nodos);
							interface.panel12.getForm().findField("conf_plantillas").setValue(contact.plantillas);
							interface.panel12.enable();
							if(conf_nodos <= conf_nnodos) Ext.getCmp('addBoton').setDisabled(true);
							if(avil == '0') Ext.getCmp('delBoton').setDisabled(true);
						}
					}
				});
				
				this.interface.win = new Ext.Window({
					title: 'Administracion',
					closeAction: 'close',
					width:780,
					height:510,
					layout: 'column',
					items: [this.interface.panel07,this.interface.panel12],
					listeners: {
						close: function() {
							this.interface = false;
						}
					}
				});
			}else{
				this.interface.win.getEl().frame();
			}
			this.interface.win.show();
			interface.panel13.show();
			interface.panel10.show();
			interface.panel11.show();
			interface.panel09.show();
			if(avil == '0'){ 
				this.interface.panel15.hide();
				this.interface.panel15.disable();
			}
		},
		save_contenido: function(){
			var interface = this.interface;
			

			if(interface.panel12.getForm().findField("conf_plantillas").getEl()){ 
				interface.panel12.getForm().findField("idiomas").setValue(interface.panel12.getForm().findField("conf_idiomas").getValue());
				interface.panel12.getForm().findField("nivel").setValue(interface.panel12.getForm().findField("conf_nivel").getValue());
				interface.panel12.getForm().findField("nodos").setValue(interface.panel12.getForm().findField("conf_nodos").getValue());
				interface.panel12.getForm().findField("plantillas").setValue(interface.panel12.getForm().findField("conf_plantillas").getValue());
				interface.panel12.getForm().findField("dominio").setValue(interface.panel12.getForm().findField("conf_dominio").getValue());
			}
			this.interface.panel12.getForm().submit({
				method: 'post',
				url : urlbase+'0/prestadores/guardarjson/',
				waitMsg: 'Grabando...',
				success: function(){ 
					var mid = interface.panel12.getForm().findField('mid').getValue();
					interface.grid02.getSelectionModel().clearSelections();
					interface.store02.reload();
					if(mid == '0'){ 
						conf_nnodos++;
						if(conf_nnodos > conf_nodos) Ext.getCmp('addBoton').setDisabled(true);
					}
					Ext.Ajax.request({
						url : urlbase+'0/prestadores/veridjson/',
						method: 'POST',
						success: function ( result, request ) { 
							//interface.panel12.getForm().findField('mid').setValue(result.responseText);
							var total = interface.grid02.getStore().getTotalCount();
							var i;
							for(i = 0;i<total;i++){
								if(result.responseText == interface.grid02.getStore().getAt(i).id){ 
									interface.grid02.getSelectionModel().selectRow(i);
									i = total;
									Ext.MessageBox.alert('Mensaje','Guardado');
								}
							}
						},
						params: { 
							email: interface.panel12.getForm().findField("email").getValue(),
							alias: interface.panel12.getForm().findField("alias").getValue(), 
							passwd: interface.panel12.getForm().findField("password").getValue()
						}
					});
					
					
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		new_contenido: function(){
			this.interface.grid02.getSelectionModel().clearSelections();
			this.interface.panel12.getForm().reset();
			this.interface.panel12.getForm().findField('mid').setValue('0');
			Ext.getDom('pic1').src = Ext.BLANK_IMAGE_URL;
			this.interface.panel09.show();
		},
		del_contenido: function(){
			var interface = this.interface;
			if(interface.panel12.getForm().findField("idiomas").getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este Nodo?',function(btn){
					if(btn === 'yes'){
						Ext.Ajax.request({
							url : urlbase+'0/prestadores/eliminarjson/'+interface.panel12.getForm().findField("mid").getValue(),
							method: 'GET',
							success: function ( result, request ) { 
								interface.panel12.getForm().reset();
								interface.panel12.getForm().findField('mid').setValue('0');
								Ext.getDom('pic1').src = Ext.BLANK_IMAGE_URL;
								interface.grid02.getSelectionModel().clearSelections();
								interface.grid02.getSelectionModel().selectRow(0);
								/*interface.store02.reload();
								interface.panel12.disable();*/
							}
						});
						
					}
				});
			}
		},
		sel_contenido: function(otro){
			editar2('galerias','0','1',otro);
		}
	};		
	

	// Videos


	var ImageChooser = function(){
	}

	ImageChooser.prototype = {
		lookup2 : {},
		
		show : function(){
			this.win = null;
			if(!this.win){
				this.initTemplates();
				this.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/galerias/vista1json/', 
					fields: ['id', 'nombre','detalle','archivo','archivos'],
					remoteSort: true
				});
				
				this.formatData2 = function(data){
					this.lookup2[data.id] = data;
					return data;
				};
				
				this.dataview2 = new Ext.DataView({
					store: this.store2,
					tpl: this.tpl2,
					autoHeight: true,
					multiSelect: true,
					overClass:'x-view-over',
					itemSelector:'div.thumb-wrap',
					emptyText: '',
					prepareData: this.formatData2.createDelegate(this)
				});
				
				this.store2.load();
								
				this.panel = new Ext.Panel({
					id: 'img-chooser-view',
					autoScroll: true,
					width:'100%',
					height: 400,
					items: this.dataview2,
					autoScroll: true,
					buttons:[{
						text:'Seleccionar',handler: function(){ this.vervisor1() }.createDelegate(this)
					}]
				});
				
				this.win = new Ext.Window({		//step 3
					title:'Seletor de imagenes',
					layout:'column',
					closeAction: 'close',
					width:700,
					height:480,
					items: [this.panel]
				});
			}
			this.win.show();
		},
		initTemplates : function(){
			this.tpl2 = new Ext.XTemplate(
				'<tpl for=".">',
					'<div class="thumb-wrap" id="{id}">',
						'<div class="thumb"><img src="'+urlbase+'tmp/sol_'+nav_id+'/thumbnails/{archivo}" title="{nombre}"></div>',
						'<div class="info">',
							'<span class="x-editable"><b>{nombre}</b></span>',
							'<span class="x-editable">{archivos} Fotos</span>',
						'</div>',
					'</div>',
				'</tpl>',
				'<div class="x-clear"></div>'
			);
			this.tpl2.compile();
		},
		vervisor1 : function(){
			var selNode = this.dataview2.getSelectedNodes(); 
			var datax = ''; 
			if(selNode.length > 0){
				var datax = ''; 
				if(selNode && selNode.length > 0){
					var i = 0;
					while(i < selNode.length){
						selNodex = selNode[i];
						var data = this.lookup2[selNodex.id];
						datax = datax + data.id;
						if(i < selNode.length - 1) datax = datax + ',';
						i++;
					}
				}
			}
			edicionx3.panel03.getComponent('galerias').setValue(datax);
			if(datax.length > 0) edicionx3.store5.load({params:{start:0, limit:0, like: datax}});
			else edicionx3.store5.removeAll();
			this.win.close();
		}
	}
	
	var ImageUploader = function(){
	}

	ImageUploader.prototype = {
		lookup2 : {},
		
		show : function(nodo_sel,tipo){
			this.win = null;
			this.tipo = tipo;
			this.formulario01 = null;
			if(!this.win){
				this.formulario01 = new Ext.FormPanel({
					fileUpload: true,
					bodyStyle:'padding: 10px',
					width:'100%',
					items:[   
						{ 
							xtype:'textfield',
							fieldLabel:'Archivo',  
							name: 'archivo', 
							id: 'archivo' ,
							width : '96%',
							inputType:'file'
						},{ 
							xtype: 'hidden',
							name: 'mid', 
							id: 'mid',
							value:'0'
						}
					] ,
					defaults:{
						iconAlign: 'top'
					},
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Subir',handler: function(){ this.upload_image(nodo_sel,tipo); }.createDelegate(this)},{text:'Salir',handler: function(){ this.win.close(); }.createDelegate(this)}]
				});
				
				this.win = new Ext.Window({		//step 3
					title:'Seletor de imagenes',
					layout:'column',
					closeAction: 'close',
					width:400,
					items: [this.formulario01]
				});
			}
			this.win.show();
		},
		
		upload_image: function(nodo_sel,tipo){
			var formu = this.win;
			this.formulario01.getForm().submit({
				url: urlbase+'includes/upload.php?p='+nodo_sel,
  				success: function () {
					if(tipo == 1) sel_img.store2.load({params:{start:nodo_sel}});
					else edicion2.store2.reload();
					formu.close();
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		}
	}
	
	var ImagesUploader = function(){
	}

	ImagesUploader.prototype = {
		lookup2 : {},
		
		show : function(nodo_sel,tipo){
			this.nodo_sel = nodo_sel;
			this.tipo = tipo;
			this.win = null;
			nodo_selx = nodo_sel;
			if(!this.win){
									
				this.win = new Ext.Window({		//step 3
					title:'Seletor de imagenes',
					closeAction: 'hide',
					width:730,
					height:530,
					listeners: {
						'hide': {fn:this.showDetails, scope:this, buffer:100},
						'close': {fn:this.showDetails, scope:this, buffer:100}
					}
				});
			}
			this.win.html = '<applet name="jumpLoaderApplet" code="jmaster.jumploader.app.JumpLoaderApplet.class" archive="'+urlbase+'includes/mediautil_z.jar,'+urlbase+'includes/sanselan_z.jar,'+urlbase+'includes/jumploader_z.jar"	width="715"	height="500"	mayscript><param name="uc_sendImageMetadata" value="true"/><param name="uc_imageEditorEnabled" value="true"/><param name="uc_useLosslessJpegTransformations" value="true"/><param name="uc_uploadUrl" value="'+urlbase+'includes/jupload-post.php?p='+nodo_sel+'"/><param name="uc_uploadScaledImages" value="true"/><param name="uc_scaledInstanceNames" value="large"/><param name="uc_scaledInstanceDimensions" value="604x450"/><param name="uc_scaledInstanceQualityFactors" value="700"/><param name="ac_fireUploaderFileAdded" value="true"/><param name="ac_fireUploaderFileStatusChanged" value="true"/><param name="uc_fileNamePattern" value="^.+\.(?i)((jpg)|(jpe)|(jpeg)|(gif)|(png))$"/><param name="vc_fileNamePattern" value="^.+\.(?i)((jpg)|(jpe)|(jpeg)|(gif)|(png))$"/><param name="vc_disableLocalFileSystem" value="false"/><param name="vc_mainViewFileTreeViewVisible" value="true"/><param name="vc_mainViewFileListViewVisible" value="true"/><param name="uc_imageRotateEnabled" value="true"/><param name="uc_scaledInstancePreserveMetadata" value="true"/></applet><form name="debugForm" style="display:none;"><p>Events:<br><textarea name="txtEvents" style="width:100%; font:10px monospace" rows="10" wrap="off" id="txtEvents"></textarea></p></form><div id="fileLinks" style="display:none;"></div>';
			this.win.show();
		},
		showDetails: function(){
			if(this.tipo == 1) sel_img.store2.load({params:{start:this.nodo_sel}});
			else edicion2.store2.load({params:{start:this.nodo_sel}});
		}
	}
	
	//**************************************************************************************************************
	//**************************************************************************************************************
	//
	//													VIDEOS
	//
	//**************************************************************************************************************
	//**************************************************************************************************************

	var edicion5 = function(config){
		this.config = config;
	}
	
	edicion5.prototype = {
		show : function(){
			this.interface = false;
			if(!this.interface){
				var config = this.config;
				this.interface = new Object();
				var interface = this.interface;
				var cargo = 0;
				
				this.searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar',
					listeners:{
						specialkey:function(elem,evnt){
							if(evnt.getKey() == 13){ 
								interface.store01.load({params:{start:0, limit:17, sort: 'nombre', dir: 'asc', like: this.searchField.getValue()}});
							}
						},
						scope: this
					}
				});
				
				var searchField = this.searchField;
				
				this.interface.store01 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/videos/vista2json/',
					fields: ['mid','nombre','cnombre'],
					remoteSort: true,
					listeners: {
						load: function(){
							if(cargo == 0){ 
								interface.grid01.getSelectionModel().selectFirstRow();
								cargo = 1;
							}
						}
					}
				});
				this.interface.colModel01 = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid', hidden:true},
					{header: 'Nombre', width: 160, sortable: true, dataIndex: 'nombre'},
					{header: 'Categoria', width: 160, sortable: true, dataIndex: 'cnombre'}
				]);
				this.interface.selModel01 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							rid = selRecordStore.data.mid;
							interface.panel02.getForm().load({ 
								method:'GET',
								url : urlbase+'0/videos/vista4json/'+selRecordStore.data.mid
							});
							
						}
					}
				});
				
				this.interface.grid01 = new Ext.grid.GridPanel({
					border: false,
					store: this.interface.store01,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.interface.colModel01,                                       
					selModel: this.interface.selModel01,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:410,
					columnWidth: '.3',
					tbar:[
						 this.searchField,
						{
							text:'Buscar',
							handler : function(){
								interface.store01.load({params:{start:0, limit:17, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
							}
						}
					],
					bbar: new Ext.PagingToolbar({
						pageSize: 5,
						store: this.interface.grid01,
						displayInfo: true,
						displayMsg: 'Videos mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				interface.store01.load({params:{start:0, limit:17, sort: 'nombre', dir: 'asc', like: this.searchField.getValue()}});
				
				this.interface.panel01 = new Ext.Panel({
					columnWidth: '.25',
					height: 420,
					border: true,
					items: this.interface.grid01
				});
				
				this.interface.store02 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/videos/vista3json/',
					fields: ['cid', 'cnombre']
				});
				this.interface.store02.load();
				
				var sol_videos_categoria_id2 = new Ext.form.Hidden({
					name:'sol_videos_categoria_id2',
					id:"sol_videos_categoria_id2",
					value: '0'
				});
				
				this.interface.store03 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.interface.store03.load();
				
				var sol_nodos_idiomas_id2 = new Ext.form.Hidden({
					name:'sol_nodos_idiomas_id2',
					id:"sol_nodos_idiomas_id2"
				});
				
				var principal2 = new Ext.form.Hidden({
					name:'principal2',
					id:"principal2"
				});
				
				this.interface.formjreader02 = new Ext.data.JsonReader({root: 'data'}, ['mid','sol_nodos_idiomas_id','sol_videos_categoria_id','vnombre','archivo','introduccion','principal']);
				this.interface.panel02 = new Ext.FormPanel({
					title: 'Datos del Video',
					columnWidth: '.75',
					reader: this.interface.formjreader02,
					height: 350,
					border: true,
					layout: 'form',
					bodyStyle:'padding: 10px',
					tbar:[{
						iconCls: 'add',
						tooltip: 'Adicionar un video',
						handler: function(){ 
							this.interface.grid01.getSelectionModel().clearSelections(); 
							this.interface.panel02.getForm().reset();
							Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
						}.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar el video',
						handler: function(){ this.del_contenido('s'); }.createDelegate(this)
					}],
					items:[{
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{
						xtype:'textfield',
						fieldLabel:'Nombre',  
						name: 'vnombre', 
						id: 'vnombre',
						width:405
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Codigo youtube',  
								name: 'archivo', 
								id: 'archivo',
								width:130,
								listeners:{
									change:function(newValue,oldValue){
										Ext.getDom('pic').src = 'http://img.youtube.com/vi/'+newValue.getValue()+'/2.jpg';
									},
									scope: this
								}
							},{
								xtype:'combo',
								fieldLabel:'Idioma',
								name:'sol_nodos_idiomas_id',
								id:'sol_nodos_idiomas_id',
								hiddenName: 'sol_nodos_idiomas_id2',
								width:130,
								forceSelection: true,
								store: this.interface.store03,
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'nombre',
								valueField: 'id',
								selectOnFocus: true
							},{
								xtype:'combo',
								fieldLabel:'Categoria',
								name:'sol_videos_categoria_id',
								id:'sol_videos_categoria_id',
								hiddenName: 'sol_videos_categoria_id2',
								width:130,
								forceSelection: true,
								store: this.interface.store02,
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'cnombre',
								valueField: 'cid',
								selectOnFocus: true,
								mode: 'local',
								listeners: {
									select : function(combo,record,index ){
										if(record.get('cid')== '-1') categoriasx.show('videos',this,interface.store02);
									}
								}
							},{
								xtype:'combo',
								fieldLabel:'Es principal',
								name:'principal',
								id:'principal',
								hiddenName: 'principal2',
								width:130,
								forceSelection: true,
								store: new Ext.data.SimpleStore({fields:['cid','cnombre'], data:[['1','Si'],['0','No']]}),
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'cnombre',
								valueField: 'cid',
								selectOnFocus: true,
								mode: 'local'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'box',
								fieldLabel:'Imagen previa', 
								autoEl: {
									tag: 'div',
									html: '<img id="pic" width="120" height="120" onclick="edicionx5.vervisor1();" src="'+ Ext.BLANK_IMAGE_URL +'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
								}
							}]
						}]
					},{ 
						xtype: 'textarea',
						width : 405,   
						height: 100,
						fieldLabel:'Introduccion', 
						name:'introduccion', 
						id:'introduccion'
					}],
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(); }.createDelegate(this)}]
				});
				
				this.interface.panel02.getForm().on({
					actioncomplete: function(form, action){
						var video = interface.panel02.getForm().findField('archivo').getValue();
						if(action.type == 'load'){
							var contact = action.result.data;
							if(video.length > 8) Ext.getDom('pic').src = 'http://img.youtube.com/vi/'+video+'/2.jpg';
							else Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
						}
					}
				});
				
				this.interface.win = new Ext.Window({
					title: 'Editar videos',
					closeAction: 'close',
					width:780,
					height:480,
					layout: 'column',
					items:[this.interface.panel01,this.interface.panel02],
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Salir',handler: function(){ this.interface.win.close(); }.createDelegate(this)}],
					listeners: {
						close: function() {
							interface = null;
							config.visible = 'false';
							//window.location = window.location;
						}
					}
				});
				
				this.interface.win.show();
			}
		},
		vervisor1: function(){
			if(this.interface.tableWindow3){
				this.interface.tableWindow3 = null;
			}
			if(!this.interface.tableWindow3){
				this.interface.tableWindow3 = new Ext.Window({
					title: 'Video',
					closeAction: 'close',
					width:440,
					height:376
				});
				var video = this.interface.panel02.getForm().findField('archivo').getValue();
				this.interface.tableWindow3.html = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/'+video+'&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+video+'&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>';
				this.interface.tableWindow3.show();
			}
		},
		save_contenido: function(modelo){
			var interface = this.interface;
			interface.panel02.getForm().submit({
				method: 'post',
				url : urlbase+'0/videos/guardarjson/',
				//waitMsg: 'Grabando...',
				success: function () {

					var mid = interface.panel02.getForm().findField('mid').getValue();
					interface.grid01.getSelectionModel().clearSelections();
					interface.store01.reload();
					
					Ext.Ajax.request({
						url : urlbase+'0/videos/veridjson/',
						method: 'POST',
						success: function ( result, request ) { 
							//interface.panel12.getForm().findField('mid').setValue(result.responseText);
							var total = interface.grid01.getStore().getTotalCount();
							var i;
							for(i = 0;i<total;i++){
								if(result.responseText == interface.grid01.getStore().getAt(i).id){ 
									interface.grid01.getSelectionModel().selectRow(i);
									i = total;
								}
							}
						},
						params: { 
							nombre: interface.panel02.getForm().findField("vnombre").getValue(),
							archivo: interface.panel02.getForm().findField("archivo").getValue()
						}
					});
					
					
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
			this.interface.store01.load({params:{start:0, limit:5}});
		},
		del_contenido: function(){
			var interface = this.interface;
			if(interface.panel02.getForm().findField('mid').getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) Video?',function(btn){
					if(btn === 'yes'){
						Ext.Ajax.request({
							url : urlbase+'0/videos/eliminarjson/'+interface.panel02.getForm().findField('mid').getValue(),
							method: 'GET'
						});
						interface.store01.reload();
						interface.panel02.getForm().reset();
						Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
						interface.grid01.getSelectionModel().selectRow(0);
					}
				});
			}
		}
	}
	
	var edicion6 = function(config){
		this.config = config;
	}
	
	edicion6.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			if(this.tableWindow3){
				this.tableWindow3 = null;

			}
			if(!this.tableWindow3){
				this.modelo = modelo;
				this.store1 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/'+modelo+'/vista5json/',
					fields: ['cid', 'cnombre']
				});
				this.store1.load();
				
				var store1 = this.store1;
				
				this.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store2.load();
				
				this.categoria_id = new Ext.form.Hidden({
					name:'categoria_id',
					id:"categoria_id"
				});
				
				var categoria_id = this.categoria_id;
				
				var idioma_id = new Ext.form.Hidden({
					name:'idioma_id',
					id:"idioma_id"
				});
				
				var tipo_id = new Ext.form.Hidden({
					name:'tipo_id',
					id:"tipo_id"
				});
				
				this.toolbar01 = new Ext.Toolbar({
					items: [
						{
							iconCls: 'add',
							tooltip: 'Adicionar',
							handler: function(){ this.new_contenido(); }.createDelegate(this)
						},{
							iconCls: 'remove',
							tooltip: 'Eliminar',
							handler: function(){ this.del_contenido(); }.createDelegate(this)
						}
					]
				});
				this.panel03 = new Ext.Panel({
					border: true,

					layout: 'form',
					items:[{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'combo',
								fieldLabel:'Categoria',
								name:'categoria',
								id:'categoria',
								hiddenName: 'categoria_id',
								forceSelection: true,
								store: this.store1,
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'cnombre',
								valueField: 'cid',
								selectOnFocus: true,
								mode: 'local',
								listeners: {
									select : function(combo,record,index ){
										if(record.get('cid')== '-1') categoriasx.show('productos',this,store1);
									}
								}
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'combo',
								fieldLabel:'Tipo',
								name:'tipo',
								id:'tipo',
								hiddenName: 'tipo_id',
								forceSelection: true,
								store: new Ext.data.SimpleStore({fields:['cid','cnombre'], data:[['1','Producto'],['2','Servicio']]}),
								emptyText:'Seleccione',
								triggerAction: 'all',
								editable: false,
								displayField:'cnombre',
								valueField: 'cid',
								selectOnFocus: true,
								mode: 'local'
							}]
						}]

					},{ 
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '90%'
					},{ 
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'imagen_id', 
						id: 'imagen_id',
						value:'0'
					},{ 
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'idioma', 
						id:'idioma' ,
						hiddenName: 'idioma_id',
						forceSelection:true,   
						store: this.store2,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype: 'textarea',
								width : 250,   
								height: 100,
								fieldLabel:'Introduccion', 
								name:'introduccion', 
								id:'introduccion'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							bodyStyle: 'padding: 0px 0px 0px 40px',
							items: [{
								xtype:'box',
								autoEl: {
									tag: 'div',
									html: '<img id="pic" onclick="edicionx.sel_contenido();" width="90" height="90" src="'+ Ext.BLANK_IMAGE_URL+'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
								}
							}]
						}]
					},{   
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
									xtype: 'checkbox',
									fieldLabel:'Comentarios', 
									name:'comentarios', 
									id:'comentarios'    
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
									xtype: 'checkbox',
									fieldLabel:'Principal',  
									name:'principal', 
									id:'principal'  
							}]
						}]
					}]
				});	
				this.panel04 = new Ext.Panel({
					border: true,
					items: [{
						xtype:'fckeditor',
						name:'fck_description',
						id:'fck_description',
						height:370,
						width:'100%',
						value:''
					}]
				});
				this.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','categoria','creacion','tipo','nombre','idioma','introduccion','imagen','imagen_id','comentarios','principal','fck_description']);
				
			
				this.formulario01 = new Ext.FormPanel({
					reader : this.formjreader01,
					title:'Formulario',
					height:'100%',
					width:'100%',
					autoHeight : true,
					autoScroll: true,
					layout: 'form',
					defaults: {
						bodyStyle:'padding:5px',
						iconAlign: 'top'
					},
					items:[   
						this.panel03,this.panel04
					] ,
					tbar: this.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(modelo,mid); }.createDelegate(this)},{text:'Salir',handler: function(){ this.tableWindow3.close(); }.createDelegate(this)}]
				});
				//************************************************
				this.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista7json/',
					fields: ['mid','categoria','creacion','tipo','nombre','idioma','comentarios','principal'],
					remoteSort: true
				});
				this.colModel = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid'},
					{header: 'Creacion', width: 80, sortable: true, dataIndex: 'creacion'},
					{header: 'Categoria', width: 100, sortable: true, dataIndex: 'categoria'},
					{header: 'Nombre', width: 420, sortable: true, dataIndex: 'nombre'},
					{header: 'Tipo', width: 100, sortable: true, dataIndex: 'tipo'},
					{header: 'Idioma', width: 100, sortable: true, dataIndex: 'idioma'}
				]);
				var form01 = this.formulario01;
				this.selModel = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
							//form01.getComponent('mid').setValue(selRecordStore.data.mid);
							tabs.setActiveTab(0);
						}
					}

				});

				this.searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar en '+modelo
				});
				
				var searchField = this.searchField;
				
				var store3 = this.store3;
				this.grid = new Ext.grid.GridPanel({
					store: this.store3,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel,                                       
					selModel: this.selModel,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:450,
					width:'100%',
					tbar:[searchField, '-',{
						text:'Buscar',
						handler : function(){
							store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 12,
						store: this.store3,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
				//***************************************************
				this.formulario02 = new Ext.Panel({
					title:'Consulta',
					items: [this.grid]
				});
				
				this.tabs = new Ext.TabPanel({
					items: [this.formulario01,this.formulario02] //le agregamos el primer tab
				});
				var tabs = this.tabs;
				var config = this.config;
				var raiz = this;
				this.tableWindow3 = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					items: this.tabs,
					listeners: {
						close: function() {
							raiz.config.visible = 'false';
							raiz.store1 = null;
							raiz.store2 = null;
							raiz.store3 = null;
							raiz.toolbar01 = null;
							raiz.formulario01 = null;
							raiz.formulario02 = null;
							raiz.grid = null;
						}
					}
				});
			}else{
				this.tableWindow3.getEl().frame();
			}
			this.tableWindow3.show();
			this.formulario01.show();
			
			this.formulario01.getForm().load({ 
				method:'GET',
				url : urlbase+'0/'+modelo+'/vista6json/'+mid
			});
			this.formulario01.getForm().on({
				actioncomplete: function(form, action){
					if(action.type == 'load'){
						var contact = action.result.data;
						Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.imagen;
					}
				}
			});
			
		},
		save_contenido: function(modelo,mid){
			var formu = this.tableWindow3;
			var formulario01 = this.formulario01;
			var store3 = this.store3;
			var searchField = this.searchField;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarjson/'+mid,
				//waitMsg: 'Grabando...',
				success: function () {
					formulario01.getForm().reset();
					store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
					Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
			//alert(this.formulario01.getComponent('mid').getValue());
		},
		new_contenido: function(){
			this.formulario01.getForm().reset();
			Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
		},
		del_contenido: function(){
			var form01 = this.formulario01;
			var modelo = this.modelo;
			if(form01.getForm().findField('mid').getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+modelo+'?',function(btn){
					if(btn === 'yes'){
						//alert(form01.getComponent('mid').value); 
						Ext.Ajax.request({
							url : urlbase+'0/'+modelo+'/eliminarjson/'+form01.getForm().findField('mid').getValue(),
							method: 'GET',
							success: function ( result, request ) { 
								form01.getForm().reset();
								Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
							}
						});
						form01.getForm().reset();
					}
				});
			}
		},
		sel_contenido: function(){
			editar2('galerias','0','1');
		}
	};
	
	
	//**************************************************************************************************************
	//**************************************************************************************************************
	//
	//													ENLACES
	//
	//**************************************************************************************************************
	//**************************************************************************************************************
	
	var edicion7 = function(config){
		this.config = config;
	}
	
	edicion7.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			if(this.tableWindow3){
				this.tableWindow3 = null;

			}
			if(!this.tableWindow3){
				this.modelo = modelo;
				
				this.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store2.load();
	
				var idioma_id = new Ext.form.Hidden({
					name:'idioma_id',
					id:"idioma_id"
				});
				
				var tipo_id = new Ext.form.Hidden({
					name:'tipo_id',
					id:"tipo_id"
				});
				
				this.toolbar01 = new Ext.Toolbar({
					items: [
						{
							iconCls: 'add',
							tooltip: 'Adicionar',
							handler: function(){ this.new_contenido(); }.createDelegate(this)
						},{
							iconCls: 'remove',
							tooltip: 'Eliminar',
							handler: function(){ this.del_contenido(); }.createDelegate(this)
						}
					]
				});
				this.panel03 = new Ext.Panel({
					border: true,

					layout: 'form',
					items:[{ 
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '90%'
					},{ 
						xtype:'textfield',
						fieldLabel:'URL',  
						name: 'url', 
						id: 'url' ,
						width : '90%'
					},{ 
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{ 
						xtype: 'hidden',
						name: 'imagen_id', 
						id: 'imagen_id',
						value:'0'
					},{ 
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'idioma', 
						id:'idioma' ,
						hiddenName: 'idioma_id',
						forceSelection:true,   
						store: this.store2,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id',
						mode: 'local'
					},{
						xtype:'combo',
						fieldLabel:'Tipo',
						name:'tipo',
						id:'tipo',
						hiddenName: 'tipo_id',
						forceSelection: true,
						store: new Ext.data.SimpleStore({fields:['cid','cnombre'], data:[['1','Laterales'],['4','Pie de pagina']]}),
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						mode: 'local'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype: 'textarea',
								width : 170,   
								height: 100,
								fieldLabel:'Introduccion', 
								name:'detalle', 
								id:'detalle'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							bodyStyle: 'padding: 0px 0px 0px 40px',
							items: [{
								xtype:'box',
								autoEl: {
									tag: 'div',
									html: '<img id="pic" onclick="edicionx.sel_contenido();" width="90" height="90" src="'+ Ext.BLANK_IMAGE_URL+'" style="background-color:#CCC;padding:5px;margin-bottom:10px;cursor:pointer;" />'
								}
							}]
						}]
					}]
				});	
				
				this.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','tipo','idioma','nombre','url','detalle','imagen','imagen_id']);
				
			
				this.formulario01 = new Ext.FormPanel({
					reader : this.formjreader01,
					title:'Formulario',
					columnWidth: '.75',
					height:'100%',
					width:'100%',
					autoHeight : true,
					autoScroll: true,
					layout: 'form',
					defaults: {
						bodyStyle:'padding:5px',
						iconAlign: 'top'
					},
					items: this.panel03,
					tbar: this.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(modelo,mid); }.createDelegate(this)},{text:'Salir',handler: function(){ this.tableWindow3.close(); }.createDelegate(this)}]
				});
				
				var cargo = 0;
				
				this.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista7json/',
					fields: ['mid','tipo','nombre','idioma'],
					remoteSort: true,
					listeners: {
						load: function(){
							if(cargo == 0){ 
								grid.getSelectionModel().selectFirstRow();
								cargo = 1;
							}
						}
					}
				});
				this.colModel = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid'},
					{header: 'Nombre', width: 420, sortable: true, dataIndex: 'nombre'},
					{header: 'Tipo', width: 100, sortable: true, dataIndex: 'tipo'},
					{header: 'Idioma', width: 100, sortable: true, dataIndex: 'idioma'}
				]);
				var form01 = this.formulario01;
				this.selModel = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
						}
					}

				});

				var searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar en '+modelo
				});
				var store3 = this.store3;
				this.grid = new Ext.grid.GridPanel({
					store: this.store3,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel,                                       
					selModel: this.selModel,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:298,
					width:'100%',
					tbar:[searchField, '-',{
						text:'Buscar',
						handler : function(){
							store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 12,
						store: this.store3,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				
				var grid = this.grid;
				this.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
				//***************************************************
				this.formulario02 = new Ext.Panel({
					title:'Consulta',
					columnWidth: '.25',
					items: [this.grid]
				});
				
				var config = this.config;
				var raiz = this;
				this.tableWindow3 = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					layout: 'column',
					items: [this.formulario02,this.formulario01],
					listeners: {
						close: function() {
							raiz.config.visible = 'false';
							raiz.store1 = null;
							raiz.store2 = null;
							raiz.store3 = null;
							raiz.toolbar01 = null;
							raiz.formulario01 = null;
							raiz.formulario02 = null;
							raiz.grid = null;
							//window.location = window.location;
						}
					}
				});
			}else{
				this.tableWindow3.getEl().frame();
			}
			this.tableWindow3.show();
			this.formulario01.show();
			
			this.formulario01.getForm().load({ 
				method:'GET',
				url : urlbase+'0/'+modelo+'/vista6json/'+mid
			});
			this.formulario01.getForm().on({
				actioncomplete: function(form, action){
					if(action.type == 'load'){
						var contact = action.result.data;
						if(contact.imagen.length > 0) Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.imagen;
						else Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
					}
				}
			});
			
		},
		save_contenido: function(modelo,mid){
			var formu = this.tableWindow3;
			var grid = this.grid;
			var store3 = this.store3;
			var formulario01 = this.formulario01;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarjson/'+mid,
				//waitMsg: 'Grabando...',
				success: function () {
					
					var mid = formulario01.getForm().findField('mid').getValue();
					grid.getSelectionModel().clearSelections();
					store3.reload();
					
					Ext.Ajax.request({
						url : urlbase+'0/'+modelo+'/veridjson/',
						method: 'POST',
						success: function ( result, request ) { 
							//interface.panel12.getForm().findField('mid').setValue(result.responseText);
							var total = grid.getStore().getTotalCount();
							var i;
							for(i = 0;i<total;i++){
								if(result.responseText == grid.getStore().getAt(i).id){ 
									grid.getSelectionModel().selectRow(i);
									i = total;
								}
							}
						},
						params: { 
							nombre: formulario01.getForm().findField("nombre").getValue(),
							url: formulario01.getForm().findField("url").getValue()
						}
					});
					
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
			//alert(this.formulario01.getComponent('mid').getValue());
		},
		new_contenido: function(){
			this.formulario01.getForm().reset();
			Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
		},
		del_contenido: function(){
			var form01 = this.formulario01;
			var modelo = this.modelo;
			var store3 = this.store3;
			var grid = this.grid;
			if(form01.getForm().findField('mid').getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+modelo+'?',function(btn){
					if(btn === 'yes'){
						grid.getSelectionModel().clearSelections();
						Ext.Ajax.request({
							url : urlbase+'0/'+modelo+'/eliminarjson/'+form01.getForm().findField('mid').getValue(),
							method: 'GET',
							success: function ( result, request ) { 
								Ext.MessageBox.alert('Success', 'El contenido ha sido eliminado'); 
								store3.reload();
								form01.getForm().reset();
								Ext.getDom('pic').src = Ext.BLANK_IMAGE_URL;
								grid.getSelectionModel().selectRow(0);
							}
						});
					}
				});
			}
		},
		sel_contenido: function(){
			editar2('galerias','0','1');
		}
	};
	
	//***********************************************************************************************
	//
	//											Menu secundario
	//
	//***********************************************************************************************
	
	var edicion8 = function(config){
		this.config = config;
	}
	
	edicion8.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			if(this.tableWindow3){
				this.tableWindow3 = null;

			}
			if(!this.tableWindow3){
				this.modelo = modelo;
				
				this.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store2.load();
				
				this.store6 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistamjson/',
					fields: ['id', 'nombre']
				});
				this.store6.load();
				
				this.store4 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistacjson/',
					fields: ['id', 'nombre']
				});
				
				this.store5 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistacejson/',
					fields: ['id', 'nombre']
				});
				
				this.toolbar01 = new Ext.Toolbar({
					items: [
						{
							iconCls: 'add',
							tooltip: 'Adicionar',
							handler: function(){ this.new_contenido(); }.createDelegate(this)
						},{
							iconCls: 'remove',
							tooltip: 'Eliminar',
							handler: function(){ this.del_contenido(); }.createDelegate(this)
						}
					]
				});
				this.panel03 = new Ext.Panel({
					border: true,
					height:250,
					layout: 'form',
					items:[{ 
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name:'nombre', 
						id:'nombre',
						width:'90%'
					},{ 
						xtype: 'hidden',
						name: 'id', 
						id: 'id',
						value:'0'
					},{ 
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'sol_nodos_idiomas_id', 
						id:'sol_nodos_idiomas_id',
						hiddenName:'sol_nodos_idiomas_id2',
						forceSelection:true,   
						store: this.store2,   
						emptyText:'Seleccione',   
						triggerAction:'all',   
						editable:false,
						displayField:'nombre',   
						valueField:'id',
						mode:'local',
						listeners:{
							select:function(combo, record, index){
								var b = this.formulario01.getForm().findField('sol_core_modulos_id').getValue();
								this.formulario01.getForm().findField('categoria_id').clearValue();
								this.formulario01.getForm().findField('elemento_id').clearValue();
								this.store4.load({params:{sel:b,sel3:record.data.id}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Modulo',
						name:'sol_core_modulos_id',
						id:'sol_core_modulos_id',
						hiddenName: 'sol_core_modulos_id2',
						forceSelection: true,
						store: this.store6,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local',
						listeners:{
							select:function(combo, record, index){
								this.formulario01.getForm().findField('categoria_id').clearValue();
								this.formulario01.getForm().findField('elemento_id').clearValue();
								var b = this.formulario01.getForm().findField('sol_nodos_idiomas_id').getValue();
								this.store4.load({params:{sel:record.data.id,sel3:b}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Categoria',
						name:'categoria_id',
						id:'categoria_id',
						hiddenName: 'categoria_id2',
						forceSelection: false,
						store: this.store4,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local',
						listeners:{
							select:function(combo, record, index){
								var a = this.formulario01.getForm().findField('sol_core_modulos_id').getValue();
								var b = this.formulario01.getForm().findField('sol_nodos_idiomas_id').getValue();
								this.formulario01.getForm().findField('elemento_id').clearValue();
								this.store5.load({params:{sel:a,sel2:record.data.id,sel3:b}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Elemento',
						name:'elemento_id',
						id:'elemento_id',
						hiddenName: 'elemento_id2',
						forceSelection: true,
						store: this.store5,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local'
					}]
				});	
				
				this.formjreader01 = new Ext.data.JsonReader({root: 'resultado'}, ['id','sol_nodos_main_id','sol_nodos_idiomas_id','nombre','sol_core_modulos_id','categoria_id','elemento_id']);
			
				this.formulario01 = new Ext.FormPanel({
					reader : this.formjreader01,
					columnWidth: '.7',
					title:'Formulario',
					autoHeight : true,
					autoScroll: true,
					layout: 'form',
					defaults: {
						bodyStyle:'padding:5px',
						iconAlign: 'top'
					},
					items: this.panel03,
					tbar: this.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(modelo,mid); }.createDelegate(this)},{text:'Salir',handler: function(){ this.tableWindow3.close(); }.createDelegate(this)}]
				});
				//************************************************
				this.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistaejson/',
					fields: ['id','nombre'],
					remoteSort: true
				});
				this.colModel = new Ext.grid.ColumnModel([
					{id:'id',header: "ID", width: 40, sortable: true, dataIndex: 'id'},
					{header: 'Nombre', width: 200, sortable: true, dataIndex: 'nombre'}
				]);
				var form01 = this.formulario01;
				var store4 = this.store4;
				var store5 = this.store5;
				this.selModel = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/menus/cargarjson/'+selRecordStore.data.id,
								success: function () {
									var a = form01.getForm().findField('sol_core_modulos_id').getValue();
									var b = form01.getForm().findField('sol_nodos_idiomas_id').getValue();
									var c = form01.getForm().findField('categoria_id').getValue();
									store4.load({
										params:{
											sel:a,
											sel3:b
										},
										callback: function () {
											form01.getForm().findField('categoria_id').setValue(c);
										}
									});
									if(form01.getForm().findField('elemento_id').getValue() > 0){
										var d = form01.getForm().findField('elemento_id').getValue();
										store5.load({
											params:{
												sel:a,
												sel2:c,
												sel3:b
											},
											callback: function () {
												form01.getForm().findField('elemento_id').setValue(d);
											}
										});
									}
								}
							});
							
						}
					}
				});

				var searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar en '+ modelo
				});
				var store3 = this.store3;
				this.grid = new Ext.grid.GridPanel({
					store: this.store3,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel,                                       
					selModel: this.selModel,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:320,
					tbar:[searchField, '-',{
						text:'Buscar',
						handler : function(){
							store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 12,
						store: this.store3,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: searchField.getValue()}});
				//***************************************************
				this.formulario02 = new Ext.Panel({
					columnWidth: '.3',
					title:'Consulta',
					items: [this.grid]
				});
				
				this.tabs = new Ext.TabPanel({
					items: [this.formulario01,this.formulario02] //le agregamos el primer tab
				});
				var tabs = this.tabs;
				var config = this.config;
				var raiz = this;
				this.tableWindow3 = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					layout: 'column',
					items: [this.formulario02,this.formulario01],
					listeners: {
						close: function() {
							raiz.config.visible = 'false';
							raiz.store1 = null;
							raiz.store2 = null;
							raiz.store3 = null;
							raiz.toolbar01 = null;
							raiz.formulario01 = null;
							raiz.formulario02 = null;
							raiz.grid = null;
							//window.location = window.location;
						}
					}
				});
			}else{
				this.tableWindow3.getEl().frame();
			}
			this.tableWindow3.show();
			this.formulario01.show();
			
						
		},
		save_contenido: function(modelo,mid){
			var formu = this.tableWindow3;
			var store3 = this.store3;
			var form01 = this.formulario01;
			grid = this.grid;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/menus/guardarjson/'+mid,
				//waitMsg: 'Grabando...',
				success: function () {
					form01.getForm().reset();
					store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: ''}});
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
			//alert(this.formulario01.getComponent('mid').getValue());
		},
		new_contenido: function(){
			this.formulario01.getForm().reset();
			this.grid.getSelectionModel().clearSelections();
		},
		del_contenido: function(){
			var form01 = this.formulario01;
			var modelo = this.modelo;
			var store3 = this.store3;
			
			if(form01.getForm().findField('id').getValue() != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+modelo+'?',function(btn){
					if(btn === 'yes'){
						//alert(form01.getComponent('mid').value); 
						Ext.Ajax.request({
							url : urlbase+'0/menus/eliminarjson/'+form01.getForm().findField('id').getValue(),
							method: 'GET',
							success: function ( result, request ) { 
								store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: ''}});
							}
						});
						form01.getForm().reset();
					}
				});
			}
		},
		sel_contenido: function(){
			editar2('galerias','0','1');
		}
	};
	
	var edicion9 = function(config){
		this.config = config;
	}
	
	edicion9.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			this.modelo = modelo;
			this.mid = mid;
			this.rid = -1;
			var rid = this.rid;
			if(this.win){
				this.win = null;
			}
			if(!this.win){
				var cargo = 0;
				var cargo2 = 0;
				this.store01 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista1json/',
					fields: ['id','categoria','nombre'],
					remoteSort: true,
					listeners: {
						load: function(){
							if(cargo == 0){ 
								selModel01.selectFirstRow();
								cargo = 1;
							}
						}
					}
				});
				this.colModel01 = new Ext.grid.ColumnModel([
					{id:'id',header: "ID", width: 40, sortable: true, dataIndex: 'id', hidden:true},
					{header: 'Categoria', width: 100, sortable: true, dataIndex: 'categoria'},
					{header: 'Nombre', width: 220, sortable: true, dataIndex: 'nombre'}
				]);
				this.selModel01 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							var selRecordStore = record;
							var rid = selRecordStore.data.id;
							form02.getForm().reset();
							store02.load({params:{publicacion: rid, start:0, limit:5, sort: 'fecha_ini', dir: 'asc', like: searchField02.getValue()}});
							form01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista4json/'+rid
							});
						}
					}
				});
				var selModel01 = this.selModel01;
				
				var searchField01 = new Ext.form.TextField({
					name: 'searchField1',
					id: 'searchField1',
					emptyText: 'Buscar en '+modelo
				});
				var store01 = this.store01;
				
				this.grid01 = new Ext.grid.GridPanel({
					border: false,
					store: this.store01,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel01,                                       
					selModel: this.selModel01,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:250,
					width:'100%',
					tbar:[{
						xtype:'textfield',
						name: 'searchField1', 
						id: 'searchField1' ,
						emptyText: 'Buscar en '+modelo,
						width : 100,
						listeners:{
							specialkey:function(elem,evnt){
								if(evnt.getKey() == 13) store01.load({params:{start:0, limit:5, sort: 'nombre', dir: 'asc', like: elem.getValue()}});
							},
							scope: this
						}
					},'-',{
						iconCls: 'add',
						tooltip: 'Adicionar una encuesta',
						handler: function(){ this.new_contenido('e',0); this.grid01.getSelectionModel().clearSelections(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar la encuesta seleccionada',
						handler: function(){ this.del_contenido('e'); }.createDelegate(this)
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 5,
						store: this.store01,
						displayInfo: true,
						displayMsg: modelo + ' mostradas {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.store01.load({params:{start:0, limit:5, sort: 'nombre', dir: 'asc', like: ''}});
				
				this.store02 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista2json/',
					fields: ['id','fecha_ini','fecha_fin'],
					remoteSort: true,
					listeners: {
						load: function(){
							//if(cargo2 == 0){ 
								selModel02.selectFirstRow();
								cargo2 = 1;
							//}
						}
					}
				});
				
				this.colModel02 = new Ext.grid.ColumnModel([
					{id:'id',header: "ID", width: 40, sortable: true, dataIndex: 'id', hidden:true},
					{header: 'Fecha inicio', width: 120, sortable: true, dataIndex: 'fecha_ini'},
					{header: 'Fecha final', width: 120, sortable: true, dataIndex: 'fecha_fin'}
				]);
				this.selModel02 = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							var selRecordStore = record;
							var rid = selRecordStore.data.id;
							form02.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista5json/'+rid,
								success: function () {
									var a = form02.getForm().findField('sol_core_modulos_id').getValue();
									var b = form01.getForm().findField('idioma').getValue();
									var c = form02.getForm().findField('categoria_id2').getValue();
									store06.load({
										params:{
											sel:a,
											sel3:b
										},
										callback: function () {
											form02.getForm().findField('categoria_id2').setValue(c);
										}
									});
									if(form02.getForm().findField('elemento_id').getValue() > 0){
										var d = form02.getForm().findField('elemento_id').getValue();
										store07.load({
											params:{
												sel:a,
												sel2:c,
												sel3:b
											},
											callback: function () {
												form02.getForm().findField('elemento_id').setValue(d);
											}
										});
									}
								}
							});
						}
					}
				});
				var selModel02 = this.selModel02;
				
				var searchField02 = new Ext.form.TextField({
					name: 'searchField2',
					id: 'searchField2',
					emptyText: 'Buscar en '+modelo
				});
				
				var store02 = this.store02;
				
				this.grid02 = new Ext.grid.GridPanel({
					border: false,
					store: this.store02,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.colModel02,                                       
					selModel: this.selModel02,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:250,
					width:'100%',
					tbar:[{
						xtype:'textfield',
						name: 'searchField2', 
						id: 'searchField2' ,
						emptyText: 'Buscar en sub'+modelo,
						width : 100,
						listeners:{
							specialkey:function(elem,evnt){
								if(evnt.getKey() == 13) store02.load({params:{rid: rid, start:0, limit:5, sort: 'nombre', dir: 'asc', like: elem.getValue()}});
							},
							scope: this
						}
					},'-',{
						iconCls: 'add',
						tooltip: 'Adicionar una publicacion',
						handler: function(){ this.new_contenido('p',0); this.grid02.getSelectionModel().clearSelections(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar la publicacion seleccionada',
						handler: function(){ this.del_contenido('p'); }.createDelegate(this)
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 5,
						store: this.store02,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				
				this.store03 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.store03.load();
				var store03 = this.store03;
				
				this.store04 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/'+modelo+'/vista3json/',
					fields: ['id', 'nombre']
				});
				this.store04.load();
				var store04 = this.store04;
				
				this.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['eid','categoria','idioma','nombre','resp1','resp2','resp3','resp4','resp5']);
				this.formulario01 = new Ext.FormPanel({
					border: false,
					height:250,
					reader: this.formjreader01,
					title:'Datos de la encuesta',
					bodyStyle:'padding:5px',
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{
						text:'Guardar',handler: function(){ this.save_contenido1(modelo) }.createDelegate(this)
					}],
					layout: 'form',
					items: [{ 
						xtype: 'hidden',
						name: 'eid', 
						id: 'eid',
						value:'0'
					},{
						xtype:'combo',
						fieldLabel:'Categoria',
						name:'categoria',
						id:'categoria',
						hiddenName: 'categoria_id',
						forceSelection: true,
						store: store04,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						listeners: {
							select : function(combo,record,index ){
								if(record.get('id')== '-1') categoriasx.show(modelo,this,store04);
							}
						}
					}, {
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'idioma', 
						id:'idioma' ,
						hiddenName: 'idioma_id',
						forceSelection:true,   
						store: store03,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id'
					},{
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '95%'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Opcion 1',  
								name: 'resp1', 
								id: 'resp1'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Opcion 2',  
								name: 'resp2', 
								id: 'resp2'
							}]
						}]

					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Opcion 3',  
								name: 'resp3', 
								id: 'resp3'
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'textfield',
								fieldLabel:'Opcion 4',  
								name: 'resp4', 
								id: 'resp4'
							}]
						}]

					},{
						xtype:'textfield',
						fieldLabel:'Opcion 5',  
						name: 'resp5', 
						id: 'resp5'
					}]
				});
				var form01 = this.formulario01;
				
				this.store05 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistamjson/',
					fields: ['id', 'nombre']
				});
				this.store05.load();
				
				this.store06 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistacjson/',
					fields: ['id', 'nombre']
				});
				var store06 = this.store06;
				
				this.store07 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/menus/vistacejson/',
					fields: ['id', 'nombre']
				});
				var store07 = this.store07;
			
				this.formjreader02 = new Ext.data.JsonReader({root: 'data'}, ['pid','fecha_ini','fecha_fin','sol_core_modulos_id','categoria_id2','elemento_id','presultado','pemail','pnombre','papellido']);
				this.formulario02 = new Ext.FormPanel({
					border: false,
					height:250,
					reader: this.formjreader02,
					title:'Datos de la publicacion',
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{
						text:'Guardar',handler: function(){ this.save_contenido2(modelo) }.createDelegate(this)
					}],
					layout: 'form',
					bodyStyle:'padding:5px',
					items: [{ 
						xtype: 'hidden',
						name: 'pid', 
						id: 'pid',
						value:'0'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'datefield',
								fieldLabel:'Desde',  
								name:'fecha_ini', 
								id:'fecha_ini',
								format:'Y-m-d',
								emptyText: fecha_actual,
								value: fecha_actual
							}]
						}, {
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'datefield',
								fieldLabel:'Hasta',  
								name:'fecha_fin', 
								id:'fecha_fin',
								format:'Y-m-d',
								emptyText: fecha_actual,
								value: fecha_actual
							}]
						}]

					},{
						xtype:'combo',
						fieldLabel:'Modulo',
						name:'sol_core_modulos_id',
						id:'sol_core_modulos_id',
						hiddenName: 'sol_core_modulos_id2',
						forceSelection: true,
						store: this.store05,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local',
						value: '0',
						listeners:{
							select:function(combo, record, index){
								this.formulario02.getForm().findField('categoria_id2').clearValue();
								this.formulario02.getForm().findField('elemento_id').clearValue();
								var b = this.formulario01.getForm().findField('idioma').getValue();
								this.store06.load({params:{sel:record.data.id,sel3:b}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Categoria',
						name:'categoria_id2',
						id:'categoria_id2',
						hiddenName: 'categoria_id3',
						forceSelection: true,
						store: this.store06,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local',
						value: '0',
						listeners:{
							select:function(combo, record, index){
								var a = this.formulario02.getForm().findField('sol_core_modulos_id').getValue();
								var b = this.formulario01.getForm().findField('idioma').getValue();
								this.formulario02.getForm().findField('elemento_id').clearValue();
								this.store07.load({params:{sel:a,sel2:record.data.id,sel3:b}});
							},
							scope: this
						}
					},{
						xtype:'combo',
						fieldLabel:'Elemento',
						name:'elemento_id',
						id:'elemento_id',
						hiddenName: 'elemento_id2',
						forceSelection: true,
						store: this.store07,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'nombre',
						valueField: 'id',
						selectOnFocus: true,
						mode: 'local',
						value: '0'
					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype: 'checkbox', 
								fieldLabel: 'Mostrar resultados',
								name: 'presultado',
								id: 'presultado',
								inputValue: 1
							}]
						},{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype:'checkbox',
								fieldLabel:'Pedir email',  
								name: 'pemail', 
								id: 'pemail',
								inputValue: 1
							}]
						}]

					},{
						layout: 'column',
						border: false,
						items: [{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype: 'checkbox', 
								fieldLabel: 'Pedir nombre',
								name: 'pnombre',
								id: 'pnombre',
								inputValue: 1
							}]
						},{
							columnWidth: '.5',
							border: false,
							layout: 'form',
							items: [{
								xtype: 'checkbox', 
								fieldLabel: 'Pedir apellidos',
								name: 'papellido',
								id: 'papellido',
								inputValue: 1
							}]
						}]

					}]
				});
				var form02 = this.formulario02;				
				
				this.panel01 = new Ext.Panel({
					columnWidth: '.302',
					border: true,
					defaults: {
						bodyStyle:'padding:0px'
					},
					layout: 'anchor',
					items: [{
						layout: 'anchor',
						items: this.grid01
					},{
						layout: 'anchor',
						items: this.grid02
					}]
				});
				
				this.panel02 = new Ext.Panel({
					border: false,
					columnWidth: '.698',
					layout: 'anchor',
					items: [{
						layout: 'anchor',
						items: this.formulario01
					},{
						layout: 'anchor',
						items: this.formulario02
					}]
				});
				var config = this.config;
				this.win = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					//height:600,
					layout: 'column',
					items:[
						this.panel01,	
						this.panel02
					],
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Salir',handler: function(){ this.win.close(); }.createDelegate(this)}],
					listeners: {
						close: function() {
							config.visible = 'false';
						}
					}
				});
			} else{
				this.win.getEl().frame();
			}
			this.win.show();
		},
		sel_contenido: function(){
			editar2('eventos','0','1');
		},
		new_contenido: function(tipo,rid){
			
			if(tipo=='e'){
				this.formulario01.getForm().reset();
			}
			else if(tipo=='p'){
				this.formulario02.getForm().reset();
				var b = this.formulario01.getForm().findField('idioma').getValue();
				this.store06.load({params:{sel:'0',sel3:b}});
				this.store07.load({params:{sel:'0',sel2:'0',sel3:b}});
			}
		},
		del_contenido: function(tipo){
			var modelo = this.modelo;
			
			var form01 = this.formulario01;
			var form02 = this.formulario02;
			
			var store01 = this.store01;
			var store02 = this.store02;
			
			var grid01 = this.grid01;
			var grid02 = this.grid02;

			if(tipo=='e'){
				if(form01.getComponent('eid').value != 0){
					Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar esta encuesta?',function(btn){
						if(btn === 'yes'){
							rid = form01.getComponent('eid').value;
							Ext.Ajax.request({
								url : urlbase+'0/'+modelo+'/eliminar1json/'+rid,
								method: 'GET',
								success: function ( result, request ) { 
									Ext.MessageBox.alert('Success', 'La encuesta ha sido eliminada');
									form01.getForm().reset();
									store01.reload();
									form02.getForm().reset();
									store02.reload();
								}
							});
						}
					});
				}
			}
			else if(tipo=='p'){
				if(form02.getComponent('pid').value != 0){
					Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar esta publicacion?',function(btn){
						if(btn === 'yes'){
							rid = form02.getComponent('pid').value;
							Ext.Ajax.request({
								url : urlbase+'0/'+modelo+'/eliminar2json/'+rid,
								method: 'GET',
								success: function ( result, request ) { 
									Ext.MessageBox.alert('Success', 'La publicacion ha sido eliminada');
									form02.getForm().reset();
									store02.reload();
								}
							});
						}
					});
				}
			}
		},
		save_contenido1: function(modelo){
			var formulario01 = this.formulario01;
			var store01 = this.store01;
			this.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardar1json/',
				//waitMsg: 'Grabando...',
				success: function () {
					store01.reload();
					formulario01.getForm().reset();
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		save_contenido2: function(modelo){
			var store02 = this.store02;
			var formulario01 = this.formulario01;
			var formulario02 = this.formulario02;
			this.formulario02.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardar2json/'+formulario01.getComponent('eid').value,
				//waitMsg: 'Grabando...',
				success: function () {
					store02.reload();
					formulario02.getForm().reset();
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		}
		
	};
	
	//***************************************************************************************************************
	//
	//													Archivo
	//
	//***************************************************************************************************************
	
	
	var edicion10 = function(config){
		this.config = config;
	}
	
	edicion10.prototype = {
		show : function(modelo,mid){
			this.config.visible = 'true';
			this.interface = false;
			if(!this.interface){
				this.interface = new Object();
				var interface = this.interface;
				this.interface.modelo = modelo;
				this.interface.store1 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url: urlbase+'0/'+modelo+'/vista5json/',
					fields: ['cid', 'cnombre']
				});
				this.interface.store1.load();
				
				this.interface.store2 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'resultado',
					url:  urlbase+'0/idiomas/vista1json/',
					fields: ['id', 'nombre']
				});
				this.interface.store2.load();
				
				var categoria_id = new Ext.form.Hidden({
					name:'categoria_id',
					id:"categoria_id"
				});
				
				var idioma_id = new Ext.form.Hidden({
					name:'idioma_id',
					id:"idioma_id"
				});
				
				this.interface.toolbar01 = new Ext.Toolbar({
					items: [{
						iconCls: 'add',
						tooltip: 'Adicionar',
						handler: function(){ this.new_contenido(); }.createDelegate(this)
					},{
						iconCls: 'remove',
						tooltip: 'Eliminar',
						handler: function(){ this.del_contenido(); }.createDelegate(this)
					}]
				});
				

				this.interface.formjreader01 = new Ext.data.JsonReader({root: 'data'}, ['mid','categoria','creacion','nombre','idioma','introduccion','original','urlfile','visible']);
				
			
				this.interface.formulario01 = new Ext.FormPanel({
					fileUpload: true,
					reader : this.interface.formjreader01,
					bodyStyle:'padding: 10px',
					height:'100%',
					width:'100%',
					autoHeight : true,
					autoScroll: true,
					columnWidth: '.7',
					layout: 'form',
					defaults: {
						bodyStyle:'padding:5px',
						iconAlign: 'top'
					},
					items:[{ 
						xtype: 'hidden',
						name: 'mid', 
						id: 'mid',
						value:'0'
					},{
						xtype:'combo',
						fieldLabel:'Idioma',  
						name:'idioma', 
						id:'idioma' ,
						hiddenName: 'idioma_id',
						forceSelection:true,   
						store: this.interface.store2,   
						emptyText:'Seleccione',   
						triggerAction: 'all',   
						editable:false,
						displayField:'nombre',   
						valueField: 'id'
					},{
						xtype:'combo',
						fieldLabel:'Categoria',
						name:'categoria',
						id:'categoria',
						hiddenName: 'categoria_id',
						forceSelection: true,
						store: this.interface.store1,
						emptyText:'Seleccione',
						triggerAction: 'all',
						editable: false,
						displayField:'cnombre',
						valueField: 'cid',
						selectOnFocus: true,
						listeners: {
							select : function(combo,record,index ){
								if(record.get('cid')== '-1') categoriasx.show(interface.modelo,this,interface.store1);
							}
						}
					},{ 
						xtype:'textfield',
						fieldLabel:'Titulo',  
						name: 'nombre', 
						id: 'nombre' ,
						width : '90%'
					},{
						xtype: 'textarea',
						width : 250,   
						height: 50,
						fieldLabel:'Introduccion', 
						name:'introduccion', 
						id:'introduccion'
					},{ 
						xtype:'textfield',
						fieldLabel:'Archivo',  
						name: 'original', 
						id: 'original' ,
						width : '90%',
						readOnly: true
					},{ 
						xtype:'textfield',
						fieldLabel:'URL',  
						name: 'urlfile', 
						id: 'urlfile' ,
						width : '90%',
						readOnly: true
					},{ 
						xtype:'textfield',
						fieldLabel:'Subir',  
						name: 'uploadx', 
						id: 'uploadx' ,
						width : '90%',
						inputType:'file'
					},{
						xtype: 'checkbox', 
						fieldLabel: 'Visible',
						name: 'visible',
						id: 'visible',
						inputValue: 1
					}],
					tbar: this.interface.toolbar01,
					buttonAlign: 'right', //<--botones alineados a la derecha   
					buttons:[{text:'Guardar',handler: function(){ this.save_contenido(modelo,mid); }.createDelegate(this)},{text:'Salir',handler: function(){ this.interface.tableWindow3.close(); }.createDelegate(this)}]
				});
				//************************************************
				this.interface.store3 = new Ext.data.JsonStore({
					totalProperty: 'total',
					root: 'data',
					url: urlbase+'0/'+modelo+'/vista7json/',
					fields: ['mid','categoria','creacion','nombre','idioma','comentarios','principal'],
					remoteSort: true
				});
				this.interface.colModel = new Ext.grid.ColumnModel([
					{id:'mid',header: "ID", width: 40, sortable: true, dataIndex: 'mid', hidden:true},
					{header: 'Creacion', width: 80, sortable: true, dataIndex: 'creacion'},
					{header: 'Nombre', width: 420, sortable: true, dataIndex: 'nombre'},
					{header: 'Categoria', width: 100, sortable: true, dataIndex: 'categoria'},
					{header: 'Idioma', width: 100, sortable: true, dataIndex: 'idioma'}
				]);

				this.interface.selModel = new Ext.grid.RowSelectionModel({ 
					singleSelect : true,
					listeners: {
						rowselect: function(smObj, rowIndex, record) {
							selRecordStore = record;
							interface.formulario01.getForm().load({ 
								method:'GET',
								url : urlbase+'0/'+modelo+'/vista6json/'+selRecordStore.data.mid
							});
							interface.formulario01.getForm().findField('mid').setValue(selRecordStore.data.mid);
						}
					}

				});

				this.interface.searchField = new Ext.form.TextField({
					name: 'searchField',
					id: 'searchField',
					emptyText: 'Buscar en '+modelo
				});

				this.interface.grid = new Ext.grid.GridPanel({
					store: this.interface.store3,
					trackMouseOver:false,
					disableSelection:false,
					colModel: this.interface.colModel,                                       
					selModel: this.interface.selModel,
					stripeRows: true,
					trackMouseOver: true,
					loadMask: true,
					height:330,
					width:'100%',
					tbar:[interface.searchField, '-',{
						text:'Buscar',
						handler : function(){
							store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
						}
					}],
					bbar: new Ext.PagingToolbar({
						pageSize: 12,
						store: this.interface.store3,
						displayInfo: true,
						displayMsg: modelo + ' mostrados {0} - {1} of {2}',
						emptyMsg: "No topics to display"
					})
				});
				this.interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
				//***************************************************
				this.interface.formulario02 = new Ext.Panel({
					columnWidth: '.3',
					items: [this.interface.grid]
				});
				
				var config = this.config;

				this.interface.tableWindow3 = new Ext.Window({
					title: 'Editar '+ modelo,
					closeAction: 'close',
					width:780,
					layout: 'column',
					items: [this.interface.formulario02,this.interface.formulario01],
					listeners: {
						close: function() {
							config.visible = 'false';
							interface = null;
							//window.location = window.location;
						}
					}
				});
				this.interface.tableWindow3.show();
				
				this.interface.formulario01.getForm().load({ 
					method:'GET',
					url : urlbase+'0/'+modelo+'/vista6json/'+mid
				});
				this.interface.formulario01.getForm().on({
					actioncomplete: function(form, action){
						if(action.type == 'load'){
							var contact = action.result.data;
							//Ext.getDom('pic').src = urlbase+'tmp/sol_'+nav_id+'/thumbnails/'+contact.imagen;
						}
					}
				});
			}
		},
		save_contenido: function(modelo,mid){
			var interface = this.interface;
			this.interface.formulario01.getForm().submit({
				method: 'post',
				url : urlbase+'0/'+modelo+'/guardarjson/'+mid,
				waitMsg: 'Grabando...',
				success: function () {
					interface.formulario01.getForm().reset();
					interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
				},
				failure: function () {
					Ext.MessageBox.alert ('Mensaje','Fallo al grabar');
				}
			});
		},
		new_contenido: function(){
			this.interface.formulario01.getForm().reset();
		},
		del_contenido: function(){
			var interface = this.interface;
			if(interface.formulario01.getComponent('mid').value != 0){
				Ext.Msg.confirm('Confirmación','Esta seguro de querer eliminar este(a) '+interface.modelo+'?',function(btn){
					if(btn === 'yes'){
						Ext.Ajax.request({
							url : urlbase+'0/'+interface.modelo+'/eliminarjson/'+interface.formulario01.getForm().findField('mid').getValue(),
							method: 'GET',
							success: function ( result, request ) { 
								Ext.MessageBox.alert('Success', 'El Archivo ha sido eliminado'); 
								interface.store3.load({params:{start:0, limit:12, sort: 'nombre', dir: 'asc', like: interface.searchField.getValue()}});
							}
						});
						interface.formulario01.getForm().reset();
					}
				});
			}
		},
		sel_contenido: function(){
			editar2('galerias','0','1');
		}
	};
	
	var categoriasx = new categorias({
		visible: 'false'
	});
	
	var edicion1 = new edicion({
		visible: 'false'
	});
	edicionx = edicion1;
	
	var edicion2 = new edicion2({
		visible: 'false'
	});
	edicionx2 = edicion2;
	
	var edicion3 = new edicion3({
		visible: 'false'
	});
	edicionx3 = edicion3;
	
	var edicion4 = new edicion4({
		conf_plantillas: conf_plantillas,
		visible: 'false'
	});
	edicionx4 = edicion4;
	
	var sel_img = new ImageChooser();
	sel_imgx = sel_img;
	
	var up_img = new ImageUploader();
	
	var up_imgs = new ImagesUploader();
	
	up_imgsx = up_imgs;
	sel_imgx = sel_img;
	
	var edicion5x = new edicion5({
    	visible: 'false'
    });
	
	edicionx5 = edicion5x;
	
	// 
	var edicion6x = new edicion6({
    	visible: 'false'
    });
	edicionx6 = edicion6x;
	
	var edicion7x = new edicion7({
    	visible: 'false'
    });
	edicionx7 = edicion7x;
	
	var edicion8x = new edicion8({
    	visible: 'false'
    });
	edicionx8 = edicion8x;
	
	
	var edicion9x = new edicion9({
    	visible: 'false'
    });
	edicionx9 = edicion9x;
	
	var edicion10x = new edicion10({
    	visible: 'false'
    });
	edicionx10 = edicion10x;
});
