function noticias(){

	var centro = viewport.getComponent('center-panel');
	
	if(!centro.findById('detalle-noticias')){
		centro.add({
			id:'detalle-noticias',
			title:'Noticias',
			closable:true,
			autoScroll:true
		}).show();
		centro.activate('detalle-noticias');
		document.getElementById('detalle-noticias').innerHTML = '<div id="noticias-grid" style="width:100%;"></div>';

	    var nom = '';
	    var des = '';
	    var has = '';
	    var filt = '0';
		var myPageSize = Math.round(altura/60);
		
	    var store = new Ext.data.Store({
	        proxy:new Ext.data.HttpProxy({url:'noticias.jsp?alert=7'}),
	        reader:new Ext.data.JsonReader({
	            root:'results',
	            totalProperty:'totalCount',
	            fields:[
	                {name:'ID'},
		            {name:'FECHA2'},
		            {name:'NOMBRE'},
		            {name:'TEXTO'},
		            {name:'TITULAR'}
	            ]
	        }),
	        remoteSort:true
	    });
	    store.setDefaultSort('FECHA2','desc');
	
	    function renderTopic(value,p,record){
	        var substr = record.data['TEXTO'].substring(0,200) + '...';
	        return String.format('<b style="background:transparent url(../icons/topic.gif) no-repeat scroll left 1px;color:#333333;display:block;font-family:tahoma, verdana;padding-left:18px;line-height:18px;vertical-align:middle;"><font color="maroon">{0}</font> .- {1}</b>{2}', record.data['FECHA2'], value, substr);
	    }
	
	    var cm = new Ext.grid.ColumnModel([{
			header:"Titular",
			dataIndex:'TITULAR',
			width:anchura-20,
			align:'left',
			css:'white-space:normal;',
			renderer:renderTopic
	    }]);
	
	    cm.defaultSortable = false;
	
	    var nom_field = new Ext.form.TextField({
	        emptyText:'Noticia',
	        size:20
	    });
	    
	    var f_desde = new Ext.form.DateField({
	        emptyText:'Fecha desde',
	        size:20,
	        format:'d/m/y'
	    });
	    
	    var f_hasta = new Ext.form.DateField({
	        emptyText:'hasta',
	        size:20,
	        format:'d/m/y'
	    });
	
	    function onSearch(){
	        filt = '1';
	        nom = escape(nom_field.getValue());
	        des = f_desde.getValue();
	        voc = 'none';
	        if(des != ''){
	            des = f_desde.getValue().format('d/m/Y');
	        }
	        has = f_hasta.getValue();
	        if(has != ''){
	            has = f_hasta.getValue().format('d/m/Y');
	        }
	        store.load({params:{start:0,limit:myPageSize,nom:nom,des:des,has:has}});
	    }
	    
		var searchbtn = new Ext.Button({
	        text:'Buscar',
	        cls:'x-btn-text-icon',
	        icon:'../icons/find.png',
	        tooltip:'<b>B&uacute;squeda de noticias</b>',
	        handler:onSearch
		});
	
	    var grid = new Ext.grid.GridPanel({
	        el:'noticias-grid',
	        width:anchura,
	        height:altura,
	        title:'Noticias',
	        store:store,
	        cm:cm,
	        trackMouseOver:false,
	        sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
	        loadMask:true,
	        tbar:[nom_field,'-',f_desde,'-',f_hasta,'-',searchbtn],
	        bbar:new Ext.PagingToolbar({
	            pageSize:myPageSize,
	            store:store,
	            displayInfo:true,
	            displayMsg:'Mostrando registros {0} - {1} de {2}',
	            emptyMsg:"No hay registros que mostrar"
	        })
	    });
	
	    grid.render();
	    
	    store.on('beforeload',function(){
	        if(filt == '0')
	            store.baseParams = {filter:filt};
	        else
	            store.baseParams = {filter:filt,nom:nom,des:des,has:has};
	    });  
	    
	    store.load({params:{start:0,limit:myPageSize}});
	    
	    grid.on('rowdblclick',function(grid,rowIndex,e){
	        crea_tab(store.getAt(rowIndex).data.ID);
	    });
	    
	}
    else{
    	centro.activate('detalle-noticias');
    	centro.findById('detalle-noticias').show();
    }
}

function actividades(){

	var centro = viewport.getComponent('center-panel');
	
	if(!centro.findById('detalle-actividades')){
		centro.add({
			id:'detalle-actividades',
			title:'Actividades',
			closable:true,
			autoScroll:true
		}).show();
		centro.activate('detalle-actividades');
		document.getElementById('detalle-actividades').innerHTML = '<div id="actividades-grid" style="width:100%;"></div>';

	    var nom = '';
	    var des = '';
	    var has = '';
	    var filt = '0'; 
		var myPageSize = Math.round(altura/30);
	    
	    var store = new Ext.data.Store({
	        proxy:new Ext.data.HttpProxy({url:'noticias.jsp?alert=8'}),
	        reader:new Ext.data.JsonReader({
	            root:'results',
	            totalProperty:'totalCount',
	            fields:[
	                {name:'ID'},
		            {name:'FECHA3'},
		            {name:'FECHA2'},
		            {name:'NOMBRE'},
		            {name:'TITULAR'}
	            ]
	        }),
	        remoteSort:true
	    });
	    store.setDefaultSort('FECHA2','desc');
	
		function renderTopic(value){
	        return String.format('<b><font color="maroon">{0}</font></b>', value);
	    }
	
	    var cm = new Ext.grid.ColumnModel([{
	        header:"Fecha de inicio",
	        dataIndex:'FECHA2',
	        format:'d/m/y',
	        align:'center',
	        renderer:renderTopic,
	        width:Math.round(anchura*0.10)
	     },{
	        header:"Fecha de fin",
	        dataIndex:'FECHA3',
	        format:'d/m/y',
	        align:'center',
	        renderer:renderTopic,
	        width:Math.round(anchura*0.10)
	     },{
			header:"Titular",
			dataIndex:'TITULAR',
			width:Math.round(anchura*0.77),
			align:'center'
	    }]);
	
	    cm.defaultSortable = false;
	
	    var nom_field = new Ext.form.TextField({
	        emptyText:'Actividad',
	        size:20
	    });
	    
	    var f_desde = new Ext.form.DateField({
	        emptyText:'Fecha desde',
	        size:20,
	        format:'d/m/y'
	    });
	    
	    var f_hasta = new Ext.form.DateField({
	        emptyText:'hasta',
	        size:20,
	        format:'d/m/y'
	    });
	
	    function onSearch(){
	        filt = '1';
	        nom = escape(nom_field.getValue());
	        des = f_desde.getValue();
	        voc = 'none';
	        if(des != ''){
	            des = f_desde.getValue().format('d/m/Y');
	        }
	        has = f_hasta.getValue();
	        if(has != ''){
	            has = f_hasta.getValue().format('d/m/Y');
	        }
	        store.load({params:{start:0,limit:myPageSize,nom:nom,des:des,has:has}});
	    }
	    
		var searchbtn = new Ext.Button({
	        text:'Buscar',
	        cls:'x-btn-text-icon',
	        icon:'../icons/find.png',
	        tooltip:'<b>B&uacute;squeda de actividades</b>',
	        handler:onSearch
		});
		
	    var grid = new Ext.grid.GridPanel({
	        el:'actividades-grid',
	        width:anchura,
	        height:altura,
	        title:'Actividades',
	        store:store,
	        cm:cm,
	        trackMouseOver:false,
	        sm:new Ext.grid.RowSelectionModel({singleSelect:true}),
	        loadMask:true,
	        tbar:[nom_field,'-',f_desde,'-',f_hasta,'-',searchbtn],
	        bbar:new Ext.PagingToolbar({
	            pageSize:myPageSize,
	            store:store,
	            displayInfo:true,
	            displayMsg:'Mostrando registros {0} - {1} de {2}',
	            emptyMsg:"No hay registros que mostrar"
	        })
	    });
	
	    grid.render();
	    
	    store.on('beforeload',function(){
	        if(filt == '0')
	            store.baseParams = {filter:filt};
	        else
	            store.baseParams = {filter:filt,nom:nom,des:des,has:has};
	    });
	    
	    store.load({params:{start:0,limit:myPageSize}});
	    
	    grid.on('rowdblclick',function(grid,rowIndex,e){
	        crea_tab(store.getAt(rowIndex).data.ID);
	    });
	}
    else{
    	centro.activate('detalle-actividades');
    	centro.findById('detalle-actividades').show();
    }
}
