

/********************************************** Ã?LTIMA HORA **********************************************/

function avanzaUltimaHora(direccion)
{
	if (typeof idIntervaloUltimaHora != "undefined")              
		clearInterval(idIntervaloUltimaHora);
    if (direccion != "+1" && direccion != "-1") direccion = "+1";
    // Vemos quÃ© noticia se estÃ¡ mostrando
    var objSpan = document.getElementById("ultimaHora");
    var cStrong = objSpan.getElementsByTagName("strong");
    for (var i=0; i<cStrong.length; i=i+2)
    {
		if (cStrong[i].style.display == "") {
			break;var er_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		}
    }
    
    var prefijo = "ultima_hora_titulo_";
    var textoId = cStrong[i].getAttribute("id");
    var index = textoId.substring(prefijo.length, textoId.length - 1);

    var index_sig = ""; // Almacena el Ã­ndice de la siguiente noticia a mostrar
    switch(direccion)
    {
        case "+1":     // Si existe la siguiente mostramos la siguiente y si no volvemos a la primera
	        if (document.getElementById("ultimaHora_titulo_" + (parseInt(index) + 1)) != null)
	            index_sig = parseInt(index) + 1;
	        else
	            index_sig = 0;
	        break;
	   	case "-1":     // Si existe la siguiente mostramos la siguiente y si no volvemos a la Ã?ltima
	        if (document.getElementById("ultimaHora_titulo_" + (parseInt(index) - 1)) != null)
	            index_sig = parseInt(index) - 1;
	        else
	            index_sig = (cStrong.length / 2) - 1;
	        break;
    }

    cStrong[2 * parseInt(index)].style.display = "none";
    cStrong[2 * parseInt(index) + 1].style.display = "none";
    cStrong[2 * parseInt(index_sig)].style.display = "";
    cStrong[2 * parseInt(index_sig) + 1].style.display = "";
    idIntervaloUltimaHora = setInterval(function(){avanzaUltimaHora(direccion);}, 5000);
}
       
/** ******************************** TITULARES ********************************* */
function getPaginaTitulares(url, pag, per)
{
	var contenedor = document.getElementById('contenedor_titulares');
	
	new Ajax.Request(url, {   
			parameters: '?pag='+pag+'&periodo='+per,
			method: 'get',   
			onSuccess: function(respuesta) 
				{     					
					 contenedor.innerHTML = respuesta.responseText;
				}, 
			onFailure: function(respuesta) 
				{     				
					// alert("OcurriÃ³ un error determinado");
				} 		
		});
}
