var ocupado = false;

var http = getXmlHttpObject(); 

function getXmlHttpObject(){
  try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e){
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function ajax(url,cad,func) {
  if (ocupado) {
    setTimeout('ajax("'+url+'","'+cad+'",'+func+')',100);
  }
  else {
    http.open("POST", url, true); 
    http.onreadystatechange = func; 
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    http.send(cad);
  }
}
