var actualGaleria;
var total_imagenes = 7;

function cargarCarrusel()
{
	b = setTimeout("cargarImagenesServidor()", 500);
}

function cargarImagenesServidor()
{
	var res = new Array();
	res[0] = "../../imagenes/cala2.gif";
	res[1] = "../../imagenes/cala3.gif";
	res[2] = "../../imagenes/cala4.gif";
	res[3] = "../../imagenes/cala5.gif";
	res[4] = "../../imagenes/cala6.gif";
	res[5] = "../../imagenes/cala1.gif";
	
	var total = res.length;
	var i;
	var d = document;
	
	actualGaleria = parseInt("0");
	
	for (i = 0; i < total; i++)
	{
		if (!d.vectorGaleria)
		{
			d.vectorGaleria = new Array();
		}
	
		d.vectorGaleria[i] = new Image;
		d.vectorGaleria[i].src = res[i];
		actualGaleria = parseInt(actualGaleria) + parseInt("1");
	}
	
	if (total > 1)
	{
		a = setTimeout("empezar(0)", 3000);    
	}
} 

function empezar(index)
{
	if (index >= actualGaleria)
	{
		index = 0;
	}
	
	if ((index >= 0) && (index <= 7))
	{		
		document.getElementById("div_banner").src = document.vectorGaleria[index].src;
		Fade("div_banner", 0, 100, 25);
		var parametro;
		
		parametro = parseInt(index) + parseInt("1");
		a = setTimeout("empezar(" + parametro + ")", 4000);  
	}
	else
	{
		document.getElementById("div_banner").src = document.vectorGaleria[8].src;	
		Fade("div_banner", 0, 100, 25);		
	}
}
		
function Fade(objID,CurrentAlpha,TargetAlpha,steps)
{
	var obj = document.getElementById(objID);
		
	CurrentAlpha = parseInt(CurrentAlpha);
	
	if (isNaN(CurrentAlpha))
	{
		CurrentAlpha = parseInt(obj.style.opacity*100);
		if (isNaN(CurrentAlpha))CurrentAlpha=100;
	}
		
	var DeltaAlpha=parseInt((CurrentAlpha-TargetAlpha)/steps);
	var NewAlpha = CurrentAlpha - DeltaAlpha;
		
	obj.style.opacity = (NewAlpha / 100);
	obj.style.MozOpacity = obj.style.opacity;
	obj.style.filter = 'alpha(opacity=' + NewAlpha + ')';
		
	if (steps > 1)
	{
		setTimeout('Fade("' + objID + '",' + NewAlpha + ',' + TargetAlpha + ',' + (steps - 1) + ')', 50);
	}
}
