
function ControlAnuncios(NumAnuncios,Intervalo,NombreObjeto)
{
	this.NumAnuncios = NumAnuncios;					
	this.AnuncioSelec = 0;
	this.Retardo = Intervalo;
	this.RetardoActual = setTimeout('',1);
	this.Nombre=NombreObjeto;	
	
	this.RotaAnuncio=RotaAnuncio;
	this.PonAnuncio=PonAnuncio;
	this.MuestraAnuncio=MuestraAnuncio;
	this.OcultaAnuncio=OcultaAnuncio;
	
	//Comenzamos la rotación
	this.PonAnuncio(0);
	
	this.PonAnuncio(0);	
}

function PonAnuncio(Cual)
{
	clearTimeout(this.RetardoActual);
	if(Cual>=this.NumAnuncios || Cual<0)
		this.AnuncioSelec=0;
	else
		this.AnuncioSelec=Cual;
		
	//Limpiamos
	for(i=0;i<this.NumAnuncios;i++)
		this.OcultaAnuncio(i);
	
	//Mostramos
	this.MuestraAnuncio(this.AnuncioSelec);		
			
	this.RetardoActual=setTimeout("Anuncios"+this.Nombre+".RotaAnuncio()", this.Retardo);				
}	

function RotaAnuncio()
{		
	this.PonAnuncio(this.AnuncioSelec+1);		
}

function MuestraAnuncio(Cual)
{
	try{
	document.getElementById(this.Nombre+"Anuncio"+Cual).style.display="block";	
	}catch(Error){}	
	try{
	document.getElementById(this.Nombre+"AnuncioBoton"+Cual).setAttribute("class","AnuncioBotonSeleccionado");
	}catch(Error){}
	try{
	document.getElementById(this.Nombre+"AnuncioBoton"+Cual).setAttribute("className","AnuncioBotonSeleccionado");
	}catch(Error){}
	
}

function OcultaAnuncio(Cual)
{
	try{
	document.getElementById(this.Nombre+"Anuncio"+Cual).style.display="none";				
	}catch(Error){}
	try{
	document.getElementById(this.Nombre+"AnuncioBoton"+Cual).setAttribute("class","AnuncioBoton");
	}catch(Error){}
	try{
	document.getElementById(this.Nombre+"AnuncioBoton"+Cual).setAttribute("className","AnuncioBoton");
	}catch(Error){}
}		