function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}



function carga_select(id_innerHTML, id_select1, id_select2, nombre_select2, txt_carga, tabla, tabla_elemento0, tabla_elemento1, tabla_elemento2, estilo)
{
	var valor=document.getElementById(id_select1).options[document.getElementById(id_select1).selectedIndex].value;
	if(valor==0)
	{
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		combo=document.getElementById(id_select2);
		combo.length=0;
		var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML = txt_carga;
		combo.appendChild(nuevaOpcion);	combo.disabled=true;
	}
	else
	{
		ajax=nuevoAjax();
		ajax.open("GET", "carga_select.php?seleccionado="+valor+"&id_select="+id_select2+"&nombre_select="+nombre_select2+"&tabla="+tabla+"&tabla_elemento0="+tabla_elemento0+"&tabla_elemento1="+tabla_elemento1+"&tabla_elemento2="+tabla_elemento2+"&estilo="+estilo, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
				combo=document.getElementById(id_select2);
				combo.length=0;
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
				combo.appendChild(nuevaOpcion); combo.disabled=true;	
			}
			if (ajax.readyState==4)
			{ 
				document.getElementById(id_innerHTML).innerHTML=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
}
