text: /*! FlodCalendar 26-08-2015 */
  !function(a,b){function c(b,c){var e,f,g,h=b.nodeName.toLowerCase();return"area"===h?(e=b.parentNode,f=e.name,b.href&&f&&"map"===e.nodeName.toLowerCase()?(g=a("img[usemap=#"+f+"]")[0],!!g&&d(g)):!1):(/input|select|textarea|button|object/.test(h)?!b.disabled:"a"===h?b.href||c:c)&&d(b)}function d(b){return a.expr.filters.visible(b)&&!a(b).parents().addBack().filter(function(){return"hidden"===a.css(this,"visibility")}).length}var e=0,f=/^ui-id-\d+$/;a.ui=a.ui||{},a.extend(a.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),a.fn.extend({focus:function(b){return function(c,d){return"number"==typeof c?this.each(function(){var b=this;setTimeout(function(){a(b).focus(),d&&d.call(b)},c)}):b.apply(this,arguments)}}(a.fn.focus),scrollParent:function(){var b;return b=a.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.css(this,"position"))&&/(auto|scroll)/.test(a.css(this,"overflow")+a.css(this,"overflow-y")+a.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(a.css(this,"overflow")+a.css(this,"overflow-y")+a.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length)for(var d,e,f=a(this[0]);f.length&&f[0]!==document;){if(d=f.css("position"),("absolute"===d||"relative"===d||"fixed"===d)&&(e=parseInt(f.css("zIndex"),10),!isNaN(e)&&0!==e))return e;f=f.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})},removeUniqueId:function(){return this.each(function(){f.test(this.id)&&a(this).removeAttr("id")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a("<a>").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function e(b,c,d,e){return a.each(f,function(){c-=parseFloat(a.css(b,"padding"+this))||0,d&&(c-=parseFloat(a.css(b,"border"+this+"Width"))||0),e&&(c-=parseFloat(a.css(b,"margin"+this))||0)}),c}var f="Width"===d?["Left","Right"]:["Top","Bottom"],g=d.toLowerCase(),h={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?h["inner"+d].call(this):this.each(function(){a(this).css(g,e(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return"number"!=typeof b?h["outer"+d].call(this,b):this.each(function(){a(this).css(g,e(this,b,!0,c)+"px")})}}),a.fn.addBack||(a.fn.addBack=function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}),a("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(a.fn.removeData=function(b){return function(c){return arguments.length?b.call(this,a.camelCase(c)):b.call(this)}}(a.fn.removeData)),a.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),a.support.selectstart="onselectstart"in document.createElement("div"),a.fn.extend({disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e,f=a.ui[b].prototype;for(e in d)f.plugins[e]=f.plugins[e]||[],f.plugins[e].push([c,d[e]])},call:function(a,b,c){var d,e=a.plugins[b];if(e&&a.element[0].parentNode&&11!==a.element[0].parentNode.nodeType)for(d=0;e.length>d;d++)a.options[e[d][0]]&&e[d][1].apply(a.element,c)}},hasScroll:function(b,c){if("hidden"===a(b).css("overflow"))return!1;var d=c&&"left"===c?"scrollLeft":"scrollTop",e=!1;return b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)}})}(jQuery),function(a,b){var c=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(var c,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(c,d,e){var f,g,h,i,j={},k=c.split(".")[0];c=c.split(".")[1],f=k+"-"+c,e||(e=d,d=a.Widget),a.expr[":"][f.toLowerCase()]=function(b){return!!a.data(b,f)},a[k]=a[k]||{},g=a[k][c],h=a[k][c]=function(a,c){return this._createWidget?(arguments.length&&this._createWidget(a,c),b):new h(a,c)},a.extend(h,g,{version:e.version,_proto:a.extend({},e),_childConstructors:[]}),i=new d,i.options=a.widget.extend({},i.options),a.each(e,function(c,e){return a.isFunction(e)?(j[c]=function(){var a=function(){return d.prototype[c].apply(this,arguments)},b=function(a){return d.prototype[c].apply(this,a)};return function(){var c,d=this._super,f=this._superApply;return this._super=a,this._superApply=b,c=e.apply(this,arguments),this._super=d,this._superApply=f,c}}(),b):(j[c]=e,b)}),h.prototype=a.widget.extend(i,{widgetEventPrefix:g?i.widgetEventPrefix:c},j,{constructor:h,namespace:k,widgetName:c,widgetFullName:f}),g?(a.each(g._childConstructors,function(b,c){var d=c.prototype;a.widget(d.namespace+"."+d.widgetName,h,c._proto)}),delete g._childConstructors):d._childConstructors.push(h),a.widget.bridge(c,h)},a.widget.extend=function(c){for(var e,f,g=d.call(arguments,1),h=0,i=g.length;i>h;h++)for(e in g[h])f=g[h][e],g[h].hasOwnProperty(e)&&f!==b&&(c[e]=a.isPlainObject(f)?a.isPlainObject(c[e])?a.widget.extend({},c[e],f):a.widget.extend({},f):f);return c},a.widget.bridge=function(c,e){var f=e.prototype.widgetFullName||c;a.fn[c]=function(g){var h="string"==typeof g,i=d.call(arguments,1),j=this;return g=!h&&i.length?a.widget.extend.apply(null,[g].concat(i)):g,this.each(h?function(){var d,e=a.data(this,f);return e?a.isFunction(e[g])&&"_"!==g.charAt(0)?(d=e[g].apply(e,i),d!==e&&d!==b?(j=d&&d.jquery?j.pushStack(d.get()):d,!1):b):a.error("no such method '"+g+"' for "+c+" widget instance"):a.error("cannot call methods on "+c+" prior to initialization; attempted to call method '"+g+"'")}:function(){var b=a.data(this,f);b?b.option(g||{})._init():a.data(this,f,new e(g,this))}),j}},a.Widget=function(){},a.Widget._childConstructors=[],a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(b,d){d=a(d||this.defaultElement||this)[0],this.element=a(d),this.uuid=c++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=a.widget.extend({},this.options,this._getCreateOptions(),b),this.bindings=a(),this.hoverable=a(),this.focusable=a(),d!==this&&(a.data(d,this.widgetFullName,this),this._on(!0,this.element,{remove:function(a){a.target===d&&this.destroy()}}),this.document=a(d.style?d.ownerDocument:d.document||d),this.window=a(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:a.noop,_getCreateEventData:a.noop,_create:a.noop,_init:a.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(a.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:a.noop,widget:function(){return this.element},option:function(c,d){var e,f,g,h=c;if(0===arguments.length)return a.widget.extend({},this.options);if("string"==typeof c)if(h={},e=c.split("."),c=e.shift(),e.length){for(f=h[c]=a.widget.extend({},this.options[c]),g=0;e.length-1>g;g++)f[e[g]]=f[e[g]]||{},f=f[e[g]];if(c=e.pop(),d===b)return f[c]===b?null:f[c];f[c]=d}else{if(d===b)return this.options[c]===b?null:this.options[c];h[c]=d}return this._setOptions(h),this},_setOptions:function(a){var b;for(b in a)this._setOption(b,a[b]);return this},_setOption:function(a,b){return this.options[a]=b,"disabled"===a&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!b).attr("aria-disabled",b),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(c,d,e){var f,g=this;"boolean"!=typeof c&&(e=d,d=c,c=!1),e?(d=f=a(d),this.bindings=this.bindings.add(d)):(e=d,d=this.element,f=this.widget()),a.each(e,function(e,h){function i(){return c||g.options.disabled!==!0&&!a(this).hasClass("ui-state-disabled")?("string"==typeof h?g[h]:h).apply(g,arguments):b}"string"!=typeof h&&(i.guid=h.guid=h.guid||i.guid||a.guid++);var j=e.match(/^(\w+)\s*(.*)$/),k=j[1]+g.eventNamespace,l=j[2];l?f.delegate(l,k,i):d.bind(k,i)})},_off:function(a,b){b=(b||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,a.unbind(b).undelegate(b)},_delay:function(a,b){function c(){return("string"==typeof a?d[a]:a).apply(d,arguments)}var d=this;return setTimeout(c,b||0)},_hoverable:function(b){this.hoverable=this.hoverable.add(b),this._on(b,{mouseenter:function(b){a(b.currentTarget).addClass("ui-state-hover")},mouseleave:function(b){a(b.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(b){this.focusable=this.focusable.add(b),this._on(b,{focusin:function(b){a(b.currentTarget).addClass("ui-state-focus")},focusout:function(b){a(b.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(b,c,d){var e,f,g=this.options[b];if(d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent)for(e in f)e in c||(c[e]=f[e]);return this.element.trigger(c,d),!(a.isFunction(g)&&g.apply(this.element[0],[c].concat(d))===!1||c.isDefaultPrevented())}},a.each({show:"fadeIn",hide:"fadeOut"},function(b,c){a.Widget.prototype["_"+b]=function(d,e,f){"string"==typeof e&&(e={effect:e});var g,h=e?e===!0||"number"==typeof e?c:e.effect||c:b;e=e||{},"number"==typeof e&&(e={duration:e}),g=!a.isEmptyObject(e),e.complete=f,e.delay&&d.delay(e.delay),g&&a.effects&&a.effects.effect[h]?d[b](e):h!==b&&d[h]?d[h](e.duration,e.easing,f):d.queue(function(c){a(this)[b](),f&&f.call(d[0]),c()})}})}(jQuery),function(a){var b=!1;a(document).mouseup(function(){b=!1}),a.widget("ui.mouse",{version:"1.10.3",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(c){return!0===a.data(c.target,b.widgetName+".preventClickEvent")?(a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(c){if(!b){this._mouseStarted&&this._mouseUp(c),this._mouseDownEvent=c;var d=this,e=1===c.which,f="string"==typeof this.options.cancel&&c.target.nodeName?a(c.target).closest(this.options.cancel).length:!1;return e&&!f&&this._mouseCapture(c)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(c)&&this._mouseDelayMet(c)&&(this._mouseStarted=this._mouseStart(c)!==!1,!this._mouseStarted)?(c.preventDefault(),!0):(!0===a.data(c.target,this.widgetName+".preventClickEvent")&&a.removeData(c.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(a){return d._mouseMove(a)},this._mouseUpDelegate=function(a){return d._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),c.preventDefault(),b=!0,!0)):!0}},_mouseMove:function(b){return a.ui.ie&&(!document.documentMode||9>document.documentMode)&&!b.button?this._mouseUp(b):this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted)},_mouseUp:function(b){return a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target===this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(a){a.widget("ui.draggable",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(b){var c=this.options;return this.helper||c.disabled||a(b.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(b),this.handle?(a(c.iframeFix===!0?"iframe":c.iframeFix).each(function(){a("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(a(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(b){var c=this.options;return this.helper=this._createHelper(b),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),a.ui.ddmanager&&(a.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),this._setContainment(),this._trigger("start",b)===!1?(this._clear(),!1):(this._cacheHelperProportions(),a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this._mouseDrag(b,!0),a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,b),!0)},_mouseDrag:function(b,c){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),!c){var d=this._uiHash();if(this._trigger("drag",b,d)===!1)return this._mouseUp({}),!1;this.position=d.position}return this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),!1},_mouseStop:function(b){var c=this,d=!1;return a.ui.ddmanager&&!this.options.dropBehaviour&&(d=a.ui.ddmanager.drop(this,b)),this.dropped&&(d=this.dropped,this.dropped=!1),"original"!==this.options.helper||a.contains(this.element[0].ownerDocument,this.element[0])?("invalid"===this.options.revert&&!d||"valid"===this.options.revert&&d||this.options.revert===!0||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d)?a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){c._trigger("stop",b)!==!1&&c._clear()}):this._trigger("stop",b)!==!1&&this._clear(),!1):!1},_mouseUp:function(b){return a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b),a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(b){return this.options.handle?!!a(b.target).closest(this.element.find(this.options.handle)).length:!0},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b])):"clone"===c.helper?this.element.clone().removeAttr("id"):this.element;return d.parents("body").length||d.appendTo("parent"===c.appendTo?this.element[0].parentNode:c.appendTo),d[0]===this.element[0]||/(fixed|absolute)/.test(d.css("position"))||d.css("position","absolute"),d},_adjustOffsetFromHelper:function(b){"string"==typeof b&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){var b=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&a.ui.ie)&&(b={top:0,left:0}),{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b,c,d,e=this.options;return e.containment?"window"===e.containment?void(this.containment=[a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,a(window).scrollLeft()+a(window).width()-this.helperProportions.width-this.margins.left,a(window).scrollTop()+(a(window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]):"document"===e.containment?void(this.containment=[0,0,a(document).width()-this.helperProportions.width-this.margins.left,(a(document).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]):e.containment.constructor===Array?void(this.containment=e.containment):("parent"===e.containment&&(e.containment=this.helper[0].parentNode),c=a(e.containment),d=c[0],void(d&&(b="hidden"!==c.css("overflow"),this.containment=[(parseInt(c.css("borderLeftWidth"),10)||0)+(parseInt(c.css("paddingLeft"),10)||0),(parseInt(c.css("borderTopWidth"),10)||0)+(parseInt(c.css("paddingTop"),10)||0),(b?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(c.css("borderRightWidth"),10)||0)-(parseInt(c.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(b?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(c.css("borderBottomWidth"),10)||0)-(parseInt(c.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=c))):void(this.containment=null)},_convertPositionTo:function(b,c){c||(c=this.position);var d="absolute"===b?1:-1,e="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent;return this.offset.scroll||(this.offset.scroll={top:e.scrollTop(),left:e.scrollLeft()}),{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top)*d,left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)*d}},_generatePosition:function(b){var c,d,e,f,g=this.options,h="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=b.pageX,j=b.pageY;return this.offset.scroll||(this.offset.scroll={top:h.scrollTop(),left:h.scrollLeft()}),this.originalPosition&&(this.containment&&(this.relative_container?(d=this.relative_container.offset(),c=[this.containment[0]+d.left,this.containment[1]+d.top,this.containment[2]+d.left,this.containment[3]+d.top]):c=this.containment,b.pageX-this.offset.click.left<c[0]&&(i=c[0]+this.offset.click.left),b.pageY-this.offset.click.top<c[1]&&(j=c[1]+this.offset.click.top),b.pageX-this.offset.click.left>c[2]&&(i=c[2]+this.offset.click.left),b.pageY-this.offset.click.top>c[3]&&(j=c[3]+this.offset.click.top)),g.grid&&(e=g.grid[1]?this.originalPageY+Math.round((j-this.originalPageY)/g.grid[1])*g.grid[1]:this.originalPageY,j=c?e-this.offset.click.top>=c[1]||e-this.offset.click.top>c[3]?e:e-this.offset.click.top>=c[1]?e-g.grid[1]:e+g.grid[1]:e,f=g.grid[0]?this.originalPageX+Math.round((i-this.originalPageX)/g.grid[0])*g.grid[0]:this.originalPageX,i=c?f-this.offset.click.left>=c[0]||f-this.offset.click.left>c[2]?f:f-this.offset.click.left>=c[0]?f-g.grid[0]:f+g.grid[0]:f)),{top:j-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():this.offset.scroll.top),left:i-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(b,c,d){return d=d||this._uiHash(),a.ui.plugin.call(this,b,[c,d]),"drag"===b&&(this.positionAbs=this._convertPositionTo("absolute")),a.Widget.prototype._trigger.call(this,b,c,d)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),a.ui.plugin.add("draggable","connectToSortable",{start:function(b,c){var d=a(this).data("ui-draggable"),e=d.options,f=a.extend({},c,{item:d.element});d.sortables=[],a(e.connectToSortable).each(function(){var c=a.data(this,"ui-sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",b,f))})},stop:function(b,c){var d=a(this).data("ui-draggable"),e=a.extend({},c,{item:d.element});a.each(d.sortables,function(){this.instance.isOver?(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(b),this.instance.options.helper=this.instance.options._helper,"original"===d.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",b,e))})},drag:function(b,c){var d=a(this).data("ui-draggable"),e=this;a.each(d.sortables,function(){var f=!1,g=this;this.instance.positionAbs=d.positionAbs,this.instance.helperProportions=d.helperProportions,this.instance.offset.click=d.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(f=!0,a.each(d.sortables,function(){return this.instance.positionAbs=d.positionAbs,this.instance.helperProportions=d.helperProportions,this.instance.offset.click=d.offset.click,this!==g&&this.instance._intersectsWith(this.instance.containerCache)&&a.contains(g.instance.element[0],this.instance.element[0])&&(f=!1),f})),f?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(e).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return c.helper[0]},b.target=this.instance.currentItem[0],this.instance._mouseCapture(b,!0),this.instance._mouseStart(b,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",b),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(b)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",b,this.instance._uiHash(this.instance)),this.instance._mouseStop(b,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",b),d.dropped=!1)})}}),a.ui.plugin.add("draggable","cursor",{start:function(){var b=a("body"),c=a(this).data("ui-draggable").options;b.css("cursor")&&(c._cursor=b.css("cursor")),b.css("cursor",c.cursor)},stop:function(){var b=a(this).data("ui-draggable").options;b._cursor&&a("body").css("cursor",b._cursor)}}),a.ui.plugin.add("draggable","opacity",{start:function(b,c){var d=a(c.helper),e=a(this).data("ui-draggable").options;d.css("opacity")&&(e._opacity=d.css("opacity")),d.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("ui-draggable").options;d._opacity&&a(c.helper).css("opacity",d._opacity)}}),a.ui.plugin.add("draggable","scroll",{start:function(){var b=a(this).data("ui-draggable");b.scrollParent[0]!==document&&"HTML"!==b.scrollParent[0].tagName&&(b.overflowOffset=b.scrollParent.offset())},drag:function(b){var c=a(this).data("ui-draggable"),d=c.options,e=!1;c.scrollParent[0]!==document&&"HTML"!==c.scrollParent[0].tagName?(d.axis&&"x"===d.axis||(c.overflowOffset.top+c.scrollParent[0].offsetHeight-b.pageY<d.scrollSensitivity?c.scrollParent[0].scrollTop=e=c.scrollParent[0].scrollTop+d.scrollSpeed:b.pageY-c.overflowOffset.top<d.scrollSensitivity&&(c.scrollParent[0].scrollTop=e=c.scrollParent[0].scrollTop-d.scrollSpeed)),d.axis&&"y"===d.axis||(c.overflowOffset.left+c.scrollParent[0].offsetWidth-b.pageX<d.scrollSensitivity?c.scrollParent[0].scrollLeft=e=c.scrollParent[0].scrollLeft+d.scrollSpeed:b.pageX-c.overflowOffset.left<d.scrollSensitivity&&(c.scrollParent[0].scrollLeft=e=c.scrollParent[0].scrollLeft-d.scrollSpeed))):(d.axis&&"x"===d.axis||(b.pageY-a(document).scrollTop()<d.scrollSensitivity?e=a(document).scrollTop(a(document).scrollTop()-d.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<d.scrollSensitivity&&(e=a(document).scrollTop(a(document).scrollTop()+d.scrollSpeed))),d.axis&&"y"===d.axis||(b.pageX-a(document).scrollLeft()<d.scrollSensitivity?e=a(document).scrollLeft(a(document).scrollLeft()-d.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<d.scrollSensitivity&&(e=a(document).scrollLeft(a(document).scrollLeft()+d.scrollSpeed)))),e!==!1&&a.ui.ddmanager&&!d.dropBehaviour&&a.ui.ddmanager.prepareOffsets(c,b)}}),a.ui.plugin.add("draggable","snap",{start:function(){var b=a(this).data("ui-draggable"),c=b.options;b.snapElements=[],a(c.snap.constructor!==String?c.snap.items||":data(ui-draggable)":c.snap).each(function(){var c=a(this),d=c.offset();this!==b.element[0]&&b.snapElements.push({item:this,width:c.outerWidth(),height:c.outerHeight(),top:d.top,left:d.left})})},drag:function(b,c){var d,e,f,g,h,i,j,k,l,m,n=a(this).data("ui-draggable"),o=n.options,p=o.snapTolerance,q=c.offset.left,r=q+n.helperProportions.width,s=c.offset.top,t=s+n.helperProportions.height;for(l=n.snapElements.length-1;l>=0;l--)h=n.snapElements[l].left,i=h+n.snapElements[l].width,j=n.snapElements[l].top,k=j+n.snapElements[l].height,h-p>r||q>i+p||j-p>t||s>k+p||!a.contains(n.snapElements[l].item.ownerDocument,n.snapElements[l].item)?(n.snapElements[l].snapping&&n.options.snap.release&&n.options.snap.release.call(n.element,b,a.extend(n._uiHash(),{snapItem:n.snapElements[l].item})),n.snapElements[l].snapping=!1):("inner"!==o.snapMode&&(d=p>=Math.abs(j-t),e=p>=Math.abs(k-s),f=p>=Math.abs(h-r),g=p>=Math.abs(i-q),d&&(c.position.top=n._convertPositionTo("relative",{top:j-n.helperProportions.height,left:0}).top-n.margins.top),e&&(c.position.top=n._convertPositionTo("relative",{top:k,left:0}).top-n.margins.top),f&&(c.position.left=n._convertPositionTo("relative",{top:0,left:h-n.helperProportions.width}).left-n.margins.left),g&&(c.position.left=n._convertPositionTo("relative",{top:0,left:i}).left-n.margins.left)),m=d||e||f||g,"outer"!==o.snapMode&&(d=p>=Math.abs(j-s),e=p>=Math.abs(k-t),f=p>=Math.abs(h-q),g=p>=Math.abs(i-r),d&&(c.position.top=n._convertPositionTo("relative",{top:j,left:0}).top-n.margins.top),e&&(c.position.top=n._convertPositionTo("relative",{top:k-n.helperProportions.height,left:0}).top-n.margins.top),f&&(c.position.left=n._convertPositionTo("relative",{top:0,left:h}).left-n.margins.left),g&&(c.position.left=n._convertPositionTo("relative",{top:0,left:i-n.helperProportions.width}).left-n.margins.left)),!n.snapElements[l].snapping&&(d||e||f||g||m)&&n.options.snap.snap&&n.options.snap.snap.call(n.element,b,a.extend(n._uiHash(),{snapItem:n.snapElements[l].item})),n.snapElements[l].snapping=d||e||f||g||m)}}),a.ui.plugin.add("draggable","stack",{start:function(){var b,c=this.data("ui-draggable").options,d=a.makeArray(a(c.stack)).sort(function(b,c){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(c).css("zIndex"),10)||0)});d.length&&(b=parseInt(a(d[0]).css("zIndex"),10)||0,a(d).each(function(c){a(this).css("zIndex",b+c)}),this.css("zIndex",b+d.length))}}),a.ui.plugin.add("draggable","zIndex",{start:function(b,c){var d=a(c.helper),e=a(this).data("ui-draggable").options;d.css("zIndex")&&(e._zIndex=d.css("zIndex")),d.css("zIndex",e.zIndex)},stop:function(b,c){var d=a(this).data("ui-draggable").options;d._zIndex&&a(c.helper).css("zIndex",d._zIndex)}})}(jQuery),function(a){function b(a,b,c){return a>b&&b+c>a}a.widget("ui.droppable",{version:"1.10.3",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var b=this.options,c=b.accept;this.isover=!1,this.isout=!0,this.accept=a.isFunction(c)?c:function(a){return a.is(c);
  
  },this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},a.ui.ddmanager.droppables[b.scope]=a.ui.ddmanager.droppables[b.scope]||[],a.ui.ddmanager.droppables[b.scope].push(this),b.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){for(var b=0,c=a.ui.ddmanager.droppables[this.options.scope];c.length>b;b++)c[b]===this&&c.splice(b,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(b,c){"accept"===b&&(this.accept=a.isFunction(c)?c:function(a){return a.is(c)}),a.Widget.prototype._setOption.apply(this,arguments)},_activate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),c&&this._trigger("activate",b,this.ui(c))},_deactivate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),c&&this._trigger("deactivate",b,this.ui(c))},_over:function(b){var c=a.ui.ddmanager.current;c&&(c.currentItem||c.element)[0]!==this.element[0]&&this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",b,this.ui(c)))},_out:function(b){var c=a.ui.ddmanager.current;c&&(c.currentItem||c.element)[0]!==this.element[0]&&this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",b,this.ui(c)))},_drop:function(b,c){var d=c||a.ui.ddmanager.current,e=!1;return d&&(d.currentItem||d.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var b=a.data(this,"ui-droppable");return b.options.greedy&&!b.options.disabled&&b.options.scope===d.options.scope&&b.accept.call(b.element[0],d.currentItem||d.element)&&a.ui.intersect(d,a.extend(b,{offset:b.element.offset()}),b.options.tolerance)?(e=!0,!1):void 0}),e?!1:this.accept.call(this.element[0],d.currentItem||d.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",b,this.ui(d)),this.element):!1):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}}),a.ui.intersect=function(a,c,d){if(!c.offset)return!1;var e,f,g=(a.positionAbs||a.position.absolute).left,h=g+a.helperProportions.width,i=(a.positionAbs||a.position.absolute).top,j=i+a.helperProportions.height,k=c.offset.left,l=k+c.proportions.width,m=c.offset.top,n=m+c.proportions.height;switch(d){case"fit":return g>=k&&l>=h&&i>=m&&n>=j;case"intersect":return g+a.helperProportions.width/2>k&&l>h-a.helperProportions.width/2&&i+a.helperProportions.height/2>m&&n>j-a.helperProportions.height/2;case"pointer":return e=(a.positionAbs||a.position.absolute).left+(a.clickOffset||a.offset.click).left,f=(a.positionAbs||a.position.absolute).top+(a.clickOffset||a.offset.click).top,b(f,m,c.proportions.height)&&b(e,k,c.proportions.width);case"touch":return(i>=m&&n>=i||j>=m&&n>=j||m>i&&j>n)&&(g>=k&&l>=g||h>=k&&l>=h||k>g&&h>l);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var d,e,f=a.ui.ddmanager.droppables[b.options.scope]||[],g=c?c.type:null,h=(b.currentItem||b.element).find(":data(ui-droppable)").addBack();a:for(d=0;f.length>d;d++)if(!(f[d].options.disabled||b&&!f[d].accept.call(f[d].element[0],b.currentItem||b.element))){for(e=0;h.length>e;e++)if(h[e]===f[d].element[0]){f[d].proportions.height=0;continue a}f[d].visible="none"!==f[d].element.css("display"),f[d].visible&&("mousedown"===g&&f[d]._activate.call(f[d],c),f[d].offset=f[d].element.offset(),f[d].proportions={width:f[d].element[0].offsetWidth,height:f[d].element[0].offsetHeight})}},drop:function(b,c){var d=!1;return a.each((a.ui.ddmanager.droppables[b.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&a.ui.intersect(b,this,this.options.tolerance)&&(d=this._drop.call(this,c)||d),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],b.currentItem||b.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,c)))}),d},dragStart:function(b,c){b.element.parentsUntil("body").bind("scroll.droppable",function(){b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)})},drag:function(b,c){b.options.refreshPositions&&a.ui.ddmanager.prepareOffsets(b,c),a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var d,e,f,g=a.ui.intersect(b,this,this.options.tolerance),h=!g&&this.isover?"isout":g&&!this.isover?"isover":null;h&&(this.options.greedy&&(e=this.options.scope,f=this.element.parents(":data(ui-droppable)").filter(function(){return a.data(this,"ui-droppable").options.scope===e}),f.length&&(d=a.data(f[0],"ui-droppable"),d.greedyChild="isover"===h)),d&&"isover"===h&&(d.isover=!1,d.isout=!0,d._out.call(d,c)),this[h]=!0,this["isout"===h?"isover":"isout"]=!1,this["isover"===h?"_over":"_out"].call(this,c),d&&"isout"===h&&(d.isout=!1,d.isover=!0,d._over.call(d,c)))}})},dragStop:function(b,c){b.element.parentsUntil("body").unbind("scroll.droppable"),b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)}}}(jQuery),function(a){function b(a){return parseInt(a,10)||0}function c(a){return!isNaN(parseInt(a,10))}a.widget("ui.resizable",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_create:function(){var b,c,d,e,f,g=this,h=this.options;if(this.element.addClass("ui-resizable"),a.extend(this,{_aspectRatio:!!h.aspectRatio,aspectRatio:h.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:h.helper||h.ghost||h.animate?h.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(a("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.data("ui-resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=h.handles||(a(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),b=this.handles.split(","),this.handles={},c=0;b.length>c;c++)d=a.trim(b[c]),f="ui-resizable-"+d,e=a("<div class='ui-resizable-handle "+f+"'></div>"),e.css({zIndex:h.zIndex}),"se"===d&&e.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[d]=".ui-resizable-"+d,this.element.append(e);this._renderAxis=function(b){var c,d,e,f;b=b||this.element;for(c in this.handles)this.handles[c].constructor===String&&(this.handles[c]=a(this.handles[c],this.element).show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(d=a(this.handles[c],this.element),f=/sw|ne|nw|se|n|s/.test(c)?d.outerHeight():d.outerWidth(),e=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join(""),b.css(e,f),this._proportionallyResize()),a(this.handles[c]).length},this._renderAxis(this.element),this._handles=a(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){g.resizing||(this.className&&(e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),g.axis=e&&e[1]?e[1]:"se")}),h.autoHide&&(this._handles.hide(),a(this.element).addClass("ui-resizable-autohide").mouseenter(function(){h.disabled||(a(this).removeClass("ui-resizable-autohide"),g._handles.show())}).mouseleave(function(){h.disabled||g.resizing||(a(this).addClass("ui-resizable-autohide"),g._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var b,c=function(b){a(b).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(c(this.element),b=this.element,this.originalElement.css({position:b.css("position"),width:b.outerWidth(),height:b.outerHeight(),top:b.css("top"),left:b.css("left")}).insertAfter(b),b.remove()),this.originalElement.css("resize",this.originalResizeStyle),c(this.originalElement),this},_mouseCapture:function(b){var c,d,e=!1;for(c in this.handles)d=a(this.handles[c])[0],(d===b.target||a.contains(d,b.target))&&(e=!0);return!this.options.disabled&&e},_mouseStart:function(c){var d,e,f,g=this.options,h=this.element.position(),i=this.element;return this.resizing=!0,/absolute/.test(i.css("position"))?i.css({position:"absolute",top:i.css("top"),left:i.css("left")}):i.is(".ui-draggable")&&i.css({position:"absolute",top:h.top,left:h.left}),this._renderProxy(),d=b(this.helper.css("left")),e=b(this.helper.css("top")),g.containment&&(d+=a(g.containment).scrollLeft()||0,e+=a(g.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:d,top:e},this.size=this._helper?{width:i.outerWidth(),height:i.outerHeight()}:{width:i.width(),height:i.height()},this.originalSize=this._helper?{width:i.outerWidth(),height:i.outerHeight()}:{width:i.width(),height:i.height()},this.originalPosition={left:d,top:e},this.sizeDiff={width:i.outerWidth()-i.width(),height:i.outerHeight()-i.height()},this.originalMousePosition={left:c.pageX,top:c.pageY},this.aspectRatio="number"==typeof g.aspectRatio?g.aspectRatio:this.originalSize.width/this.originalSize.height||1,f=a(".ui-resizable-"+this.axis).css("cursor"),a("body").css("cursor","auto"===f?this.axis+"-resize":f),i.addClass("ui-resizable-resizing"),this._propagate("start",c),!0},_mouseDrag:function(b){var c,d=this.helper,e={},f=this.originalMousePosition,g=this.axis,h=this.position.top,i=this.position.left,j=this.size.width,k=this.size.height,l=b.pageX-f.left||0,m=b.pageY-f.top||0,n=this._change[g];return n?(c=n.apply(this,[b,l,m]),this._updateVirtualBoundaries(b.shiftKey),(this._aspectRatio||b.shiftKey)&&(c=this._updateRatio(c,b)),c=this._respectSize(c,b),this._updateCache(c),this._propagate("resize",b),this.position.top!==h&&(e.top=this.position.top+"px"),this.position.left!==i&&(e.left=this.position.left+"px"),this.size.width!==j&&(e.width=this.size.width+"px"),this.size.height!==k&&(e.height=this.size.height+"px"),d.css(e),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),a.isEmptyObject(e)||this._trigger("resize",b,this.ui()),!1):!1},_mouseStop:function(b){this.resizing=!1;var c,d,e,f,g,h,i,j=this.options,k=this;return this._helper&&(c=this._proportionallyResizeElements,d=c.length&&/textarea/i.test(c[0].nodeName),e=d&&a.ui.hasScroll(c[0],"left")?0:k.sizeDiff.height,f=d?0:k.sizeDiff.width,g={width:k.helper.width()-f,height:k.helper.height()-e},h=parseInt(k.element.css("left"),10)+(k.position.left-k.originalPosition.left)||null,i=parseInt(k.element.css("top"),10)+(k.position.top-k.originalPosition.top)||null,j.animate||this.element.css(a.extend(g,{top:i,left:h})),k.helper.height(k.size.height),k.helper.width(k.size.width),this._helper&&!j.animate&&this._proportionallyResize()),a("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",b),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(a){var b,d,e,f,g,h=this.options;g={minWidth:c(h.minWidth)?h.minWidth:0,maxWidth:c(h.maxWidth)?h.maxWidth:1/0,minHeight:c(h.minHeight)?h.minHeight:0,maxHeight:c(h.maxHeight)?h.maxHeight:1/0},(this._aspectRatio||a)&&(b=g.minHeight*this.aspectRatio,e=g.minWidth/this.aspectRatio,d=g.maxHeight*this.aspectRatio,f=g.maxWidth/this.aspectRatio,b>g.minWidth&&(g.minWidth=b),e>g.minHeight&&(g.minHeight=e),g.maxWidth>d&&(g.maxWidth=d),g.maxHeight>f&&(g.maxHeight=f)),this._vBoundaries=g},_updateCache:function(a){this.offset=this.helper.offset(),c(a.left)&&(this.position.left=a.left),c(a.top)&&(this.position.top=a.top),c(a.height)&&(this.size.height=a.height),c(a.width)&&(this.size.width=a.width)},_updateRatio:function(a){var b=this.position,d=this.size,e=this.axis;return c(a.height)?a.width=a.height*this.aspectRatio:c(a.width)&&(a.height=a.width/this.aspectRatio),"sw"===e&&(a.left=b.left+(d.width-a.width),a.top=null),"nw"===e&&(a.top=b.top+(d.height-a.height),a.left=b.left+(d.width-a.width)),a},_respectSize:function(a){var b=this._vBoundaries,d=this.axis,e=c(a.width)&&b.maxWidth&&b.maxWidth<a.width,f=c(a.height)&&b.maxHeight&&b.maxHeight<a.height,g=c(a.width)&&b.minWidth&&b.minWidth>a.width,h=c(a.height)&&b.minHeight&&b.minHeight>a.height,i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,k=/sw|nw|w/.test(d),l=/nw|ne|n/.test(d);return g&&(a.width=b.minWidth),h&&(a.height=b.minHeight),e&&(a.width=b.maxWidth),f&&(a.height=b.maxHeight),g&&k&&(a.left=i-b.minWidth),e&&k&&(a.left=i-b.maxWidth),h&&l&&(a.top=j-b.minHeight),f&&l&&(a.top=j-b.maxHeight),a.width||a.height||a.left||!a.top?a.width||a.height||a.top||!a.left||(a.left=null):a.top=null,a},_proportionallyResize:function(){if(this._proportionallyResizeElements.length){var a,b,c,d,e,f=this.helper||this.element;for(a=0;this._proportionallyResizeElements.length>a;a++){if(e=this._proportionallyResizeElements[a],!this.borderDif)for(this.borderDif=[],c=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],d=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")],b=0;c.length>b;b++)this.borderDif[b]=(parseInt(c[b],10)||0)+(parseInt(d[b],10)||0);e.css({height:f.height()-this.borderDif[0]-this.borderDif[2]||0,width:f.width()-this.borderDif[1]-this.borderDif[3]||0})}}},_renderProxy:function(){var b=this.element,c=this.options;this.elementOffset=b.offset(),this._helper?(this.helper=this.helper||a("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++c.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(a,b){return{width:this.originalSize.width+b}},w:function(a,b){var c=this.originalSize,d=this.originalPosition;return{left:d.left+b,width:c.width-b}},n:function(a,b,c){var d=this.originalSize,e=this.originalPosition;return{top:e.top+c,height:d.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},sw:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,c,d]))},ne:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},nw:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,c,d]))}},_propagate:function(b,c){a.ui.plugin.call(this,b,[c,this.ui()]),"resize"!==b&&this._trigger(b,c,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),a.ui.plugin.add("resizable","animate",{stop:function(b){var c=a(this).data("ui-resizable"),d=c.options,e=c._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName),g=f&&a.ui.hasScroll(e[0],"left")?0:c.sizeDiff.height,h=f?0:c.sizeDiff.width,i={width:c.size.width-h,height:c.size.height-g},j=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null,k=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;c.element.animate(a.extend(i,k&&j?{top:k,left:j}:{}),{duration:d.animateDuration,easing:d.animateEasing,step:function(){var d={width:parseInt(c.element.css("width"),10),height:parseInt(c.element.css("height"),10),top:parseInt(c.element.css("top"),10),left:parseInt(c.element.css("left"),10)};e&&e.length&&a(e[0]).css({width:d.width,height:d.height}),c._updateCache(d),c._propagate("resize",b)}})}}),a.ui.plugin.add("resizable","containment",{start:function(){var c,d,e,f,g,h,i,j=a(this).data("ui-resizable"),k=j.options,l=j.element,m=k.containment,n=m instanceof a?m.get(0):/parent/.test(m)?l.parent().get(0):m;n&&(j.containerElement=a(n),/document/.test(m)||m===document?(j.containerOffset={left:0,top:0},j.containerPosition={left:0,top:0},j.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight}):(c=a(n),d=[],a(["Top","Right","Left","Bottom"]).each(function(a,e){d[a]=b(c.css("padding"+e))}),j.containerOffset=c.offset(),j.containerPosition=c.position(),j.containerSize={height:c.innerHeight()-d[3],width:c.innerWidth()-d[1]},e=j.containerOffset,f=j.containerSize.height,g=j.containerSize.width,h=a.ui.hasScroll(n,"left")?n.scrollWidth:g,i=a.ui.hasScroll(n)?n.scrollHeight:f,j.parentData={element:n,left:e.left,top:e.top,width:h,height:i}))},resize:function(b){var c,d,e,f,g=a(this).data("ui-resizable"),h=g.options,i=g.containerOffset,j=g.position,k=g._aspectRatio||b.shiftKey,l={top:0,left:0},m=g.containerElement;m[0]!==document&&/static/.test(m.css("position"))&&(l=i),j.left<(g._helper?i.left:0)&&(g.size.width=g.size.width+(g._helper?g.position.left-i.left:g.position.left-l.left),k&&(g.size.height=g.size.width/g.aspectRatio),g.position.left=h.helper?i.left:0),j.top<(g._helper?i.top:0)&&(g.size.height=g.size.height+(g._helper?g.position.top-i.top:g.position.top),k&&(g.size.width=g.size.height*g.aspectRatio),g.position.top=g._helper?i.top:0),g.offset.left=g.parentData.left+g.position.left,g.offset.top=g.parentData.top+g.position.top,c=Math.abs((g._helper?g.offset.left-l.left:g.offset.left-l.left)+g.sizeDiff.width),d=Math.abs((g._helper?g.offset.top-l.top:g.offset.top-i.top)+g.sizeDiff.height),e=g.containerElement.get(0)===g.element.parent().get(0),f=/relative|absolute/.test(g.containerElement.css("position")),e&&f&&(c-=g.parentData.left),c+g.size.width>=g.parentData.width&&(g.size.width=g.parentData.width-c,k&&(g.size.height=g.size.width/g.aspectRatio)),d+g.size.height>=g.parentData.height&&(g.size.height=g.parentData.height-d,k&&(g.size.width=g.size.height*g.aspectRatio))},stop:function(){var b=a(this).data("ui-resizable"),c=b.options,d=b.containerOffset,e=b.containerPosition,f=b.containerElement,g=a(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width,j=g.outerHeight()-b.sizeDiff.height;b._helper&&!c.animate&&/relative/.test(f.css("position"))&&a(this).css({left:h.left-e.left-d.left,width:i,height:j}),b._helper&&!c.animate&&/static/.test(f.css("position"))&&a(this).css({left:h.left-e.left-d.left,width:i,height:j})}}),a.ui.plugin.add("resizable","alsoResize",{start:function(){var b=a(this).data("ui-resizable"),c=b.options,d=function(b){a(b).each(function(){var b=a(this);b.data("ui-resizable-alsoresize",{width:parseInt(b.width(),10),height:parseInt(b.height(),10),left:parseInt(b.css("left"),10),top:parseInt(b.css("top"),10)})})};"object"!=typeof c.alsoResize||c.alsoResize.parentNode?d(c.alsoResize):c.alsoResize.length?(c.alsoResize=c.alsoResize[0],d(c.alsoResize)):a.each(c.alsoResize,function(a){d(a)})},resize:function(b,c){var d=a(this).data("ui-resizable"),e=d.options,f=d.originalSize,g=d.originalPosition,h={height:d.size.height-f.height||0,width:d.size.width-f.width||0,top:d.position.top-g.top||0,left:d.position.left-g.left||0},i=function(b,d){a(b).each(function(){var b=a(this),e=a(this).data("ui-resizable-alsoresize"),f={},g=d&&d.length?d:b.parents(c.originalElement[0]).length?["width","height"]:["width","height","top","left"];a.each(g,function(a,b){var c=(e[b]||0)+(h[b]||0);c&&c>=0&&(f[b]=c||null)}),b.css(f)})};"object"!=typeof e.alsoResize||e.alsoResize.nodeType?i(e.alsoResize):a.each(e.alsoResize,function(a,b){i(a,b)})},stop:function(){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","ghost",{start:function(){var b=a(this).data("ui-resizable"),c=b.options,d=b.size;b.ghost=b.originalElement.clone(),b.ghost.css({opacity:.25,display:"block",position:"relative",height:d.height,width:d.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof c.ghost?c.ghost:""),b.ghost.appendTo(b.helper)},resize:function(){var b=a(this).data("ui-resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=a(this).data("ui-resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(){var b=a(this).data("ui-resizable"),c=b.options,d=b.size,e=b.originalSize,f=b.originalPosition,g=b.axis,h="number"==typeof c.grid?[c.grid,c.grid]:c.grid,i=h[0]||1,j=h[1]||1,k=Math.round((d.width-e.width)/i)*i,l=Math.round((d.height-e.height)/j)*j,m=e.width+k,n=e.height+l,o=c.maxWidth&&m>c.maxWidth,p=c.maxHeight&&n>c.maxHeight,q=c.minWidth&&c.minWidth>m,r=c.minHeight&&c.minHeight>n;c.grid=h,q&&(m+=i),r&&(n+=j),o&&(m-=i),p&&(n-=j),/^(se|s|e)$/.test(g)?(b.size.width=m,b.size.height=n):/^(ne)$/.test(g)?(b.size.width=m,b.size.height=n,b.position.top=f.top-l):/^(sw)$/.test(g)?(b.size.width=m,b.size.height=n,b.position.left=f.left-k):(b.size.width=m,b.size.height=n,b.position.top=f.top-l,b.position.left=f.left-k)}})}(jQuery);var Flod=window.Flod||{};!function(a,b){"use strict";function c(a){var b=moment(a);return b.isValid()?b:moment(a,"HH:mm:ss")}a.TimeSlot=Backbone.Model.extend({defaults:{resource:null,start_time:null,end_time:null,organisation:null,person:null,status:"Unknown",label:""},parse:function(a){if(a){var b=_.clone(a);return b.start_time&&(b.start_time=c(b.start_time)),b.end_time&&(b.end_time=c(b.end_time)),b}return null},constructor:function(a,b){Backbone.Model.apply(this,[this.parse(a),b])},getDisplayName:function(){return this.has("display_name")?this.get("display_name"):this.getAktorName()},getAktorName:function(){return this.has("organisation")&&this.get("organisation").name?this.get("organisation").name:this.has("person")&&this.get("person")instanceof Backbone.Model&&this.get("person").has("name")?this.get("person").get("name"):this.has("person")&&this.get("person").name?this.get("person").name:this.has("person")&&this.get("person").first_name&&this.get("person").last_name?this.get("person").last_name+", "+this.get("person").first_name:""},getStatus:function(){return this.get("status").toLowerCase()},getLabel:function(){if("Unknown"==this.get("status"))return"";var a=this.has("display_name")?this.get("display_name").split("(")[0]:this.getAktorName();return a},getRange:function(){return moment().range(this.get("start_time"),moment(this.get("end_time")))},toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);return a.start_time=moment(this.get("start_time")).format("YYYY-MM-DDTHH:mm:ss"),a.end_time=moment(this.get("end_time")).format("YYYY-MM-DDTHH:mm:ss"),this.get("person")instanceof Backbone.Model?a.person={uri:this.get("person").get("uri")}:a.person={uri:this.get("person").uri},a.resource={uri:this.get("resource").uri},a.organisation&&(a.organisation.uri||(a=_.omit(a,"organisation"))),_.omit(a,"editable")},changeDate:function(a){return this.get("start_time").year(a.year()).month(a.month()).date(a.date()),this.get("end_time").year(a.year()).month(a.month()).date(a.date()),this},getDuration:function(){return this.get("end_time").diff(this.get("start_time"),"minutes")},collidesWith:function(a,b){if(_.isEqual(this,a))return!1;var c=this.getRange();return c.contains(a.get("start_time"))?!this.get("end_time").isSame(a.get("start_time")):c.contains(a.get("end_time"))?!this.get("start_time").isSame(a.get("end_time")):b?!1:a.collidesWith(this,!0)}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";function c(a,b){var c=$($(a).parent().parent()),d=c.position().left+c.width()-25,e=b.position.left+b.size.width;e>=d&&$(a).resizable("option",{maxWidth:b.size.width})}var d=Backbone.View.extend({className:"timeslot",events:{click:"clicked"},initialize:function(){this.model.on("change:display_name",this.render,this),_.bindAll(this,"clicked"),this.model.on("change:selected",this.render,this),this.model.on("change:status",this.render,this)},render:function(){var a=this.model.getDuration()/this.model.collection.options.slot_duration;this.$el.data("slot",this.model),this.model.hasChanged("status")&&this.$el.removeClass(this.model.previous("status").toLowerCase()),this.$el.addClass(this.model.getStatus()),this.model.has("color")&&this.$el.css("background-color",this.model.get("color")),this.$el.text(this.model.getLabel()),this.$el.attr("title",this.model.getDisplayName());var b=26*a+(2*a-1);return this.$el.css("width",b+"px"),this.model.get("editable")?this.makeEditable():(this.$el.is(".ui-resizable")&&this.$el.resizable("destroy"),this.$el.is(".ui-draggable")&&this.$el.draggable("destroy")),this.model.get("selected")?this.$el.addClass("selected"):this.$el.removeClass("selected"),this},resized:function(a,b){var c=(b.size.width-b.originalSize.width)/28*30;this.model.collection.canChangeSlotTo(this.model,moment(this.model.get("start_time")),moment(this.model.get("end_time")).add(c,"minutes"))&&this.model.get("end_time").add(c,"minutes"),this.model.trigger("slotChanged",this.model)},makeEditable:function(){var a,b=_.bind(this.resized,this);this.options.table&&(a=this.options.table.$("tbody")),this.$el.draggable({grid:[28,26],zIndex:100,containment:a}).resizable({grid:[28,26],handles:"e",start:function(a,b){c(this,b)},stop:function(a,c){$(this).resizable("option",{maxWidth:null}),b(a,c)},resize:function(a,b){c(this,b),$(this).css("height","")}})},clicked:function(){var a=this.model.collection;_.has(this.model,"parentCollection")&&(a=this.model.parentCollection),a.trigger("slotClick",this.model)}});a.TimeSlotView=Backbone.View.extend({className:"slot",tagName:"td",render:function(){var a=this.model.getDuration()/this.options.slotDuration;return this.slotView=new d({model:this.model,table:this.options.table}),this.$el.append(this.slotView.render(a).$el),this.$el.attr("colspan",a),this}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";a.CalendarModel=Backbone.Model.extend({defaults:{slot_duration:30,calendar_start:moment("08:00","HH:mm"),calendar_end:moment("23:00","HH:mm"),editable:!1},constructor:function(a,b){var c=[];a&&(c=a.rows),Backbone.Model.apply(this,[_.omit(a,"rows"),b]),this.set({rows:this.mapRows(c)}),_.each(this.get("rows"),this.registerRow,this)},registerRow:function(a){a.on("emptySlotClick",this.clickEmptySlot,this),a.on("slotClick",this.clickSlot,this),a.on("slotChanged",this.slotChanged,this),a.on("destroy",this.removeRow,this),a.on("add",this.addToRow,this)},addToRow:function(a){this.trigger("slotAdded",a)},clickEmptySlot:function(a){this.trigger("emptySlotClick",a)},clickSlot:function(a){this.trigger("slotClick",a)},slotChanged:function(a){this.trigger("slotChanged",a)},removeRow:function(a){a.off("emptySlotClick",this.clickEmptySlot,this),a.off("slotClick",this.clickSlot,this),a.off("slotChanged",this.slotChanged,this),a.off("destroy",this.removeRow,this);var b=_.without(this.get("rows"),a);this.set("rows",b),this.trigger("reset")},mapRows:function(b){var c=this.getConfig();return _.map(b,function(b){return b instanceof a.CalendarRow?(b.options=_.extend(b.options,c),b):new a.CalendarRow(b.slots,_.omit(_.extend(b,c),"slots"))})},getConfig:function(){return{slot_duration:this.get("slot_duration"),calendar_start:this.get("calendar_start"),calendar_end:this.get("calendar_end"),editable:this.get("editable")}},row:function(a){return this.get("rows")[a]},reset:function(a){a=a||[],this.set({rows:this.mapRows(a)}),_.each(this.get("rows"),this.registerRow,this),this.trigger("reset")},getSlots:function(){return _.flatten(_.map(this.get("rows"),function(a){return a.models}))},addRow:function(a,b){return a=this.mapRows([a])[0],b?this.get("rows").splice(b,0,a):this.get("rows").push(a),this.registerRow(a),this.trigger("reset"),a},addRows:function(a){_.isArray(a)||(a=[a]),a=this.mapRows(a);var b=this.get("rows");return this.set("rows",b.concat(a)),_.each(this.get("rows"),this.registerRow,this),this.trigger("reset"),a},getIndexForRow:function(a){return _.indexOf(this.get("rows"),a)},getRowForDate:function(a){return _.find(this.get("rows"),function(b){return b.date.isSame(moment(a),"day")})},getRowForWeekday:function(a){return _.find(this.get("rows"),function(b){return b.date.isoWeekday()==a})}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";function c(a){var b=moment(a);return b.isValid()?b:moment(a,"HH:mm:ss")}a.ColorSlot=Backbone.Model.extend({defaults:{start_time:null,end_time:null,background_color:"#FFFFFF"},parse:function(a){if(a){var b=_.clone(a);return b.start_time&&(b.start_time=c(b.start_time)),b.end_time&&(b.end_time=c(b.end_time)),b}return null}});var d=Backbone.Collection.extend({model:a.ColorSlot,getByTime:function(a){return this.find(function(b){var c=moment(b.get("start_time").format("HH:mm"),"HH:mm"),d=moment(b.get("end_time").format("HH:mm"),"HH:mm");return(c.isBefore(a)||c.isSame(a))&&d.isAfter(a)})}});a.CalendarRow=Backbone.Collection.extend({model:a.TimeSlot,initialize:function(a,b){this.displayName=b.displayName,this.date=moment(b.date),this.options=_.omit(b,"displayName","date"),this.colors=new d(this.options.colors||[],{parse:!0})},reset:function(a,b){return Backbone.Collection.prototype.reset.apply(this,arguments),this.each(this.checkEditable,this),this},removeSlot:function(a){this.remove(a),this.trigger("slotRemoved")},getDisplayName:function(){return this.displayName||""},getDate:function(){return this.date},checkEditable:function(a){(_.isUndefined(a.get("editable"))||a.get("editable"))&&a.set({editable:this.options.editable})},slotCollides:function(a){var b=this.map(function(b){return b.collidesWith(a)});return-1!==b.indexOf(!0)},canChangeSlotTo:function(a,b,c){if(this.onlyOwn&&a.collection!==this)return!1;var d=a.clone(),e=moment(this.date).hours(b.hours()).minutes(b.minutes()),f=moment(this.date).hours(c.hours()).minutes(c.minutes());if(d.set({start_time:e}),d.set({end_time:f}),this.onlyOwn&&a.parentCollection){var g=!1;for(var h in a.parentCollection.models){var i=a.parentCollection.models[h];if(i.collidesWith(d)&&(g=0==_.flatten(_.filter(i.get("slots"),function(b){return b.cid==a.cid},this)).length))break}return!g}if(this.slotCollides(d)){var j=this.filter(function(a){return a.collidesWith(d)});return j.length<2?_.isEqual(j[0],a):!1}return!0},addColors:function(a){var b=_.map(a,function(a){this.addColor(a)},this);return-1===b.indexOf(!1)},addColor:function(b){b instanceof a.ColorSlot||(b=new a.ColorSlot(b,{parse:!0})),this.colors.add(b)},addSlots:function(a){var b=_.map(a,function(a){this.addSlot(a)},this);return-1===b.indexOf(!1)},addSlot:function(b){if(b instanceof a.TimeSlot||(b=new a.TimeSlot(b)),
  b.collection&&_.isEqual(b.collection,this))return this.trigger("slotChanged",b),!0;if(this.slotCollides(b.clone().changeDate(this.getDate())))return!1;if(b.get("slots")){var c=this;_.each(b.get("slots"),function(a){a.changeDate(c.getDate())})}b.changeDate(this.getDate());var d;return b.collection&&(d=b.collection,d.remove(b)),this.checkEditable(b),this.add(b),d&&d.trigger("slotRemoved"),!0},getByStart:function(a){return this.find(function(b){return moment(b.get("start_time").format("HH:mm"),"HH:mm").isSame(a)})},timeOccupied:function(a){return!!this.find(function(b){var c=moment(b.get("start_time").format("HH:mm"),"HH:mm"),d=moment(b.get("end_time").format("HH:mm"),"HH:mm");return!moment().range(c,d).contains(a)||c.isSame(a)||d.isSame(a)?!1:!0})},getAvailableSpan:function(a){var b=this.filter(function(b){return b.get("start_time").diff(a)>0});if(b.length){var c=_.min(b,function(a){return a.get("start_time").format("X")});return moment(c.get("start_time"))}return moment(this.date).hours(this.options.calendar_end.hours()).minutes(this.options.calendar_end.minutes()).seconds(0)},destroy:function(){this.reset(),this.trigger("destroy",this)}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";var c=a.TimeSlotView.extend({events:{click:"clicked"},className:"slot empty-slot",initialize:function(){_.bindAll(this,"clicked")},render:function(){return this.$el.css("background-color",this.options.background_color),this},clicked:function(){this.collection.trigger("emptySlotClick",{start_time:this.options.start_time,end_time:this.options.end_time,row:this.collection})}});a.CalendarRowView=Backbone.View.extend({tagName:"tr",className:"calendar-row",initialize:function(){_.bindAll(this,"slotDropped"),this.collection.on("add",this.render,this),this.collection.on("remove",this.render,this),this.collection.on("slotChanged",this.render,this),this.collection.on("slotRemoved",this.render,this),this.collection.on("slotRemoved",this.slotRemoved,this),this.collection.colors.on("add",this.render,this),this.collection.colors.on("remove",this.render,this)},render:function(){this.$el.html($("<td><div class='slot_title' title='"+this.collection.getDisplayName()+"'>"+this.collection.getDisplayName()+"</div></td>"));var b=this.collection.options.calendar_start,d=this.collection.options.slot_duration;return this.views=_.compact(_.times(this.getNumSlots(),function(e){var f=moment(b).add("minutes",e*d),g=moment(b).add("minutes",(e+1)*d),h=this.collection.getByStart(f);if(h)return new a.TimeSlotView({model:h,slotDuration:d,table:this.options.table}).render();if(!this.collection.timeOccupied(f)){var i="#FFFFFF",j=this.collection.colors.getByTime(f);return j&&(i=j.get("background_color")),new c({collection:this.collection,slotDuration:d,start_time:f,end_time:g,background_color:i}).render()}return null},this)),this.$el.append(_.pluck(this.views,"$el")),this.collection.options.editable&&this.$el.droppable({drop:_.bind(function(a,b){var c=b.position.left/28*30,d=moment(b.draggable.data("slot").get("start_time").format("HH:mm"),"HH:mm").add("m",c);this.slotDropped(b.draggable.data("slot"),d)},this)}),this},slotDropped:function(a,b){var c=b.diff(moment(a.get("start_time").format("HH:mm"),"HH:mm"),"minutes");this.collection.canChangeSlotTo(a,moment(a.get("start_time")).add(c,"minutes"),moment(a.get("end_time")).add(c,"minutes"))?(a.get("start_time").add(c,"minutes"),a.get("end_time").add(c,"minutes"),this.collection.addSlot(a)):a.collection.trigger("slotChanged",a)},getNumSlots:function(){var a=this.collection.options;return 60*a.calendar_end.diff(a.calendar_start,"hours")/a.slot_duration},slotRemoved:function(){this.trigger("slotRemoved",this)}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";function c(a,b,c){return 60*b.diff(a,"hours")/c}function d(a,b,c){var d=$("<tr><th class='first'>"+a+"</th></tr>");return d.append(b),c&&d.addClass(c),d}var e=Backbone.View.extend({tagName:"thead",render:function(){var a=c(this.model.get("calendar_start"),this.model.get("calendar_end"),this.model.get("slot_duration")),b=this.model.get("calendar_start"),e=this.model.get("slot_duration"),f=_.compact(_.times(a,function(a){var c=moment(b).add("minutes",a*e);return 0===c.minutes()?$("<th colspan='2'>"+c.format("H")+"</th>"):void 0})),g=_.compact(_.times(a,function(a){var c=moment(b).add("minutes",a*e);return $("<th>"+c.format("mm")+"</th>")}));return this.$el.append(d(this.model.get("title"),f)),this.$el.append(d(this.model.get("subtitle"),g,"gray")),this}});a.CalendarView=Backbone.View.extend({tagName:"table",className:"flod-calendar",initialize:function(){this.model||(this.model=new a.CalendarModel),this.model.on("emptySlotClick",this.emptySlotClick,this),this.model.on("slotClick",this.slotClick,this),this.model.on("reset",this.render,this)},emptySlotClick:function(a){this.trigger("emptySlotClick",a)},slotClick:function(a){this.trigger("slotClick",a)},render:function(){return this.views&&_.each(this.views,function(a){a.undelegateEvents()}),this.header=new e({model:this.model}).render(),this.$el.html(this.header.$el),this.$el.append($("<tbody></tbody>")),this.views=_.map(this.model.get("rows"),function(b){var c=new a.CalendarRowView({collection:b,table:this});return c.on("slotRemoved",this.slotRemoved,this),c.render()},this),this.$el.append(_.pluck(this.views,"$el")),this},getNumSlots:function(){return 60*this.model.get("calendar_end").diff(this.model.get("calendar_start"),"hours")/this.model.get("slot_duration")},slotRemoved:function(){this.trigger("slotRemoved",this)}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";var c=Backbone.View.extend({editable:!0,initialize:function(){this.calendar=new a.CalendarModel({rows:[],title:"",subtitle:"",editable:this.editable}),this.calendarView=new Flod.CalendarView({model:this.calendar}),this.calendarView.on("emptySlotClick",this.emptySlotClick,this),this.calendarView.on("slotClick",this.slotClick,this)},render:function(){return this.resetRows(),this.$el.append(this.calendarView.render().$el),this},emptySlotClick:function(a){this.trigger("emptySlotClick",a)},slotClick:function(a){this.trigger("slotClick",a)},resetRows:function(){this.calendarView.model.reset(_.map(this.getDays(this.getInitDate()),function(a){return{displayName:a.moment.format("dddd"),date:a.moment}}))},getDays:function(a){var b=new Flod.Week({year:a.year(),week:a.isoWeek()});return b.getDays()}}),d=Backbone.Collection.extend({model:a.TimeSlot,type:"slots",initialize:function(a,b){this.options=b},url:function(){var a="/api/booking/v1/resources"+this.options.resource_uri+"/"+this.type+"/";return this.options.start_date&&this.options.end_date&&(a+="?start_date="+this.options.start_date+"&end_date="+this.options.end_date),a}}),e=function(a,b){var c=b.get("start_time").format("YYYY-MM-DD");return a[c]||(a[c]=[]),a[c].push(b),a};a.BrowsableWeeklyCalendarView=c.extend({getBlocked:!0,initialize:function(){c.prototype.initialize.apply(this,arguments),this.currentWeek=new Flod.Week({year:this.getInitDate().isoWeekYear(),week:this.getInitDate().isoWeek()}),this.weeksChooser=new Flod.WeeksView({model:new Flod.Weeks({week:this.currentWeek})}),this.weeksChooser.on("changeWeek",this.changeWeek,this),this.rows=[],_.bindAll(this,"slotsFectched")},changeWeek:function(a){var b=_.clone(this.calendarView.model.get("rows")),c=_.find(this.rows,function(a){return a.week.equals(this.currentWeek)},this);c?c.rows=b:this.rows.push({week:this.currentWeek,rows:b}),this.currentWeek=a;var d=_.find(this.rows,function(b){return b.week.equals(a)},this);d?this.calendarView.model.reset(d.rows):this.resetRows(),this.calendarView.render()},render:function(){return c.prototype.render.apply(this,arguments),this.$el.append(this.weeksChooser.render().$el),this.$el.append(this.calendarView.render().$el),this},getInitDate:function(){return moment(this.options.data.date)},resetRows:function(){var a=this.currentWeek.getDays();this.trigger("resetRows",a);var b=new d([],{resource_uri:this.options.data.resource.get("uri"),start_date:a[0].moment.format("YYYY-MM-DD"),end_date:a[a.length-1].moment.format("YYYY-MM-DD")});if(this.getBlocked){var c=new d([],{resource_uri:this.options.data.resource.get("uri"),start_date:a[0].moment.format("YYYY-MM-DD"),end_date:a[a.length-1].moment.format("YYYY-MM-DD")});c.type="blockedtimes";var e=_.after(2,_.bind(function(){this.slotsFectched(b,c)},this));b.fetch({success:e}),c.fetch({success:e})}else b.fetch({success:_.bind(function(){this.slotsFectched(b)},this)})},slotsFectched:function(a,b){var c=a.reduce(e,{});if(b){b.each(function(a){a.set("status","reserved")});var d=b.reduce(e,{});_.each(d,function(a,b){_.has(c,b)?c[b]=c[b].concat(a):c[b]=a})}_.each(c,function(a,b){var c=_.find(this.calendar.get("rows"),function(a){return a.date.isSame(moment(b),"day")});a=_.filter(a,function(a){return"granted"===a.getStatus()||"reserved"===a.getStatus()}),_.each(a,function(a){a.set("editable",!1)}),c.addSlots(a)},this)}}),a.IdealizedWeeklyCalendarView=c.extend({getInitDate:function(){return moment()}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";function c(a){function b(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=moment(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function c(a,c,d){return b(moment([a,11,31+c-d]),c,d).week}return c(a,1,4)}a.Week=Backbone.Model.extend({weekDayFormat:"dddd",dayFormat:"D.M",_getLastValidDay:function(){var a=moment(this.get("year")+"-01-01","YYYY-MM-DD");return a.endOf("isoWeek"),a.add("w",parseInt(this.get("week"),10)-1),a},_changeWeek:function(a){var b=c(this.get("year")),d=this.get("week"),e=d+a,f=this.get("year");1>e?(f-=1,e=c(f)+e):e>b&&(f+=1,e-=b),this.set({year:f,week:e})},_asRange:function(){return moment().range(this.getFirstValidDay(),this._getLastValidDay())},getFirstValidDay:function(){var a=moment(this.get("year")+"-01-01","YYYY-MM-DD");return a.startOf("isoWeek"),a.add("w",parseInt(this.get("week"),10)-1),a},getDisplayStr:function(){return"Uke "+this.get("week")+", "+this.get("year")},getDays:function(){var a=this.getFirstValidDay(),b=this._getLastValidDay(),c=b.diff(a,"days");return _.map(_.range(0,c+1),function(b){var c=moment(a).add("d",b);return{moment:c}})},hasPrev:function(){return this.has("range")?!this._asRange().contains(this.get("range").start):!0},hasNext:function(){return this.has("range")?!this._asRange().contains(this.get("range").end):!0},next:function(){return this.hasNext()&&this._changeWeek(1),this},prev:function(){return this.hasPrev()&&this._changeWeek(-1),this},nextMonth:function(){if(this.hasNext()){var a=this.get("week")+4;if(this.has("range")){var b=moment(this.get("range").end).week();a>b&&(a=b)}a-=this.get("week"),this._changeWeek(a)}return this},prevMonth:function(){if(this.hasPrev()){var a=this.get("week")-4;if(this.has("range")){var b=moment(this.get("range").start).week();b>a&&(a=b)}a-=this.get("week"),this._changeWeek(a)}return this},equals:function(a){return this.get("week")===a.get("week")&&this.get("year")===a.get("year")}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";moment.lang("no",{months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],weekdays:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],weekdaysShort:["S","M","T","O","T","F","L"]}),moment.lang("no");var c=Backbone.View.extend({tagName:"td",className:"selectable",events:{click:"change"},initialize:function(){_.bindAll(this,"change")},render:function(){this.$el.addClass(this.model.get("selected")?"selected current":"otherdate"),this.model.get("disabled")&&this.$el.addClass("disabled")}}),d=c.extend({template:"<div><%= day_name %></div><div><%= date %></div>",render:function(){return c.prototype.render.apply(this,arguments),this.$el.html(_.template(this.template,{day_name:this.model.get("moment").format(this.model.get("weekDayFormat")),date:this.model.get("moment").format(this.model.get("dayFormat"))})),this},change:function(){this.model.get("disabled")||this.options.parent.change(this.model.get("moment"))}}),e=Backbone.View.extend({tagName:"table",className:"flod-calendar flod-calendar-chooser",template:"<tr><td><%= title %></td></tr>",render:function(){if(this.$el.html(_.template(this.template,{title:this.model.getDisplayStr()})),this.model.hasPrev()){var a=$('<td class="flod-btn"><i><img src="/static/images/backward2.png" height="26" width="17"></i></td>');this.$("tr").append(a),a.on("click",_.bind(this.prevMonth,this));var b=$('<td class="flod-btn"><i id="left"><img src="/static/images/backward1.png" height="26" width="17"></i></td>');this.$("tr").append(b),b.on("click",_.bind(this.prev,this))}if(this.renderElements(),this.model.hasNext()){var c=$('<td class="flod-btn right"><i id="right"><img src="/static/images/forward1.png" height="26" width="17"></i></td>');this.$("tr").append(c),c.on("click",_.bind(this.next,this));var d=$('<td class="flod-btn"><i><img src="/static/images/forward2.png" height="26" width="17"></i></td>');this.$("tr").append(d),d.on("click",_.bind(this.nextMonth,this))}return this},prev:function(){},prevMonth:function(){},next:function(){},nextMonth:function(){}});a.WeekView=e.extend({renderElements:function(){var a;this.model.has("range")&&(a=moment().range(moment(this.model.get("range").start.format("YYYY-MM-DD"),"YYYY-MM-DD"),moment(this.model.get("range").end.format("YYYY-MM-DD"),"YYYY-MM-DD")));var b=_.map(this.model.getDays(),function(b){return b.weekDayFormat=this.model.weekDayFormat,b.dayFormat=this.model.dayFormat,this.options.selected&&(b.selected=this.options.selected.isSame(b.moment,"day")),a&&(b.disabled=!a.contains(b.moment)),new d({model:new Backbone.Model(b),parent:this}).render().$el},this);this.$("tr").append(b)},change:function(a){this.options.selected=a,this.trigger("changeDay",a),this.render()},prev:function(){if(this.model.hasPrev()){this.model.prev();var a=moment(this.options.selected).subtract(7,"days").endOf("isoWeek");this.change(a)}},prevMonth:function(){if(this.model.hasPrev()){this.model.prevMonth();var a=moment(this.options.selected).subtract(4,"w").endOf("isoWeek");if(this.model.has("range")){var b=moment(this.model.get("range").start).endOf("isoWeek");b>a&&(a=b)}this.change(a)}},next:function(){if(this.model.hasNext()){this.model.next();var a=moment(this.options.selected).add(7,"days").startOf("isoWeek");this.change(a)}},nextMonth:function(){if(this.model.hasNext()){this.model.nextMonth();var a=moment(this.options.selected).add(4,"w").startOf("isoWeek");if(this.model.has("range")){var b=moment(this.model.get("range").end).startOf("isoWeek");a>b&&(a=b)}this.change(a)}}});var f=c.extend({render:function(){return c.prototype.render.apply(this,arguments),this.$el.html("Uke "+this.model.get("week")),this},change:function(){this.options.parent.change(this.model)}});a.WeeksView=e.extend({renderElements:function(){var a=_.map(this.model.getWeeks(),function(a){return a.set("selected",!1),a.equals(this.model.get("week"))&&a.set("selected",!0),new f({model:a,parent:this}).render().$el},this);this.$("tr").append(a)},change:function(a){this.model.set("week",a),this.trigger("changeWeek",a),this.render()},prev:function(){this.change(this.model.prev())},next:function(){this.change(this.model.next())},prevMonth:function(){this.change(this.model.prevMonth())},nextMonth:function(){this.change(this.model.nextMonth())}})}(Flod);var Flod=window.Flod||{};!function(a,b){"use strict";a.Weeks=Backbone.Model.extend({getDisplayStr:function(){return"Uke "+this.get("week").get("week")+", "+this.get("week").get("year")},getWeeks:function(){return[this.get("week").clone().prev(),this.get("week").clone(),this.get("week").clone().next()]},next:function(){return this.get("week").clone().next()},nextMonth:function(){return this.get("week").clone().nextMonth()},prev:function(){return this.get("week").clone().prev()},prevMonth:function(){return this.get("week").clone().prevMonth()},hasPrev:function(){return!0},hasNext:function(){return!0}})}(Flod),$.widget("ui.draggable",$.extend({},$.ui.draggable.prototype,{_setContainment:function(){"use strict";var a,b,c,d=this.options;if(b=$(d.containment),c=b[0]){a="hidden"!==b.css("overflow");var e=b.children().first().children().first().width();this.containment=[(parseInt(b.css("borderLeftWidth"),10)||0)+(parseInt(b.css("paddingLeft"),10)||0)+e,(parseInt(b.css("borderTopWidth"),10)||0)+(parseInt(b.css("paddingTop"),10)||0),(a?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(b.css("borderRightWidth"),10)||0)-(parseInt(b.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(a?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(b.css("borderBottomWidth"),10)||0)-(parseInt(b.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=b}}}));var Flod=window.Flod||{};Flod.calendar=Flod.calendar||{},function(a,b){"use strict";function c(a,b,c){return new Flod.TimeSlot({start_time:a,end_time:b,week_day:c,editable:!1,status:"reserved"})}function d(a,b){b=_.sortBy(b,function(a){return a.get("start_time").unix()});var d=_.map(b,function(a){return[a.get("start_time"),a.get("end_time")]});return d.unshift([moment("08:00","HH:mm"),moment("08:00","HH:mm")]),d.push([moment("23:00","HH:mm"),moment("23:00","HH:mm")]),_.compact(_.map(d,function(b,d,e){if(e[d+1]){var f=e[d+1],g=b[1],h=f[0];if(0!==g.diff(h))return c(g,h,a)}}))}function e(a,b){return a.get("start_time").unix()<b.get("start_time").unix()?-1:a.get("start_time").unix()>b.get("start_time").unix()?1:0}a.invertSlots=function(a){return _.reduce(_.range(1,8),function(b,c){return b[c]=d(c,a[c]),b},{})};var f=function(a,b){var c=a.clone(),d=c.get("start_time").isSame(b.get("start_time")),e=c.get("end_time").isSame(b.get("end_time"));if(d&&e)return null;if(d)return c.set("start_time",moment(b.get("end_time"))),[c];if(e)return c.set("end_time",moment(b.get("start_time"))),[c];if(c.get("start_time").isBefore(b.get("start_time"))&&c.get("end_time").isAfter(b.get("end_time"))){var f=c.clone();return c.set("end_time",b.get("start_time")),f.set("start_time",b.get("end_time")),[c,f]}return b.get("start_time").isBefore(c.get("start_time"))?(c.set("start_time",b.get("end_time")),[c]):b.get("end_time").isAfter(c.get("end_time"))?(c.set("end_time",b.get("start_time")),[c]):[a]};a.splitSlot=function(a,b){b.sort(e);var c=[a];return _.each(b,function(a){var b=c.shift();if(b.collidesWith(a)){var d=f(b,a);_.each(d,function(a){c.unshift(a)})}else c.unshift(b)}),_.compact(c).reverse()}}(Flod.calendar);