function getXMLHttpRequest()
{
    var xmlhttp = null;

    if (window.XMLHttpRequest) // code for all new browsers
    {
        xmlhttp=new XMLHttpRequest();
    }
    else if (window.ActiveXObject) // code for IE5 and IE6
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    return xmlhttp;
}

function updateCalendar( month, year )
{
    var loadingIMG = 
        '<table cellspacing=\'0\' cellpadding=\'0\'>'+
        '<tr><td style=\'height:120px; vertical-align:middle; text-align:center;\'>'+
        '<img src=\'./css/immagini/loading.gif\' style=\'border:0px; vertical-align:middle; width:62px; height:13px;\' />'+
        '</td></tr>'+
        '</table>';

    // visualizzazione animazione di caricamento
    document.getElementById('cal_ajax').innerHTML = loadingIMG;

    var xmlHttp = getXMLHttpRequest();
    if( xmlHttp == null ) return;

    if( month < 10 ) month = '0' + month;
    var params = "cal_date=" + month + year;
    
    xmlHttp.open("POST", "calendardisplay.php", true);

    //Send the proper header information along with the request
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange = function() //Call a function when the state changes.
    {
        if( xmlHttp.readyState == 4 && xmlHttp.status == 200 )
        {
            document.getElementById('cal_ajax').innerHTML = xmlHttp.responseText;
        }
    }
    
    xmlHttp.send(params);
}

