/*
 * Composicion de busqueda avanzada
 */
function objNoticia(datosComposicion,orden,esUltima){  
	
	this.titular = datosComposicion.get('titular');
	this.fechaLocale = datosComposicion.get('fechaLocale');
	this.noticia = 	datosComposicion.get('noticia');	
	this.resumen = 	datosComposicion.get('resumen');
	this.restoNoticia = datosComposicion.get('restoNoticia');
	
	this.esUltima = false;		 
	if (this.novedad==true){
		this.visNovedad = '';
	}


	
	this.html =	'' +						
 				'<div class="noticia">'+
	 				'<div class="noticiac0">{fechaLocale}</div>'+
	 				'<div class="noticiac1">{titular}</div>';
	 				
	if(this.restoNoticia!=''){
		this.html += '<div class="noticiac2"><a href="javascript:void(0)"><img src="../img/mas.jpg" width="11" height="11"/></a></div>';
	}			
		this.html +='<div class="tope">&nbsp;</div>'+
					'<div class="resumenNoticiaInfo">{resumen}</div>'
					'</div>';
	
	this.htmlMasInformacion = ''+
		'<div class="restoNoticia">' +	
			'<div>'+
				'<div>{restoNoticia}</div>'+
			'</div><div class="tope">&nbsp;</div>'+			
		'</div>';
	
	this.tpl = new Ext.Template(this.html);		
	this.tpl.compile();	
	
	this.tplMasInformacion = new Ext.Template(this.htmlMasInformacion);		
	this.tplMasInformacion.compile();	
	
	this.booleanExpandido = false;	
	this.divContenidoPrincipal = null;
	this.elContenidoPrincipal = null;
	this.botonMasInformacion = null;
	this.elBotonMasInformacion = null;
 	this.divMasInformacion = null;
 	this.elMasInformacion = null;
 	this.elComposicion = null;
 	
 	this.pintar = function(){		
 		
 		this.elComposicion = Ext.get('listaNoticias').createChild();
 		
 		if(this.esUltima==true){
 			this.elComposicion.addClass('noticiapadreultima');
 		}else{
 			this.elComposicion.addClass('noticiapadre');
 		}
 																	
		// si ya existe ese div
		this.contenidoPrincipal = this.tpl.append(this.elComposicion, {titular:this.titular,fechaLocale:this.fechaLocale,resumen:this.resumen});																														
		this.elContenidoPrincipal = Ext.get(this.contenidoPrincipal);		
		// boton mas informacion
		this.botonMasInformacion = this.elContenidoPrincipal.select('div.noticiac2').elements[0];	
		this.elBotonMasInformacion = Ext.get(this.botonMasInformacion);	
		var padre = this;
		this.elBotonMasInformacion.on('click',function(){padre.mostrarMasInformacion();});
		
		this.booleanExpandido=false;			
	}						
		   				    				
	this.mostrarMasInformacion = function(){
		if(this.booleanExpandido==true){
			this.booleanExpandido=false;
			this.elMasInformacion.setHeight(0,true);
			this.elMasInformacion.addClass('composicionmasinfocoll');
			this.elMasInformacion.removeClass('composicionmasinfo');
			this.elMasInformacion.update();
			this.elBotonMasInformacion.child('img').dom.src = "../img/mas.jpg";
		}else{
			if(this.elMasInformacion!=null){
				this.elMasInformacion.remove();
			}
			this.booleanExpandido=true;
			this.divMasInformacion = this.tplMasInformacion.append(this.elComposicion , {restoNoticia:this.restoNoticia});									
			this.elMasInformacion = Ext.get(this.divMasInformacion);
			this.elMasInformacion.setHeight(0);
			this.elMasInformacion.autoHeight(true);
			
			this.elBotonMasInformacion.child('img').dom.src = "../img/menos.jpg";	
		}	
	}
}