if (top != self) top.location.href = location.href;

function refreshStatus ()
{
  var addr = location.href.substring(0, location.href.indexOf('/', 8));
  var url = addr + '/num_players.php';
  var xmlHttp;

  if (document.all) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else {
    xmlHttp = new XMLHttpRequest();

    try { netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead'); }
    catch (e) { }
  }

  xmlHttp.onreadystatechange = function () {
    if (xmlHttp.readyState == 4) {
      var doc = xmlHttp.responseText;

      var statusdiv = document.getElementById("status");

      if (doc == -1) {
	statusdiv.className = "topbutton compteur offline";
        statusdiv.innerHTML = "<span>serveur</span>Hors ligne";
      } else if (doc == -2) {
        statusdiv.className = "topbutton compteur offline";
	statusdiv.innerHTML = "<span>serveur en</span>Maintenance";
      } else {
        statusdiv.className = "topbutton compteur online";

	var str = doc + "<span>";
	if (doc <= 1) str += "joueur connecté";
	else str += "joueurs connectés";
	str += "</span>";

        statusdiv.innerHTML = str;
      }
    }
  }

  xmlHttp.open ("GET", url);
  xmlHttp.send (null);
}

refreshStatus();
setInterval("refreshStatus()", 3000);

