var sending=false;

//create the Cross-browser XMLHttpRequest object
function poker_getTournaments(pURL,page,game,type,room) {
  var loading = document.getElementById('tournaments_loading');
  var table = document.getElementById('tournaments_table');
  loading.style.width = (table.clientWidth+1) + "px";
  loading.style.height = (table.clientHeight+1) + "px";
  loading.style.lineHeight = (table.clientHeight+1) + "px";
  loading.style.display = 'block';
  if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
    xmlhttp=new XMLHttpRequest();
    if (xmlhttp.overrideMimeType) {
      xmlhttp.overrideMimeType('text/xml');
    }
    xmlhttp.onreadystatechange=poker_postFileReady;
    xmlhttp.open("GET", pURL+'/'+page+'/'+game+'/'+type+'/'+room, true);
    xmlhttp.send(null);
  } else if (window.ActiveXObject) { //IE
    xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
    if (xmlhttp) {
      xmlhttp.onreadystatechange=poker_postFileReady;
      xmlhttp.open('GET', pURL+'/'+page, false);
      xmlhttp.send();
    }
  }
}

// function to handle asynchronus call
function poker_postFileReady() {
  if (xmlhttp.readyState==4) {
    if (xmlhttp.status==200) {
      if (xmlhttp.responseText != 'false') {
        document.getElementById('tournaments_span').innerHTML=xmlhttp.responseText;
      }
      document.getElementById('tournaments_loading').style.display = 'none';
    }
  }
}
