function Epoch(d,g,e,a,c,f,b){this.mLangage="en";this.state=0;this.name=d;this.curDate=new Date();this.mode=g;this.selectMultiple=(a==true);this.selectedDates=new Array();this.calendar;this.calHeading;this.calCells;this.rows;this.cols;this.cells=new Array();this.monthSelect;this.yearSelect;this.mousein=false;this.calConfig();this.setDays();this.displayYear=this.displayYearInitial;this.displayMonth=this.displayMonthInitial;this.mDaySelect=c;this.mMonthSelect=f;this.mYearSelect=b;this.createCalendar();if(this.mode=="popup"&&e){this.tgt=e;this.calendar.style.position="absolute";this.topOffset=this.tgt.offsetHeight;this.leftOffset=0;this.calendar.style.top=this.getTop(e)+this.topOffset+"px";this.calendar.style.left=this.getLeft(e)+this.leftOffset+"px";document.body.appendChild(this.calendar);this.tgt.calendar=this;if(c&&f&&b){this.tgt.onclick=function(){this.calendar.show()};c.calendar=this;f.calendar=this;b.calendar=this;c.onfocus=function(){if(!this.calendar.mousein){this.calendar.hide()}};f.onfocus=function(){if(!this.calendar.mousein){this.calendar.hide()}};b.onfocus=function(){if(!this.calendar.mousein){this.calendar.hide()}}}else{this.tgt.onfocus=function(){this.calendar.show()};this.tgt.onblur=function(){if(!this.calendar.mousein){this.calendar.hide()}}}}else{this.container=e;this.container.appendChild(this.calendar)}this.state=2;this.visible?this.show():this.hide()}Epoch.prototype.calConfig=function(){this.displayYearInitial=this.curDate.getFullYear();this.displayMonthInitial=this.curDate.getMonth();this.rangeYearLower=2009;this.rangeYearUpper=2020;this.minDate=new Date(2009,7,7);this.maxDate=new Date(2020,0,1);this.startDay=0;this.showWeeks=false;this.selCurMonthOnly=false;this.clearSelectedOnChange=true;switch(this.mode){case"popup":this.visible=false;break;case"flat":this.visible=true;break}this.setLang("fr")};function SetSelected(b,a){if(b){var c=b.length;while(c>0){c--;if(b.options[c].value==a){b.selectedIndex=c;return}}}}function GetSelected(a){if(a){if(a.selectedIndex>=0){return a.options[a.selectedIndex].value}}return -1}Epoch.prototype.SetDropDownUI=function(c,b,a){SetSelected(this.mDaySelect,c);SetSelected(this.mMonthSelect,b);SetSelected(this.mYearSelect,a)};Epoch.prototype.SetCaladenrFromDropDownUI=function(){var a=GetSelected(this.mYearSelect);var c=GetSelected(this.mMonthSelect)-1;var b=GetSelected(this.mDaySelect);this.selectedDates=new Array();if((a>0)&&(c>=0)&&(b>=0)){var e=new Array;e[0]=new Date(a,c,b);this.addDates(e)}if((c>=0)||(a>0)){if((c<0)||isNaN(c)){var d=new Date();c=d.getMonth()}if((a<0)||isNaN(a)){var d=new Date();a=d.getYear()}this.displayYear=a;this.displayMonth=c;this.goToMonth(a,c)}this.reDraw()};Epoch.prototype.setLang=function(a){this.mLangage=a;if(a=="fr"){this.daylist=new Array("Dim","Lun","Mar","Mer","Jeu","Ven","Sam","Dim","Lun","Mar","Mer","Jeu","Ven","Sam");this.months_sh=new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Sept","Oct","Nov","Déc");this.monthup_title="Aller au mois prochain";this.monthdn_title="Aller au mois pr&eacute;c&eacute;dent";this.clearbtn_caption="Effacer";this.clearbtn_title="Effacer la date sélectionnée";this.closebtn_caption="Fermer";this.closebtn_title="Fermer la fenêtre";this.maxrange_caption="Hors limite!"}else{this.daylist=new Array("Su","Mo","Tu","We","Th","Fr","Sa","Su","Mo","Tu","We","Th","Fr","Sa");this.months_sh=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");this.monthup_title="Go to the next month";this.monthdn_title="Go to the previous month";this.clearbtn_caption="Clear";this.clearbtn_title="Clears any dates selected on the calendar";this.maxrange_caption="This is the maximum range";this.closebtn_caption="Cancel";this.closebtn_title="Cancel and close calendar"}};Epoch.prototype.getTop=function(a){var c=a;var b=0;while(c.tagName!="BODY"){b+=c.offsetTop;c=c.offsetParent}return b};Epoch.prototype.getLeft=function(a){var c=a;var b=0;while(c.tagName!="BODY"){b+=c.offsetLeft;c=c.offsetParent}return b};Epoch.prototype.show=function(){this.calendar.style.display="block";this.visible=true;this.SetCaladenrFromDropDownUI()};Epoch.prototype.hide=function(){this.calendar.style.display="none";this.visible=false};Epoch.prototype.toggle=function(){if(this.visible){this.hide()}else{this.show()}};Epoch.prototype.setDays=function(){this.daynames=new Array();var a=0;for(var b=this.startDay;b<this.startDay+7;b++){this.daynames[a++]=this.daylist[b]}this.monthDayCount=new Array(31,((this.curDate.getFullYear()-2000)%4?28:29),31,30,31,30,31,31,30,31,30,31)};Epoch.prototype.setClass=function(a,b){a.setAttribute("class",b);a.setAttribute("className",b)};Epoch.prototype.createCalendar=function(){var a,b,c;this.calendar=document.createElement("table");this.calendar.setAttribute("id",this.name+"_calendar");this.setClass(this.calendar,"calendar");this.calendar.onselectstart=function(){return false};this.calendar.ondrag=function(){return false};a=document.createElement("tbody");b=document.createElement("tr");c=document.createElement("td");c.setAttribute("align","center");c.appendChild(this.createMainHeading());b.appendChild(c);a.appendChild(b);b=document.createElement("tr");c=document.createElement("td");c.appendChild(this.createDayHeading());b.appendChild(c);a.appendChild(b);b=document.createElement("tr");c=document.createElement("td");c.setAttribute("id",this.name+"_cell_td");this.calCellContainer=c;c.appendChild(this.createCalCells());b.appendChild(c);a.appendChild(b);b=document.createElement("tr");c=document.createElement("td");c.appendChild(this.createFooter());b.appendChild(c);a.appendChild(b);this.calendar.appendChild(a);this.calendar.owner=this;this.calendar.onmouseover=function(){this.owner.mousein=true};this.calendar.onmouseout=function(){this.owner.mousein=false}};Epoch.prototype.createMainHeading=function(){var a=document.createElement("div");a.setAttribute("id",this.name+"_mainheading");this.setClass(a,"mainheading");this.monthSelect=document.createElement("select");this.yearSelect=document.createElement("select");var e=document.createElement("input"),d=document.createElement("input");var c,b;for(b=0;b<12;b++){c=document.createElement("option");c.setAttribute("value",b);if(this.state==0&&this.displayMonth==b){c.setAttribute("selected","selected")}c.appendChild(document.createTextNode(this.months_sh[b]));this.monthSelect.appendChild(c)}for(b=this.rangeYearLower;b<=this.rangeYearUpper;b++){c=document.createElement("option");c.setAttribute("value",b);if(this.state==0&&this.displayYear==b){c.setAttribute("selected","selected")}c.appendChild(document.createTextNode(b));this.yearSelect.appendChild(c)}d.setAttribute("type","button");d.setAttribute("value",">");d.setAttribute("title",this.monthup_title);e.setAttribute("type","button");e.setAttribute("value","<");e.setAttribute("title",this.monthdn_title);this.monthSelect.owner=this.yearSelect.owner=d.owner=e.owner=this;d.onmouseup=function(){this.owner.nextMonth()};e.onmouseup=function(){this.owner.prevMonth()};this.monthSelect.onchange=function(){this.owner.displayMonth=this.value;this.owner.displayYear=this.owner.yearSelect.value;this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth)};this.yearSelect.onchange=function(){this.owner.displayMonth=this.owner.monthSelect.value;this.owner.displayYear=this.value;this.owner.goToMonth(this.owner.displayYear,this.owner.displayMonth)};a.appendChild(e);a.appendChild(this.monthSelect);a.appendChild(this.yearSelect);a.appendChild(d);return a};Epoch.prototype.createFooter=function(){var b=document.createElement("div");if(this.mode=="popup"){var a=document.createElement("input");a.setAttribute("type","button");a.setAttribute("value",this.closebtn_caption);a.setAttribute("title",this.closebtn_title);a.setAttribute("class","ClearButton");a.owner=this;a.onclick=function(){this.owner.hide()};b.appendChild(a)}return b};Epoch.prototype.resetSelections=function(a){this.selectedDates=new Array();this.rows=new Array(false,false,false,false,false,false,false);this.cols=new Array(false,false,false,false,false,false,false);if(this.tgt){if(this.mode=="popup"){this.hide()}}if(a==true){this.goToMonth(this.displayYearInitial,this.displayMonthInitial)}else{this.reDraw()}};Epoch.prototype.createDayHeading=function(){this.calHeading=document.createElement("table");this.calHeading.setAttribute("id",this.name+"_caldayheading");this.setClass(this.calHeading,"caldayheading");var a,b,d;a=document.createElement("tbody");b=document.createElement("tr");this.cols=new Array(false,false,false,false,false,false,false);if(this.showWeeks){d=document.createElement("td");d.setAttribute("class","wkhead");d.setAttribute("className","wkhead");b.appendChild(d)}for(var c=0;c<7;c++){d=document.createElement("td");d.appendChild(document.createTextNode(this.daynames[c]));if(this.selectMultiple){d.headObj=new CalHeading(this,d,(c+this.startDay<7?c+this.startDay:c+this.startDay-7))}b.appendChild(d)}a.appendChild(b);this.calHeading.appendChild(a);return this.calHeading};Epoch.prototype.createCalCells=function(){this.rows=new Array(false,false,false,false,false,false);this.cells=new Array();var k=-1,c=(this.showWeeks?48:42);var d=new Date(this.displayYear,this.displayMonth,1);var g=new Date(this.displayYear,this.displayMonth,this.monthDayCount[this.displayMonth]);var a=new Date(d);a.setDate(a.getDate()+(this.startDay-d.getDay())-(this.startDay-d.getDay()>0?7:0));this.calCells=document.createElement("table");this.calCells.setAttribute("id",this.name+"_calcells");this.setClass(this.calCells,"calcells");var f,h,b;f=document.createElement("tbody");for(var e=0;e<c;e++){if(this.showWeeks){if(e%8==0){k++;h=document.createElement("tr");b=document.createElement("td");if(this.selectMultiple){b.weekObj=new WeekHeading(this,b,a.getWeek(),k)}else{b.setAttribute("class","wkhead");b.setAttribute("className","wkhead")}b.appendChild(document.createTextNode(a.getWeek()));h.appendChild(b);e++}}else{if(e%7==0){k++;h=document.createElement("tr")}}b=document.createElement("td");b.appendChild(document.createTextNode(a.getDate()));var j=new CalCell(this,b,a,k);this.cells.push(j);b.cellObj=j;a.setDate(a.getDate()+1);h.appendChild(b);f.appendChild(h)}this.calCells.appendChild(f);this.reDraw();return this.calCells};Epoch.prototype.reDraw=function(){this.state=1;var b,a;for(b=0;b<this.cells.length;b++){this.cells[b].selected=false}for(b=0;b<this.cells.length;b++){for(a=0;a<this.selectedDates.length;a++){if(this.cells[b].date.getUeDay()==this.selectedDates[a].getUeDay()){this.cells[b].selected=true}}this.cells[b].setClass()}this.state=2};Epoch.prototype.deleteCells=function(){this.calCellContainer.removeChild(this.calCellContainer.firstChild);this.cells=new Array()};Epoch.prototype.goToMonth=function(a,b){this.monthSelect.value=this.displayMonth=b;this.yearSelect.value=this.displayYear=a;this.deleteCells();this.calCellContainer.appendChild(this.createCalCells())};Epoch.prototype.nextMonth=function(){if(this.monthSelect.value<11){this.monthSelect.value++}else{if(this.yearSelect.value<this.rangeYearUpper){this.monthSelect.value=0;this.yearSelect.value++}else{alert(this.maxrange_caption)}}this.displayMonth=this.monthSelect.value;this.displayYear=this.yearSelect.value;this.deleteCells();this.calCellContainer.appendChild(this.createCalCells())};Epoch.prototype.prevMonth=function(){if(this.monthSelect.value>0){this.monthSelect.value--}else{if(this.yearSelect.value>this.rangeYearLower){this.monthSelect.value=11;this.yearSelect.value--}else{alert(this.maxrange_caption)}}this.displayMonth=this.monthSelect.value;this.displayYear=this.yearSelect.value;this.deleteCells();this.calCellContainer.appendChild(this.createCalCells())};Epoch.prototype.addZero=function(a){return((a<10)?"0":"")+a};Epoch.prototype.addDates=function(d,e){var a,c;for(var b=0;b<d.length;b++){c=false;for(a=0;a<this.selectedDates.length;a++){if(d[b].getUeDay()==this.selectedDates[a].getUeDay()){c=true;break}}if(!c){this.selectedDates.push(d[b])}}if(e!=false){this.reDraw()}};Epoch.prototype.removeDates=function(c,d){var a;for(var b=0;b<c.length;b++){for(a=0;a<this.selectedDates.length;a++){if(c[b].getUeDay()==this.selectedDates[a].getUeDay()){this.selectedDates.splice(a,1)}}}if(d!=false){this.reDraw()}};Epoch.prototype.outputDate=function(c,i){var j=this.addZero(c.getDate());var g=this.addZero(c.getMonth()+1);var a=this.addZero(c.getFullYear());var f=this.addZero(c.getFullYear().toString().substring(3,4));var h=(i.indexOf("yyyy")>-1?a:f);var e=this.addZero(c.getHours());var d=this.addZero(c.getMinutes());var b=this.addZero(c.getSeconds());return i.replace(/dd/g,j).replace(/mm/g,g).replace(/y{1,4}/g,h).replace(/hh/g,e).replace(/nn/g,d).replace(/ss/g,b)};Epoch.prototype.updatePos=function(a){this.calendar.style.top=this.getTop(a)+this.topOffset+"px";this.calendar.style.left=this.getLeft(a)+this.leftOffset+"px"};function CalHeading(a,c,b){this.owner=a;this.tableCell=c;this.dayOfWeek=b;this.tableCell.onclick=this.onclick}CalHeading.prototype.onclick=function(){var a=this.headObj.owner;var e=a.selectedDates;var c=a.cells;a.cols[this.headObj.dayOfWeek]=!a.cols[this.headObj.dayOfWeek];for(var d=0;d<c.length;d++){if(c[d].dayOfWeek==this.headObj.dayOfWeek&&(!a.selCurMonthOnly||c[d].date.getMonth()==a.displayMonth&&c[d].date.getFullYear()==a.displayYear)){if(a.cols[this.headObj.dayOfWeek]){if(a.selectedDates.arrayIndex(c[d].date)==-1){e.push(c[d].date)}}else{for(var b=0;b<e.length;b++){if(c[d].dayOfWeek==e[b].getDay()){e.splice(b,1);break}}}c[d].selected=a.cols[this.headObj.dayOfWeek]}}a.reDraw()};function WeekHeading(a,d,b,c){this.owner=a;this.tableCell=d;this.week=b;this.tableRow=c;this.tableCell.setAttribute("class","wkhead");this.tableCell.setAttribute("className","wkhead");this.tableCell.onclick=this.onclick}WeekHeading.prototype.onclick=function(){var a=this.weekObj.owner;var c=a.cells;var e=a.selectedDates;var d,b;a.rows[this.weekObj.tableRow]=!a.rows[this.weekObj.tableRow];for(d=0;d<c.length;d++){if(c[d].tableRow==this.weekObj.tableRow){if(a.rows[this.weekObj.tableRow]&&(!a.selCurMonthOnly||c[d].date.getMonth()==a.displayMonth&&c[d].date.getFullYear()==a.displayYear)){if(a.selectedDates.arrayIndex(c[d].date)==-1){e.push(c[d].date)}}else{for(b=0;b<e.length;b++){if(e[b].getTime()==c[d].date.getTime()){e.splice(b,1);break}}}}}a.reDraw()};function CalCell(a,d,b,c){this.owner=a;this.tableCell=d;this.cellClass;this.selected=false;this.date=new Date(b);this.dayOfWeek=this.date.getDay();this.week=this.date.getWeek();this.tableRow=c;this.tableCell.onclick=this.onclick;this.tableCell.onmouseover=this.onmouseover;this.tableCell.onmouseout=this.onmouseout;this.setClass()}CalCell.prototype.onmouseover=function(){this.setAttribute("class",this.cellClass+" hover");this.setAttribute("className",this.cellClass+" hover")};CalCell.prototype.onmouseout=function(){this.cellObj.setClass()};CalCell.prototype.onclick=function(){var b=this.cellObj;var a=b.owner;if(!a.selCurMonthOnly||b.date.getMonth()==a.displayMonth&&b.date.getFullYear()==a.displayYear){if(a.selectMultiple==true){if(!b.selected){if(a.selectedDates.arrayIndex(b.date)==-1){a.selectedDates.push(b.date)}}else{var d=a.selectedDates;for(var c=0;c<d.length;c++){if(d[c].getUeDay()==b.date.getUeDay()){d.splice(c,1)}}}}else{a.selectedDates=new Array(b.date);if(a.tgt){a.SetDropDownUI(a.selectedDates[0].getDate(),a.selectedDates[0].getMonth()+1,a.selectedDates[0].getFullYear());if(a.mode=="popup"){a.hide()}}}a.reDraw()}};CalCell.prototype.setClass=function(){if(this.selected){this.cellClass="cell_selected"}else{if(this.owner.displayMonth!=this.date.getMonth()){this.cellClass="notmnth"}else{if(this.date.getDay()>0&&this.date.getDay()<6){this.cellClass="wkday"}else{this.cellClass="wkend"}}}if(this.date.getFullYear()==this.owner.curDate.getFullYear()&&this.date.getMonth()==this.owner.curDate.getMonth()&&this.date.getDate()==this.owner.curDate.getDate()){this.cellClass=this.cellClass+" curdate"}this.tableCell.setAttribute("class",this.cellClass);this.tableCell.setAttribute("className",this.cellClass)};Date.prototype.getDayOfYear=function(){return parseInt((this.getTime()-new Date(this.getFullYear(),0,1).getTime())/86400000+1)};Date.prototype.getWeek=function(){return parseInt((this.getTime()-new Date(this.getFullYear(),0,1).getTime())/604800000+1)};Date.prototype.getUeDay=function(){return parseInt(Math.floor((this.getTime()-this.getTimezoneOffset()*60000)/86400000))};Date.prototype.dateFormat=function(I,u){if(!I){I="m/d/Y"}LZ=function(c){return(c<0||c>9?"":"0")+c};var l=new Array("January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var z=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat");if(u=="fr"){l=new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")}I=I+"";var n="";var x=0;var L="";var f="";var j=this.getFullYear().toString();var g=this.getMonth()+1;var J=this.getDate();var p=this.getDay();var o=this.getHours();var B=this.getMinutes();var r=this.getSeconds();var v,w,b,t,N,e,G,F,C,q,P,o,O,i,a,D;var A=new Object();A.Y=j.toString();A.y=j.substring(2);A.n=g;A.m=LZ(g);A.F=l[g-1];A.M=l[g+11];A.j=J;A.d=LZ(J);A.D=z[p+7];A.l=z[p];A.G=o;A.H=LZ(o);if(o==0){A.g=12}else{if(o>12){A.g=o-12}else{A.g=o}}A.h=LZ(A.g);if(o>11){A.a="pm";A.A="PM"}else{A.a="am";A.A="AM"}A.i=LZ(B);A.s=LZ(r);while(x<I.length){L=I.charAt(x);f="";while((I.charAt(x)==L)&&(x<I.length)){f+=I.charAt(x++)}if(A[f]!=null){n=n+A[f]}else{n=n+f}}return n};Array.prototype.arrayIndex=function(a,c){c=(c!=null?c:0);for(var b=c;b<this.length;b++){if(a==this[b]){return b}}return -1};
