<!-- =============================== -->

	function datePicker(inputFieldId, calendarDiv, locale, minDate, maxDate) {

		function dateSelectHandler(type,args,obj) {
			var dates = args[0];
			var date = dates[0];
			var year = date[0], month = date[1]+"", day = date[2]+"";

			YAHOO.util.Dom.get(inputFieldId).value = year + "-" + (month.length > 1?month:"0"+month) + "-" + (day.length > 1?day:"0"+day);
			var calDiv = YAHOO.util.Dom.get(calendarDiv);
			calDiv.innerHTML = '';
			calDiv.className = '';
		};
		
		var navConfig;
		if(locale == 'FR'){
			navConfig = { 
			      strings : { 
			          month: "mois", 
			          year: "ann\u00e9e", 
			          submit: "O.K.", 
			          cancel: "Annuler", 
			          invalidYear: "Veuillez \u00e9crire une ann\u00e9e valide" 
			      }, 
			      monthFormat: YAHOO.widget.Calendar.SHORT, 
			      initialFocus: "year"
			}; 
		}else{
			navConfig = { 
			      strings : { 
			          month: "Month", 
			          year: "Year", 
			          submit: "OK", 
			          cancel: "Cancel", 
			          invalidYear: "Please enter a valid year" 
			      }, 
			      monthFormat: YAHOO.widget.Calendar.SHORT, 
			      initialFocus: "year"
			}; 
		}
		
		var elePos = getPosition($(inputFieldId));
		var dateDiv = document.getElementById(calendarDiv);
		dateDiv.style.position = 'absolute';
		dateDiv.style.top      = elePos.y + 25;
		dateDiv.style.left     = elePos.x;
		var divWidth = "204px";
		if(navigator.appName == "Netscape") divWidth = "205px";
		dateDiv.innerHTML = "<div style='background-color:#f2f2f2;'><table style='border:1px solid #808080;border-bottom:0;width:"+divWidth+"'><tr>"
								+"<td style='text-align:right;'><label id='closeCal' onclick=\"document.getElementById('"+calendarDiv
								+"').innerHTML='';\" style='cursor:pointer;font-size:14px;border: 1px solid #cccccc;background-color:#ffffff;'>"
								+"&nbsp;&nbsp;<strong>x</strong>&nbsp;&nbsp;</label></td></tr></table></div><div id='"+calendarDiv+"_cal'></div>";
/*		$(calendarDiv).style.position = 'absolute';
		$(calendarDiv).style.top      = elePos.y + 25;
		$(calendarDiv).style.left     = elePos.x;
		$(calendarDiv).innerHTML = "<div style='background-color:#f2f2f2;'><table style='border:1px solid #808080;border-bottom:0;width:100%;'><tr>"
		thisDiv.style.position = 'absolute';
		thisDiv.style.top      = elePos.y + 25;
		thisDiv.style.left     = elePos.x;
		thisDiv.innerHTML = "<div style='background-color:#f2f2f2;'><table style='border:1px solid #808080;border-bottom:0;width:100%;'><tr>"
									+"<td style='text-align:right;'><label id='closeCal' onclick=\"Document.getElementById("+calendarDiv
									+").innerHTML='';\" style='cursor:pointer;font-size:14px;border: 1px solid #cccccc;background-color:#ffffff;'>"
									+"&nbsp;&nbsp;<strong>x</strong>&nbsp;&nbsp;</label></td></tr></table></div><div id='"+calendarDiv+"_cal'></div>";
*/
		var cal1 = new YAHOO.widget.Calendar("cal1",
					calendarDiv+"_cal", 
					{title:'',navigator:navConfig,
					mindate: (minDate?minDate.substring(5,7)+'/'+minDate.substring(8)+'/'+minDate.substring(0,4):''),
					maxdate: (maxDate?maxDate.substring(5,7)+'/'+maxDate.substring(8)+'/'+maxDate.substring(0,4):'')});

		if(locale == 'FR'){
			
			// Date labels for French locale
			cal1.cfg.setProperty("MONTHS_SHORT",   ["Jan", "F\u00e9v", "Mar", "Avr", "Mai", "Juin", "Juil", "Ao\u00fbt", "Sep", "Oct", "Nov", "D\u00e9c"]);
			cal1.cfg.setProperty("MONTHS_LONG",    ["Janvier", "F\u00e9vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Ao\u00fbt", "Septembre", "Octobre", "Novembre", "D\u00e9cembre"]);
			cal1.cfg.setProperty("WEEKDAYS_1CHAR", ["d", "l", "m", "m", "j", "v", "s"]);
			cal1.cfg.setProperty("WEEKDAYS_SHORT", ["di", "lu", "ma", "me", "je", "ve", "sa"]);
			cal1.cfg.setProperty("WEEKDAYS_MEDIUM",["dim", "lun", "mar", "mer", "jeu", "ven", "sam"]);
			cal1.cfg.setProperty("WEEKDAYS_LONG",  ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]);
		}

		cal1.selectEvent.subscribe(dateSelectHandler, cal1, true);

		cal1.render();

	}

	function getPosition(e){
		var left = 0;
		var top  = 0;
		while (e.offsetParent){
			left += e.offsetLeft;
			top  += e.offsetTop;
			e     = e.offsetParent;
		}
	
		left += e.offsetLeft;
		top  += e.offsetTop;
	
		return {x:left, y:top};
	
	}
	
