function creerCalendrier() {
	this.date=new Date();
	this.mois=Array("Janvier", "F&eacute;vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Ao&ucirc;t", "Septembre", "Octobre", "Novembre", "D&eacute;cembre");
	this.formatDate=formatDateCalendrier;
	this.getDate=getDateCalendrier;
	this.affiche=afficheCalendrier;
	this.getContenu=getContenuCalendrier;
}
function formatDateCalendrier(dt) {
	var Y=dt.getFullYear();
	var D=dt.getDate();
	if (D<10) {D="0"+D;}
	var M=dt.getMonth()+1;
	if (M<10) {M="0"+M;}
	return "?jour="+D+"&mois="+M+"&annee="+Y;
}
function getDateCalendrier(txtDt) {
	var dt=new Date();
	var regControleDate=new RegExp("^[0-9]{2}(/){1}[0-9]{2}(/){1}[0-9]{4}$","g");
	if (txtDt.match(regControleDate)) {
		dt.setDate(txtDt.substring(0,2));
		dt.setMonth(txtDt.substring(3,5)-1);
		dt.setFullYear(txtDt.substring(6,10));
		}
	return dt;
}
function afficheCalendrier() {
	var div=document.getElementById("divCalendrier");
	this.getContenu();
}
function getContenuCalendrier () {
	
	var mois=this.mois[this.date.getMonth()];
	var annee=this.date.getFullYear();
	var txtContenu="<table cellspacing=\"1\"><tr><td class=\"titre\"><a href=\"#;\" onclick=\"calendrier.date.setMonth("+(this.date.getMonth()-1)+");calendrier.getContenu();\"><<</a></td><td colspan=\"5\" class=\"titre\">"+mois+" "+annee+"</td><td class=\"titre\"><a href=\"#;\" onclick=\"calendrier.date.setMonth("+(this.date.getMonth()+1)+");calendrier.getContenu();\">>></a></td></tr>";
	txtContenu+="<tr><td class=\"jour\">L</td><td class=\"jour\">M</td><td class=\"jour\">M</td><td class=\"jour\">J</td><td class=\"jour\">V</td><td class=\"jour\">S</td><td class=\"jour\">D</td></tr>";
	txtContenu+="<tr>";
	
	var dtAujourdhui=new Date();
	var dtJour1=new Date();
	dtJour1.setDate(1);
	dtJour1.setMonth(this.date.getMonth());
	dtJour1.setFullYear(this.date.getFullYear());
	var nbJourDecalage=dtJour1.getDay();
	if (nbJourDecalage==0) { //Dimanche
		nbJourDecalage=7;
	}
	
	var nbCase=0;
	var dtBoucle=dtJour1;
	dtBoucle.setDate(1-nbJourDecalage);
	for (var i=0; i<42; i++) {
	  dtBoucle.setDate(dtBoucle.getDate()+1);
	  var txtDt=this.formatDate(dtBoucle);
	  var classe="moisActif";
	  if (dtBoucle.getMonth()!=this.date.getMonth()) {
	    classe="moisInactif";
		}
	  txtContenu+="<td class=\""+classe+"\"><a href=\"/"+txtDt+"\">"+dtBoucle.getDate()+"</a></td>";
	  nbCase++;
	  if (nbCase==7) {

	    txtContenu+="</tr>";
		if (i<41) {
		  txtContenu+="<tr>";
		  }
		nbCase=0;
		}
	}
	txtContenu+="</table>";
	  document.getElementById("divCalendrier").innerHTML=txtContenu;
}
var calendrier=new creerCalendrier();