var myElement;
var currentPage="HomeCCI1";


function openLink(myElement)
{
    if(myElement[myElement.curIndex].id == "HomeCCI1")
        location.href = document.location.toString() + "/ProyectoAmpliaciónAeropuertoTocumen/tabid/106/Default.aspx";
    else if(myElement[myElement.curIndex].id == "HomeCCI2")
        location.href = document.location.toString() + "/ProyectoAmpliaciónAeropuertoTocumen/tabid/106/Default.aspx";
    else if(myElement[myElement.curIndex].id == "HomeCCI3")
        location.href = document.location.toString() + "/ProyectoAmpliaciónAeropuertoTocumen/tabid/106/Default.aspx";
    /*else if(myElement[myElement.curIndex].id == "HomeCCI4")
        location.href = document.location.toString() + "/ProyectoMulticentro/tabid/98/Default.aspx";
    else if(myElement[myElement.curIndex].id == "HomeCCI5")
        location.href = document.location.toString() + "/ProyectoBayside/tabid/61/Default.aspx";*/
}

function fadeInNext()
{
	if (!myElement || myElement.length < 1)
		return;

	var curEle;

	if (typeof myElement.curIndex == "undefined")
		myElement.curIndex = myElement.length - 1;
	else
		curEle = myElement[myElement.curIndex];

	myElement.curIndex = (myElement.curIndex+1)%myElement.length;
	var nextEle = myElement[myElement.curIndex];

	currentPage = nextEle.id;

	if (curEle)
		Spry.Effect.DoFade(curEle, { from: 100, to: 0 });
	Spry.Effect.DoFade(nextEle, { to: 100, finish: function(){ setTimeout(function(){ fadeInNext(); }, fadeInNext.interval); } });
}

fadeInNext.interval = 3000;


Spry.Utils.addLoadListener(function()
{
	// Find the bannerBox and setup any quotes inside it for fading.
    Spry.$$(".bannerBox").setStyle("position: relative;");
	myElement = Spry.$$(".banner").setStyle("position: absolute; top: 0px; left: 0px; opacity: 0; filter: alpha(opacity=0); cursor:hand; ");
	Spry.$$("#HomeCCI1, #HomeCCI2, #HomeCCI3").addEventListener("click", function(){openLink(myElement); return false; }, false);
	fadeInNext();
});