if(!window.smarcoms){window.smarcoms={}}if(!smarcoms.log){smarcoms.log={}}smarcoms.log.init=function(){if(!smarcoms.log.config){return}if(window.Log){return}if(window.console){Log=window.console;if(!console.debug){console.debug=function(e){console.log("DEBUG",e)}}}else{Log={}}if(smarcoms.log.config.enableDebugLoggig===true&&Log&&(Log.debug)){Log.info("Startuji podporu javascriptoveho logovani");if(smarcoms.log.config.ieTrace===true){Log.ieTrace=function(e){this.info("TR: "+e)}}else{Log.ieTrace=function(e){}}if(smarcoms.log.config.jsProfile!==true){Log.time=function(){};Log.timeEnd=function(){}}}else{var b=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd","ieTrace"];Log={};var c=function(){};for(var a=0;a<b.length;++a){Log[b[a]]=c}}if(window.LOG){LOG.transmitToServer=false;if(smarcoms.log.config.a4jDebug){LOG.LEVEL=LOG.ALL}else{LOG.LEVEL=LOG.WARN}LOG._logToConsole=function(h,e,g){var f="a4j: "+h;if(e===LOG.DEBUG||e===LOG.A4J_DEBUG){Log.debug(f)}else{if(e===LOG.ERROR||e===LOG.FATAL){Log.error(f)}else{if(e===LOG.WARN){Log.warn(f)}else{if(e===LOG.INFO){Log.info(f)}else{Log.debug(h)}}}}}}if(window.A4J&&A4J.AJAX){A4J.AJAX.onError=function(g,e,f){Log.info(g);if(e==599){f=smarcoms.log.FAILURE_NETWORK_ERROR;Log.error("599 - chyba spojeni")}else{if(e==500&&g.getResponseText().indexOf("ViewExpiredException")!=-1){Log.warn("Obrzena ViewExpiredException ze serveru");f=smarcoms.log.FAILURE_NETWORK_ERROR}}smarcoms.Modal.showError(f);Log.info(e);Log.info(g)};A4J.AJAX.onExpired=function(f,e){smarcoms.Modal.showError(e);Log.error(e);Log.info(f)}}};if(!window.smarcoms){window.smarcoms={}}smarcoms.PopupPanel={shownModalComponentId:null,onclickObserver:null,topOffset:-5,leftOffset:-25,size:[370,170],registerOuterClickObserver:function(){if(this.onclickObserver===null){}},show:function(e,b){if(this.shownModalComponentId){Log.warn("Uz mame zobrazeno");return}var c=$(e).component;this.shownModalComponentId=e;c.show();Log.debug(c);try{if(!b){b=this.guessPositionFromClickedCell()}this.move(c,b)}catch(a){Log.error(a)}},showWhenNoErrors:function(b,a){if(!smarcoms.messages.containsAnyMessage(b)){this.show(a)}else{if(window.App&&App.schedule){App.schedule.cleanMarkedCells()}}},hide:function(b){if(this.shownModalComponentId){var a=$(this.shownModalComponentId).component;a.hide();this.shownModalComponentId=null}},move:function(l,f){Log.debug("Moving to position: ",f);var k=f[1];var b=f[0];var c=$(l.contentDiv);var e=this.size[1];var a=k-e+this.topOffset;if(a<0){a=k-this.topOffset}k=a;var j=b+this.leftOffset;var g=j+this.size[0];if(g>document.viewport.getDimensions().width-20){j=b-this.size[0]+this.leftOffset}b=j;l.setTop(k);l.setLeft(b)},guessPositionFromClickedCell:function(){var a=App.emptyCellData;if(!a){Log.warn("Nepodarilo se zikat pozici bunky na kterou bylo klinuto za ucelem premisteni modalu");return[0,0]}return a.position},onMouseDown:function(e){if(this.shownModalComponentId){Log.debug("klinuto, zavirame?");Log.debug(e,e.element());var c=$(this.shownModalComponentId).component;var a=$(c.cdiv);var b=$("quickAddForm:quick_res_suggestion");if(!e.element().descendantOf(a)&&!e.element().descendantOf(b)){this.hide(this.shownModalComponentId)}}},isShown:function(){return(this.shownModalComponentId)?true:false}};smarcoms.ScheduleTooltip={showTimeout:1000,showingForCell:null,showingTooltip:null,_timerHandle:null,_tooltipMouseOut:null,_willShowForCell:null,_willShowOnPosition:null,_willShowTooltip:null,cellNoteRowTemplate:new Template("#{note}<br />"),showForCell:function(c,b,a){if(!this.showingForCell&&!smarcoms.PopupPanel.isShown()){if(this._willShowForCell){window.clearTimeout(this._timerHandle);this.clear()}this._willShowForCell=b;this._willShowOnPosition=a;this._willShowTooltip=c;if(this.showTimeout>0){Log.debug("startuji timeout");this._timerHandle=window.setTimeout(this._showForCell.bindAsEventListener(this),this.showTimeout)}else{this._showForCell()}}},_showForCell:function(){try{if(this._willShowForCell){Log.debug("showing tooltip");this.showingForCell=this._willShowForCell;this.showingTooltip=this._willShowTooltip;var b=$(this.showingTooltip).component;var c=$(b.cdiv);var e=this.buildCellNoteContent(this.showingForCell);this.setContent(c,e);smarcoms.PopupPanel.show(this._willShowTooltip,this._willShowOnPosition);this._willShowForCell=null;this._willShowOnPosition=null;this._willShowTooltip=null;this._tooltipMouseOut=this.onTooltipMouseOut.bindAsEventListener(this);Event.observe(c,"mouseout",this._tooltipMouseOut)}else{Log.warn("Chyba, nemam _willShowForCell")}}catch(a){Log.error(a)}},hide:function(f,c){if(this._willShowForCell){Log.debug("rusim nacasovani");window.clearTimeout(this._timerHandle);this.clear()}else{if(this.showingForCell){var a=$(f).component;var b=(a.cdiv);var e=$(c.relatedTarget);if(c&&e&&e.descendantOf(b)){Log.debug("Jsme nad tooltipem, neschovavej :)");return}else{Log.debug("hiding tooltip");a=$(this.showingTooltip).component;b=(a.cdiv);Event.stopObserving(b,"mouseout",this._tooltipMouseOut);this._tooltipMouseOut=null;smarcoms.PopupPanel.hide(f);this.clear()}}}},clear:function(){this._willShowForCell=null;this._willShowOnPosition=null;this._willShowTooltip=null;this.showingForCell=null;this.showingTooltip=null},onTooltipMouseOut:function(a){Log.debug("sjeli jsme z tooltipu");this.hide(this.showingTooltip,a)},setContent:function(a,b){$("scheduleTooltipContent").update(b)},buildCellNoteContent:function(a){if(Object.isArray(a.notes)){var e="";var c=a.notes;for(var b=0;b<c.length;b++){e=e+this.cellNoteRowTemplate.evaluate({note:c[b]})}return e}else{if(typeof a.notes=="string"){return a.notes}}}};if(!window.smarcoms){window.smarcoms={}}if(!smarcoms.math){smarcoms.math={}}if(!smarcoms.util){smarcoms.util={}}if(!smarcoms.modal){smarcoms.modal={}}if(!smarcoms.cookies){smarcoms.cookies={}}if(!smarcoms.leftPanel){smarcoms.leftPanel={}}if(!smarcoms.pricing){smarcoms.pricing={}}if(!smarcoms.special){smarcoms.special={}}if(!smarcoms.calendar){smarcoms.calendar={}}if(!smarcoms.date){smarcoms.date={}}if(!smarcoms.bizzy){smarcoms.bizzy={}}if(!smarcoms.form){smarcoms.form={}}if(!smarcoms.table){smarcoms.table={}}smarcoms.leftPanel.isOpened=function(a){return(smarcoms.leftPanel.getState(a)=="opened")};smarcoms.leftPanel.getState=function(b){var a=TogglePanelManager.panels.get(b);if(a){return a.currentId}else{Log.debug("Toggle panel "+b+" nenalezen");return null}};smarcoms.cookies.create=function(c,e,f){var b=new Date();b.setTime(b.getTime()+(f*24*60*60*1000));var a="; expires="+b.toGMTString();document.cookie=c+"="+e+a+"; path=/"};smarcoms.cookies.read=function(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return null};smarcoms.cookies.exists=function(a){if(!smarcoms.cookies.read(a)){return"true"}return"false"};smarcoms.cookies.erase=function(a){smarcoms.cookies.create(a,"",-1)};smarcoms.math.div=function(b,a){if((b%a)===0){return b/a}else{return Math.round((b-(b%a))/a)}};smarcoms.util.isArray=function(a){Log.warn("deprecated - pouzijte Object.isArray() z prototype");return a&&a.constructor===Array};smarcoms.util.rmPxFromStyle=function(a){var b=a.indexOf("px");if(b<0){Log.error("rmPxFromStyle: retezec '"+a+"' neobsahuje px.");return null}else{return a.substring(0,b)*1}};smarcoms.util.createQueryString=function(b,c){var a=$H({});smarcoms.util._createQueryStringItem(b,a,c);return a.toQueryString()};smarcoms.util._createQueryStringItem=function(c,b,e){if(!e){e=""}if(typeof(c)=="string"||typeof(c)=="boolean"||typeof(c)=="number"){b.set(e,c)}else{if(Object.isArray(c)){$A(c).each(function(f,g){smarcoms.util._createQueryStringItem(f,b,e+"_"+g)})}else{var a=$H(c);a.each(function(f){smarcoms.util._createQueryStringItem(f.value,b,e+"."+f.key)})}}};smarcoms.util.openModalDialog=function(b,a){if(!smarcoms.messages.containsAnyError(b)){Richfaces.showModalPanel(a)}};smarcoms.util.closeModalDialog=function(b,a){if(!smarcoms.messages.containsAnyError(b)){Log.debug("hiding modal panel"+a);Richfaces.hideModalPanel(a);return true}else{Log.debug("NOT hiding modal panel"+a);return false}};smarcoms.util.toggleDisplayByCheckbox=function(b,e,a){var c;if(b.checked&&e||!b.checked&&!e){c=null}else{c="none"}$A(a).each(function(f){var g=$(f);if(g){g.style.display=c}else{if(Log){Log.error("Nenalezen element s id: ",f)}}})};smarcoms.util.toggleDisabledByCheckbox=function(b,f,a){var e;if(b.checked&&f||!b.checked&&!f){e=false}else{e=true}var c="ie-disabled";$A(a).each(function(g){var h=$(g);if(h){h.disabled=e;smarcoms.util.initDisabledIeStyleClass(h)}else{if(Log){Log.error("Nenalezen element s id: ",g)}}})};smarcoms.util.initDisabledIeStyleClass=function(b){if(!window.event){return}var a="ie-disabled";if(b.disabled){Element.addClassName(b,a)}else{Element.removeClassName(b,a)}};smarcoms.util.checkAllCheckboxes=function(b,c){var e=0;var a=$(b+":"+e);do{if(a){if(c){a.checked=false}else{a.checked=true}}e++;a=$(b+":"+e)}while(a);return false};smarcoms.util.handleSuggestionValue=function(c,b,a){if(Object.isArray(c)){if(c.length>0){sItem=c[0];if(sItem.object){Log.info("Vybran objekt s klicem "+sItem.object[a]);$(b).value=sItem.object[a]}else{Log.warn("vybrany objekt nema parametr object - nemam odkud ziskat hodnotu klice");$(b).value=""}}}else{Log.warn("Parametr selectedItems neni pole: "+c)}};smarcoms.util.setFocusOnId=function(b){var a=document.getElementById(b);if(a!=null){a.focus()}else{Log.warn("setFocusOnId: Nenalezen pozadovany element: "+b)}};smarcoms.special.startScheduleWaiting=function(){Protoload.startWaiting($(document.body),"bigWaiting",250)};smarcoms.special.stopScheduleWaiting=function(){Protoload.stopWaiting($(document.body))};smarcoms.pricing.recountRelativePriceChanged=function(e,a,c,f,l){var b=0;var j=e.value*1;var g=$(a+":"+b+":"+c);do{if(g){if(g.checked){var k=$(a+":"+b+":"+f).value*1;var h=$(a+":"+b+":"+l);h.value=j*(k/100)}}b++;g=$(a+":"+b+":"+c)}while(g)};smarcoms.pricing.recountRelativePercentChanged=function(c,b,f,m,e){var j=0;var k=c.value.replace(",",".")*1;if(k<0){k=0}var o=$(b).value.replace(",",".")*1;var a=$(f).value.replace(",",".")*1;var h=$(m);var g=$(e);if(h){var l=(o*(k/100));var n=(a*(k/100));h.value=l.toFixed(2).replace(".",",");g.value=n.toFixed(2).replace(".",",")}};smarcoms.Modal={_errorDialog:{realId:null,rfId:"errorModal"},_messageDialog:{realId:null,rfId:"errorModal"},showError:function(a){if(this._errorDialog.realId===null){this._errorDialog.realId=smarcoms.Modal._findRichfacesModal(this._errorDialog.rfId);if(this._errorDialog.realId===null){Log.error("Nelze nalezt modal dialog");alert(a);return}}this._showModal(this._errorDialog,a)},showMessage:function(a){if(this._messageDialog.realId===null){this._messageDialog.realId=smarcoms.Modal._findRichfacesModal(this._messageDialog.rfId);if(this._messageDialog.realId===null){Log.error("Nelze nalezt modal dialog");alert(a);return}}this._showModal(this._messageDialog,a)},_showModal:function(a,b){if(Richfaces){$(a.realId+"_Text").update(b);Richfaces.showModalPanel(a.rfId)}else{Log.error("Nelze ziskat pristup k objektu Richfaces.");alert(b)}},_findRichfacesModal:function(a){var b=null;if(ModalPanel.panels){ModalPanel.panels.each(function(c){if(c.markerId.id.endsWith(a)){b=c.markerId.id;return}})}return b}};smarcoms.calendar.shiftDay=function(e,b){var c=e.getSelectedDate();var a=new Date();a.setTime(c.getTime()+b*24*60*60*1000);e.selectDate(a);Log.debug("selected date",a)};smarcoms.date.formatForHeader=function(f){if(!smarcoms.date.labels){Log.error("Nemam k dispozici lokalizovane nazvy dni a mesicu");return}var c=smarcoms.date.labels;var e=(f.getMinutes()).toPaddedString(2);var b=(f.getSeconds()).toPaddedString(2);var a=c.days[f.getDay()]+" / "+f.getDate()+"."+c.months[f.getMonth()];a=a+" / "+f.getHours()+":"+e+":"+b;return a};smarcoms.date.startActualTimer=function(a){smarcoms.date.stopActualTimer();smarcoms.date._actualTimeTargetId=a;smarcoms.date.showActualTime()};smarcoms.date.stopActualTimer=function(){if(smarcoms.date._actualTimeTimerId){clearTimeout(smarcoms.date._actualTimeTimerId)}};smarcoms.date.showActualTime=function(){$(smarcoms.date._actualTimeTargetId).innerHTML=smarcoms.date.formatForHeader(new Date());smarcoms.date._actualTimeTimerId=setTimeout(smarcoms.date.showActualTime,1000)};smarcoms.special.rememberSearchPanelState=function(b,a){if(smarcoms.leftPanel.isOpened(b)){beforeSecond=new Date();beforeSecond.setTime(beforeSecond.getTime()-1);document.cookie=a+"=false;expire="+beforeSecond.toGMTString()}else{nextYear=new Date();nextYear.setTime(nextYear.getTime()+356*24*60*60*1000);document.cookie=a+"=true;expire="+nextYear.toGMTString()}};smarcoms.special.rememberRichMessages=function(a){Log.ieTrace("smarcoms.special.rememberRichMessages");var b=$(a);if(b&&b.style.display!="none"){smarcoms.Ajax.richMessageHolder={richMessageHtml:b.innerHTML,richMessageId:a,inner:true};Log.debug("rememberRichMessages",b.innerHTML)}};smarcoms.util.closeModalWithScheduleRefresh=function(c,a){var b=smarcoms.util.closeModalDialog(c,a);if(b&&smarcoms.Ajax&&window.App&&App.schedule){Log.info("updating schedule after edit");smarcoms.Ajax.forceScheduleUpdate()}return b};smarcoms.form.fireClickOnEnterPressed=function(b,a){if(smarcoms.form.isEnterPressed(b)){smarcoms.form.fireClick(a);return false}return true};smarcoms.form.fireClick=function(c){var b=document.getElementById(c);if(document.createEvent){var a=document.createEvent("MouseEvents");a.initEvent("click",true,false);b.dispatchEvent(a)}else{if(document.createEventObject){b.fireEvent("onclick")}}};smarcoms.form.isEnterPressed=function(b){var c;if(window.event){c=b.keyCode}else{if(b.which){c=b.which}}var a=13;return a==c};smarcoms.form.checkAllCheckboxes=function(e,b){var c=$(e).getInputs("checkbox");for(var a in c){c[a].checked=b}return true};smarcoms.table.setSelectedBatchCheckboxesCount=function(e,b){var c=smarcoms.table.getBatchCheckboxCount(e);var a=$(b).innerHTML*1;$(b).innerHTML=c+a};smarcoms.table.checkAllBatchCheckboxes=function(e,b){var c=$(e).getInputs("checkbox");for(i=0;i<c.length;i++){if(c[i].hasClassName("batch")){var a=c[i].onchange;c[i].onchange=null;c[i].checked=b;c[i].onchange=a}}};smarcoms.table.getBatchCheckboxCount=function(c){var b=$(c).getInputs("checkbox");var a=0;for(i=0;i<b.length;i=i+1){if(b[i].checked&&b[i].hasClassName("batch")){a=a+1}}return a};smarcoms.ScheduleResizer={MESSAGES_WIDTH_CORR:-68,CONTENT_WIDTH_CORR:-17,SIDEBAR_ID:"cdForm:leftPanel",resizeScheduleForSidebar:function(){this.resizeSchedule(App.schedule.scheduleData,true)},resizeForHeader:function(){if(App.schedule){this.resizeSchedule(App.schedule.scheduleData,false)}else{this.resizeContent(false)}},resizeContent:function(f){if(this._hasSchedulePage()){this._resizeScheduleViewport(f)}else{var g="leftPanelForm:leftPanel";var b=this._getSidebarWidth(g,f);var c=smarcoms.util.getViewportSize();var h=c[0];var e=h-b;var j=$("content-right");if(j){j.style.width=e+this.CONTENT_WIDTH_CORR+"px"}var k=$("bin");var a=k?k.offsetWidth:0;$("infoblok").style.width=h-448-10-a+"px"}},_resizeScheduleViewport:function(c){if(this._hasSchedulePage()){var a=this._getSidebarWidth(this.SIDEBAR_ID,c);var b=this._resizeScheduleContent(a);this._resizeInfoblok(b.viewportWidth);this._resizeServiceTabs(b.width)}},_hasSchedulePage:function(){return $("cdForm:serviceTabs")!=undefined},resizeSchedule:function(e,c){var a=this._getSidebarWidth(this.SIDEBAR_ID,c);var b=this._resizeScheduleContent(a);this._resizeInfoblok(b.viewportWidth);this._resizeServiceTabs(b.width);this._resizeScheduleReservations(b.width,a);this._resizeContentIeResizer(e,a)},_resizeScheduleContent:function(b){var m=$("header");var n=$("small_header");var g=m.visible()?m.offsetHeight:n.offsetHeight;var f=$("menu").offsetHeight+g+$("scheduleNavigForm:navigace").offsetHeight;var a=$("footer").offsetHeight;var e=f+a;if(Prototype.Browser.IE){e+=1}var h=this._getViewportSize();var o=h[0];var c=h[1];var k=$("content");if(k){var l=o-b;var j=c-e;k.style.height=j+"px"}return{viewportWidth:o,viewportHeight:c,width:l,height:j}},_resizeInfoblok:function(b){var a=$("bin");var c=a?a.offsetWidth:0;$("infoblok").style.width=b-448-c+"px"},_resizeServiceTabs:function(b){var a=$("cdForm:serviceTabs");if(a){a.style.width=b+this.CONTENT_WIDTH_CORR+"px"}},_resizeScheduleReservations:function(b,a){var c=$("cdForm:scheduleReservations");if(c){c.style.width=b+this.CONTENT_WIDTH_CORR-a+"px"}},_resizeContentIeResizer:function(g,b){Log.info("menim velikost falesneho content divu ktery zajistuje scroolbary v ie6");if(!g){return}var f=this._computeMaxTableWidth(g);var c=f+b;$("content-ie-resizer").style.width=c+"px";var e=$("cdForm:scheduleComponent");if(e){e.style.width=c-b+"px"}var a=$("content-right");if(a){a.style.width=c-b+"px"}},_computeMaxTableWidth:function(h){var f=0;for(var a=0;a<h.grids.length;a++){var b=h.grids[a];var e=$(b.tableId);if(e&&e.offsetWidth>f){f=e.offsetWidth}}var c=$("cdForm:serviceTabs");if(c){var g=c.offsetWidth;f=Math.max(g,f)}return f},_getSidebarWidth:function(h,g){var c=30;var a=$(h+"_opened");var k=false;if(a){k=a.childNodes.length===0;var f=$("cdForm:sidebar");if(!k&&f){var b=false;for(var e=0;e<f.childNodes.length;e++){var j=f.childNodes[e];if((j.tagName=="DIV"||j.tagName=="div")&&j.style.display!="none"){b=true}}k=!b}}if((smarcoms.leftPanel.isOpened(h)&&!g)||(!smarcoms.leftPanel.isOpened(h)&&g===true)){if(!k||g){c=220}}if(Prototype.Browser.IE){c+=17}if(c>200){$("content-right").addClassName("sidebar-on");$("content-right").removeClassName("sidebar-off")}else{$("content-right").removeClassName("sidebar-on");$("content-right").addClassName("sidebar-off")}return c},_getViewportSize:function(){var b;var a;if(typeof window.innerWidth!="undefined"){b=window.innerWidth;a=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!==0){b=document.documentElement.clientWidth;a=document.documentElement.clientHeight}else{b=document.getElementsByTagName("body")[0].clientWidth;a=document.getElementsByTagName("body")[0].clientHeight}}return[b,a]}};if(!window.smarcoms){window.smarcoms={}}if(!smarcoms.messages){smarcoms.messages={}}smarcoms.messages={LEVEL_ERROR:"error",LEVEL_INFO:"info",LEVEL_INFO_CLASS:"form-msg-info",LEVEL_INFO_SPAN_CLASS:"messages-info",LEVEL_ERROR_CLASS:"form-msg-error",LEVEL_ERROR_SPAN_CLASS:"messages-error",SCHEDULE_MESSAGES_ID:"schedule-messages",SCHEDULE_MESSAGES_TIMEOUT:15000,scheduleTimeoutId:null,_templates:{"error":new Template('<dt><span class="rich-messages-label #{levelClass}">#{msg}</span></dt>'),"info":new Template('<dt><span class="rich-messages-label  #{levelClass}">#{msg}</span></dt>')},addMessage:function(c,e,f){var b=$(c);if(b){var a=this._templates[f].evaluate({msg:e,levelClass:(f==this.LEVEL_ERROR?this.LEVEL_ERROR_SPAN_CLASS:this.LEVEL_INFO_SPAN_CLASS)});b.insert({top:a});if(b.visible()){Effect.Pulsate(c,{pulses:1,duration:0.75})}else{Effect.SlideDown(c,{duration:0.75})}}else{Log.error("msg container "+c+" nenalezen")}},clearAndHide:function(b){var a=$(b);if(a){Effect.BlindUp(b,{duration:0.5,afterFinish:function(){smarcoms.messages.clear(b)}})}},clearAndSlideUp:function(b){var a=$(b);if(a){Effect.SlideUp(b,{duration:0.75,afterFinish:function(){smarcoms.messages.clear(b)}})}},clear:function(b){var a=$(b);if(a){a.innerHTML=""}},setScheduleMessagesTimeout:function(){clearTimeout(smarcoms.messages.scheduleTimeoutId);smarcoms.messages.scheduleTimeoutId=setTimeout("smarcoms.messages.hideScheduleMessages();",this.SCHEDULE_MESSAGES_TIMEOUT)},hideScheduleMessages:function(){smarcoms.messages.clearAndSlideUp("schedule-messages")},containsAnyMessage:function(b){var a=document.getElementById(b);if(!a||a.style.display==="none"){return false}else{return true}},containsAnyError:function(e){var c=$(e);if(c==null){return false}var b=c.childElements();for(var a=0;a<b.length;++a){var f=b[a];if(smarcoms.messages._isError(f)){return true}}return false},_isError:function(b){var a=b.childElements();return b.hasClassName(this.LEVEL_ERROR_CLASS)||a.length>0&&a[0].hasClassName(this.LEVEL_ERROR_SPAN_CLASS)},containsAnyInfo:function(e){var c=$(e);if(c==null){return false}var b=c.childElements();for(var a=0;a<b.length;++a){var f=b[a];if(smarcoms.messages._isInfo(f)){return true}}return false},_isInfo:function(b){var a=b.childElements();return b.hasClassName(this.LEVEL_INFO_CLASS)||a.length>0&&a[0].hasClassName(this.LEVEL_INFO_SPAN_CLASS)}};if(!window.smarcoms){window.smarcoms={}}smarcoms.BasicLayoutManager=Class.create();smarcoms.BasicLayoutManager.prototype={initialize:function(){},usesFitting:function(){return false},findSubelements:function(a,c){var b=a.childElements();if(b.length>1){a._topResHandle=b[0];a._leftResHandle=b[1];a._contentElm=b[2];a._rightResHandle=b[3];a._bottomResHandle=b[4]}else{a._contentElm=b[0]}},fit:function(f,b,e,c,a){}};smarcoms.HorizontalDelayLayoutManager=Class.create();smarcoms.HorizontalDelayLayoutManager.prototype={initialize:function(){},usesFitting:function(){return true},findSubelements:function(b,e){var c=b.childElements();var a=0;if(e.delayBefore>0){b._delayBefore=c[a++];if(e.blinded!==true){b._leftResHandle=b._delayBefore.childElements()[0]}}else{if(e.blinded!==true){b._leftResHandle=c[a++]}}if(e.blinded!==true){b._topResHandle=c[a++]}b._contentElm=c[a++];if(e.blinded!==true){b._bottomResHandle=c[a++]}if(e.delayAfter>0){b._delayAfter=c[a++];if(e.blinded!==true){b._rightResHandle=b._delayAfter.childElements()[0]}}else{if(e.blinded!==true){b._rightResHandle=c[a++]}}},fit:function(n,f,b,a,c){var g=0;var l=0;if(a.eventData.delayBefore>0){var m=n.getCellEnd(c.startCol+a.eventData.delayBefore-1,c.startRow);l=m[0]-f[0];a.eventBaseElement._delayBefore.style.width=l+"px";g=l}if(a.eventData.delayAfter>0){var h=c.getEnd();var k=n.getCellStart(h[0]-a.eventData.delayAfter+1,h[1]);var j=b[0]-k[0];a.eventBaseElement._delayAfter.style.width=j+"px";g=g+j}if(g>0){var e=b[0]-f[0]-g;a.eventBaseElement._contentElm.style.width=e+"px";if(l>0){a.eventBaseElement._contentElm.style.left=l+"px"}}}};smarcoms.VerticalDelayLayoutManager=Class.create();smarcoms.VerticalDelayLayoutManager.prototype={initialize:function(){},usesFitting:function(){return true},findSubelements:function(b,e){var c=b.childElements();var a=0;if(e.blinded!==true){b._leftResHandle=c[a++]}if(e.delayBefore>0){b._delayBefore=c[a++];if(e.blinded!==true){b._topResHandle=b._delayBefore.childElements()[0]}}else{if(e.blinded!==true){b._topResHandle=c[a++]}}b._contentElm=c[a++];if(e.delayAfter>0){b._delayAfter=c[a++];if(e.blinded!==true){b._bottomResHandle=b._delayAfter.childElements()[0]}}else{if(e.blinded!==true){b._bottomResHandle=c[a++]}}if(e.blinded!==true){b._rightResHandle=c[a++]}},fit:function(n,h,e,b,f){var c=0;var j=0;if(b.eventData.delayBefore>0){var m=n.getCellEnd(f.startCol,f.startRow+b.eventData.delayBefore-1);j=m[1]-h[1];b.eventBaseElement._delayBefore.style.height=j+"px";c=j}if(b.eventData.delayAfter>0){var k=f.getEnd();var l=n.getCellStart(k[0],k[1]-b.eventData.delayAfter+1);var g=e[1]-l[1];b.eventBaseElement._delayAfter.style.height=g+"px";c=c+g}if(c>0){var a=e[1]-h[1]-c;b.eventBaseElement._contentElm.style.height=a+"px";if(j>0){b.eventBaseElement._contentElm.style.top=j+"px"}}}};smarcoms.EventLayoutManagers={_basic:new smarcoms.BasicLayoutManager(),_delayHoriz:new smarcoms.HorizontalDelayLayoutManager(),_delayVert:new smarcoms.VerticalDelayLayoutManager(),getInstance:function(a,b){if(a.delayBefore==0&&a.delayAfter==0){return this._basic}else{if(b){return this._delayHoriz}else{return this._delayVert}}}};if(!window.smarcoms){window.smarcoms={}}smarcoms.Schedule=Class.create();smarcoms.Schedule.prototype={gridModels:null,events:null,scheduleData:null,updater:null,stopOnClick:false,_stopNotePopups:false,_popupNoteContainerElementId:"schedule-popup-note",initialize:function(scheduleData,printMode){Log.ieTrace("schedule.initialize");this.printMode=printMode;this.scheduleData=scheduleData;if(!scheduleData.grids){Log.error("Nejsou nastaveny udaje o mrizkach");return}Log.info("schedule init: gridmodely");Log.time("init_gridmodels");this.gridModels=[];for(var index=0;index<this.scheduleData.grids.length;index++){var grid=this.scheduleData.grids[index];var gModel=new smarcoms.ScheduleGridModel(this,grid,this.scheduleData.pastTimeData[index],printMode);this.gridModels[grid.id]=gModel}Log.timeEnd("init_gridmodels");Log.info("schedule init: eventy");Log.time("init_events");this.events=[];for(var i=0;i<this.scheduleData.events.length;i++){var evtData=this.scheduleData.events[i];this.events[i]=new smarcoms.ScheduleEvent(evtData.htmlId,this,this.gridModels[evtData.gridId],evtData,printMode)}if(scheduleData.binId){var binElm=$(scheduleData.binId);if(binElm){smarcoms.scriptaculous.Droppables.add(binElm,{onDrop:this.onDropBin.bind(this)})}}else{Log.debug("kde je kos? :(")}$("resContainer").setStyle({visibility:"visible"});if(printMode!==true){$(document.body).setStyle({"overflow":"hidden"});Log.timeEnd("init_events");Log.info("schedule init:ostatni");if(scheduleData.onNeedUpdateScript){var onNeedUpdateFunction=eval('(fnc = function () {Log.debug("Update rozvrhu"); var event = null; '+scheduleData.onNeedUpdateScript+" })");this.updateSchedule=onNeedUpdateFunction}if(scheduleData.deleteReservationFunctionName){this.reservationDeleteAction=eval("(fnc = function () { App.schedule.quitUpdater();"+scheduleData.deleteReservationFunctionName+"(); })")}this.initUpdater()}},initUpdater:function(){Log.info("Startuji automatickou kontrolu aktuality rozvrhu, interval "+this.scheduleData.updateQuestionPeriod);if(this.updater){Log.info("Automaticka kontrola jiz bezi, nestartuji");return}this.updater=new PeriodicalExecuter(smarcoms.Ajax.checkScheduleChange.bind(smarcoms.Ajax),this.scheduleData.updateQuestionPeriod)},quitUpdater:function(){if(this.updater){Log.info("Zastavuji automatickou kontrolu aktuality rozvrhu");this.updater.stop();delete this.updater}},updatePastTimeData:function(b){Log.ieTrace("schedule.updatePastTimeData");try{for(var a=0;a<this.gridModels.length;a++){this.gridModels[a].updatePastTimeData(b[a])}}catch(c){Log.error(c.description);Log.dir(c)}},eventMoved:function(e,b){Log.debug("Schedule.eventMoved");var c=e.parentGrid;var a=this.findDestGridModelForEvtPosition(e);c.removeEventFromGridModel(e);if(c==a){e.resetTableCellArea((b===true)?false:true)}else{e.resetTableCellAreaForNewGridModel(a);e.parentGrid=a}a.resizeEvent(e);a.fillEventIntoGridModel(e);this.lastMovedEvent=e;smarcoms.Ajax.sendEventChange(this,e)},findDestGridModelForEvtPosition:function(c){var a=c.eventBaseElement;var b=Position.positionedOffset(a);return this.gridModels.find(function(e){return(e.isInGrid(b[0],b[1])&&e.isInGrid(b[0]+a.offsetWidth-1,b[1]+a.offsetHeight-1))})},canPlaceEvent:function(g){Log.ieTrace("Schedule.canPlaceEvent");var e=g.parentGrid;var b=this.findDestGridModelForEvtPosition(g);if(!b){Log.debug("Rezervaci nelze polozit mimo mrizku");return false}if(!this.scheduleData.canDragBetweenGridModels&&b!=e){Log.debug("Presouvani rezervaci mezi mrizkami neni povoleno.");return false}var c=g.getTableCellArea();if(!c.canPlaceOverCoveredCells(smarcoms.blockedCellClasses)){Log.debug("Rezervaci nelze presunout, jelikoz puvodne lezela v bunkach se kterymi nelze pracovat");Log.debug(c.startCol,c.startRow);return false}var a=b.countActualTableCellAreaForElement(g);var f=a.canPlaceOverCoveredCells(smarcoms.blockedCellClasses);if(!f){Log.debug("Rezervaci nelze polozit protoze smeruje na zablokovanou bunku");return f}f=f&&a.isFree(g);if(!f){Log.debug("Rezervaci nelze polozit protoze oblast je obsazena jinou rezervaci.");return f}return f},cleanMarkedCells:function(){for(var a=0;a<this.gridModels.length;a++){this.gridModels[a].cleanMarkedCells()}},canAddReservation:function(e,a,c){if(e.gridData.canAddReservation===true){var b=$A(smarcoms.blockedCellClasses).find(function(g){return a.hasClassName(g)});var f=$A(smarcoms.allowedCellTags).find(function(g){return a.tagName.toUpperCase()==g});return f&&!b}else{return false}},popupNote:function(a,f,p){if(this._stopNotePopups!==true){var o=5;var g=$(this._popupNoteContainerElementId);if(g.visible()){g.hide()}g.innerHTML=p;if(!a){a=window.event}var j=Event.pointerX(a);var h=Event.pointerY(a);Log.debug(j,h,a);var b=Position.offsetParent(g);var e=Position.cumulativeOffset(b);var c=$("content");var n=0;var m=0;if(c){n=c.scrollLeft;m=c.scrollTop}var l=j-e[0]+n+o;var k=h-e[1]+m+o;Element.setStyle(g,{left:l+"px",top:k+"px"});g.show()}},popupNoteHide:function(a){if(this._stopNotePopups!==true){var b=$(this._popupNoteContainerElementId);if(b.visible()){b.hide()}}},handleChanges:function(j){if(j){if(j.forceFullRefresh){App.prepareForUpdate();this.updateSchedule()}if(j.removed){Log.info("applying changes - removing ");for(var c=0;c<j.removed.length;c++){var b=j.removed[c];var f=$(b.htmlId);var a=f.scheduleEvent;a.remove()}}if(j.added){var e=this.events.length;var k=$("resContainer");Log.info("applying changes - adding");for(var c=0;c<j.added.length;c++){var g=j.added[c];var h=g.renderedHtml;g.renderedHtml=null;k.insert({bottom:h});this.events[e]=new smarcoms.ScheduleEvent(g.htmlId,this,this.gridModels[g.gridId],g,this.printMode);e++}}}},returnDeletedEvent:function(){if(this.lastDeletedEvent){var a=this.lastDeletedEvent.eventData;this.lastDeletedEvent.eventBaseElement.show();this.lastDeletedEvent.remove(true);this.lastDeletedEvent=null;this.events[this.events.length]=new smarcoms.ScheduleEvent(a.htmlId,this,this.gridModels[a.gridId],a,this.printMode)}},updateSchedule:function(){Log.warn("Neni specifikovana akce pro update rozvrhu!")},emptyCellClickAction:function(){Log.warn("Neni specifikovana akce pro kliknuti do prazdne bunky rozvrhu!")},reservationClickAction:function(){Log.warn("Neni specifikovana akce pro kliknuti do rezervace!")},reservationDeleteAction:function(){Log.warn("Neni specifikovana akce pro smazani do rezervace!")},_onDrop:function(a){},onDropBin:function(a){Log.debug("marking for delete");a.scheduleEvent.markedForDelete=true},onReservationMoveConfirmed:function(a){if(a.success){this.lastMovedEvent=null;if(a.modelChanged){this.handleChanges(a.modelChanges)}}else{var c=this.lastMovedEvent;this.lastMovedEvent=null;var b=c.eventData;c.remove(true);this.events[this.events.length]=new smarcoms.ScheduleEvent(b.htmlId,this,this.gridModels[b.gridId],b,this.printMode)}},destroy:function(){Log.ieTrace("Schedule.destroy");this.quitUpdater();var b=this.events.length;for(var c=0;c<b;c++){this.events[c].destroy(true,true);delete this.events[c]}smarcoms.scriptaculous.Draggables.unregisterAll();Resizables.unregisterAll();delete this.events;this.events=null;for(var a=0;a<this.gridModels.length;a++){this.gridModels[a].destroy();delete this.gridModels[a]}delete this.gridModels;this.gridModels=null;smarcoms.scriptaculous.Droppables.removeAll();window.onresize=null}};if(!window.smarcoms){window.smarcoms={}}smarcoms.ScheduleEvent=Class.create();smarcoms.ScheduleEvent.prototype={EVENT_DATA_REQ_PARAMS_PREFIX:"eventDto",eventBaseElement:null,draggable:null,resizable:null,parentSchedule:null,parentGrid:null,markedForDelete:false,markedForRevert:false,_tableCellArea:null,_onClickObserver:null,eventData:null,_eventNoteString:null,usesFitting:false,layoutManager:null,initialize:function(a,e,f,c,b){Log.ieTrace("ScheduleEvent.initialize");this.eventBaseElement=$(a);this.parentSchedule=e;this.parentGrid=f;Log.time("init_event_"+f.gridId);this.eventData=c;Log.time("init_event_cellArea");this._tableCellArea=f.computeTableCellAreaFromServerData(this);Log.timeEnd("init_event_cellArea");this.layoutManager=smarcoms.EventLayoutManagers.getInstance(c,f.isHorizontalMainDerection);this.usesFitting=this.layoutManager.usesFitting();this.layoutManager.findSubelements(this.eventBaseElement,c);Log.time("init_event_placeandresize");this.parentGrid.placeAndResizeEvent(this);Log.timeEnd("init_event_placeandresize");Log.ieTrace("ScheduleEvent.initialize before draggable and resizable creation");this.eventBaseElement.scheduleEvent=this;if(b!==true){Log.time("init_event_createdrag");this._createDraggable(this.canDragAndDrop(),this.parentGrid.gridData.useFakeDrag);Log.timeEnd("init_event_createdrag");Log.time("init_event_createresize");if(this.canResize()){this._createResizable()}Log.timeEnd("init_event_createresize");Log.ieTrace("ScheduleEvent.initialize before adding onclick observer");if(this.eventData.canEdit===true){this._onClickObserver=this._onClick.bindAsEventListener(this);this.eventBaseElement._contentElm.observe("mouseup",this._onClickObserver)}}if(e.scheduleData.useNotes===true&&this.eventData.notes&&this.eventData.notes.length>0){Event.observe(this.eventBaseElement,"mouseover",this.showNote.bindAsEventListener(this));Event.observe(this.eventBaseElement,"mouseout",this.hideNote.bindAsEventListener(this))}Log.timeEnd("init_event_"+f.gridId)},remove:function(a){this.parentGrid.removeEventFromGridModel(this);this.destroy(a)},destroy:function(a,b){Log.ieTrace("Event.destroy ");if(this.draggable){this.draggable.destroy(b);this.draggable=null}if(this.resizable){this.resizable.destroy(b);this.resizable=null}if(this._onClickObserver){this.eventBaseElement.stopObserving("click",this._onClickObserver);this._onClickObserver=null}if(this.eventBaseElement!=null){this.eventBaseElement.scheduleEvent=null;this.eventBaseElement.stopObserving("mouseover");this.eventBaseElement.stopObserving("mouseout")}else{Log.warn("oops, this.eventBaseElement je null ale jeste jsme ho nevynuovali")}if(!a){this.eventBaseElement.remove();this.eventBaseElement=null}this.parentSchedule=null;this.parentGrid=null;if(this._tableCellArea){this._tableCellArea.destroy();delete this._tableCellArea;this._tableCellArea=null}},getTableCellArea:function(){if(!this._tableCellArea){Log.error("Pozadovan table cell area, ale je null.")}return this._tableCellArea},resetTableCellArea:function(a){this._tableCellArea.reset(this.eventBaseElement,a)},resetTableCellAreaForNewGridModel:function(a){this._tableCellArea.reset(this.eventBaseElement,true,a)},refreshEventData:function(){this.eventData.newStart=this.getTableCellArea().getModelStart();this.eventData.newEnd=this.getTableCellArea().getModelEnd();this.eventData.newGridId=this.parentGrid.gridId},getEvendDataAsQueryString:function(){this.refreshEventData();return smarcoms.util.createQueryString(this.eventData,this.EVENT_DATA_REQ_PARAMS_PREFIX)},canDragAndDrop:function(){return(this.eventData.canDragAndDrop===true||(this.parentGrid.gridData.enableDragAndDrop&&this.eventData.canDragAndDrop!==false))},canDragAndDropBetweenGrids:function(){return(this.eventData.canDragAndDropBetweenGrids===true||(this.parentSchedule.scheduleData.canDragAndDropBetweenGrids&&this.eventData.canDragAndDropBetweenGrids!==false))},canResize:function(){return(this.canResizeInHorizontal()||this.canResizeInVertical())},canResizeInHorizontal:function(){if(this.parentSchedule.scheduleData.mainDirection=="HORIZONTAL"){if(this.eventData.canResizeInMainDirection===true||this.eventData.canResizeInMainDirection===false){return this.eventData.canResizeInMainDirection}else{return this.parentGrid.gridData.enableResize}}else{if(this.eventData.canResizeInSecondaryDirection===true||this.eventData.canResizeInSecondaryDirection===false){return this.eventData.canResizeInSecondaryDirection&&this.parentSchedule.scheduleData.canResizeInSecondaryDirection}else{return this.parentGrid.gridData.enableResize&&this.parentSchedule.scheduleData.canResizeInSecondaryDirection}}},canResizeInVertical:function(){if(this.parentSchedule.scheduleData.mainDirection=="VERTICAL"){if(this.eventData.canResizeInMainDirection===true||this.eventData.canResizeInMainDirection===false){return this.eventData.canResizeInMainDirection}else{return this.parentGrid.gridData.enableResize}}else{if(this.eventData.canResizeInSecondaryDirection===true||this.eventData.canResizeInSecondaryDirection===false){return this.eventData.canResizeInSecondaryDirection&&this.parentSchedule.scheduleData.canResizeInSecondaryDirection}else{return this.parentGrid.gridData.enableResize&&this.parentSchedule.scheduleData.canResizeInSecondaryDirection}}},_createDraggable:function(a,b){if(!window._contentElm){_contentElm=$("content")}if(a||b!==false){this.draggable=new smarcoms.scriptaculous.Draggable(this.eventBaseElement,{ghosting:false,snap:this._snapStrategy.bind(this),revert:(a?this._revertStrategy.bind(this):this._alwaysRevertStrategy),onStart:this._onDragStart.bind(this),onEnd:(a?this._onDragEnd.bind(this):this._onDragEndFake.bind(this)),handle:this.eventBaseElement._contentElm,delay:50,scroll:_contentElm,zindex:1000,scrollSensitivity:20,scrollSpeed:15})}},_createResizable:function(){if(!window._contentElm){_contentElm=$("content")}this.resizable=new Resizable(this.eventBaseElement,{snap:this._snapStrategy.bind(this),snapSize:this._sizeSnapStrategy.bind(this),checkResize:this._checkResize.bind(this),change:this._afterResizeDrawn.bind(this),onEnd:this._onResizeEnd.bind(this),onStart:this._onResizeStart.bind(this),handleLeft:this.canResizeInHorizontal()?this.eventBaseElement._leftResHandle:null,handleUp:this.canResizeInVertical()?this.eventBaseElement._topResHandle:null,handleDown:this.canResizeInVertical()?this.eventBaseElement._bottomResHandle:null,handleRight:this.canResizeInHorizontal()?this.eventBaseElement._rightResHandle:null,ghosting:false,scroll:_contentElm,handle:false,zindex:1000,revert:false,delay:0})},_createFakeDraggable:function(){Log.ieTrace("ScheduleEvent._createFakeDraggable");var a=this.eventBaseElement._contentElm;this._fakeDnD=new smarcoms.FakeDnD(a,function(){})},showNote:function(b){if(!this._eventNoteString){var a=$A(this.eventData.notes).collect(function(c){return c.text});this._eventNoteString=a.join("<br />")}this.parentSchedule.popupNote(b,this.eventBaseElement,this._eventNoteString)},hideNote:function(a){this.parentSchedule.popupNoteHide(this.eventBaseElement)},_onClick:function(a){if(this.parentSchedule&&!this.parentSchedule.stopOnclick&&Event.isLeftClick(a)){smarcoms.scriptaculous.Draggables.endDrag(a);Log.ieTrace("kliknuto do rezervace");App.reservationData=this.eventData.reservation.id;this.parentGrid.reservationClickAction();App.reservationData=null}},_snapStrategy:function(a,h,c){var e=this.parentSchedule.gridModels.find(function(j){return j.isInGrid(a,h)});if(e){var f=e.getTableColForPoint(a);var b=e.getTableRowForPoint(h);var g=e.getCellStart(f,b);if(Prototype.Browser.WebKit){g[0]++;g[1]++}return g}return[a,h]},_sizeSnapStrategy:function(b,a){return this.parentGrid.computeSnapSize(b,a)},_checkResize:function(c,b){if(!this.parentGrid.isInGrid(c[0],c[1])){Log.debug("_checkResize : zamitam !inGrid");return false}var a=this.parentGrid.countActualTableCellArea(c,b);if(a.cols<1||a.rows<1){Log.debug("_checkResize : zamitam smallcellarea");return false}return a.isFree(this)&&a.canPlaceOverCoveredCells(smarcoms.blockedCellClasses)},_afterResizeDrawn:function(a){},_revertStrategy:function(b){var a=this.markedForRevert;this.markedForRevert=false;return a},_alwaysRevertStrategy:function(a){return true},_onDragStart:function(a,b){Log.ieTrace("_onDragStart");this.parentSchedule.stopOnclick=true;this.parentSchedule.popupNoteHide();this.parentSchedule._stopNotePopups=true},_onDragEnd:function(a,b){Log.ieTrace("_onDragEnd");Event.stop(b);this.parentSchedule.stopOnclick=false;this.parentSchedule._stopNotePopups=false;Log.debug("_onDragEnd");if(!this.markedForRevert){if(this.markedForDelete){Log.debug("mazani rezervace ",this.eventData.reservation.id);App.reservationData=this.eventData.reservation.id;this.markedForRevert=false;var c=this.parentSchedule;this.eventBaseElement.hide();c.lastDeletedEvent=this;c.reservationDeleteAction()}else{this.markedForRevert=!this.parentSchedule.canPlaceEvent(this)}if(!this.markedForRevert&&!this.markedForDelete){this.parentSchedule.eventMoved(this)}}smarcoms.messages.setScheduleMessagesTimeout()},_onDragEndFake:function(a,b){smarcoms.messages.clear(smarcoms.messages.SCHEDULE_MESSAGES_ID);smarcoms.messages.addMessage(smarcoms.messages.SCHEDULE_MESSAGES_ID,smarcoms.log.FAILURE_CANNOT_DND,smarcoms.messages.LEVEL_INFO);smarcoms.messages.setScheduleMessagesTimeout();this.parentSchedule.stopOnclick=false;this.parentSchedule._stopNotePopups=false},_onResizeEnd:function(a,b){Log.ieTrace("_onResizeEnd");Event.stop(b);this.parentSchedule.eventMoved(this,true);smarcoms.messages.setScheduleMessagesTimeout()},_onResizeStart:function(b,a){Log.ieTrace("_onResizeStart");this.parentSchedule.stopOnclick=true;this.parentSchedule.popupNoteHide();this.parentSchedule._stopNotePopups=true}};if(!window.smarcoms){window.smarcoms={}}smarcoms.ScheduleGridModel=Class.create();smarcoms.ScheduleGridModel.prototype={parentSchedule:null,table:null,gridId:null,_gridModel:null,tableResized:false,_real2modelRows:null,_real2modelCols:null,_cachedStartCell:null,_cachedEndCell:null,_onClickObserver:null,_markedCellClass:"marked",_lastPastTimeData:null,markedCells:null,closed:false,gridData:null,_emptyCellClickAction:null,reservationClickAction:null,_realCellWidth:0,_realCellHeight:0,_realHorizHeaderCellHeight:0,_realVertHeaderCellWidth:0,_firstCellX:0,_firstCellY:0,_colCount:0,_rowCount:0,_printMode:false,initialize:function(schedule,gridData,pastTimeData,printMode){Log.ieTrace("GridModel.initialize "+gridData.tableId);this.parentSchedule=schedule;this.table=$(gridData.tableId);this.gridId=gridData.id;this.closed=gridData.closed;this.gridData=gridData;this.printMode=printMode;this.isHorizontalMainDerection=(schedule.scheduleData.mainDirection=="HORIZONTAL");this._gridModel=[];if(!this.closed){Log.time("grid_createDroppable");this._createDroppable();Log.timeEnd("grid_createDroppable");var tableRows=this.table.rows;for(var i=0;i<tableRows.length;i++){this._gridModel[i]=[]}tableRows=null;Log.time("grid_initialize_cells");this._initializePositioning(gridData);Log.timeEnd("grid_initialize_cells");if(this.printMode!==true){this._onClickObserver=this.onClickHandler.bindAsEventListener(this);this.table.observe("click",this._onClickObserver);this._lastPastTimeData=pastTimeData;if(gridData.emptyCellClickFunctionName){this._emptyCellClickAction=eval("(fnc = function (event) { App.schedule.quitUpdater();"+gridData.emptyCellClickFunctionName+"(); })")}if(gridData.editReservationFunctionName){this.reservationClickAction=eval("(fnc = function () { App.schedule.quitUpdater();"+gridData.editReservationFunctionName+"(); })")}}this.table.observe("mouseover",this.onMouseOver.bindAsEventListener(this));this.table.observe("mouseout",this.onMouseOut.bindAsEventListener(this))}this.markedCells=[]},onMouseOver:function(a){try{var c=Event.element(a);if(c.notes){smarcoms.ScheduleTooltip.showForCell("scheduleTooltip",c,[a.clientX,a.clientY])}}catch(b){Log.error(b)}},onMouseOut:function(b){try{smarcoms.ScheduleTooltip.hide("scheduleTooltip",b)}catch(a){Log.error(a)}},computeSnapSize:function(g,e){Log.ieTrace("ScheduleGridModel.computeSnapSize");var a=this.getTableColForPoint(g[0]+e[0]-1);var f=this.getTableRowForPoint(g[1]+e[1]-1);if(a<0||f<0||a===null||f===null){Log.debug("nenalezena bunka pro pozici ",g);return null}else{var c=this.getCellEndX(a);var b=this.getCellEndY(f);return[c-g[0],b-g[1]]}},fillEventIntoGridModel:function(f){var a=f.eventData.htmlId;var e=f.getTableCellArea();for(var c=e.getStart()[1];c<=e.getEnd()[1];c++){for(var b=e.getStart()[0];b<=e.getEnd()[0];b++){this._gridModel[c][b]=a}}},removeEventFromGridModel:function(e){var c=e.getTableCellArea();for(var b=c.getStart()[1];b<=c.getEnd()[1];b++){for(var a=c.getStart()[0];a<=c.getEnd()[0];a++){if(!this._gridModel[b][a]){Log.error("Nekonzistentni grid model. (snazim se odstranit rezervaci, ale v dane oblasti neni zavedena)");Log.info(e);Log.info(b,a);Log.info(c)}this._gridModel[b][a]=null}}},updatePastTimeData:function(c){if(this.closed||this.gridData.usePastTime===false){return}for(mRow=0;mRow<c.length;mRow++){mCol=c[mRow];if(mCol>this._lastPastTimeData[mRow]){Log.info("Aktualizuje zasednuti uplnynuleho casu");for(var b=this._lastPastTimeData[mRow]+1;b<=mCol;b++){var a=this.getTableCellForModelPos(b,mRow);if(a){$(a).addClassName(smarcoms.PAST_TIME_SCHEDULE_CELL_CLASS)}}this._lastPastTimeData[mRow]=mCol}}},isInGrid:function(a,b){if(this.closed){return false}if(a>=this._firstCellX&&b>=this._firstCellY&&a<=this.getGridEndX()&&b<=this.getGridEndY()){return true}else{return false}},computeTableCellAreaFromServerData:function(k){var g=k.eventData.start;var h=k.eventData.end;var f=[g[0],g[1]];var b=[h[0],h[1]];var c=this.swapModel2realCoords([b[0]-f[0]+1,b[1]-f[1]+1]);var a=this.swapModel2realCoords(f);a[0]=this.model2realCol(a[0]);a[1]=this.model2realRow(a[1]);var j=new smarcoms.ScheduleCellArea(this,a,c,f);return j},countActualTableCellAreaForElement:function(b){Log.ieTrace("countActualTableCellAreaForElement");var a=b.getTableCellArea();var c=new smarcoms.ScheduleCellArea(this,[1,1],a.getSize());c.reset(b.eventBaseElement,true);return c},countActualTableCellArea:function(a,e,c){var b=new smarcoms.ScheduleCellArea(this);b.reset(a,e,false);return b},getTablePosForPoint:function(a,b){return[this.getTableColForPoint(a),this.getTableRowForPoint(b)]},getTableColForPoint:function(a){var e=a-this._firstCellX;var c=this.gridData.headerCols;if(c.length==1){e=e-this._realVertHeaderCellWidth;return Math.floor(e/this._realCellWidth)+1}else{var g=0;var h=0;var b=0;for(var f=0;f<this._colCount;f++){h=b;if(c.length>g&&f==c[g]){b=h+this._realVertHeaderCellWidth;g++}else{b=h+this._realCellWidth}if(h<=e&&b>e){return f}}}},getTableRowForPoint:function(h){var c=h-this._firstCellY;var b=this.gridData.headerRows;if(b.length==1){c=c-this._realHorizHeaderCellHeight;return Math.floor(c/this._realCellHeight)+1}else{var f=0;var g=0;var a=0;for(var e=0;e<this._rowCount;e++){g=a;if(b.length>f&&e==b[f]){a=g+this._realHorizHeaderCellHeight;f++}else{a=g+this._realCellHeight}if(g<=c&&a>c){return e}}}},getCellStart:function(a,b){return[this.getCellStartX(a),this.getCellStartY(b)]},getCellStartX:function(c){var b=this._real2modelCols[c];var a=c-b;return this._firstCellX+b*this._realCellWidth+a*this._realVertHeaderCellWidth},getCellStartY:function(c){var b=this._real2modelRows[c];var a=c-b;return this._firstCellY+b*this._realCellHeight+a*this._realHorizHeaderCellHeight},getCellEnd:function(a,b){return[this.getCellEndX(a),this.getCellEndY(b)]},getCellEndX:function(c){var b=this._real2modelCols[c];var a=c-b;return this._firstCellX+(b+1)*this._realCellWidth+a*this._realVertHeaderCellWidth-1},getCellEndY:function(c){var b=this._real2modelRows[c];var a=c-b;return this._firstCellY+(b+1)*this._realCellHeight+a*this._realHorizHeaderCellHeight-1},getGridEndX:function(){return this.getCellEndX(this._colCount-1)},getGridEndY:function(){return this.getCellEndY(this._rowCount-1)},getStartCell:function(){if(!this._cachedStartCell){this._cachedStartCell=this.table.rows[0].cells[0]}return this._cachedStartCell},getEndCellCords:function(){if(!this._cachedEndCell){this._cachedEndCell=[this.table.rows[this.table.rows.length-1].cells.length-2,this.table.rows.length-2]}return this._cachedEndCell},swapModel2realCoords:function(a){if(this.isHorizontalMainDerection){return a}else{return[a[1],a[0]]}},model2realRow:function(e){var a=this.gridData.headerRows;var c=e;for(var b=0;b<a.length;b++){if(a[b]!==null&&a[b]<=c){c++}}return c},model2realCol:function(b){var a=this.gridData.headerCols;var e=b;for(var c=0;c<a.length;c++){if(a[c]!==null&&a[c]<=e){e++}}return e},real2modelCol:function(a){return this._real2modelCols[a]},real2modelRow:function(a){return this._real2modelRows[a]},placeAndResizeEvent:function(b){Log.ieTrace("placeAndResizeEvent.start");var a=this.placeEvent(b);this.resizeEvent(b,a);this.fillEventIntoGridModel(b)},cleanMarkedCells:function(){for(var a=0;a<this.markedCells.length;a++){this.markedCells[a].removeClassName(this._markedCellClass)}this.markedCells=[]},placeEvent:function(g){Log.ieTrace("GridModel.placeEvent");var e=g.getTableCellArea();var b=this.getCellStart(e.startCol,e.startRow);var a=0;var c=0;if(Prototype.Browser.WebKit){a=1;c=1}var f=g.eventBaseElement;f.style.left=(b[0]+a)+"px";f.style.top=(b[1]+c)+"px";f=null;return{cellArea:e,start:b}},resizeEvent:function(h,g){Log.ieTrace("GridModel.resizeEvent");var f=null;var c=null;if(g){f=g.cellArea;c=g.start}else{f=h.getTableCellArea();c=this.getCellStart(f.startCol,f.startRow)}var a=this.getCellEnd(f.startCol+f.cols-1,f.startRow+f.rows-1);var b=a[0]-c[0];var e=a[1]-c[1];h.eventBaseElement.style.width=b+"px";h.eventBaseElement.style.height=e+"px";Log.ieTrace("GridModel.resizeEvent nastaveny nove rozmery");if(h.usesFitting===true){h.layoutManager.fit(this,c,a,h,f)}},buildCellId:function(b,a){return"sched_"+b+"_i_"+a[0]+"_"+a[1]},getTableCell:function(a,f){if(a.constructor===Array){var e=a;a=e[0];f=e[1]}var b=this.table.rows[f];if(b){var g=b.cells[a];if(g){return g}}return null},getTableCellForModelPos:function(b,f){if(Object.isArray(b)){var c=b;b=c[0];f=c[1]}var a=this.model2realRow(f);var e=this.model2realCol(b);return this.getTableCell(this.swapModel2realCoords([e,a]))},parseCellId:function(b){var a=b.match(/^.*_(\d+)_i_(\d+)_(\d+)$/);return[a[2],a[3]]},destroy:function(){Log.ieTrace("GridModel.destroy ");smarcoms.scriptaculous.Droppables.remove(this.table);if(this._onClickObserver){this.table.stopObserving("click",this._onClickObserver)}delete this.table;this.table=null;this.parentSchedule=null;delete this._onClickObserver;this._onClickObserver=null;this.gridData=null},onClickHandler:function(a){if(a.target){Log.debug("kliknuto do "+a.target+", tagName: "+a.target.tagName);var b=$(a.target);var c=b.cellIndex;var h=b.parentNode.rowIndex;var g=this._real2modelRows[h];var f=c-1;var e=[f,g];e=this.swapModel2realCoords(e);Log.debug(e);if(e&&this.parentSchedule.canAddReservation(this,b,e)){if(this._markedCellClass){$(b).addClassName(this._markedCellClass);this.markedCells[this.markedCells.length]=$(b)}App.emptyCellData={gridId:this.gridId,modelPosition:e,position:[a.clientX,a.clientY]};this._emptyCellClickAction(a)}else{Log.debug("Na kliknutou bunku nelze pridat rezervaci nebo nebyla nalezena pozice v modelu.")}}},_createDroppable:function(){if(this.printMode!==true){smarcoms.scriptaculous.Droppables.add(this.table.id,{onDrop:this.parentSchedule._onDrop.bind(this.parentSchedule)})}},_initializePositioning:function(w){var x=this.table;var t=x.rows;var a=t[0].cells[0];this._realHorizHeaderCellHeight=a.offsetHeight;this._realVertHeaderCellWidth=a.offsetWidth;this._firstCellX=a.offsetLeft+x.offsetLeft;this._firstCellY=a.offsetTop+x.offsetTop;if(Prototype.Browser.IE===true){var b=x.offsetParent;var u=Element.getStyle(b,"position");if(u!="relative"&&u!="absolute"){this._firstCellX+=b.offsetLeft;this._firstCellY+=b.offsetTop}}this._colCount=t[1].cells.length;this._rowCount=t.length;var e=0;var z=w.headerCols;var n=z.length;for(var A=0;A<n;A++){if(e==z[A]){e++}else{break}}var g=0;var y=w.headerRows;var f=y.length;for(var q=0;q<f;q++){if(g==y[q]){g++}else{break}}var o=t[g].cells[e];this._realCellHeight=o.offsetHeight;this._realCellWidth=o.offsetWidth;var j=[];var h=-1;var B=0;var m=this._rowCount;for(var l=0;l<m;l++){if(f>B&&l===y[B]){B++;j[l]=h+1}else{h++;j[l]=h}}this._real2modelRows=j;var v=[];h=-1;B=0;var s=this._colCount;for(var k=0;k<s;k++){if(n>B&&k===z[B]){B++;v[k]=h+1}else{h++;v[k]=h}}this._real2modelCols=v}};if(!window.smarcoms){window.smarcoms={}}smarcoms.ScheduleCellArea=Class.create();smarcoms.ScheduleCellArea.prototype={parentGridModel:null,_coveredTableCellsCache:null,startCol:null,startRow:null,rows:null,cols:null,initialize:function(c,e,a,b){this.parentGridModel=c;Log.ieTrace("ScheduleCellArea.initialize()");if(e){this.startCol=e[0];this.startRow=e[1];this.cols=a[0];this.rows=a[1];this._fillCoveredTableCellsCache([e[0],e[1]],a)}},isFree:function(l){var a=l.eventData.htmlId;var b=this.getEnd();var e=true;var g=b[1];var k=b[0];for(var f=this.startRow;f<=g;f++){var h=this.parentGridModel._gridModel[f];for(var c=this.startCol;c<=k;c++){if(h[c]&&h[c]!==a){e=false;break}}}if(e===false){Log.debug("isFree false")}return e},canPlaceOverCoveredCells:function(b){b=$A(b);var a=this._getCoveredTableCells();var c=null;c=a.flatten().find(function(e){return !this.canDropHere(e)}.bind(this));return c?false:true},canDropHere:function(a){if(a._canDropHere!==true&&a._canDropHere!==false){var b=$w(a.className).find(function(c){return smarcoms.blockedCellClasses.grep(c).length>0});a._canDropHere=(b?false:true)}return a._canDropHere},_getCoveredTableCells:function(){return $A(this._coveredTableCellsCache)},getModelStart:function(){var c=this.parentGridModel.real2modelRow(this.startRow);var a=this.parentGridModel.real2modelCol(this.startCol);var b=this.parentGridModel.swapModel2realCoords([a,c]);return b},getModelEnd:function(){var c=this.parentGridModel.real2modelRow(this.startRow);var b=this.parentGridModel.real2modelCol(this.startCol);var a=this.parentGridModel.swapModel2realCoords([b+this.cols-1,c+this.rows-1]);return a},getStart:function(){return[this.startCol,this.startRow]},getSize:function(){return[this.getEnd()[0]-this.getStart()[0]+1,this.getEnd()[1]-this.getStart()[1]+1]},getEnd:function(){return[this.startCol+this.cols-1,this.startRow+this.rows-1]},getStartCell:function(){return this._coveredTableCellsCache[0][0]},getEndCell:function(){return this._coveredTableCellsCache[this._coveredTableCellsCache.length-1][this._coveredTableCellsCache[this._coveredTableCellsCache.length-1].length-1]},reset:function(){if(Object.isArray(arguments[0])){this._resetForPoint(arguments[0],arguments[1],(arguments[2]?arguments[2]:false),(arguments[3]?arguments[3]:null))}else{this._resetForElement(arguments[0],(arguments[1]?arguments[1]:false),(arguments[2]?arguments[2]:null))}},_resetForPoint:function(a,e,c,b){Log.ieTrace("ScheduleCellArea._resetForPoint");if(b){this.parentGridModel=b}this.startCol=this.parentGridModel.getTableColForPoint(a[0]);this.startRow=this.parentGridModel.getTableRowForPoint(a[1]);if(c!==true){var f=[a[0]+e[0]-1,a[1]+e[1]-1];this.cols=this.parentGridModel.getTableColForPoint(f[0])-this.startCol+1;this.rows=this.parentGridModel.getTableRowForPoint(f[1])-this.startRow+1}this._fillCoveredTableCellsCache([this.startCol,this.startRow],[this.cols,this.rows])},_fillCoveredTableCellsCache:function(a,m){Log.ieTrace("_fillCoveredTableCellsCache");this._canDropHere=null;this._coveredTableCellsCache=[];var b=a[0];var j=a[0]+m[0]-1;var l=a[1];var g=a[1]+m[1]-1;for(var c=b,h=0;c<=j;c++,h++){var e=[];for(var k=l,f=0;k<=g;k++,f++){e[f]=this.parentGridModel.getTableCell(c,k)}this._coveredTableCellsCache[h]=e}},_resetForElement:function(e,c,b){var a=Position.positionedOffset(e);var f=[e.offsetWidth,e.offsetHeight];this._resetForPoint(a,f,c,b)},destroy:function(){if(this.__coveredTableCellsCache){for(var a=0;a<this.__coveredTableCellsCache.length;a++){this.__coveredTableCellsCache[a]=null}delete this.__coveredTableCellsCache;this.__coveredTableCellsCache=null}this.parentGridModel=null}};var Resizables={resizers:[],observers:[],register:function(a){if(this.resizers.length==0){this.eventMouseUp=this.endResize.bindAsEventListener(this);this.eventMouseMove=this.updateResize.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.resizers.push(a)},unregister:function(a){this.resizers=this.resizers.reject(function(b){return b==a});if(this.resizers.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},unregisterAll:function(){this.resizers=[];Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)},activate:function(a){if(a.options.delay){this._timeout=setTimeout(function(){Resizables._timeout=null;window.focus();Resizables.activeResizable=a}.bind(this),a.options.delay)}else{window.focus();this.activeResizable=a}},deactivate:function(){this.activeResizable=null},updateResize:function(a){if(!this.activeResizable){return}var b=[Event.pointerX(a),Event.pointerY(a)];if(this._lastPointer&&(this._lastPointer.inspect()==b.inspect())){return}this._lastPointer=b;this.activeResizable.updateResize(a,b)},endResize:function(a){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeResizable){return}this._lastPointer=null;this.activeResizable.endResize(a);this.activeResizable=null},keyPress:function(a){if(this.activeResizable){this.activeResizable.keyPress(a)}},addObserver:function(a){this.observers.push(a);this._cacheObserverCallbacks()},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b.element==a});this._cacheObserverCallbacks()},notify:function(a,b,c){if(this[a+"Count"]>0){this.observers.each(function(e){if(e[a]){e[a](a,b,c)}})}if(b.options[a]){b.options[a](b,c)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onResize"].each(function(a){Resizables[a+"Count"]=Resizables.observers.select(function(b){return b[a]}).length})}};var Resizable=Class.create();Resizable._resizing={};Resizable.DIR_LEFT="Left";Resizable.DIR_RIGHT="Right";Resizable.DIR_UP="Up";Resizable.DIR_DOWN="Down";Resizable.HANDLES=["handleLeft","handleRight","handleUp","handleDown"];Resizable.prototype={initialize:function(e){var b=arguments[1];this.options=b;this.element=e;this.resizing=false;this.eventMouseDown=this.initResize.bindAsEventListener(this);for(var c=0;c<4;c++){var a=Resizable.HANDLES[c];var f=b[a];if(f){if(!this[a]){this[a]=$(f)}Event.observe(this[a],"mousedown",this.eventMouseDown)}}Resizables.register(this)},reverteffect:function(e,a,c){var f=this._edim[0]-a;var b=this._edim[1]-c;new Effect.ReSize(e,{direction:"vert",amount:b});new Effect.ReSize(e,{direction:"horizontal",amount:f})},destroy:function(c){for(var b=0;b<4;b++){var a=Resizable.HANDLES[b];if(this[a]){Event.stopObserving(this[a],"mousedown",this.eventMouseDown)}}if(c!==true){Resizables.unregister(this)}},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])},initResize:function(a){Log.debug("initResize");if(typeof Resizable._resizing[this.element]!="undefined"&&Resizable._resizing[this.element]){return}if(Event.isLeftClick(a)){var e=Event.element(a);if((tag_name=e.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return}["Left","Right","Up","Down"].each(function(j){if(this["handle"+j]&&this["handle"+j].className==e.className){this.resizingDirection=j}}.bind(this));var c=[Event.pointerX(a),Event.pointerY(a)];this._initialX=c[0];this._initialY=c[1];var b=Element.getDimensions(this.element);this._edim=[b.width,b.height];this._cdim=[b.width,b.height];this.delta=this.currentDelta();this._min=[1,1];this._max=[0,0];var h=Position.positionedOffset(this.element);this.offset=[0,1].map(function(j){return(c[j]-h[j])});if(this.options.bind==true){this._parentDim=Element.getDimensions(this.element.parentNode);var g=Position.cumulativeOffset(this.element.parentNode);var f=Position.cumulativeOffset(this.element);this.elementOffset=[f[0]-g[0],f[1]-g[1]]}if(this.options.min){if(this.options.min instanceof Array){this._min=this._min.map(function(j,k){return(this.options.min[k]>0?this.options.min[k]:1)}.bind(this))}else{this._min=this._min.map(function(j,k){return(this.options.min>0?this.options.min:1)}.bind(this))}}if(this.options.max){if(this.options.max instanceof Array){this._max=this._max.map(function(j,k){return(this.options.max[k]>=this._min[k])?this.options.max[k]:0}.bind(this))}else{this._max=this._max.map(function(j,k){return(this.options.max>=this._min[k])?this.options.max:0}.bind(this))}}Resizables.activate(this);Event.stop(a)}},startResize:function(b){this.resizing=true;if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);this.element.parentNode.insertBefore(this._clone,this.element);var a=this._clone.style;Position.absolutize(this._clone);if(navigator.appName.indexOf("Microsoft")!=-1&&parseInt(Element.getStyle(this.element,"margin-top"))>0){this.element.style.top=a.marginTop}a.margin="0px"}Resizables.notify("onStart",this,b);if(this.options.starteffect){this.options.starteffect(this.element)}Resizable._resizing[this.element]=true},updateResize:function(a,b){if(!this.resizing){this.startResize(a)}Resizables.notify("onResize",this,a);this.draw(b);if(this.options.change){this.options.change(this)}Event.stop(a)},finishResize:function(b,e){Log.ieTrace("finishResize");this.resizing=false;if(this.options.ghosting){if(navigator.appName.indexOf("Microsoft")!=-1&&parseInt(Element.getStyle(this.element,"margin-top"))>0){this.element.style.top=this._clone.style.marginTop}Element.remove(this._clone);this._clone=null}Resizables.notify("onEnd",this,b);var a=this.options.revert;if(a&&typeof a=="function"){a=a(this.element)}if(a&&this.reverteffect){var c=Element.getDimensions(this.element);this.reverteffect(this.element,c.width,c.height)}if(this.options.zindex){this.element.style.zIndex=this.originalZ}if(this.options.endeffect){this.options.endeffect(this.element)}Resizable._resizing[this.element]=false;Resizables.deactivate(this)},keyPress:function(a){if(a.keyCode!=Event.KEY_ESC){return}this.finishResize(a,false);Event.stop(a)},endResize:function(a){if(!this.resizing){return}this.finishResize(a,true);Event.stop(a)},draw:function(l){var j=Position.positionedOffset(this.element);var f=this.currentDelta();var c=[0,1].map(function(n){return(l[n]-j[n]+f[n]-this.offset[n])}.bind(this));var e=c[0]-f[0];var h=c[1]-f[1];var k;var b;if(!this.resizingDirection){Log.error("Neni nastaven smer zmeny velikosti")}if(this.resizingDirection==Resizable.DIR_LEFT){var m=[c[0]-f[0]+j[0],c[1]-f[1]+j[1]];k=this._cdim[0]-e;b=this._cdim[1]}if(this.resizingDirection==Resizable.DIR_UP){var m=[c[0]-f[0]+j[0],c[1]-f[1]+j[1]];k=this._cdim[0];b=this._cdim[1]-h;if(b<=0||k<=0){return}}if(this.resizingDirection==Resizable.DIR_RIGHT){k=this._edim[0]+e;b=this._edim[1]}if(this.resizingDirection==Resizable.DIR_DOWN){b=this._edim[1]+h;k=this._edim[0]}c[0]=(k>this._min[0])?k:this._min[0];c[1]=(b>this._min[1])?b:this._min[1];if(this.resizingDirection==Resizable.DIR_LEFT||this.resizingDirection==Resizable.DIR_UP){var g=this._applySnap(this.options.snap,m);c[0]+=m[0]-g[0];c[1]+=m[1]-g[1];m=g}if(this.options.snapSize){c=this.options.snapSize(m?m:j,c)}if(this.options.bind){if(this._parentDim.width<=c[0]+this.elementOffset[0]){c[0]=this._parentDim.width-this.elementOffset[0]-2}if(this._parentDim.height<=c[1]+this.elementOffset[1]){c[1]=this._parentDim.height-this.elementOffset[1]-2}}if(this.options.min){c[0]=c[0]>this._min[0]?c[0]:this._min[0];c[1]=c[1]>this._min[1]?c[1]:this._min[1]}if(this.options.max){c[0]=c[0]<this._max[0]?c[0]:(this._max[0]>0?this._max[0]:c[0]);c[1]=c[1]<this._max[1]?c[1]:(this._max[1]>0?this._max[1]:c[1])}if(this.options.checkResize){if(!this.options.checkResize((m?m:[j[0],j[1]]),c)){Log.ieTrace("resize.draw - zamitnuto na checkResize");return}}var a=this.element.style;if(this.resizingDirection==Resizable.DIR_LEFT||this.resizingDirection==Resizable.DIR_RIGHT){a.width=(c[0]-1)+"px";this._cdim[0]=c[0]-1;if(m){a.left=(m[0]+f[0]-j[0])+"px"}}if(this.resizingDirection==Resizable.DIR_DOWN||this.resizingDirection==Resizable.DIR_UP){a.height=(c[1]-1)+"px";this._cdim[1]=c[1]-1;if(m){a.top=(m[1]+f[1]-j[1])+"px"}}if(a.visibility=="hidden"){a.visibility=""}},_applySnap:function(a,b){if(a){if(typeof a=="function"){b=a(b[0],b[1],this)}else{if(a instanceof Array){b=b.map(function(c,e){var f=Math.round(c/a[e])*a[e];return(a[e]>0)?((f>this._min[e])?f:this._min[e]):this._edim[e]}.bind(this))}else{b=b.map(function(c,e){var f=Math.round(c/a)*a-d[e];return(a>0)?((f>this._min[e])?f:this._min[e]):this._edim[e]}.bind(this))}}}return b}};if(!window.smarcoms){window.smarcoms={}}smarcoms.blockedCellClasses=["closedCell","scheduleTimeHeader","horizotalRowHeader"];smarcoms.allowedCellTags=["TD"];smarcoms.PAST_TIME_SCHEDULE_CELL_CLASS="pastTime";smarcoms.Application=Class.create();smarcoms.Application.prototype={schedule:null,emptyCellData:null,reservationData:null,oneDayDate:null,initialize:function(){try{smarcoms.log.init()}catch(b){alert(b.message)}Log.debug("application constructor");var a=$("content");if(a){a.setStyle({visibility:"visible"})}if(window.scheduleData){if(smarcoms.printMode!==true){smarcoms.ScheduleResizer.resizeSchedule(false)}Log.debug("schedule init");Log.time("init");this.initSchedulesAndEvents(scheduleData,smarcoms.printMode);scheduleData=null;delete scheduleData;Log.timeEnd("init")}else{if(smarcoms.printMode!==true){smarcoms.ScheduleResizer.resizeContent()}}if(smarcoms.printMode!==true){smarcoms.date.startActualTimer("mainMenuForm:header_time");Event.observe(window,"resize",function(c){smarcoms.ScheduleResizer.resizeContent()})}Log.info("Application init finished")},initSchedulesAndEvents:function(b,a){if(!b){Log.error("Nebyly predany zadna data o rovzrhu ze serveru. Ukoncuji inicializaci");return}if(b.grids){this.schedule=new smarcoms.Schedule(b,a)}else{Log.error("Nebyly predany zadna data o rovzrhu ze serveru. Ukoncuji inicializaci");Log.debug(b);return}},_destroyModel:function(){if(this.schedule==null){return}this.schedule.destroy();delete this.schedule;this.schedule=null},reinit:function(){var a=null;if(window.scheduleData){a=window.scheduleData}try{smarcoms.Ajax.showOldRichfacesMessageIfHolded();if(window.scheduleData){Log.info("reinit");smarcoms.ScheduleResizer.resizeSchedule(false);Log.info("destroy old model");this._destroyModel();Log.info("init new model");this.initSchedulesAndEvents(a);Log.debug("reinit finished");scheduleData=null;delete scheduleData}else{Log.debug("no scheduleData. only resizing");smarcoms.ScheduleResizer.resizeContent(false)}}catch(b){Log.error(b.name+": "+b.message+" \nIn file: "+b.fileName+" ["+b.lineNumber+"]");Log.error(b.stack)}smarcoms.special.stopScheduleWaiting()},prepareForUpdate:function(){Log.debug("Preparing for update");if(this.schedule){this.schedule.quitUpdater()}},initUpdater:function(){if(this.schedule){this.schedule.initUpdater()}},getEmptyCellClickedData:function(){if(this.emptyCellData){return Object.toJSON(this.emptyCellData)}},getReservationClickedData:function(){if(this.reservationData){return this.reservationData}},getScheduleOneDayDate:function(){if(this.oneDayDate){return this.oneDayDate}},setScheduleOneDayDate:function(a){this.oneDayDate=a}};if(!window.smarcoms){window.smarcoms={}}if(!smarcoms.scriptaculous){smarcoms.scriptaculous={}}smarcoms.scriptaculous.Droppables={drops:[],remove:function(a){this.drops=this.drops.reject(function(b){return b.element==$(a)})},removeAll:function(){this.drops.clear()},add:function(b){b=$(b);var a=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(a.containment){a._containers=[];var c=a.containment;if((typeof c=="object")&&(c.constructor==Array)){c.each(function(e){a._containers.push($(e))})}else{a._containers.push($(c))}}if(a.accept){a.accept=[a.accept].flatten()}a.element=b;this.drops.push(a)},findDeepestChild:function(a){deepest=a[0];for(i=1;i<a.length;++i){if(Element.isParent(a[i].element,deepest.element)){deepest=a[i]}}return deepest},isContained:function(b,a){var c;if(a.tree){c=b.treeNode}else{c=b.parentNode}return a._containers.detect(function(e){return c==e})},isAffected:function(n,h,b){try{var g=(b.element!=h)}catch(k){Log.error("result1")}try{var f=((!b._containers)||this.isContained(h,b))}catch(m){Log.error("result2")}try{var c=((!b.accept)||(Element.classNames(h).detect(function(e){return b.accept.include(e)})))}catch(l){Log.error("result3")}try{var a=Position.within(b.element,n[0],n[1])}catch(j){Log.error("result4");Log.dir(b.element)}var o=(g&&f&&c&&a);return o},deactivate:function(a){if(a.hoverclass){Element.removeClassName(a.element,a.hoverclass)}this.last_active=null},activate:function(a){if(a.hoverclass){Element.addClassName(a.element,a.hoverclass)}this.last_active=a},show:function(a,b){if(!this.drops.length){return}var f=[];if(this.last_active){this.deactivate(this.last_active)}try{this.drops.each(function(e){if(smarcoms.scriptaculous.Droppables.isAffected(a,b,e)){f.push(e)}})}catch(c){Log.dir(c)}if(f.length>0){drop=smarcoms.scriptaculous.Droppables.findDeepestChild(f);Position.within(drop.element,a[0],a[1]);if(drop.onHover){drop.onHover(b,drop.element,Position.overlap(drop.overlap,drop.element))}smarcoms.scriptaculous.Droppables.activate(drop)}},fire:function(b,a){if(!this.last_active){return}Position.prepare();if(this.isAffected([Event.pointerX(b),Event.pointerY(b)],a,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(a,this.last_active.element,b)}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)}}};smarcoms.scriptaculous.Draggables={drags:[],observers:[],register:function(a){if(this.drags.length===0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(a)},unregister:function(a){this.drags=this.drags.reject(function(b){return b==a});if(this.drags.length===0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},unregisterAll:function(){this.drags=[];Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)},activate:function(a){if(a.options.delay){this._timeout=setTimeout(function(){smarcoms.scriptaculous.Draggables._timeout=null;window.focus();smarcoms.scriptaculous.Draggables.activeDraggable=a}.bind(this),a.options.delay)}else{window.focus();this.activeDraggable=a}},deactivate:function(){this.activeDraggable=null},updateDrag:function(a){if(!this.activeDraggable){return}Event.stop(a);var b=[Event.pointerX(a),Event.pointerY(a)];if(this._lastPointer&&(this._lastPointer.inspect()==b.inspect())){return}this._lastPointer=b;this.activeDraggable.updateDrag(a,b)},endDrag:function(a){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeDraggable){return}this._lastPointer=null;this.activeDraggable.endDrag(a);this.activeDraggable=null},keyPress:function(a){if(this.activeDraggable){this.activeDraggable.keyPress(a)}},addObserver:function(a){this.observers.push(a);this._cacheObserverCallbacks()},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b.element==a});this._cacheObserverCallbacks()},notify:function(b,a,c){if(this[b+"Count"]>0){this.observers.each(function(e){if(e[b]){e[b](b,a,c)}})}if(a.options[b]){a.options[b](a,c)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(a){smarcoms.scriptaculous.Draggables[a+"Count"]=smarcoms.scriptaculous.Draggables.observers.select(function(b){return b[a]}).length})}};smarcoms.scriptaculous.Draggable=Class.create();smarcoms.scriptaculous.Draggable._dragging={};smarcoms.scriptaculous.Draggable.prototype={initialize:function(b){var a=arguments[1];a.reverteffect=function(f,e,c){var g=Math.sqrt(Math.abs(e^2)+Math.abs(c^2))*0.02;new Effect.Move(f,{x:-c,y:-e,duration:g,queue:{scope:"_draggable",position:"end"}})};this.element=b;if(!this.handle){this.handle=a.handle}if(!this.handle){this.handle=this.element}if(a.scroll&&!a.scroll.scrollTo&&!a.scroll.outerHTML){a.scroll=a.scroll;this._isScrollChild=Element.childOf(this.element,a.scroll)}this.options=a;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);smarcoms.scriptaculous.Draggables.register(this)},destroy:function(a){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);if(a!==true){smarcoms.scriptaculous.Draggables.unregister(this)}this._oldPosParent=null;this._oldParent=null},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])},initDrag:function(a){if(typeof smarcoms.scriptaculous.Draggable._dragging[this.element]!="undefined"&&smarcoms.scriptaculous.Draggable._dragging[this.element]){return}if(Event.isLeftClick(a)){var c=Event.element(a);if((tag_name=c.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return}var b=[Event.pointerX(a),Event.pointerY(a)];var e=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(f){return(b[f]-e[f])});if(!this.delta){this.delta=this.currentDelta()}smarcoms.scriptaculous.Draggables.activate(this);Event.stop(a)}},startDrag:function(b){this.dragging=true;if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);this.element._originallyAbsolute=(this.element.getStyle("position")=="absolute");if(!this.element._originallyAbsolute){Position.absolutize(this.element)}this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.scroll){if(this.options.scroll==window){var a=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=a.left;this.originalScrollTop=a.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}smarcoms.scriptaculous.Draggables.notify("onStart",this,b);if(this.options.starteffect){this.options.starteffect(this.element)}smarcoms.scriptaculous.Draggable._dragging[this.element]=true},updateDrag:function(event,pointer){if(!this.dragging){this.startDrag(event)}Position.prepare();smarcoms.scriptaculous.Droppables.show(pointer,this.element);smarcoms.scriptaculous.Draggables.notify("onDrag",this,event);this.draw(pointer);if(this.options.change){this.options.change(this)}if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)}var speed=[0,0];if(pointer[0]<(p[0]+this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity)}if(pointer[1]<(p[1]+this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity)}if(pointer[0]>(p[2]-this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity)}if(pointer[1]>(p[3]-this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity)}this.startScrolling(speed)}if(navigator.appVersion.indexOf("AppleWebKit")>0){window.scrollBy(0,0)}Event.stop(event)},finishDrag:function(b,e){Log.ieTrace("Draggable.finishDrag");this.dragging=false;if(this.options.ghosting){if(!this.element._originallyAbsolute){Position.relativize(this.element)}this.element._originallyAbsolute=undefined;Element.remove(this._clone);this._clone=null}Log.ieTrace("Draggable.finishDrag - po likvidaci ghosting");if(e){smarcoms.scriptaculous.Droppables.fire(b,this.element)}smarcoms.scriptaculous.Draggables.notify("onEnd",this,b);var a=this.options.revert;if(a&&typeof a=="function"){a=a(this.element)}if(this._outOfBox){this._oldParent.insert(this.element);this._outOfBox=false;this._oldPosParent=null;this._oldParent=null}var c=this.currentDelta();if(a&&this.options.reverteffect){this.options.reverteffect(this.element,c[1]-this.delta[1],c[0]-this.delta[0])}else{this.delta=c}if(this.options.zindex){this.element.style.zIndex=this.originalZ}if(this.options.endeffect){this.options.endeffect(this.element)}smarcoms.scriptaculous.Draggable._dragging[this.element]=false;smarcoms.scriptaculous.Draggables.deactivate(this);smarcoms.scriptaculous.Droppables.reset()},keyPress:function(a){if(a.keyCode!=Event.KEY_ESC){return}this.finishDrag(a,false);Event.stop(a)},endDrag:function(a){Log.ieTrace("Draggable.endDrag");if(!this.dragging){return}this.stopScrolling();this.finishDrag(a,true);Event.stop(a)},draw:function(a){var g=Position.cumulativeOffset(this.element);if(this.options.ghosting){var c=Position.realOffset(this.element);g[0]+=c[0]-Position.deltaX;g[1]+=c[1]-Position.deltaY}var f=this.currentDelta();g[0]-=f[0];g[1]-=f[1];if(this.options.scroll){g[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;g[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var e=[0,1].map(function(h){return(a[h]-g[h]-this.offset[h])}.bind(this));if(this.options.snap&&!this._outOfBox){if(typeof this.options.snap=="function"){e=this.options.snap(e[0],e[1],this)}else{if(this.options.snap instanceof Array){e=e.map(function(h,j){return Math.round(h/this.options.snap[j])*this.options.snap[j]}.bind(this))}else{e=e.map(function(h){return Math.round(h/this.options.snap)*this.options.snap}.bind(this))}}}if(this.options.scroll&&this.options.scroll!=window){this._handleScroolOutOfBox(e)}var b=this.element.style;if((!this.options.constraint)||(this.options.constraint=="horizontal")){b.left=e[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){b.top=e[1]+"px"}if(b.visibility=="hidden"){b.visibility=""}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;smarcoms.scriptaculous.Draggables._lastScrollPointer=null}},startScrolling:function(a){if(!(a[0]||a[1])){return}this.scrollSpeed=[a[0]*this.options.scrollSpeed,a[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var current=new Date();var delta=current-this.lastScrolled;this.lastScrolled=current;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000}Position.prepare();smarcoms.scriptaculous.Droppables.show(smarcoms.scriptaculous.Draggables._lastPointer,this.element);smarcoms.scriptaculous.Draggables.notify("onDrag",this);if(this._isScrollChild){smarcoms.scriptaculous.Draggables._lastScrollPointer=smarcoms.scriptaculous.Draggables._lastScrollPointer||$A(smarcoms.scriptaculous.Draggables._lastPointer);smarcoms.scriptaculous.Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;smarcoms.scriptaculous.Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;if(smarcoms.scriptaculous.Draggables._lastScrollPointer[0]<0){smarcoms.scriptaculous.Draggables._lastScrollPointer[0]=0}if(smarcoms.scriptaculous.Draggables._lastScrollPointer[1]<0){smarcoms.scriptaculous.Draggables._lastScrollPointer[1]=0}this.draw(smarcoms.scriptaculous.Draggables._lastScrollPointer)}if(this.options.change){this.options.change(this)}},_handleScroolOutOfBox:function(b){if(this._outOfBox){var a=Position.cumulativeOffset(this._oldPosParent);if(b[1]>(a[1]+10)){$(this._oldParent).insert(this.element);Log.debug("returning inbox");this._outOfBox=false;this._oldPosParent=null;this._oldParent=null}}if(b[1]<0){this._oldPosParent=this.element.getOffsetParent();this._oldParent=this.element.parentNode;document.body.insert(this.element);this._outOfBox=true;Log.debug("getting out of box")}},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}}};if(!window.smarcoms){window.smarcoms={}}smarcoms.Ajax={JSF_VIEW_STATE_ELM_NAME:"javax.faces.ViewState",COMMON_AJAX_REQ_METHOD:"get",AJAX_REQ_MARKER_STRING:"ajax",RESERVATION_MOVE_INDICATION_VALUE:"reseravtionMoved",SCHEDULE_CHANGE_QUESTION_INDICATION_VALUE:"shouldUpdateScheduleQuestion",JSON_DATA_PARAM_NAME:"data",richMessageHolder:null,sendEventChange:function(c,a){Log.ieTrace("Ajax.sendEventChange");App.schedule.quitUpdater();a.refreshEventData();var b={eventData:a.eventData};this.sendScheduleAjaxRequest(this.RESERVATION_MOVE_INDICATION_VALUE,b,true,function(f){var e=f.responseJSON;Log.info("odpoved na ajax request  byla: ",f.responseText);Log.info("odpoved na ajax request  byla v JSON: ",e);smarcoms.special.stopScheduleWaiting();App.schedule.onReservationMoveConfirmed(e.response);if(e){if(e.richMessageHtml){smarcoms.Ajax.richMessageHolder=e;smarcoms.Ajax.showOldRichfacesMessageIfHolded()}else{Log.warn("Neuspesny pokus o presunuti rezervace, ale nedorazila zprava pro rich:messages")}}else{Log.warn("Nemam objekt s odpovedi po pokusu o presun rezervace.")}App.schedule.initUpdater();App.schedule.stopOnclick=false;App.schedule._stopNotePopups=false})},checkScheduleChange:function(){Log.ieTrace("Ajax.checkScheduleChange");this.sendScheduleAjaxRequest(this.SCHEDULE_CHANGE_QUESTION_INDICATION_VALUE,null,false,function(b){var a=b.responseJSON;if(b.status!=200){Log.warn("Chyba kontroly rozvrhu",b.status);smarcoms.Modal.showError(smarcoms.log.FAILURE_NETWORK_ERROR)}else{if(a){if(a.response.modelChanged){Log.info("zmeny rozvrhu zaznamenany -> update");App.schedule.handleChanges(a.response.modelChanges)}if(a.response.pastTimeData){App.schedule.updatePastTimeData(a.response.pastTimeData)}if(!App.schedule.updater){App.schedule.initUpdater()}}}})},sendScheduleAjaxRequest:function(h,f,a,j){Log.ieTrace("Ajax.sendScheduleAjaxRequest");var g=App.schedule;var c=this.prepareJsfViewStateForRequest({});c[g.scheduleData.clientId]=h;c[this.JSON_DATA_PARAM_NAME]=Object.toJSON(f);var e=$H(c).toQueryString();var b=this.getPostbackURL();if(a){smarcoms.special.startScheduleWaiting()}var k=new Ajax.Request(b,{method:this.COMMON_AJAX_REQ_METHOD,parameters:e,onSuccess:j,onFailure:this.onFailure})},forceScheduleUpdate:function(){App.schedule.quitUpdater();App.schedule.updateSchedule()},prepareJsfViewStateForRequest:function(b){b[this.JSF_VIEW_STATE_ELM_NAME]=$(this.JSF_VIEW_STATE_ELM_NAME).value;var a=this.getCurrentFormId();b[a]=a;return b},getPostbackURL:function(){return($("cdForm").action)},getCurrentFormId:function(){return($("cdForm").id)},onFailure:function(b){var a=smarcoms.log.FAILURE_UNKNOWN_ERROR;if(b.responseJSON){a=b.responseJSON.response.errorMsg}else{if(b.status==500){if(b.responseText&&b.responseText.indexOf("ViewExpiredException")!=-1){Log.warn("Obrzena ViewExpiredException ze serveru");if(window.App&&App.schedule){App.schedule.quitUpdater()}return}}}Log.warn(b);App.schedule.stopOnclick=false;App.schedule._stopNotePopups=false;smarcoms.Modal.showError(a);App.schedule.quitUpdater()},showOldRichfacesMessageIfHolded:function(){if(this.richMessageHolder){var a=this.richMessageHolder;this.richMessageHolder=null;if(a.richMessageId){if(a.inner){var b=$(a.richMessageId);b.innerHTML=a.richMessageHtml;b.show()}else{$(a.richMessageId).replace(a.richMessageHtml)}}}},keepActualRichfacesMessage:function(c){var a=$(c);if(a&&a.visible()){var b=a.innerHTML;this.richMessageHolder={richMessageHtml:b,richMessageId:c,inner:true}}}};Protoload={timeUntilShow:250,opacity:0.8,startWaiting:function(a,b,f){if(typeof a=="string"){a=document.getElementById(a)}if(b==undefined){b="waiting"}if(f==undefined){f=Protoload.timeUntilShow}a._waiting=true;if(!a._loading){var c=document.createElement("div");$(a.offsetParent||document.body).insert(a._loading=c);a.appendChild(a._loading=c);c.style.position="absolute";try{c.style.opacity=Protoload.opacity}catch(c){}try{c.style.MozOpacity=Protoload.opacity}catch(c){}try{c.style.filter="alpha(opacity="+Math.round(Protoload.opacity*100)+")"}catch(c){}try{c.style.KhtmlOpacity=Protoload.opacity}catch(c){}}a._loading.className=b;window.setTimeout((function(){if(this._waiting){var k=this.offsetLeft,j=this.offsetTop,h=this.offsetWidth,e=this.offsetHeight,g=this._loading;g.style.left=k+"px";g.style.top=j+"px";g.style.width=h+"px";g.style.height=e+"px";g.style.display="inline"}}).bind(a),f)},stopWaiting:function(a){if(a._waiting){a._waiting=false;a._loading.parentNode.removeChild(a._loading);a._loading=null}}};if(Prototype){Element.addMethods(Protoload);Object.extend(Element,Protoload)};