// Referencia al objeto XMLHttpRequest
var objXML = false;

// Esta función crea una instancia del objeto
// XMLHttpRequest y devuelve su referencia
function CreaXHR()
{
  var ref = false; // No tenemos objeto

  try { // Intentamos crearlo en IE 5 con
   // MSXML 3.0 o posterior
   ref = new ActiveXObject('Msxml2.XMLHTTP');
  } catch (e1) { // si no funciona
   try { // lo intentamos como IE 5 con MSXML 2
     ref = 
        new ActiveXObject('Microsoft.XMLHTTP');
     }  catch (e2) { // si no funciona
     ref = false; // no tenemos objeto
   }
  }

  // si no tenemos objeto y existe el tipo
  // XMLHttpRequest como nativo
  if (!ref && (typeof XMLHttpRequest != 
    'undefined' || window.XMLHttpRequest)) 
    // lo creamos directamente
   ref = new XMLHttpRequest();  
   
  return ref; // devolvemos la referencia
}
