
function displayNews(news)
{

	if (news == 'enlinea')
	{
		pestana="enlinea";
		element_id="news_enlinea"
		fragment_url="/noticias_enlinea/noticias_enlinea.html";
		document.getElementById('news_enlinea').style.display = 'block';
		document.getElementById('news_titulares').style.display = 'none';
		document.getElementById('news_masvistas').style.display = 'none';
		//document.getElementById('not_todas_enlinea').style.display = 'block';
		//document.getElementById('not_todas_masvistas').style.display = 'none';
		//document.getElementById('not_todas_titulares').style.display = 'none';
		//document.getElementById("tab_enlinea").style.display = 'block';
		//document.getElementById("tab_titulares").style.display = 'none';
		//document.getElementById("tab_masvistas").style.display = 'none';
	}
	else if (news == 'titulares')
	{
		pestana="titulares";
		element_id="news_titulares"
		fragment_url="/noticias_enlinea/noticias_enlinea.html";
		document.getElementById('news_enlinea').style.display = 'none';
		document.getElementById('news_titulares').style.display = 'block';
		document.getElementById('news_masvistas').style.display = 'none';
		//document.getElementById('not_todas_enlinea').style.display = 'none';
		//document.getElementById('not_todas_masvistas').style.display = 'none';
		//document.getElementById('not_todas_titulares').style.display = 'block';
		//document.getElementById("tab_enlinea").style.display = 'none';
		//document.getElementById("tab_titulares").style.display = 'block';
		//document.getElementById("tab_masvistas").style.display = 'none';
	}
	else
	{
		pestana="";
		element_id="news_masvistas"
		fragment_url="/include/lo_mas_visto.html"
		document.getElementById('news_enlinea').style.display = 'none';
		document.getElementById('news_titulares').style.display = 'none';
		document.getElementById('news_masvistas').style.display = 'block';
		//document.getElementById('not_todas_enlinea').style.display = 'none';
		//document.getElementById('not_todas_masvistas').style.display = 'block';
		//document.getElementById('not_todas_titulares').style.display = 'none';
		//document.getElementById("tab_enlinea").style.display = 'none';
		//document.getElementById("tab_titulares").style.display = 'none';
		//document.getElementById("tab_masvistas").style.display = 'block';
	}
	
}

var contador = 10 ;//55;
var conta_reset= contador
var contador_max = 0;
var pestana="enlinea"
var fragment_url="/noticias_enlinea/noticias_enlinea.html";
var element_id="news_enlinea";

function Actualizar() 
{

	fragment_url=fragment_url+"?borraCache="+Math.random().toString();
	

	contador --;
	//alert(contador);
	
	
	//fragment_url="/include/noticias_enlinea_v3.html?borraCache="+Math.random().toString();
	
	
	if (contador < contador_max)
	{
		alert(contador+" - - " +fragment_url);
		cargar(fragment_url, element_id);//return;
		displayNews(pestana);
		contador = conta_reset;
	}
	window.setTimeout("Actualizar();",950);
}




var peticion = false;
 try {
  peticion = new XMLHttpRequest();
  } catch (trymicrosoft) {
  try {
		peticion = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (othermicrosoft) {
  try {
		peticion = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (failed) {
		peticion = false;
} 
}
}

/*if (!peticion)
  alert("ERROR AL INICIALIZAR!");
  */

function cargar(fragment_url, element_id) 
{ 	var element = document.getElementById(element_id); 
	/*element.innerHTML ='<table width="565" height="250" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center">&nbsp;</td></tr><tr><td height="20" align="center"><table width="100" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><img src="../img/gif/cargando.gif" width="16" height="16"/></td></tr><tr><td align="center" class="texto_naranjo">cargando</td></tr></table></td></tr><tr><td align="center">&nbsp;</td></tr></table>'; */
	peticion.open("GET", fragment_url);
	peticion.onreadystatechange = function() { 
	if (peticion.readyState == 4) { 
		element.innerHTML = peticion.responseText; 
		displayNews(pestana);
	} 
	} 
	peticion.send(null); 
}



function enviarFormulario(url,formid,element_id)
{
	var Formulario = document.getElementById(formid);
	var longitudFormulario = Formulario.elements.length;
	//alert(longitudFormulario);
	var cadenaFormulario = ""
	var sepCampos
	sepCampos = ""
	for (var i=0; i <= Formulario.elements.length-1;i++)
	{
	cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+escape(Formulario.elements[i].value);
	sepCampos="&";
	}
	//alert(cadenaFormulario);
	var element = document.getElementById(element_id);
	/*element.innerHTML = '<table width="565" height="250" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center">&nbsp;</td></tr><tr><td height="20" align="center"><table width="100" border="0" cellpadding="0" cellspacing="0"><tr><td align="center"><img src="../img/gif/cargando.gif" width="16" height="16"/></td></tr><tr><td align="center" class="texto">cargando</td></tr></table></td></tr><tr><td align="center">&nbsp;</td></tr></table>'; */
	peticion.open("POST", url, true);
	peticion.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
	peticion.onreadystatechange = function () {
		if (peticion.readyState == 4) {
		element.innerHTML = peticion.responseText
		}
	}
	peticion.send(cadenaFormulario);
}








