

/*****************************************************************************
Presentación de Imágenes3 (SlideShow) por Tunait! 6/agosto/03
Actualizado el 28/12/2003
Si quieres usar este script en tu sitio eres libre de hacerlo con la condición de que permanezcan intactas estas líneas, osea, los créditos.

http://javascript.tunait.com
tunait@yahoo.com 
******************************************************************************/
var segundos = 10 //cada cuantos segundos cambia la imagen
var dire = "recursos/imagenes/carteleria" //directorio o ruta donde están las imágenes

var imagenes=new Array()
	imagenes[0]="img1.jpg"
	imagenes[1]="img2.jpg"

if(dire != "" && dire.charAt(dire.length-1) != "/")
	{dire = dire + "/"}

var preImagenes = new Array()
for (pre = 0; pre < imagenes.length; 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]
	
	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()',10)
	}
	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="display:none"><img src="' + dire + imagenes[0] + '" name="foto2" id="foto2" onclick="inicio()" style="-moz-opacity:0"></div>')
	document.writeln('<a href="' + dire + imagenes[1] + '" title="add a caption to title attribute / or leave blank" class="smoothbox"> <img src="' + dire + imagenes[1] + '" name="foto" id="foto"  alt="ALT"><a/>')

	
}

document.writeln ('<style type="text/css">')
document.writeln ('#foto {')
if(iex){
	document.writeln ('filter: alpha(opacity=100);')
}
document.writeln ('}')
document.writeln ('#foto2 {')
if(iex){
	document.writeln ('filter: alpha(opacity=0);')
}
document.writeln ('}')
document.writeln ('</style>')


