<!--//Localized calendar dropdown

function dateTool() {

	/*dateTool.prototype.formatDate = function(dteDateToFormat) {
		var strDay = dteDateToFormat.getDate();
		var strMonth = monthArray[dteDateToFormat.getMonth() + 1];
		var strYear = dteDateToFormat.getFullYear();
		var strFormattedDate = strDay + " " + strMonth + " " + strYear;
		return strFormattedDate;
	}*/

	dateTool.prototype.constructDate = function(oMonYear, oDay, bMinus1) {
		
		var objYear = this.getYear(oMonYear);
		var objMonth = this.getMonth(oMonYear);
		var objDay = this.getDay(oDay);
		var objDate;
		
		if (bMinus1) {
			objDate = new Date(objYear, (objMonth-1), objDay);
		} else {
			objDate = new Date(objYear, objMonth, objDay);
		}
		return objDate;
	}

	dateTool.prototype.getYear = function(inputDate) {	
		dateToReturn=inputDate.value.split("/");
		return dateToReturn[2];
	}

	dateTool.prototype.getMonth = function(inputDate){
		dateToReturn=inputDate.value.split("/");
		return dateToReturn[1];
	}

	dateTool.prototype.getDay = function(inputDate) {
		dateToReturn = inputDate.value.split("/");
		return dateToReturn[0];
	}
	
 dateTool.addEvent = function(el, evname, func) {
	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	 } else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	 } else {
		el["on" + evname] = func;
	 }
  }
	
}
var timeout = 500;
var timeoutId;
var monthArray = new Array();
monthArray['1']='janvier';monthArray['2']='f&eacute;vrier';monthArray['3']='mars';monthArray['4']='avril';monthArray['5']='mai';monthArray['6']='juin';monthArray['7']='juillet';monthArray['8']='ao&ucirc;t';monthArray['9']='septembre';monthArray['10']='octobre';monthArray['11']='novembre';monthArray['12']='d&eacute;cembre';
/*Initialisation du calendrier avec la date du client*/
serverDate = new Date();
serverDay = serverDate.getDate();
if(serverDay<10)
	serverDay = "0"+serverDay;
serverMonth = serverDate.getMonth()+1;
if(serverMonth<10)
	serverMonth = "0"+serverMonth;
serverYear = (serverDate.getYear()<999) ? serverDate.getYear()+1900 : serverDate.getYear();

var shortMonthArray = new Array();
shortMonthArray['1']='jan';shortMonthArray['2']='fév';shortMonthArray['3']='mar';shortMonthArray['4']='avr';shortMonthArray['5']='mai';shortMonthArray['6']='jui';shortMonthArray['7']='juil';shortMonthArray['8']='aoû';shortMonthArray['9']='sep';shortMonthArray['10']='oct';shortMonthArray['11']='nov';shortMonthArray['12']='déc';
var shortDayArray = new Array();
shortDayArray['0']='Dim';shortDayArray['1']='Lun';shortDayArray['2']='Mar';shortDayArray['3']='Mer';shortDayArray['4']='Jeu';shortDayArray['5']='Ven';shortDayArray['6']='Sam';
var dayArray = new Array();
dayArray['1']='Lundi';dayArray['2']='Mardi';dayArray['3']='Mercredi';dayArray['4']='Jeudi';dayArray['5']='Vendredi';dayArray['6']='Samedi';dayArray['7']='Dimanche';

document.write('<div id="container"');
if (timeout) document.write(' onmouseout="calendarTimer();" onmouseover="if (timeoutId) clearTimeout(timeoutId);"');
document.write(' style="display: none;zindex:1000;"></div>');

var dT = new dateTool();
var gCal= new Calendar();

function calendarTimer(){
	/*timeoutId=setTimeout('gCal.closeMe();',timeout);*/
}

function Calendar(){
	this._iMonth;
	this._iDay;
	this._endMonth;
	this._container;
	this._selectedDate;
	this._currentMonth=0;	
	this._currentYear=0;
	this._ExitCode="";
	this._options = {};
    
	Calendar.prototype.showCalendar=function(inputFieldId, selectedDateId, options){
		try{
		serverDay = parseInt(serverDay);
		if(typeof options != "undefined")
    		this._options = options;
    	else
    		this._options = {};
    	/*Rajout de l'option permettant de ne pas pouvoir choisir les dates à j+N*/	
    	if(typeof this._options.offsetDay == "undefined")
    		this._options.offsetDay = 0;	
		this._container=document.getElementById?document.getElementById('container'):document.all.container;
		this._selectedDate=document.getElementById?document.getElementById(selectedDateId):document.all.selectedDateId;
		this._iDay=dT.getDay(this._selectedDate);
		this._iMonth=dT.getMonth(this._selectedDate);
		this._currentYear = dT.getYear(this._selectedDate);
		if(isNaN(this._currentYear) || (this._currentYear < serverYear && (typeof this._options.beforeToday != "string")))
		        {this._currentYear = serverYear;this._iMonth = serverMonth;}
		if(!isNaN(this._currentYear) && !isNaN(this._iMonth) && this._currentYear == serverYear && this._iMonth<serverMonth && typeof this._options.beforeToday != "string")
		        this._iMonth = serverMonth;
		if(isNaN(this._iDay) || this._iDay>31 || this._iDay<1 )
		        this._iDay = serverDay;
      if(isNaN(this._iMonth) || this._iMonth>12 || this._iMonth<1 )
        this._iMonth = serverMonth;     
     this._currentMonth=this._iMonth;
		
    	
		 
     var calendarHTML=this.buildCalendar(this._currentMonth+""+this._currentYear,parseInt(this._iDay)+parseInt(this._options.offsetDay), options);		
  		var objCal=document.getElementById?document.getElementById(inputFieldId):document.all.inputFieldId;
  		
  		this._container.innerHTML= calendarHTML;
  		this._container.style.left=this.getElementX(objCal)+"px";
  		this._container.style.top=parseInt(this.getElementY(objCal))+20+"px";
  		this._container.style.zIndex=999;
  		this._container.style.display="";
  		/*Pour le rendre vraiment absolu*/
  		document.body.appendChild(this._container);
		}catch(e){
			this.closeMe();
		}
	window.currentCalendar = this;
  dateTool.addEvent(document,"mousedown",gCal.closeMeOut);
  if(document.all)//POUR IE, TELLEMENT BIEN CODE...CACHE LES SELECT QUI APPRAISSENT AU DESSUS
  	{
  	allSelect = document.getElementsByTagName('SELECT');
  		for(i=0;i<allSelect.length;i++)
  		allSelect[i].style.visibility="hidden";
  	}
}
	Calendar.prototype.setExitCode=function(exitCode){
  this._ExitCode=exitCode;
  }
  Calendar.prototype.setOnUpdate=function(updateCode){
  this._UpdateCode=updateCode;
  }
	Calendar.prototype.buildCalendar=function(iCurrentMonthYear,iCurrentDay) {
    var rangeBeforeToday = (typeof this._options.beforeToday == "string") ? true : false;
    var iMonth = iCurrentMonthYear.substring(0,2);
		var iYear = iCurrentMonthYear.substring(2,6);
    var currDate=new Date(iYear,iMonth-1,1);
		var month=currDate.getMonth()+1;
		var numDays=this.getDaysInMonth(month,iYear);
		var year=this.getFullYear(currDate);currDate.setDate(1);		
		var startDate=1;
    var firstDay=(((currDate.getDay())+(7-startDate)) % 7);
    var calHTML='<table class="calTable" cellspacing="0" cellpadding="0"><tr><td height="20" width="15" class="calHeader arrow">';
		serverYearMonth = serverYear+""+serverMonth;
    iCurrentYearMonth = iYear+""+iMonth;
	if (rangeBeforeToday || iCurrentYearMonth>serverYearMonth){
		calHTML+='<a href="javascript:gCal.movePrevious()" style="text-decoration:none;">&larr;</a>';
	}
		var monthOutOfRange = false;
		/*if (iCurrentYearMonth<serverYearMonth)
		   monthOutOfRange = true;*/
	//monthOutOfRange est vrai si le mois n'est pas selectionnable (en dehors de la periode authorisée)
	//On test suivant si l'on veut une periode avant ou une periode après la date courante.
	monthOutOfRange = (rangeBeforeToday) ? (iCurrentYearMonth>serverYearMonth) : (iCurrentYearMonth<serverYearMonth);
    
    monthName = monthArray[currDate.getMonth()+1];
	calHTML+='</td><td colspan="5" width="100" class="calHeader">'+ monthName +' '+year+'</td><td class="calHeader arrow" width="20">';
		if (!rangeBeforeToday || iCurrentYearMonth<serverYearMonth){
		calHTML+='<a href="javascript:gCal.moveNext()" style="text-decoration:none;">&rarr;</a>';
		}
	calHTML+='</td></tr><tr class="dayNames">';
		for(var iDay=0;iDay<7;iDay++){
			calHTML+='<td height="20" width="20"';
			if(iDay>4)
			         calHTML+=' class="we"';
      calHTML+='>'+shortDayArray[(iDay+startDate) % 7]+'</td>';
		}		
		calHTML+='</tr>';
		
		
		for(var iWeek=0;iWeek<6;iWeek++){
			calHTML+='<tr class="week">';
			
			for(iDay=1;iDay<8;iDay++){
				var dayWeekPos=(iWeek*7)+iDay;		
				var dayOffset=dayWeekPos-firstDay;
        var isValidDay=(dayWeekPos>firstDay)&&(dayOffset<=numDays);	
				/*var dayOutOfRange=(monthBefore||(iCurrentYearMonth==serverYearMonth && dayOffset<serverDay));*/
		
		//dayOutOfRange est vrai si le jour n'est pas selectionnable (en dehors de la periode authorisée)
		//il est tout d'abord egal à la possibilité de selectionner le mois courant
		var dayOutOfRange = monthOutOfRange;
		//Si le mois courant est selectionnable et que c'est le mois cuorant, on teste:
		if(!dayOutOfRange && iCurrentYearMonth==serverYearMonth)
		dayOutOfRange=(rangeBeforeToday)? (dayOffset>serverDay-this._options.offsetDay) : (dayOffset<serverDay+this._options.offsetDay);		
		
					
        var dateToShow=(isValidDay)?dayOffset:'';
        className="";
        if(iCurrentDay!=null && iCurrentDay==dateToShow && isValidDay)
          className+="selectedDate ";
        
        if(iDay>5)
  			  className+="we ";
		 if(isValidDay&&!dayOutOfRange)
		      className+="selectable ";
		calHTML+='<td height="20" class="'+className+'" title="'+dayArray[iDay]+' '+dateToShow+' '+monthName+' '+year+'"';
	    calHTML+=(isValidDay && !dayOutOfRange)?' onclick="javascript:gCal.selectDay('+dateToShow+',\''+iMonth+'\',\''+iYear+'\')"':'';
	    calHTML+='>';
		calHTML+=dateToShow;
		calHTML+='</td>';
			}                                                                                                
			calHTML+='</tr>';
    }                                                                              
		calHTML+='<tr><td height="20" class="calHeader">&nbsp;</td>'
		calHTML+='<td colspan="5" class="calHeader"><a href="javascript:gCal.closeMe()">Fermer</a></td>'
		calHTML+='<td class="calHeader">&nbsp;</td></tr></table>'
				
		return calHTML;
	}
	Calendar.prototype.getDaysInMonth=function(iMonth,iYear){
		if(iMonth==2){
			var febYear=iYear;
			var febDate=new Date(Date.UTC(febYear,1,29));
			return (febDate.getMonth()==1)?29:28;
		}
		else return (iMonth==4||iMonth==6||iMonth==9||iMonth==11)?30:31;
	}
	
	Calendar.prototype.getElementX=function(element){
		var x=element.offsetLeft;
		var oParent=element.offsetParent;
		while(oParent){
		x+=oParent.offsetLeft;
			oParent=oParent.offsetParent;}
		return x;
	}
	
	Calendar.prototype.getElementY=function(element){
		var y=element.offsetTop;
		var oParent=element.offsetParent;
		while(oParent){
			y+=oParent.offsetTop;
			oParent=oParent.offsetParent;}
		return y;
	}
	
	Calendar.prototype.closeMe=function(){
		this._container.style.left="";
		this._container.style.top="";
		this._container.style.display="none";
		window.currentCalendar = null;
		if(document.all)//POUR IE, TELLEMENT BIEN CODE...
	  	{
	  	allSelect = document.getElementsByTagName('SELECT');
	  		for(i=0;i<allSelect.length;i++)
	  		allSelect[i].style.visibility="visible";
	  	}
	}
	
	Calendar.prototype.closeMeOut=function(ev){
	if(!window.currentCalendar)
	  return false;
	target = window.event ? window.event.srcElement : ev.target;
  for (; target != null && target != window.currentCalendar._container;target = target.parentNode) ;
  if (target == null) {
		window.currentCalendar.closeMe();		
	 }
		return false;
	}
	Calendar.prototype.movePrevious=function(){  
			this._currentMonth--;		
		if(this._currentMonth<10)
      this._currentMonth="0"+this._currentMonth;
    if(this._currentMonth<1)
      {this._currentMonth=12;this._currentYear--;}                      
		var calendarHTML=this.buildCalendar(this._currentMonth+""+this._currentYear,null);
		this._container.innerHTML= calendarHTML;
	}

	Calendar.prototype.moveNext=function(){
			this._currentMonth++;		
    if(this._currentMonth<10)
      this._currentMonth="0"+this._currentMonth;
      if(this._currentMonth>12)
      {this._currentMonth="01";this._currentYear++;}
		var calendarHTML=this.buildCalendar(this._currentMonth+""+this._currentYear,null);
		this._container.innerHTML= calendarHTML;
	}
	
	Calendar.prototype.selectDay=function(iDay,iMonth,iYear){	
		if(iDay<10)
        iDay="0"+iDay;
    if(iMonth<10 && iMonth.substring(0,1)!="0")
        iMonth="0"+iMonth;
    this._selectedDate.value=iDay+"/"+iMonth+"/"+iYear;
    if(this._selectedDate.onchange)
    	this._selectedDate.onchange();
    if(typeof this._UpdateCode == "function")
    	this._UpdateCode();
    if(typeof this._UpdateCode == "string")
    	eval(this._UpdateCode);
    	
    eval(this._ExitCode);
		this.closeMe();
	}
	Calendar.prototype.getMonth = function(sMonthYear){
		return sMonthYear.substring(0,2);
	}
	Calendar.prototype.getYear = function(sMonthYear){
		return sMonthYear.substring(2,6);
	}
	Calendar.prototype.getFullYear=function(date){
		fullyear = date.getYear();
		return (fullyear<1000)?fullyear+=1900:fullyear;
	}

}

var idNumber = 0;
function addCalendar(in_field, in_button, options){
	targetEl = document.getElementById(in_field);
	buttonEl = document.getElementById(in_button);
	//alert(buttonEl.href);
	buttonEl.href="javascript:void(0)";
	
	if (targetEl.attachEvent)
	{ // IE
		targetEl.attachEvent("onclick", function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		});
		buttonEl.attachEvent("onclick", function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		});
	 }
	 else if (targetEl.addEventListener) 
	 {// Gecko / W3C
		targetEl.addEventListener("click", function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		}, true);
		buttonEl.addEventListener("click", function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		}, true);
	 }
	 else
	 {
		targetEl["onclick"] = function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		};
		buttonEl["onclick"] = function() {
		gCal.showCalendar(in_field,in_field,options);return false;
		};
	 }
	/*document.getElementById(in_field).onclick = function() {
	gCal.showCalendar(in_field,in_field);return false;
	};*/
}

-->

