// JavaScript Document


/*cambio de iconos del menú2*/
function cambiaIcono(nombre,icono){
	document.images[nombre].src = 'downloads/'+icono+'';
}

function cambiaIconoNormal(nombre,icono){
	document.images[nombre].src = 'downloads/'+icono+'';
}


//CAMBIO DE IMÁGENES DE LOS NIÑOS DE LA CABECERA
//metemos en una matriz cada imagen
fotos = ['url(../imagenes/foto_cabecera2.jpg)','url(../imagenes/foto_cabecera3.jpg)','url(../imagenes/foto_cabecera4.jpg)','url(../imagenes/foto_cabecera1.jpg)'];

n = 0;
var color = 0;//inicio valores de la opacidad de las imágenes
var suma = 10;

function aparecer(){
	if(document.getElementById("cabe")){
		document.getElementById("cabe").style.backgroundImage = fotos[n];
		var obj = document.getElementById('cabe');
		obj.style.display = "block";
		color += suma;
		
		if (!(color>=110)) {
			//obj.style.filter = 'alpha(opacity='+color+')';se lo he quitado poblemas en IE debido al brillo de los niños
			obj.style.opacity = color /100;
			obj.style.MozOpacity = color /100;
			obj.style.KHTMLOpacity = color /100;
			window.setTimeout ("aparecer();", 100);
		}
		else
		{
			n = n + 1;
			if(n>=fotos.length) n=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			color = 0;//valores de la opacidad de las imágenes
			suma = 10;
		}
	}
}
	
setInterval('aparecer()',8000);//8 segundos


//CAMBIO DE IMÁGENES DE HISTORIA
//metemos en una matriz cada imagen
fotosHistoria = ['url(imagenes/historia/foto2historia.jpg)','url(imagenes/historia/foto3historia.jpg)','url(imagenes/historia/foto1historia.jpg)'];
h = 0;
var colorHistoria = 0;//inicio valores de la opacidad de las imágenes
var sumaHistoria = 10;

function aparecerHistoria(){
	if(document.getElementById("historia")){
		document.getElementById("historia").style.backgroundImage = fotosHistoria[h];
		var objHis = document.getElementById('historia');
		objHis.style.display = "block";
		colorHistoria += sumaHistoria;
		if (!(colorHistoria>=110)) {
			objHis.style.filter = 'alpha(opacity='+colorHistoria+')';
			objHis.style.opacity = colorHistoria /100;
			objHis.style.MozOpacity = colorHistoria /100;
			objHis.style.KHTMLOpacity = colorHistoria /100;
			window.setTimeout ("aparecerHistoria();", 100);
		}
		else
		{
			h = h + 1;
			if(h>=fotosHistoria.length) h=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			colorHistoria = 0;//valores de la opacidad de las imágenes
			sumaHistoria = 10;
		}
	}
}

setInterval('aparecerHistoria()',5000);//5 segundos


//CAMBIO DE IMÁGENES DE INSTALACIONES Y RESUMEN
//metemos en una matriz cada imagen
fotosInsta = ['url(imagenes/insta-resumen/foto2instal-resumen.jpg)','url(imagenes/insta-resumen/foto3instal-resumen.jpg)','url(imagenes/insta-resumen/foto4instal-resumen.jpg)','url(imagenes/insta-resumen/foto5instal-resumen.jpg)','url(imagenes/insta-resumen/foto6instal-resumen.jpg)','url(imagenes/insta-resumen/foto1instal-resumen.jpg)'];
i = 0;
var colorInsta = 0;//inicio valores de la opacidad de las imágenes
var sumaInsta = 10;

function aparecerInsta(){
	if(document.getElementById("insta")){
		document.getElementById("insta").style.backgroundImage = fotosInsta[i];
		var objInsta = document.getElementById('insta');
		objInsta.style.display = "block";
		colorInsta += sumaInsta;
		if (!(colorInsta>=110)) {
			objInsta.style.filter = 'alpha(opacity='+colorInsta+')';
			objInsta.style.opacity = colorInsta /100;
			objInsta.style.MozOpacity = colorInsta /100;
			objInsta.style.KHTMLOpacity = colorInsta /100;
			window.setTimeout ("aparecerInsta();", 100);
		}
		else
		{
			i = i + 1;
			if(i>=fotosInsta.length) i=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			colorInsta = 0;//valores de la opacidad de las imágenes
			sumaInsta = 10;
		}
	}
}

setInterval('aparecerInsta()',5000);//5 segundos



//CAMBIO DE IMÁGENES DE SERVICIOS/COMEDOR E INFORMACIÓN
//metemos en una matriz cada imagen
fotosCome = ['url(imagenes/serviciosComeInfor/foto3ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto4ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto5ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto6ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto7ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto8ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto9ServiciosComedorInformacion.jpg)','url(imagenes/serviciosComeInfor/foto2ServiciosComedorInformacion.jpg)'];
c = 0;
var colorCome = 0;//inicio valores de la opacidad de las imágenes
var sumaCome = 10;

function aparecerCome(){
	if(document.getElementById("come")){
		document.getElementById("come").style.backgroundImage = fotosCome[c];
		var objCome = document.getElementById('come');
		objCome.style.display = "block";
		colorCome += sumaCome;
		if (!(colorCome>=110)) {
			objCome.style.filter = 'alpha(opacity='+colorCome+')';
			objCome.style.opacity = colorCome /100;
			objCome.style.MozOpacity = colorCome /100;
			objCome.style.KHTMLOpacity = colorCome /100;
			window.setTimeout ("aparecerCome();", 100);
		}
		else
		{
			c = c + 1;
			if(c>=fotosCome.length) c=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			colorCome = 0;//valores de la opacidad de las imágenes
			sumaCome = 10;
		}
	}
}

setInterval('aparecerCome()',5000);//5 segundos



//CAMBIO DE IMÁGENES DE SERVICIOS/RUTAS BUS E INFORMACIÓN
//metemos en una matriz cada imagen
fotosBus = ['url(imagenes/serviciosRutasBus/foto2ServiciosRutasBus.jpg)','url(imagenes/serviciosRutasBus/foto1ServiciosRutasBus.jpg)'];
b = 0;
var colorBus = 0;//inicio valores de la opacidad de las imágenes
var sumaBus = 10;

function aparecerBus(){
	if(document.getElementById("rutaBus")){
		document.getElementById("rutaBus").style.backgroundImage = fotosBus[b];
		var objBus = document.getElementById('rutaBus');
		objBus.style.display = "block";
		colorBus += sumaBus;
		if (!(colorBus>=110)) {
			objBus.style.filter = 'alpha(opacity='+colorBus+')';
			objBus.style.opacity = colorBus /100;
			objBus.style.MozOpacity = colorBus /100;
			objBus.style.KHTMLOpacity = colorBus /100;
			window.setTimeout ("aparecerBus();", 100);
		}
		else
		{
			b = b + 1;
			if(b>=fotosBus.length) b=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			colorBus = 0;//valores de la opacidad de las imágenes
			sumaBus = 10;
		}
	}
}

setInterval('aparecerBus()',5000);//5 segundos



//CAMBIO DE IMÁGENES DE CONÓCENOS/PRESENTACIÓN
//metemos en una matriz cada imagen
fotosPresen = ['url(imagenes/conoPresenBienvenidos/foto2ConoPresentBienvenidos.jpg)','url(imagenes/conoPresenBienvenidos/foto3ConoPresentBienvenidos.jpg)','url(imagenes/conoPresenBienvenidos/foto1ConoPresentBienvenidos.jpg)'];
p = 0;
var colorPresen = 0;//inicio valores de la opacidad de las imágenes
var sumaPresen = 10;

function aparecerPresen(){
	if(document.getElementById("presen")){
		document.getElementById("presen").style.backgroundImage = fotosPresen[p];
		var objPresen = document.getElementById('presen');
		objPresen.style.display = "block";
		colorPresen += sumaPresen;
		if (!(colorPresen>=110)) {
			objPresen.style.filter = 'alpha(opacity='+colorPresen+')';
			objPresen.style.opacity = colorPresen /100;
			objPresen.style.MozOpacity = colorPresen /100;
			objPresen.style.KHTMLOpacity = colorPresen /100;
			window.setTimeout ("aparecerPresen();", 100);
		}
		else
		{
			p = p + 1;
			if(p>=fotosPresen.length) p=0;//si llega al fin de la matriz de imágenes, vuelve al principio
			colorPresen = 0;//valores de la opacidad de las imágenes
			sumaPresen = 10;
		}
	}
}
setInterval('aparecerPresen()',5000);//5 segundos

