var req; 
var ajax_url='/index.php/ajax_agenda/events_html/';

function get_callendar_xml(addme) 
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", ajax_url+addme, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", ajax_url+addme, true);
            req.send();
        }
    }
}

function processReqChange() 
{
    // only if req shows "complete"

    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
	     var calhtml = document.getElementById('calendar').innerHTML;
	     document.getElementById('calendar').innerHTML = req.responseText;
 	 } else if(req.status == 404) {
	   // Add a custom message or redirect the user to another page
	     document.getElementById('calendar').innerHTML = "File not found";
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}


