function handleHttpResponse() {
    if (http.readyState == 4) {
        if (http.responseText.indexOf('invalid') == -1) {
            var response = http.responseXML;
            calendario_agenda = document.getElementById('div_calendario');
            //alert("Borra el contenido del Calendario");
            document.getElementById("div_calendario").innerHTML="";
			//alert("Insertar el contenido al Calendario");
			calendario_agenda.innerHTML = response.getElementsByTagName('data').item(0).firstChild.data;
            //calendario_agenda.innerHTML = response.getElementsByTagName('data').item(0).firstChild.data;
            isWorking = false;
		}
    }
}

var isWorking = false;
function calendario_agenda(fech, lenguage)
{
    http = new XMLHttpRequest();
    calendario_agenda.innerHTML = "";
    if (!isWorking && http)
    {
        if (!fech)
        {
            alert("El parametro recibido no es el correcto, si el problema persiste, pongase en contacto con el administrador del sistema");   
        }
        else
        {
            var url = "../inc/calendario.php?date="+fech+"&lenguage="+lenguage;
            http.open("GET", url, true);
            http.onreadystatechange = handleHttpResponse;
            isWorking = true;
            http.send(null);
        }
   }
}

function calendario2(fech, lenguage){
    http = new XMLHttpRequest();
    calendario_agenda.innerHTML = "";
    if (!isWorking && http)
    {
        if (!fech)
        {
            alert("Poner error publico");   
        }
        else
        {
            var url = "../inc/calendario.php?date="+fech+"&lenguage="+lenguage;;
            http.open("GET", url, true);
            http.onreadystatechange = handleHttpResponse;
            isWorking = true;
            http.send(null);
        }
   }
}
