		var orden2 = "";

		var valores2 = new Array();
		var valores_anterior2 = new Array();
		var elemento2 = 'indice';
		var orden_anterior2 = 1;
		//para que el orden de variacion y volumen empiece siempre de mayor a menor, asistencia 9813
		var elemento_anterior2 = ""



		
		
		
		function indices_internacionales(ind) {
		var http2 = createRequestObject();
		http2.open('get', '/backend/indices_txt_int.php?indice=' + ind + '&r=' + Math.random());
		http2.onreadystatechange = function () {
	    		if(http2.readyState == 4){
		        	valores_anterior2 = valores2;
		        	valores2 = new Array();
		        	var response = http2.responseText;
			        var update = new Array();
			        var j = 0;
			       campos = response.split("#");
			        for (i = 1; i < campos.length; i++) {
			   		campos2 = campos[i].split("=");
			   		eval(campos2[0] + ' = campos2[1].split("|")');    	
			        }

			        for (i = 0; i <= valor.length - 2; i++) {
			        	valores2[i] = new val2(valor[i], precios[i], aperturas[i], maximos[i], minimos[i], anteriores[i], variaciones[i], variaciones_por[i], horas[i], horas_ver[i], codigos_valor[i]);
			       	}
			       	
			       	j = valor.length - 2;
			       	el_indice = new val2(valor[j], precios[j], aperturas[j], maximos[j], minimos[j], anteriores[j], variaciones[j], variaciones_por[j], horas[j], horas_ver[j], codigos_valor[j]);
			       	switch (orden_anterior2) {
					case 1:
						valores2.sort(ordenar_texto2);
						valores_anterior2.sort(ordenar_texto2);
						break;
					case 2: 
						valores2.sort(ordenar_texto_r2);
						valores_anterior2.sort(ordenar_texto_r2);
						break;	
					case 3:
						valores2.sort(ordenar_numero2);
						valores_anterior2.sort(ordenar_numero2);
						break;
					case 4:
						valores2.sort(ordenar_numero_r2);
						valores_anterior2.sort(ordenar_numero_r2);
						break;
					default:
						break;	
				}	
			       	mostrar_tabla2();	       	
	       		}
		}
			http2.send(null);
			setTimeout("indices_internacionales('"+ind+"')", 10000);
		}


		
		function mostrar_tabla2() {
			mostrar_cabecera_tabla2();

			var j = 0;
			/*
			window.document.getElementById("indice" + j).innerHTML = el_indice.indice;
	        	window.document.getElementById("precio" + j).innerHTML = el_indice.precio;
	        	window.document.getElementById("apertura" + j).innerHTML = el_indice.apertura;
	        	window.document.getElementById("maximo" + j).innerHTML = el_indice.maximo;
	        	window.document.getElementById("minimo" + j).innerHTML = el_indice.minimo;
	        	window.document.getElementById("anterior" + j).innerHTML = el_indice.anterior;
	        	
	        	if (el_indice.variacion > 0) {
	        		window.document.getElementById("variacion" + j).innerHTML = '<div class="sube">' + el_indice.variacion + "(" + el_indice.variacion_por + "%)</div>";
	        	}
	        	else if (el_indice.variacion < 0) {
	        		window.document.getElementById("variacion" + j).innerHTML = '<div class="baja">' + el_indice.variacion + "(" + el_indice.variacion_por + "%)</div>";
	        	}
	        	else {
	        		window.document.getElementById("variacion" + j).innerHTML = el_indice.variacion + "(" + el_indice.variacion_por + "%)";
	        	}
	        	
	        	window.document.getElementById("hora" + j).innerHTML = el_indice.hora_ver;	
				window.document.getElementById("favorito" + j).innerHTML = "<a href=\"javascript:annadirFav2('" + el_indice.codigo_valor + "');\"><img src=\"/img/ico_annadir_favoritos.gif\" width=17 height=17 border=0></a>";	
			*/

			for (i = 0; i < valores2.length; i++) { 
			//	for (i = 12; i < valores.length; i++) {
				enlace = valores2[i].codigo_valor;
				//enlace = enlace.replace("_","-"); 
				fin = enlace.length;
				inicio = enlace.indexOf("_") +1;
				enlace = enlace.substring(inicio,fin) ;
				s = new String(valores2[i].indice);
				s = s.replace(/ /g,"-");
				indice = valores2[i].indice.substr(0, 1).toUpperCase() + valores2[i].indice.substr(1);
		        	//window.document.getElementById("indice" + j).innerHTML = "<a href='/cotizaciones/" + enlace +"'>" + valores2[i].indice + "</a>";
		        	window.document.getElementById("indice" + j).innerHTML = "<a href='/cotizacion/" + s +".htm'>" + indice + "</a>";
		        	window.document.getElementById('indice_op' + j).innerHTML = valores2[i].indice;
		        	if (valores_anterior2.length > 0) {
			        	if (valores2[i].precio != valores_anterior2[i].precio) {
			        		window.document.getElementById("precio" + j).innerHTML = '<div style="font-size:12px"><b>' + valores2[i].precio + '</b></div>';
			        	}
			        	else {
			        		window.document.getElementById("precio" + j).innerHTML = valores2[i].precio;	
			        	}
			        }
			        else {
			        	window.document.getElementById("precio" + j).innerHTML = valores2[i].precio;	
			        }
		        	window.document.getElementById("apertura" + j).innerHTML = valores2[i].apertura;
		        	window.document.getElementById("maximo" + j).innerHTML = valores2[i].maximo;
		        	window.document.getElementById("minimo" + j).innerHTML = valores2[i].minimo;
		        	window.document.getElementById("anterior" + j).innerHTML = valores2[i].anterior;
		        	
		        	
		        	if (valores_anterior2.length > 0) {
		        		if (valores2[i].variacion != valores_anterior2[i].variacion) {
		        			if (valores2[i].variacion > 0) {
		        				window.document.getElementById("variacion" + j).innerHTML = '<div class="sube" style="font-size:13px"><b>' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</b></div>";
		        				}
		        			else if (valores2[i].variacion < 0) {
		        				window.document.getElementById("variacion" + j).innerHTML = '<div class="baja" style="font-size:13px"><b>' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</b></div>";
		        				}
		        			else {
		        				window.document.getElementById("variacion" + j).innerHTML = '<div style="font-size:13px"><b>' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</b></div>";
		        				}
		        			}
		        		else {
		        			if (valores2[i].variacion > 0) {
		        				window.document.getElementById("variacion" + j).innerHTML = '<div class="sube">' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</div>";
		        				}
		        			else if (valores2[i].variacion < 0) {
		        				window.document.getElementById("variacion" + j).innerHTML = '<div class="baja">' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</div>";
		        				}
		        			else {
		        				window.document.getElementById("variacion" + j).innerHTML = valores2[i].variacion + "(" + valores2[i].variacion_por + "%)";
		        				}
		        			}
		        		}
		       	 	else {
		        		if (valores2[i].variacion > 0) {
		        			window.document.getElementById("variacion" + j).innerHTML = '<div class="sube">' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</div>";
		        			}
		        		else if (valores2[i].variacion < 0) {
		        			window.document.getElementById("variacion" + j).innerHTML = '<div class="baja">' + valores2[i].variacion + "(" + valores2[i].variacion_por + "%)</div>";
		        			}
		        		else {
		        			window.document.getElementById("variacion" + j).innerHTML = valores2[i].variacion + "(" + valores2[i].variacion_por + "%)";
		        			}
		        		}
		        	window.document.getElementById("hora" + j).innerHTML = valores2[i].hora_ver;	
							//window.document.getElementById("favorito" + j).innerHTML = "<a  title=\"Añadir a tus favoritos\" href=\"javascript:annadirFav2('" + valores2[i].codigo_valor + "');\"><img src=\"/img/ico_annadir_favoritos.gif\" width=17 height=17 border=0></a>";	
							window.document.getElementById("cartera" + j).innerHTML = "<a href=\"/backend/comprar.php?mercado=" + valores2[i].codigo_valor + "\">- Añadir a Mi Cartera</a>";
        			window.document.getElementById("favorito" + j).innerHTML = "<a title=\"Añadir a tus favoritos\" href=\"javascript:annadirFav2('" + valores2[i].codigo_valor + "');\">- Añadir a Favoritos</a>";	
					j = j + 1;
		        }		
		    
		}

		function mostrar_cabecera_tabla2() {
			var arrColumnas = new Array("indiceI#Nombre#txt","precioI#Precio#num","aperturaI#Apertura#num","maximoI#Max.#num","minimoI#Min.#num","anteriorI#Ant.#num","variacion_porI#Variación#num","horaI#Hora#num");
			var estilo = "";
			var nombre = "";
			var nombre2 = "";
			var nombre_ver = ""; 
			var funcion_orden = "";
			var arrAux;
			var i=0;

			for(i=0;i<arrColumnas.length;i++) {
				arrAux = arrColumnas[i].split("#");
				nombre = arrAux[0];
				nombre2 = nombre.substring(0,(nombre.length)-1);
				nombre_ver = arrAux[1];
				funcion_orden = arrAux[2];
				funcion_orden = (funcion_orden == "num")?"ordenar_n":"ordenar_t";
				estilo = (orden2 == nombre2 || (i == 0 && orden2 == ""))?"asc":"";	
				if(estilo == "asc") {
					estilo = (orden_anterior2%2 == 0)?"asc":"des";
				}
				document.getElementById(nombre).innerHTML = "<a href=\"#\" onClick=\""+funcion_orden+"2('"+nombre2+"')\" class=\""+estilo+"\" title=\"ordenar por "+ nombre_ver+"\">"+nombre_ver+"</a><br>";
			}
		}

		
		function val2(indice, precio, apertura, maximo, minimo, anterior, variacion, variacion_por, hora, hora_ver, codigo_valor) {
			this.indice = indice;
			this.precio = precio;
			this.apertura = apertura;
			this.maximo = maximo;
			this.minimo = minimo;
			this.anterior = anterior;
			this.variacion = variacion;
			this.variacion_por = variacion_por;
			this.hora = hora;
			this.hora_ver = hora_ver;
			this.codigo_valor = codigo_valor;
		}
		
		function annadirFav2(indice) {
			setCookie('SIMB', indice, 'Fri, 31-Dec-2010 00:00:00 GMT', '/', '', '');
		}

		function ordenar_texto2(a, b) {
			an = eval("a." + elemento2);
			bn = eval("b." + elemento2);
			
			if (an < bn) {
				return -1;	
			}	
			else if (an > bn) {
				return 1;	
			}
			else {
				return 0;	
			}
		}
		
		function ordenar_numero2(a, b) {
			
			an = Number(eval("a." + elemento2));
			bn = Number(eval("b." + elemento2));
			
			if (an < bn) {
				return -1;	
			}	
			else if (an > bn) {
				return 1;	
			}
			else {
				return 0;	
			}
		}
		
		function ordenar_texto_r2(a, b) {
			an = eval("a." + elemento2);
			bn = eval("b." + elemento2);
			
			if (an < bn) {
				return 1;	
			}	
			else if (an > bn) {
				return -1;	
			}
			else {
				return 0;	
			}	
		}
		
		function ordenar_numero_r2(a, b) {
			an = Number(eval("a." + elemento2));
			bn = Number(eval("b." + elemento2));
			
			if (an < bn) {
				return 1;	
			}	
			else if (an > bn) {
				return -1;	
			}
			else {
				return 0;	
			}
		}
		
		function ordenar_t2(e) {
			elemento2 = e;
			switch (orden_anterior2) {
				case 1:
					valores2.sort(ordenar_texto_r2);
					valores_anterior2.sort(ordenar_texto_r2);
					orden_anterior2 = 2;
					break;
				case 2: 
					valores2.sort(ordenar_texto2);
					valores_anterior2.sort(ordenar_texto2);
					orden_anterior2 = 1;
					break;	
				default:
					valores2.sort(ordenar_texto2);
					valores_anterior2.sort(ordenar_texto2);
					orden_anterior2= 1;
					break;
				
			}	
			orden2 = e;
			mostrar_tabla2();
		}
		
		function ordenar_n2(e) {
			elemento2 = e;
			// asistencia 9813
			if (elemento2 == "variacion_por" && elemento_anterior2 != "variacion_por") {
				orden_anterior2 = "";
				}
			if (elemento2 == "volumen" && elemento_anterior2 != "volumen") {
				orden_anterior2 = "";
				}
			switch (orden_anterior2) {
				case 3:
					valores2.sort(ordenar_numero_r2);
					valores_anterior2.sort(ordenar_numero_r2);
					orden_anterior2 = 4;
					break;
				case 4:
					valores2.sort(ordenar_numero2);
					valores_anterior2.sort(ordenar_numero2);
					orden_anterior2 = 3;
					break;
				default:
					valores2.sort(ordenar_numero_r2);
					valores_anterior2.sort(ordenar_numero_r2);
					orden_anterior2 = 4;
					break;
				
			}
			elemento_anterior2 = elemento2;
			orden2 = e;
			mostrar_tabla2();
		}
