if(typeof links==="undefined"){links={}}if(typeof google==="undefined"){google=undefined}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(d,c){for(var b=0,a=this.length;b<a;++b){d.call(c||this,this[b],b,this)}}}links.Timeline=function(a,b){if(!a){return}this.dom={};this.conversion={};this.eventParams={};this.groups=[];this.groupIndexes={};this.items=[];this.renderQueue={show:[],hide:[],update:[]};this.renderedItems=[];this.clusterGenerator=new links.Timeline.ClusterGenerator(this);this.currentClusters=[];this.selection=undefined;this.listeners={};this.size={actualHeight:0,axis:{characterMajorHeight:0,characterMajorWidth:0,characterMinorHeight:0,characterMinorWidth:0,height:0,labelMajorTop:0,labelMinorTop:0,line:0,lineMajorWidth:0,lineMinorHeight:0,lineMinorTop:0,lineMinorWidth:0,top:0},contentHeight:0,contentLeft:0,contentWidth:0,frameHeight:0,frameWidth:0,groupsLeft:0,groupsWidth:0,items:{top:0}};this.dom.container=a;this.options={width:"100%",height:"auto",minHeight:0,groupMinHeight:0,autoHeight:true,eventMargin:10,eventMarginAxis:20,dragAreaWidth:10,min:undefined,max:undefined,zoomMin:10,zoomMax:1000*60*60*24*365*10000,moveable:true,zoomable:true,selectable:true,unselectable:true,editable:false,snapEvents:true,groupsChangeable:true,timeChangeable:true,showCurrentTime:true,showCustomTime:false,showMajorLabels:true,showMinorLabels:true,showNavigation:false,showButtonNew:false,groupsOnRight:false,groupsOrder:true,axisOnTop:false,stackEvents:true,animate:true,animateZoom:true,cluster:false,clusterMaxItems:5,style:"box",customStackOrder:false,locale:"en",MONTHS:["January","February","March","April","May","June","July","August","September","October","November","December"],MONTHS_SHORT:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],DAYS:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],DAYS_SHORT:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ZOOM_IN:"Zoom in",ZOOM_OUT:"Zoom out",MOVE_LEFT:"Move left",MOVE_RIGHT:"Move right",NEW:"New",CREATE_NEW_EVENT:"Create new event"};this.setOptions(b);this.clientTimeOffset=0;var d=this.dom;while(d.container.hasChildNodes()){d.container.removeChild(d.container.firstChild)}this.step=new links.Timeline.StepDate();this.itemTypes={box:links.Timeline.ItemBox,range:links.Timeline.ItemRange,floatingRange:links.Timeline.ItemFloatingRange,dot:links.Timeline.ItemDot};this.data=[];this.firstDraw=true;this.setVisibleChartRange(undefined,undefined,false);this.render();var c=this;setTimeout(function(){c.trigger("ready")},0)};links.Timeline.prototype.draw=function(b,a){if(a){console.log("WARNING: Passing options in draw() is deprecated. Pass options to the constructur or use setOptions() instead!");this.setOptions(a)}if(this.options.selectable){links.Timeline.addClassName(this.dom.frame,"timeline-selectable")}this.setData(b);if(this.firstDraw){this.setVisibleChartRangeAuto()}this.firstDraw=false};links.Timeline.prototype.setOptions=function(b){if(b){for(var d in b){if(b.hasOwnProperty(d)){this.options[d]=b[d]}}if(typeof links.locales!=="undefined"&&this.options.locale!=="en"){var c=links.locales[this.options.locale];if(c){for(var a in c){if(c.hasOwnProperty(a)){this.options[a]=c[a]}}}}if(b.showButtonAdd!=undefined){this.options.showButtonNew=b.showButtonAdd;console.log("WARNING: Option showButtonAdd is deprecated. Use showButtonNew instead")}if(b.intervalMin!=undefined){this.options.zoomMin=b.intervalMin;console.log("WARNING: Option intervalMin is deprecated. Use zoomMin instead")}if(b.intervalMax!=undefined){this.options.zoomMax=b.intervalMax;console.log("WARNING: Option intervalMax is deprecated. Use zoomMax instead")}if(b.scale&&b.step){this.step.setScale(b.scale,b.step)}}this.options.autoHeight=(this.options.height==="auto")};links.Timeline.prototype.getOptions=function(){return this.options};links.Timeline.prototype.addItemType=function(a,b){this.itemTypes[a]=b};links.Timeline.mapColumnIds=function(c){var d={},b=c.getNumberOfColumns(),f=true;for(var a=0;a<b;a++){var e=c.getColumnId(a)||c.getColumnLabel(a);d[e]=a;if(e=="start"||e=="end"||e=="content"||e=="group"||e=="className"||e=="editable"||e=="type"){f=false}}if(f){d.start=0;d.end=1;d.content=2;if(b>3){d.group=3}if(b>4){d.className=4}if(b>5){d.editable=5}if(b>6){d.type=6}}return d};links.Timeline.prototype.setData=function(e){this.unselectItem();if(!e){e=[]}this.stackCancelAnimation();this.clearItems();this.data=e;var b=this.items;this.deleteGroups();if(google&&google.visualization&&e instanceof google.visualization.DataTable){var f=links.Timeline.mapColumnIds(e);for(var g=0,d=e.getNumberOfRows();g<d;g++){b.push(this.createItem({start:((f.start!=undefined)?e.getValue(g,f.start):undefined),end:((f.end!=undefined)?e.getValue(g,f.end):undefined),content:((f.content!=undefined)?e.getValue(g,f.content):undefined),group:((f.group!=undefined)?e.getValue(g,f.group):undefined),className:((f.className!=undefined)?e.getValue(g,f.className):undefined),editable:((f.editable!=undefined)?e.getValue(g,f.editable):undefined),type:((f.type!=undefined)?e.getValue(g,f.type):undefined)}))}}else{if(links.Timeline.isArray(e)){for(var g=0,d=e.length;g<d;g++){var a=e[g];var c=this.createItem(a);b.push(c)}}else{throw"Unknown data type. DataTable or Array expected."}}if(this.options.cluster){this.clusterGenerator.setData(this.items)}this.render({animate:false})};links.Timeline.prototype.getData=function(){return this.data};links.Timeline.prototype.updateData=function(e,i){var d=this.data,a;if(google&&google.visualization&&d instanceof google.visualization.DataTable){var g=(e+1)-d.getNumberOfRows();if(g>0){d.addRows(g)}var f=links.Timeline.mapColumnIds(d);for(a in i){if(i.hasOwnProperty(a)){var b=f[a];if(b==undefined){var h=i[a];var c="string";if(typeof(h)=="number"){c="number"}else{if(typeof(h)=="boolean"){c="boolean"}else{if(h instanceof Date){c="datetime"}}}b=d.addColumn(c,a)}d.setValue(e,b,i[a])}}}else{if(links.Timeline.isArray(d)){var k=d[e];if(k==undefined){k={};d[e]=k}for(a in i){if(i.hasOwnProperty(a)){k[a]=i[a]}}}else{throw"Cannot update data, unknown type of data"}}};links.Timeline.prototype.getItemIndex=function(f){var g=f,k=this.dom,h=k.items.frame,b=this.items,c=undefined;while(g.parentNode&&g.parentNode!==h){g=g.parentNode}if(g.parentNode===h){for(var d=0,a=b.length;d<a;d++){if(b[d].dom===g){c=d;break}}}return c};links.Timeline.prototype.getClusterIndex=function(d){var g=d,k=this.dom,h=k.items.frame,f=this.clusters,b=undefined;if(this.clusters){while(g.parentNode&&g.parentNode!==h){g=g.parentNode}if(g.parentNode===h){for(var c=0,a=f.length;c<a;c++){if(f[c].dom===g){b=c;break}}}}return b};links.Timeline.prototype.getVisibleItems=function(g,b){var c=this.items;var f=[];if(c){for(var d=0,a=c.length;d<a;d++){var e=c[d];if(e.end){if(g<=e.start&&e.end<=b){f.push({row:d})}}else{if(g<=e.start&&e.start<=b){f.push({row:d})}}}}return f};links.Timeline.prototype.setSize=function(b,a){if(b){this.options.width=b;this.dom.frame.style.width=b}if(a){this.options.height=a;this.options.autoHeight=(this.options.height==="auto");if(a!=="auto"){this.dom.frame.style.height=a}}this.render({animate:false})};links.Timeline.prototype.setVisibleChartRange=function(f,b,e){var c={};if(!f||!b){c=this.getDataRange(true)}if(!f){if(b){if(c.min&&c.min.valueOf()<b.valueOf()){f=c.min}else{f=new Date(b.valueOf());f.setDate(f.getDate()-7)}}else{f=new Date();f.setDate(f.getDate()-3)}}if(!b){if(c.max){b=c.max}else{b=new Date(f.valueOf());b.setDate(b.getDate()+7)}}if(b<=f){b=new Date(f.valueOf());b.setDate(b.getDate()+7)}var d=this.options.min?this.options.min:undefined;if(d!=undefined&&f.valueOf()<d.valueOf()){f=new Date(d.valueOf())}var a=this.options.max?this.options.max:undefined;if(a!=undefined&&b.valueOf()>a.valueOf()){b=new Date(a.valueOf())}this.applyRange(f,b);if(e==undefined||e==true){this.render({animate:false})}else{this.recalcConversion()}};links.Timeline.prototype.setVisibleChartRangeAuto=function(){if(this.options&&(this.options.start||this.options.end)){this.setVisibleChartRange(this.options.start,this.options.end)}else{var a=this.getDataRange(true);this.setVisibleChartRange(a.min,a.max)}};links.Timeline.prototype.setVisibleChartRangeNow=function(){var a=new Date();var b=(this.end.valueOf()-this.start.valueOf());var d=new Date(a.valueOf()-b/2);var c=new Date(d.valueOf()+b);this.setVisibleChartRange(d,c)};links.Timeline.prototype.getVisibleChartRange=function(){return{start:new Date(this.start.valueOf()),end:new Date(this.end.valueOf())}};links.Timeline.prototype.getDataRange=function(b){var g=this.items,d=undefined,h=undefined;if(g){for(var f=0,e=g.length;f<e;f++){var l=g[f],a=l.start!=undefined?l.start.valueOf():undefined,c=l.end!=undefined?l.end.valueOf():a;if(a!=undefined){d=(d!=undefined)?Math.min(d.valueOf(),a.valueOf()):a}if(c!=undefined){h=(h!=undefined)?Math.max(h.valueOf(),c.valueOf()):c}}}if(d&&h&&b){var k=(h-d);d=d-k*0.05;h=h+k*0.05}return{min:d!=undefined?new Date(d):undefined,max:h!=undefined?new Date(h):undefined}};links.Timeline.prototype.render=function(i){var e=this.reflowFrame();var h=this.reflowAxis();var d=this.reflowGroups();var g=this.reflowItems();var f=(e||h||d||g);var a=this.options.animate;if(i&&i.animate!=undefined){a=i.animate}this.recalcConversion();this.clusterItems();this.filterItems();this.stackItems(a);this.recalcItems();var b=this.repaint();if(b){var c=i?i.renderTimesLeft:undefined;if(c==undefined){c=5}if(c>0){this.render({animate:i?i.animate:undefined,renderTimesLeft:(c-1)})}}};links.Timeline.prototype.repaint=function(){var b=this.repaintFrame();var a=this.repaintAxis();var d=this.repaintGroups();var c=this.repaintItems();this.repaintCurrentTime();this.repaintCustomTime();return(b||a||d||c)};links.Timeline.prototype.reflowFrame=function(){var f=this.dom,d=this.options,e=this.size,b=false;var a=f.frame?f.frame.offsetWidth:0,c=f.frame?f.frame.clientHeight:0;b=b||(e.frameWidth!==a);b=b||(e.frameHeight!==c);e.frameWidth=a;e.frameHeight=c;return b};links.Timeline.prototype.repaintFrame=function(){var b=false,d=this.dom,i=this.options,h=this.size;if(!d.frame){d.frame=document.createElement("DIV");d.frame.className="timeline-frame ui-widget ui-widget-content ui-corner-all";d.container.appendChild(d.frame);b=true}var g=i.autoHeight?(h.actualHeight+"px"):(i.height||"100%");var a=i.width||"100%";b=b||(d.frame.style.height!=g);b=b||(d.frame.style.width!=a);d.frame.style.height=g;d.frame.style.width=a;if(!d.content){d.content=document.createElement("DIV");d.content.className="timeline-content";d.frame.appendChild(d.content);var e=document.createElement("DIV");e.style.position="absolute";e.style.left="0px";e.style.top="0px";e.style.height="100%";e.style.width="0px";d.content.appendChild(e);d.contentTimelines=e;var c=this.eventParams,f=this;if(!c.onMouseDown){c.onMouseDown=function(k){f.onMouseDown(k)};links.Timeline.addEventListener(d.content,"mousedown",c.onMouseDown)}if(!c.onTouchStart){c.onTouchStart=function(k){f.onTouchStart(k)};links.Timeline.addEventListener(d.content,"touchstart",c.onTouchStart)}if(!c.onMouseWheel){c.onMouseWheel=function(k){f.onMouseWheel(k)};links.Timeline.addEventListener(d.content,"mousewheel",c.onMouseWheel)}if(!c.onDblClick){c.onDblClick=function(k){f.onDblClick(k)};links.Timeline.addEventListener(d.content,"dblclick",c.onDblClick)}b=true}d.content.style.left=h.contentLeft+"px";d.content.style.top="0px";d.content.style.width=h.contentWidth+"px";d.content.style.height=h.frameHeight+"px";this.repaintNavigation();return b};links.Timeline.prototype.reflowAxis=function(){var h=false,g=this.dom,n=this.options,m=this.size,k=g.axis;var i=(k&&k.characterMinor)?k.characterMinor.clientWidth:0,f=(k&&k.characterMinor)?k.characterMinor.clientHeight:0,b=(k&&k.characterMajor)?k.characterMajor.clientWidth:0,e=(k&&k.characterMajor)?k.characterMajor.clientHeight:0,d=(n.showMinorLabels?f:0)+(n.showMajorLabels?e:0);var a=n.axisOnTop?0:m.frameHeight-d,c=n.axisOnTop?d:a;h=h||(m.axis.top!==a);h=h||(m.axis.line!==c);h=h||(m.axis.height!==d);m.axis.top=a;m.axis.line=c;m.axis.height=d;m.axis.labelMajorTop=n.axisOnTop?0:c+(n.showMinorLabels?f:0);m.axis.labelMinorTop=n.axisOnTop?(n.showMajorLabels?e:0):c;m.axis.lineMinorTop=n.axisOnTop?m.axis.labelMinorTop:0;m.axis.lineMinorHeight=n.showMajorLabels?m.frameHeight-e:m.frameHeight;if(k&&k.minorLines&&k.minorLines.length){m.axis.lineMinorWidth=k.minorLines[0].offsetWidth}else{m.axis.lineMinorWidth=1}if(k&&k.majorLines&&k.majorLines.length){m.axis.lineMajorWidth=k.majorLines[0].offsetWidth}else{m.axis.lineMajorWidth=1}h=h||(m.axis.characterMinorWidth!==i);h=h||(m.axis.characterMinorHeight!==f);h=h||(m.axis.characterMajorWidth!==b);h=h||(m.axis.characterMajorHeight!==e);m.axis.characterMinorWidth=i;m.axis.characterMinorHeight=f;m.axis.characterMajorWidth=b;m.axis.characterMajorHeight=e;var l=Math.max(m.frameHeight-d,0);m.contentLeft=n.groupsOnRight?0:m.groupsWidth;m.contentWidth=Math.max(m.frameWidth-m.groupsWidth,0);m.contentHeight=l;return h};links.Timeline.prototype.repaintAxis=function(){var f=false,i=this.dom,r=this.options,q=this.size,e=this.step;var g=i.axis;if(!g){g={};i.axis=g}if(!q.axis.properties){q.axis.properties={}}if(!g.minorTexts){g.minorTexts=[]}if(!g.minorLines){g.minorLines=[]}if(!g.majorTexts){g.majorTexts=[]}if(!g.majorLines){g.majorLines=[]}if(!g.frame){g.frame=document.createElement("DIV");g.frame.style.position="absolute";g.frame.style.left="0px";g.frame.style.top="0px";i.content.appendChild(g.frame)}i.content.removeChild(g.frame);g.frame.style.width=(q.contentWidth)+"px";g.frame.style.height=(q.axis.height)+"px";var d=this.screenToTime(0);var h=this.screenToTime(q.contentWidth);if(q.axis.characterMinorWidth){this.minimumStep=this.screenToTime(q.axis.characterMinorWidth*6)-this.screenToTime(0);e.setRange(d,h,this.minimumStep)}var o=this.repaintAxisCharacters();f=f||o;this.repaintAxisStartOverwriting();e.start();var a=undefined;var l=0;while(!e.end()&&l<1000){l++;var p=e.getCurrent(),n=this.timeToScreen(p),k=e.isMajor();if(r.showMinorLabels){this.repaintAxisMinorText(n,e.getLabelMinor(r))}if(k&&r.showMajorLabels){if(n>0){if(a==undefined){a=n}this.repaintAxisMajorText(n,e.getLabelMajor(r))}this.repaintAxisMajorLine(n)}else{this.repaintAxisMinorLine(n)}e.next()}if(r.showMajorLabels){var c=this.screenToTime(0),m=this.step.getLabelMajor(r,c),b=m.length*q.axis.characterMajorWidth+10;if(a==undefined||b<a){this.repaintAxisMajorText(0,m,c)}}this.repaintAxisEndOverwriting();this.repaintAxisHorizontal();i.content.insertBefore(g.frame,i.content.firstChild);return f};links.Timeline.prototype.repaintAxisCharacters=function(){var c=false,f=this.dom,b=f.axis,e;if(!b.characterMinor){e=document.createTextNode("0");var a=document.createElement("DIV");a.className="timeline-axis-text timeline-axis-text-minor";a.appendChild(e);a.style.position="absolute";a.style.visibility="hidden";a.style.paddingLeft="0px";a.style.paddingRight="0px";b.frame.appendChild(a);b.characterMinor=a;c=true}if(!b.characterMajor){e=document.createTextNode("0");var d=document.createElement("DIV");d.className="timeline-axis-text timeline-axis-text-major";d.appendChild(e);d.style.position="absolute";d.style.visibility="hidden";d.style.paddingLeft="0px";d.style.paddingRight="0px";b.frame.appendChild(d);b.characterMajor=d;c=true}return c};links.Timeline.prototype.repaintAxisStartOverwriting=function(){var a=this.size.axis.properties;a.minorTextNum=0;a.minorLineNum=0;a.majorTextNum=0;a.majorLineNum=0};links.Timeline.prototype.repaintAxisEndOverwriting=function(){var b=this.dom,i=this.size.axis.properties,a=this.dom.axis.frame,e;var l=b.axis.minorTexts;e=i.minorTextNum;while(l.length>e){var c=l[e];a.removeChild(c);l.splice(e,1)}var d=b.axis.minorLines;e=i.minorLineNum;while(d.length>e){var f=d[e];a.removeChild(f);d.splice(e,1)}var m=b.axis.majorTexts;e=i.majorTextNum;while(m.length>e){var h=m[e];a.removeChild(h);m.splice(e,1)}var g=b.axis.majorLines;e=i.majorLineNum;while(g.length>e){var k=g[e];a.removeChild(k);g.splice(e,1)}};links.Timeline.prototype.repaintAxisHorizontal=function(){var e=this.dom.axis,d=this.size,c=this.options;var a=(c.showMinorLabels||c.showMajorLabels);if(a){if(!e.backgroundLine){var f=document.createElement("DIV");f.className="timeline-axis";f.style.position="absolute";f.style.left="0px";f.style.width="100%";f.style.border="none";e.frame.insertBefore(f,e.frame.firstChild);e.backgroundLine=f}if(e.backgroundLine){e.backgroundLine.style.top=d.axis.top+"px";e.backgroundLine.style.height=d.axis.height+"px"}}else{if(e.backgroundLine){e.frame.removeChild(e.backgroundLine);delete e.backgroundLine}}if(a){if(e.line){var b=e.frame.removeChild(e.line);e.frame.appendChild(b)}else{var b=document.createElement("DIV");b.className="timeline-axis";b.style.position="absolute";b.style.left="0px";b.style.width="100%";b.style.height="0px";e.frame.appendChild(b);e.line=b}e.line.style.top=d.axis.line+"px"}else{if(e.line&&e.line.parentElement){e.frame.removeChild(e.line);delete e.line}}};links.Timeline.prototype.repaintAxisMinorText=function(h,i){var k=this.size,b=this.dom,e=k.axis.properties,a=b.axis.frame,g=b.axis.minorTexts,c=e.minorTextNum,f;if(c<g.length){f=g[c]}else{var d=document.createTextNode("");f=document.createElement("DIV");f.appendChild(d);f.className="timeline-axis-text timeline-axis-text-minor";f.style.position="absolute";a.appendChild(f);g.push(f)}f.childNodes[0].nodeValue=i;f.style.left=h+"px";f.style.top=k.axis.labelMinorTop+"px";e.minorTextNum++};links.Timeline.prototype.repaintAxisMinorLine=function(a){var e=this.size.axis,h=this.dom,d=e.properties,g=h.axis.frame,f=h.axis.minorLines,c=d.minorLineNum,b;if(c<f.length){b=f[c]}else{b=document.createElement("DIV");b.className="timeline-axis-grid timeline-axis-grid-minor";b.style.position="absolute";b.style.width="0px";g.appendChild(b);f.push(b)}b.style.top=e.lineMinorTop+"px";b.style.height=e.lineMinorHeight+"px";b.style.left=(a-e.lineMinorWidth/2)+"px";d.minorLineNum++};links.Timeline.prototype.repaintAxisMajorText=function(f,h){var i=this.size,d=i.axis.properties,a=this.dom.axis.frame,g=this.dom.axis.majorTexts,b=d.majorTextNum,e;if(b<g.length){e=g[b]}else{var c=document.createTextNode(h);e=document.createElement("DIV");e.className="timeline-axis-text timeline-axis-text-major";e.appendChild(c);e.style.position="absolute";e.style.top="0px";a.appendChild(e);g.push(e)}e.childNodes[0].nodeValue=h;e.style.top=i.axis.labelMajorTop+"px";e.style.left=f+"px";d.majorTextNum++};links.Timeline.prototype.repaintAxisMajorLine=function(a){var e=this.size,g=e.axis.properties,f=this.size.axis,h=this.dom.axis.frame,d=this.dom.axis.majorLines,c=g.majorLineNum,b;if(c<d.length){b=d[c]}else{b=document.createElement("DIV");b.className="timeline-axis-grid timeline-axis-grid-major";b.style.position="absolute";b.style.top="0px";b.style.width="0px";h.appendChild(b);d.push(b)}b.style.left=(a-f.lineMajorWidth/2)+"px";b.style.height=e.frameHeight+"px";g.majorLineNum++};links.Timeline.prototype.reflowItems=function(){var g=false,f,e,h,d=this.groups,c=this.renderedItems;if(d){d.forEach(function(i){i.itemsHeight=i.labelHeight||0})}for(f=0,e=c.length;f<e;f++){var l=c[f],a=l.dom;h=l.group;if(a){var b=a?a.clientWidth:0;var k=a?a.clientHeight:0;g=g||(l.width!=b);g=g||(l.height!=k);l.width=b;l.height=k;l.reflow()}if(h){h.itemsHeight=Math.max(this.options.groupMinHeight,h.itemsHeight?Math.max(h.itemsHeight,l.height):l.height)}}return g};links.Timeline.prototype.recalcItems=function(){var r=false,q,m,s,u,f,d,t=this.groups,l=this.size,b=this.options,o=this.renderedItems;var a=0;if(t.length==0){if(b.autoHeight||b.cluster){var n=0,p=0;if(this.stack&&this.stack.finalItems){f=this.stack.finalItems;u=f[0];if(u&&u.top){n=u.top;p=u.top+u.height}for(q=1,m=f.length;q<m;q++){u=f[q];n=Math.min(n,u.top);p=Math.max(p,u.top+u.height)}}else{s=o[0];if(s&&s.top){n=s.top;p=s.top+s.height}for(q=1,m=o.length;q<m;q++){s=o[q];if(s.top){n=Math.min(n,s.top);p=Math.max(p,(s.top+s.height))}}}a=(p-n)+2*b.eventMarginAxis+l.axis.height;if(a<b.minHeight){a=b.minHeight}if(l.actualHeight!=a&&b.autoHeight&&!b.axisOnTop){var g=a-l.actualHeight;if(this.stack&&this.stack.finalItems){f=this.stack.finalItems;for(q=0,m=f.length;q<m;q++){f[q].top+=g;f[q].item.top+=g}}else{for(q=0,m=o.length;q<m;q++){o[q].top+=g}}}}}else{a=l.axis.height+2*b.eventMarginAxis;for(q=0,m=t.length;q<m;q++){d=t[q];var k=d.itemsHeight;r=r||(k!=d.height);d.height=Math.max(k,b.groupMinHeight);a+=t[q].height+b.eventMargin}var c=b.eventMargin,h=b.axisOnTop?b.eventMarginAxis+c/2:l.contentHeight-b.eventMarginAxis+c/2,e=l.axis.height;for(q=0,m=t.length;q<m;q++){d=t[q];if(b.axisOnTop){d.top=h+e;d.labelTop=h+e+(d.height-d.labelHeight)/2;d.lineTop=h+e+d.height+c/2;h+=d.height+c}else{h-=d.height+c;d.top=h;d.labelTop=h+(d.height-d.labelHeight)/2;d.lineTop=h-c/2}}r=true}if(a<b.minHeight){a=b.minHeight}r=r||(a!=l.actualHeight);l.actualHeight=a;return r};links.Timeline.prototype.clearItems=function(){var a=this.renderQueue.hide;this.renderedItems.forEach(function(b){a.push(b)});this.clusterGenerator.clear();this.items=[]};links.Timeline.prototype.repaintItems=function(){var h,g,o,l;var d=false,f=this.dom,p=this.size,n=this,b=this.renderedItems;if(!f.items){f.items={}}var a=f.items.frame;if(!a){a=document.createElement("DIV");a.style.position="relative";f.content.appendChild(a);f.items.frame=a}a.style.left="0px";a.style.top=p.items.top+"px";a.style.height="0px";f.content.removeChild(a);var k=this.renderQueue;var c=[];d=d||(k.show.length>0)||(k.update.length>0)||(k.hide.length>0);while(o=k.show.shift()){o.showDOM(a);o.getImageUrls(c);b.push(o)}while(o=k.update.shift()){o.updateDOM(a);o.getImageUrls(c);l=this.renderedItems.indexOf(o);if(l==-1){b.push(o)}}while(o=k.hide.shift()){o.hideDOM(a);l=this.renderedItems.indexOf(o);if(l!=-1){b.splice(l,1)}}b.forEach(function(i){i.updatePosition(n)});this.repaintDeleteButton();this.repaintDragAreas();f.content.appendChild(a);if(c.length){var m=function(){n.render()};var e=false;links.imageloader.loadAll(c,m,e)}return d};links.Timeline.prototype.reflowGroups=function(){var f=false,n=this.options,m=this.size,d=this.dom;var k=0;var b=this.groups;var g=this.dom.groups?this.dom.groups.labels:[];for(var e=0,c=b.length;e<c;e++){var l=b[e];var h=g[e];l.labelWidth=h?h.clientWidth:0;l.labelHeight=h?h.clientHeight:0;l.width=l.labelWidth;k=Math.max(k,l.width)}if(n.groupsWidth!==undefined){k=d.groups&&d.groups.frame?d.groups.frame.clientWidth:0}k+=1;var a=n.groupsOnRight?m.frameWidth-k:0;f=f||(m.groupsWidth!==k);f=f||(m.groupsLeft!==a);m.groupsWidth=k;m.groupsLeft=a;return f};links.Timeline.prototype.repaintGroups=function(){var v=this.dom,f=this,b=this.options,o=this.size,x=this.groups;if(v.groups===undefined){v.groups={}}var w=v.groups.labels;if(!w){w=[];v.groups.labels=w}var g=v.groups.labelLines;if(!g){g=[];v.groups.labelLines=g}var p=v.groups.itemLines;if(!p){p=[];v.groups.itemLines=p}var n=v.groups.frame;if(!n){n=document.createElement("DIV");n.className="timeline-groups-axis";n.style.position="absolute";n.style.overflow="hidden";n.style.top="0px";n.style.height="100%";v.frame.appendChild(n);v.groups.frame=n}n.style.left=o.groupsLeft+"px";n.style.width=(b.groupsWidth!==undefined)?b.groupsWidth:o.groupsWidth+"px";if(x.length==0){n.style.display="none"}else{n.style.display=""}var r=w.length,l=x.length;for(var t=0,s=Math.min(r,l);t<s;t++){var h=x[t];var k=w[t];k.innerHTML=this.getGroupName(h);k.style.display=""}for(var t=r;t<l;t++){var h=x[t];var k=document.createElement("DIV");k.className="timeline-groups-text";k.style.position="absolute";if(b.groupsWidth===undefined){k.style.whiteSpace="nowrap"}k.innerHTML=this.getGroupName(h);n.appendChild(k);w[t]=k;var e=document.createElement("DIV");e.className="timeline-axis-grid timeline-axis-grid-minor";e.style.position="absolute";e.style.left="0px";e.style.width="100%";e.style.height="0px";e.style.borderTopStyle="solid";n.appendChild(e);g[t]=e;var d=document.createElement("DIV");d.className="timeline-axis-grid timeline-axis-grid-minor";d.style.position="absolute";d.style.left="0px";d.style.width="100%";d.style.height="0px";d.style.borderTopStyle="solid";v.content.insertBefore(d,v.content.firstChild);p[t]=d}for(var t=l;t<r;t++){var k=w[t],e=g[t],d=p[t];n.removeChild(k);n.removeChild(e);v.content.removeChild(d)}w.splice(l,r-l);g.splice(l,r-l);p.splice(l,r-l);links.Timeline.addClassName(n,b.groupsOnRight?"timeline-groups-axis-onright":"timeline-groups-axis-onleft");for(var t=0,s=x.length;t<s;t++){var h=x[t],k=w[t],e=g[t],d=p[t];k.style.top=h.labelTop+"px";e.style.top=h.lineTop+"px";d.style.top=h.lineTop+"px";d.style.width=o.contentWidth+"px"}if(!v.groups.background){var u=document.createElement("DIV");u.className="timeline-axis";u.style.position="absolute";u.style.left="0px";u.style.width="100%";u.style.border="none";n.appendChild(u);v.groups.background=u}v.groups.background.style.top=o.axis.top+"px";v.groups.background.style.height=o.axis.height+"px";if(!v.groups.line){var m=document.createElement("DIV");m.className="timeline-axis";m.style.position="absolute";m.style.left="0px";m.style.width="100%";m.style.height="0px";n.appendChild(m);v.groups.line=m}v.groups.line.style.top=o.axis.line+"px";if(v.groups.frame&&x.length){var q=[];links.imageloader.filterImageUrls(v.groups.frame,q);if(q.length){var c=function(){f.render()};var a=false;links.imageloader.loadAll(q,c,a)}}};links.Timeline.prototype.repaintCurrentTime=function(){var l=this.options,e=this.dom,k=this.size;if(!l.showCurrentTime){if(e.currentTime){e.contentTimelines.removeChild(e.currentTime);delete e.currentTime}return}if(!e.currentTime){var a=document.createElement("DIV");a.className="timeline-currenttime";a.style.position="absolute";a.style.top="0px";a.style.height="100%";e.contentTimelines.appendChild(a);e.currentTime=a}var b=new Date();var f=new Date(b.valueOf()+this.clientTimeOffset);var h=this.timeToScreen(f);var d=(h>-k.contentWidth&&h<2*k.contentWidth);e.currentTime.style.display=d?"":"none";e.currentTime.style.left=h+"px";e.currentTime.title="Current time: "+f;if(this.currentTimeTimer!=undefined){clearTimeout(this.currentTimeTimer);delete this.currentTimeTimer}var i=this;var g=function(){i.repaintCurrentTime()};var c=1/this.conversion.factor/2;if(c<30){c=30}this.currentTimeTimer=setTimeout(g,c)};links.Timeline.prototype.repaintCustomTime=function(){var c=this.options,g=this.dom,d=this.size;if(!c.showCustomTime){if(g.customTime){g.contentTimelines.removeChild(g.customTime);delete g.customTime}return}if(!g.customTime){var b=document.createElement("DIV");b.className="timeline-customtime";b.style.position="absolute";b.style.top="0px";b.style.height="100%";var e=document.createElement("DIV");e.style.position="relative";e.style.top="0px";e.style.left="-10px";e.style.height="100%";e.style.width="20px";b.appendChild(e);g.contentTimelines.appendChild(b);g.customTime=b;this.customTime=new Date()}var a=this.timeToScreen(this.customTime),f=(a>-d.contentWidth&&a<2*d.contentWidth);g.customTime.style.display=f?"":"none";g.customTime.style.left=a+"px";g.customTime.title="Time: "+this.customTime};links.Timeline.prototype.repaintDeleteButton=function(){var d=this,g=this.dom,f=g.items.frame;var h=g.items.deleteButton;if(!h){h=document.createElement("DIV");h.className="timeline-navigation-delete";h.style.position="absolute";f.appendChild(h);g.items.deleteButton=h}var a=(this.selection&&this.selection.index!==undefined)?this.selection.index:-1,c=(this.selection&&this.selection.index!==undefined)?this.items[a]:undefined;if(c&&c.rendered&&this.isEditable(c)){var b=c.getRight(this),e=c.top;h.style.left=b+"px";h.style.top=e+"px";h.style.display="";f.removeChild(h);f.appendChild(h)}else{h.style.display="none"}};links.Timeline.prototype.repaintDragAreas=function(){var k=this,m=this.options,d=this.dom,a=this.dom.items.frame;var c=d.items.dragLeft;if(!c){c=document.createElement("DIV");c.className="timeline-event-range-drag-left";c.style.position="absolute";a.appendChild(c);d.items.dragLeft=c}var e=d.items.dragRight;if(!e){e=document.createElement("DIV");e.className="timeline-event-range-drag-right";e.style.position="absolute";a.appendChild(e);d.items.dragRight=e}var f=(this.selection&&this.selection.index!==undefined)?this.selection.index:-1,l=(this.selection&&this.selection.index!==undefined)?this.items[f]:undefined;if(l&&l.rendered&&this.isEditable(l)&&(l instanceof links.Timeline.ItemRange||l instanceof links.Timeline.ItemFloatingRange)){var b=l.getLeft(this),h=l.getRight(this),g=l.top,i=l.height;c.style.left=b+"px";c.style.top=g+"px";c.style.width=m.dragAreaWidth+"px";c.style.height=i+"px";c.style.display="";a.removeChild(c);a.appendChild(c);e.style.left=(h-m.dragAreaWidth)+"px";e.style.top=g+"px";e.style.width=m.dragAreaWidth+"px";e.style.height=i+"px";e.style.display="";a.removeChild(e);a.appendChild(e)}else{c.style.display="none";e.style.display="none"}};links.Timeline.prototype.repaintNavigation=function(){var q=this,r=this.options,i=this.dom,e=i.frame,f=i.navBar;if(!f){var a=r.showButtonNew&&r.editable;var d=r.showNavigation&&(r.zoomable||r.moveable);if(d||a){f=document.createElement("DIV");f.style.position="absolute";f.className="timeline-navigation ui-widget ui-state-highlight ui-corner-all";if(r.groupsOnRight){f.style.left="10px"}else{f.style.right="10px"}if(r.axisOnTop){f.style.bottom="10px"}else{f.style.top="10px"}i.navBar=f;e.appendChild(f)}if(a){f.addButton=document.createElement("DIV");f.addButton.className="timeline-navigation-new";f.addButton.title=r.CREATE_NEW_EVENT;var h=document.createElement("SPAN");h.className="ui-icon ui-icon-circle-plus";f.addButton.appendChild(h);var m=function(A){links.Timeline.preventDefault(A);links.Timeline.stopPropagation(A);var t=q.size.contentWidth;var s=t/2;var u=q.screenToTime(s);if(r.snapEvents){q.step.snap(u)}var z=r.NEW;var B=q.groups.length?q.groups[0].content:undefined;var y=true;q.addItem({start:u,content:z,group:B},y);var v=(q.items.length-1);q.selectItem(v);q.applyAdd=true;q.trigger("add");if(q.applyAdd){q.render({animate:false});q.selectItem(v)}else{q.deleteItem(v)}};links.Timeline.addEventListener(f.addButton,"mousedown",m);f.appendChild(f.addButton)}if(a&&d){links.Timeline.addClassName(f.addButton,"timeline-navigation-new-line")}if(d){if(r.zoomable){f.zoomInButton=document.createElement("DIV");f.zoomInButton.className="timeline-navigation-zoom-in";f.zoomInButton.title=this.options.ZOOM_IN;var p=document.createElement("SPAN");p.className="ui-icon ui-icon-circle-zoomin";f.zoomInButton.appendChild(p);var c=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.zoom(0.4);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.zoomInButton,"mousedown",c);f.appendChild(f.zoomInButton);f.zoomOutButton=document.createElement("DIV");f.zoomOutButton.className="timeline-navigation-zoom-out";f.zoomOutButton.title=this.options.ZOOM_OUT;var l=document.createElement("SPAN");l.className="ui-icon ui-icon-circle-zoomout";f.zoomOutButton.appendChild(l);var k=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.zoom(-0.4);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.zoomOutButton,"mousedown",k);f.appendChild(f.zoomOutButton)}if(r.moveable){f.moveLeftButton=document.createElement("DIV");f.moveLeftButton.className="timeline-navigation-move-left";f.moveLeftButton.title=this.options.MOVE_LEFT;var o=document.createElement("SPAN");o.className="ui-icon ui-icon-circle-arrow-w";f.moveLeftButton.appendChild(o);var n=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.move(-0.2);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.moveLeftButton,"mousedown",n);f.appendChild(f.moveLeftButton);f.moveRightButton=document.createElement("DIV");f.moveRightButton.className="timeline-navigation-move-right";f.moveRightButton.title=this.options.MOVE_RIGHT;var g=document.createElement("SPAN");g.className="ui-icon ui-icon-circle-arrow-e";f.moveRightButton.appendChild(g);var b=function(s){links.Timeline.preventDefault(s);links.Timeline.stopPropagation(s);q.move(0.2);q.trigger("rangechange");q.trigger("rangechanged")};links.Timeline.addEventListener(f.moveRightButton,"mousedown",b);f.appendChild(f.moveRightButton)}}}};links.Timeline.prototype.setCurrentTime=function(b){var a=new Date();this.clientTimeOffset=(b.valueOf()-a.valueOf());this.repaintCurrentTime()};links.Timeline.prototype.getCurrentTime=function(){var a=new Date();return new Date(a.valueOf()+this.clientTimeOffset)};links.Timeline.prototype.setCustomTime=function(a){this.customTime=new Date(a.valueOf());this.repaintCustomTime()};links.Timeline.prototype.getCustomTime=function(){return new Date(this.customTime.valueOf())};links.Timeline.prototype.setScale=function(b,a){this.step.setScale(b,a);this.render()};links.Timeline.prototype.setAutoScale=function(a){this.step.setAutoScale(a);this.render()};links.Timeline.prototype.redraw=function(){this.setData(this.data)};links.Timeline.prototype.checkResize=function(){this.render()};links.Timeline.prototype.isEditable=function(a){if(a){if(a.editable!=undefined){return a.editable}else{return this.options.editable}}return false};links.Timeline.prototype.recalcConversion=function(){this.conversion.offset=this.start.valueOf();this.conversion.factor=this.size.contentWidth/(this.end.valueOf()-this.start.valueOf())};links.Timeline.prototype.screenToTime=function(a){var b=this.conversion;return new Date(a/b.factor+b.offset)};links.Timeline.prototype.timeToScreen=function(b){var a=this.conversion;return(b.valueOf()-a.offset)*a.factor};links.Timeline.prototype.onTouchStart=function(c){var e=this.eventParams,b=this;if(e.touchDown){return}e.touchDown=true;e.zoomed=false;this.onMouseDown(c);if(!e.onTouchMove){e.onTouchMove=function(f){b.onTouchMove(f)};links.Timeline.addEventListener(document,"touchmove",e.onTouchMove)}if(!e.onTouchEnd){e.onTouchEnd=function(f){b.onTouchEnd(f)};links.Timeline.addEventListener(document,"touchend",e.onTouchEnd)}var d=links.Timeline.getTarget(c);var a=this.getItemIndex(d);e.doubleTapStartPrev=e.doubleTapStart;e.doubleTapStart=(new Date()).valueOf();e.doubleTapItemPrev=e.doubleTapItem;e.doubleTapItem=a;links.Timeline.preventDefault(c)};links.Timeline.prototype.onTouchMove=function(d){var g=this.eventParams;if(d.scale&&d.scale!==1){g.zoomed=true}if(!g.zoomed){this.onMouseMove(d)}else{if(this.options.zoomable){g.zoomed=true;var f=d.scale,b=(g.end.valueOf()-g.start.valueOf()),c=b/f,e=c-b,h=new Date(parseInt(g.start.valueOf()-e/2)),a=new Date(parseInt(g.end.valueOf()+e/2));this.setVisibleChartRange(h,a);this.trigger("rangechange")}}links.Timeline.preventDefault(d)};links.Timeline.prototype.onTouchEnd=function(d){var f=this.eventParams;var c=this;f.touchDown=false;if(f.zoomed){this.trigger("rangechanged")}if(f.onTouchMove){links.Timeline.removeEventListener(document,"touchmove",f.onTouchMove);delete f.onTouchMove}if(f.onTouchEnd){links.Timeline.removeEventListener(document,"touchend",f.onTouchEnd);delete f.onTouchEnd}this.onMouseUp(d);var g=500;var a=(new Date()).valueOf();var e=links.Timeline.getTarget(d);var b=this.getItemIndex(e);if(f.doubleTapStartPrev&&(a-f.doubleTapStartPrev)<g&&f.doubleTapItem==f.doubleTapItemPrev){f.touchDown=true;c.onDblClick(d);f.touchDown=false}links.Timeline.preventDefault(d)};links.Timeline.prototype.onMouseDown=function(b){b=b||window.event;var e=this.eventParams,q=this.options,f=this.dom;var p=b.which?(b.which==1):(b.button==1);if(!p&&!e.touchDown){return}e.mouseX=links.Timeline.getPageX(b);e.mouseY=links.Timeline.getPageY(b);e.frameLeft=links.Timeline.getAbsoluteLeft(this.dom.content);e.frameTop=links.Timeline.getAbsoluteTop(this.dom.content);e.previousLeft=0;e.previousOffset=0;e.moved=false;e.start=new Date(this.start.valueOf());e.end=new Date(this.end.valueOf());e.target=links.Timeline.getTarget(b);var d=(f.items&&f.items.dragLeft)?f.items.dragLeft:undefined;var g=(f.items&&f.items.dragRight)?f.items.dragRight:undefined;e.itemDragLeft=(e.target===d);e.itemDragRight=(e.target===g);if(e.itemDragLeft||e.itemDragRight){e.itemIndex=(this.selection&&this.selection.index!==undefined)?this.selection.index:undefined;delete e.clusterIndex}else{e.itemIndex=this.getItemIndex(e.target);e.clusterIndex=this.getClusterIndex(e.target)}e.customTime=(e.target===f.customTime||e.target.parentNode===f.customTime)?this.customTime:undefined;e.addItem=(q.editable&&b.ctrlKey);if(e.addItem){var l=e.mouseX-e.frameLeft;var k=e.mouseY-e.frameTop;var n=this.screenToTime(l);if(q.snapEvents){this.step.snap(n)}var a=new Date(n.valueOf());var h=q.NEW;var m=this.getGroupFromHeight(k);this.addItem({start:n,end:a,content:h,group:this.getGroupName(m)});e.itemIndex=(this.items.length-1);delete e.clusterIndex;this.selectItem(e.itemIndex);e.itemDragRight=true}var o=this.items[e.itemIndex];var c=this.isSelected(e.itemIndex);e.editItem=c&&this.isEditable(o);if(e.editItem){e.itemStart=o.start;e.itemEnd=o.end;e.itemGroup=o.group;e.itemLeft=o.getLeft(this);e.itemRight=o.getRight(this)}else{this.dom.frame.style.cursor="move"}if(!e.touchDown){var i=this;if(!e.onMouseMove){e.onMouseMove=function(r){i.onMouseMove(r)};links.Timeline.addEventListener(document,"mousemove",e.onMouseMove)}if(!e.onMouseUp){e.onMouseUp=function(r){i.onMouseUp(r)};links.Timeline.addEventListener(document,"mouseup",e.onMouseUp)}links.Timeline.preventDefault(b)}};links.Timeline.prototype.onMouseMove=function(w){w=w||window.event;var D=this.eventParams,r=this.size,z=this.dom,e=this.options;var m=links.Timeline.getPageX(w);var k=links.Timeline.getPageY(w);if(D.mouseX==undefined){D.mouseX=m}if(D.mouseY==undefined){D.mouseY=k}var t=m-D.mouseX;var s=k-D.mouseY;if(Math.abs(t)>=1){D.moved=true}if(D.customTime){var o=this.timeToScreen(D.customTime);var q=o+t;this.customTime=this.screenToTime(q);this.repaintCustomTime();this.trigger("timechange")}else{if(D.editItem){var B=this.items[D.itemIndex],f,C;if(D.itemDragLeft&&e.timeChangeable){f=D.itemLeft+t;C=D.itemRight;B.start=this.screenToTime(f);if(e.snapEvents){this.step.snap(B.start);f=this.timeToScreen(B.start)}if(f>C){f=C;B.start=this.screenToTime(f)}this.trigger("change")}else{if(D.itemDragRight&&e.timeChangeable){f=D.itemLeft;C=D.itemRight+t;B.end=this.screenToTime(C);if(e.snapEvents){this.step.snap(B.end);C=this.timeToScreen(B.end)}if(C<f){C=f;B.end=this.screenToTime(C)}this.trigger("change")}else{if(e.timeChangeable){f=D.itemLeft+t;B.start=this.screenToTime(f);if(e.snapEvents){this.step.snap(B.start);f=this.timeToScreen(B.start)}if(B.end){C=f+(D.itemRight-D.itemLeft);B.end=this.screenToTime(C)}this.trigger("change")}}}B.setPosition(f,C);var u=D.itemDragLeft||D.itemDragRight;if(this.groups.length&&!u){var n=k-D.frameTop;var i=this.getGroupFromHeight(n);if(e.groupsChangeable&&B.group!==i){var g=this.items.indexOf(B);this.changeItem(g,{group:this.getGroupName(i)})}else{this.repaintDeleteButton();this.repaintDragAreas()}}else{this.render()}}else{if(e.moveable){var A=(D.end.valueOf()-D.start.valueOf());var E=Math.round((-t)/r.contentWidth*A);var b=new Date(D.start.valueOf()+E);var a=new Date(D.end.valueOf()+E);this.applyRange(b,a);var l=(this.start.valueOf()-b.valueOf());if(l){E+=l}this.recalcConversion();var d=D.previousLeft||0;var v=parseFloat(z.items.frame.style.left)||0;var p=D.previousOffset||0;var c=p+(v-d);var h=-E/A*r.contentWidth+c;z.items.frame.style.left=(h)+"px";D.previousOffset=c;D.previousLeft=parseFloat(z.items.frame.style.left)||h;this.repaintCurrentTime();this.repaintCustomTime();this.repaintAxis();this.trigger("rangechange")}}}links.Timeline.preventDefault(w)};links.Timeline.prototype.onMouseUp=function(d){var e=this.eventParams,a=this.options;d=d||window.event;this.dom.frame.style.cursor="auto";if(e.onMouseMove){links.Timeline.removeEventListener(document,"mousemove",e.onMouseMove);delete e.onMouseMove}if(e.onMouseUp){links.Timeline.removeEventListener(document,"mouseup",e.onMouseUp);delete e.onMouseUp}if(e.customTime){this.trigger("timechanged")}else{if(e.editItem){var c=this.items[e.itemIndex];if(e.moved||e.addItem){this.applyChange=true;this.applyAdd=true;this.updateData(e.itemIndex,{start:c.start,end:c.end});this.trigger(e.addItem?"add":"changed");c=this.items[e.itemIndex];if(e.addItem){if(this.applyAdd){this.updateData(e.itemIndex,{start:c.start,end:c.end,content:c.content,group:this.getGroupName(c.group)})}else{this.deleteItem(e.itemIndex)}}else{if(this.applyChange){this.updateData(e.itemIndex,{start:c.start,end:c.end})}else{delete this.applyChange;delete this.applyAdd;var c=this.items[e.itemIndex],b=c.dom;c.start=e.itemStart;c.end=e.itemEnd;c.group=e.itemGroup;c.setPosition(e.itemLeft,e.itemRight);this.updateData(e.itemIndex,{start:e.itemStart,end:e.itemEnd})}}if(this.options.cluster){this.clusterGenerator.updateData()}this.render()}}else{if(!e.moved&&!e.zoomed){if(e.target===this.dom.items.deleteButton){if(this.selection&&this.selection.index!==undefined){this.confirmDeleteItem(this.selection.index)}}else{if(a.selectable){if(e.itemIndex!=undefined){if(!this.isSelected(e.itemIndex)){this.selectItem(e.itemIndex);this.trigger("select")}}else{if(e.clusterIndex!=undefined){this.selectCluster(e.clusterIndex);this.trigger("select")}else{if(a.unselectable){this.unselectItem();this.trigger("select")}}}}}}else{this.render();if((e.moved&&a.moveable)||(e.zoomed&&a.zoomable)){this.trigger("rangechanged")}}}}};links.Timeline.prototype.onDblClick=function(a){var b=this.eventParams,m=this.options,c=this.dom,l=this.size;a=a||window.event;if(b.itemIndex!=undefined){var k=this.items[b.itemIndex];if(k&&this.isEditable(k)){this.trigger("edit")}}else{if(m.editable){b.mouseX=links.Timeline.getPageX(a);b.mouseY=links.Timeline.getPageY(a);var g=b.mouseX-links.Timeline.getAbsoluteLeft(c.content);var f=b.mouseY-links.Timeline.getAbsoluteTop(c.content);var i=this.screenToTime(g);if(m.snapEvents){this.step.snap(i)}var d=m.NEW;var h=this.getGroupFromHeight(f);var e=true;this.addItem({start:i,content:d,group:this.getGroupName(h)},e);b.itemIndex=(this.items.length-1);this.selectItem(b.itemIndex);this.applyAdd=true;this.trigger("add");if(this.applyAdd){this.render({animate:false});this.selectItem(b.itemIndex)}else{this.deleteItem(b.itemIndex)}}}links.Timeline.preventDefault(a)};links.Timeline.prototype.onMouseWheel=function(d){if(!this.options.zoomable){return}if(!d){d=window.event}var e=0;if(d.wheelDelta){e=d.wheelDelta/120}else{if(d.detail){e=-d.detail/3}}if(e){var c=this;var b=function(){var h=e/5;var g=links.Timeline.getAbsoluteLeft(c.dom.content);var f=links.Timeline.getPageX(d);var i=(f!=undefined&&g!=undefined)?c.screenToTime(f-g):undefined;c.zoom(h,i);c.trigger("rangechange");c.trigger("rangechanged")};var a=function(){c.move(e*-0.2);c.trigger("rangechange");c.trigger("rangechanged")};if(d.shiftKey){a()}else{b()}}links.Timeline.preventDefault(d)};links.Timeline.prototype.zoom=function(g,h){if(h==undefined){h=new Date((this.start.valueOf()+this.end.valueOf())/2)}if(g>=1){g=0.9}if(g<=-1){g=-0.9}if(g<0){g=g/(1+g)}var e=(this.start.valueOf()-h);var d=(this.end.valueOf()-h);var a=new Date(this.start.valueOf()-e*g);var f=new Date(this.end.valueOf()-d*g);var c=(f.valueOf()-a.valueOf());var b=Number(this.options.zoomMin)||10;if(b<10){b=10}if(c>=b){this.applyRange(a,f,h);this.render({animate:this.options.animate&&this.options.animateZoom})}};links.Timeline.prototype.move=function(b){var d=(this.end.valueOf()-this.start.valueOf());var a=new Date(this.start.valueOf()+d*b);var c=new Date(this.end.valueOf()+d*b);this.applyRange(a,c);this.render()};links.Timeline.prototype.applyRange=function(b,e,a){var c=b.valueOf();var n=e.valueOf();var d=(n-c);var q=this.options;var k=1000*60*60*24*365;var h=Number(q.zoomMin)||10;if(h<10){h=10}var p=Number(q.zoomMax)||10000*k;if(p>10000*k){p=10000*k}if(p<h){p=h}var g=q.min?q.min.valueOf():undefined;var m=q.max?q.max.valueOf():undefined;if(g!=undefined&&m!=undefined){if(g>=m){var l=1000*60*60*24;m=g+l}if(p>(m-g)){p=(m-g)}if(h>(m-g)){h=(m-g)}}if(c>=n){n+=1000*60*60*24}if(d<h){var o=(h-d);var i=a?(a.valueOf()-c)/d:0.5;c-=Math.round(o*i);n+=Math.round(o*(1-i))}if(d>p){var o=(d-p);var i=a?(a.valueOf()-c)/d:0.5;c+=Math.round(o*i);n-=Math.round(o*(1-i))}if(g!=undefined){var o=(c-g);if(o<0){c-=o;n-=o}}if(m!=undefined){var o=(m-n);if(o<0){c+=o;n+=o}}this.start=new Date(c);this.end=new Date(n)};links.Timeline.prototype.confirmDeleteItem=function(a){this.applyDelete=true;if(!this.isSelected(a)){this.selectItem(a)}this.trigger("delete");if(this.applyDelete){this.deleteItem(a)}delete this.applyDelete};links.Timeline.prototype.deleteItem=function(a,c){if(a>=this.items.length){throw"Cannot delete row, index out of range"}if(this.selection&&this.selection.index!==undefined){if(this.selection.index==a){this.unselectItem()}else{if(this.selection.index>a){this.selection.index--}}}var b=this.items.splice(a,1)[0];this.renderQueue.hide.push(b);if(this.data){if(google&&google.visualization&&this.data instanceof google.visualization.DataTable){this.data.removeRow(a)}else{if(links.Timeline.isArray(this.data)){this.data.splice(a,1)}else{throw"Cannot delete row from data, unknown data type"}}}if(this.options.cluster){this.clusterGenerator.updateData()}if(!c){this.render()}};links.Timeline.prototype.deleteAllItems=function(){this.unselectItem();this.clearItems();this.deleteGroups();if(this.data){if(google&&google.visualization&&this.data instanceof google.visualization.DataTable){this.data.removeRows(0,this.data.getNumberOfRows())}else{if(links.Timeline.isArray(this.data)){this.data.splice(0,this.data.length)}else{throw"Cannot delete row from data, unknown data type"}}}if(this.options.cluster){this.clusterGenerator.updateData()}this.render()};links.Timeline.prototype.getGroupFromHeight=function(b){var c,d,a=this.groups;if(a.length){if(this.options.axisOnTop){for(c=a.length-1;c>=0;c--){d=a[c];if(b>d.top){return d}}}else{for(c=0;c<a.length;c++){d=a[c];if(b>d.top){return d}}}return d}return undefined};links.Timeline.Item=function(c,a){if(c){this.start=c.start;this.end=c.end;this.content=c.content;this.className=c.className;this.editable=c.editable;this.group=c.group;this.type=c.type}this.top=0;this.left=0;this.width=0;this.height=0;this.lineWidth=0;this.dotWidth=0;this.dotHeight=0;this.rendered=false;if(a){for(var b in a){if(a.hasOwnProperty(b)){this[b]=a[b]}}}};links.Timeline.Item.prototype.reflow=function(){return false};links.Timeline.Item.prototype.getImageUrls=function(a){if(this.dom){links.imageloader.filterImageUrls(this.dom,a)}};links.Timeline.Item.prototype.select=function(){};links.Timeline.Item.prototype.unselect=function(){};links.Timeline.Item.prototype.createDOM=function(){};links.Timeline.Item.prototype.showDOM=function(a){};links.Timeline.Item.prototype.hideDOM=function(a){};links.Timeline.Item.prototype.updateDOM=function(){};links.Timeline.Item.prototype.updatePosition=function(a){};links.Timeline.Item.prototype.isRendered=function(){return this.rendered};links.Timeline.Item.prototype.isVisible=function(b,a){return false};links.Timeline.Item.prototype.setPosition=function(b,a){};links.Timeline.Item.prototype.getLeft=function(a){return 0};links.Timeline.Item.prototype.getRight=function(a){return 0};links.Timeline.Item.prototype.getWidth=function(a){return this.width||0};links.Timeline.ItemBox=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemBox.prototype=new links.Timeline.Item();links.Timeline.ItemBox.prototype.reflow=function(){var e=this.dom,c=e.dot.offsetHeight,d=e.dot.offsetWidth,a=e.line.offsetWidth,b=((this.dotHeight!=c)||(this.dotWidth!=d)||(this.lineWidth!=a));this.dotHeight=c;this.dotWidth=d;this.lineWidth=a;return b};links.Timeline.ItemBox.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active");links.Timeline.addClassName(a.line,"timeline-event-selected ui-state-active");links.Timeline.addClassName(a.dot,"timeline-event-selected ui-state-active")};links.Timeline.ItemBox.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active");links.Timeline.removeClassName(a.line,"timeline-event-selected ui-state-active");links.Timeline.removeClassName(a.dot,"timeline-event-selected ui-state-active")};links.Timeline.ItemBox.prototype.createDOM=function(){var c=document.createElement("DIV");c.style.position="absolute";c.style.left=this.left+"px";c.style.top=this.top+"px";var b=document.createElement("DIV");b.className="timeline-event-content";b.innerHTML=this.content;c.appendChild(b);var d=document.createElement("DIV");d.style.position="absolute";d.style.width="0px";c.line=d;var a=document.createElement("DIV");a.style.position="absolute";a.style.width="0px";a.style.height="0px";c.dot=a;this.dom=c;this.updateDOM();return c};links.Timeline.ItemBox.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);a.insertBefore(b.line,a.firstChild);a.appendChild(b.dot);this.rendered=true}};links.Timeline.ItemBox.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}if(a.line&&a.line.parentNode){a.line.parentNode.removeChild(a.line)}if(a.dot&&a.dot.parentNode){a.dot.parentNode.removeChild(a.dot)}this.rendered=false}};links.Timeline.ItemBox.prototype.updateDOM=function(){var b=this.dom;if(b){var c=b.line;var a=b.dot;b.firstChild.innerHTML=this.content;b.className="timeline-event timeline-event-box ui-widget ui-state-default";c.className="timeline-event timeline-event-line ui-widget ui-state-default";a.className="timeline-event timeline-event-dot ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(b,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(c,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(b,this.className);links.Timeline.addClassName(c,this.className);links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemBox.prototype.updatePosition=function(g){var e=this.dom;if(e){var c=g.timeToScreen(this.start),f=g.options.axisOnTop,a=g.size.axis.top,d=g.size.axis.height,h=(g.options.box&&g.options.box.align)?g.options.box.align:undefined;e.style.top=this.top+"px";if(h=="right"){e.style.left=(c-this.width)+"px"}else{if(h=="left"){e.style.left=(c)+"px"}else{e.style.left=(c-this.width/2)+"px"}}var i=e.line;var b=e.dot;i.style.left=(c-this.lineWidth/2)+"px";b.style.left=(c-this.dotWidth/2)+"px";if(f){i.style.top=d+"px";i.style.height=Math.max(this.top-d,0)+"px";b.style.top=(d-this.dotHeight/2)+"px"}else{i.style.top=(this.top+this.height)+"px";i.style.height=Math.max(a-this.top-this.height,0)+"px";b.style.top=(a-this.dotHeight/2)+"px"}}};links.Timeline.ItemBox.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.start>b)&&(this.start<a)};links.Timeline.ItemBox.prototype.setPosition=function(b,a){var c=this.dom;c.style.left=(b-this.width/2)+"px";c.line.style.left=(b-this.lineWidth/2)+"px";c.dot.style.left=(b-this.dotWidth/2)+"px";if(this.group){this.top=this.group.top;c.style.top=this.top+"px"}};links.Timeline.ItemBox.prototype.getLeft=function(b){var a=(b.options.box&&b.options.box.align)?b.options.box.align:undefined;var c=b.timeToScreen(this.start);if(a=="right"){c=c-width}else{c=(c-this.width/2)}return c};links.Timeline.ItemBox.prototype.getRight=function(c){var a=(c.options.box&&c.options.box.align)?c.options.box.align:undefined;var d=c.timeToScreen(this.start);var b;if(a=="right"){b=d}else{if(a=="left"){b=(d+this.width)}else{b=(d+this.width/2)}}return b};links.Timeline.ItemRange=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemRange.prototype=new links.Timeline.Item();links.Timeline.ItemRange.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemRange.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemRange.prototype.createDOM=function(){var b=document.createElement("DIV");b.style.position="absolute";var a=document.createElement("DIV");a.className="timeline-event-content";b.appendChild(a);this.dom=b;this.updateDOM();return b};links.Timeline.ItemRange.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);this.rendered=true}};links.Timeline.ItemRange.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}this.rendered=false}};links.Timeline.ItemRange.prototype.updateDOM=function(){var a=this.dom;if(a){a.firstChild.innerHTML=this.content;a.className="timeline-event timeline-event-range ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemRange.prototype.updatePosition=function(c){var e=this.dom;if(e){var a=c.size.contentWidth,d=c.timeToScreen(this.start),b=c.timeToScreen(this.end);if(d<-a){d=-a}if(b>2*a){b=2*a}e.style.top=this.top+"px";e.style.left=d+"px";e.style.width=Math.max(b-d,1)+"px"}};links.Timeline.ItemRange.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.end>b)&&(this.start<a)};links.Timeline.ItemRange.prototype.setPosition=function(b,a){var c=this.dom;c.style.left=b+"px";c.style.width=(a-b)+"px";if(this.group){this.top=this.group.top;c.style.top=this.top+"px"}};links.Timeline.ItemRange.prototype.getLeft=function(a){return a.timeToScreen(this.start)};links.Timeline.ItemRange.prototype.getRight=function(a){return a.timeToScreen(this.end)};links.Timeline.ItemRange.prototype.getWidth=function(a){return a.timeToScreen(this.end)-a.timeToScreen(this.start)};links.Timeline.ItemFloatingRange=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemFloatingRange.prototype=new links.Timeline.Item();links.Timeline.ItemFloatingRange.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemFloatingRange.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemFloatingRange.prototype.createDOM=function(){var b=document.createElement("DIV");b.style.position="absolute";var a=document.createElement("DIV");a.className="timeline-event-content";b.appendChild(a);this.dom=b;this.updateDOM();return b};links.Timeline.ItemFloatingRange.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);this.rendered=true}};links.Timeline.ItemFloatingRange.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}this.rendered=false}};links.Timeline.ItemFloatingRange.prototype.updateDOM=function(){var a=this.dom;if(a){a.firstChild.innerHTML=this.content;a.className="timeline-event timeline-event-range ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemFloatingRange.prototype.updatePosition=function(c){var e=this.dom;if(e){var a=c.size.contentWidth,d=this.getLeft(c),b=this.getRight(c);if(d<-a){d=-a}if(b>2*a){b=2*a}e.style.top=this.top+"px";e.style.left=d+"px";e.style.width=Math.max(b-d,1)+"px"}};links.Timeline.ItemFloatingRange.prototype.isVisible=function(b,a){if(this.cluster){return false}if(this.end&&this.start){return(this.end>b)&&(this.start<a)}else{if(this.start){return(this.start<a)}else{if(this.end){return(this.end>b)}else{return true}}}};links.Timeline.ItemFloatingRange.prototype.setPosition=function(b,a){var c=this.dom;c.style.left=b+"px";c.style.width=(a-b)+"px";if(this.group){this.top=this.group.top;c.style.top=this.top+"px"}};links.Timeline.ItemFloatingRange.prototype.getLeft=function(a){if(this.start){return a.timeToScreen(this.start)}else{return 0}};links.Timeline.ItemFloatingRange.prototype.getRight=function(a){if(this.end){return a.timeToScreen(this.end)}else{return a.size.contentWidth}};links.Timeline.ItemFloatingRange.prototype.getWidth=function(a){return this.getRight(a)-this.getLeft(a)};links.Timeline.ItemDot=function(b,a){links.Timeline.Item.call(this,b,a)};links.Timeline.ItemDot.prototype=new links.Timeline.Item();links.Timeline.ItemDot.prototype.reflow=function(){var e=this.dom,c=e.dot.offsetHeight,d=e.dot.offsetWidth,b=e.content.offsetHeight,a=((this.dotHeight!=c)||(this.dotWidth!=d)||(this.contentHeight!=b));this.dotHeight=c;this.dotWidth=d;this.contentHeight=b;return a};links.Timeline.ItemDot.prototype.select=function(){var a=this.dom;links.Timeline.addClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemDot.prototype.unselect=function(){var a=this.dom;links.Timeline.removeClassName(a,"timeline-event-selected ui-state-active")};links.Timeline.ItemDot.prototype.createDOM=function(){var c=document.createElement("DIV");c.style.position="absolute";var b=document.createElement("DIV");b.className="timeline-event-content";c.appendChild(b);var a=document.createElement("DIV");a.style.position="absolute";a.style.width="0px";a.style.height="0px";c.appendChild(a);c.content=b;c.dot=a;this.dom=c;this.updateDOM();return c};links.Timeline.ItemDot.prototype.showDOM=function(a){var b=this.dom;if(!b){b=this.createDOM()}if(b.parentNode!=a){if(b.parentNode){this.hideDOM()}a.appendChild(b);this.rendered=true}};links.Timeline.ItemDot.prototype.hideDOM=function(){var a=this.dom;if(a){if(a.parentNode){a.parentNode.removeChild(a)}this.rendered=false}};links.Timeline.ItemDot.prototype.updateDOM=function(){if(this.dom){var b=this.dom;var a=b.dot;b.firstChild.innerHTML=this.content;b.className="timeline-event-dot-container";a.className="timeline-event timeline-event-dot ui-widget ui-state-default";if(this.isCluster){links.Timeline.addClassName(b,"timeline-event-cluster ui-widget-header");links.Timeline.addClassName(a,"timeline-event-cluster ui-widget-header")}if(this.className){links.Timeline.addClassName(b,this.className);links.Timeline.addClassName(a,this.className)}}};links.Timeline.ItemDot.prototype.updatePosition=function(a){var c=this.dom;if(c){var b=a.timeToScreen(this.start);c.style.top=this.top+"px";c.style.left=(b-this.dotWidth/2)+"px";c.content.style.marginLeft=(1.5*this.dotWidth)+"px";c.dot.style.top=((this.height-this.dotHeight)/2)+"px"}};links.Timeline.ItemDot.prototype.isVisible=function(b,a){if(this.cluster){return false}return(this.start>b)&&(this.start<a)};links.Timeline.ItemDot.prototype.setPosition=function(b,a){var c=this.dom;c.style.left=(b-this.dotWidth/2)+"px";if(this.group){this.top=this.group.top;c.style.top=this.top+"px"}};links.Timeline.ItemDot.prototype.getLeft=function(a){return a.timeToScreen(this.start)};links.Timeline.ItemDot.prototype.getRight=function(a){return a.timeToScreen(this.start)+this.width};links.Timeline.prototype.getItem=function(c){if(c>=this.items.length){throw"Cannot get item, index out of range"}var e=this.data,a;if(google&&google.visualization&&e instanceof google.visualization.DataTable){var f=links.Timeline.mapColumnIds(e);a={};for(var b in f){if(f.hasOwnProperty(b)){a[b]=this.data.getValue(c,f[b])}}}else{if(links.Timeline.isArray(this.data)){a=links.Timeline.clone(this.data[c])}else{throw"Unknown data type. DataTable or Array expected."}}var d=this.items[c];a.start=new Date(d.start.valueOf());if(d.end){a.end=new Date(d.end.valueOf())}a.content=d.content;if(d.group){a.group=this.getGroupName(d.group)}if(d.className){a.className=d.className}if(typeof d.editable!=="undefined"){a.editable=d.editable}if(d.type){a.type=d.type}return a};links.Timeline.prototype.getCluster=function(d){if(d>=this.clusters.length){throw"Cannot get cluster, index out of range"}var b={},a=this.clusters[d],f=a.items;b.start=new Date(a.start.valueOf());if(a.type){b.type=a.type}b.items=[];for(var e=0;e<f.length;e++){for(var c=0;c<this.items.length;c++){if(this.items[c]==f[e]){b.items.push(this.getItem(c));break}}}return b};links.Timeline.prototype.addItem=function(a,b){var c=[a];this.addItems(c,b)};links.Timeline.prototype.addItems=function(d,c){var b=this,a=this.items;d.forEach(function(e){var f=a.length;a.push(b.createItem(e));b.updateData(f,e)});if(this.options.cluster){this.clusterGenerator.updateData()}if(!c){this.render({animate:false})}};links.Timeline.prototype.createItem=function(a){var c=a.type||(a.end?"range":this.options.style);var e=links.Timeline.clone(a);e.type=c;e.group=this.getGroup(a.group);var d,b=this.options;if(b.axisOnTop){d=this.size.axis.height+b.eventMarginAxis+b.eventMargin/2}else{d=this.size.contentHeight-b.eventMarginAxis-b.eventMargin/2}if(c in this.itemTypes){return new this.itemTypes[c](e,{top:d})}console.log('ERROR: Unknown event type "'+c+'"');return new links.Timeline.Item(e,{top:d})};links.Timeline.prototype.changeItem=function(b,a,d){var e=this.items[b];if(!e){throw"Cannot change item, index out of range"}var c=this.createItem({start:a.hasOwnProperty("start")?a.start:e.start,end:a.hasOwnProperty("end")?a.end:e.end,content:a.hasOwnProperty("content")?a.content:e.content,group:a.hasOwnProperty("group")?a.group:this.getGroupName(e.group),className:a.hasOwnProperty("className")?a.className:e.className,editable:a.hasOwnProperty("editable")?a.editable:e.editable,type:a.hasOwnProperty("type")?a.type:(a.end?"range":"box")});this.items[b]=c;this.renderQueue.hide.push(e);this.renderQueue.show.push(c);this.updateData(b,a);if(this.options.cluster){this.clusterGenerator.updateData()}if(!d){this.render({animate:false});if(this.selection&&this.selection.index==b){c.select()}}};links.Timeline.prototype.deleteGroups=function(){this.groups=[];this.groupIndexes={}};links.Timeline.prototype.getGroup=function(g){var b=this.groups,c=this.groupIndexes,e=undefined;var f=c[g];if(f==undefined&&g!=undefined){e={content:g,labelTop:0,lineTop:0};b.push(e);if(this.options.groupsOrder==true){b=b.sort(function(i,h){if(i.content>h.content){return 1}if(i.content<h.content){return -1}return 0})}else{if(typeof(this.options.groupsOrder)=="function"){b=b.sort(this.options.groupsOrder)}}for(var d=0,a=b.length;d<a;d++){c[b[d].content]=d}}else{e=b[f]}return e};links.Timeline.prototype.getGroupName=function(a){return a?a.content:undefined};links.Timeline.prototype.cancelChange=function(){this.applyChange=false};links.Timeline.prototype.cancelDelete=function(){this.applyDelete=false};links.Timeline.prototype.cancelAdd=function(){this.applyAdd=false};links.Timeline.prototype.setSelection=function(g){if(g!=undefined&&g.length>0){if(g[0].row!=undefined){var e=g[0].row;if(this.items[e]){var h=this.items[e];this.selectItem(e);var a=h.start;var c=h.end;var i;if(c!=undefined){i=(c.valueOf()+a.valueOf())/2}else{i=a.valueOf()}var f=(this.end.valueOf()-this.start.valueOf()),d=new Date(i-f/2),b=new Date(i+f/2);this.setVisibleChartRange(d,b);return true}}}else{this.unselectItem()}return false};links.Timeline.prototype.getSelection=function(){var a=[];if(this.selection){if(this.selection.index!==undefined){a.push({row:this.selection.index})}else{a.push({cluster:this.selection.cluster})}}return a};links.Timeline.prototype.selectItem=function(a){this.unselectItem();this.selection=undefined;if(this.items[a]!=undefined){var c=this.items[a],b=c.dom;this.selection={index:a};if(c&&c.dom){if(this.isEditable(c)){c.dom.style.cursor="move"}c.select()}this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.selectCluster=function(a){this.unselectItem();this.selection=undefined;if(this.clusters[a]!=undefined){this.selection={cluster:a};this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.isSelected=function(a){return(this.selection&&this.selection.index==a)};links.Timeline.prototype.unselectItem=function(){if(this.selection&&this.selection.index!==undefined){var b=this.items[this.selection.index];if(b&&b.dom){var a=b.dom;a.style.cursor="";b.unselect()}this.selection=undefined;this.repaintDeleteButton();this.repaintDragAreas()}};links.Timeline.prototype.stackItems=function(b){if(b==undefined){b=false}var a=this.stack;if(!a){a={};this.stack=a}a.sortedItems=this.stackOrder(this.renderedItems);a.finalItems=this.stackCalculateFinal(a.sortedItems);if(b||a.timer){var d=this;var c=function(){var e=d.stackMoveOneStep(a.sortedItems,a.finalItems);d.repaint();if(!e){a.timer=setTimeout(c,30)}else{delete a.timer}};if(!a.timer){a.timer=setTimeout(c,30)}}else{this.stackMoveToFinal(a.sortedItems,a.finalItems)}};links.Timeline.prototype.stackCancelAnimation=function(){if(this.stack&&this.stack.timer){clearTimeout(this.stack.timer);delete this.stack.timer}};links.Timeline.prototype.getItemsByGroup=function(a){var d={};for(var b=0;b<a.length;++b){var c=a[b];var e="undefined";if(c.group){if(c.group.content){e=c.group.content}else{e=c.group}}if(!d[e]){d[e]=[]}d[e].push(c)}return d};links.Timeline.prototype.stackOrder=function(a){var c=a.concat([]);var b=this.options.customStackOrder&&(typeof this.options.customStackOrder==="function")?this.options.customStackOrder:function(e,d){if((e instanceof links.Timeline.ItemRange||e instanceof links.Timeline.ItemFloatingRange)&&!(d instanceof links.Timeline.ItemRange||d instanceof links.Timeline.ItemFloatingRange)){return -1}if(!(e instanceof links.Timeline.ItemRange||e instanceof links.Timeline.ItemFloatingRange)&&(d instanceof links.Timeline.ItemRange||d instanceof links.Timeline.ItemFloatingRange)){return 1}return(e.left-d.left)};c.sort(b);return c};links.Timeline.prototype.stackCalculateFinal=function(d){var i=this.size,k=this.options,e=k.axisOnTop,b=k.eventMargin,a=k.eventMarginAxis,l=(e)?i.axis.height+a+b/2:i.contentHeight-a-b/2,c,h,g=[];c=this.getItemsByGroup(d);for(j=0;j<this.groups.length;++j){var f=this.groups[j];if(!c[f.content]){if(e){l+=Math.max(k.groupMinHeight,f.labelHeight)+b}else{l-=(Math.max(k.groupMinHeight,f.labelHeight)+b)}continue}h=this.finalItemsPosition(c[f.content],l,f);h.forEach(function(m){g.push(m)});if(e){l+=f.itemsHeight+b}else{l-=(f.itemsHeight+b)}}if(c["undefined"]){h=this.finalItemsPosition(c["undefined"],l);h.forEach(function(m){g.push(m)})}return g};links.Timeline.prototype.finalItemsPosition=function(d,l,h){var c,b,m=this.options,g=m.axisOnTop,a=m.eventMargin,k;k=this.initialItemsPosition(d,l);for(c=0,b=k.length;c<b;c++){var f=k[c];var e=null;if(this.options.stackEvents){do{e=this.stackItemsCheckOverlap(k,c,0,c-1);if(e!=null){if(g){f.top=e.top+e.height+a}else{f.top=e.top-f.height-a}f.bottom=f.top+f.height}}while(e)}if(h){if(g){h.itemsHeight=(h.itemsHeight)?Math.max(h.itemsHeight,f.bottom-l):f.height+a}else{h.itemsHeight=(h.itemsHeight)?Math.max(h.itemsHeight,l-f.top):f.height+a}}}return k};links.Timeline.prototype.initialItemsPosition=function(f,o){var p=this.options,h=p.axisOnTop,l=[];for(var e=0,d=f.length;e<d;++e){var n=f[e],g,a,m=n.height,b=n.getWidth(this),k=n.getRight(this),c=k-b;g=(h)?o:o-m;a=g+m;l.push({left:c,top:g,right:k,bottom:a,height:m,item:n})}return l};links.Timeline.prototype.stackMoveOneStep=function(g,m){var d=true;for(var e=0,c=m.length;e<c;e++){var f=m[e],n=f.item;var l=parseInt(n.top);var h=parseInt(f.top);var k=(h-l);if(k){var a=(h==l)?0:((h>l)?1:-1);if(Math.abs(k)>4){a=k/4}var b=parseInt(l+a);if(b!=h){d=false}n.top=b;n.bottom=n.top+n.height}else{n.top=f.top;n.bottom=f.bottom}n.left=f.left;n.right=f.right}return d};links.Timeline.prototype.stackMoveToFinal=function(b,d){for(var c=0,a=d.length;c<a;c++){var f=d[c],e=f.item;e.left=f.left;e.top=f.top;e.right=f.right;e.bottom=f.bottom}};links.Timeline.prototype.stackItemsCheckOverlap=function(h,a,g,f){var b=this.options.eventMargin,k=this.collision;var e=h[a];for(var c=f;c>=g;c--){var d=h[c];if(k(e,d,b)){if(c!=a){return d}}}return undefined};links.Timeline.prototype.collision=function(b,a,c){if(c==undefined){c=0}return(b.left-c<a.right&&b.right+c>a.left&&b.top-c<a.bottom&&b.bottom+c>a.top)};links.Timeline.prototype.trigger=function(b){var a=null;switch(b){case"rangechange":case"rangechanged":a={start:new Date(this.start.valueOf()),end:new Date(this.end.valueOf())};break;case"timechange":case"timechanged":a={time:new Date(this.customTime.valueOf())};break}links.events.trigger(this,b,a);if(google&&google.visualization){google.visualization.events.trigger(this,b,a)}};links.Timeline.prototype.clusterItems=function(){if(!this.options.cluster){return}var b=this.clusterGenerator.getClusters(this.conversion.factor,this.options.clusterMaxItems);if(this.clusters!=b){var a=this.renderQueue;if(this.clusters){this.clusters.forEach(function(c){a.hide.push(c);c.items.forEach(function(d){d.cluster=undefined})})}b.forEach(function(c){c.items.forEach(function(d){d.cluster=c})});this.clusters=b}};links.Timeline.prototype.filterItems=function(){var a=this.renderQueue,d=(this.end-this.start),e=new Date(this.start.valueOf()-d),b=new Date(this.end.valueOf()+d);function c(f){f.forEach(function(g){var i=g.rendered;var h=g.isVisible(e,b);if(i!=h){if(i){a.hide.push(g)}if(h&&(a.show.indexOf(g)==-1)){a.show.push(g)}}})}c(this.items);if(this.clusters){c(this.clusters)}};links.Timeline.ClusterGenerator=function(a){this.timeline=a;this.clear()};links.Timeline.ClusterGenerator.prototype.clear=function(){this.items=[];this.groups={};this.clearCache()};links.Timeline.ClusterGenerator.prototype.clearCache=function(){this.cache={};this.cacheLevel=-1;this.cache[this.cacheLevel]=[]};links.Timeline.ClusterGenerator.prototype.setData=function(a,b){this.items=a||[];this.dataChanged=true;this.applyOnChangedLevel=true;if(b&&b.applyOnChangedLevel){this.applyOnChangedLevel=b.applyOnChangedLevel}};links.Timeline.ClusterGenerator.prototype.updateData=function(){this.dataChanged=true;this.applyOnChangedLevel=false};links.Timeline.ClusterGenerator.prototype.filterData=function(){var b=this.items||[];var a={};this.groups=a;b.forEach(function(d){var f=d.group?d.group.content:"";var e=a[f];if(!e){e=[];a[f]=e}e.push(d);if(d.start){if(d.end){d.center=(d.start.valueOf()+d.end.valueOf())/2}else{d.center=d.start.valueOf()}}});for(var c in a){if(a.hasOwnProperty(c)){a[c].sort(function(e,d){return(e.center-d.center)})}}this.dataChanged=false};links.Timeline.ClusterGenerator.prototype.getClusters=function(K,H){var a=-1,b=2,x=0;if(K>0){a=Math.round(Math.log(100/K)/Math.log(b));x=Math.pow(b,a)}if(this.dataChanged){var w=(a!=this.cacheLevel);var D=this.applyOnChangedLevel?w:true;if(D){this.clearCache();this.filterData()}}this.cacheLevel=a;var h=this.cache[a];if(!h){h=[];for(var q in this.groups){if(this.groups.hasOwnProperty(q)){var r=this.groups[q];var z=r.length;var G=0;while(G<z){var J=r[G];var v=1;var E=G-1;while(E>=0&&(J.center-r[E].center)<x/2){if(!r[E].cluster){v++}E--}var C=G+1;while(C<r.length&&(r[C].center-J.center)<x/2){v++;C++}var A=h.length-1;while(A>=0&&(J.center-h[A].center)<x/2){if(J.group==h[A].group){v++}A--}if(v>H){var n=v-H+1;var d=[];var t=undefined;var y=undefined;var F=undefined;var f=false;var g=0;var u=G;while(d.length<n&&u<r.length){var s=r[u];var e=s.start.valueOf();var c=s.end?s.end.valueOf():s.start.valueOf();d.push(s);if(g){t=(g/(g+1))*t+(1/(g+1))*s.center}else{t=s.center}y=(y!=undefined)?Math.min(y,e):e;F=(F!=undefined)?Math.max(F,c):c;f=f||(s instanceof links.Timeline.ItemRange||s instanceof links.Timeline.ItemFloatingRange);g++;u++}var I;var L="Cluster containing "+g+" events. Zoom in to see the individual events.";var B='<div title="'+L+'">'+g+" events</div>";var o=J.group?J.group.content:undefined;if(f){I=this.timeline.createItem({start:new Date(y),end:new Date(F),content:B,group:o})}else{I=this.timeline.createItem({start:new Date(t),content:B,group:o})}I.isCluster=true;I.items=d;I.items.forEach(function(i){i.cluster=I});h.push(I);G+=n}else{delete J.cluster;G+=1}}}}this.cache[a]=h}return h};links.events=links.events||{listeners:[],indexOf:function(b){var d=this.listeners;for(var c=0,a=this.listeners.length;c<a;c++){var e=d[c];if(e&&e.object==b){return c}}return -1},addListener:function(b,d,f){var a=this.indexOf(b);var e=this.listeners[a];if(!e){e={object:b,events:{}};this.listeners.push(e)}var c=e.events[d];if(!c){c=[];e.events[d]=c}if(c.indexOf(f)==-1){c.push(f)}},removeListener:function(c,a,i){var f=this.indexOf(c);var b=this.listeners[f];if(b){var h=b.events[a];if(h){var f=h.indexOf(i);if(f!=-1){h.splice(f,1)}if(h.length==0){delete b.events[a]}}var d=0;var k=b.events;for(var g in k){if(k.hasOwnProperty(g)){d++}}if(d==0){delete this.listeners[f]}}},removeAllListeners:function(){this.listeners=[]},trigger:function(c,g,e){var b=this.indexOf(c);var h=this.listeners[b];if(h){var f=h.events[g];if(f){for(var d=0,a=f.length;d<a;d++){f[d](e)}}}}};links.Timeline.StepDate=function(c,a,b){this.current=new Date();this._start=new Date();this._end=new Date();this.autoScale=true;this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1;this.setRange(c,a,b)};links.Timeline.StepDate.SCALE={MILLISECOND:1,SECOND:2,MINUTE:3,HOUR:4,DAY:5,WEEKDAY:6,MONTH:7,YEAR:8};links.Timeline.StepDate.prototype.setRange=function(c,a,b){if(!(c instanceof Date)||!(a instanceof Date)){return}this._start=(c!=undefined)?new Date(c.valueOf()):new Date();this._end=(a!=undefined)?new Date(a.valueOf()):new Date();if(this.autoScale){this.setMinimumStep(b)}};links.Timeline.StepDate.prototype.start=function(){this.current=new Date(this._start.valueOf());this.roundToMinor()};links.Timeline.StepDate.prototype.roundToMinor=function(){switch(this.scale){case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.step*Math.floor(this.current.getFullYear()/this.step));this.current.setMonth(0);case links.Timeline.StepDate.SCALE.MONTH:this.current.setDate(1);case links.Timeline.StepDate.SCALE.DAY:case links.Timeline.StepDate.SCALE.WEEKDAY:this.current.setHours(0);case links.Timeline.StepDate.SCALE.HOUR:this.current.setMinutes(0);case links.Timeline.StepDate.SCALE.MINUTE:this.current.setSeconds(0);case links.Timeline.StepDate.SCALE.SECOND:this.current.setMilliseconds(0)}if(this.step!=1){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current.setMilliseconds(this.current.getMilliseconds()-this.current.getMilliseconds()%this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current.setSeconds(this.current.getSeconds()-this.current.getSeconds()%this.step);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current.setMinutes(this.current.getMinutes()-this.current.getMinutes()%this.step);break;case links.Timeline.StepDate.SCALE.HOUR:this.current.setHours(this.current.getHours()-this.current.getHours()%this.step);break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:this.current.setDate((this.current.getDate()-1)-(this.current.getDate()-1)%this.step+1);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()-this.current.getMonth()%this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()-this.current.getFullYear()%this.step);break;default:break}}};links.Timeline.StepDate.prototype.end=function(){return(this.current.valueOf()>this._end.valueOf())};links.Timeline.StepDate.prototype.next=function(){var b=this.current.valueOf();if(this.current.getMonth()<6){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.valueOf()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current=new Date(this.current.valueOf()+this.step*1000);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current=new Date(this.current.valueOf()+this.step*1000*60);break;case links.Timeline.StepDate.SCALE.HOUR:this.current=new Date(this.current.valueOf()+this.step*1000*60*60);var a=this.current.getHours();this.current.setHours(a-(a%this.step));break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:break}}else{switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.valueOf()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current.setSeconds(this.current.getSeconds()+this.step);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current.setMinutes(this.current.getMinutes()+this.step);break;case links.Timeline.StepDate.SCALE.HOUR:this.current.setHours(this.current.getHours()+this.step);break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:this.current.setDate(this.current.getDate()+this.step);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.setMonth(this.current.getMonth()+this.step);break;case links.Timeline.StepDate.SCALE.YEAR:this.current.setFullYear(this.current.getFullYear()+this.step);break;default:break}}if(this.step!=1){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:if(this.current.getMilliseconds()<this.step){this.current.setMilliseconds(0)}break;case links.Timeline.StepDate.SCALE.SECOND:if(this.current.getSeconds()<this.step){this.current.setSeconds(0)}break;case links.Timeline.StepDate.SCALE.MINUTE:if(this.current.getMinutes()<this.step){this.current.setMinutes(0)}break;case links.Timeline.StepDate.SCALE.HOUR:if(this.current.getHours()<this.step){this.current.setHours(0)}break;case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:if(this.current.getDate()<this.step+1){this.current.setDate(1)}break;case links.Timeline.StepDate.SCALE.MONTH:if(this.current.getMonth()<this.step){this.current.setMonth(0)}break;case links.Timeline.StepDate.SCALE.YEAR:break;default:break}}if(this.current.valueOf()==b){this.current=new Date(this._end.valueOf())}};links.Timeline.StepDate.prototype.getCurrent=function(){return this.current};links.Timeline.StepDate.prototype.setScale=function(b,a){this.scale=b;if(a>0){this.step=a}this.autoScale=false};links.Timeline.StepDate.prototype.setAutoScale=function(a){this.autoScale=a};links.Timeline.StepDate.prototype.setMinimumStep=function(f){if(f==undefined){return}var b=(1000*60*60*24*30*12);var a=(1000*60*60*24*30);var e=(1000*60*60*24);var g=(1000*60*60);var d=(1000*60);var h=(1000);var c=(1);if(b*1000>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1000}if(b*500>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=500}if(b*100>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=100}if(b*50>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=50}if(b*10>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=10}if(b*5>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=5}if(b>f){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1}if(a*3>f){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=3}if(a>f){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=1}if(e*5>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=5}if(e*2>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=2}if(e>f){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1}if(e/2>f){this.scale=links.Timeline.StepDate.SCALE.WEEKDAY;this.step=1}if(g*4>f){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=4}if(g>f){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=1}if(d*15>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=15}if(d*10>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=10}if(d*5>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=5}if(d>f){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=1}if(h*15>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=15}if(h*10>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=10}if(h*5>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=5}if(h>f){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=1}if(c*200>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=200}if(c*100>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=100}if(c*50>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=50}if(c*10>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=10}if(c*5>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=5}if(c>f){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=1}};links.Timeline.StepDate.prototype.snap=function(a){if(this.scale==links.Timeline.StepDate.SCALE.YEAR){var b=a.getFullYear()+Math.round(a.getMonth()/12);a.setFullYear(Math.round(b/this.step)*this.step);a.setMonth(0);a.setDate(0);a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.MONTH){if(a.getDate()>15){a.setDate(1);a.setMonth(a.getMonth()+1)}else{a.setDate(1)}a.setHours(0);a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.DAY||this.scale==links.Timeline.StepDate.SCALE.WEEKDAY){switch(this.step){case 5:case 2:a.setHours(Math.round(a.getHours()/24)*24);break;default:a.setHours(Math.round(a.getHours()/12)*12);break}a.setMinutes(0);a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.HOUR){switch(this.step){case 4:a.setMinutes(Math.round(a.getMinutes()/60)*60);break;default:a.setMinutes(Math.round(a.getMinutes()/30)*30);break}a.setSeconds(0);a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.MINUTE){switch(this.step){case 15:case 10:a.setMinutes(Math.round(a.getMinutes()/5)*5);a.setSeconds(0);break;case 5:a.setSeconds(Math.round(a.getSeconds()/60)*60);break;default:a.setSeconds(Math.round(a.getSeconds()/30)*30);break}a.setMilliseconds(0)}else{if(this.scale==links.Timeline.StepDate.SCALE.SECOND){switch(this.step){case 15:case 10:a.setSeconds(Math.round(a.getSeconds()/5)*5);a.setMilliseconds(0);break;case 5:a.setMilliseconds(Math.round(a.getMilliseconds()/1000)*1000);break;default:a.setMilliseconds(Math.round(a.getMilliseconds()/500)*500);break}}else{if(this.scale==links.Timeline.StepDate.SCALE.MILLISECOND){var c=this.step>5?this.step/2:1;a.setMilliseconds(Math.round(a.getMilliseconds()/c)*c)}}}}}}}};links.Timeline.StepDate.prototype.isMajor=function(){switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return(this.current.getMilliseconds()==0);case links.Timeline.StepDate.SCALE.SECOND:return(this.current.getSeconds()==0);case links.Timeline.StepDate.SCALE.MINUTE:return(this.current.getHours()==0)&&(this.current.getMinutes()==0);case links.Timeline.StepDate.SCALE.HOUR:return(this.current.getHours()==0);case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:return(this.current.getDate()==1);case links.Timeline.StepDate.SCALE.MONTH:return(this.current.getMonth()==0);case links.Timeline.StepDate.SCALE.YEAR:return false;default:return false}};links.Timeline.StepDate.prototype.getLabelMinor=function(b,a){if(a==undefined){a=this.current}switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return String(a.getMilliseconds());case links.Timeline.StepDate.SCALE.SECOND:return String(a.getSeconds());case links.Timeline.StepDate.SCALE.MINUTE:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.HOUR:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.WEEKDAY:return b.DAYS_SHORT[a.getDay()]+" "+a.getDate();case links.Timeline.StepDate.SCALE.DAY:return String(a.getDate());case links.Timeline.StepDate.SCALE.MONTH:return b.MONTHS_SHORT[a.getMonth()];case links.Timeline.StepDate.SCALE.YEAR:return String(a.getFullYear());default:return""}};links.Timeline.StepDate.prototype.getLabelMajor=function(b,a){if(a==undefined){a=this.current}switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2)+":"+this.addZeros(a.getSeconds(),2);case links.Timeline.StepDate.SCALE.SECOND:return a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.MINUTE:return b.DAYS[a.getDay()]+" "+a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.HOUR:return b.DAYS[a.getDay()]+" "+a.getDate()+" "+b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.WEEKDAY:case links.Timeline.StepDate.SCALE.DAY:return b.MONTHS[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.MONTH:return String(a.getFullYear());default:return""}};links.Timeline.StepDate.prototype.addZeros=function(b,a){var c=""+b;while(c.length<a){c="0"+c}return c};links.imageloader=(function(){var g={};var c={};function a(h){if(g[h]==true){return true}var i=new Image();i.src=h;if(i.complete){return true}return false}function b(h){return(c[h]!=undefined)}function f(h,m,i){if(i==undefined){i=true}if(a(h)){if(i){m(h)}return}if(b(h)&&!i){return}var l=c[h];if(!l){var k=new Image();k.src=h;l=[];c[h]=l;k.onload=function(o){g[h]=true;delete c[h];for(var n=0;n<l.length;n++){l[n](h)}}}if(l.indexOf(m)==-1){l.push(m)}}function e(k,m,i){var l=[];k.forEach(function(n){if(!a(n)){l.push(n)}});if(l.length){var h=l.length;l.forEach(function(n){f(n,function(){h--;if(h==0){m()}},i)})}else{if(i){m()}}}function d(i,k){var l=i.firstChild;while(l){if(l.tagName=="IMG"){var h=l.src;if(k.indexOf(h)==-1){k.push(h)}}d(l,k);l=l.nextSibling}}return{isLoaded:a,isLoading:b,load:f,loadAll:e,filterImageUrls:d}})();links.Timeline.addEventListener=function(b,d,c,a){if(b.addEventListener){if(a===undefined){a=false}if(d==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0){d="DOMMouseScroll"}b.addEventListener(d,c,a)}else{b.attachEvent("on"+d,c)}};links.Timeline.removeEventListener=function(b,d,c,a){if(b.removeEventListener){if(a===undefined){a=false}if(d==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0){d="DOMMouseScroll"}b.removeEventListener(d,c,a)}else{b.detachEvent("on"+d,c)}};links.Timeline.getTarget=function(a){if(!a){a=window.event}var b;if(a.target){b=a.target}else{if(a.srcElement){b=a.srcElement}}if(b.nodeType!=undefined&&b.nodeType==3){b=b.parentNode}return b};links.Timeline.stopPropagation=function(a){if(!a){a=window.event}if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}};links.Timeline.preventDefault=function(a){if(!a){a=window.event}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}};links.Timeline.getAbsoluteLeft=function(b){var f=document.documentElement;var a=document.body;var d=b.offsetLeft;var c=b.offsetParent;while(c!=null&&c!=a&&c!=f){d+=c.offsetLeft;d-=c.scrollLeft;c=c.offsetParent}return d};links.Timeline.getAbsoluteTop=function(b){var f=document.documentElement;var a=document.body;var d=b.offsetTop;var c=b.offsetParent;while(c!=null&&c!=a&&c!=f){d+=c.offsetTop;d-=c.scrollTop;c=c.offsetParent}return d};links.Timeline.getPageY=function(c){if(("targetTouches" in c)&&c.targetTouches.length){c=c.targetTouches[0]}if("pageY" in c){return c.pageY}var b=c.clientY;var d=document.documentElement;var a=document.body;return b+(d&&d.scrollTop||a&&a.scrollTop||0)-(d&&d.clientTop||a&&a.clientTop||0)};links.Timeline.getPageX=function(c){if(("targetTouches" in c)&&c.targetTouches.length){c=c.targetTouches[0]}if("pageX" in c){return c.pageX}var b=c.clientX;var d=document.documentElement;var a=document.body;return b+(d&&d.scrollLeft||a&&a.scrollLeft||0)-(d&&d.clientLeft||a&&a.clientLeft||0)};links.Timeline.addClassName=function(f,e){var b=f.className.split(" ");var d=e.split(" ");var c=false;for(var a=0;a<d.length;a++){if(b.indexOf(d[a])==-1){b.push(d[a]);c=true}}if(c){f.className=b.join(" ")}};links.Timeline.removeClassName=function(f,e){var d=f.className.split(" ");var a=e.split(" ");var g=false;for(var c=0;c<a.length;c++){var b=d.indexOf(a[c]);if(b!=-1){d.splice(b,1);g=true}}if(g){f.className=d.join(" ")}};links.Timeline.isArray=function(a){if(a instanceof Array){return true}return(Object.prototype.toString.call(a)==="[object Array]")};links.Timeline.clone=function(a){var c={};for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c};links.Timeline.parseJSONDate=function(b){if(b==undefined){return undefined}if(b instanceof Date){return b}var a=b.match(/\/Date\((-?\d+)([-\+]?\d{2})?(\d{2})?\)\//i);if(a){var c=a[2]?(3600000*a[2])+(60000*a[3]*(a[2]/Math.abs(a[2]))):0;return new Date((1*a[1])+c)}return Date.parse(b)};
PrimeFaces.widget.Timeline=PrimeFaces.widget.DeferredWidget.extend({init:function(a){this._super(a);this.cfg=a;this.id=a.id;this.lazy=this.getBehavior("lazyload")!=null;if(this.lazy){this.min=(typeof this.cfg.opts.min!=="undefined"?this.cfg.opts.min.getTime():null);this.max=(typeof this.cfg.opts.max!=="undefined"?this.cfg.opts.max.getTime():null);this.pFactor=this.cfg.opts.preloadFactor;this.rangeLoadedEvents={start:null,end:null}}this.renderDeferred()},_render:function(){var c=PrimeFaces.getLocaleSettings();if(c){for(var b in c){this.cfg.opts[b]=c[b]}}var a=document.getElementById(this.id);this.instance=new links.Timeline(a,this.cfg.opts);this.instance.draw(this.cfg.data,null);if(this.cfg.opts.currentTime){this.instance.setCurrentTime(this.cfg.opts.currentTime)}this.bindEvents(a)},bindEvents:function(b){if(this.cfg.opts.responsive){var d=$(b).closest(".ui-layout-pane");if(d.length>0){d.on("layoutpaneonresize",$.proxy(function(){this.instance.checkResize()},this))}else{var c="resize.timeline"+PrimeFaces.escapeClientId(this.id);$(window).off(c).on(c,$.proxy(function(){this.instance.checkResize()},this))}}if(this.cfg.opts.selectable&&this.getBehavior("select")){links.events.addListener(this.instance,"select",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("select").call(this,e)},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("add")){links.events.addListener(this.instance,"add",$.proxy(function(){var e=this.getSelectedEvent();if(e==null){return}var f=[];f.push({name:this.id+"_startDate",value:e.start.getTime()});if(e.end){f.push({name:this.id+"_endDate",value:e.end.getTime()})}if(e.group){f.push({name:this.id+"_group",value:e.group})}this.getBehavior("add").call(this,{params:f})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.cfg.opts.timeChangeable&&this.getBehavior("change")){links.events.addListener(this.instance,"change",$.proxy(function(){var e=this.getSelectedIndex();if(e<0){return}var f=this.getEvent(e);if(f==null){return}if(!this.instance.isEditable(f)){return}var g=[];g.push({name:this.id+"_eventIdx",value:e});g.push({name:this.id+"_startDate",value:f.start.getTime()});if(f.end){g.push({name:this.id+"_endDate",value:f.end.getTime()})}if(f.group){g.push({name:this.id+"_group",value:f.group})}this.getBehavior("change").call(this,{params:g})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.cfg.opts.timeChangeable&&this.getBehavior("changed")){links.events.addListener(this.instance,"changed",$.proxy(function(){var e=this.getSelectedIndex();if(e<0){return}var f=this.getEvent(e);if(f==null){return}if(!this.instance.isEditable(f)){return}var g=[];g.push({name:this.id+"_eventIdx",value:e});g.push({name:this.id+"_startDate",value:f.start.getTime()});if(f.end){g.push({name:this.id+"_endDate",value:f.end.getTime()})}if(f.group){g.push({name:this.id+"_group",value:f.group})}this.getBehavior("changed").call(this,{params:g})},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("edit")){links.events.addListener(this.instance,"edit",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}if(!this.isEditable(f)){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("edit").call(this,e)},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("delete")){links.events.addListener(this.instance,"delete",$.proxy(function(){var f=this.getSelectedIndex();if(f<0){return}if(!this.isEditable(f)){return}var e={params:[{name:this.id+"_eventIdx",value:f}]};this.getBehavior("delete").call(this,e)},this))}if((this.cfg.opts.zoomable||this.cfg.opts.moveable)&&this.getBehavior("rangechange")){links.events.addListener(this.instance,"rangechange",$.proxy(function(){var e=this.instance.getVisibleChartRange();var f={params:[{name:this.id+"_startDate",value:e.start.getTime()},{name:this.id+"_endDate",value:e.end.getTime()}]};this.getBehavior("rangechange").call(this,f)},this))}if((this.cfg.opts.zoomable||this.cfg.opts.moveable)&&this.getBehavior("rangechanged")){links.events.addListener(this.instance,"rangechanged",$.proxy(function(){var e=this.instance.getVisibleChartRange();var f={params:[{name:this.id+"_startDate",value:e.start.getTime()},{name:this.id+"_endDate",value:e.end.getTime()}]};this.getBehavior("rangechanged").call(this,f)},this))}if(this.lazy){this.fireLazyLoading();links.events.addListener(this.instance,"rangechanged",$.proxy(function(){this.fireLazyLoading()},this))}if(this.cfg.opts.selectable&&this.cfg.opts.editable&&this.getBehavior("drop")){var a={tolerance:"pointer"};if(this.cfg.opts.hoverClass){a.hoverClass=this.cfg.opts.hoverClass}if(this.cfg.opts.activeClass){a.activeClass=this.cfg.opts.activeClass}if(this.cfg.opts.accept){a.accept=this.cfg.opts.accept}if(this.cfg.opts.scope){a.scope=this.cfg.opts.scope}a.drop=$.proxy(function(m,j){var g=this.getInstance();var k=m.pageX-links.Timeline.getAbsoluteLeft(g.dom.content);var i=m.pageY-links.Timeline.getAbsoluteTop(g.dom.content);var n=g.screenToTime(k);var e=g.screenToTime(k+g.size.frameWidth/10);if(this.cfg.opts.snapEvents){g.step.snap(n);g.step.snap(e)}var f=[];f.push({name:this.id+"_startDate",value:n.getTime()});f.push({name:this.id+"_endDate",value:e.getTime()});var l=g.getGroupFromHeight(i);if(l){f.push({name:this.id+"_group",value:g.getGroupName(l)})}f.push({name:this.id+"_dragId",value:j.draggable.attr("id")});var h=j.draggable.closest(".ui-datatable, .ui-datagrid, .ui-datalist, .ui-carousel");if(h.length>0){f.push({name:this.id+"_uiDataId",value:h.attr("id")})}this.getBehavior("drop").call(this,{params:f,event:m,ui:j})},this);$(b).droppable(a)}},getData:function(){var a=$.map(this.instance.getData(),$.proxy(function(c){var b={};if(c.hasOwnProperty("content")){b.data=c.content}if(c.hasOwnProperty("start")){b.startDate=c.start.getTime()}if(c.hasOwnProperty("end")&&(c.end!=null)){b.endDate=c.end.getTime()}else{b.endDate=null}if(c.hasOwnProperty("editable")){b.editable=c.editable}else{b.editable=null}if(c.hasOwnProperty("group")){b.group=c.group}else{b.group=null}if(c.hasOwnProperty("className")){b.styleClass=c.className}else{b.styleClass=null}return b},this));return JSON.stringify(a)},fireLazyLoading:function(){var a=this.getLazyLoadRange();if(a==null){return}var b={params:[]};if(a.startFirst!=null&&a.endFirst!=null){b.params[0]={name:this.id+"_startDateFirst",value:a.startFirst};b.params[1]={name:this.id+"_endDateFirst",value:a.endFirst}}if(a.startSecond!=null&&a.endSecond!=null){b.params[2]={name:this.id+"_startDateSecond",value:a.startSecond};b.params[3]={name:this.id+"_endDateSecond",value:a.endSecond}}this.getBehavior("lazyload").call(this,b)},getLazyLoadRange:function(){var b=this.instance.getVisibleChartRange();if(this.rangeLoadedEvents.start==null||this.rangeLoadedEvents.end==null){var d=(b.end.getTime()-b.start.getTime())*this.pFactor;this.rangeLoadedEvents.start=Math.round(b.start.getTime()-d);this.rangeLoadedEvents.end=Math.round(b.end.getTime()+d);if(this.min!=null&&this.rangeLoadedEvents.start<this.min){this.rangeLoadedEvents.start=this.min}if(this.max!=null&&this.rangeLoadedEvents.end>this.max){this.rangeLoadedEvents.end=this.max}return{startFirst:this.rangeLoadedEvents.start,endFirst:this.rangeLoadedEvents.end,startSecond:null,endSecond:null}}if((b.end.getTime()>this.rangeLoadedEvents.end)&&(b.start.getTime()>=this.rangeLoadedEvents.start)){var g=this.rangeLoadedEvents.end+1;this.rangeLoadedEvents.end=Math.round(b.end.getTime()+(b.end.getTime()-b.start.getTime())*this.pFactor);if(this.max!=null&&this.rangeLoadedEvents.end>this.max){this.rangeLoadedEvents.end=this.max}return{startFirst:g,endFirst:this.rangeLoadedEvents.end,startSecond:null,endSecond:null}}if((b.start.getTime()<this.rangeLoadedEvents.start)&&(b.end.getTime()<=this.rangeLoadedEvents.end)){var f=this.rangeLoadedEvents.start-1;this.rangeLoadedEvents.start=Math.round(b.start.getTime()-(b.end.getTime()-b.start.getTime())*this.pFactor);if(this.min!=null&&this.rangeLoadedEvents.start<this.min){this.rangeLoadedEvents.start=this.min}return{startFirst:this.rangeLoadedEvents.start,endFirst:f,startSecond:null,endSecond:null}}if((b.start.getTime()<this.rangeLoadedEvents.start)&&(b.end.getTime()>this.rangeLoadedEvents.end)){var a=(b.end.getTime()-b.start.getTime())*this.pFactor;var e=this.rangeLoadedEvents.start-1;var c=this.rangeLoadedEvents.end+1;this.rangeLoadedEvents.start=Math.round(b.start.getTime()-a);this.rangeLoadedEvents.end=Math.round(b.end.getTime()+a);if(this.min!=null&&this.rangeLoadedEvents.start<this.min){this.rangeLoadedEvents.start=this.min}if(this.max!=null&&this.rangeLoadedEvents.end>this.max){this.rangeLoadedEvents.end=this.max}return{startFirst:this.rangeLoadedEvents.start,endFirst:e,startSecond:c,endSecond:this.rangeLoadedEvents.end}}return null},renderTimeline:function(a){this.instance.render({animate:a})},addEvent:function(a,b){this.instance.addItem(a,b)},changeEvent:function(a,b,c){this.instance.changeItem(a,b,c)},deleteEvent:function(a,b){this.instance.deleteItem(a,b)},deleteAllEvents:function(){this.instance.deleteAllItems()},cancelAdd:function(){this.instance.cancelAdd()},cancelChange:function(){this.instance.cancelChange()},cancelDelete:function(){this.instance.cancelDelete()},getEvent:function(a){return this.instance.getItem(a)},isEditable:function(a){return this.instance.isEditable(this.getEvent(a))},getVisibleRange:function(){return this.instance.getVisibleChartRange()},setVisibleRange:function(b,a){return this.instance.setVisibleChartRange(b,a)},move:function(a){return this.instance.move(a)},zoom:function(a,b){return this.instance.zoom(a,b)},checkResize:function(){this.instance.checkResize()},getNumberOfEvents:function(){return this.instance.getData().length},getBehavior:function(a){return this.cfg.behaviors?this.cfg.behaviors[a]:null},getSelectedIndex:function(){var a=this.instance.getSelection();if(a.length){if(a[0].row!=undefined){return a[0].row}}return -1},getSelectedEvent:function(){var a=this.getSelectedIndex();if(a!=-1){return this.instance.getItem(a)}return null},setSelection:function(a){if(a>=0){this.instance.setSelection([{row:a}])}else{this.instance.setSelection([])}},getInstance:function(){return this.instance}});
