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);
	}},
	enControlesDePaginacion: function (controlesPaginador, controlPausa) { with(this) {
		controlesPaginador.each( function (control) {
			Event.observe(control,'click',lanzaComportamientoMostrarDestacadoPorAccionUsuario.bind(this));  
		},this);
		
		controlPausa.each( function (control) {
			Event.observe(control,'click',lanzaComportamientoPausarOContinuar.bind(this));  
		},this);
		
		return false;

	
	}},
	lanzaComportamientoMostrarDestacadoPorAccionUsuario: function (event) { with(this) {
		Event.stop(event);
		var enlace;
		if (Event.element(event).tagName != "LI")
			controlPaginacion = Element.buscaElementoSuperior(Event.element(event), "LI", Adesis.Constantes.tiposBusqueda.busquedaPorEtiqueta);
		else
			controlPaginacion = Event.element(event);
		
		this.controlador["muestraDestacadoPorAccionUsuario"](controlPaginacion);
	}},	
	lanzaComportamientoPausarOContinuar: function (event) { with(this) {
		Event.stop(event);
		var enlace;
		if (Event.element(event).tagName != "A")
			controlPaginacion = Element.buscaElementoSuperior(Event.element(event), "A", Adesis.Constantes.tiposBusqueda.busquedaPorEtiqueta);
		else
			controlPaginacion = Event.element(event);
		
		this.controlador["pausaOContinuaAnimacion"](controlPaginacion);
	}},	
	enOpcionesMenu: function (arrEnlaces) { with(this) {
		arrEnlaces.each( function (enlace) {
			Event.observe(enlace,'click',lanzaComportamientoMostrarSubmenu.bind(this));   
		},this);
	}},
	lanzaComportamientoMostrarSubmenu: function (event) { with(this) {
		Event.stop(event);
		var control;
		if (Event.element(event).tagName != "LI")
			control = Element.buscaElementoSuperior(Event.element(event), "LI", Adesis.Constantes.tiposBusqueda.busquedaPorEtiqueta);
		else
			control = Event.element(event);
		this.controlador["accionaSubmenu"](control);
	}}
	
}
