function DDate(){var A=new Date();A.isLeapYear=function(){var B=this.getYear();return !(B%4)&&((B%100)||!(B%400));};A.getDaysInMonth=function(){return[31,(this.isLeapYear()?29:28),31,30,31,30,31,31,30,31,30,31][this.getMonth()];};A.getFirstWeekDayOfMonth=function(){var B=new Date();B.setDate(1);B.setMonth(this.getMonth(),1);B.setFullYear(this.getFullYear());return B.getDay();};A.getMonthName=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"][this.getMonth()];};A.previousMonth=function(){this.setMonth(this.getMonth()-1,1);};A.nextMonth=function(){this.setMonth(this.getMonth()+1,1);};A.isMonthBefore=function(D){var C=this.getFullYear(),B=D.getFullYear();if(C<B){return true;}if(C>B){return false;}if(C===B){return this.getMonth()<D.getMonth();}};return A;}function DCalendar(A){this.date=new DDate();this.minDate=new DDate();this.maxDate=null;this.allowPastDates=false;this.selectedDayColor="white";this.selectedDayBackgroundColor="rgb(80,80,80)";this.mouseOverDayBackgroundColor="rgb(255,255,204)";this.calendarControl=document.getElementById(A);this.previousMonth=function(){if(this.allowPastDates||this.minDate===null||this.minDate.isMonthBefore(this.date)){this.date.previousMonth();this.draw();}};this.nextMonth=function(){if(this.maxDate===null||this.date.isMonthBefore(this.maxDate)){this.date.nextMonth();this.draw();}};this.setMinDate=function(E,B,C){var D=new DDate();D.setFullYear(C,E,B);this.minDate=D;};this.setMaxDate=function(D,B,C){var E=new DDate();E.setFullYear(C,D,B);this.maxDate=E;};this.toggleVisibility=function(){this.calendarControl.style.display=(this.calendarControl.style.display!="none")?"none":"";};this.draw=function(){this.calendarControl.innerHTML="";var H=this.date.getFirstWeekDayOfMonth(),B=this.date.getDaysInMonth(),G=document.createElement("table"),L=G.insertRow(0),J=L.insertCell(0),F=document.createElement("a"),I=document.createElement("a"),K=["S","M","T","W","T","F","S"],D=this.date.getDate(),C=1,E=0;G.border=0;G.align="center";F.style.fontWeight=I.style.fontWeight="bold";F.style.textDecoration=I.style.textDecoration="none";F.style.fontSize=I.style.fontSize="12pt";F.style.cursor=I.style.cursor="pointer";F.calendar=I.calendar=this;F.onclick=function(M){if(!M){M=window.event;}if(M.stopPropagation){M.stopPropagation();}M.cancelBubble=true;this.calendar.previousMonth();};F.innerHTML="&lt;";J.appendChild(F);J=L.insertCell(1);J.style.textAlign="center";J.style.fontWeight="bold";J.style.fontSize="11pt";J.colSpan=5;J.innerHTML=this.date.getMonthName()+" "+this.date.getFullYear();J=L.insertCell(2);I.onclick=function(M){if(!M){M=window.event;}if(M.stopPropagation){M.stopPropagation();}M.cancelBubble=true;this.calendar.nextMonth();};I.innerHTML="&gt;";J.appendChild(I);L=G.insertRow(1);for(E=0;E<K.length;E++){J=L.insertCell(E);J.style.fontWeight="bold";J.style.color="rgb(200,200,200)";J.innerHTML=K[E];}L=G.insertRow(2);if(H>0){J=L.insertCell(0);J.colSpan=H;}for(E=H;E<B+H;E++,C++){if(E%7===0){L=G.insertRow(G.rows.length);}J=L.insertCell(L.cells.length);J.innerHTML=C;J.calendar=this;if(!this.allowPastDates&&C<this.minDate.getDate()&&this.date.getMonth()===this.minDate.getMonth()&&this.date.getFullYear()===this.minDate.getFullYear()){J.style.color="rgb(210,210,210)";}else{J.dayOfMonth=C;J.calendar=this;if(C==D){J.style.color=this.selectedDayColor;J.style.background=this.selectedDayBackgroundColor;}J.onclick=function(){this.calendar.date.setDate(this.dayOfMonth);this.calendar.draw();if(this.calendar.ondateclick){this.calendar.ondateclick();}};if(C!=D){J.onmouseover=function(){this.style.cursor="pointer";this.style.background=this.calendar.mouseOverDayBackgroundColor;};J.onmouseout=function(){this.style.background="";};}}}this.calendarControl.appendChild(G);};}