function zwCalendarDrop(id,d,b,t,c){this.id=id;this.showYears=b;this.control=document.getElementById(id);this.container=document.getElementById(id+"_cnt");this.inputType=t;this.weekDay=false;this.daySelector=false;this.monthSelector=false;this.comboDrop=false;this.disabled=d;this.callBack=c;this.shown=false;this.centuryDif=10;this.mode=0;this.emptyMode=0;this.date=new Date();if(this.inputType==1||this.inputType==2){this.weekDay=document.getElementById(id+"_wday");this.daySelector=document.getElementById(id+"_day");this.monthSelector=document.getElementById(id+"_month");this.yearSelector=document.getElementById(id+"_year");this.comboDrop=document.getElementById(id+"_combo")}this.container.zwCalendar=this;this.control.zwCalendar=this;this.getObjects=function(){this.dropObj=document.getElementById("_zwcalendareditor");this.detailMonth=document.getElementById("_zwcalendarmonthdetail");this.detailYear=document.getElementById("_zwcalendaryeardetail");this.detailDecade=document.getElementById("_zwcalendardecadedetail");this.detailCentury=document.getElementById("_zwcalendarcenturydetail");this.viewCalendar=document.getElementById("_zwcalendarviewcalendar");this.viewMonths=document.getElementById("_zwcalendarviewmonths");this.viewYears=document.getElementById("_zwcalendarviewyears");this.viewDecades=document.getElementById("_zwcalendarviewdecades")};this.show=function(){var oDrop;var difX=0,difY=0;var oRp,oRo;var oP,m,_self=this;oP=this.container;if(oP){m=(zw.forms.isDate(this.control.value)?0:this.emptyMode);this.getObjects();this.initDate();this.setMode(m);this.update();this.shown=true;zw.context.show(this.dropObj,oP,difX,difY,function(){_self.hideCallBack()})}};this.keyEventHandler=function(e){var c=(e.keyCode?e.keyCode:e.charCode),r=true;if(this.shown){if(c==46||c==8){this.clear();r=false;zw.stopEventPropagation(arguments[0])}}return r};this.hideCallBack=function(){this.shown=false};this.hide=function(){this.shown=false;zw.context.hide()};this.clear=function(){this.control.value="";this.initDate();this.setMode(this.emptyMode);this.update();this.hide()};this.blur=function(){};this.next=function(e){switch(this.mode){case 1:this.nextYear();break;case 2:this.nextDecade();break;case 3:this.nextCentury();break;case 0:default:this.nextMonth();break}return zw.stopEventPropagation(e,true)};this.updateFields=function(){if(this.inputType==1||this.inputType==2){this.weekDay.innerHTML=this.getDayName(this.wd);this.daySelector.value=this.day;this.monthSelector.value=this.month+1;this.yearSelector.value=this.year}};this.prev=function(e){switch(this.mode){case 1:this.prevYear();break;case 2:this.prevDecade();break;case 3:this.prevCentury();break;case 0:default:this.prevMonth();break}return zw.stopEventPropagation(e,true)};this.update=function(){switch(this.mode){case 1:this.setMonths();break;case 2:this.setYears();break;case 3:this.setDecades();break;case 0:default:this.setCalendar();break}};this.nextCentury=function(){this.century+=100;this.update()};this.prevCentury=function(){this.century-=100;this.update()};this.nextDecade=function(){this.decade+=10;this.update()};this.prevDecade=function(){this.decade-=10;this.update()};this.nextYear=function(){this.date.setYear(this.date.getFullYear()+1);this.setDateParts();this.update()};this.prevYear=function(){this.date.setYear(this.date.getFullYear()-1);this.setDateParts();this.update()};this.nextMonth=function(){this.date.setMonth(this.date.getMonth()+1);this.setDateParts();this.update()};this.prevMonth=function(){this.date.setMonth(this.date.getMonth()-1);this.setDateParts();this.update()};this.initDate=function(){var p=this.control.value.split("/");if(p.length==3){d=new Date(p[2],p[1]-1,p[0])}else{d=new Date()}this.date=d;this.selDate=new Date(d.getFullYear(),d.getMonth(),d.getDate());this.setDateParts()};this.setDateParts=function(){this.wd=this.date.getDay();this.day=this.date.getDate();this.month=this.date.getMonth();this.year=this.date.getFullYear();this.decade=Math.floor(this.year/10)*10;this.century=Math.floor(this.year/100)*100};this.getDayName=function(i){switch(i){case 0:n=zw.jslng.sunday_abbr_med;break;case 1:n=zw.jslng.monday_abbr_med;break;case 2:n=zw.jslng.tuesday_abbr_med;break;case 3:n=zw.jslng.wednesday_abbr_med;break;case 4:n=zw.jslng.thursday_abbr_med;break;case 5:n=zw.jslng.friday_abbr_med;break;case 6:n=zw.jslng.saturday_abbr_med;break;default:n="";break}return n};this.setCalendar=function(){var i,j,c,t,f,m,l;t=new Date(this.year,this.month,1);f=t.getDay();switch(this.month){case 0:m=zw.jslng.january;break;case 1:m=zw.jslng.february;break;case 2:m=zw.jslng.march;break;case 3:m=zw.jslng.april;break;case 4:m=zw.jslng.may;break;case 5:m=zw.jslng.june;break;case 6:m=zw.jslng.july;break;case 7:m=zw.jslng.august;break;case 8:m=zw.jslng.september;break;case 9:m=zw.jslng.october;break;case 10:m=zw.jslng.november;break;case 11:m=zw.jslng.december;break;default:m="";break}this.detailMonth.innerHTML=m+" "+t.getFullYear();if(f<=1){f+=7}for(i=f;f>1;f--){t.setDate(t.getDate()-1)}for(i=0;i<6;i++){for(j=0;j<7;j++){c=document.getElementById("_calendar_d_"+i+"_"+j);c.zwDate=new Date(t.getFullYear(),t.getMonth(),t.getDate());c.innerHTML=t.getDate();l=c.className.replace(/ (cmscaldis|cmscalsel|cmscalovr)/g,"");if(t.getMonth()!=this.month){l+=" cmscaldis"}if(t.getDate()==this.selDate.getDate()&&t.getMonth()==this.selDate.getMonth()&&t.getFullYear()==this.selDate.getFullYear()){l+=" cmscalsel"}c.className=l;t.setDate(t.getDate()+1)}}};this.setMonths=function(){this.detailYear.innerHTML=this.year};this.setYears=function(){var i,j,d,s,c;s=this.decade-1;this.detailDecade.innerHTML=this.decade+"-"+(this.decade+9);for(i=0;i<3;i++){for(j=0;j<4;j++){c=document.getElementById("_calendar_dc_"+i+"_"+j);c.innerHTML=s;c.zwYear=s;s++}}};this.setDecades=function(){var i,j,d,s,c,n,w;n=new Date();s=this.century;if(s==Math.floor(n.getFullYear()/100)*100){s-=this.centuryDif;this.detailCentury.innerHTML=s+"-"+(s+119);w=false}else{s-=10;this.detailCentury.innerHTML=this.century+"-"+(this.century+99);w=true}for(i=0;i<3;i++){for(j=0;j<4;j++){c=document.getElementById("_calendar_cn_"+i+"_"+j);c.innerHTML=s+"-"+(s+9);c.zwDecade=s;l=c.className.replace(/ (cmscaldis|cmscalsel|cmscalovr)/g,"");if(w&&s<this.century||s>this.century+99){l+=" cmscaldis"}c.className=l;s+=10}}};this.setMode=function(m){this.mode=m;this.detailMonth.style.display=(this.mode==0?"block":"none");this.detailYear.style.display=(this.mode==1?"block":"none");this.detailDecade.style.display=(this.mode==2?"block":"none");this.detailCentury.style.display=(this.mode==3?"block":"none");this.viewCalendar.style.display=(this.mode==0?"block":"none");this.viewMonths.style.display=(this.mode==1?"block":"none");this.viewYears.style.display=(this.mode==2?"block":"none");this.viewDecades.style.display=(this.mode==3?"block":"none");this.update()};this.rotateMode=function(e){if(this.mode<3){this.setMode(++this.mode)}return zw.stopEventPropagation(e,true)};this.decadeMouseDown=function(e){e=(window.event?window.event:e);var o=(window.event?e.srcElement:e.target);var s=parseInt(o.zwDecade);if(!isNaN(s)){this.date.setYear(s);this.setDateParts();this.setMode(2)}return zw.stopEventPropagation(e,true)};this.yearMouseDown=function(e){e=(window.event?window.event:e);var o=(window.event?e.srcElement:e.target);var s=parseInt(o.zwYear);if(!isNaN(s)){this.date.setYear(s);this.setDateParts();this.setMode(1)}return zw.stopEventPropagation(e,true)};this.monthMouseDown=function(e){e=(window.event?window.event:e);var o=(window.event?e.srcElement:e.target);var s=o.id;s=parseInt(s.replace(/[^0-9]/g,""));if(!isNaN(s)){this.date.setMonth(s);this.setDateParts();this.setMode(0)}return zw.stopEventPropagation(e,true)};this.dayMouseDown=function(e){var o,t;e=(window.event?window.event:e);o=(window.event?e.srcElement:e.target);t=o.zwDate;if(t){this.setDate(t)}return zw.stopEventPropagation(e,true)};this.setDate=function(t){var d,m,y,e;d=new String(t.getDate());m=new String(t.getMonth()+1);y=new String(t.getFullYear());this.control.value=(d.length<2?"0":"")+d+"/"+(m.length<2?"0":"")+m+"/"+y;this.initDate();this.updateFields();zw.context.hide();if(this.callBack){e=false;eval("if(typeof "+this.callBack+"=='function') e="+this.callBack+";");if(e){e.call(this,this)}}};this.cellOver=function(e){var o,c;e=(window.event?window.event:e);o=(window.event?e.srcElement:e.target);while(o.tagName!="TD"&&o.tagName!="TABLE"){o=o.parentNode}if(o.tagName=="TD"){c=o.className.replace(/ cmscalovr/g,"");c+=" cmscalovr";o.className=c}};this.cellOut=function(e){var o,c;e=(window.event?window.event:e);o=(window.event?e.srcElement:e.target);while(o.tagName!="TD"&&o.tagName!="TABLE"){o=o.parentNode}if(o.tagName=="TD"){c=o.className.replace(/ cmscalovr/g,"");o.className=c}};this.selectorChanged=function(e){var t=new Date(this.yearSelector.value,this.monthSelector.value-1,this.daySelector.value);this.setDate(t)};var tO=this;switch(this.inputType){case 1:case 2:zw.addEventHandler(this.comboDrop,"onmousedown",function(){tO.show();return zw.stopEventPropagation(arguments[0])});zw.addEventHandler(this.daySelector,"onchange",function(){tO.selectorChanged();return zw.stopEventPropagation(arguments[0])});zw.addEventHandler(this.monthSelector,"onchange",function(){tO.selectorChanged();return zw.stopEventPropagation(arguments[0])});zw.addEventHandler(this.monthSelector,"onchange",function(){tO.selectorChanged();return zw.stopEventPropagation(arguments[0])});if(this.inputType==2){zw.addEventHandler(this.yearSelector,"onchange",function(){tO.selectorChanged();return zw.stopEventPropagation(arguments[0])})}break;case 0:default:zw.addEventHandler(this.container,"onmousedown",function(){tO.show();zw.stopEventPropagation(arguments[0]);return false});zw.addEventHandler(document,"onkeydown",function(){return tO.keyEventHandler(arguments[0])});break}this.initDate();this.updateFields();if(this.showYears){zw.forms.dateYears(this.control)}}function _zwCalendarNext(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.next(a)}}function _zwCalendarPrev(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.prev(a)}}function _zwCalendarRotateMode(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.rotateMode()}}function _zwCalendarDecadeMouseDown(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.decadeMouseDown(a)}}function _zwCalendarYearMouseDown(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.yearMouseDown(a)}}function _zwCalendarMonthMouseDown(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.monthMouseDown(a)}}function _zwCalendarDayMouseDown(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.dayMouseDown(a)}}function _zwCalendarCellOver(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.cellOver(a)}}function _zwCalendarCellOut(a){if(zw.context.object&&zw.context.object.id=="_zwcalendareditor"){zw.context.parent.zwCalendar.cellOut(a)}};
