var wait_id = 'ajax-calendar-wait';
var container_id = 'ajax-calendar-container';

function showCalendar(month, year) {     
    showWaitMessage();
                                                              
    var TID = CPHttpRequest.InitThread(); 
    CPHttpRequest.SetAction(TID, updateCalendar); 
    CPHttpRequest.Send(TID, '/ajax/calendar.php', {'month': month, 'year': year}); 
    
    return false;
}

function updateCalendar(data) {
    var obCalendarContainer = document.getElementById(container_id); 
    if (obCalendarContainer) { 
        obCalendarContainer.innerHTML = data; 
    } 
    
    closeWaitMessage();
}

function showWaitMessage() {
    var obWaitContainer = document.getElementById(wait_id); 
    var obCalendarContainer = document.getElementById(container_id); 
    if (obWaitContainer && obCalendarContainer) { 
        obWaitContainer.style.display = 'block';    
        obCalendarContainer.style.display = 'none';
    }
}     

  
function closeWaitMessage() {
    var obWaitContainer = document.getElementById(wait_id); 
    var obCalendarContainer = document.getElementById(container_id);
    if (obWaitContainer && obCalendarContainer) { 
        obWaitContainer.style.display = 'none';  
        obCalendarContainer.style.display = 'block';
    } 
}
