	var mov = true;
	var response = "";
	var primeraVez = true;

	function createRequestObject_t() {
	    	var ro;
        	var browser = navigator.appName;
		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
    			ro = new XMLHttpRequest();
		}
		return ro;
	}    
		
	var http_t = createRequestObject_t();
	var valores_t = new Array();
	
	function sndReq_t() {

		http_t.open('get', '/includes/ticker.php?r=' + Math.random());
	    http_t.onreadystatechange = handleResponse_t;
		http_t.send(null);

		//setTimeout("sndReq_t()", 10000);
	}

	function handleResponse_t() {
		
   		if(http_t.readyState == 4){
			valores_t = new Array();
			
			response += http_t.responseText;
			arrAux = response.split("###");
			numNoticias = arrAux[0];
			response2 = arrAux[1];
			campos = response2.split("|");
			 for (i = 0; i < campos.length - 1; i++) {
			campos2 = campos[i].split("#");
			valores_t[i] = new val_t(campos2[0], campos2[1], campos2[2], campos2[3]);
			}
		
		crea_valores(numNoticias);
		movimiento();

		mostrar_tabla_t(numNoticias);
		primeraVez = false;
		}
	}
	
	function mostrar_tabla_t(numNoticias) {
		
		for (i = 0; i < numNoticias; i++) {
			//window.document.getElementById("titular" + i).innerHTML = '<a href="javascript:noticia(' + valores_t[i].id + ')" class="tknoticia">' + valores_t[i].titular + ' [+]</a> ';
			window.document.getElementById("empresa" + i).innerHTML = valores_t[i].empresa + "&nbsp;";
			window.document.getElementById("fecha" + i).innerHTML = valores_t[i].fecha;
			window.document.getElementById("titular" + i).innerHTML = '<a href="javascript:noticia(' + valores_t[i].id + ')" onmouseover="javascript:parar();" onmouseout="javascript:seguir();">' + valores_t[i].titular + '</a>';
		}
	}

	function noticia(id_noticia) {
		ventanaSecundaria("noticia.php?id_noticia=" + id_noticia);
	}
	
	function val_t(id, empresa, titular, fecha) {
		this.id = id;
		this.empresa = empresa;
		this.titular = titular;
		this.fecha = fecha;
	}
	
	function movimiento() {

		if(mov) {
			diff = document.getElementById("ticker-contenedor").scrollHeight - document.getElementById("ticker-contenedor").offsetHeight;
//			diff = document.getElementById("ticker-contenedor").scrollHeight;
			document.getElementById("ticker-contenedor").scrollTop += 1;
			if (document.getElementById("ticker-contenedor").scrollTop >= diff) {
				document.getElementById("ticker-contenedor").scrollTop = 0;
				arrAux = response.split("###");
				numNoticias = arrAux[0];
				response2 = arrAux[1];
				campos = response2.split("|");
			    for (i = 0; i < campos.length - 1; i++) {
					campos2 = campos[i].split("#");
					valores_t[i] = new val_t(campos2[0], campos2[1], campos2[2], campos2[3]);
		        }
				crea_valores(numNoticias);
				mostrar_tabla_t(numNoticias);
			} 
		}
		setTimeout("movimiento()", 35);
	}
  	
  	function crea_valores(numNoticias) {
		resetea();
		for (i = 0; i < numNoticias; i++) {
			if(i==0) {
				if(primeraVez)
					window.document.getElementById("ticker-contenido").innerHTML += "<br><br><br><br><br><br>";
				else
					window.document.getElementById("ticker-contenido").innerHTML += "<br><br><br>";
			}
			window.document.getElementById("ticker-contenido").innerHTML += '<table border="0" cellspacing="0" cellpadding="0"><tr><td><div class="ticker-empresa" id="empresa'+i+'"></div></td><td><div class="ticker-fecha" id="fecha'+i+'"></div></td></tr><tr><td colspan="2"><div class="tknoticias" id="titular'+i+'"></div></td></tr></table><br><br>';
			window.document.getElementById("ticker-contenido").innerHTML += "<br><br><br>";
		}
  	}

	function resetea() {
		window.document.getElementById("ticker-contenido").innerHTML = "";
		//document.getElementById("ticker-contenedor").scrollTop = 0;
  	}

	function parar() {
		mov = false;
	}

	function seguir() {
		mov = true;
	}

	sndReq_t();
	
  	

