// JavaScript Document
var xhr = null;
 
// Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX
function getXhr(){
  if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
  else if(window.ActiveXObject){  
    try{
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
     }
    catch (e){
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
     }
   }
  else { 
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour"); 
    xhr = false; 
   } 
}


function funccal(year,month,day,nbyearmoins,nbyearplus,nbmonthmoins,nbmonthplus){
  getXhr();
  
  xhr.onreadystatechange = function(){
    if(xhr.readyState == 4 && xhr.status == 200){
	  
		  document.getElementById('calendrier').innerHTML =  xhr.responseText;
		  
     }
   }

	xhr.open("POST",'func_calendrier.php',true);
  	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

	if(nbyearmoins==true) { 
			year=year-1; 
	}
	if(nbyearplus==true) { 
			year=year+1; 
	}
	if(nbmonthmoins==true) { 
		if(month==1) { 
			month=12;
			year=year-1;
		}
		else month=month-1; 
	}
	if(nbmonthplus==true) { 
		if(month==12) { 
			month=1;
			year=year+1;
		}
		else month=month+1; 
	}
	xhr.send("year="+year+"&month="+month+"&day="+day);

}


function ajaxcal(year,month,day){
  getXhr();
  
  xhr.onreadystatechange = function(){
    if(xhr.readyState == 4 && xhr.status == 200){
		
	  
		  document.getElementById('evenement').innerHTML =  xhr.responseText;
		  
     }
   }

	

	xhr.open("POST",'calendrier_ajax.php',true);
  	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  	//no = document.getElementById('no').value;
	xhr.send("year="+year+"&month="+month+"&day="+day);

}
 
 