/*

@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(t){t.initCustomLightbox=function(e,i,n){function a(){if(!i._lightbox){var t=i._getLightbox(),n=t.childNodes[1];t.className.indexOf("dhx_cal_light_wide")>=0?n.lastChild.firstChild.style.display="none":n.firstChild.style.display="none",n.style.height=n.style.height.replace("px","")-25+"px",t.style.height=t.style.height.replace("px","")-50+"px",t.style.width=+e.width+10+"px",n.style.width=e.width+"px"}return i._lightbox}var r={initial:0,load_data:1,save_data:2
},s=n+"_here_iframe_";if(i.config.buttons_left=[],i.config.buttons_right=[],i._getLightbox=i.getLightbox,i.config.lightbox.sections=[{type:"frame",name:"box",action:e.view}],i._cust_string_to_date=function(t){return i.templates.xml_date(t)},i._cust_date_to_str=function(t){return i.templates.xml_format(t)},i._deep_copy=function(e){if("object"==typeof e){
if("[object Date]"==Object.prototype.toString.call(e))var i=new Date(e);else if("[object Array]"==Object.prototype.toString.call(e))var i=new Array;else var i=new Object;for(var n in e)i[n]=t._deep_copy(e[n])}else var i=e;return i},"external"==e.type)i.attachEvent("onBeforeLightbox",function(){return i._custom_box_stage=0,!0}),i.getLightbox=a,i._setLightboxValues=function(n,a){var o=t.config.lightbox.sections[0],d=o?o.action:e.view,n=document.getElementById(s);try{switch(i._custom_box_stage){
case r.initial:if(!i.dataProcessor){var l=i.dataProcessor=new DataProcessor;l.init(i)}var l=i.dataProcessor||l,_=l._getRowData(a),h=-1===(d||"").indexOf("?")?"?":"&",c="<form action='/"+d+h+"id="+encodeURIComponent(a)+"' method='POST'>";for(var u in _)c+="<input type='hidden' name='"+u+"'/>";if(c+="</form>",n.Document)var f=n.Document.body;else var f=n.contentDocument.body;f.innerHTML=c;var g=0;for(var u in _)f.firstChild.childNodes[g++].value=_[u];f.firstChild.submit();break;case r.load_data:
if(!n.contentWindow.lightbox){n.contentWindow;n.contentWindow.lightbox={close:function(){i._remove_customBox()}}}i.callEvent("onLightbox",[a]);break;case r.save_data:if(!n)return;var v=n.contentWindow;if(!v||!v.response_data)return;i._doLAction(v.response_data),i._remove_customBox()}}catch(t){i._remove_customBox(),window.console&&console.log(t)}i._custom_box_stage++},i._remove_customBox=function(){i._lightbox?i.endLightbox(!1,i._lightbox):i.endLightbox(!1),i.callEvent("onAfterLightbox",[])},
i._doLAction=function(t){try{if(!t)return;var e=t.data;e.start_date&&e.end_date&&(e.start_date=i._cust_string_to_date(t.data.start_date),e.end_date=i._cust_string_to_date(t.data.end_date));var n=t.action;switch(t.action){case"insert":i._loading=!0,i.addEvent(e),i._loading=!1,n="inserted";break;case"update":var a=i.getEvent(t.sid);for(var r in e)a[r]=e[r];i.event_updated(a),i.updateEvent(t.sid),n="updated";break;case"delete":i.deleteEvent(t.sid,!0),n="deleted"}
i.dataProcessor.callEvent("onAfterUpdate",[t.sid,n,t.tid,t])}catch(t){}},i.form_blocks.frame={onload:function(t,e,i){i._setLightboxValues(t,e)},render:function(t){return"<div style='display:inline-block; height:"+e.height+"px'></div>"},set_value:function(t,a,r,o){i._last_id=r.id;var d='<iframe id="'+s+'" frameborder="0" onload="'+n+".form_blocks.frame.onload(this, "+n+"._last_id, "+n+');" src=""';return(e.width||e.height)&&(d+=" style='"),e.width&&(d+="width:"+e.width+"px;",
t.style.width=e.width+"px"),e.height&&(d+="height:"+e.height+"px;",t.style.height=e.height+"px"),(e.width||e.height)&&(d+=" '"),d+="><html></html></iframe>",t.innerHTML=d,e.className&&(t.className=e.className),!0},get_value:function(t,e){return!0},focus:function(t){return!0}};else{var o=t.config.lightbox.sections[0],d=o?o.action:e.view;i.form_blocks.frame={render:function(t){var i='<iframe  id="'+n+"_here_iframe_\" onload='"+n+"._addLightboxInterface(this)' frameborder='0' src='"+d+"'"
;return(e.width||e.height)&&(i+=" style='"),e.width&&(i+="width:"+e.width+"px;"),e.height&&(i+="height:"+e.height+"px;"),(e.width||e.height)&&(i+=" '"),i+=" ></iframe>"},set_value:function(t,e,i){if(t.contentWindow&&t.contentWindow.setValues){if(1==t.contentWindow.document.getElementsByTagName("form").length)t.contentWindow.document.getElementsByTagName("form")[0].reset();else{var i=t.contentWindow.getValues();for(var n in i)i[n]="";t.contentWindow.setValues(i)}t.contentWindow.setValues(i)}},
get_value:function(t,e){return i._deep_copy(t.contentWindow.getValues())},focus:function(t){return!0}},i.getLightbox=a,i._addLightboxInterface=function(t){if(t.contentWindow.lightbox||(t.contentWindow.lightbox={}),t.contentWindow.lightbox.save=function(){var e=i.getEvent(i.getState().lightbox_id),n=t.contentWindow.getValues();for(var a in n)e[a]=n[a];i.endLightbox(!0,i._lightbox),i.callEvent("onAfterLightbox",[])},t.contentWindow.lightbox.close=function(t){i.endLightbox(!1,i._lightbox),
i.callEvent("onAfterLightbox",[])},t.contentWindow.lightbox.remove=function(){var t=i.locale.labels.confirm_deleting;t&&!confirm(t)||(i.deleteEvent(i._lightbox_id),i._new_event=null),i.endLightbox(!0,i._lightbox)},1==t.contentWindow.document.getElementsByTagName("form").length)t.contentWindow.document.getElementsByTagName("form")[0].reset();else if(t.contentWindow.getValues&&t.contentWindow.setValues){var e=t.contentWindow.getValues();for(var n in e)e[n]="";t.contentWindow.setValues(e)}
t.contentWindow.setValues&&t.contentWindow.setValues(i.getEvent(i._lightbox_id)),i.callEvent("onLightbox",[i._lightbox_id])}}}});