function TCalendar(id,position,x,y) {
//Attribut
	this.AId = id;
	this.AFixedX = (x==undefined)?-1:x;			// x position (-1 if to appear below control)
	this.AFixedY = (y==undefined)?-1:y;			// y position (-1 if to appear below control)
	this.APosition = (position==undefined)?"absolute":position;
	this.AStartAt = 1;			// 0 - sunday ; 1 - monday
	this.AShowWeekNumber = 0;	// 0 - don't show; 1 - show
	this.AShowToday = 0;		// 0 - don't show; 1 - show
	this.AShowLegend = 0;		// 0 - don't show; 1 - show
	this.AStyleToday = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#B9B8B3;text-align:center;font-size:9pt;color:white;font-family: Arial Verdana;cursor:default;padding:1px;z-index:99";
	this.AStyleCalendar = "border-left: #000000 0px solid;border-top: #000000 0px solid;border-right: #000000 0px solid;border-bottom: #000000 0px solid;background-color:#000000;text-align:left;font-size:9pt;color:white;font-family: Arial Verdana;cursor:default;padding:1px;z-index:99";
	this.AStyleEntete = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #F54C0F 1px solid;background-color:#FFFFFF;text-align:left;font-size:9pt;color:white;font-family: Arial Verdana;cursor:default;padding:1px;z-index:99";
	this.AStyleComment = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#B9B8B3;text-align:center;font-size:9pt;color:white;font-family: Arial Verdana;cursor:default;padding:1px;z-index:99";
	this.AStyleLegend = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#B9B8B3;text-align:center;font-size:9pt;color:white;font-family: Arial Verdana;cursor:default;padding:1px;z-index:99";
	this.AStyleComposantOut = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;font-weight:bold;color:black;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleComposantOver = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;font-weight:bold;color:black;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleCadrePopUp = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#B9B8B3;padding:1px;z-index:99";
	this.AStyleButtonPopUpOut = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#B9B8B3;font-size:9pt;text-align:center;color:white;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonPopUpOver = "border-left: #333333 1px solid;border-top: #333333 1px solid;border-right: #CAC9C8 1px solid;border-bottom: #CAC9C8 1px solid;background-color:#777777;font-size:9pt;text-align:center;color:white;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";

	this.AStyleCadreDay = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;text-align:center;color:white;font-family: Verdana;padding:1px;z-index:99";
	this.AStyleButtonDayOut = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;font-weight:bold;text-align:center;color:black;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDayOver = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#F54C0F;font-size:9pt;font-weight:bold;text-align:center;color:white;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDayHoliday = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;font-weight:bold;text-align:center;color:DarkGray;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDayWeek = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;text-align:center;font-weight:bold;color:DarkGray;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDaySelected = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;text-align:center;font-weight:bold;color:green;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDayOld = "border-left: #FFFFFF 1px solid;border-top: #FFFFFF 1px solid;border-right: #FFFFFF 1px solid;border-bottom: #FFFFFF 1px solid;background-color:#FFFFFF;font-size:9pt;text-align:center;font-weight:bold;color:#F54C0F;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleButtonDayUnselected = "border-left: #CAC9C8 1px solid;border-top: #CAC9C8 1px solid;border-right: #333333 1px solid;border-bottom: #333333 1px solid;background-color:#73091F;font-size:9pt;text-align:center;font-weight:bold;color:white;font-family: Verdana;cursor:pointer;padding:1px;z-index:99";
	this.AStyleNumberWeek = "background-color:#FFFFFF;font-size:9pt;text-align:center;color:black;font-family: Verdana;padding:1px";
	this.AStyleNameDay = "background-color:#FFFFFF;font-size:9pt;font-weight:normal;text-align:center;color:black;font-family: Verdana;padding:1px";

  	this.ADaySpacing = 0;
	this.ATypeAnim = 0;
	this.AVitesseAnim = 7;
	
	// CETTE PARTIE SE TROUVE DANS LE FICHIER CONFIG
	regexp = /\/Location\//i;
	if(document.URL.match(regexp))
	{
		//this.AImgDir = "/V2/FR/Inccalendrier/images/";
		this.AImgDir = "/Location/FR/Inccalendrier/images/";
	}
	else
	{
		this.AImgDir = "/FR/Inccalendrier/images/";
	}    // directory for images ... e.g. this.AImgDir="/img/"
	
	this.ADayCloses = new Array([0]);


	this.AMonthSelected = "";
	this.AYearSelected = "";
	this.ADateSelected = "";
	this.AOmonthSelected = "";
	this.AOyearSelected = "";
	this.AOdateSelected = "";
	this.AMonthConstructed = false;
	this.AYearConstructed = false;
	this.AIntervalID1 = "";
	this.AIntervalID2 = "";
	this.ATimeoutID1 = "";
	this.ATimeoutID2 = "";
	this.ACtlToPlaceValue = null;
	this.ACtlNow = null;
	this.ADateFormat = "jj/mm/yyyy";
	this.ANStartingYear = "";
	this.ADayWeek = false;
	this.ADayHoliday = false;
 	this.ABorne = null;

	this.AToday =	new	Date();
	this.ADateNow	 = this.AToday.getDate();
	this.AMonthNow = this.AToday.getMonth();
	this.AYearNow	 = this.AToday.getYear();
	if (!MS) this.AYearNow += 1900;

	this.ABShow = false;
	this.ABPageLoaded=false;

	this.AStrEaster = "P&acirc;ques";
	this.AStrEasterMonday = "Lundi de P&acirc;ques";
	this.AStrAscension = "Ascension";
	this.AStrPentecostMonday = "Lundi de Pentec&ocirc;te";
	this.AStrPentecost = "Pentec&ocirc;te";

	this.AMonthName = TabMois ;
	this.ADayName = (this.AStartAt==0)?TabJoursDim:TabJoursLun;
	
	//M&eacute;thodes:	
	this.MInit = TMInit;
	this.MPopUpCalendar = TMPopUpCalendar;
	this.MFormatDate = TMFormatDate;
	this.MConstructCalendar = TMConstructCalendar;
	this.MConstructDate = TMConstructDate;
	this.MWeekNbr = TMWeekNbr;
	this.MHideCalendar = TMHideCalendar;
	this.MDecMonth = TMDecMonth;
	this.MIncMonth = TMIncMonth;
	this.MStartDecMonth = TMStartDecMonth;
	this.MStartIncMonth = TMStartIncMonth;
	this.MCloseCalendar = TMCloseCalendar;
	this.MPopUpMonth = TMPopUpMonth;
	this.MConstructMonth = TMConstructMonth;
	this.MPopDownYear = TMPopDownYear;
	this.MPopDownMonth = TMPopDownMonth;
	this.MPopUpYear = TMPopUpYear;
	this.MConstructYear = TMConstructYear;
	this.MIncYear = TMIncYear;
	this.MDecYear = TMDecYear;
	this.MIncYearAuto = TMIncYearAuto;
	this.MDecYearAuto = TMDecYearAuto;
	this.MStartDecYear = TMStartDecYear;
	this.MStartIncYear = TMStartIncYear;
	this.MSelectYear = TMSelectYear;
	this.MShowDefault = TMShowDefault;
	this.MSetXY = TMSetXY;
  	this.MInitWeekDays = TMInitWeekDays;
	

	// Initialisation  
  	this.MInit();
}

function TMInitWeekDays () {
  var i = 0;
  this.ADayCloses.clear(); 
	while(arguments[i] != null)  
    this.ADayCloses.push(arguments[i++]);
}

function TMInit()	{
	var htmlText = "";
  var attStyle = "";
	
	// htmlText += "<div id='"+this.AId+"' style='z-Index: auto' width="+((this.AShowWeekNumber==1)?250:220)+">";
	// htmlText += "<table	border=0 cellpadding=0 cellspacing=0 width="+((this.AShowWeekNumber==1)?250:220)+">";
	htmlText += "<div id='"+this.AId+"' style='z-Index: auto' width="+((this.AShowWeekNumber==1)?290:260)+">";
	htmlText += "<table	border=0 cellpadding=0 cellspacing=0 width="+((this.AShowWeekNumber==1)?290:260)+">";
	htmlText += "<tr><td>";
	htmlText += "	<table id='"+this.AId+"_entete' width='100%'>";
	htmlText += "	<tr><td >";
	htmlText += "		<div id='"+this.AId+"_caption' style='z-Index: auto'>";
	htmlText += "			<table border=0 cellpadding=0 cellspacing=0><tr>";
	htmlText += "				<td id='"+this.AId+"_spanLeft' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");clearInterval("+this.AId+".AIntervalID1);' onmousedown='clearTimeout("+this.AId+".ATimeoutID1);"+this.AId+".ATimeoutID1=setTimeout(\""+this.AId+".MStartDecMonth()\",100)'	onmouseup='clearTimeout("+this.AId+".ATimeoutID1);clearInterval("+this.AId+".AIntervalID1)' onclick='javascript:"+this.AId+".MDecMonth();'><IMG id='"+this.AId+"_changeLeft' SRC='"+this.AImgDir+"FlecheGauche.gif' width=15 height=15 BORDER=0></td>";
	htmlText += "				<td width='80' align='center' id='"+this.AId+"_spanMonth' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanMonthBas\",null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanMonthBas\",null,\""+this.AStyleComposantOut+"\");'></td>";
	htmlText += "				<td id='"+this.AId+"_spanRight' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:clearInterval("+this.AId+".AIntervalID1);set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");' onmousedown='clearTimeout("+this.AId+".ATimeoutID1);"+this.AId+".ATimeoutID1=setTimeout(\""+this.AId+".MStartIncMonth()\",100)'	onmouseup='clearTimeout("+this.AId+".ATimeoutID1);clearInterval("+this.AId+".AIntervalID1)' onclick='javascript:"+this.AId+".MIncMonth();'><IMG id='"+this.AId+"_changeRight' SRC='"+this.AImgDir+"FlecheDroite.gif'	width=15 height=15 BORDER=0></td>";
	//htmlText += "				<td id='"+this.AId+"_spanMonthBas' valign='middle' onmouseover='javascript:"+this.AId+".MShowComment(\""+this.ASelectMonthMessage+"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanMonth\",null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:"+this.AId+".MShowComment(\"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanMonth\",null,\""+this.AStyleComposantOut+"\");' onclick='javascript:"+this.AId+".MPopUpMonth();'><IMG id='"+this.IAd+"_changeMonth' SRC='"+this.AImgDir+"FlecheBas.gif' WIDTH='15' HEIGHT='15' BORDER=0></td>";
	//htmlText += "				<td id='"+this.AId+"_spanMonthBas' valign='middle'  onmouseover='javascript:"+this.AId+".MShowComment(\""+this.ASelectMonthMessage+"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanMonth\",null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:"+this.AId+".MShowComment(\"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanMonth\",null,\""+this.AStyleComposantOut+"\");' onclick='javascript:"+this.AId+".MPopUpMonth();'></td>";
	htmlText += "				<td id='"+this.AId+"_spanMonthBas' valign='middle'></td>";
	htmlText += "				<td>&nbsp;&nbsp;</td>";
	htmlText += "				<td id='"+this.AId+"_spanLeftYear' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:clearInterval("+this.AId+".AIntervalID1);set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");' onmousedown='clearTimeout("+this.AId+".ATimeoutID1);"+this.AId+".ATimeoutID1=setTimeout(\""+this.AId+".MStartDecYear()\",100)'	onmouseup='clearTimeout("+this.AId+".ATimeoutID1);clearInterval("+this.AId+".AIntervalID1)' onclick='javascript:"+this.AId+".MDecYearAuto();'><IMG id='"+this.AId+"_changeLeft' SRC='"+this.AImgDir+"FlecheGauche.gif' width=15 height=15 BORDER=0></td>";
	htmlText += "				<td id='"+this.AId+"_spanYear' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanYearBas\",null,\""+this.AStyleComposantOver+"\");'	onmouseout='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanYearBas\",null,\""+this.AStyleComposantOut+"\");'></td>";
	htmlText += "				<td id='"+this.AId+"_spanRightYear' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");' onmouseout='javascript:clearInterval("+this.AId+".AIntervalID1);set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");' onmousedown='clearTimeout("+this.AId+".ATimeoutID1);"+this.AId+".ATimeoutID1=setTimeout(\""+this.AId+".MStartIncYear()\",100)'	onmouseup='clearTimeout("+this.AId+".ATimeoutID1);clearInterval("+this.AId+".AIntervalID1)' onclick='javascript:"+this.AId+".MIncYearAuto();'><IMG id='"+this.AId+"_changeRight' SRC='"+this.AImgDir+"FlecheDroite.gif'	width=15 height=15 BORDER=0></td>";
	//htmlText += "				<td id='"+this.AId+"_spanYearBas' valign='middle' onmouseover='javascript:"+this.AId+".MShowComment(\""+this.ASelectYearMessage+"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanYear\",null,\""+this.AStyleComposantOver+"\");'	onmouseout='javascript:"+this.AId+".MShowComment(\"\");set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanYear\",null,\""+this.AStyleComposantOut+"\");'	onclick='javascript:"+this.AId+".MPopUpYear()'><IMG id='"+this.IAd+"_changeYear' SRC='"+this.AImgDir+"FlecheBas.gif' WIDTH='15' HEIGHT='15' BORDER=0></td>";	
	htmlText += "				<td id='"+this.AId+"_spanYearBas' valign='middle' onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOver+"\");set_style_div(\"id\",\""+this.AId+"_spanYear\",null,\""+this.AStyleComposantOver+"\");'	onmouseout='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleComposantOut+"\");set_style_div(\"id\",\""+this.AId+"_spanYear\",null,\""+this.AStyleComposantOut+"\");'	onclick='javascript:"+this.AId+".MPopUpYear()'></td>";
	htmlText += "			</tr></table>";
	htmlText += "		</div>";
	htmlText += "	</td><td valign='middle' style='cursor:pointer'>";
	htmlText += "		<IMG SRC='"+this.AImgDir+"close.gif' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Fermer le calendrier' onclick='javascript:"+this.AId+".MHideCalendar();'>";
	htmlText += "	</td></tr>";
	htmlText += "	</table>";
	htmlText += "</td></tr>";
	htmlText += "<tr><td align=center>";
	htmlText += "	<div id='"+this.AId+"_content' style='z-Index: auto'></div>";
	htmlText += "</td></tr>";
		
			
	

	htmlText += "</table></div>";
	htmlText += "<div id='"+this.AId+"_selectMonth' style='z-index:+999;position:absolute;'></div>";
	htmlText += "<div id='"+this.AId+"_selectYear' style='z-index:+999;position:absolute;'></div>";

	document.write (htmlText);

	set_style_div("id",this.AId,null,this.AStyleCalendar);
	set_position_div("id",this.AId,null,this.APosition);
	set_style_div("id",this.AId+"_entete",null,this.AStyleEntete);
	
	
	
	set_style_div("id",this.AId+"_spanLeft",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanRight",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanLeftYear",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanRightYear",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanMonth",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanYear",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanYearBas",null,this.AStyleComposantOut);
	set_style_div("id",this.AId+"_spanMonthBas",null,this.AStyleComposantOut);
	
	this.AMonthConstructed=false;
	this.AYearConstructed=false;

	this.ABPageLoaded=true;
	this.MHideCalendar();
}



function TMConstructCalendar () {
	var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31);
	var dateMessage;
	var	startDate =	new	Date (this.AYearSelected,this.AMonthSelected,1);
	var endDate;
	var numDaysInMonth;
	var datePointer = 0;
	var sHTML = "";
	var sHint = "";
	var sStyle = "";
	var attStyle = "style";
	var datetype = null;
  

	if (this.AMonthSelected==1)	{
		endDate	= new Date (this.AYearSelected,this.AMonthSelected+1,1);
		endDate	= new Date (endDate	- (24*60*60*1000));
		numDaysInMonth = endDate.getDate();
	}
	else numDaysInMonth = aNumDays[this.AMonthSelected];

	dayPointer = startDate.getDay() - this.AStartAt;
		
	if (dayPointer<0) dayPointer = 6;

	sHTML +=	"<table	 id='"+this.AId+"_cadrejour' border=0 cellpadding=0 cellspacing=" + this.ADaySpacing + " width=100% ><tr>";

	if (this.AStyleNameDay.is_style()) attStyle = "style";
	else attStyle = "class";  
	for	(i=0; i<7; i++)	{
    sHTML += "<td width='27' "+attStyle+"='"+this.AStyleNameDay+"'>"+this.ADayName[i]+"</td>";
  }

	sHTML +="</tr><tr>";

	

	for	( var i=1; i<=dayPointer;i++ ) {sHTML += "<td>&nbsp;</td>";}
	
	for	( datePointer=1; datePointer<=numDaysInMonth; datePointer++ ) {
		dayPointer++;
		sHint = "";

		sStyle = this.AStyleButtonDayOut;

   
		if ((datePointer==this.ADateNow)&&(this.AMonthSelected==this.AMonthNow)&&(this.AYearSelected==this.AYearNow))
			sStyle = this.AStyleButtonDaySelected; 

		if ((datePointer==this.AOdateSelected) && (this.AMonthSelected==this.AOmonthSelected) && (this.AYearSelected==this.AOyearSelected))
			sStyle=this.AStyleButtonDayOld; 

		

		if	(this.ADayCloses.is_in(dayPointer%7)) 
			sStyle = this.AStyleButtonDayWeek; 

    	if (this.ABorne) {
      			datetype = String(this.AYearSelected)+String(this.AMonthSelected+1).fillPrevChar("0",2)+String(datePointer).fillPrevChar("0",2);
      			if (!this.ABorne.in_born(datetype))
				sStyle=this.AStyleButtonDayUnselected;
    	}  
    
		var regexp= /\"/g;
		sHint=sHint.replace(regexp,"&quot;");

		dateMessage = "onmouseover='javascript:set_style_div(\"id\",this.id,null,\""+this.AStyleButtonDayOver+"\");' onmouseout='javascript:set_style_div(\"id\",this.id,null,\""+sStyle+"\");' onclick='javascript:"+this.AId+".ADateSelected="+datePointer + ";"+this.AId+".MCloseCalendar();'";

		if ((sStyle == this.AStyleButtonDayUnselected) ||
			(sStyle == this.AStyleButtonDayHoliday && this.ADayHoliday) ||
			(sStyle == this.AStyleButtonDayWeek && this.ADayWeek))
			dateMessage = "";

		if (sStyle.is_style()) attStyle = "style";
		else attStyle = "class";  

		sHTML += "<td id='day_"+datePointer+"' "+dateMessage+" title=\"" + sHint + "\" "+attStyle+"='"+sStyle+"' >" + padZero(datePointer) + "</div>";
		sHTML += "</td>";

		sHTML += "";

		if ((dayPointer+this.AStartAt) % 7 == this.AStartAt) { 
			sHTML += "</tr><tr>" ;
			if ((this.AShowWeekNumber==1)&&(datePointer<numDaysInMonth)) {
    		if (this.AStyleNumberWeek.is_style()) attStyle = "style";
		    else attStyle = "class";  
    		sHTML += "<td align=center "+attStyle+"='"+this.AStyleNumberWeek+"'>" + (this.MWeekNbr(new Date(this.AYearSelected,this.AMonthSelected,datePointer+1))) + "&nbsp;</td>";
			}
		}
	}

	setCont("id",this.AId+"_content",null,sHTML);
	setCont("id",this.AId+"_spanMonth",null,"&nbsp;"+this.AMonthName[this.AMonthSelected]+"&nbsp;"); 
	setCont("id",this.AId+"_spanYear",null,"&nbsp;"+this.AYearSelected+"&nbsp;");
	set_style_div("id",this.AId+"_cadrejour",null,this.AStyleCadreDay);
}
	

function TMFormatDate(format) {
	return (this.ADateFormat.split(format).length < 3)?"":format;
}	

function TMPopUpCalendar(ctl,ctl2,format,borne,jourfermer,jourferier) {
	var	leftpos=-200;
	var	toppos=0;
	var formatChar = " ";
	var aFormat;
	var tokensChanged = 0;
	var aDate;
	
  this.ABorne = (borne == undefined || borne == null)?null:borne;
	this.ADayWeek   = (jourfermer == undefined || jourfermer == null)?false:jourfermer;
	//this.ADayHoliday   = (jourferier == undefined || jourferier == null)?false:jourferier;

	if (this.ABPageLoaded)
	{
		if (!is_visible_div("id",this.AId)) {
			this.ACtlToPlaceValue	= ctl2;
			this.ADateFormat = format;
			
			formatChar = 	this.MFormatDate(" ") +
							this.MFormatDate("/") +
							this.MFormatDate(".") +
							this.MFormatDate("-");

			tokensChanged =	0;

			if ( formatChar	!= "" ) {
				aFormat = this.ADateFormat.split(formatChar);
				aData =	this.ACtlToPlaceValue.value.split(formatChar);
				for	(i=0;i<3;i++) {
					
					if ((aFormat[i].toLowerCase()=="d") || (aFormat[i].toLowerCase()=="dd")) {
						this.ADateSelected = parseInt(aData[i], 10);
						tokensChanged ++;
					}
					else if	((aFormat[i].toLowerCase()=="m") || (aFormat[i].toLowerCase()=="mm")) {
						this.AMonthSelected =	parseInt(aData[i], 10) - 1;
						tokensChanged ++;
					}
					else if	(aFormat[i].toLowerCase()=="mmm")	{
						this.AMonthSelected= parseInt((aData[i])?aData[i].getNumMonth():null)-1;
						tokensChanged ++;
					}
					else if	(aFormat[i].toLowerCase()=="yyyy") {
						this.AYearSelected = parseInt(aData[i], 10);							
						tokensChanged ++;
					}
				}
			}
			if ((tokensChanged!=3)||isNaN(this.ADateSelected)||isNaN(this.AMonthSelected)||isNaN(this.AYearSelected)) {
				this.ADateSelected = this.ADateNow;
				this.AMonthSelected = this.AMonthNow;
				this.AYearSelected = this.AYearNow;
			}
			this.AOdateSelected = this.ADateSelected;
			this.AOmonthSelected = this.AMonthSelected;
			this.AOyearSelected = this.AYearSelected;


			this.MConstructCalendar ();
			this.ABShow = true;
			
			this.MSetXY();
      
			switch(this.ATypeAnim) {
				case 0: this.MShowDefault();break;
				
				default: this.MShowDefault();break;
			}	
		}
		else {
			if (this.ACtlNow != ctl) {
        hide_div("id",this.AId);
        this.MPopUpCalendar(ctl,ctl2,format,borne,jourfermer,jourferier);
      }
      else this.MHideCalendar();
		}
		this.ACtlNow = ctl;
	}
}

function TMSetXY() {
// C'est ici qu'on place le tableau par rapport au champ
	var x = get_x_obj(this.ACtlToPlaceValue)+120;
	var y = get_y_obj(this.ACtlToPlaceValue)+this.ACtlToPlaceValue.offsetHeight-20;
	var l = get_l_div("id",this.AId);
	var h = get_h_div("id",this.AId);
	if ((x+l) >= (left_fenetre()+largeur_fenetre())) 
		x = left_fenetre()+largeur_fenetre()-l-(MS?33:0);
	if ((y+h) >= (top_fenetre()+hauteur_fenetre())) 
		y = top_fenetre()+hauteur_fenetre()-h;
		
	
	set_x_div("id",this.AId,null,(this.AFixedX==-1)?x:this.AFixedX);
	set_y_div("id",this.AId,null,(this.AFixedY==-1)?y:this.AFixedY);
	
}

function TMShowDefault() {
	show_div("id",this.AId);
}

function TMHideCalendar()	{
	if (getElem("id",this.AId+"_selectMonth")) hide_div("id",this.AId+"_selectMonth");
	if (getElem("id",this.AId+"_selectYear")) hide_div("id",this.AId+"_selectYear");
  
	switch(this.ATypeAnim) {
		case 0: hide_div("id",this.AId);break;
	}	
}

function padZero(num) {
	return (num	< 10)? '0' + num : num ;
}

function TMConstructDate(d,m,y)
{
	sTmp = this.ADateFormat;
	sTmp = sTmp.replace	("dd","<e>");
	sTmp = sTmp.replace	("d","<d>");
	sTmp = sTmp.replace	("<e>",padZero(d));
	sTmp = sTmp.replace	("<d>",d);
	sTmp = sTmp.replace	("mmm","<o>");
	sTmp = sTmp.replace	("mm","<n>");
	sTmp = sTmp.replace	("m","<m>");
	sTmp = sTmp.replace	("<m>",m+1);
	sTmp = sTmp.replace	("<n>",padZero(m+1));
	sTmp = sTmp.replace	("<o>",this.AMonthName[m]);
	return sTmp.replace ("yyyy",y);
}

function TMCloseCalendar() {
	this.MHideCalendar();
	this.ACtlToPlaceValue.value = this.MConstructDate(this.ADateSelected,this.AMonthSelected,this.AYearSelected);
}

function TMStartDecMonth() {this.AIntervalID1 = setInterval(this.AId+".MDecMonth()",80);}

function TMStartIncMonth() {this.AIntervalID1 = setInterval(this.AId+".MIncMonth()",80);}

function TMStartDecYear() {this.AIntervalID1 = setInterval(this.AId+".MDecYearAuto()",80);}

function TMStartIncYear() {this.AIntervalID1 = setInterval(this.AId+".MIncYearAuto()",80);}

function TMIncMonth () {
	this.AMonthSelected++;
	if (this.AMonthSelected>11) {
		this.AMonthSelected=0;
		this.AYearSelected++;
	}
	this.MConstructCalendar();
}

function TMDecMonth () {
	this.AMonthSelected--;
	if (this.AMonthSelected<0) {
		this.AMonthSelected=11;
		this.AYearSelected--;
	}
	this.MConstructCalendar();
}

function TMIncYearAuto () {
	this.AYearSelected++;
	this.MConstructCalendar();
}

function TMDecYearAuto () {
	this.AYearSelected--;
	this.MConstructCalendar();
}

function TMConstructMonth() {
	var sHTML = "";
	var sName = "";
	
	this.MPopDownYear();
	if (!this.AMonthConstructed) {
		sHTML =	"";
		for	(i=0; i<12;	i++) {
			sName =	this.AMonthName[i];
			if (i==this.AMonthSelected){
				sName =	"<B>" +	sName +	"</B>";
			}
			sHTML += "<tr><td id='"+this.AId+"_m" + i + "' onmouseover='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOver+"\");' onmouseout='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOut+"\");' onclick='"+this.AId+".AMonthConstructed=false;"+this.AId+".AMonthSelected=" + i + ";"+this.AId+".MConstructCalendar();"+this.AId+".MPopDownMonth();event.cancelBubble=true'>&nbsp;" + sName + "&nbsp;</td></tr>";
		}

		setCont("id",this.AId+"_selectMonth",null,"<table id='"+this.AId+"_cadrepopupmonth' width=70 cellspacing=0 onmouseover='clearTimeout("+this.AId+".ATimeoutID1)'	onmouseout='clearTimeout("+this.AId+".ATimeoutID1);"+this.AId+".ATimeoutID1=setTimeout(\""+this.AId+".MPopDownMonth()\",100);event.cancelBubble=true'>" +	sHTML +	"</table>");
		set_style_div("id",this.AId+"_cadrepopupmonth",null,this.AStyleCadrePopUp);
		for	(i=0; i<12;	i++) 
			set_style_div("id",this.AId+"_m" + i,null,this.AStyleButtonPopUpOut);

		this.AMonthConstructed=true;
	}
}

function TMPopUpMonth() {
	this.MConstructMonth();
	set_x_div("id",this.AId+"_selectMonth",null,get_x_div("id",this.AId+"_spanMonth"));
	set_y_div("id",this.AId+"_selectMonth",null,get_y_div("id",this.AId+"_spanMonth")+get_h_div("id",this.AId+"_spanMonth"));
	show_div("id",this.AId+"_selectMonth");
}

function TMPopDownMonth()	{hide_div("id",this.AId+"_selectMonth");}

function TMIncYear() {
	var newYear = "";
	var txtYear = "";

	for	(i=0; i<7; i++){
		newYear	= (i+this.ANStartingYear)+1;
		if (newYear==this.AYearSelected) txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;";
		else txtYear = "&nbsp;" + newYear + "&nbsp;";
		setCont("id",this.AId+"_y"+i,null,txtYear);
	}
	this.ANStartingYear ++;
	this.ABShow=true;
}

function TMDecYear() {
	var newYear = "";
	var txtYear = "";
	
	for	(i=0; i<7; i++){
		newYear	= (i+this.ANStartingYear)-1;
		if (newYear==this.AYearSelected) txtYear = "&nbsp;<B>" + newYear + "</B>&nbsp;";
		else txtYear = "&nbsp;" + newYear + "&nbsp;"; 
		setCont("id",this.AId+"_y"+i,null,txtYear);
	}
	this.ANStartingYear --;
	this.ABShow=true;
}

function TMSelectYear(nYear) {
	this.AYearSelected=parseInt(nYear+this.ANStartingYear);
	this.AYearConstructed=false;
	this.MConstructCalendar();
	this.MPopDownYear();
}

function TMConstructYear() {
	var sHTML =	"";
	var sName = "";
	var j = 0;
	
	this.MPopDownMonth();
	
	if (!this.AYearConstructed) {
		sHTML =	"<tr><td id='"+this.AId+"_moins' onmouseover='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOver+"\");' onmouseout='clearInterval("+this.AId+".AIntervalID1);set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOut+"\");' onmousedown='clearInterval("+this.AId+".AIntervalID1);"+this.AId+".AIntervalID1=setInterval(\""+this.AId+".MDecYear()\",30)' onmouseup='clearInterval("+this.AId+".AIntervalID1)'>-</td></tr>";
		j =	0;
		this.ANStartingYear =	this.AYearSelected-3;
		for	(i=(this.AYearSelected-3); i<=(this.AYearSelected+3); i++) {
			sName =	i;
			if (i==this.AYearSelected){
				sName =	"<B>" +	sName +	"</B>";
			}
			sHTML += "<tr><td id='"+this.AId+"_y" + j + "' onmouseover='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOver+"\");' onmouseout='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOut+"\");' onclick='"+this.AId+".MSelectYear("+j+");event.cancelBubble=true'>" + sName + "</td></tr>";
			j ++;
		}

		sHTML += "<tr><td id='"+this.AId+"_plus' onmouseover='set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOver+"\");' onmouseout='clearInterval("+this.AId+".AIntervalID2);set_style_div(\"id\",this.id,null,\""+this.AStyleButtonPopUpOut+"\");' onmousedown='clearInterval("+this.AId+".AIntervalID2);"+this.AId+".AIntervalID2=setInterval(\""+this.AId+".MIncYear()\",30)'	onmouseup='clearInterval("+this.AId+".AIntervalID2)'>+</td></tr>";

		setCont("id",this.AId+"_selectYear",null,"<table id='"+this.AId+"_cadrepopupyear' width=44 	onmouseover='clearTimeout("+this.AId+".ATimeoutID2)' onmouseout='clearTimeout("+this.AId+".ATimeoutID2);"+this.AId+".ATimeoutID2=setTimeout(\""+this.AId+".MPopDownYear()\",100)' cellspacing=0>"	+ sHTML	+ "</table>");
		set_style_div("id",this.AId+"_cadrepopupyear",null,this.AStyleCadrePopUp);
		set_style_div("id",this.AId+"_moins",null,this.AStyleButtonPopUpOut);
		set_style_div("id",this.AId+"_plus",null,this.AStyleButtonPopUpOut);
		j=0;
		for	(i=(this.AYearSelected-3); i<=(this.AYearSelected+3); i++) 
			set_style_div("id",this.AId+"_y" + (j++),null,this.AStyleButtonPopUpOut);

		this.AYearConstructed	= true;
	}
}

function TMPopDownYear() {
	clearInterval(this.AIntervalID1);
	clearTimeout(this.ATimeoutID1);
	clearInterval(this.AIntervalID2);
	clearTimeout(this.ATimeoutID2);
	hide_div("id",this.AId+"_selectYear");
}

function TMPopUpYear() {
	this.MConstructYear();
	set_x_div("id",this.AId+"_selectYear",null,get_x_div("id",this.AId+"_spanYear"));
	set_y_div("id",this.AId+"_selectYear",null,get_y_div("id",this.AId+"_spanYear")+get_h_div("id",this.AId+"_spanYear"));
	show_div("id",this.AId+"_selectYear");
}

	/*** calendar ***/
function TMWeekNbr(n) {
		var year = n.getFullYear();
		var month = n.getMonth() + 1;
		var day = (this.AStartAt == 0)?n.getDate() + 1:n.getDate();
		
		var a = Math.floor((14-month) / 12);
		var y = year + 4800 - a;
		var m = month + 12 * a - 3;
		var b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
		var J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
		var d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
		var L = Math.floor(d4 / 1460);
		var d1 = ((d4 - L) % 365) + L;
		var week = Math.floor(d1/7) + 1;
		
		return week;
}


