var pos = 0;
var numfotos = 0;
var imagenes = new Array ();
var timer;

function slideinfo ()
{
	this.foto = "";
	this.html = "";
	this.link = "";
	this.timeout = "";
}

function slideshow ( data )
{
	pos = 0;

	for ( var i = 0; i < data.length; i++ )
	{
		if ( i == 0 )
			document.getElementById ("tablaviaje" + ( i + 1 ) ).style.background = "url(fondo_opciones_viajes1.gif)";
		else
			document.getElementById ("tablaviaje" + ( i + 1 ) ).style.background = "url(fondo_opciones_viajes0.gif)";
	}

	numfotos = data.length;
	imagenes = data;

	document.getElementById ("fotodiv").innerHTML = "<a href='" + data [0].link + "'><img src='" + data [0].foto + ".jpg' border=0></a>";

	if ( timer )
		clearTimeout ( timer );

	if ( data [0].timeout != "" )
		timer = setTimeout ( adelante, data [0].timeout );
	else
		timer = setTimeout ( adelante, 4000 );		
}

function adelante ()
{
	if ( timer )
		clearTimeout ( timer );
	
	if ( pos < numfotos - 1 )
		pos++;
	else
		pos = 0;

	for ( var i = 0; i < numfotos; i++ )
		document.getElementById ("tablaviaje" + ( i + 1 ) ).style.background = "url(fondo_opciones_viajes0.gif)";
		
	document.getElementById ("tablaviaje" + ( pos + 1 ) ).style.background = "url(fondo_opciones_viajes1.gif)";
	if ( imagenes [pos].html != "" )
		document.getElementById ("fotodiv").innerHTML = imagenes [pos].html;
	else
		document.getElementById ("fotodiv").innerHTML = "<a href='" + imagenes [pos].link + "'><img src='" + imagenes [pos].foto + ".jpg' border=0></a>";

	if ( imagenes [pos].timeout != "" )
		timer = setTimeout ( adelante, imagenes [pos].timeout );
	else
		timer = setTimeout ( adelante, 4000 );
}

function atras ()
{
	if ( timer )
		clearTimeout ( timer );
	
	if ( pos > 0 )
		pos--;
	else
		pos = numfotos - 1;

	for ( var i = 0; i < numfotos; i++ )
		document.getElementById ("tablaviaje" + ( i + 1 ) ).style.background = "url(fondo_opciones_viajes0.gif)";
		
	document.getElementById ("tablaviaje" + ( pos + 1 ) ).style.background = "url(fondo_opciones_viajes1.gif)";
	if ( imagenes [pos].html != "" )
		document.getElementById ("fotodiv").innerHTML = imagenes [pos].html;
	else
		document.getElementById ("fotodiv").innerHTML = "<a href='" + imagenes [pos].link + "'><img src='" + imagenes [pos].foto + ".jpg' border=0></a>";

	if ( imagenes [pos].timeout != "" )
		timer = setTimeout ( adelante, imagenes [pos].timeout );
	else
		timer = setTimeout ( adelante, 4000 );
}
