// JavaScript Document
	
	// Abre una nueva ventana	
	function abrirVentana(ruta,ancho,alto)
	{
	
		posIzq=0
		posSup=0
			
		if (screen)
		{
			posIzq= (screen.width/2) - (ancho/2)
			posSup= (screen.height/2) - (alto/2)
		}
		
		ancho=ancho+20;
		alto=alto+20;
		
		nuevaVentana=window.open(ruta,"Imagen","width=" + ancho + " ,height=" + alto + " ,left=" + posIzq + ",top=" + posSup + ",location=0,resizable=0,menubar=0, toolbar=0");
	}

	var contadorCambiarImagen = 1;
	var automaticoCambiarImagen = true;
	var miArray = new Array() 
	
	function CambiarImagenAutomatico(ruta, contenedorImagen, contenedorTexto, maxFotos, paso, automatico, textos)
	{
		if(!automatico)
		{
			automaticoCambiarImagen = false;
		}
					
		contadorCambiarImagen = contadorCambiarImagen + paso;
	
		if( contadorCambiarImagen < 1)
		{
			contadorCambiarImagen = maxFotos;
		}
		else if (contadorCambiarImagen > maxFotos)
		{
			contadorCambiarImagen = 1;
		}
		
		var img = document.getElementById(contenedorImagen);
		
		img.src = ruta +  contadorCambiarImagen.toString() + ".jpg";
		
		if( contenedorTexto!= "")
		{
			var texto = document.getElementById(contenedorTexto);
			
			texto.innerHTML = textos[contadorCambiarImagen];
		}
	}
	
	function CambiarImagen(ruta, contenedorImagen, contenedorTexto, maxFotos, paso, textos)
	{
		CambiarImagenAutomatico(ruta, contenedorImagen, contenedorTexto, maxFotos, paso, false, textos);
	}
	
	function AvanzaCambiarImagen(ruta, contenedorImagen, contenedorTexto, maxFotos, textos)
	{
		if(automaticoCambiarImagen)
		{
			CambiarImagenAutomatico(ruta, contenedorImagen, contenedorTexto, maxFotos, 1, true, textos);
		}
	}
	
	// GESTIONA LA CAPA
	function GestionarImagen(id, botonMostrar, botonOcultar,ocultar)
	{
		if (document.getElementById)
		{ //se obtiene el id
			var el = document.getElementById(id); //se define la variable "el" igual a nuestro div
			var bm = document.getElementById(botonMostrar); //se define la variable "el" igual a nuestro div			
			var bo = document.getElementById(botonOcultar); //se define la variable "el" igual a nuestro div
			
			if(ocultar)
			{
				bm.style.display = 'block' ; 
				bo.style.display = 'none' ; 
				el.style.display = 'none' ; //damos un atributo display:none que oculta el div
			}
			else
			{
				bm.style.display = 'none' ; 
				bo.style.display = 'block' ; 
				el.style.display = 'block' ; //damos un atributo display:block que oculta el div
			}		
		}
	}
	
	var contadorGestionarCapa = 1;
	
	
	// GESTIONA LA CAPA
	function GestionarCapas(maxCapas, paso)
	{
		contadorGestionarCapa =  contadorGestionarCapa + paso;
		
		if( contadorGestionarCapa < 1)
		{
			contadorGestionarCapa = maxCapas;
		}
		else if (contadorGestionarCapa > maxCapas)
		{
			contadorGestionarCapa = 1;
		}

		if (document.getElementById)
		{ //se obtiene el id

					
			for ( var i = 1; i<= maxCapas;i++)
			{
					var idCapa ='Capa' + i;

					var capa = document.getElementById(idCapa); //se define la variable "el" igual a nuestro div																
					
					if(contadorGestionarCapa == i)
					{
						capa.style.display = 'block' ; 
					}
					else
					{
						capa.style.display = 'none' ; 
					}
			}						
		}
	}
