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


var isWorking = false;
function calendario_agenda(fech)
{
    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;
            http.open("GET", url, true);
            http.onreadystatechange = handleHttpResponse;
            isWorking = true;
            http.send(null);
        }
   }
   
}

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

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