    var peticion = false;
    var  testPasado = false;
    try {
      peticion = new XMLHttpRequest();
      } catch (trymicrosoft) {
      try {
     peticion = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
     try {
     peticion = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (failed) {
     peticion = false;
     }
     }
  }
   if (!peticion)
   alert("ERROR AL INICIALIZAR!");

   function cargarCombo (url, dia, mes, ano, element_id) {
       //Obtenemos el contenido del div
       //donde se cargaran los resultados
      var element =  document.getElementById(element_id);
       //Obtenemos el valor seleccionado del combo anterior
       //construimos la url definitiva
       //pasando como parametro el valor seleccionado
       var fragment_url = url+'?dia='+dia+'&mes='+mes+'&ano='+ano;
       //abrimos la url
       peticion.open("GET", fragment_url);
       peticion.onreadystatechange = function() {
           if (peticion.readyState == 4) {
   //escribimos la respuesta
   element.innerHTML = peticion.responseText;
          }
      }
      peticion.send(null);
   }

	function llamar(fragment_url, dia) {
		peticion.open("GET", fragment_url);
   		peticion.onreadystatechange = function() {
   			if (peticion.readyState == 4) {
   			//escribimos la respuesta
   				document.getElementById('calen').innerHTML = peticion.responseText;
   				j = 0;
   				while(j < document.getElementById('diascal').length)
   				{
   					if (document.getElementById('diascal').options[j].value != dia) {
   					cambiacal(document.getElementById('diascal').options[j].value);
   					}
   					j++;
   				}
   				cambiacal2(dia);
	          }
    	  }
    	peticion.send(null);
   	}
function tratarFecha(dia,mes,ano){
  cargarCombo('clases/cal.php', dia, mes, ano, 'calendarjo')
  cambiacal2(dia)
}
function cambiacal(id)
{
		var obj = document.getElementById('cal_'+id);
		obj.className = 'calrojo';
}
function cambiacal2(id)
{
		var obj = document.getElementById('cal_'+id);
		obj.className = 'calverde';
}
function tratarFecha2(dia,mes,ano){
	tratarFecha(dia,mes,ano);
	cambiacal2(dia);
}
