var aMarquesinas = new Array();
var nDesplazamiento = 1; 	// Avanza pixel a pixel
var nVelocidad = 1000 / 25; // 45 veces por segundo

function Marquesina( oCapa, nPosicion )
{
	this.capa = oCapa;
	this.deslizable = true;
	this.posicion = nPosicion;
	this.arrancar = function()
	{
		this.deslizable = true;
		this.deslizar();
	}
	this.deslizar = function()
	{
		var nAltura = this.capa.style.top;
		nAltura = ( nAltura.length > 0 ) ? parseInt( nAltura ) : 0;
		this.capa.style.top = ( nAltura - nDesplazamiento ) + 'px';
		if ( ( this.capa.offsetHeight + nAltura + nDesplazamiento ) < 0 )
			this.capa.style.top = this.capa.parentNode.offsetHeight + 'px';
	}
	this.parar = function()
	{
		this.deslizable = false;
	}
	this.arrancar();
}

function parar( oCapa, bParada )
{
	aCapas = oCapa.getElementsByTagName( 'div' );
	for ( i = 0; i < aCapas.length; i++ )
		if ( aCapas[i].className == 'texto' )
			for ( j = 0; j < aMarquesinas.length; j++ )
				if ( aMarquesinas[j].capa == aCapas[i] )
					aMarquesinas[j].deslizable = !bParada;
}

function deslizar()
{
	for ( i = 0; i < aMarquesinas.length; i++ )
		if ( aMarquesinas[i].deslizable )
			aMarquesinas[i].deslizar();
}

function iniciarHome()
{
	if ( document.getElementById )
	{
		// Tratar las marquesinas del menú
		aCapas = document.getElementById( 'menu' ).getElementsByTagName( 'div' );
		for ( i = 0; i < aCapas.length; i++ )
		{
			oCapa = aCapas[i];
			if ( oCapa.className == 'texto' )
			{
				oPadre = oCapa.parentNode;
				if ( oPadre.className == 'marquesina' )
				{
					oPadre.style.overflow = 'hidden';
					nPosicion = aMarquesinas.length;
					aMarquesinas[ nPosicion ] = new Marquesina( oCapa, nPosicion );
					oPadre.onmouseout = function()
					{
						parar( this, false );
					}
					oPadre.onmouseover = function()
					{
						parar( this, true );
					}
				}
			}
		}
		setInterval( 'deslizar()', nVelocidad );
	}
}