// JavaScript Document

var segundos = 3 //cada cuantos segundos cambia la imagen
var dire = "galeria/" //directorio o ruta donde están las imágenes

var imagenes=new Array()
	imagenes[0]="1.jpg"
	imagenes[1]="2.jpg"
	imagenes[2]="3.jpg"
	imagenes[3]="4.jpg"
	imagenes[4]="5.jpg"
	imagenes[5]="6.jpg"
	imagenes[6]="7.jpg"
	imagenes[7]="8.jpg"
	imagenes[8]="9.jpg"
	imagenes[9]="10.jpg"
	imagenes[10]="11.jpg"

if(dire != "" && dire.charAt(dire.length-1) != "/")
	{dire = dire + "/"}

var preImagenes = new Array()
for (pre = 0; pre < imagenes.length-1; pre++)
	{
	preImagenes[pre] = new Image()
	preImagenes[pre].src = dire + imagenes[pre]
	}
cont=1
var iex = navigator.appName=="Microsoft Internet Explorer" ? true : false;
var fi = iex?'filters.alpha.opacity':'style.MozOpacity'



function presImagen()
{
	document.foto.src = document.foto2.src
	eval('document.foto.' + fi + ' = iex?100:1;')
	eval('document.foto2.' + fi + ' = 0')
	document.foto2.src= dire + imagenes[cont]
	document.foto.style.left = 0 - (document.foto.width/2)
	document.foto2.style.left = 0 - (document.foto2.width/2)
	if (cont < imagenes.length-1)
		{cont ++}
	else
		{cont=0}
	tiempo=window.setTimeout('Opacidad()',segundos*1000)
}
var opa = iex ? 100 : 1;
var opa2 = 0
function Opacidad(){
	if(opa >= 0){
		cambia()
		opa -= iex?10:0.1
		setTimeout('Opacidad()',75)
	}
	else{
	opa = iex?100:1;
		presImagen()
	}
}
function cambia()
{
	opaci = iex?100 : 1
	eval('document.foto.' + fi + ' = opa')
	eval('document.foto2.' + fi + ' = (opaci-opa)')
}
var tiempo
function inicio()
{
	clearTimeout(tiempo)
	Opacidad()
}

function escribe()
{
	document.writeln('<div style="position:relative; width: 5px; height: 5px;" id="fu"> ')
	document.writeln('<div align="left">')
	document.writeln('<img src="' + dire + imagenes[0] + '" name="foto2" id="foto2" style="-moz-opacity:0"> ')
	document.writeln(' <img src="' + dire + imagenes[10] + '" name="foto" id="foto" >')
	document.writeln(' </div></div>')
	document.foto.onload = centra
}

function centra()
{
	document.foto.style.left = 0 - (document.foto.width/2)
	document.foto2.style.left = 0 - (document.foto2.width/2)
}

document.writeln ('<style type="text/css">')
document.writeln ('#foto {')

if(iex)
{
	document.writeln ('filter: alpha(opacity=100);')
}

document.writeln ('position:absolute}')
document.writeln ('#foto2 {')

if(iex)
{
	document.writeln ('filter: alpha(opacity=0);')
}

document.writeln ('position:absolute}')
document.writeln ('</style>')

// Dibuja la primera imagen en pantalla
escribe()

// Se inicia automaticamente la galeria de fotos
setTimeout("inicio()",segundos*1000);


