function getPot() {

    url = 'php/currentPot.php';
    sType = "homepage";

    var currentPot = new GetCurrentPot(url, sType, 'Paradise Bingo', displayHomepagePot);
    currentPot.doGet();

    var currentPot2 = new GetCurrentPot(url, sType, 'Classic Bingo V', displayHomepagePot);
    currentPot2.doGet();

    var currentPot3 = new GetCurrentPot(url, sType, 'Classic Bingo 111', displayHomepagePot);
    currentPot3.doGet();

    var currentPot4 = new GetCurrentPot(url, sType, 'Classic Bingo 1V', displayHomepagePot);
    currentPot4.doGet();

    var currentPot5 = new GetCurrentPot(url, sType, 'Big D Bingo', displayHomepagePot);
    currentPot5.doGet();
}
//window.onload = getPot();

/*
 * Handle coccurent AJAX requests 
 * Take an URL of server script, name of a bingo hall and name of callback function
 * When server returns a response, callback function will be invoked
 */
function GetCurrentPot(url, siteType, hallName, callback) {
    
    var xmlHttpObject = getXmlHttpObject();
    xmlHttpObject.onreadystatechange = function() { getCurrentPotHomepageChange(hallName) };
    
    function getXmlHttpObject() {

        var xmlHttpObj = null;
        try {
            // Firefox, Opera 8.0+, Safari
            xmlHttpObj = new XMLHttpRequest();
        }
        catch (e) {
            // Internet Explorer
            try {
                xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }

        return xmlHttpObj;

    } //getXmlHttpObject()


    function getCurrentPotHomepageChange(hall) {

        if (xmlHttpObject.readyState == 4) { 
            if (xmlHttpObject.status == 200) { 

                if(callback) {
                    callback(hall, xmlHttpObject.responseText);
                }
                //document.getElementById(hall).innerHTML = xmlHttpObject.responseText; 
            }
        }
    }


    this.doGet = function() {

        url = url + "?hallName=" + hallName;
        url = url + "&site=" + siteType;
        xmlHttpObject.open("GET", url, true);
        xmlHttpObject.send(null);
    }
}

/* Callback function when the response returns from server */
function displayHomepagePot(hName, response) {
    document.getElementById(hName).innerHTML = response; 
}


/* Get all current pot for a hall */
function getHallPot(hallName) {

    url = 'php/currentPot.php';
    site = 'hallPage';
    var hallPot = new GetCurrentPot(url, site, hallName, displayHomepagePot);
    hallPot.doGet();
}

