var iContImg=1;
var efectoActivo=1;
var fotoActual;
var divContent;
var tiempoAtenuacion;
var tiempoIntervalo;
var objFade;
var objFade2;
var objTime;
var next;
var numeroDivs;

//Setea la imagen por defecto que se verá, y comienza el intervalo del efecto.
function cargaEfecto(divCont,tIntervalo,tAtenuacion,nDivs)
{
	divContent		 = divCont;
	tiempoAtenuacion = tAtenuacion*1000;
	tiempoIntervalo	 = tIntervalo*1000;
	numeroDivs		 = nDivs;

	document.getElementById(divContent+"1").style.display="block";
	for(i=2;i<=numeroDivs;i++)
		document.getElementById(divContent+i).style.display="none";
	next = "SIG";
	objTime = setInterval("iniciaEfecto()",tiempoIntervalo);
}

//La foto actual comienza a desaparecer
function iniciaEfecto(){
	var iAux = iContImg;
	fotoActual = document.getElementById(divContent+iContImg); 
	objFade	 = new Spry.Effect.Fade(fotoActual,{duration:tiempoAtenuacion, from:'100', to:'0',toggle:true,setup:setupFunc});
	objFade.start();
}

//Función que se gatilla cuando comienza el objeto Fade, permite que la foto siguiente comience a aparecer.
 function setupFunc(elmentObj , FadeObj)
{
	cambiaFoto();
	fotoActual = document.getElementById(divContent+iContImg); 
	objFade2	 = new Spry.Effect.Fade(fotoActual,{duration:tiempoAtenuacion, from:'0', to:'100',toggle:true});
	objFade2.start();
}

//Incrementa o decrementa el indice de las fotos según corresponda.
function cambiaFoto()
{
	if(next == "SIG")
	{
		iContImg++;
		if (iContImg>numeroDivs)
			iContImg=1;
	}
	else
	{
		iContImg--;
		if (iContImg<1)
			iContImg=numeroDivs;
	}
}

//Inicia o detiene efecto, según corresponda
function PresentarFotos(idFoto)
{
	if(efectoActivo == 1)
	{
		clearInterval(objTime);
		objTime=0;
		efectoActivo=0;
		document.getElementById(idFoto).src = "/imagenes_2009/"+idFoto+"Play"+".gif";
	}
	else
	{
		objTime = setInterval("iniciaEfecto()",tiempoIntervalo);
		efectoActivo=1;
		document.getElementById(idFoto).src = "/imagenes_2009/"+idFoto+".gif";
	}
}

//siguiente div
function DivSiguiente()
{
	next = "SIG";
	iniciaEfecto();
}

//div anterior
function DivAnterior()
{
	next = "ANT";
	iniciaEfecto();
}

function getUrlDiv()
{
	window.location.href = arrUrl[iContImg];
}


