Adesis.ManipuladorComportamientos = Class.create();
Adesis.ManipuladorComportamientos.prototype = {
	initialize: function(controlador){
		this.controlador = controlador;
		return this;
	},
	enPestanyasTogleadorContenidoPestanyas: function (arrEnlacesPestanyas) { with(this) {
		arrEnlacesPestanyas.each( function (enlace,indice) {
			Event.observe(enlace,'click',lanzaComportamientoTooglearContenidoPestanyas.bind(this));  
		},this);
	}},
	lanzaComportamientoTooglearContenidoPestanyas: function (event) { with(this) {
		Event.stop(event);
		var enlace = Event.element(event);
		this.controlador["toggleaContenido"](enlace);
		this.controlador["modificaEstiloPestanya"](enlace);
		this.controlador["almacenaPestanyaActiva"](enlace);
	}},
	enEnlaceConAccion: function (enlace) { with(this) {
		if (!controlador.esUnEnlaceLightbox(enlace))
			Event.observe(enlace,'click',lanzaComportamientoEnEnlaceConAccion.bind(this)); 
	}},	
	lanzaComportamientoEnEnlaceConAccion: function (event) { with(this) {
		Event.stop(event);
		var enlace;
		if (Event.element(event).tagName != "A")
			enlace = Element.buscaElementoSuperior(Event.element(event), "A", Adesis.Constantes.tiposBusqueda.busquedaPorEtiqueta);
		else
			enlace = Event.element(event);
		
		this.controlador["accionaEnlace"](enlace);
	}},
	enEnlacesPestanyas: function (contenedor,selectorEncabezados) { with(this) {
		$A($$(selectorEncabezados)).each( function (encabezado) {
			Event.observe(encabezado,'click',lanzaComportamientoEnPestanyaHome.bind(this));  
		},this);
		return false;
	}},	
	lanzaComportamientoEnPestanyaHome: function (event) { with(this) {
		Event.stop(event);
		var enlace;
		if (Event.element(event).tagName != "A")
			enlace = Element.buscaElementoSuperior(Event.element(event), "A", Adesis.Constantes.tiposBusqueda.busquedaPorEtiqueta);
		else
			enlace = Event.element(event);
		
		this.controlador["accionaPestanya"](enlace);
	}}
	
}
