//AJAX ******
function getHTTPObject()
        {
          var xmlhttp;
          if (!xmlhttp)
          {
            if(window.XMLHttpRequest)
            {
                    try
                    {
						//alert("new XMLHttpRequest();");
                        xmlhttp = new XMLHttpRequest();
                    }
                    catch(e)
                    {
                            alert("mensaje error 1.1")
                            xmlhttp = false;
                    }
    // branch for IE/Windows ActiveX version
            }
            else if(window.ActiveXObject)
            {
                       try
                       {
						  // alert("Msxml2.XMLHTTP");
                        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                      }
                      catch(e)
                      {
                        try
                        {
							//alert("Microsoft.XMLHTTP");
                          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch(e)
                        {
                        alert("mensaje de error 1.2")
                          xmlhttp = false;
                        }
                    }
            }
         }
        return xmlhttp;
}
/*
function getHTTPObject() {
    var xmlhttp;
*/
/*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
/*
 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}*/



function ajaxLoader(url,id,urlocal) {
var randomnumber=Math.floor(Math.random()*40)
 url=url //+ '?idSel=' + randomnumber
  

  if (document.getElementById) {
    var x = getHTTPObject();
  }
  if (x) {
    x.onreadystatechange = function() {
		
		//alert("Estado = " + x.readyState + " Status = "+ x.status);
        el = document.getElementById(id);
        el.innerHTML = '<br><br><br><br><center><img src="images/wait.gif">Por favor espere...<br><img src="images/charge.gif"></center>';
      if (x.readyState == 4 && x.status == 200) {
		  
        el.innerHTML = x.responseText;
		//En caso de que el Broker este dado de baja.
		if ( (x.responseText == '<html><head><title>WebSpeed error from messenger process (6019)</title></head><body bgcolor="#FFFFCC" text="#000000" link="#660066" vlink="#99000"><h1>WebSpeed error from messenger process (6019)</h1><p>Msngr: Failed to connect to the specified WebSpeed named service. Verify that the service has been started. Verify the configuration for the service is correct. (5804): Error -60</p></body></html>') 
		  || (x.responseText == '<html><head><title>WebSpeed error from messenger process (6019)</title></head><body bgcolor="#FFFFCC" text="#000000" link="#660066" vlink="#99000"><h1>WebSpeed error from messenger process (6019)</h1><p>Msngr: Failed to connect to the specified WebSpeed named service. Verify that the service has been started. Verify the configuration for the service is correct. (5804): Error -66</p></body></html>'))
		 {
			//el.innerHTML = '<img src="images/wait.gif"><br>Por el momento estamos actualizando la informaci&oacute;n,<br>por favor intente m&aacute;s tarde, <br>gracias.<br>';
			noUrl("erroresAjax/"+urlocal,id);
		  }
	  } else {
		 // alert('Estado = ' + x.readyState + ' Status = '+ x.status);
		 // noUrl(urlocal,id);
	  }
	  if (x.readyState == 4 && x.status != 200) {
		 // alert("estatus = "+ x.status);
		  if (x.status == 404) { //Not Found
			noUrl("erroresAjax/"+urlocal,id);
		  } else {
			noUrl("erroresAjax/mensaje.asp?errorCode="+x.status,id);
		  }
	  }
    }
    x.open("GET", url, true);
    x.send(null);
  } 
}
function noUrl(url,id) {

  if (document.getElementById) {
    var x = getHTTPObject();
  }
  if (x) {
    x.onreadystatechange = function() {
      if (x.readyState == 4 && x.status == 200) {
        el = document.getElementById(id);
        el.innerHTML = x.responseText;
		
      }else{

	  }
	  if (x.readyState == 4) {
  		  if (x.status == 500) {
			alert('!Servidor con falla 500!');
		  }
		  if (x.status == 404) {
			alert('!No encontro la página de aviso!');
		  }	  
	  }
    }
	
    x.open("GET", url, true);
    x.send(null);
	
  }
}
//AJAX ******
function Redireccionar(direccion)
{
window.location.replace(direccion)
}