// JavaScript Document
var segundos = 8 //cada cuantos segundos cambia la imagen
var dire = "imagenes" //directorio o ruta donde están las imágenes

var imagenes=new Array()
	imagenes[0]="cabecera1.png"
	imagenes[1]="cabecera2.png"
	imagenes[2]="cabecera3.png"
	imagenes[3]="cabecera4.png"
	imagenes[4]="cabecera5.png"
	imagenes[5]="cabecera6.png"

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]
	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()',100)
	}
	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" onclick="inicio()" style="-moz-opacity:0"> ')
	document.writeln(' <img src="' + dire + imagenes[3] + '" name="foto" id="foto" onclick="inicio()">')
	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>')
