var curpage=1;
var timer=null;
var stopped=true;
var imagesWidth=null;
var imagesHeight=null;
var slideHeight=230;
function rpb() {
	var obj=document.getElementsByName('pause');
	if (obj) {
		for (i=0;i <= (obj.length-1);i++) {
			obj[i].src="img/btn_pausa.gif";
		}
	}
}

function fnc_next()
{
	if (stopped)
	{rpb();}
	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";
	start();
}

function fnc_prev()
{
	if (stopped)
		rpb();

	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<=0)
		curpage = numpages;
	var obj=document.getElementById('rota'+curpage);
	obj.style.visibility = "visible";
	obj.style.display = "block";
	obj.style.height = slideHeight + "px";
	start();
}

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

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

function firsthide()
{
	//Oculto cada una de las imagenes
	for (i=1;i <= numpages;i++)
	{
		var obj=document.getElementById('rota'+i);
		if(i==1) 
		{
			var img1 = document.getElementById('img1');
			imagesWidth = img1.width;
			imagesHeight = img1.height;
		}
		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');
		var top = imagesHeight + 227;
		var left = imagesWidth + 120;
		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);
	obj.style.visibility = "visible";
	obj.style.display = "block";
	obj.style.height = slideHeight + "px";
	start();
}

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

