function Ajax(){
  // Propiedades
  this.xmlhttp = null;
  this.Load = Load;
  this.UserOnline = UserOnline;
}

function Load(){
  
  try {
   // Creación del objeto ajax para navegadores diferentes a Explorer
   this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   // o bien
   try {
     // Creación del objet ajax para Explorer
     this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	 catch (E) {
     this.xmlhttp = false;
     }
  }

  if (!this.xmlhttp && typeof XMLHttpRequest!='undefined') {
   this.xmlhttp = new XMLHttpRequest();
  }  
} 


function UserOnline(){
   		
	var _ajax = this;
	
	_ajax.xmlhttp.open("GET",document.location.protocol+"//"+document.location.host+"/web/users.php",true); 
	
	_ajax.xmlhttp.onreadystatechange=function() {//ha sido procesada la carga del AJAX
		 
	 if (_ajax.xmlhttp.readyState==4) {   
	     
	    if(_ajax.xmlhttp.status == 200) { //ok       
         if(!isNaN(_ajax.xmlhttp.responseText))    
	      document.getElementById('users').innerHTML = _ajax.xmlhttp.responseText;
		 
          setTimeout("objajax.UserOnline()",15000); 		 
		}else {
          document.getElementById('users').innerHTML = 1;
        }	   
	 }else{
	   //contenedor.innerHTML = "Cargando...";
	 }
	 
	}
	
	this.xmlhttp.send(null);// aqui se hace el envio del objeto	

}

var objajax = new Ajax();
objajax.Load();
objajax.UserOnline();




	   

      
