Calendar=function(a,b,c,d){this.timeout=this.getDateText=this.getDateToolTip=this.getDateStatus=this.currentDateEl=this.activeDiv=null;this.onSelected=c||null;this.onClose=d||null;this.hidden=this.dragging=!1;this.minYear=1970;this.maxYear=2050;this.dateFormat=Calendar._TT.DEF_DATE_FORMAT;this.ttDateFormat=Calendar._TT.TT_DATE_FORMAT;this.weekNumbers=this.isPopup=!0;this.firstDayOfWeek=typeof a=="number"?a:Calendar._FD;this.showsOtherMonths=!1;this.dateStr=b;this.ar_days=null;this.showsTime=!1;this.time24=
!0;this.yearStep=2;this.hiliteToday=!0;this.activeYear=this.hilitedYear=this.activeMonth=this.hilitedMonth=this.yearsCombo=this.monthsCombo=this.firstdayname=this.tbody=this.element=this.table=this.multiple=null;this.dateClicked=!1;if(typeof Calendar._SDN=="undefined"){if(typeof Calendar._SDN_len=="undefined")Calendar._SDN_len=3;a=[];for(b=8;b>0;)a[--b]=Calendar._DN[b].substr(0,Calendar._SDN_len);Calendar._SDN=a;if(typeof Calendar._SMN_len=="undefined")Calendar._SMN_len=3;a=[];for(b=12;b>0;)a[--b]=
Calendar._MN[b].substr(0,Calendar._SMN_len);Calendar._SMN=a}};Calendar._C=null;Calendar.is_ie=/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent);Calendar.is_ie5=Calendar.is_ie&&/msie 5\.0/i.test(navigator.userAgent);Calendar.is_opera=/opera/i.test(navigator.userAgent);Calendar.is_khtml=/Konqueror|Safari|KHTML/i.test(navigator.userAgent);
Calendar.getAbsolutePos=function(a){var b=0,c=0,d=/^div$/i.test(a.tagName);if(d&&a.scrollLeft)b=a.scrollLeft;if(d&&a.scrollTop)c=a.scrollTop;b={x:a.offsetLeft-b,y:a.offsetTop-c};a.offsetParent&&(a=this.getAbsolutePos(a.offsetParent),b.x+=a.x,b.y+=a.y);return b};Calendar.isRelated=function(a,b){var c=b.relatedTarget;if(!c){var d=b.type;if(d=="mouseover")c=b.fromElement;else if(d=="mouseout")c=b.toElement}for(;c;){if(c==a)return!0;c=c.parentNode}return!1};
Calendar.removeClass=function(a,b){if(a&&a.className){for(var c=a.className.split(" "),d=[],e=c.length;e>0;)c[--e]!=b&&(d[d.length]=c[e]);a.className=d.join(" ")}};Calendar.addClass=function(a,b){Calendar.removeClass(a,b);a.className+=" "+b};Calendar.getElement=function(a){for(a=Calendar.is_ie?window.event.srcElement:a.currentTarget;a.nodeType!=1||/^div$/i.test(a.tagName);)a=a.parentNode;return a};
Calendar.getTargetElement=function(a){for(a=Calendar.is_ie?window.event.srcElement:a.target;a.nodeType!=1;)a=a.parentNode;return a};Calendar.stopEvent=function(a){a||(a=window.event);Calendar.is_ie?(a.cancelBubble=!0,a.returnValue=!1):(a.preventDefault(),a.stopPropagation());return!1};Calendar.addEvent=function(a,b,c){$(a).bind(b,c)};Calendar.removeEvent=function(a,b,c){$(a).unbind(b,c)};
Calendar.createElement=function(a,b){var c=null,c=document.createElementNS?document.createElementNS("http://www.w3.org/1999/xhtml",a):document.createElement(a);typeof b!="undefined"&&b.appendChild(c);return c};Calendar._add_evs=function(a){with(Calendar)addEvent(a,"mouseover",dayMouseOver),addEvent(a,"mousedown",dayMouseDown),addEvent(a,"mouseout",dayMouseOut),is_ie&&(addEvent(a,"dblclick",dayMouseDblClick),a.setAttribute("unselectable",!0))};
Calendar.findMonth=function(a){if(typeof a.month!="undefined")return a;else if(typeof a.parentNode.month!="undefined")return a.parentNode;return null};Calendar.findYear=function(a){if(typeof a.year!="undefined")return a;else if(typeof a.parentNode.year!="undefined")return a.parentNode;return null};
Calendar.showMonthsCombo=function(){var a=Calendar._C;if(!a)return!1;var b=a.activeDiv,c=a.monthsCombo;a.hilitedMonth&&Calendar.removeClass(a.hilitedMonth,"hilite");a.activeMonth&&Calendar.removeClass(a.activeMonth,"active");var d=a.monthsCombo.getElementsByTagName("div")[a.date.getMonth()];Calendar.addClass(d,"active");a.activeMonth=d;a=c.style;a.display="block";b.navtype<0?a.left=b.offsetLeft+"px":(c=c.offsetWidth,typeof c=="undefined"&&(c=50),a.left=b.offsetLeft+b.offsetWidth-c+"px");a.top=b.offsetTop+
b.offsetHeight+"px"};
Calendar.showYearsCombo=function(a){var b=Calendar._C;if(!b)return!1;var c=b.activeDiv,d=b.yearsCombo;b.hilitedYear&&Calendar.removeClass(b.hilitedYear,"hilite");b.activeYear&&Calendar.removeClass(b.activeYear,"active");b.activeYear=null;for(var e=b.date.getFullYear()+(a?1:-1),g=d.firstChild,f=!1,k=12;k>0;--k)e>=b.minYear&&e<=b.maxYear?(g.innerHTML=e,g.year=e,g.style.display="block",f=!0):g.style.display="none",g=g.nextSibling,e+=a?b.yearStep:-b.yearStep;if(f)a=d.style,a.display="block",c.navtype<
0?a.left=c.offsetLeft+"px":(d=d.offsetWidth,typeof d=="undefined"&&(d=50),a.left=c.offsetLeft+c.offsetWidth-d+"px"),a.top=c.offsetTop+c.offsetHeight+"px"};
Calendar.tableMouseUp=function(a){var b=Calendar._C;if(!b)return!1;b.timeout&&clearTimeout(b.timeout);var c=b.activeDiv;if(!c)return!1;var d=Calendar.getTargetElement(a);a||(a=window.event);Calendar.removeClass(c,"active");(d==c||d.parentNode==c)&&Calendar.cellClick(c,a);var e=Calendar.findMonth(d),c=null;if(e){if(c=new Date(b.date),e.month!=c.getMonth())c.setMonth(e.month),b.setDate(c),b.dateClicked=!1,b.callHandler()}else if(d=Calendar.findYear(d))if(c=new Date(b.date),d.year!=c.getFullYear())c.setFullYear(d.year),
b.setDate(c),b.dateClicked=!1,b.callHandler();with(Calendar)return removeEvent(document,"mouseup",tableMouseUp),removeEvent(document,"mouseover",tableMouseOver),removeEvent(document,"mousemove",tableMouseOver),b._hideCombos(),_C=null,stopEvent(a)};
Calendar.tableMouseOver=function(a){var b=Calendar._C;if(b){var c=b.activeDiv,d=Calendar.getTargetElement(a);d==c||d.parentNode==c?(Calendar.addClass(c,"hilite active"),Calendar.addClass(c.parentNode,"rowhilite")):((typeof c.navtype=="undefined"||c.navtype!=50&&(c.navtype==0||Math.abs(c.navtype)>2))&&Calendar.removeClass(c,"active"),Calendar.removeClass(c,"hilite"),Calendar.removeClass(c.parentNode,"rowhilite"));a||(a=window.event);if(c.navtype==50&&d!=c){var e=Calendar.getAbsolutePos(c),g=c.offsetWidth,
f=a.clientX,k=!0;f>e.x+g?(f=f-e.x-g,k=!1):f=e.x-f;f<0&&(f=0);for(var e=c._range,g=c._current,f=Math.floor(f/10)%e.length,h=e.length;--h>=0;)if(e[h]==g)break;for(;f-- >0;)k?--h<0&&(h=e.length-1):++h>=e.length&&(h=0);c.innerHTML=e[h];b.onUpdateTime()}(c=Calendar.findMonth(d))?c.month!=b.date.getMonth()?(b.hilitedMonth&&Calendar.removeClass(b.hilitedMonth,"hilite"),Calendar.addClass(c,"hilite"),b.hilitedMonth=c):b.hilitedMonth&&Calendar.removeClass(b.hilitedMonth,"hilite"):(b.hilitedMonth&&Calendar.removeClass(b.hilitedMonth,
"hilite"),(d=Calendar.findYear(d))?d.year!=b.date.getFullYear()?(b.hilitedYear&&Calendar.removeClass(b.hilitedYear,"hilite"),Calendar.addClass(d,"hilite"),b.hilitedYear=d):b.hilitedYear&&Calendar.removeClass(b.hilitedYear,"hilite"):b.hilitedYear&&Calendar.removeClass(b.hilitedYear,"hilite"));return Calendar.stopEvent(a)}};Calendar.tableMouseDown=function(a){if(Calendar.getTargetElement(a)==Calendar.getElement(a))return Calendar.stopEvent(a)};
Calendar.calDragIt=function(a){var b=Calendar._C;if(!b||!b.dragging)return!1;var c,d;Calendar.is_ie?(d=window.event.clientY+document.body.scrollTop,c=window.event.clientX+document.body.scrollLeft):(c=a.pageX,d=a.pageY);b.hideShowCovered();var e=b.element.style;e.left=c-b.xOffs+"px";e.top=d-b.yOffs+"px";return Calendar.stopEvent(a)};
Calendar.calDragEnd=function(a){var b=Calendar._C;if(!b)return!1;b.dragging=!1;with(Calendar)removeEvent(document,"mousemove",calDragIt),removeEvent(document,"mouseup",calDragEnd),tableMouseUp(a);b.hideShowCovered()};
Calendar.dayMouseDown=function(a){var b=Calendar.getElement(a);if(b.disabled)return!1;var c=b.calendar;c.activeDiv=b;Calendar._C=c;if(b.navtype!=300)with(Calendar)b.navtype==50?(b._current=b.innerHTML,addEvent(document,"mousemove",tableMouseOver)):addEvent(document,Calendar.is_ie5?"mousemove":"mouseover",tableMouseOver),addClass(b,"hilite active"),addEvent(document,"mouseup",tableMouseUp);else c.isPopup&&c._dragStart(a);b.navtype==-1||b.navtype==1?(c.timeout&&clearTimeout(c.timeout),c.timeout=setTimeout("Calendar.showMonthsCombo()",
250)):b.navtype==-2||b.navtype==2?(c.timeout&&clearTimeout(c.timeout),c.timeout=setTimeout(b.navtype>0?"Calendar.showYearsCombo(true)":"Calendar.showYearsCombo(false)",250)):c.timeout=null;return Calendar.stopEvent(a)};Calendar.dayMouseDblClick=function(a){Calendar.cellClick(Calendar.getElement(a),a||window.event);Calendar.is_ie&&document.selection.empty()};
Calendar.dayMouseOver=function(a){var b=Calendar.getElement(a);if(Calendar.isRelated(b,a)||Calendar._C||b.disabled)return!1;if(b.ttip){if(b.ttip.substr(0,1)=="_")b.ttip=b.caldate.print(b.calendar.ttDateFormat)+b.ttip.substr(1);b.calendar.tooltips.innerHTML=b.ttip}b.navtype!=300&&(Calendar.addClass(b,"hilite"),b.caldate&&Calendar.addClass(b.parentNode,"rowhilite"));return Calendar.stopEvent(a)};
Calendar.dayMouseOut=function(a){with(Calendar){var b=getElement(a);if(isRelated(b,a)||_C||b.disabled)return!1;removeClass(b,"hilite");b.caldate&&removeClass(b.parentNode,"rowhilite");if(b.calendar)b.calendar.tooltips.innerHTML=_TT.SEL_DATE;return stopEvent(a)}};
Calendar.cellClick=function(a,b){var c=a.calendar,d=!1,e=!1,g=null;if(typeof a.navtype=="undefined"){if(c.currentDateEl&&(Calendar.removeClass(c.currentDateEl,"selected"),Calendar.addClass(a,"selected"),d=c.currentDateEl==a,!d))c.currentDateEl=a;c.date.setDateOnly(a.caldate);var g=c.date,f=!(c.dateClicked=!a.otherMonth);!f&&!c.currentDateEl?c._toggleMultipleDate(new Date(g)):e=!a.disabled;f&&c._init(c.firstDayOfWeek,g);e&&b&&c.callHandler()}else{if(a.navtype==200){Calendar.removeClass(a,"hilite");
c.callCloseHandler();return}g=new Date(c.date);a.navtype==0&&g.setDateOnly(new Date);c.dateClicked=!1;var e=g.getFullYear(),f=g.getMonth(),k=function(a){var b=g.getDate(),c=g.getMonthDays(a);b>c&&g.setDate(c);g.setMonth(a)};switch(a.navtype){case 400:Calendar.removeClass(a,"hilite");d=Calendar._TT.ABOUT;typeof d!="undefined"?d+=c.showsTime?Calendar._TT.ABOUT_TIME:"":d='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 <mihai_bazon@yahoo.com> to get it into the distribution  ;-)\n\nThank you!\nhttp://dynarch.com/mishoo/calendar.epl\n';
alert(d);return;case -2:e>c.minYear&&g.setFullYear(e-1);break;case -1:f>0?k(f-1):e-- >c.minYear&&(g.setFullYear(e),k(11));break;case 1:f<11?k(f+1):e<c.maxYear&&(g.setFullYear(e+1),k(0));break;case 2:e<c.maxYear&&g.setFullYear(e+1);break;case 100:c.setFirstDayOfWeek(a.fdow);return;case 50:d=a._range;e=a.innerHTML;for(f=d.length;--f>=0;)if(d[f]==e)break;b&&b.shiftKey?--f<0&&(f=d.length-1):++f>=d.length&&(f=0);a.innerHTML=d[f];c.onUpdateTime();return;case 0:if(typeof c.getDateStatus=="function"&&c.getDateStatus(g,
g.getFullYear(),g.getMonth(),g.getDate()))return!1}g.equalsTo(c.date)?a.navtype==0&&(e=d=!0):(c.setDate(g),e=!0)}d&&(Calendar.removeClass(a,"hilite"),b&&c.callCloseHandler())};Calendar.hh=function(a,b,c,d,e){cell=Calendar.createElement("td",b);cell.colSpan=d;cell.className="button";e!=0&&Math.abs(e)<=2&&(cell.className+=" nav");Calendar._add_evs(cell);cell.calendar=a;cell.navtype=e;cell.innerHTML="<div unselectable='on'>"+c+"</div>";return cell};
Calendar.prototype.create=function(a){var b=null;a?(b=a,this.isPopup=!1):(b=document.getElementsByTagName("body")[0],this.isPopup=!0);this.date=this.dateStr?new Date(this.dateStr):new Date;this.table=a=Calendar.createElement("table");a.cellSpacing=0;a.cellPadding=0;a.calendar=this;Calendar.addEvent(a,"mousedown",Calendar.tableMouseDown);var c=Calendar.createElement("div");this.element=c;c.className="calendar";if(this.isPopup)c.style.position="absolute",c.style.display="none";c.appendChild(a);var d=
Calendar.createElement("thead",a),e=null,c=null,c=Calendar.createElement("tr",d),e=6;this.isPopup&&--e;this.weekNumbers&&++e;Calendar.hh(this,c,"?",1,400).ttip=Calendar._TT.INFO;this.title=Calendar.hh(this,c,"",e,300);this.title.className="title";if(this.isPopup)this.title.ttip=Calendar._TT.DRAG_TO_MOVE,this.title.style.cursor="move",Calendar.hh(this,c,"&#x00d7;",1,200).ttip=Calendar._TT.CLOSE;c=Calendar.createElement("tr",d);c.className="headrow";this._nav_py=Calendar.hh(this,c,"&#x00ab;",1,-2);
this._nav_py.ttip=Calendar._TT.PREV_YEAR;this._nav_pm=Calendar.hh(this,c,"&#x2039;",1,-1);this._nav_pm.ttip=Calendar._TT.PREV_MONTH;this._nav_now=Calendar.hh(this,c,Calendar._TT.TODAY,this.weekNumbers?4:3,0);this._nav_now.ttip=Calendar._TT.GO_TODAY;this._nav_nm=Calendar.hh(this,c,"&#x203a;",1,1);this._nav_nm.ttip=Calendar._TT.NEXT_MONTH;this._nav_ny=Calendar.hh(this,c,"&#x00bb;",1,2);this._nav_ny.ttip=Calendar._TT.NEXT_YEAR;c=Calendar.createElement("tr",d);c.className="daynames";if(this.weekNumbers)e=
Calendar.createElement("td",c),e.className="name wn",e.innerHTML=Calendar._TT.WK;for(d=7;d>0;--d)if(e=Calendar.createElement("td",c),!d)e.navtype=100,e.calendar=this,Calendar._add_evs(e);this.firstdayname=this.weekNumbers?c.firstChild.nextSibling:c.firstChild;this._displayWeekdays();var g=Calendar.createElement("tbody",a);this.tbody=g;for(d=6;d>0;--d){c=Calendar.createElement("tr",g);this.weekNumbers&&Calendar.createElement("td",c);for(var f=7;f>0;--f)e=Calendar.createElement("td",c),e.calendar=this,
Calendar._add_evs(e)}a=Calendar.createElement("tfoot",a);c=Calendar.createElement("tr",a);c.className="footrow";e=Calendar.hh(this,c,Calendar._TT.SEL_DATE,this.weekNumbers?8:7,300);e.className="ttip";if(this.isPopup)e.ttip=Calendar._TT.DRAG_TO_MOVE,e.style.cursor="move";this.tooltips=e;this.monthsCombo=c=Calendar.createElement("div",this.element);c.className="combo";for(d=0;d<Calendar._MN.length;++d)a=Calendar.createElement("div"),a.className=Calendar.is_ie?"label-IEfix":"label",a.month=d,a.innerHTML=
Calendar._SMN[d],c.appendChild(a);this.yearsCombo=c=Calendar.createElement("div",this.element);c.className="combo";for(d=12;d>0;--d)a=Calendar.createElement("div"),a.className=Calendar.is_ie?"label-IEfix":"label",c.appendChild(a);this._init(this.firstDayOfWeek,this.date);b.appendChild(this.element)};
Calendar._keyEvent=function(a){var b=window._dynarch_popupCalendar;if(!b||b.multiple)return!1;Calendar.is_ie&&(a=window.event);var c=Calendar.is_ie||a.type=="keypress",d=a.keyCode;if(a.ctrlKey)switch(d){case 37:c&&Calendar.cellClick(b._nav_pm);break;case 38:c&&Calendar.cellClick(b._nav_py);break;case 39:c&&Calendar.cellClick(b._nav_nm);break;case 40:c&&Calendar.cellClick(b._nav_ny);break;default:return!1}else switch(d){case 32:Calendar.cellClick(b._nav_now);break;case 27:c&&b.callCloseHandler();break;
case 37:case 38:case 39:case 40:if(c){var e,g,f,k,h,c=d==37||d==38;h=d==37||d==39?1:7;var i=function(){k=b.currentDateEl;var a=k.pos;e=a&15;g=a>>4;f=b.ar_days[g][e]};i();for(var l=function(){var a=new Date(b.date);a.setDate(a.getDate()-h);b.setDate(a)},m=function(){var a=new Date(b.date);a.setDate(a.getDate()+h);b.setDate(a)};;){switch(d){case 37:if(--e>=0)f=b.ar_days[g][e];else{e=6;d=38;continue}break;case 38:--g>=0?f=b.ar_days[g][e]:(l(),i());break;case 39:if(++e<7)f=b.ar_days[g][e];else{e=0;d=
40;continue}break;case 40:++g<b.ar_days.length?f=b.ar_days[g][e]:(m(),i())}break}f&&(f.disabled?c?l():m():Calendar.cellClick(f))}break;case 13:c&&Calendar.cellClick(b.currentDateEl,a);break;default:return!1}return Calendar.stopEvent(a)};
Calendar.prototype._init=function(a,b){var c=new Date,d=c.getFullYear(),e=c.getMonth(),c=c.getDate();this.table.style.visibility="hidden";var g=b.getFullYear();if(g<this.minYear)g=this.minYear,b.setFullYear(g);else if(g>this.maxYear)g=this.maxYear,b.setFullYear(g);this.firstDayOfWeek=a;this.date=new Date(b);var f=b.getMonth(),k=b.getDate();b.getMonthDays();b.setDate(1);var h=(b.getDay()-this.firstDayOfWeek)%7;h<0&&(h+=7);b.setDate(-h);b.setDate(b.getDate()+1);for(var h=this.tbody.firstChild,i=this.ar_days=
[],l=Calendar._TT.WEEKEND,m=this.multiple?this.datesCells={}:null,n=0;n<6;++n,h=h.nextSibling){var j=h.firstChild;if(this.weekNumbers)j.className="day wn",j.innerHTML=b.getWeekNumber(),j=j.nextSibling;h.className="daysrow";for(var r=!1,o,u=i[n]=[],p=0;p<7;++p,j=j.nextSibling,b.setDate(o+1)){o=b.getDate();var v=b.getDay();j.className="day";j.pos=n<<4|p;u[p]=j;var s=b.getMonth()==f;if(s)j.otherMonth=!1,r=!0;else if(this.showsOtherMonths)j.className+=" othermonth",j.otherMonth=!0;else{j.className="emptycell";
j.innerHTML="&nbsp;";j.disabled=!0;continue}j.disabled=!1;j.innerHTML=this.getDateText?this.getDateText(b,o):o;m&&(m[b.print("%Y%m%d")]=j);if(this.getDateStatus){var q=this.getDateStatus(b,g,f,o);if(this.getDateToolTip){var t=this.getDateToolTip(b,g,f,o);if(t)j.title=t}if(q===!0)j.className+=" disabled",j.disabled=!0;else{if(/disabled/i.test(q))j.disabled=!0;j.className+=" "+q}}if(!j.disabled){j.caldate=new Date(b);j.ttip="_";if(!this.multiple&&s&&o==k&&this.hiliteToday)j.className+=" selected",this.currentDateEl=
j;b.getFullYear()==d&&b.getMonth()==e&&o==c&&(j.className+=" today",j.ttip+=Calendar._TT.PART_TODAY);l.indexOf(v.toString())!=-1&&(j.className+=j.otherMonth?" oweekend":" weekend")}}if(!r&&!this.showsOtherMonths)h.className="emptyrow"}this.title.innerHTML=Calendar._MN[f]+", "+g;this.table.style.visibility="visible";this._initMultipleDates()};Calendar.prototype._initMultipleDates=function(){if(this.multiple)for(var a in this.multiple){var b=this.datesCells[a];this.multiple[a]&&b&&(b.className+=" selected")}};
Calendar.prototype._toggleMultipleDate=function(a){if(this.multiple){var b=a.print("%Y%m%d"),c=this.datesCells[b];c&&(this.multiple[b]?(Calendar.removeClass(c,"selected"),delete this.multiple[b]):(Calendar.addClass(c,"selected"),this.multiple[b]=a))}};Calendar.prototype.setDateToolTipHandler=function(a){this.getDateToolTip=a};Calendar.prototype.setDate=function(a){a.equalsTo(this.date)||this._init(this.firstDayOfWeek,a)};Calendar.prototype.refresh=function(){this._init(this.firstDayOfWeek,this.date)};
Calendar.prototype.setFirstDayOfWeek=function(a){this._init(a,this.date);this._displayWeekdays()};Calendar.prototype.setDateStatusHandler=Calendar.prototype.setDisabledHandler=function(a){this.getDateStatus=a};Calendar.prototype.setRange=function(a,b){this.minYear=a;this.maxYear=b};Calendar.prototype.callHandler=function(){if(this.onSelected)this.onSelected(this,this.date.print(this.dateFormat))};Calendar.prototype.callCloseHandler=function(){if(this.onClose)this.onClose(this);this.hideShowCovered()};
Calendar.prototype.destroy=function(){$(this.element).empty();this.element.parentNode.removeChild(this.element);this.params=this.activeYear=this.hilitedYear=this.activeMonth=this.hilitedMonth=this.yearsCombo=this.monthsCombo=this.tooltips=this._nav_ny=this._nav_nm=this._nav_now=this._nav_pm=this._nav_py=this.title=this.firstdayname=this.tbody=this.element=this.table=this.multiple=this.ar_days=this.ttDateFormat=this.dateFormat=this.onClose=this.onSelected=this.timeout=this.getDateText=this.getDateToolTip=
this.getDateStatus=this.currentDateEl=this.activeDiv=null};Calendar.prototype.reparent=function(a){var b=this.element;b.parentNode.removeChild(b);a.appendChild(b)};Calendar._checkCalendar=function(a){var b=window._dynarch_popupCalendar;if(!b)return!1;for(var c=Calendar.is_ie?Calendar.getElement(a):Calendar.getTargetElement(a);c!=null&&c!=b.element;c=c.parentNode);if(c==null)return window._dynarch_popupCalendar.callCloseHandler(),Calendar.stopEvent(a)};
Calendar.prototype.show=function(){for(var a=this.table.getElementsByTagName("tr"),b=a.length;b>0;){var c=a[--b];Calendar.removeClass(c,"rowhilite");for(var c=c.getElementsByTagName("td"),d=c.length;d>0;){var e=c[--d];Calendar.removeClass(e,"hilite");Calendar.removeClass(e,"active")}}this.element.style.display="block";this.hidden=!1;if(this.isPopup)window._dynarch_popupCalendar=this,Calendar.addEvent(document,"keydown",Calendar._keyEvent),Calendar.addEvent(document,"keypress",Calendar._keyEvent),
Calendar.addEvent(document,"mousedown",Calendar._checkCalendar);this.hideShowCovered()};Calendar.prototype.hide=function(){this.isPopup&&(Calendar.removeEvent(document,"keydown",Calendar._keyEvent),Calendar.removeEvent(document,"keypress",Calendar._keyEvent),Calendar.removeEvent(document,"mousedown",Calendar._checkCalendar));this.element.style.display="none";this.hidden=!0;this.hideShowCovered()};
Calendar.prototype.showAt=function(a,b){this.element.style.display="block";this.element.style.visiblity="hidden";var c=YAHOO.util.Dom.getXY(this.element);c[0]=a;c[1]=b;var d=RQ.util.docScrollLeft(),e=RQ.util.docScrollTop(),g=c[0]+this.element.offsetWidth+5,f=c[1]+this.element.offsetHeight+5,d=YAHOO.util.Dom.getClientWidth()+d-12,e=YAHOO.util.Dom.getClientHeight()+e;g>d&&(c[0]=d-this.element.offsetWidth-5);f>e&&(c[1]=e-this.element.offsetHeight-5);YAHOO.util.Dom.setXY(this.element,c);this.show()};
Calendar.prototype.showAtElement=function(a,b){var c=Calendar.getAbsolutePos(a);if(!b||typeof b!="string")return this.showAt(c.x,c.y+a.offsetHeight),!0;var d=YAHOO.util.Dom.getXY(a);c.x=d[0];c.y=d[1];var d=this.element.offsetWidth,e=this.element.offsetHeight;this.element.style.display="none";var g=b.substr(0,1),f="l";b.length>1&&(f=b.substr(1,1));switch(g){case "T":c.y-=e;break;case "B":c.y+=a.offsetHeight;break;case "C":c.y+=(a.offsetHeight-e)/2;break;case "t":c.y+=a.offsetHeight-e}switch(f){case "L":c.x-=
d;break;case "R":c.x+=a.offsetWidth;break;case "C":c.x+=(a.offsetWidth-d)/2;break;case "l":c.x+=a.offsetWidth-d}c.width=d;c.height=e+40;this.monthsCombo.style.display="none";(function(a){if(a.x<0)a.x=0;if(a.y<0)a.y=0})(c);this.showAt(c.x,c.y)};Calendar.prototype.setDateFormat=function(a){this.dateFormat=a};Calendar.prototype.setTtDateFormat=function(a){this.ttDateFormat=a};Calendar.prototype.parseDate=function(a,b){if(!b)b=this.dateFormat;this.setDate(Date.parseDate(a,b))};
Calendar.prototype.hideShowCovered=function(){function a(a){var b=a.style.visibility;b||(b=document.defaultView&&typeof document.defaultView.getComputedStyle=="function"?Calendar.is_khtml?"":document.defaultView.getComputedStyle(a,"").getPropertyValue("visibility"):a.currentStyle?a.currentStyle.visibility:"");return b}if(Calendar.is_ie||Calendar.is_opera)for(var b=["applet","iframe","select"],c=this.element,d=Calendar.getAbsolutePos(c),e=d.x,g=c.offsetWidth+e,f=d.y,c=c.offsetHeight+f,k=b.length;k>
0;)for(var h=document.getElementsByTagName(b[--k]),i=null,l=h.length;l>0;){var i=h[--l],d=Calendar.getAbsolutePos(i),m=d.x,n=i.offsetWidth+m,d=d.y,j=i.offsetHeight+d;if(this.hidden||m>g||n<e||d>c||j<f){if(!i.__msh_save_visibility)i.__msh_save_visibility=a(i);i.style.visibility=i.__msh_save_visibility}else{if(!i.__msh_save_visibility)i.__msh_save_visibility=a(i);i.style.visibility="hidden"}}};
Calendar.prototype._displayWeekdays=function(){for(var a=this.firstDayOfWeek,b=this.firstdayname,c=Calendar._TT.WEEKEND,d=0;d<7;++d){b.className="day name";var e=(d+a)%7;if(d)b.ttip=Calendar._TT.DAY_FIRST.replace("%s",Calendar._DN[e]),b.navtype=100,b.calendar=this,b.fdow=e,Calendar._add_evs(b);c.indexOf(e.toString())!=-1&&Calendar.addClass(b,"weekend");b.innerHTML=Calendar._SDN[(d+a)%7];b=b.nextSibling}};
Calendar.prototype._hideCombos=function(){this.monthsCombo.style.display="none";this.yearsCombo.style.display="none"};Calendar.prototype._dragStart=function(a){if(!this.dragging){this.dragging=!0;var b;Calendar.is_ie?(b=window.event.clientY+document.body.scrollTop,a=window.event.clientX+document.body.scrollLeft):(b=a.clientY+window.scrollY,a=a.clientX+window.scrollX);var c=this.element.style;this.xOffs=a-parseInt(c.left);this.yOffs=b-parseInt(c.top);with(Calendar);}};
Date._MD=[31,28,31,30,31,30,31,31,30,31,30,31];Date.SECOND=1E3;Date.MINUTE=60*Date.SECOND;Date.HOUR=60*Date.MINUTE;Date.DAY=24*Date.HOUR;Date.WEEK=7*Date.DAY;
Date.parseDate=function(a,b){for(var c=new Date,d=0,e=-1,g=0,f=a.split(/\W+/),k=b.match(/%./g),h=0,i=0,l=0,m=0,h=0;h<f.length;++h)if(f[h])switch(k[h]){case "%d":case "%e":g=parseInt(f[h],10);break;case "%m":e=parseInt(f[h],10)-1;break;case "%Y":case "%y":d=parseInt(f[h],10);d<100&&(d+=d>29?1900:2E3);break;case "%b":case "%B":for(i=0;i<12;++i)if(Calendar._MN[i].substr(0,f[h].length).toLowerCase()==f[h].toLowerCase()){e=i;break}break;case "%H":case "%I":case "%k":case "%l":l=parseInt(f[h],10);break;
case "%P":case "%p":/pm/i.test(f[h])&&l<12?l+=12:/am/i.test(f[h])&&l>=12&&(l-=12);break;case "%M":m=parseInt(f[h],10)}isNaN(d)&&(d=c.getFullYear());isNaN(e)&&(e=c.getMonth());isNaN(g)&&(g=c.getDate());isNaN(l)&&(l=c.getHours());isNaN(m)&&(m=c.getMinutes());if(d!=0&&e!=-1&&g!=0)return new Date(d,e,g,l,m,0);d=0;e=-1;for(h=g=0;h<f.length;++h)if(f[h].search(/[a-zA-Z]+/)!=-1){k=-1;for(i=0;i<12;++i)if(Calendar._MN[i].substr(0,f[h].length).toLowerCase()==f[h].toLowerCase()){k=i;break}k!=-1&&(e!=-1&&(g=e+
1),e=k)}else parseInt(f[h],10)<=12&&e==-1?e=f[h]-1:parseInt(f[h],10)>31&&d==0?(d=parseInt(f[h],10),d<100&&(d+=d>29?1900:2E3)):g==0&&(g=f[h]);d==0&&(d=c.getFullYear());return e!=-1&&g!=0?new Date(d,e,g,l,m,0):c};Date.prototype.getMonthDays=function(a){var b=this.getFullYear();typeof a=="undefined"&&(a=this.getMonth());return 0==b%4&&(0!=b%100||0==b%400)&&a==1?29:Date._MD[a]};
Date.prototype.getDayOfYear=function(){var a=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=new Date(this.getFullYear(),0,0,0,0,0);return Math.floor((a-b)/Date.DAY)};Date.prototype.getWeekNumber=function(){var a=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=a.getDay();a.setDate(a.getDate()-(b+6)%7+3);b=a.valueOf();a.setMonth(0);a.setDate(4);return Math.round((b-a.valueOf())/6048E5)+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.setDateOnly=function(a){a=new Date(a);this.setDate(1);this.setFullYear(a.getFullYear());this.setMonth(a.getMonth());this.setDate(a.getDate())};
Date.prototype.print=function(a){var b=this.getMonth(),c=this.getDate(),d=this.getFullYear(),e=this.getWeekNumber(),g=this.getDay(),f={},k=this.getHours(),h=k>=12,i=h?k-12:k,l=this.getDayOfYear();i==0&&(i=12);var m=this.getMinutes(),n=this.getSeconds();f["%a"]=Calendar._SDN[g];f["%A"]=Calendar._DN[g];f["%b"]=Calendar._SMN[b];f["%B"]=Calendar._MN[b];f["%C"]=1+Math.floor(d/100);f["%d"]=c<10?"0"+c:c;f["%e"]=c;f["%H"]=k<10?"0"+k:k;f["%I"]=i<10?"0"+i:i;f["%j"]=l<100?l<10?"00"+l:"0"+l:l;f["%k"]=k;f["%l"]=
i;f["%m"]=b<9?"0"+(1+b):1+b;f["%M"]=m<10?"0"+m:m;f["%n"]="\n";f["%p"]=h?"PM":"AM";f["%P"]=h?"pm":"am";f["%s"]=Math.floor(this.getTime()/1E3);f["%S"]=n<10?"0"+n:n;f["%t"]="\t";f["%U"]=f["%W"]=f["%V"]=e<10?"0"+e:e;f["%u"]=g+1;f["%w"]=g;f["%y"]=(""+d).substr(2,2);f["%Y"]=d;f["%%"]="%";b=/%./g;if(!Calendar.is_ie5&&!Calendar.is_khtml)return a.replace(b,function(a){return f[a]||a});c=a.match(b);for(d=0;d<c.length;d++)if(e=f[c[d]])b=RegExp(c[d],"g"),a=a.replace(b,e);return a};
Date.prototype.__msh_oldSetFullYear=Date.prototype.setFullYear;Date.prototype.setFullYear=function(a){var b=new Date(this);b.__msh_oldSetFullYear(a);b.getMonth()!=this.getMonth()&&this.setDate(28);this.__msh_oldSetFullYear(a)};window._dynarch_popupCalendar=null;Calendar._DN="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday".split(",");Calendar._SDN="Sun,Mon,Tue,Wed,Thu,Fri,Sat,Sun".split(",");Calendar._FD=0;Calendar._MN="January,February,March,April,May,June,July,August,September,October,November,December".split(",");
Calendar._SMN="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(",");Calendar._TT={};Calendar._TT.INFO="About the calendar";
Calendar._TT.ABOUT="DHTML Date/Time Selector\n(c) dynarch.com 2002-2005 / Author: Mihai Bazon\nFor latest version visit: http://www.dynarch.com/projects/calendar/\nDistributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details.\n\nDate selection:\n- Use the \u00ab, \u00bb buttons to select year\n- Use the "+String.fromCharCode(8249)+", "+String.fromCharCode(8250)+" buttons to select month\n- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT.ABOUT_TIME="\n\nTime selection:\n- Click on any of the time parts to increase it\n- or Shift-click to decrease it\n- or click and drag for faster selection.";Calendar._TT.PREV_YEAR="Prev. year (hold for menu)";Calendar._TT.PREV_MONTH="Prev. month (hold for menu)";Calendar._TT.GO_TODAY="Go Today";Calendar._TT.NEXT_MONTH="Next month (hold for menu)";Calendar._TT.NEXT_YEAR="Next year (hold for menu)";Calendar._TT.SEL_DATE="Select date";Calendar._TT.DRAG_TO_MOVE="Drag to move";
Calendar._TT.PART_TODAY=" (today)";Calendar._TT.DAY_FIRST="Display %s first";Calendar._TT.WEEKEND="0,6";Calendar._TT.CLOSE="Close";Calendar._TT.TODAY="Today";Calendar._TT.TIME_PART="(Shift-)Click or drag to change value";Calendar._TT.DEF_DATE_FORMAT="%Y-%m-%d";Calendar._TT.TT_DATE_FORMAT="%a, %b %e";Calendar._TT.WK="wk";Calendar._TT.TIME="Time:";
Calendar.setup=function(a){function b(b,c){typeof a[b]=="undefined"&&(a[b]=c)}b("inputField",null);b("displayArea",null);b("button",null);b("eventName","click");b("ifFormat","%Y/%m/%d");b("daFormat","%Y/%m/%d");b("singleClick",!0);b("disableFunc",null);b("dateStatusFunc",a.disableFunc);b("dateText",null);b("firstDay",null);b("align","Br");b("range",[1900,2999]);b("weekNumbers",!0);b("flat",null);b("flatCallback",null);b("onSelect",null);b("onClose",null);b("onUpdate",null);b("date",null);b("showsTime",
!1);b("timeFormat","24");b("electric",!0);b("step",2);b("position",null);b("cache",!1);b("showOthers",!1);b("multiple",null);var c=["inputField","displayArea","button"],d;for(d in c)typeof a[c[d]]=="string"&&(a[c[d]]=document.getElementById(a[c[d]]));if(!a.flat&&!a.multiple&&!a.inputField&&!a.displayArea&&!a.button)return alert("Calendar.setup:\n  Nothing to setup (no fields found).  Please check your code"),!1;if(a.flat!=null){if(typeof a.flat=="string")a.flat=document.getElementById(a.flat);if(!a.flat)return alert("Calendar.setup:\n  Flat specified but can't find parent."),
!1;var e=new Calendar(a.firstDay,a.date,a.onSelect||Calendar.onSelect);e.showsOtherMonths=a.showOthers;e.showsTime=a.showsTime;e.time24=a.timeFormat=="24";e.params=a;e.weekNumbers=a.weekNumbers;e.setRange(a.range[0],a.range[1]);e.setDateStatusHandler(a.dateStatusFunc);e.getDateText=a.dateText;a.ifFormat&&e.setDateFormat(a.ifFormat);a.inputField&&typeof a.inputField.value=="string"&&e.parseDate(a.inputField.value);e.create(a.flat);e.show();return!1}c=a.button||a.displayArea||a.inputField;$(c).unbind(a.eventName);
$(c).bind(a.eventName,Calendar.onTrigger);return e};Calendar.onSelect=function(a){var b=a.params,c=a.dateClicked||b.electric;if(c&&b.inputField&&(b.inputField.value=a.date.print(b.ifFormat),typeof b.inputField.onchange=="function"))b.inputField.onchange();if(c&&b.displayArea)b.displayArea.innerHTML=a.date.print(b.daFormat);if(c&&typeof b.onUpdate=="function")b.onUpdate(a);c&&b.flat&&typeof b.flatCallback=="function"&&b.flatCallback(a);c&&b.singleClick&&a.dateClicked&&a.callCloseHandler()};
Calendar.onTrigger=function(){var a=this.id.substring(7),a=$("#"+a).data("params"),b=a.inputField||a.displayArea,c=a.inputField?a.ifFormat:a.daFormat,d=!1,e=window.calendar;if(b)a.date=Date.parseDate(b.value||b.innerHTML,c);!e||!a.cache?(window.calendar=e=new Calendar(a.firstDay,a.date,a.onSelect||Calendar.onSelect,a.onClose||function(a){a.hide()}),e.showsTime=a.showsTime,e.time24=a.timeFormat=="24",e.weekNumbers=a.weekNumbers,d=!0):(a.date&&e.setDate(a.date),e.hide());if(a.multiple){e.multiple={};
for(b=a.multiple.length;--b>=0;){var g=a.multiple[b],f=g.print("%Y%m%d");e.multiple[f]=g}}e.showsOtherMonths=a.showOthers;e.yearStep=a.step;e.setRange(a.range[0],a.range[1]);e.params=a;e.setDateStatusHandler(a.dateStatusFunc);e.getDateText=a.dateText;e.setDateFormat(c);d&&e.create();e.refresh();a.position?e.showAt(a.position[0],a.position[1]):e.showAtElement(a.button||a.displayArea||a.inputField,a.align);return!1};
(function(a){a.fn.rqcalendar=function(b){typeof b=="object"&&(b=null);if(b=="destroy"){b=this.attr("id");window._dynarch_popupCalendar?(a(window._dynarch_popupCalendar.element).empty(),window._dynarch_popupCalendar.destroy()):window.calendar&&(a(window.calendar.element).empty(),window.calendar.destroy());b=document.getElementById("button_"+b);a(b).unbind();this.unbind();Calendar._C=null;window._dynarch_popupCalendar=null;window.calendar=null;if(b=this.data("params"))b.inputField=null,b.displayArea=
null,b.button=null;return this.removeData("params")}b=this.attr("id");b={inputField:b,ifFormat:rqCalFormat,button:"button_"+b,singleClick:!0,firstDay:rqCalFirstDay,step:1};this.data("params",b);Calendar.setup(b);return this}})(jQuery);
