/*==================================================================================
FUNCION:	Constructor del oBannerTxt (banner de texto)
ARGS:		idBanner: cadena atributo ID del bloque DIV que alberga al banner
			lista: array de textos que aparecerán en el banner
			estilo: nombre del estilo CSS para el banner
DEVUELVE:	nada
DESCRIP:	Este objeto usa un bloque DIV para mostrar en su interior diferentes 
			textos que se van alternando.
===================================================================================*/
function oBannerTxt(idBanner, estilo)
{
this.textos = new Array();
this.oHtml= objHtml(idBanner);
this.oHtml.lnk = null;
this.estCss = estilo;
this.indTxt = 0;
this.actualizar = actualizar;
this.centrar = centrar;
this.ponerAncho = ponerAncho;
this.ponerAlto = ponerAlto;
this.agregarTxt = agregarTxt;
this.posx = -1;
this.oHtml.onclick = pulsar;
this.oHtml.onmouseover = new Function("this.style.cursor = 'hand'");
//Para navegadores modernos (standard) puede usarse appendChild

if (!this.oHtml.firstChild && this.oHtml.appendChild)
	{
	var nodo = document.createElement('SPAN');
	var texto = document.createTextNode("&nbsp;");
	nodo.appendChild(texto);
	this.oHtml.appendChild(nodo);
	}
else if (miNavegador.IE && miNavegador.Verent < 5)
	{
	this.oHtml.innerHTML = "<span>ttt</span>"	
	}
//Para el Netscape antiguo (versión < 6)
if (miNavegador.NS && !miNavegador.standard)
	{
	document.tags.A.textDecoration = "none";
	document.tags.A.color = null;
	}
/*==================================================================================
FUNCION:	agregar(texto, enlace). Método de oBannerTxt
ARGS:		texto: cadena de texto que se muestra.
			enlace: cadena de texto con la dirección URL que le corresponde.
DEVUELVE:	nada
DESCRIP:	Este método añade los textos y enlaces correspondientes al banner. A cada
			cadena le corresponde un enlace.
===================================================================================*/
function agregarTxt(texto, enlace, tam, color, peso, subr)
{
var ult = this.textos.length;
this.textos[ult] = new Array(2);
this.textos[ult].txt = texto;
this.textos[ult].lnk = enlace;
this.textos[ult].tam = tam ;
this.textos[ult].color = color;
this.textos[ult].estilo = estilo;
this.textos[ult].subr = subr || 'none';
}
/*==================================================================================
FUNCION:	pulsar(). Método de oBannerTxt
ARGS:		ninguno
DEVUELVE:	nada
DESCRIP:	Este método actúa como el hipervínculo del texto actual, enviando la página
			a la dirección almacenada en lnk.
===================================================================================*/
function pulsar()
{
if (this.lnk)
	location.href = this.lnk;
}	
/*==================================================================================
FUNCION:	actualizar(). Método de oBannerTxt
ARGS:		ninguno
DEVUELVE:	nada
DESCRIP:	Este método se encarga de actualizar el contenido del banner de texto y de 
			poner en la propiedad lnk del bloque DIV el valor del enlace correspondiente 
			a ese texto. La función es llamado periódicamente en un intervalo de tiempo 
			indicado en un setInterval
===================================================================================*/
 function actualizar()
 {
 var alto=0;
 if (!this.textos[0]) return;
 if (miNavegador.standard)
 	{
	 var capa = this.oHtml.firstChild;
	 var nodo = capa.firstChild;
 	 //capa.style.visibility="hidden";
	 nodo.nodeValue = "&nbsp;";
	 if (this.textos[this.indTxt].tam >0)
	 	{
		 capa.style.fontSize = this.textos[this.indTxt].tam +"px";
	 	 alto =(parseInt(this.oHtml.style.height) - this.textos[this.indTxt].tam)/2;
		 alto = Math.round(alto- this.textos[this.indTxt].tam/3)+"px";
		 }
	 if ( this.textos[this.indTxt].color)
	 	 capa.style.color = this.textos[this.indTxt].color;
	 if (this.textos[this.indTxt].estilo)
	 	 capa.style.fontweight = this.textos[this.indTxt].estilo;
	 if (this.textos[this.indTxt].subr)	 
		 capa.style.textDecoration =  this.textos[this.indTxt].subr;
	 capa.style.position = "relative";
	 capa.style.top = alto;
	 nodo.nodeValue = this.textos[this.indTxt].txt;
	 capa.style.visibility="visible";
	 }
 else{
 	if (miNavegador.IE && miNavegador.Verent < 5)
		{
		capa = this.oHtml.children[0];
		capa.innerText = this.textos[this.indTxt].txt;
		capa.style.fontSize = this.textos[this.indTxt].tam;
 		capa.style.color = this.textos[this.indTxt].color;
 	 	capa.style.fontweight = this.textos[this.indTxt].estilo;
	 	capa.style.textDecoration =  this.textos[this.indTxt].subr;
		}
	else 
		if (miNavegador.NS && !miNavegador.standard)
			{	
			document.classes[this.estCss].all.position="relative";
			document.classes[this.estCss].all.marginLeft= -50;
			this.oHtml.document.open();
			this.oHtml.document.write('<span id="b_div" class="'+this.estCss+'">');
			this.oHtml.document.write('<a href ="'+this.textos[this.indTxt].txt+'">');
			this.oHtml.document.write(this.textos[this.indTxt].txt);
			this.oHtml.document.write("</a>");
			this.oHtml.document.write('</span>')
			this.oHtml.document.close();
			}
	}		 
 this.oHtml.lnk = this.textos[this.indTxt].lnk;
 this.indTxt++;
 if (this.indTxt == this.textos.length)
	this.indTxt = 0; 
 }
/*==================================================================================
FUNCION:	ponerAncho(valor). Método del objeto oBannerTxt
ARGS:		número que indica el ancho que tendrá el banner
DEVUELVE:	nada
DESCRIP:	Pone el ancho del bloque que contiene al banner al valor pasado como argumento
===================================================================================*/
 function ponerAncho(valor)
 {
 if (this.oHtml.style)
 	this.oHtml.style.width = "538" + "px";
 else if (miNavegador.NS)
 		this.oHtml.clip.width = valor;
 }
/*==================================================================================
FUNCION:	ponerAlto(valor). Método del objeto oBannerTxt
ARGS:		número que indica el alto que tendrá el banner
DEVUELVE:	nada
DESCRIP:	Pone el alto del bloque que contiene al banner al valor pasado como argumento
===================================================================================*/
function ponerAlto(valor)
 {
 if (this.oHtml.style)
 	this.oHtml.style.height = valor +"px";
 else 
   if (miNavegador.NS && !miNavegador.standard)
 		this.oHtml.clip.height = valor;
 }
/*==================================================================================
FUNCION:	centrar(valor). Método del objeto oBannerTxt
ARGS:		no
DEVUELVE:	nada
DESCRIP:	Centra horizontalmente el banner en la ventana del navegador.
===================================================================================*/
function centrar()
 {
 var total = parseInt(window.screen.width);
 var ancho = 0;
 if (this.oHtml.style)
 	ancho = this.oHtml.style.width;
 else if(miNavegador.NS && !miNavegador.standard)
 	ancho = this.oHtml.clip.width;	
 ancho = parseInt(ancho);
 if (isNaN(ancho) && miNavegador.IE)
 	ancho = parseInt(estiloActual(this.oHtml, this.estCss, 'width'));
 var posHrz = Math.round((total - ancho)/2);
 if (this.oHtml.style)
	 this.oHtml.style.left= posHrz;
 else
  if (miNavegador.NS && !miNavegador.standard)
 	this.oHtml.left = posHrz;	 
 }
}
/*======================= FIN DEL CÓDIGO DEL OBJETO ============================*/
