//CODIGO QUE LANZA EL METODO CONTROLADOR	
Event.observe(window,"load",function(){
	
	Adesis.Controlador.initialize();
	Adesis.Desplegables.initialize();
});

/* inicio desplegables */
Adesis.Desplegables = {
	initialize: function () { with(this){
		$$(Selectores.plegablesEmpleo).each(function (desplegable) {
			Element.wrap(desplegable,'a',{'href':'#'});
			var enlace = desplegable.up();
			var contenido = enlace.next();
			contenido.setStyle({'display':'none'});
			Element.observe(enlace,'click',function (ev) {
				Event.stop(ev);
				contenido.toggle();
			});
		});
	}}
}
/* fin desplegables */

Adesis.Controlador = {
	hayEnlacesConAccion: false,
	hayEnlacesLightbox: false,
	initialize: function () { with(this){
		//corregirOnKeyPress();
		controlaComportamientoEnlaces();
		asignaRolesEstructuras();
		controlaComportamientoPestanyas();
		controlaComportamientoMapaGoogle();
	}},
	controlaComportamientoEnlaces: function () { with(this) {
		$$(Selectores.enlaces.enlaceConAccion).each ( function (enlace) {
			hayEnlacesConAccion = true;
		},this);
		if (hayEnlacesConAccion) modificaEnlacesConAccion();
		
	}},
	controlaComportamientoPestanyas: function () { with(this) {
		$$(Selectores.pestanyasInteractivasHome.contenedor).each ( function (contenedor) {
			modificaPestanyasHome(contenedor);
		},this);
		
	}},	
	modificaPestanyasHome: function (contenedor) {
		var modificardorPestanyas = new Adesis.Utilidades.ModificarPestanyasHome(this, contenedor);
	},	
	controlaComportamientoMapaGoogle: function () { with(this) {
		$$(Selectores.mapaGoogle).each ( function (contenedor) {
			modificaHTMLMapaGoogle(contenedor);
		},this);
		
	}},
	modificaHTMLMapaGoogle: function (contenedor) {
		var modificadorHTMLMapaGoogle = new Adesis.Utilidades.ModificarHTMLMapaGoogle(this, contenedor);
	},	
	modificaEnlacesConAccion: function () {
		var modificardorEnlacesConAccion = new Adesis.Utilidades.ModificarEnlacesConAccion(this);
	},	
	asignaRolesEstructuras: function () {
		new Adesis.Utilidades.ARIA.AsignarRolesEstructuras(this);
	},	
	insertaComportamiento: function (controlador) {with(this) {
		return new Adesis.ManipuladorComportamientos(controlador);
	}}
	
}


//CODIGO PARA CARGAR DISTINTOS EVENTOS DE LA APLICACION
Event.observe(window, 'load', lanzarEventos, false);

	function lanzarEventos() {
		//new Pelayo.Controlador();
	}
	
	
	
	(function(){
    function esIE(){
      return !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1)
    }
    if(!esIE()) return;
    function menu(){
		if (document.getElementById('menuNavegacion')){
			var listas = document.getElementById('menuNavegacion').getElementsByTagName('li'), i = listas.length;
			while(i--){
				listas[i].onmouseover = function(){
					this.className+= ' iehover';
				}
				listas[i].onmouseout = function(){
					this.className=this.className.replace(new RegExp(' iehover\\b'), '');
				}
			}
		}
    }
    window.attachEvent("onload", menu)
})();



