var curpage=0;
var timer=null;
var imagesWidth=null;
var imagesHeight=null;
var slideHeight= "285";
var stopped = false;
var numpages = 0;
var arraySlides;
var obj;


function fnc_next()
{
	if (curpage > numpages-1)
	{
		curpage=0;
	}

	obj=arraySlides[curpage];
	obj.style.visibility = "hidden";
	obj.style.display = "none";
	obj.style.height = "1px";

	curpage++;

	if (curpage>numpages - 1) 
	{
		curpage = 0;
	}

	obj=arraySlides[curpage];
	obj.style.visibility = "visible";
	obj.style.display = "block";
	obj.style.height = slideHeight + "px";

	if(!stopped)
	{
		clearTimeout(timer);
		start();
	}

}

function fnc_prev()
{
	if (curpage>numpages)	curpage = 0;

	//Obtengo la nota Actual
	obj= arraySlides[curpage];

	if(obj)
	{
		obj.style.visibility = "hidden";
		obj.style.display = "none";
		obj.style.height = "1px";
	}
	
	curpage--;
	if (curpage<0)	curpage = numpages-1;

	//Obtengo la nota Anterior
	obj=arraySlides[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="noticias/Scripts/"+img.id+".gif";
		img.onmouseover="sgppnov(this);";
		img.onmouseout="sgppnou(this);";
		start();
	} else {
		img.src="noticias/Scripts/"+img.id+"_over.gif";
		img.onmouseover="";
		img.onmouseout="";
		stop();
	}
}

function stop() 
{
	if (!(stopped)) 
	{
		clearTimeout(timer);
		stopped=true;
	}
}

function start() 
{
	timer=setTimeout('fnc_next()',4000);
	stopped=false;
}


function firsthide()
{
	arraySlides = document.getElementsByName("rota1");
	numpages = arraySlides.length;

	if (numpages > 1)
	{
		var botonera = document.getElementById('botoneraSlide');
		if(botonera)
		{
			botonera.style.visibility = "visible";
			botonera.style.display = "block";
		}
	}


	for (i=0;i < numpages;i++)
	{

		if(i==0) 
		{
			imagesWidth	 = document.getElementById('imgSlide').width;
			imagesHeight = document.getElementById('imgSlide').height;
		}

		obj=arraySlides[i];
		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.zIndex = 1;
	}

	//Muestro la primer imagen
	curpage = 0;
	var firstSlide = arraySlides[curpage];

	if(firstSlide)
	{
		firstSlide.style.visibility = "visible";
		firstSlide.style.display = "block";
		firstSlide.style.height = slideHeight + "px";
		start();
	}
	
}

function sgppnov(img)
{
	img.src='noticias/Scripts/'+img.id+'_over.gif';
}
function sgppnou(img)
{
	img.src='noticias/Scripts/'+img.id+'.gif';
}