function zwCalendar(uid){this.id=0;this.uid=uid;this.months=1;this.updating=false;this.ajax=null;this.ajaxUrl="";this.cellIndex=[];this.cellEvents=[];this.firstTime=true;this.selMode=0;this.noServerUpdate=false;this.selDate=false;this.selCell=false;this.selFrom=false;this.selTo=false;this.selCellFrom=false;this.selCellTo=false;this.allowFromDate=false;this.allowToDate=false;this.errBox=document.getElementById(this.uid+"_errorbox");this.errDet=document.getElementById(this.uid+"_errordet");this.showMonth=0;this.showYear=0;this.selectionChanged=false;this.refresh=function(){var s;if(this.noServerUpdate){return}if(this.updating&&this.ajax){try{this.ajax.req.abort()}catch(e){}}s=this;this.updating=true;this.ajax=new zw.Ajax(this.ajaxUrl+"&cmscalid="+this.id+"&cmsmonth="+this.showMonth+"&cmsyear="+this.showYear,function(){s.ajaxUpdate(arguments[0])});this.ajax.call()};this.initialize=function(){this.update();this.refresh()};this.showError=function(e){this.errDet.innerHTML=e;this.errBox.style.display="block"};this.hideError=function(){this.errBox.style.display="none"};this.ajaxUpdate=function(q){var g,jo,d,i,j,k,c,o,fnc;var eovr,eout,eclk,emdn,emup,ebbc;g=this;try{eval("jo=("+q.responseText+")")}catch(e){alert(e.description)}if(!jo){return}this.hideError();if(jo.error.length>0){this.showError(jo.error)}for(i=0;i<this.cellEvents.length;i++){var o=this.cellEvents[i];zw.removeEventHandler(o.obj,o.evt,o.fun)}for(k=0;k<this.months;k++){for(i=0;i<6;i++){for(j=0;j<7;j++){c=document.getElementById("_cal_"+this.id+"_"+k+"_"+i+"_"+j);c.className=c.zwDate.className;c.zwDate.tag=false}}}this.cellEvents=[];d=jo.data;for(i=0;i<d.length;i++){o=d[i];c=this.cellIndex[o.caldate];if(c){c.zwDate.tag=o;if(o.cellclass&&o.cellclass.length>0){c.className+=" "+o.cellclass;c.zwDate.className=c.className}if(o.mouseover){eovr=eval(o.mouseover);if(eovr){eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) eovr.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"onmouseover",fnc)}}if(o.mouseout){eout=eval(o.mouseout);if(eout){eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) eout.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"onmouseout",fnc)}}if(o.mouseup){emup=eval(o.mouseup);if(emup){eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) emup.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"onmouseup",fnc)}}if(o.mousedown){emdn=eval(o.mousedown);if(emdn){eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) emdn.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"onmousedown",fnc)}}if(o.click){eclk=eval(o.click);if(eclk){c.className+=" cmscalclickcell";eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) eclk.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"onclick",fnc)}}if(o.dblclick){ebbc=eval(o.dblclick);if(ebbc){eval("fnc=function (){ var c; c=g.cellIndex["+o.caldate+"]; if(c.zwDate.inRange) ebbc.call(g, g, c.zwDate.tag, c.zwDate, arguments[0]); }");this.addCellEventHandler(c,"ondblclick",fnc)}}}}};this.addCellEventHandler=function(o,s,e){this.cellEvents.push({obj:o,evt:s,fun:e});zw.addEventHandler(o,s,e)};this.nextMonth=function(){this.showMonth++;if(this.showMonth>=12){this.showYear++;this.showMonth=1}this.update();this.refresh()};this.prevMonth=function(){this.showMonth--;if(this.showMonth<1){this.showYear--;this.showMonth=12}this.update();this.refresh()};this.cellOver=function(t){};this.cellOut=function(t){};this.getCellByDate=function(y,m,d){var t,i,r=false;m=m.toString();d=d.toString();if(m.length<2){m="0"+m}if(d.length<2){d="0"+d}t=y+m+d;r=this.cellIndex[t];return r};this.cellClick=function(t){var s=this;switch(this.selMode){case 1:if(t.zwDate.inRange){if(this.selCell){this.selCell.className=this.selCell.sourceClass}t.className+=" cmscalsel";this.selCell=t;this.selDate=t.zwDate;if(this.selectionChanged){this.selectionChanged.call(s,this.selDate)}}break;case 2:if(t.zwDate.inRange){if(!this.selCellFrom||(this.selCellFrom&&this.selCellTo)){this.selCellFrom=t;this.selFrom=t.zwDate;if(this.selCellTo){this.selTo=false;this.selCellTo=false}if(this.selectionChanged){this.selectionChanged.call(s,this.selFrom,this.selTo)}this.updateSelection()}else{if(this.selFrom>t.zwDate){this.selCellTo=this.selCellFrom;this.selTo=this.selFrom;this.selCellFrom=t;this.selFrom=t.zwDate}else{this.selCellTo=t;this.selTo=t.zwDate}this.updateSelection();if(this.selectionChanged){this.selectionChanged.call(s,this.selFrom,this.selTo)}}}break;case 0:default:break}};this.updateSelection=function(){for(k=0;k<this.months;k++){for(i=0;i<6;i++){for(j=0;j<7;j++){c=document.getElementById("_cal_"+this.id+"_"+k+"_"+i+"_"+j);if(this.selFrom&&this.selTo){if(c.zwDate>=this.selFrom&&c.zwDate<=this.selTo&&c.zwDate.inMonth){c.className+=" cmscalsel"}}else{if(this.selFrom==c.zwDate){c.className+=" cmscalsel"}else{c.className=c.zwDate.className}}}}}};this.update=function(){var i,j,c,t,f,m,l,k,d,s,h;this.cellIndex=[];for(k=0;k<this.months;k++){t=new Date(this.showYear,this.showMonth-1+k,1);f=t.getDay();s=t.getMonth();switch(s){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}h=document.getElementById("_cal_"+this.id+"_"+k+"_month");h.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("_cal_"+this.id+"_"+k+"_"+i+"_"+j);c.zwDate=new Date(t.getFullYear(),t.getMonth(),t.getDate());c.innerHTML=t.getDate();c.zwDate.inRange=true;if(this.firstTime){l=c.className;c.sourceClass=l}else{l=c.sourceClass}if(this.allowFromDate&&t<=this.allowFromDate){l+=" cmscaloutrange";c.zwDate.inRange=false}if(this.allowToDate&&t>=this.allowToDate){l+=" cmscaloutrange";c.zwDate.inRange=false}if(t.getMonth()!=s){l+=" cmscaldis";c.zwDate.inMonth=false}else{d=t.getFullYear().toString()+(t.getMonth()+1<10?"0":"")+(t.getMonth()+1).toString()+(t.getDate()<10?"0":"")+t.getDate().toString();this.cellIndex[d]=c;c.zwDate.inMonth=true}c.zwDate.className=l;c.zwDate.objectDOM=c;c.className=l;t.setDate(t.getDate()+1)}}}this.firstTime=false}};
