var curpage=1;
var timer=null;
var imagesWidth=null;
var imagesHeight=null;
var slideHeight=0;
var stopped = false;


function fnc_next()
{
	if (curpage == 0 || curpage>numpages)
	{curpage=1;}

	//stop();

	var obj=document.getElementById('rota'+curpage);

	obj.style.visibility = "hidden";
	obj.style.display = "none";
	obj.style.height = "1px";
	curpage++;
	if (curpage>numpages)
		curpage = 1;
	var obj=document.getElementById('rota'+curpage);
	obj.style.visibility = "visible";
	obj.style.display = "block";
	obj.style.height = slideHeight +"px";

	if(!stopped)
	{
		clearTimeout(timer);
		start();
	}

}

function fnc_prev()
{
	if (curpage == 0 || curpage>numpages)
		curpage=1;

	//Obtengo la nota Actual
	var obj=document.getElementById('rota'+curpage);
	if(obj)
	{
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		obj.style.height = "1px";
	}
	
	curpage--;
	if (curpage<=0)	curpage = numpages;

	//Obtengo la nota Anterior
	var obj=document.getElementById('rota'+curpage);
	if(obj)
	{
		obj.style.visibility = "visible";
		obj.style.display = "block";
		obj.style.height = slideHeight + "px";
	}

	if(!stopped)
	{
		clearTimeout(timer);
		start();
	}
}

function stopstart(img) 
{
	if (stopped) {
		img.src="archivos_rota/"+img.id+".gif";
		img.onmouseover="sgppnov(this);";
		img.onmouseout="sgppnou(this);";
		start();
	} else {
		img.src="archivos_rota/"+img.id+"_over.gif";
		img.onmouseover="";
		img.onmouseout="";
		stop();
	}
}

function stop() {
	if (!(stopped)) {
		clearTimeout(timer);
		stopped=true;
	}
}
function start() {
	timer=setTimeout('fnc_next()',10000);
	stopped=false;
}

function firsthide()
{
	//Oculto cada una de las imagenes
	for (i=1;i <= numpages;i++)
	{
		var obj=document.getElementById('rota'+i);
		if(obj)
		{
			if(i==1) 
			{
				imagesWidth	 = document.getElementById('img1').width;
				imagesHeight = document.getElementById('img1').height;
			}
			slideHeight = imagesHeight + 83;
			obj.style.visibility="hidden";
			obj.style.display = "none";
			obj.style.height = "1px";
			obj.style.overflow ="hidden";
			obj.style.top = "0px";
			obj.style.position = "relative";
			obj.style.border = "0px solid";
			obj.style.zIndex = 1;
		}
	}

	//Ubico la botonera segun el alto de la primer imagen
	if (numpages > 1)
	{
		var botonera=document.getElementById('botoneraSlide');
		if(botonera)
		{
			var top = imagesHeight - 18;
			var left = imagesWidth - 95;
			botonera.style.visibility = "visible";
			botonera.style.display = "block";
			botonera.style.top = top + "px";
			botonera.style.left = left+ "px";
			botonera.style.zIndex = "5";
		}
	}

	//Muestro la primer imagen
	curpage = 1;
	var obj=document.getElementById('rota'+curpage);
	if(obj)
	{
		obj.style.visibility = "visible";
		obj.style.display = "block";
		obj.style.height = slideHeight + "px";
		start();
	}
}

function sgppnov(img)
{
	img.src='archivos_rota/'+img.id+'_over.gif';
}
function sgppnou(img)
{
	img.src='archivos_rota/'+img.id+'.gif';
}
