poker_page = 1;
poker_game = 'all';
poker_type = 'all';
poker_room = 'all';

//create the Cross-browser XMLHttpRequest object
function poker_getTournaments(pURL,page,game,type,room) {
  if (page == null) {page = poker_page;} else {poker_page = page;}
  if (game == null) {game = poker_game;} else {poker_game = game;}
  if (type == null) {type = poker_type;} else {poker_type = type;}
  if (room == null) {room = poker_room;} else {poker_room = 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+'/'+encodeURIComponent(page)+'/'+encodeURIComponent(game)+'/'+encodeURIComponent(type)+'/'+encodeURIComponent(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+'/'+encodeURIComponent(page)+'/'+encodeURIComponent(game)+'/'+encodeURIComponent(type)+'/'+encodeURIComponent(room), 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';
    }
  }
}
