Zapatec.Calendar=function(C,B,E,A){this.bShowHistoryEvent=false;this.activeDiv=null;this.currentDateEl=null;this.getDateStatus=null;this.getDateToolTip=null;this.getDateText=null;this.timeout=null;this.onSelected=E||null;this.onClose=A||null;this.onFDOW=null;this.dragging=false;this.hidden=false;this.minYear=1970;this.maxYear=2050;this.minMonth=0;this.maxMonth=11;this.dateFormat=Zapatec.Calendar.i18n("DEF_DATE_FORMAT");this.ttDateFormat=Zapatec.Calendar.i18n("TT_DATE_FORMAT");this.historyDateFormat="%B %d, %Y";this.isPopup=true;this.weekNumbers=true;this.noGrab=false;if(Zapatec.Calendar.prefs.fdow||(Zapatec.Calendar.prefs.fdow==0)){this.firstDayOfWeek=parseInt(Zapatec.Calendar.prefs.fdow,10);}else{var D=0;if(typeof C=="number"){D=C;}else{if(typeof Zapatec.Calendar._FD=="number"){D=Zapatec.Calendar._FD;}}this.firstDayOfWeek=D;}this.showsOtherMonths=false;this.dateStr=B;this.showsTime=false;this.sortOrder="asc";this.time24=true;this.timeInterval=null;this.yearStep=2;this.hiliteToday=true;this.multiple=null;this.table=null;this.element=null;this.tbody=new Array();this.firstdayname=null;this.monthsCombo=null;this.hilitedMonth=null;this.activeMonth=null;this.yearsCombo=null;this.hilitedYear=null;this.activeYear=null;this.histCombo=null;this.hilitedHist=null;this.dateClicked=false;this.numberMonths=1;this.controlMonth=1;this.vertical=false;this.monthsInRow=1;this.titles=new Array();this.rowsOfDayNames=new Array();this.helpButton=true;this.disableFdowClick=false;Zapatec.Calendar._initSDN();};Zapatec.Calendar._initSDN=function(){if(typeof Zapatec.Calendar._TT._SDN=="undefined"){if(typeof Zapatec.Calendar._TT._SDN_len=="undefined"){Zapatec.Calendar._TT._SDN_len=3;}var A=[];for(var B=8;B>0;){A[--B]=Zapatec.Calendar._TT._DN[B].substr(0,Zapatec.Calendar._TT._SDN_len);}Zapatec.Calendar._TT._SDN=A;if(typeof Zapatec.Calendar._TT._SMN_len=="undefined"){Zapatec.Calendar._TT._SMN_len=3;}A=[];for(var B=12;B>0;){A[--B]=Zapatec.Calendar._TT._MN[B].substr(0,Zapatec.Calendar._TT._SMN_len);}Zapatec.Calendar._TT._SMN=A;}};Zapatec.Calendar.i18n=function(C,A){var B="";if(!A){if(Zapatec.Calendar._TT){B=Zapatec.Calendar._TT[C];}if(!B&&Zapatec.Calendar._TT_en){B=Zapatec.Calendar._TT_en[C];}}else{switch(A){case"dn":B=Zapatec.Calendar._TT._DN[C];break;case"sdn":B=Zapatec.Calendar._TT._SDN[C];break;case"mn":B=Zapatec.Calendar._TT._MN[C];break;case"smn":B=Zapatec.Calendar._TT._SMN[C];break;}}if(!B){B=""+C;}return B;};Zapatec.Calendar._C=null;Zapatec.Calendar.prefs={fdow:null,history:"",sortOrder:"asc",hsize:9};Zapatec.Calendar.savePrefs=function(){Zapatec.Utils.writeCookie("ZP_CAL",Zapatec.Utils.makePref(this.prefs),null,"/",30);};Zapatec.Calendar.loadPrefs=function(){var A=Zapatec.Utils.getCookie("ZP_CAL"),B;if(A){B=Zapatec.Utils.loadPref(A);if(B){Zapatec.Utils.mergeObjects(this.prefs,B);}}};Zapatec.Calendar._add_evs=function(A){var B=Zapatec.Calendar;Zapatec.Utils.addEvent(A,"mouseover",B.dayMouseOver);Zapatec.Utils.addEvent(A,"mousedown",B.dayMouseDown);Zapatec.Utils.addEvent(A,"mouseout",B.dayMouseOut);if(Zapatec.is_ie){Zapatec.Utils.addEvent(A,"dblclick",B.dayMouseDblClick);}};Zapatec.Calendar._del_evs=function(A){var B=this;Zapatec.Utils.removeEvent(A,"mouseover",B.dayMouseOver);Zapatec.Utils.removeEvent(A,"mousedown",B.dayMouseDown);Zapatec.Utils.removeEvent(A,"mouseout",B.dayMouseOut);if(Zapatec.is_ie){Zapatec.Utils.removeEvent(A,"dblclick",B.dayMouseDblClick);}};Zapatec.Calendar.findMonth=function(A){if(typeof A.month!="undefined"){return A;}else{if(A.parentNode&&typeof A.parentNode.month!="undefined"){return A.parentNode;}}return null;};Zapatec.Calendar.findHist=function(A){if(typeof A.histDate!="undefined"){return A;}else{if(A.parentNode&&typeof A.parentNode.histDate!="undefined"){return A.parentNode;}}return null;};Zapatec.Calendar.findYear=function(A){if(typeof A.year!="undefined"){return A;}else{if(A.parentNode&&typeof A.parentNode.year!="undefined"){return A.parentNode;}}return null;};Zapatec.Calendar.showMonthsCombo=function(){var B=Zapatec.Calendar._C;if(!B){return false;}var D=B.activeDiv;var J=B.monthsCombo;var F=B.date,K=B.date.getMonth(),C=B.date.getFullYear(),G=(C==B.minYear),I=(C==B.maxYear);for(var H=J.firstChild;H;H=H.nextSibling){var E=H.month;Zapatec.Utils.removeClass(H,"hilite");Zapatec.Utils.removeClass(H,"active");Zapatec.Utils.removeClass(H,"disabled");H.disabled=false;if((G&&E<B.minMonth)||(I&&E>B.maxMonth)){Zapatec.Utils.addClass(H,"disabled");H.disabled=true;}if(E==K){Zapatec.Utils.addClass(B.activeMonth=H,"active");}}var L=J.style;L.display="block";if(D.navtype<0){L.left=D.offsetLeft+"px";}else{var A=J.offsetWidth;if(typeof A=="undefined"){A=50;}L.left=(D.offsetLeft+D.offsetWidth-A)+"px";}L.top=(D.offsetTop+D.offsetHeight)+"px";B.updateWCH(J);};Zapatec.Calendar.showHistoryCombo=function(){var B=Zapatec.Calendar._C,H,F,D,C,G,I,E,A;if(!B){return false;}G=B.histCombo;while(G.firstChild){G.removeChild(G.lastChild);}if(Zapatec.Calendar.prefs.history){H=Zapatec.Calendar.prefs.history.split(/,/);D=0;while(E=H[D++]){E=E.split(/\//);F=Zapatec.Utils.createElement("div");F.className=Zapatec.is_ie?"label-IEfix":"label";F.histDate=new Date(parseInt(E[0],10),parseInt(E[1],10)-1,parseInt(E[2],10),E[3]?parseInt(E[3],10):0,E[4]?parseInt(E[4],10):0);F.appendChild(window.document.createTextNode(F.histDate.print(B.historyDateFormat)));G.appendChild(F);if(F.histDate.dateEqualsTo(B.date)){Zapatec.Utils.addClass(F,"active");}}}C=B.activeDiv;I=G.style;I.display="block";I.left=Math.floor(C.offsetLeft+(C.offsetWidth-G.offsetWidth)/2)+"px";I.top=(C.offsetTop+C.offsetHeight)+"px";B.updateWCH(G);B.bEventShowHistory=true;};Zapatec.Calendar.showYearsCombo=function(D){var A=Zapatec.Calendar._C;if(!A){return false;}var C=A.activeDiv;var F=A.yearsCombo;if(A.hilitedYear){Zapatec.Utils.removeClass(A.hilitedYear,"hilite");}if(A.activeYear){Zapatec.Utils.removeClass(A.activeYear,"active");}A.activeYear=null;var B=A.date.getFullYear()+(D?1:-1);var I=F.firstChild;var H=false;for(var E=12;E>0;--E){if(B>=A.minYear&&B<=A.maxYear){I.firstChild.data=B;I.year=B;I.style.display="block";H=true;}else{I.style.display="none";}I=I.nextSibling;B+=D?A.yearStep:-A.yearStep;}if(H){var J=F.style;J.display="block";if(C.navtype<0){J.left=C.offsetLeft+"px";}else{var G=F.offsetWidth;if(typeof G=="undefined"){G=50;}J.left=(C.offsetLeft+C.offsetWidth-G)+"px";}J.top=(C.offsetTop+C.offsetHeight)+"px";}A.updateWCH(F);};Zapatec.Calendar.tableMouseUp=function(E){var H=Zapatec.Calendar._C;if(!H){return false;}if(H.timeout){clearTimeout(H.timeout);}var D=H.activeDiv;if(!D){return false;}var G=Zapatec.Utils.getTargetElement(E);if(typeof (D.navtype)=="undefined"){while(!G.calendar){G=G.parentNode;}}E||(E=window.event);Zapatec.Utils.removeClass(D,"active");if(G==D||G.parentNode==D){Zapatec.Calendar.cellClick(D,E);}var C=Zapatec.Calendar.findMonth(G);var A=null;if(C){if(!C.disabled){A=new Date(H.date);if(C.month!=A.getMonth()){A.setMonth(C.month);H.setDate(A,true);H.dateClicked=false;H.callHandler();}}}else{var B=Zapatec.Calendar.findYear(G);if(B){A=new Date(H.date);if(B.year!=A.getFullYear()){A.setFullYear(B.year);H.setDate(A,true);H.dateClicked=false;H.callHandler();}}else{var F=Zapatec.Calendar.findHist(G);if(F&&!F.histDate.dateEqualsTo(H.date)){A=new Date(F.histDate);H._init(H.firstDayOfWeek,H.date=A);H.dateClicked=false;H.callHandler();H.updateHistory();}}}Zapatec.Utils.removeEvent(window.document,"mouseup",Zapatec.Calendar.tableMouseUp);Zapatec.Utils.removeEvent(window.document,"mouseover",Zapatec.Calendar.tableMouseOver);Zapatec.Utils.removeEvent(window.document,"mousemove",Zapatec.Calendar.tableMouseOver);H._hideCombos();Zapatec.Calendar._C=null;return Zapatec.Utils.stopEvent(E);};Zapatec.Calendar.tableMouseOver=function(U){var M=Zapatec.Calendar._C;if(!M){return ;}var D=M.activeDiv;var W=Zapatec.Utils.getTargetElement(U);if(W==D||W.parentNode==D){Zapatec.Utils.addClass(D,"hilite active");Zapatec.Utils.addClass(D.parentNode,"rowhilite");}else{if(typeof D.navtype=="undefined"||(D.navtype!=50&&((D.navtype==0&&!M.histCombo)||Math.abs(D.navtype)>2))){Zapatec.Utils.removeClass(D,"active");}Zapatec.Utils.removeClass(D,"hilite");Zapatec.Utils.removeClass(D.parentNode,"rowhilite");}U||(U=window.event);if(D.navtype==50&&W!=D){var G=Zapatec.Utils.getAbsolutePos(D);var J=D.offsetWidth;var I=U.clientX;var L;var A=true;if(I>G.x+J){L=I-G.x-J;A=false;}else{L=G.x-I;}if(L<0){L=0;}var N=D._range;var P=D._current;var V=M.date;var T=(V.getHours()>=12);var B=D.firstChild.data;var H=Math.floor(L/10)%N.length;for(var S=N.length;--S>=0;){if(N[S]==P){break;}}while(H-->0){if(A){if(--S<0){S=N.length-1;}}else{if(++S>=N.length){S=0;}}}if(M.getDateStatus){var O=null;var F=null;var C=new Date(V);if(D.className.indexOf("ampm",0)!=-1){O=V.getMinutes();if(B!=N[S]){F=(N[S]=="pm")?((V.getHours()==0)?(12):(V.getHours()+12)):(V.getHours()-12);}else{F=V.getHours();}C.setHours(F);}if(D.className.indexOf("hour",0)!=-1){O=V.getMinutes();F=(!M.time24)?((T)?((N[S]!=12)?(parseInt(N[S],10)+12):(12)):((N[S]!=12)?(N[S]):(0))):(N[S]);C.setHours(F);}if(D.className.indexOf("minute",0)!=-1){F=V.getHours();O=N[S];C.setMinutes(O);}}var Q=false;if(M.getDateStatus){Q=M.getDateStatus(C,V.getFullYear(),V.getMonth(),V.getDate(),parseInt(F,10),parseInt(O,10));}if(Q==false){if(!((!M.time24)&&(N[S]=="pm")&&(F>23))){D.firstChild.data=N[S];}}M.onUpdateTime();}var R=Zapatec.Calendar.findMonth(W);if(R){if(!R.disabled){if(R.month!=M.date.getMonth()){if(M.hilitedMonth){Zapatec.Utils.removeClass(M.hilitedMonth,"hilite");}Zapatec.Utils.addClass(R,"hilite");M.hilitedMonth=R;}else{if(M.hilitedMonth){Zapatec.Utils.removeClass(M.hilitedMonth,"hilite");}}}}else{if(M.hilitedMonth){Zapatec.Utils.removeClass(M.hilitedMonth,"hilite");}var K=Zapatec.Calendar.findYear(W);if(K){if(K.year!=M.date.getFullYear()){if(M.hilitedYear){Zapatec.Utils.removeClass(M.hilitedYear,"hilite");}Zapatec.Utils.addClass(K,"hilite");M.hilitedYear=K;}else{if(M.hilitedYear){Zapatec.Utils.removeClass(M.hilitedYear,"hilite");}}}else{if(M.hilitedYear){Zapatec.Utils.removeClass(M.hilitedYear,"hilite");}var E=Zapatec.Calendar.findHist(W);if(E){if(!E.histDate.dateEqualsTo(M.date)){if(M.hilitedHist){Zapatec.Utils.removeClass(M.hilitedHist,"hilite");}Zapatec.Utils.addClass(E,"hilite");M.hilitedHist=E;}else{if(M.hilitedHist){Zapatec.Utils.removeClass(M.hilitedHist,"hilite");}}}else{if(M.hilitedHist){Zapatec.Utils.removeClass(M.hilitedHist,"hilite");}}}}return Zapatec.Utils.stopEvent(U);};Zapatec.Calendar.tableMouseDown=function(A){if(Zapatec.Utils.getTargetElement(A)==Zapatec.Utils.getElement(A)){return Zapatec.Utils.stopEvent(A);}};Zapatec.Calendar.calDragIt=function(D){D||(D=window.event);var E=Zapatec.Calendar._C;if(!(E&&E.dragging)){return false;}var G=D.clientX+window.document.body.scrollLeft;var F=D.clientY+window.document.body.scrollTop;E.hideShowCovered();var C=E.element.style,A=G-E.xOffs,B=F-E.yOffs;C.left=A+"px";C.top=B+"px";Zapatec.Utils.setupWCH(E.WCH,A,B);return Zapatec.Utils.stopEvent(D);};Zapatec.Calendar.calDragEnd=function(A){var B=Zapatec.Calendar._C;if(!B){return false;}B.dragging=false;Zapatec.Utils.removeEvent(window.document,"mousemove",Zapatec.Calendar.calDragIt);Zapatec.Utils.removeEvent(window.document,"mouseover",Zapatec.Calendar.calDragIt);Zapatec.Utils.removeEvent(window.document,"mouseup",Zapatec.Calendar.calDragEnd);Zapatec.Calendar.tableMouseUp(A);B.hideShowCovered();};Zapatec.Calendar.dayMouseDown=function(C){var A=true;var B=Zapatec.Utils.getElement(C);if(B.disabled){return false;}var D=B.calendar;while(!D){B=B.parentNode;D=B.calendar;}D.bEventShowHistory=false;D.activeDiv=B;Zapatec.Calendar._C=D;if(B.navtype!=300){if(B.navtype==50){if(!((D.timeInterval==null)||((D.timeInterval<60)&&(B.className.indexOf("hour",0)!=-1)))){A=false;}B._current=B.firstChild.data;if(A){Zapatec.Utils.addEvent(window.document,"mousemove",Zapatec.Calendar.tableMouseOver);}}else{if(((B.navtype==201)||(B.navtype==202))&&(D.timeInterval>30)&&(B.timePart.className.indexOf("minute",0)!=-1)){A=false;}if(A){Zapatec.Utils.addEvent(window.document,Zapatec.is_ie5?"mousemove":"mouseover",Zapatec.Calendar.tableMouseOver);}}if(A){Zapatec.Utils.addClass(B,"hilite active");}Zapatec.Utils.addEvent(window.document,"mouseup",Zapatec.Calendar.tableMouseUp);}else{if(D.isPopup){D._dragStart(C);}else{Zapatec.Calendar._C=null;}}if(B.navtype==-1||B.navtype==1){if(D.timeout){clearTimeout(D.timeout);}D.timeout=setTimeout("Zapatec.Calendar.showMonthsCombo()",250);}else{if(B.navtype==-2||B.navtype==2){if(D.timeout){clearTimeout(D.timeout);}D.timeout=setTimeout((B.navtype>0)?"Zapatec.Calendar.showYearsCombo(true)":"Zapatec.Calendar.showYearsCombo(false)",250);}else{if(B.navtype==0&&Zapatec.Calendar.prefs.history){if(D.timeout){clearTimeout(D.timeout);}D.timeout=setTimeout("Zapatec.Calendar.showHistoryCombo()",250);}else{D.timeout=null;}}}return Zapatec.Utils.stopEvent(C);};Zapatec.Calendar.dayMouseDblClick=function(A){Zapatec.Calendar.cellClick(Zapatec.Utils.getElement(A),A||window.event);if(Zapatec.is_ie){window.document.selection.empty();}};Zapatec.Calendar.dayMouseOver=function(D){var C=Zapatec.Utils.getElement(D),A=C.caldate;while(!C.calendar){C=C.parentNode;A=C.caldate;}var E=C.calendar;var B=C.timePart;if(A){A=new Date(A[0],A[1],A[2]);if(A.getDate()!=C.caldate[2]){A.setDate(C.caldate[2]);}}if(Zapatec.Utils.isRelated(C,D)||Zapatec.Calendar._C||C.disabled){return false;}if(C.ttip){if(C.ttip.substr(0,1)=="_"){C.ttip=A.print(C.calendar.ttDateFormat)+C.ttip.substr(1);}C.calendar.showHint(C.ttip);}if(C.navtype!=300){if(!((E.timeInterval==null)||(C.className.indexOf("ampm",0)!=-1)||((E.timeInterval<60)&&(C.className.indexOf("hour",0)!=-1)))&&(C.navtype==50)){return Zapatec.Utils.stopEvent(D);}if(((C.navtype==201)||(C.navtype==202))&&(E.timeInterval>30)&&(B.className.indexOf("minute",0)!=-1)){return Zapatec.Utils.stopEvent(D);}Zapatec.Utils.addClass(C,"hilite");if(A){Zapatec.Utils.addClass(C.parentNode,"rowhilite");}}return Zapatec.Utils.stopEvent(D);};Zapatec.Calendar.dayMouseOut=function(B){var A=Zapatec.Utils.getElement(B);while(!A.calendar){A=A.parentNode;caldate=A.caldate;}if(Zapatec.Utils.isRelated(A,B)||Zapatec.Calendar._C||A.disabled){return false;}Zapatec.Utils.removeClass(A,"hilite");if(A.caldate){Zapatec.Utils.removeClass(A.parentNode,"rowhilite");}if(A.calendar){A.calendar.showHint(Zapatec.Calendar.i18n("SEL_DATE"));}return Zapatec.Utils.stopEvent(B);};Zapatec.Calendar.cellClick=function(C,V){var L=C.calendar;var G=false;var B=false;var W=null;while(!L){C=C.parentNode;L=C.calendar;}if(typeof C.navtype=="undefined"){if(L.currentDateEl){Zapatec.Utils.removeClass(L.currentDateEl,"selected");Zapatec.Utils.addClass(C,"selected");G=(L.currentDateEl==C);if(!G){L.currentDateEl=C;}}var D=new Date(C.caldate[0],C.caldate[1],C.caldate[2]);if(D.getDate()!=C.caldate[2]){D.setDate(C.caldate[2]);}L.date.setDateOnly(D);L.currentDate.setDateOnly(D);W=L.date;var I=!(L.dateClicked=!C.otherMonth);if(!I&&L.multiple){L._toggleMultipleDate(new Date(W));}B=true;if(I){L._init(L.firstDayOfWeek,W);}L.onSetTime();}else{if(C.navtype==200){Zapatec.Utils.removeClass(C,"hilite");L.callCloseHandler();return ;}W=new Date(L.date);if(C.navtype==0&&!L.bEventShowHistory){W.setDateOnly(new Date());}L.dateClicked=false;var K=W.getFullYear();var R=W.getMonth();function J(Z){var a=W.getDate();var Y=W.getMonthDays(Z);if(a>Y){W.setDate(Y);}W.setMonth(Z);}switch(C.navtype){case 400:Zapatec.Utils.removeClass(C,"hilite");var M=Zapatec.Calendar.i18n("ABOUT");if(typeof M!="undefined"){M+=L.showsTime?Zapatec.Calendar.i18n("ABOUT_TIME"):"";}else{M='Help and about box text is not translated into this language.\nIf you know this language and you feel generous please update\nthe corresponding file in "lang" subdir to match calendar-en.js\nand send it back to <support@zapatec.com> to get it into the distribution  ;-)\n\nThank you!\nhttp://www.zapatec.com\n';}alert(M);return ;case -2:if(K>L.minYear){W.setFullYear(K-1);}break;case -1:if(R>0){J(R-1);}else{if(K-->L.minYear){W.setFullYear(K);J(11);}}break;case 1:if(R<11){J(R+1);}else{if(K<L.maxYear){W.setFullYear(K+1);J(0);}}break;case 2:if(K<L.maxYear){W.setFullYear(K+1);}break;case 100:L.setFirstDayOfWeek(C.fdow);Zapatec.Calendar.prefs.fdow=L.firstDayOfWeek;Zapatec.Calendar.savePrefs();if(L.onFDOW){L.onFDOW(L.firstDayOfWeek);}return ;case 50:var W=L.currentDate;if(C.className.indexOf("ampm",0)>=0){}else{if(!((L.timeInterval==null)||((L.timeInterval<60)&&(C.className.indexOf("hour",0)!=-1)))){break;}}var N=C._range;var P=C.firstChild.data;var T=(W.getHours()>=12);for(var S=N.length;--S>=0;){if(N[S]==P){break;}}if(V&&V.shiftKey){if(--S<0){S=N.length-1;}}else{if(++S>=N.length){S=0;}}if(L.getDateStatus){var O=null;var F=null;var A=new Date(W);if(C.className.indexOf("ampm",0)!=-1){O=W.getMinutes();F=(N[S]=="pm")?((W.getHours()==12)?(W.getHours()):(W.getHours()+12)):(W.getHours()-12);if(L.getDateStatus&&L.getDateStatus(A,W.getFullYear(),W.getMonth(),W.getDate(),parseInt(F,10),parseInt(O,10))){var H;if(N[S]=="pm"){H=-5;}else{H=5;}hours=F;minutes=O;do{minutes+=H;if(minutes>=60){minutes-=60;++hours;if(hours>=24){hours-=24;}A.setHours(hours);}if(minutes<0){minutes+=60;--hours;if(hours<0){hours+=24;}A.setHours(hours);}A.setMinutes(minutes);if(!L.getDateStatus(A,W.getFullYear(),W.getMonth(),W.getDate(),parseInt(hours,10),parseInt(minutes,10))){F=hours;O=minutes;if(F>12){S=1;}else{S=0;}L.date.setHours(F);L.date.setMinutes(O);L.onSetTime();}}while((F!=hours)||(O!=minutes));}A.setHours(F);}if(C.className.indexOf("hour",0)!=-1){O=W.getMinutes();F=(!L.time24)?((T)?((N[S]!=12)?(parseInt(N[S],10)+12):(12)):((N[S]!=12)?(N[S]):(0))):(N[S]);A.setHours(F);}if(C.className.indexOf("minute",0)!=-1){F=W.getHours();O=N[S];A.setMinutes(O);}}var Q=false;if(L.getDateStatus){Q=L.getDateStatus(A,W.getFullYear(),W.getMonth(),W.getDate(),parseInt(F,10),parseInt(O,10));}if(!Q){C.firstChild.data=N[S];}L.onUpdateTime();return ;case 201:case 202:var U=C.timePart;var W=L.currentDate;if((U.className.indexOf("minute",0)!=-1)&&(L.timeInterval>30)){break;}var X=parseInt(U.firstChild.data,10);var T=(W.getHours()>=12);var N=U._range;for(var S=N.length;--S>=0;){if(X==N[S]){X=S;break;}}var E=U._step;if(C.navtype==201){X=E*Math.floor(X/E);X+=E;if(X>=N.length){X=0;}}else{X=E*Math.ceil(X/E);X-=E;if(X<0){X=N.length-E;}}if(L.getDateStatus){var O=null;var F=null;var A=new Date(W);if(U.className=="hour"){O=W.getMinutes();F=(!L.time24)?((T)?((N[X]!=12)?(parseInt(N[X],10)+12):(12)):((N[X]!=12)?(N[X]):(0))):(N[X]);A.setHours(F);}if(U.className=="minute"){F=W.getHours();O=X;A.setMinutes(N[X]);}}var Q=false;if(L.getDateStatus){Q=L.getDateStatus(A,W.getFullYear(),W.getMonth(),W.getDate(),parseInt(F,10),parseInt(O,10));}if(!Q){U.firstChild.data=N[X];}L.onUpdateTime();return ;case 0:if(L.getDateStatus&&((L.getDateStatus(W,W.getFullYear(),W.getMonth(),W.getDate())==true)||(L.getDateStatus(W,W.getFullYear(),W.getMonth(),W.getDate())=="disabled"))){return false;}break;}if(!W.equalsTo(L.date)){if((C.navtype>=-2&&C.navtype<=2)&&(C.navtype!=0)){L._init(L.firstDayOfWeek,W,true);return ;}L.setDate(W);B=!(C.navtype&&(C.navtype>=-2&&C.navtype<=2));}}if(B){L.callHandler();}if(G){Zapatec.Utils.removeClass(C,"hilite");L.callCloseHandler();}};Zapatec.Calendar.prototype.create=function(J){var F=null;if(!J){F=window.document.getElementsByTagName("body")[0];this.isPopup=true;this.WCH=Zapatec.Utils.createWCH();}else{F=J;this.isPopup=false;}this.currentDate=this.date=this.dateStr?new Date(this.dateStr):new Date();var S=Zapatec.Utils.createElement("table");this.table=S;S.cellSpacing=0;S.cellPadding=0;S.calendar=this;Zapatec.Utils.addEvent(S,"mousedown",Zapatec.Calendar.tableMouseDown);var I=Zapatec.Utils.createElement("div");this.element=I;I.className="calendar";if(Zapatec.is_opera){S.style.width=(this.monthsInRow*((this.weekNumbers)?(8):(7))*2+4.4*this.monthsInRow)+"em";}if(this.isPopup){I.style.position="absolute";I.style.display="none";}I.appendChild(S);var C=null;var E=null;var H=this;var D=function(X,W,V){C=Zapatec.Utils.createElement("td",E);C.colSpan=W;C.className="button";if(Math.abs(V)<=2){C.className+=" nav";}Zapatec.Calendar._add_evs(C);C.calendar=H;C.navtype=V;if(X.substr(0,1)!="&"){C.appendChild(document.createTextNode(X));}else{C.innerHTML=X;}return C;};var T=((this.weekNumbers)?(8):(7))*this.monthsInRow-2;var R=Zapatec.Utils.createElement("thead",S);if(this.numberMonths==1){this.title=R;}E=Zapatec.Utils.createElement("tr",R);if(this.helpButton){D("?",1,400).ttip=Zapatec.Calendar.i18n("INFO");}else{C=Zapatec.Utils.createElement("td",E);C.colSpan=1;C.className="button";C.innerHTML="<p>&nbsp</p>";}this.title=D("",T,300);this.title.className="title";if(this.isPopup){this.title.ttip=Zapatec.Calendar.i18n("DRAG_TO_MOVE");this.title.style.cursor="move";D("&#x00d7;",1,200).ttip=Zapatec.Calendar.i18n("CLOSE");}else{C=Zapatec.Utils.createElement("td",E);C.colSpan=1;C.className="button";C.innerHTML="<p>&nbsp</p>";}if(this.params&&this.params.titleHtml){this.title.innerHTML=this.params.titleHtml;}E=Zapatec.Utils.createElement("tr",R);this._nav_py=D("&#x00ab;",1,-2);this._nav_py.ttip=Zapatec.Calendar.i18n("PREV_YEAR");this._nav_pm=D("&#x2039;",1,-1);this._nav_pm.ttip=Zapatec.Calendar.i18n("PREV_MONTH");this._nav_now=D(Zapatec.Calendar.i18n("TODAY"),T-2,0);this._nav_now.ttip=Zapatec.Calendar.i18n("GO_TODAY");this._nav_nm=D("&#x203a;",1,1);this._nav_nm.ttip=Zapatec.Calendar.i18n("NEXT_MONTH");this._nav_ny=D("&#x00bb;",1,2);this._nav_ny.ttip=Zapatec.Calendar.i18n("NEXT_YEAR");var U=Math.floor(this.numberMonths/this.monthsInRow);if(this.numberMonths%this.monthsInRow>0){++U;}for(var K=1;K<=U;++K){var R=Zapatec.Utils.createElement("thead",S);if(Zapatec.is_opera){R.style.display="table-row-group";}if(this.numberMonths!=1){E=Zapatec.Utils.createElement("tr",R);var T=5;this.weekNumbers&&++T;this.titles[K]=new Array();for(var L=1;(L<=this.monthsInRow)&&((K-1)*this.monthsInRow+L<=this.numberMonths);++L){C=Zapatec.Utils.createElement("td",E);C.colSpan=1;C.className="button";C.innerHTML="<p>&nbsp</p>";this.titles[K][L]=D("",T,300);this.titles[K][L].className="title";C=Zapatec.Utils.createElement("td",E);C.colSpan=1;C.className="button";C.innerHTML="<p>&nbsp</p>";}}E=Zapatec.Utils.createElement("tr",R);E.className="daynames";for(L=1;(L<=this.monthsInRow)&&((K-1)*this.monthsInRow+L<=this.numberMonths);++L){if(this.weekNumbers){C=Zapatec.Utils.createElement("td",E);C.className="name wn";C.appendChild(window.document.createTextNode(Zapatec.Calendar.i18n("WK")));if(L>1){Zapatec.Utils.addClass(C,"month-left-border");}var Q=Zapatec.Calendar.i18n("WK");if(Q==null){Q="";}}for(var P=7;P>0;--P){C=Zapatec.Utils.createElement("td",E);C.appendChild(window.document.createTextNode(""));}}this.firstdayname=E.childNodes[this.weekNumbers?1:0];this.rowsOfDayNames[K]=this.firstdayname;this._displayWeekdays();var B=Zapatec.Utils.createElement("tbody",S);this.tbody[K]=B;for(P=6;P>0;--P){E=Zapatec.Utils.createElement("tr",B);for(L=1;(L<=this.monthsInRow)&&((K-1)*this.monthsInRow+L<=this.numberMonths);++L){if(this.weekNumbers){C=Zapatec.Utils.createElement("td",E);C.appendChild(document.createTextNode(""));}for(var M=7;M>0;--M){C=Zapatec.Utils.createElement("td",E);C.appendChild(document.createTextNode(""));C.calendar=this;Zapatec.Calendar._add_evs(C);}}}}var G=Zapatec.Utils.createElement("tfoot",S);if(this.showsTime){E=Zapatec.Utils.createElement("tr",G);E.className="time";var A;if(this.monthsInRow!=1){C=Zapatec.Utils.createElement("td",E);A=C.colSpan=Math.ceil((((this.weekNumbers)?8:7)*(this.monthsInRow-1))/2);C.className="timetext";C.innerHTML="&nbsp";}C=Zapatec.Utils.createElement("td",E);C.className="timetext";C.colSpan=this.weekNumbers?2:1;C.innerHTML=Zapatec.Calendar.i18n("TIME")||"&nbsp;";(function(){function a(q,u,g,t){var v,p,r,l,h;if(t){C=Zapatec.Utils.createElement("td",E);C.colSpan=1;if(H.showsTime!="seconds"){++C.colSpan;}C.className="parent-"+q;v=Zapatec.Utils.createElement("table",C);v.cellSpacing=v.cellPadding=0;if(q=="hour"){v.align="right";}v.className="calendar-time-scroller";p=Zapatec.Utils.createElement("tbody",v);r=Zapatec.Utils.createElement("tr",p);l=Zapatec.Utils.createElement("tr",p);}else{r=E;}h=Zapatec.Utils.createElement("td",r);h.className=q;h.appendChild(window.document.createTextNode(u));h.calendar=H;h.ttip=Zapatec.Calendar.i18n("TIME_PART");h.navtype=50;h._range=[];if(!t){h._range=g;}else{h.rowSpan=2;for(var o=g;o<=t;++o){var n;if(o<10&&t>=10){n="0"+o;}else{n=""+o;}h._range[h._range.length]=n;}var m=Zapatec.Utils.createElement("td",r);m.className="up";m.navtype=201;m.calendar=H;m.timePart=h;if(Zapatec.is_khtml){m.innerHTML="&nbsp;";}Zapatec.Calendar._add_evs(m);var s=Zapatec.Utils.createElement("td",l);s.className="down";s.navtype=202;s.calendar=H;s.timePart=h;if(Zapatec.is_khtml){s.innerHTML="&nbsp;";}Zapatec.Calendar._add_evs(s);}Zapatec.Calendar._add_evs(h);return h;}var d=H.currentDate.getHours();var V=H.currentDate.getMinutes();if(H.showsTime=="seconds"){var Y=H.currentDate.getSeconds();}var f=!H.time24;var W=(d>12);if(f&&W){d-=12;}var b=a("hour",d,f?1:0,f?12:23);b._step=(H.timeInterval>30)?(H.timeInterval/60):1;C=Zapatec.Utils.createElement("td",E);C.innerHTML=":";C.className="colon";var Z=a("minute",V,0,59);Z._step=((H.timeInterval)&&(H.timeInterval<60))?(H.timeInterval):5;if(H.showsTime=="seconds"){C=Zapatec.Utils.createElement("td",E);C.innerHTML=":";C.className="colon";var X=a("minute",Y,0,59);X._step=5;}var c=null;if(f){c=a("ampm",W?"pm":"am",["am","pm"]);c.className+=" button";}else{Zapatec.Utils.createElement("td",E).innerHTML="&nbsp;";}H.onSetTime=function(){var l=this.currentDate.getHours();var m=this.currentDate.getMinutes();if(this.showsTime=="seconds"){var i=H.currentDate.getSeconds();}if(this.timeInterval){m+=this.timeInterval-((m-1+this.timeInterval)%this.timeInterval)-1;}while(m>=60){m-=60;++l;}if(this.timeInterval>60){var g=this.timeInterval/60;if(l%g!=0){l+=g-((l-1+g)%g)-1;}if(l>=24){l-=24;}}var n=new Date(this.currentDate);if(this.getDateStatus&&this.getDateStatus(this.currentDate,this.currentDate.getFullYear(),this.currentDate.getMonth(),this.currentDate.getDate(),l,m)){hours=l;minutes=m;do{if(this.timeInterval){if(this.timeInterval<60){minutes+=this.timeInterval;}else{l+=this.timeInterval/60;}}else{minutes+=5;}if(minutes>=60){minutes-=60;hours+=1;}if(hours>=24){hours-=24;}n.setMinutes(minutes);n.setHours(hours);if(!this.getDateStatus(n,this.currentDate.getFullYear(),this.currentDate.getMonth(),this.currentDate.getDate(),hours,minutes)){l=hours;m=minutes;}}while((l!=hours)||(m!=minutes));}this.currentDate.setMinutes(m);this.currentDate.setHours(l);var h=(l>=12);if(h&&f&&l!=12){l-=12;}if(!h&&f&&l==0){l=12;}b.firstChild.data=(l<10)?("0"+l):l;Z.firstChild.data=(m<10)?("0"+m):m;if(this.showsTime=="seconds"){X.firstChild.data=(i<10)?("0"+i):i;}if(f){c.firstChild.data=h?"pm":"am";}};H.onUpdateTime=function(){var i=this.currentDate;var l=parseInt(b.firstChild.data,10);if(f){if(/pm/i.test(c.firstChild.data)&&l<12){l+=12;}else{if(/am/i.test(c.firstChild.data)&&l==12){l=0;}}}var n=i.getDate();var g=i.getMonth();var o=i.getFullYear();i.setHours(l);i.setMinutes(parseInt(Z.firstChild.data,10));if(this.showsTime=="seconds"){i.setSeconds(parseInt(X.firstChild.data,10));}i.setFullYear(o);i.setMonth(g);i.setDate(n);this.dateClicked=false;this.callHandler();};})();if(this.monthsInRow!=1){C=Zapatec.Utils.createElement("td",E);C.colSpan=((this.weekNumbers)?8:7)*(this.monthsInRow-1)-Math.ceil(A);C.className="timetext";C.innerHTML="&nbsp";}}else{this.onSetTime=this.onUpdateTime=function(){};}E=Zapatec.Utils.createElement("tr",G);E.className="footrow";C=D(Zapatec.Calendar.i18n("SEL_DATE"),this.weekNumbers?(8*this.numberMonths):(7*this.numberMonths),300);C.className="ttip";if(this.isPopup){C.ttip=Zapatec.Calendar.i18n("DRAG_TO_MOVE");C.style.cursor="move";}this.tooltips=C;I=this.monthsCombo=Zapatec.Utils.createElement("div",this.element);I.className="combo";for(P=0;P<12;++P){var O=Zapatec.Utils.createElement("div");O.className=Zapatec.is_ie?"label-IEfix":"label";O.month=P;O.appendChild(window.document.createTextNode(Zapatec.Calendar.i18n(P,"smn")));I.appendChild(O);}I=this.yearsCombo=Zapatec.Utils.createElement("div",this.element);I.className="combo";for(P=12;P>0;--P){var N=Zapatec.Utils.createElement("div");N.className=Zapatec.is_ie?"label-IEfix":"label";N.appendChild(window.document.createTextNode(""));I.appendChild(N);}I=this.histCombo=Zapatec.Utils.createElement("div",this.element);I.className="combo history";this._init(this.firstDayOfWeek,this.date);F.appendChild(this.element);};Zapatec.Calendar._keyEvent=function(D){if(!window.calendar){return false;}(Zapatec.is_ie)&&(D=window.event);var E=window.calendar;var B=(Zapatec.is_ie||D.type=="keypress");var A=D.keyCode;var C=new Date(E.date);if(D.ctrlKey){switch(A){case 37:B&&Zapatec.Calendar.cellClick(E._nav_pm);break;case 38:B&&Zapatec.Calendar.cellClick(E._nav_py);break;case 39:B&&Zapatec.Calendar.cellClick(E._nav_nm);break;case 40:B&&Zapatec.Calendar.cellClick(E._nav_ny);break;default:return false;}}else{switch(A){case 32:Zapatec.Calendar.cellClick(E._nav_now);break;case 27:B&&E.callCloseHandler();break;case 37:if(B&&!E.multiple){C.setTime(C.getTime()-86400000);E.setDate(C);}break;case 38:if(B&&!E.multiple){C.setTime(C.getTime()-7*86400000);E.setDate(C);}break;case 39:if(B&&!E.multiple){C.setTime(C.getTime()+86400000);E.setDate(C);}break;case 40:if(B&&!E.multiple){C.setTime(C.getTime()+7*86400000);E.setDate(C);}break;case 13:if(B){Zapatec.Calendar.cellClick(E.currentDateEl);}break;default:return false;}}return Zapatec.Utils.stopEvent(D);};Zapatec.Calendar.prototype._init=function(Q,t,N){var I=new Date(),q=I.getDate(),a=I.getFullYear(),h=I.getMonth();if(this.getDateStatus&&!N){var Y=this.getDateStatus(t,t.getFullYear(),t.getMonth(),t.getDate());var F=new Date(t);while(((Y==true)||(Y=="disabled"))&&(F.getMonth()==t.getMonth())){t.setTime(t.getTime()+86400000);var Y=this.getDateStatus(t,t.getFullYear(),t.getMonth(),t.getDate());}if(F.getMonth()!=t.getMonth()){t=new Date(F);while(((Y==true)||(Y=="disabled"))&&(F.getMonth()==t.getMonth())){t.setTime(t.getTime()-86400000);var Y=this.getDateStatus(t,t.getFullYear(),t.getMonth(),t.getDate());}}if(F.getMonth()!=t.getMonth()){N=true;t=new Date(F);}}var E=t.getFullYear();var A=t.getMonth();var v=Math.floor(this.numberMonths/this.monthsInRow);var P;var T,Z,K;if(!this.vertical){T=(this.controlMonth-1);P=A-T;}else{Z=((this.numberMonths-1)%this.monthsInRow)+1;K=(this.controlMonth-1)%this.monthsInRow;bottom=(K>=(Z)?(Z):(K));T=(K)*(v-1)+Math.floor((this.controlMonth-1)/this.monthsInRow)+bottom;P=A-T;}var M=E;if(P<0){P+=12;--M;}var U=P+this.numberMonths-1;var S=M;if(U>11){U-=12;++S;}function V(i){Zapatec.Calendar._del_evs(i);i.disabled=true;i.className="button";i.innerHTML="<p>&nbsp</p>";}function D(l,i){Zapatec.Calendar._add_evs(l);l.disabled=false;l.className="button nav";l.innerHTML=i;}if(M<=this.minYear){if(!this._nav_py.disabled){V(this._nav_py);}}else{if(this._nav_py.disabled){D(this._nav_py,"&#x00ab;");}}if(S>=this.maxYear){if(!this._nav_ny.disabled){V(this._nav_ny);}}else{if(this._nav_ny.disabled){D(this._nav_ny,"&#x00bb;");}}if(((M==this.minYear)&&(P<=this.minMonth))||(M<this.minYear)){if(!this._nav_pm.disabled){V(this._nav_pm);}}else{if(this._nav_pm.disabled){D(this._nav_pm,"&#x2039;");}}if(((S==this.maxYear)&&(U>=this.maxMonth))||(S>this.maxYear)){if(!this._nav_nm.disabled){V(this._nav_nm);}}else{if(this._nav_nm.disabled){D(this._nav_nm,"&#x203a;");}}upperMonth=this.maxMonth+1;upperYear=this.maxYear;if(upperMonth>11){upperMonth-=12;++upperYear;}bottomMonth=this.minMonth-1;bottomYear=this.minYear;if(bottomMonth<0){bottomMonth+=12;--bottomYear;}maxDate1=new Date(S,U,t.getMonthDays(U),23,59,59,999);maxDate2=new Date(upperYear,upperMonth,1,0,0,0,0);minDate1=new Date(M,P,1,0,0,0,0);minDate2=new Date(bottomYear,bottomMonth,t.getMonthDays(bottomMonth),23,59,59,999);if(maxDate1.getTime()>maxDate2.getTime()){t.setTime(t.getTime()-(maxDate1.getTime()-maxDate2.getTime()));}if(minDate1.getTime()<minDate2.getTime()){t.setTime(t.getTime()+(minDate2.getTime()-minDate1.getTime()));}delete maxDate1;delete maxDate2;delete minDate1;delete minDate2;this.firstDayOfWeek=Q;if(!N){this.currentDate=t;}this.date=t;(this.date=new Date(this.date)).setDateOnly(t);E=this.date.getFullYear();A=this.date.getMonth();var H=t.getMonth();var G=this.date.getDate();var d=t.getMonthDays();var R=new Array();if(this.numberMonths%this.monthsInRow>0){++v;}for(var o=1;o<=v;++o){R[o]=new Array();for(var p=1;(p<=this.monthsInRow)&&((o-1)*this.monthsInRow+p<=this.numberMonths);++p){var c=new Date(t);if(this.vertical){var u=t.getMonth()-T+((p-1)*(v-1)+(o-1)+((Z<p)?(Z):(p-1)));}else{var u=t.getMonth()-T+(o-1)*this.monthsInRow+p-1;}if(u<0){c.setFullYear(c.getFullYear()-1);u=12+u;}if(u>11){c.setFullYear(c.getFullYear()+1);u=u-12;}c.setDate(1);c.setMonth(u);var m=(c.getDay()-this.firstDayOfWeek)%7;if(m<0){m+=7;}c.setDate(-m);c.setDate(c.getDate()+1);R[o][p]=c;}}var B=Zapatec.Calendar.i18n(A,"smn");var C=Zapatec.Calendar.i18n("WEEKEND");var n=this.multiple?(this.datesCells={}):null;var f=this.getDateText;for(var o=1;o<=v;++o){var J=this.tbody[o].firstChild;for(var r=7;--r>0;J=J.nextSibling){var W=J.firstChild;var w=false;for(var p=1;(p<=this.monthsInRow)&&((o-1)*this.monthsInRow+p<=this.numberMonths);++p){t=R[o][p];if(this.weekNumbers){W.className=" day wn";W.innerHTML=t.getWeekNumber();if(p>1){Zapatec.Utils.addClass(W,"month-left-border");}W=W.nextSibling;}J.className="daysrow";var X;for(j=7;W&&(X=t.getDate())&&(j>0);t.setDate(X+1),((t.getDate()==X)?(t.setHours(1)&&t.setDate(X+1)):(false)),W=W.nextSibling,--j){var L=t.getDay(),b=t.getMonth(),g=t.getFullYear();W.className=" day";if((!this.weekNumbers)&&(j==7)&&(p!=1)){Zapatec.Utils.addClass(W,"month-left-border");}if((j==1)&&(p!=this.monthsInRow)){Zapatec.Utils.addClass(W,"month-right-border");}if(this.vertical){u=H-T+((p-1)*(v-1)+(o-1)+((Z<p)?(Z):(p-1)));}else{u=H-T+((o-1)*this.monthsInRow+p-1);}if(u<0){u=12+u;}if(u>11){u=u-12;}var s=!(W.otherMonth=!(b==u));if(!s){if(this.showsOtherMonths){W.className+=" othermonth";}else{W.innerHTML="<p>&nbsp;</p>";W.disabled=true;continue;}}else{w=true;}W.disabled=false;W.innerHTML=f?f(t,g,b,X):X;n&&(n[t.print("%Y%m%d")]=W);if(this.getDateStatus){var Y=this.getDateStatus(t,g,b,X);if(this.getDateToolTip){var O=this.getDateToolTip(t,g,b,X);if(O){W.title=O;}}if(Y==true){W.className+=" disabled";W.disabled=true;}else{if(/disabled/i.test(Y)){W.disabled=true;}W.className+=" "+Y;}}if(!W.disabled){W.caldate=[g,b,X];W.ttip="_";if(!this.multiple&&s&&X==this.currentDate.getDate()&&this.hiliteToday&&(b==this.currentDate.getMonth())&&(g==this.currentDate.getFullYear())){W.className+=" selected";this.currentDateEl=W;}if(g==a&&b==h&&X==q){W.className+=" today";W.ttip+=Zapatec.Calendar.i18n("PART_TODAY");}if((C!=null)&&(C.indexOf(L.toString())!=-1)){W.className+=W.otherMonth?" oweekend":" weekend";}}}if(!(w||this.showsOtherMonths)){J.className="emptyrow";}}if((r==1)&&(o<v)){if(J.className=="emptyrow"){J=J.previousSibling;}W=J.firstChild;while(W!=null){Zapatec.Utils.addClass(W,"month-bottom-border");W=W.nextSibling;}}}}if(this.numberMonths==1){this.title.innerHTML=Zapatec.Calendar.i18n(A,"mn")+", "+E;}else{for(var o=1;o<=v;++o){for(var p=1;(p<=this.monthsInRow)&&((o-1)*this.monthsInRow+p<=this.numberMonths);++p){if(this.vertical){u=A-T+((p-1)*(v-1)+(o-1)+((Z<p)?(Z):(p-1)));}else{u=A-T+(o-1)*this.monthsInRow+p-1;}validYear=E;if(u<0){--validYear;u=12+u;}if(u>11){++validYear;u=u-12;}this.titles[o][p].innerHTML=Zapatec.Calendar.i18n(u,"mn")+", "+validYear;}}}this.onSetTime();this._initMultipleDates();this.updateWCH();};Zapatec.Calendar.prototype._initMultipleDates=function(){if(this.multiple){for(var B in this.multiple){var A=this.datesCells[B];var C=this.multiple[B];if(!C){continue;}if(A){A.className+=" selected";}}}};Zapatec.Calendar.prototype._toggleMultipleDate=function(B){if(this.multiple){var C=B.print("%Y%m%d");var A=this.datesCells[C];if(A){var D=this.multiple[C];if(!D){Zapatec.Utils.addClass(A,"selected");this.multiple[C]=B;}else{Zapatec.Utils.removeClass(A,"selected");delete this.multiple[C];}}}};Zapatec.Calendar.prototype.setDateToolTipHandler=function(A){this.getDateToolTip=A;};Zapatec.Calendar.prototype.setDate=function(B,D){if(!B){B=new Date();}if(!B.equalsTo(this.date)){var C=B.getFullYear(),A=B.getMonth();if(C==this.minYear&&A<this.minMonth){this.showHint("<div class='error'>"+Zapatec.Calendar.i18n("E_RANGE")+" »»»</div>");}else{if(C==this.maxYear&&A>this.maxMonth){this.showHint("<div class='error'>««« "+Zapatec.Calendar.i18n("E_RANGE")+"</div>");}}this._init(this.firstDayOfWeek,B,D);}};Zapatec.Calendar.prototype.showHint=function(A){this.tooltips.innerHTML=A;};Zapatec.Calendar.prototype.reinit=function(){this._init(this.firstDayOfWeek,this.date);};Zapatec.Calendar.prototype.refresh=function(){var B=this.isPopup?null:this.element.parentNode;var A=parseInt(this.element.style.left);var C=parseInt(this.element.style.top);this.destroy();this.dateStr=this.date;this.create(B);if(this.isPopup){this.showAt(A,C);}else{this.show();}};Zapatec.Calendar.prototype.setFirstDayOfWeek=function(B){if(this.firstDayOfWeek!=B){this._init(B,this.date);var C=Math.floor(this.numberMonths/this.monthsInRow);if(this.numberMonths%this.monthsInRow>0){++C;}for(var A=1;A<=C;++A){this.firstdayname=this.rowsOfDayNames[A];this._displayWeekdays();}}};Zapatec.Calendar.prototype.setDateStatusHandler=Zapatec.Calendar.prototype.setDisabledHandler=function(A){this.getDateStatus=A;};Zapatec.Calendar.prototype.setRange=function(C,E){var B,D=Math.min(C,E),F=Math.max(C,E);this.minYear=B=Math.floor(D);this.minMonth=(B==D)?0:Math.ceil((D-B)*100-1);this.maxYear=B=Math.floor(F);this.maxMonth=(B==F)?11:Math.ceil((F-B)*100-1);};Zapatec.Calendar.prototype.setMultipleDates=function(A){if(!A||typeof A=="undefined"){return ;}this.multiple={};for(var B=A.length;--B>=0;){var D=A[B];var C=D.print("%Y%m%d");this.multiple[C]=D;}};Zapatec.Calendar.prototype.submitFlatDates=function(){if(typeof this.params.flatCallback=="function"){Zapatec.Utils.sortOrder=(this.sortOrder!="asc"&&this.sortOrder!="desc"&&this.sortOrder!="none")?"none":this.sortOrder;if(this.multiple&&(Zapatec.Utils.sortOrder!="none")){var D=new Array();for(var B in this.multiple){var A=this.multiple[B];if(A){D[D.length]=A;}D.sort(Zapatec.Utils.compareDates);}this.multiple={};for(var B=0;B<D.length;B++){var E=D[B];var C=E.print("%Y%m%d");this.multiple[C]=E;}}this.params.flatCallback(this);}};Zapatec.Calendar.prototype.callHandler=function(){if(this.onSelected){this.onSelected(this,this.date.print(this.dateFormat));}};Zapatec.Calendar.prototype.updateHistory=function(){var B,D,G,C,E,F="",A=Zapatec.Calendar.prefs.hsize-1;if(Zapatec.Calendar.prefs.history){B=Zapatec.Calendar.prefs.history.split(/,/);D=0;while(D<A&&(C=B[D++])){E=C.split(/\//);G=new Date(parseInt(E[0],10),parseInt(E[1],10)-1,parseInt(E[2],10),parseInt(E[3],10),parseInt(E[4],10));if(!G.dateEqualsTo(this.date)){F+=","+C;}}}Zapatec.Calendar.prefs.history=this.date.print("%Y/%m/%d/%H/%M")+F;Zapatec.Calendar.savePrefs();};Zapatec.Calendar.prototype.callCloseHandler=function(){if(this.dateClicked){this.updateHistory();}if(this.onClose){this.onClose(this);}this.hideShowCovered();};Zapatec.Calendar.prototype.destroy=function(){this.hide();Zapatec.Utils.destroy(this.element);Zapatec.Utils.destroy(this.WCH);Zapatec.Calendar._C=null;window.calendar=null;};Zapatec.Calendar.prototype.reparent=function(B){var A=this.element;A.parentNode.removeChild(A);B.appendChild(A);};Zapatec.Calendar._checkCalendar=function(B){if(!window.calendar){return false;}var A=Zapatec.is_ie?Zapatec.Utils.getElement(B):Zapatec.Utils.getTargetElement(B);for(;A!=null&&A!=calendar.element;A=A.parentNode){}if(A==null){window.calendar.callCloseHandler();return Zapatec.Utils.stopEvent(B);}};Zapatec.Calendar.prototype.updateWCH=function(A){Zapatec.Utils.setupWCH_el(this.WCH,this.element,A);};Zapatec.Calendar.prototype.show=function(){var E=this.table.getElementsByTagName("tr");for(var D=E.length;D>0;){var F=E[--D];Zapatec.Utils.removeClass(F,"rowhilite");var C=F.getElementsByTagName("td");for(var B=C.length;B>0;){var A=C[--B];Zapatec.Utils.removeClass(A,"hilite");Zapatec.Utils.removeClass(A,"active");}}this.element.style.display="block";this.hidden=false;if(this.isPopup){this.updateWCH();window.calendar=this;if(!this.noGrab){Zapatec.Utils.addEvent(window.document,"keydown",Zapatec.Calendar._keyEvent);Zapatec.Utils.addEvent(window.document,"keypress",Zapatec.Calendar._keyEvent);Zapatec.Utils.addEvent(window.document,"mousedown",Zapatec.Calendar._checkCalendar);}}this.hideShowCovered();};Zapatec.Calendar.prototype.hide=function(){if(this.isPopup){Zapatec.Utils.removeEvent(window.document,"keydown",Zapatec.Calendar._keyEvent);Zapatec.Utils.removeEvent(window.document,"keypress",Zapatec.Calendar._keyEvent);Zapatec.Utils.removeEvent(window.document,"mousedown",Zapatec.Calendar._checkCalendar);}this.element.style.display="none";Zapatec.Utils.hideWCH(this.WCH);this.hidden=true;this.hideShowCovered();};Zapatec.Calendar.prototype.showAt=function(A,C){var B=this.element.style;B.left=A+"px";B.top=C+"px";this.show();};Zapatec.Calendar.prototype.showAtElement=function(E,F){var B=this;var H=Zapatec.Utils.getAbsolutePos(E);if(!F||typeof F!="string"){this.showAt(H.x,H.y+E.offsetHeight);return true;}this.element.style.display="block";var A=B.element.offsetWidth;var D=B.element.offsetHeight;B.element.style.display="none";var C=F.substr(0,1);var G="l";if(F.length>1){G=F.substr(1,1);}switch(C){case"T":H.y-=D;break;case"B":H.y+=E.offsetHeight;break;case"C":H.y+=(E.offsetHeight-D)/2;break;case"t":H.y+=E.offsetHeight-D;break;case"b":break;}switch(G){case"L":H.x-=A;break;case"R":H.x+=E.offsetWidth;break;case"C":H.x+=(E.offsetWidth-A)/2;break;case"l":H.x+=E.offsetWidth-A;break;case"r":break;}H.width=A;H.height=D+40;B.monthsCombo.style.display="none";Zapatec.Utils.fixBoxPosition(H);B.showAt(H.x,H.y);};Zapatec.Calendar.prototype.setDateFormat=function(A){this.dateFormat=A;};Zapatec.Calendar.prototype.setTtDateFormat=function(A){this.ttDateFormat=A;};Zapatec.Calendar.prototype.parseDate=function(C,A){if(!C){return this.setDate(this.date);}if(!A){A=this.dateFormat;}var B=Date.parseDate(C,A);return this.setDate(B);};Zapatec.Calendar.prototype.hideShowCovered=function(){if(!Zapatec.is_ie5){return ;}var P=this;function B(S){var R=S.style.visibility;if(!R){if(window.document.defaultView&&typeof (window.document.defaultView.getComputedStyle)=="function"){if(!Zapatec.is_khtml){R=window.document.defaultView.getComputedStyle(S,"").getPropertyValue("visibility");}else{R="";}}else{if(S.currentStyle){R=S.currentStyle.visibility;}else{R="";}}}return R;}var Q=["applet","iframe","select"];var C=P.element;var A=Zapatec.Utils.getAbsolutePos(C);var F=A.x;var D=C.offsetWidth+F;var O=A.y;var N=C.offsetHeight+O;for(var H=Q.length;H>0;){var G=window.document.getElementsByTagName(Q[--H]);var E=null;for(var J=G.length;J>0;){E=G[--J];A=Zapatec.Utils.getAbsolutePos(E);var M=A.x;var L=E.offsetWidth+M;var K=A.y;var I=E.offsetHeight+K;if(P.hidden||(M>D)||(L<F)||(K>N)||(I<O)){if(!E.__msh_save_visibility){E.__msh_save_visibility=B(E);}E.style.visibility=E.__msh_save_visibility;}else{if(!E.__msh_save_visibility){E.__msh_save_visibility=B(E);}E.style.visibility="hidden";}}}};Zapatec.Calendar.prototype._displayWeekdays=function(){var B=this.firstDayOfWeek;var A=this.firstdayname;var D=Zapatec.Calendar.i18n("WEEKEND");for(k=1;(k<=this.monthsInRow)&&(A);++k){for(var C=0;C<7;++C){A.className=" day name";if((!this.weekNumbers)&&(C==0)&&(k!=1)){Zapatec.Utils.addClass(A,"month-left-border");}if((C==6)&&(k!=this.monthsInRow)){Zapatec.Utils.addClass(A,"month-right-border");}var E=(C+B)%7;if((!this.disableFdowClick)&&((this.params&&this.params.fdowClick)||C)){if(Zapatec.Calendar.i18n("DAY_FIRST")!=null){A.ttip=Zapatec.Calendar.i18n("DAY_FIRST").replace("%s",Zapatec.Calendar.i18n(E,"dn"));}A.navtype=100;A.calendar=this;A.fdow=E;Zapatec.Calendar._add_evs(A);}if((D!=null)&&(D.indexOf(E.toString())!=-1)){Zapatec.Utils.addClass(A,"weekend");}A.innerHTML=Zapatec.Calendar.i18n((C+B)%7,"sdn");A=A.nextSibling;}if(this.weekNumbers&&A){A=A.nextSibling;}}};Zapatec.Utils.compareDates=function(B,A){if(Zapatec.Calendar.prefs.sortOrder=="asc"){return B-A;}else{return A-B;}};Zapatec.Calendar.prototype._hideCombos=function(){this.monthsCombo.style.display="none";this.yearsCombo.style.display="none";this.histCombo.style.display="none";this.updateWCH();};Zapatec.Calendar.prototype._dragStart=function(B){B||(B=window.event);if(this.dragging){return ;}this.dragging=true;var D=B.clientX+window.document.body.scrollLeft;var C=B.clientY+window.document.body.scrollTop;var A=this.element.style;this.xOffs=D-parseInt(A.left);this.yOffs=C-parseInt(A.top);Zapatec.Utils.addEvent(window.document,"mousemove",Zapatec.Calendar.calDragIt);Zapatec.Utils.addEvent(window.document,"mouseover",Zapatec.Calendar.calDragIt);Zapatec.Utils.addEvent(window.document,"mouseup",Zapatec.Calendar.calDragEnd);};Date._MD=[31,28,31,30,31,30,31,31,30,31,30,31];Date.SECOND=1000;Date.MINUTE=60*Date.SECOND;Date.HOUR=60*Date.MINUTE;Date.DAY=24*Date.HOUR;Date.WEEK=7*Date.DAY;Date.prototype.getMonthDays=function(B){var A=this.getFullYear();if(typeof B=="undefined"){B=this.getMonth();}if(((0==(A%4))&&((0!=(A%100))||(0==(A%400))))&&B==1){return 29;}else{return Date._MD[B];}};Date.prototype.getDayOfYear=function(){var A=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var C=new Date(this.getFullYear(),0,0,0,0,0);var B=A-C;return Math.floor(B/Date.DAY);};Date.prototype.getWeekNumber=function(){var C=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var B=C.getDay();C.setDate(C.getDate()-(B+6)%7+3);var A=C.valueOf();C.setMonth(0);C.setDate(4);return Math.round((A-C.valueOf())/(7*86400000))+1;};Date.prototype.equalsTo=function(A){return((this.getFullYear()==A.getFullYear())&&(this.getMonth()==A.getMonth())&&(this.getDate()==A.getDate())&&(this.getHours()==A.getHours())&&(this.getMinutes()==A.getMinutes()));};Date.prototype.dateEqualsTo=function(A){return((this.getFullYear()==A.getFullYear())&&(this.getMonth()==A.getMonth())&&(this.getDate()==A.getDate()));};Date.prototype.setDateOnly=function(A){var B=new Date(A);this.setDate(1);this.setFullYear(B.getFullYear());this.setMonth(B.getMonth());this.setDate(B.getDate());};Date.prototype.print=function(I){var A=this.getMonth();var H=this.getDate();var J=this.getFullYear();var L=this.getWeekNumber();var M=this.getDay();var Q={};var N=this.getHours();var B=(N>=12);var F=(B)?(N-12):N;var P=this.getDayOfYear();if(F==0){F=12;}var C=this.getMinutes();var G=this.getSeconds();Q["%a"]=Zapatec.Calendar.i18n(M,"sdn");Q["%A"]=Zapatec.Calendar.i18n(M,"dn");Q["%b"]=Zapatec.Calendar.i18n(A,"smn");Q["%B"]=Zapatec.Calendar.i18n(A,"mn");Q["%C"]=1+Math.floor(J/100);Q["%d"]=(H<10)?("0"+H):H;Q["%e"]=H;Q["%H"]=(N<10)?("0"+N):N;Q["%I"]=(F<10)?("0"+F):F;Q["%j"]=(P<100)?((P<10)?("00"+P):("0"+P)):P;Q["%k"]=N?N:"0";Q["%l"]=F;Q["%m"]=(A<9)?("0"+(1+A)):(1+A);Q["%M"]=(C<10)?("0"+C):C;Q["%n"]="\n";Q["%p"]=B?"PM":"AM";Q["%P"]=B?"pm":"am";Q["%s"]=Math.floor(this.getTime()/1000);Q["%S"]=(G<10)?("0"+G):G;Q["%t"]="\t";Q["%U"]=Q["%W"]=Q["%V"]=(L<10)?("0"+L):L;Q["%u"]=(M==0)?7:M;Q["%w"]=M?M:"0";Q["%y"]=(""+J).substr(2,2);Q["%Y"]=J;Q["%%"]="%";var O=/%./g;if(!Zapatec.is_ie5&&!Zapatec.is_khtml&&!Zapatec.is_mac_ie){return I.replace(O,function(R){return Q[R]||R;});}var K=I.match(O);for(var E=0;E<K.length;E++){var D=Q[K[E]];if(D){O=new RegExp(K[E],"g");I=I.replace(O,D);}}return I;};Date.parseDate=function(I,A){if(!I){return new Date();}var J=0;var B=-1;var G=0;var L=I.split(/\W+/);var K=A.match(/%./g);var F=0,E=0;var M=0;var D=0;for(F=0;F<L.length;++F){if(!L[F]){continue;}switch(K[F]){case"%d":case"%e":G=parseInt(L[F],10);break;case"%m":B=parseInt(L[F],10)-1;break;case"%Y":case"%y":J=parseInt(L[F],10);(J<100)&&(J+=(J>29)?1900:2000);break;case"%b":case"%B":for(E=0;E<12;++E){if(Zapatec.Calendar.i18n(E,"mn").substr(0,L[F].length).toLowerCase()==L[F].toLowerCase()){B=E;break;}}break;case"%H":case"%I":case"%k":case"%l":M=parseInt(L[F],10);break;case"%P":case"%p":if(/pm/i.test(L[F])&&M<12){M+=12;}if(/am/i.test(L[F])&&M==12){M=0;}break;case"%M":D=parseInt(L[F],10);break;}}var C=!isNaN(J)&&!isNaN(B)&&!isNaN(G)&&!isNaN(M)&&!isNaN(D);if(!C){return null;}if(J!=0&&B!=-1&&G!=0){return new Date(J,B,G,M,D,0);}J=0;B=-1;G=0;for(F=0;F<L.length;++F){if(L[F].search(/[a-zA-Z]+/)!=-1){var N=-1;for(E=0;E<12;++E){if(Zapatec.Calendar.i18n(E,"mn").substr(0,L[F].length).toLowerCase()==L[F].toLowerCase()){N=E;break;}}if(N!=-1){if(B!=-1){G=B+1;}B=N;}}else{if(parseInt(L[F],10)<=12&&B==-1){B=L[F]-1;}else{if(parseInt(L[F],10)>31&&J==0){J=parseInt(L[F],10);(J<100)&&(J+=(J>29)?1900:2000);}else{if(G==0){G=L[F];}}}}}if(J==0){var H=new Date();J=H.getFullYear();}if(B!=-1&&G!=0){return new Date(J,B,G,M,D,0);}return null;};Date.prototype.__msh_oldSetFullYear=Date.prototype.setFullYear;Date.prototype.setFullYear=function(B){var A=new Date(this);A.__msh_oldSetFullYear(B);if(A.getMonth()!=this.getMonth()){this.setDate(28);}this.__msh_oldSetFullYear(B);};Date.prototype.compareDatesOnly=function(E,D){var C=E.getYear();var B=D.getYear();var A=E.getMonth();var H=D.getMonth();var G=E.getDate();var F=D.getDate();if(C>B){return -1;}if(B>C){return 1;}if(A>H){return -1;}if(H>A){return 1;}if(G>F){return -1;}if(F>G){return 1;}return 0;};window.calendar=null;try{Zapatec.Calendar.loadPrefs();}catch(e){}