<!--

var req = createXMLHttpRequest();

function createXMLHttpRequest() {
 var ua;
 if(window.XMLHttpRequest) {
 try {
  ua = new XMLHttpRequest();
 } catch(e) {
  ua = false;
 }
 } else if(window.ActiveXObject) {
  try {
	ua = new ActiveXObject("Microsoft.XMLHTTP");
  } catch(e) {
	ua = false;
  }
 }
return ua;
}

function AjaxComboBox(pComboTipo,pComboOrigen,pComboDestino,pComboDestinoSeleccion,pComboDestinoContent,pTodos)
{
	document.body.style.cursor = "wait";
	var pComboOrigenSeleccion=document.getElementById(pComboOrigen).options[document.getElementById(pComboOrigen).selectedIndex].value;
	if(pComboOrigenSeleccion==-1)
	{
		// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo todo por defecto
		combo=document.getElementById(pComboDestino);
		combo.length=0;
		var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=-1; nuevaOpcion.innerHTML=""; //...
		combo.appendChild(nuevaOpcion);	combo.disabled=true;
	}
	else
	{
		ajax=createXMLHttpRequest();
		var rnd982g = Math.random();	/* esta funcion sirve para generar un numero aleatorio y la envio en el URL, de tal forma que siempre se asegura enviar una direccion diferente para que no haga cache al mostrar los datos */
		ajax.open("GET", "../tools/ajax_combos.php?pComboDestino=" + pComboDestino + "&rnd982g=" + rnd982g + "&pComboTipo=" + pComboTipo + "&pComboOrigenSeleccion=" + pComboOrigenSeleccion + "&pComboDestinoSeleccion=" + pComboDestinoSeleccion + "&pTodos=" + pTodos, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Mientras carga elimino la opcion "Elige pais" y pongo una que dice "Cargando"
				combo=document.getElementById(pComboDestino);
				//combo.length=0; // aaron
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=-1; nuevaOpcion.innerHTML="Cargando...";
				combo.appendChild(nuevaOpcion); combo.disabled=true;	
			}
			if (ajax.readyState==4)
			{ 
				document.getElementById(pComboDestinoContent).innerHTML=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
	document.body.style.cursor = "default";
}

function AjaxText(pComboTipo,pComboOrigen,pComboDestino,pComboDestinoSeleccion,pComboDestinoContent,pTodos)
{
	document.body.style.cursor = "wait";
	var pComboOrigenSeleccion=document.getElementById(pComboOrigen).options[document.getElementById(pComboOrigen).selectedIndex].value;
	if(pComboOrigenSeleccion==-1 || pComboOrigenSeleccion==0)
	{
		document.getElementById(pComboDestino).value=0;
	}
	else
	{
		ajax=createXMLHttpRequest();
		var rnd982g = Math.random();	/* esta funcion sirve para generar un numero aleatorio y la envio en el URL, de tal forma que siempre se asegura enviar una direccion diferente para que no haga cache al mostrar los datos */
		ajax.open("GET", "../tools/ajax_text.php?pComboDestino=" + pComboDestino + "&rnd982g=" + rnd982g + "&pComboTipo=" + pComboTipo + "&pComboOrigenSeleccion=" + pComboOrigenSeleccion + "&pComboDestinoSeleccion=" + pComboDestinoSeleccion + "&pTodos=" + pTodos, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				document.getElementById(pComboDestino).value=0;
			}
			if (ajax.readyState==4)
			{ 
				document.getElementById(pComboDestino).value=ajax.responseText;
			} 
		}
		ajax.send(null);
	}
	document.body.style.cursor = "default";
}

//-->	