/*
Copyright 2007 Michael Minault

Use, modification, and distribution are subject to the
Cigognes Website License (See accompanying file LICENSE.txt)
*/

function refreshPlayers(pathPrefix)
    {
    var POLL_TIME = 60; // sec
    var TIME_OUT = 25; // sec
    var playerList = document.getElementById("playerList");
    var statusElement = document.getElementById("playerListStatus");
    
    
    var xhReq = new XMLHttpRequest();
    
    var xhReqTimeout = setTimeout( function()
        {
        if (xhReq.readyState != 0 && xhReq.readyState != 4)
            {
            xhReq.abort();
            
            setTimeout("refreshPlayers('" + pathPrefix + "')", POLL_TIME * 1000);
            }
        }, TIME_OUT * 1000 );
    
    xhReq.onreadystatechange = function()
        {
        if (xhReq.readyState != 4)
            {
            return;
            }
        
        clearTimeout(xhReqTimeout);
        setTimeout("refreshPlayers('" + pathPrefix + "')", POLL_TIME * 1000);
        
        if (xhReq.status != 200)
            {
            
            return;
            }
        
        if ( xhReq.responseText.indexOf('class="exception"') != -1 )
            {
            
            }
        else
            {
           
            }
        
        playerList.innerHTML = xhReq.responseText;
        };
    
    xhReq.open("POST", pathPrefix + "player_list.php5", true);
    xhReq.send(null);
    };

