	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();
	var elemento_t = 'indice';
	var mov = true;
	
	function sndReq_t() {
		http_t.open('get', '/apoyos/hoyinversion/ticker/ticker.php?r=' + Math.random());
	  http_t.onreadystatechange = handleResponse_t;
		http_t.send(null);
		setTimeout("sndReq_t()", 190000);
	}

	function handleResponse_t() {
    		if(http_t.readyState == 4){
    			
    			valores_t = new Array();
    			
	        	var response = http_t.responseText;
			//alert(response);
			campos = response.split("#");

			        
		        for (i = 1; i < campos.length; i++) {
		        //	alert(campos[i]);
		   		campos2 = campos[i].split("=");
		   		eval(campos2[0] + ' = campos2[1].split("|")');    	
		        }
		        for (i = 0; i < valor.length - 1; i++) {
				valores_t[i] = new val_t(valor[i], precios[i], variaciones[i], variaciones_abs[i], codigos[i]);
			}
			
			valores_t.sort(ordenar_texto_t);
			mostrar_tabla_t();
		}
	}
	
	function mostrar_tabla_t() {
		
		for (i = 0; i < 35; i++) {
	
			if (valores_t[i]) {	
				//window.document.getElementById("nombret" + i).innerHTML = '<a href="/cotizaciones/' + valores_t[i].codigo + '">' +  valores_t[i].indice + '</a>';
				if (valores_t[i].variacion >= 0) {
					window.document.getElementById("valor" + i).innerHTML = '<a href="http://www.finanzas.com/cotizacion/' + valores_t[i].codigo + '.htm" target="_blank"><span><strong>' + valores_t[i].indice + '</strong> ' + valores_t[i].precio + ' <img src="/hoyinversion/img/cotizaciones_sube_red.gif" alt="Sube" /> ' + valores_t[i].variacion + '%</span></a>';
					}
				else {
					window.document.getElementById("valor" + i).innerHTML = '<a href="http://www.finanzas.com/cotizacion/' + valores_t[i].codigo + '.htm" target="_blank"><span><strong>' + valores_t[i].indice + '</strong> ' + valores_t[i].precio + ' <img src="/hoyinversion/img/cotizaciones_baja_red.gif" alt="Baja" /> ' + valores_t[i].variacion + '%</span></a>';
					}
				/*
				//window.document.getElementById("preciot" + i).innerHTML = valores_t[i].precio;
				//window.document.getElementById("variaciont" + i).innerHTML = valores_t[i].variacion + " %";
				if (valores_t[i].variacion > 0) {
					window.document.getElementById("variaciont" + i).className = 'tk-sube';		
				}
			
				if (valores_t[i].variacion < 0) {
					window.document.getElementById("variaciont" + i).className = 'tk-baja';		
				}
				*/
			}
		}
	}
	
	function val_t(indice, precio, variacion, variacion_abs, codigo) {
		this.indice = indice;
		this.precio = precio;
		this.variacion = variacion;
		this.variacion_abs = variacion_abs;
		this.codigo = codigo;
	}
	
	function ordenar_texto_t(a, b) {
		
		an = eval("a." + elemento_t);
		bn = eval("b." + elemento_t);
		
		if (an < bn) {
			return -1;	
		}	
		else if (an > bn) {
			return 1;	
		}
		else {
			return 0;	
		}
	}
	
	function movimiento_t() {
  		if (mov) {
  			var diff = document.getElementById("contenedorticker").scrollWidth - document.getElementById("contenedorticker").offsetWidth;
  			document.getElementById("contenedorticker").scrollLeft += 2;
  			if (document.getElementById("contenedorticker").scrollLeft >= diff) {
  				document.getElementById("contenedorticker").scrollLeft = 0;
			}
  		}
  			setTimeout("movimiento_t()", 35);
  	}
  	
  	function crea_valores() {
  		
  		for (i = 0; i < 35; i++) {
		  	window.document.getElementById("ticker-contenido").innerHTML += '<span><strong><span id="nombret' + i + '" ><a href="#">Telefónica</a></span></strong>';
		  	window.document.getElementById("ticker-contenido").innerHTML += '<span id="preciot' + i + '" >231.158</span>';
		  	window.document.getElementById("ticker-contenido").innerHTML += '<span id="variaciont' + i + '" >2,5%</span>';
		}
  			
  	}
  	
  	function parar() {
  		mov = false;	
  	}
  	
  	function activar() {
  		mov = true;	
  	}
  	
  	/*
  	if (getCookie_t('TICKER') == 'ON' || getCookie_t('TICKER') == null) {
  		verticker();	
  	}
  	else {
  		noverticker();
  	}
  	*/
  	movimiento_t();
  	sndReq_t();
  	//sndReq_rg();
	
	

