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_seleccionar1, txt_seleccionar2, 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 "Seleccionar", 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_seleccionar1;

		combo.appendChild(nuevaOpcion);	combo.disabled=true;

	}

	else

	{

		ajax=nuevoAjax();

		ajax.open("GET", "carga_select.asp?seleccionado="+valor+"&id_select="+id_select2+"&nombre_select="+nombre_select2+"&tabla="+tabla+"&tabla_elemento0="+tabla_elemento0+"&tabla_elemento1="+tabla_elemento1+"&tabla_elemento2="+tabla_elemento2+"&txt_seleccionar=" + txt_seleccionar2 +"&estilo=estilo_"+estilo, true);			

		ajax.onreadystatechange=function() 

		{ 

			if (ajax.readyState==1)

			{

				// Mientras carga elimino la opcion "Seleccionar" 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)

			{ 

				txt=unescape(ajax.responseText);
				txt2=txt.replace(/\+/gi," ");
				document.getElementById(id_innerHTML).innerHTML=txt2;

			} 

		}

		ajax.send(null);		

	}

}
