function AJAX(cargador)
{
  var obj;

  if (cargador) mostrarCargador();

  try
  {
    obj = new XMLHttpRequest();
  }
  catch (error)
  {
    try
    {
      obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (error)
    {
      try
      {
        obj = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (error)
      {
        return false;
      }
    }
  }

  return obj;
}


var ajax_obj = AJAX(false);
hay_ajax = (ajax_obj) ? true : false;
delete ajax_obj;

if (document.images)
{
  pic1= new Image(13,13);
  pic1.src="images/timer.gif";
}


function mostrarCargador()
{
  if (!document.getElementById('cargador'))
  {
    var carg = document.createElement('div');
    carg.setAttribute('id', 'cargador');
//     carg.setAttribute('style', 'line-height: 25px; height: 25px;');

    var img = document.createElement('img');
    img.setAttribute('src', 'images/timer.gif');
    img.setAttribute('alt', '');
    img.setAttribute('style', 'vertical-align: middle;');
    carg.appendChild(img);

    carg.appendChild(document.createTextNode(' Cargando...'));

    document.getElementById('contenido').appendChild(carg);
  }
  document.getElementById('cargador').style.visibility = 'visible';
}

function ocultarCargador()
{
  if (document.getElementById('cargador')) document.getElementById('cargador').style.visibility = 'hidden';
}

function TotalRemplace(str, old, nou)
{
  while (str.indexOf(old)>-1)
  {
    str = str.replace(old,nou);
  }
  return str;
}

function escapar(texto)
{
   if (encodeURIComponent) return encodeURIComponent(texto);
   return escape(texto);
//   texto = TotalRemplace(texto, '+', "%2b");
//   texto = TotalRemplace(texto, '\\',"%5c");
//   texto = TotalRemplace(texto, '&', "%26");
//   return texto;
}
