/*

@license
dhtmlxScheduler.Net v.4.0.3 Professional Evaluation

This software is covered by DHTMLX Evaluation License. Contact sales@dhtmlx.com to get Commercial or Enterprise license. Usage without proper license is prohibited.

(c) XB Software Ltd.

*/
Scheduler.plugin(function(e){function t(){n=!1,e.callEvent("onAfterSchedulerResize",[]),n=!0}function a(){var e=document.createElement("div");e.style.cssText="visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t}e.config.container_autoresize=!0,e.config.month_day_min_height=90,e.config.min_grid_size=25,
e.config.min_map_size=400;var i=e._pre_render_events,n=!0,r=0,o=0;e._pre_render_events=function(t,a){if(!e.config.container_autoresize||!n)return i.apply(this,arguments);var s=this.xy.bar_height,d=this._colsS.heights,l=this._colsS.heights=[0,0,0,0,0,0,0],_=this._els.dhx_cal_data[0];if(t=this._table_view?this._pre_render_events_table(t,a):this._pre_render_events_line(t,a),this._table_view)if(a)this._colsS.heights=d;else{var h=_.firstChild;if(h.rows){for(var c=0;c<h.rows.length;c++){
if(++l[c]*s>this._colsS.height-this.xy.month_head_height){var u=h.rows[c].cells,v=this._colsS.height-this.xy.month_head_height;1*this.config.max_month_events!==this.config.max_month_events||l[c]<=this.config.max_month_events?v=l[c]*s:(this.config.max_month_events+1)*s>this._colsS.height-this.xy.month_head_height&&(v=(this.config.max_month_events+1)*s);for(var p=0;p<u.length;p++)u[p].childNodes[1].style.height=v+"px";l[c]=(l[c-1]||0)+u[0].offsetHeight}
l[c]=(l[c-1]||0)+h.rows[c].cells[0].offsetHeight}l.unshift(0),h.parentNode.offsetHeight<h.parentNode.scrollHeight&&h._h_fix}else if(t.length||"visible"!=this._els.dhx_multi_day[0].style.visibility||(l[0]=-1),t.length||-1==l[0]){var g=(h.parentNode.childNodes,(l[0]+1)*s+1);o!=g+1&&(this._obj.style.height=r-o+g-1+"px"),g+="px",_.style.top=this._els.dhx_cal_navline[0].offsetHeight+this._els.dhx_cal_header[0].offsetHeight+parseInt(g,10)+"px",
_.style.height=this._obj.offsetHeight-parseInt(_.style.top,10)-(this.xy.margin_top||0)+"px";var f=this._els.dhx_multi_day[0];f.style.height=g,f.style.visibility=-1==l[0]?"hidden":"visible",f=this._els.dhx_multi_day[1],f.style.height=g,f.style.visibility=-1==l[0]?"hidden":"visible",f.className=l[0]?"dhx_multi_day_icon":"dhx_multi_day_icon_small",this._dy_shift=(l[0]+1)*s,l[0]=0}}return t};var s=["dhx_cal_navline","dhx_cal_header","dhx_multi_day","dhx_cal_data"],d=function(t){r=0
;for(var i=0;i<s.length;i++){var n=s[i],d=e._els[n]?e._els[n][0]:null,l=0;switch(n){case"dhx_cal_navline":case"dhx_cal_header":l=parseInt(d.style.height,10);break;case"dhx_multi_day":l=d?d.offsetHeight-1:0,o=l;break;case"dhx_cal_data":var _=e.getState().mode;if(l=d.childNodes[1]&&"month"!=_?d.childNodes[1].offsetHeight:Math.max(d.offsetHeight-1,d.scrollHeight),"month"==_){if(e.config.month_day_min_height&&!t){l=d.getElementsByTagName("tr").length*e.config.month_day_min_height}
t&&(d.style.height=l+"px")}else if("year"==_)l=190*e.config.year_y;else if("agenda"==_){if(l=0,d.childNodes&&d.childNodes.length)for(var h=0;h<d.childNodes.length;h++)l+=d.childNodes[h].offsetHeight;l+2<e.config.min_grid_size?l=e.config.min_grid_size:l+=2}else if("week_agenda"==_){for(var c,u,v=e.xy.week_agenda_scale_height+e.config.min_grid_size,p=0;p<d.childNodes.length;p++){u=d.childNodes[p];for(var h=0;h<u.childNodes.length;h++){
for(var g=0,f=u.childNodes[h].childNodes[1],m=0;m<f.childNodes.length;m++)g+=f.childNodes[m].offsetHeight;c=g+e.xy.week_agenda_scale_height,c=1!=p||2!=h&&3!=h?c:2*c,c>v&&(v=c)}}l=3*v}else if("map"==_){l=0;for(var x=d.querySelectorAll(".dhx_map_line"),h=0;h<x.length;h++)l+=x[h].offsetHeight;l+2<e.config.min_map_size?l=e.config.min_map_size:l+=2}else if(e._gridView)if(l=0,d.childNodes[1].childNodes[0].childNodes&&d.childNodes[1].childNodes[0].childNodes.length){
for(var x=d.childNodes[1].childNodes[0].childNodes[0].childNodes,h=0;h<x.length;h++)l+=x[h].offsetHeight;l+=2,l<e.config.min_grid_size&&(l=e.config.min_grid_size)}else l=e.config.min_grid_size;if(e.matrix&&e.matrix[_]){if(t)l+=0,d.style.height=l+"px";else{l=0;for(var b=e.matrix[_],y=b.y_unit,w=0;w<y.length;w++)l+=b._section_height[y[w].key];e.$container.clientWidth!=e.$container.scrollWidth&&(l+=a())}l-=1}("day"==_||"week"==_||e._props&&e._props[_])&&(l+=2)}l+=1,r+=l}e._obj.style.height=r+"px",
t||e.updateView()},l=function(){if(!e.config.container_autoresize||!n)return!0;var a=e.getState().mode;if(!a)return!0;var i=window.requestAnimationFrame||window.setTimeout,r=document.documentElement.scrollTop;i(function(){d()}),e.matrix&&e.matrix[a]||"month"==a?i(function(){d(!0),document.documentElement.scrollTop=r,t()},1):t()};e.attachEvent("onBeforeViewChange",function(){var t=e.config.container_autoresize;if(e.xy.$original_scroll_width||(e.xy.$original_scroll_width=e.xy.scroll_width),
e.xy.scroll_width=t?0:e.xy.$original_scroll_width,e.matrix)for(var a in e.matrix){var i=e.matrix[a];i.$original_section_autoheight||(i.$original_section_autoheight=i.section_autoheight),i.section_autoheight=!t&&i.$original_section_autoheight}return!0}),e.attachEvent("onViewChange",l),e.attachEvent("onXLE",l),e.attachEvent("onEventChanged",l),e.attachEvent("onEventCreated",l),e.attachEvent("onEventAdded",l),e.attachEvent("onEventDeleted",l),e.attachEvent("onAfterSchedulerResize",l),
e.attachEvent("onClearAll",l),e.attachEvent("onBeforeExpand",function(){return n=!1,!0}),e.attachEvent("onBeforeCollapse",function(){return n=!0,!0})});