/* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright (c) 2011-2012 Almende B.V. @author Jos de Jong, @date 2012-06-15 @version 2.1.2 */ typeof links==="undefined"&&(links={});typeof google==="undefined"&&(google=void 0); links.Timeline=function(a){this.dom={};this.conversion={};this.eventParams={};this.groups=[];this.groupIndexes={};this.items=[];this.selection=void 0;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,dataChanged:!1,frameHeight:0,frameWidth:0,groupsLeft:0, groupsWidth:0,items:{top:0}};this.dom.container=a;this.options={width:"100%",height:"auto",minHeight:0,autoHeight:!0,eventMargin:10,eventMarginAxis:20,dragAreaWidth:10,min:void 0,max:void 0,intervalMin:10,intervalMax:31536E10,moveable:!0,zoomable:!0,selectable:!0,editable:!1,snapEvents:!0,groupChangeable:!0,showCurrentTime:!0,showCustomTime:!1,showMajorLabels:!0,showNavigation:!1,showButtonAdd:!0,groupsOnRight:!1,axisOnTop:!1,stackEvents:!0,animate:!0,animateZoom:!0,style:"box"};this.clientTimeOffset= 0;for(a=this.dom;a.container.hasChildNodes();)a.container.removeChild(a.container.firstChild);this.step=new links.Timeline.StepDate;this.data=[];this.firstDraw=!0;this.setVisibleChartRange(void 0,void 0,!1);this.redrawFrame();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a){for(var c=0;c3,d=0,e=a.getNumberOfRows();d3)for(var a=a.getDistinctValues(3),b=0,c=a.length;b0&&c.addRows(d);b.start&&c.setValue(a,0,b.start);b.end&&c.setValue(a,1,b.end);b.content&&c.setValue(a,2,b.content);b.group&&c.getNumberOfColumns()>3&&c.setValue(a,3,b.group)}else if(links.Timeline.isArray(c)){d=c[a];d==void 0&&(d={},c[a]=d);if(b.start)d.start=b.start;if(b.end)d.end=b.end;if(b.content)d.content=b.content;if(b.group)d.group= b.group}else throw"Cannot update data, unknown type of data";};links.Timeline.prototype.getItemIndex=function(a){for(var b=this.dom,c=this.items,d=void 0;a.parentNode&&a.parentNode!==b.items.frame;)a=a.parentNode;if(a.parentNode===b.items.frame)for(var b=0,e=c.length;bd&&(b=new Date(d));this.applyRange(a,b);c==void 0||c==!0?(this.recalcSize(),this.stackEvents(!1),this.redrawFrame()): this.recalcConversion()};links.Timeline.prototype.setVisibleChartRangeAuto=function(){for(var a=this.items,b=void 0,c=void 0,d=0,e=a.length;d0&&(g===void 0&&(g=j),this.redrawAxisMajorText(j,d.getLabelMajor())),this.redrawAxisMajorLine(j)):this.redrawAxisMinorLine(j),d.next();b.showMajorLabels&&(b=this.screenToTime(0),d=this.step.getLabelMajor(b),j=d.length*c.axis.characterMajorWidth+10,(g===void 0||je;)c.removeChild(d[e]),d.splice(e,1);d=a.axis.minorLines;for(e=b.minorLineNum;d.length>e;)c.removeChild(d[e]),d.splice(e,1);d=a.axis.majorTexts;for(e=b.majorTextNum;d.length>e;)c.removeChild(d[e]),d.splice(e,1);a=a.axis.majorLines;for(e=b.majorLineNum;a.length>e;)c.removeChild(a[e]),a.splice(e,1)}; links.Timeline.prototype.redrawAxisHorizontal=function(){var a=this.dom.axis,b=this.size;if(!a.backgroundLine){var c=document.createElement("DIV");c.className="timeline-axis";c.style.position="absolute";c.style.left="0px";c.style.width="100%";c.style.border="none";a.frame.insertBefore(c,a.frame.firstChild);a.backgroundLine=c}a.backgroundLine.style.top=b.axis.top+"px";a.backgroundLine.style.height=b.axis.height+"px";a.line?(c=a.frame.removeChild(a.line),a.frame.appendChild(c)):(c=document.createElement("DIV"), c.className="timeline-axis",c.style.position="absolute",c.style.left="0px",c.style.width="100%",c.style.height="0px",a.frame.appendChild(c),a.line=c);a.line.style.top=b.axis.line+"px"}; links.Timeline.prototype.redrawAxisMinorText=function(a,b){var c=this.size,d=this.dom,e=c.axis.properties,g=d.axis.frame,d=d.axis.minorTexts,f=e.minorTextNum;if(f2*e&&(p=2*e);if((u=p>-e&&l<2*e)||d.dataChanged){if(k.hidden)k.hidden=!1,h.style.display="";h.style.top=k.top+"px";h.style.left=l+"px";h.style.width=Math.max(p-l,1)+"px"}else if(!k.hidden)h.style.display="none",k.hidden=!0;break;case "box":l=this.timeToScreen(k.start);v=b.axisOnTop;p=d.axis.top;if((u=l+k.width/2>-e&&l-k.width/2<2*e)||d.dataChanged){if(k.hidden)k.hidden=!1,h.style.display="",h.line.style.display= "",h.dot.style.display="";h.style.top=k.top+"px";h.style.left=c=="right"?l-k.width+"px":c=="left"?l+"px":l-k.width/2+"px";u=h.line;u.style.left=l-k.lineWidth/2+"px";v?(u.style.top="0px",u.style.height=Math.max(k.top,0)+"px"):(u.style.top=k.top+k.height+"px",u.style.height=Math.max(p-k.top-k.height,0)+"px");h=h.dot;h.style.left=l-k.dotWidth/2+"px";h.style.top=p-k.dotHeight/2+"px"}else if(!k.hidden)h.style.display="none",h.line.style.display="none",h.dot.style.display="none",k.hidden=!0;break;case "dot":if(l= this.timeToScreen(k.start),(u=l+k.width>-e&&l<2*e)||d.dataChanged){if(k.hidden)k.hidden=!1,h.style.display="";h.style.top=k.top+"px";h.style.left=l-k.dotWidth/2+"px";h.content.style.marginLeft=1.5*k.dotWidth+"px";h.dot.style.top=(k.height-k.dotHeight)/2+"px"}else if(!k.hidden)h.style.display="none",k.hidden=!0}if(this.selection)k=this.selection.item,f.removeChild(k),f.appendChild(k);a.content.appendChild(f)}; links.Timeline.prototype.createEventBox=function(a){var b=document.createElement("DIV");b.style.position="absolute";b.style.left="0px";b.style.top="0px";b.className="timeline-event timeline-event-box";var c=document.createElement("DIV");c.className="timeline-event-content";c.innerHTML=a;b.appendChild(c);a=document.createElement("DIV");a.style.position="absolute";a.style.width="0px";a.className="timeline-event timeline-event-line";b.line=a;a=document.createElement("DIV");a.style.position="absolute"; a.style.width="0px";a.style.height="0px";a.className="timeline-event timeline-event-dot";b.dot=a;return b}; links.Timeline.prototype.createEventDot=function(a){var b=document.createElement("DIV");b.style.position="absolute";var c=document.createElement("DIV");c.className="timeline-event-content";c.innerHTML=a;b.appendChild(c);a=document.createElement("DIV");a.style.position="absolute";a.className="timeline-event timeline-event-dot";a.style.width="0px";a.style.height="0px";b.appendChild(a);b.content=c;b.dot=a;return b}; links.Timeline.prototype.createEventRange=function(a){var b=document.createElement("DIV");b.style.position="absolute";b.className="timeline-event timeline-event-range";var c=document.createElement("DIV");c.className="timeline-event-content";c.innerHTML=a;b.appendChild(c);return b}; links.Timeline.prototype.redrawGroups=function(){var a=this.dom,b=this.options,c=this.size,d=this.groups;if(a.groups===void 0)a.groups={};var e=a.groups.labels;if(!e)e=[],a.groups.labels=e;var g=a.groups.labelLines;if(!g)g=[],a.groups.labelLines=g;var f=a.groups.itemLines;if(!f)f=[],a.groups.itemLines=f;var j=a.groups.frame;if(!j)j=document.createElement("DIV"),j.className="timeline-groups-axis",j.style.position="absolute",j.style.overflow="hidden",j.style.top="0px",j.style.height="100%",a.frame.appendChild(j), a.groups.frame=j;j.style.left=c.groupsLeft+"px";j.style.width=b.groupsWidth!==void 0?b.groupsWidth:c.groupsWidth+"px";j.style.display=d.length==0?"none":"";if(c.dataChanged){for(var l=e.length,p=d.length,o=0,u=Math.min(l,p);o-b.contentWidth&&d<2*b.contentWidth?"":"none";a.currentTime.style.left= d+"px";a.currentTime.title="Current time: "+c;this.currentTimeTimer!=void 0&&(clearTimeout(this.currentTimeTimer),delete this.currentTimeTimer);var e=this,a=1/this.conversion.factor/2;a<30&&(a=30);this.currentTimeTimer=setTimeout(function(){e.redrawCurrentTime()},a)}else a.currentTime&&(a.contentTimelines.removeChild(a.currentTime),delete a.currentTime)}; links.Timeline.prototype.redrawCustomTime=function(){var a=this.dom,b=this.size;if(this.options.showCustomTime){if(!a.customTime){var c=document.createElement("DIV");c.className="timeline-customtime";c.style.position="absolute";c.style.top="0px";c.style.height="100%";var d=document.createElement("DIV");d.style.position="relative";d.style.top="0px";d.style.left="-10px";d.style.height="100%";d.style.width="20px";c.appendChild(d);a.contentTimelines.appendChild(c);a.customTime=c;this.customTime=new Date}c= this.timeToScreen(this.customTime);a.customTime.style.display=c>-b.contentWidth&&c<2*b.contentWidth?"":"none";a.customTime.style.left=c+"px";a.customTime.title="Time: "+this.customTime}else a.customTime&&(a.contentTimelines.removeChild(a.customTime),delete a.customTime)}; links.Timeline.prototype.redrawDeleteButton=function(){var a=this.dom,b=this.size,c=a.items.frame;if(this.options.editable){var d=a.items.deleteButton;if(!d)d=document.createElement("DIV"),d.className="timeline-navigation-delete",d.style.position="absolute",c.appendChild(d),a.items.deleteButton=d;if(this.selection){var a=this.items[this.selection.index],e,g=a.top;switch(a.type){case "range":e=this.timeToScreen(a.end);break;case "box":e=this.timeToScreen(a.start)+a.width/2;break;case "dot":e=this.timeToScreen(a.start)+ a.width}e<-b.contentWidth&&(e=-b.contentWidth);e>2*b.contentWidth&&(e=2*b.contentWidth);d.style.left=e+"px";d.style.top=g+"px";d.style.display="";c.removeChild(d);c.appendChild(d)}else d.style.display="none"}}; links.Timeline.prototype.redrawDragAreas=function(){var a=this.options,b=this.dom,c=this.dom.items.frame;if(a.editable){var d=b.items.dragLeft;if(!d)d=document.createElement("DIV"),d.className="timeline-event-range-drag-left",d.style.width=a.dragAreaWidth+"px",d.style.position="absolute",c.appendChild(d),b.items.dragLeft=d;var e=b.items.dragRight;if(!e)e=document.createElement("DIV"),e.className="timeline-event-range-drag-right",e.style.width=a.dragAreaWidth+"px",e.style.position="absolute",c.appendChild(e), b.items.dragRight=e;if(this.selection){var g=this.items[this.selection.index];if(g.type=="range"){var b=this.timeToScreen(g.start),f=this.timeToScreen(g.end),j=g.top,g=g.height;d.style.left=b+"px";d.style.top=j+"px";d.style.height=g+"px";d.style.display="";c.removeChild(d);c.appendChild(d);e.style.left=f-a.dragAreaWidth+"px";e.style.top=j+"px";e.style.height=g+"px";e.style.display="";c.removeChild(e);c.appendChild(e)}}else d.style.display="none",e.style.display="none"}}; links.Timeline.prototype.redrawNavigation=function(){var a=this,b=this.options,c=this.dom,d=c.frame,e=c.navBar;if(!e){if(b.editable||b.showNavigation)e=document.createElement("DIV"),e.style.position="absolute",e.className="timeline-navigation",b.groupsOnRight?e.style.left="10px":e.style.right="10px",b.axisOnTop?e.style.bottom="10px":e.style.top="10px",c.navBar=e,d.appendChild(e);if(b.editable&&b.showButtonAdd)e.addButton=document.createElement("DIV"),e.addButton.className="timeline-navigation-new", e.addButton.title="Create new event",links.Timeline.addEventListener(e.addButton,"mousedown",function(c){links.Timeline.preventDefault(c);links.Timeline.stopPropagation(c);var d=a.size.contentWidth,e=d/2,c=a.screenToTime(e-d/10),d=a.screenToTime(e+d/10);b.snapEvents&&(a.step.snap(c),a.step.snap(d));a.addItem({start:c,end:d,content:"New",group:a.groups.length?a.groups[0].content:void 0});c=a.items.length-1;a.selectItem(c);a.applyAdd=!0;a.trigger("add");a.applyAdd||a.deleteItem(c);a.redrawDeleteButton(); a.redrawDragAreas()}),e.appendChild(e.addButton);if(b.editable&&b.showButtonAdd&&b.showNavigation)e.addButton.style.borderRightWidth="1px",e.addButton.style.borderRightStyle="solid";if(b.showNavigation)e.zoomInButton=document.createElement("DIV"),e.zoomInButton.className="timeline-navigation-zoom-in",e.zoomInButton.title="Zoom in",links.Timeline.addEventListener(e.zoomInButton,"mousedown",function(b){links.Timeline.preventDefault(b);links.Timeline.stopPropagation(b);a.zoom(0.4);a.trigger("rangechange"); a.trigger("rangechanged")}),e.appendChild(e.zoomInButton),e.zoomOutButton=document.createElement("DIV"),e.zoomOutButton.className="timeline-navigation-zoom-out",e.zoomOutButton.title="Zoom out",links.Timeline.addEventListener(e.zoomOutButton,"mousedown",function(b){links.Timeline.preventDefault(b);links.Timeline.stopPropagation(b);a.zoom(-0.4);a.trigger("rangechange");a.trigger("rangechanged")}),e.appendChild(e.zoomOutButton),e.moveLeftButton=document.createElement("DIV"),e.moveLeftButton.className= "timeline-navigation-move-left",e.moveLeftButton.title="Move left",links.Timeline.addEventListener(e.moveLeftButton,"mousedown",function(b){links.Timeline.preventDefault(b);links.Timeline.stopPropagation(b);a.move(-0.2);a.trigger("rangechange");a.trigger("rangechanged")}),e.appendChild(e.moveLeftButton),e.moveRightButton=document.createElement("DIV"),e.moveRightButton.className="timeline-navigation-move-right",e.moveRightButton.title="Move right",links.Timeline.addEventListener(e.moveRightButton, "mousedown",function(b){links.Timeline.preventDefault(b);links.Timeline.stopPropagation(b);a.move(0.2);a.trigger("rangechange");a.trigger("rangechanged")}),e.appendChild(e.moveRightButton)}};links.Timeline.prototype.setCurrentTime=function(a){var b=new Date;this.clientTimeOffset=a.getTime()-b.getTime();this.redrawCurrentTime()};links.Timeline.prototype.getCurrentTime=function(){return new Date((new Date).getTime()+this.clientTimeOffset)}; links.Timeline.prototype.setCustomTime=function(a){this.customTime=new Date(a);this.redrawCustomTime()};links.Timeline.prototype.getCustomTime=function(){return new Date(this.customTime)};links.Timeline.prototype.setScale=function(a,b){this.step.setScale(a,b);this.redrawFrame()};links.Timeline.prototype.setAutoScale=function(a){this.step.setAutoScale(a);this.redrawFrame()};links.Timeline.prototype.redraw=function(){this.setData(this.data)}; links.Timeline.prototype.checkResize=function(){this.recalcSize()&&this.redrawFrame()};links.Timeline.filterImageUrls=function(a,b){for(var c=a.firstChild;c;){if(c.tagName=="IMG"){var d=c.src;b.indexOf(d)==-1&&b.push(d)}links.Timeline.filterImageUrls(c,b);c=c.nextSibling}}; links.Timeline.prototype.recalcSize=function(){var a=!1,b=this,c=this.size,d=this.options,e=d.axisOnTop,g=this.dom,f=g.axis,j=this.groups,l=g.groups.labels,p=this.items,o=c.groupsWidth,u=f.characterMinor?f.characterMinor.clientWidth:0,v=f.characterMinor?f.characterMinor.clientHeight:0,s=f.characterMajor?f.characterMajor.clientWidth:0,f=f.characterMajor?f.characterMajor.clientHeight:0,r=v+(d.showMajorLabels?f:0),q=c.actualHeight||r;if(c.dataChanged){for(var m=[],n=0,k=p.length;nj)c=j,d.start=this.screenToTime(c)}else if(b.itemDragRight){if(c=b.itemLeft,j=b.itemRight+g,d.end=this.screenToTime(j),e.snapEvents&&(this.step.snap(d.end),j=this.timeToScreen(d.end)),j=1&&(a=0.9);a<=-1&&(a=-0.9);a<0&&(a/=1+a);var c=parseFloat(this.start.valueOf()-b.valueOf()),d=parseFloat(this.end.valueOf()-b.valueOf());this.applyRange(new Date(this.start.valueOf()-c*a),new Date(this.end.valueOf()-d*a),b);this.recalcSize();c=this.options.animate?this.options.animateZoom:!1;this.stackEvents(c);(!c||this.groups.length>0)&&this.redrawFrame()}; links.Timeline.prototype.move=function(a){var b=parseFloat(this.end.valueOf()-this.start.valueOf());this.applyRange(new Date(this.start.valueOf()+b*a),new Date(this.end.valueOf()+b*a));this.recalcConversion();this.redrawFrame()}; links.Timeline.prototype.repositionItem=function(a,b,c){var d=a.dom;switch(a.type){case "range":d.style.left=b+"px";d.style.width=Math.max(c-b,1)+"px";break;case "box":d.style.left=b-a.width/2+"px";d.line.style.left=b-a.lineWidth/2+"px";d.dot.style.left=b-a.dotWidth/2+"px";break;case "dot":d.style.left=b-a.dotWidth/2+"px"}if(this.groups.length>0)d.style.top=a.top+"px"}; links.Timeline.prototype.applyRange=function(a,b,c){var a=a.valueOf(),b=b.valueOf(),d=b-a,e=this.options,g=Number(e.intervalMin)||10;g<10&&(g=10);var f=Number(e.intervalMax)||31536E10;f>31536E10&&(f=31536E10);f=e&&(e=j+864E5),f>e-j&&(f=e-j),g>e-j&&(g=e-j));a>=b&&(b+=864E5);if(df&&(g=d-f,l=c?(c.valueOf()-a)/d:0.5,a+=Math.round(g*l), b-=Math.round(g*(1-l)));j&&(g=a-j,g<0&&(a-=g,b-=g));e&&(g=e-b,g<0&&(a+=g,b+=g));this.start=new Date(a);this.end=new Date(b)};links.Timeline.prototype.confirmDeleteItem=function(a){this.applyDelete=!0;this.isSelected(a)||this.selectItem(a);this.trigger("delete");this.applyDelete&&this.deleteItem(a);delete this.applyDelete}; links.Timeline.prototype.deleteItem=function(a){if(a>=this.items.length)throw"Cannot delete row, index out of range";this.unselectItem();this.items.splice(a,1);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";this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.stackEvents(this.options.animate); this.options.animate||this.redrawFrame();this.size.dataChanged=!1}; links.Timeline.prototype.deleteAllItems=function(){this.unselectItem();this.items=[];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";this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.stackEvents(this.options.animate);this.options.animate|| this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.getGroupFromHeight=function(a){var b=this.groups,c=this.size;a-=this.options.axisOnTop?c.axis.height:0;if(b){for(var d,c=b.length-1;c>=0;c--)if(d=b[c],a>d.top)break;return d}};links.Timeline.prototype.getItem=function(a){if(a>=this.items.length)throw"Cannot get item, index out of range";var a=this.items[a],b={};b.start=new Date(a.start);if(a.end)b.end=new Date(a.end);b.content=a.content;if(a.group)b.group=a.group.content;return b}; links.Timeline.prototype.addItem=function(a){this.addItems([a])};links.Timeline.prototype.addItems=function(a){for(var b=this.items,c=0,d=a.length;c=this.items.length)throw"Cannot change item, index out of range";var c=this.items[a];if(b.start)c.start=b.start;if(b.end)c.end=b.end;if(b.content)c.content=b.content;if(b.group)c.group=this.addGroup(b.group);this.updateData(a,b);this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.stackEvents(!1);this.redrawFrame();this.size.dataChanged=!1}; links.Timeline.prototype.findGroup=function(a){a=this.groupIndexes[a];return a!=void 0?this.groups[a]:void 0};links.Timeline.prototype.deleteGroups=function(){this.groups=[];this.groupIndexes={}}; links.Timeline.prototype.addGroup=function(a){var b=this.groups,c=this.groupIndexes,d=void 0,d=c[a];if(d===void 0&&a!==void 0){d={content:a,labelTop:0,lineTop:0};b.push(d);for(var b=b.sort(function(a,b){return a.content>b.content?1:a.content0){if(a[0].row!=void 0){var b=a[0].row;if(this.items[b])return a=this.items[b],this.selectItem(b),b=a.start,a=a.end,a=a!=void 0?new Date((a.valueOf()+b.valueOf())/2):new Date(b),b=this.end.valueOf()-this.start.valueOf(),this.setVisibleChartRange(new Date(a.valueOf()-b/2),new Date(a.valueOf()+b/2)),!0}}else this.unselectItem();return!1}; links.Timeline.prototype.getSelection=function(){var a=[];this.selection&&a.push({row:this.selection.index});return a}; links.Timeline.prototype.selectItem=function(a){this.unselectItem();this.selection=void 0;if(this.items[a]!==void 0){var b=this.items[a],c=b.dom;this.selection={index:a,item:c};if(this.options.editable)c.style.cursor="move";switch(b.type){case "range":c.className="timeline-event timeline-event-selected timeline-event-range";break;case "box":c.className="timeline-event timeline-event-selected timeline-event-box";c.line.className="timeline-event timeline-event-selected timeline-event-line";c.dot.className= "timeline-event timeline-event-selected timeline-event-dot";break;case "dot":c.className="timeline-event timeline-event-selected",c.dot.className="timeline-event timeline-event-selected timeline-event-dot"}}};links.Timeline.prototype.isSelected=function(a){return this.selection&&this.selection.index===a}; links.Timeline.prototype.unselectItem=function(){if(this.selection){var a=this.items[this.selection.index];if(a&&a.dom){var b=a.dom;b.style.cursor="";switch(a.type){case "range":b.className="timeline-event timeline-event-range";break;case "box":b.className="timeline-event timeline-event-box";b.line.className="timeline-event timeline-event-line";b.dot.className="timeline-event timeline-event-dot";break;case "dot":b.className="",b.dot.className="timeline-event timeline-event-dot"}}}this.selection=void 0}; links.Timeline.prototype.stackEvents=function(a){if(!(this.groups.length>0)){a==void 0&&(a=!1);var b=this.stackOrder(this.items),c=this.stackCalculateFinal(b,a);if(a){var d=this.animation;if(!d)this.animation=d={};d.finalItems=c;var e=this,g=function(){var a=e.stackMoveOneStep(b,d.finalItems);e.recalcSize();e.redrawFrame();a?(delete d.finalItems,delete d.timer):d.timer=setTimeout(g,30)};if(!d.timer)d.timer=setTimeout(g,30)}else this.stackMoveToFinal(b,c),this.recalcSize()}}; links.Timeline.prototype.stackOrder=function(a){a=a.concat([]);a.sort(function(a,c){return a.type=="range"&&c.type!="range"?-1:a.type!="range"&&c.type=="range"?1:a.left-c.left});return a}; links.Timeline.prototype.stackCalculateFinal=function(a){for(var b=this.size.axis.top,c=this.options,d=c.axisOnTop,e=c.eventMargin,g=c.eventMarginAxis,c=[],f=0,j=a.length;fg?1:-1;Math.abs(j)>4&&(l=j/4);g=parseInt(g+l);g!=f&&(c=!1);e.top=g;e.bottom=e.top+e.height}else e.top=d.top,e.bottom=d.bottom;e.left=d.left;e.right=d.right}return c}; links.Timeline.prototype.stackMoveToFinal=function(a,b){for(i=0,iMax=a.length;i=c;d--){var j=a[d];if(g(f,j,e)&&d!=b)return j}};links.Timeline.prototype.collision=function(a,b,c){c==void 0&&(c=0);return a.left-cb.left&&a.top-cb.top}; links.Timeline.prototype.trigger=function(a){var b=null;switch(a){case "rangechange":case "rangechanged":b={start:new Date(this.start),end:new Date(this.end)};break;case "timechange":case "timechanged":b={time:new Date(this.customTime)}}links.events.trigger(this,a,b);google&&google.visualization&&google.visualization.events.trigger(this,a,b)}; links.events=links.events||{listeners:[],indexOf:function(a){for(var b=this.listeners,c=0,d=this.listeners.length;cthis._end.getTime()}; links.Timeline.StepDate.prototype.next=function(){var a=this.current.getTime();if(this.current.getMonth()<6)switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current=new Date(this.current.getTime()+this.step);break;case links.Timeline.StepDate.SCALE.SECOND:this.current=new Date(this.current.getTime()+this.step*1E3);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current=new Date(this.current.getTime()+this.step*6E4);break;case links.Timeline.StepDate.SCALE.HOUR:this.current= new Date(this.current.getTime()+this.step*36E5);var b=this.current.getHours();this.current.setHours(b-b%this.step);break;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)}else switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current= new Date(this.current.getTime()+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.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)}if(this.step!=1)switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current.getMilliseconds()0)this.step=b;this.autoScale=!1};links.Timeline.StepDate.prototype.setAutoScale=function(a){this.autoScale=a}; links.Timeline.StepDate.prototype.setMinimumStep=function(a){if(a!=void 0){if(31104E9>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=1E3;if(15552E9>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=500;if(31104E8>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=100;if(15552E8>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=50;if(31104E7>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=10;if(15552E7>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step= 5;if(31104E6>a)this.scale=links.Timeline.StepDate.SCALE.YEAR,this.step=1;if(7776E6>a)this.scale=links.Timeline.StepDate.SCALE.MONTH,this.step=3;if(2592E6>a)this.scale=links.Timeline.StepDate.SCALE.MONTH,this.step=1;if(432E6>a)this.scale=links.Timeline.StepDate.SCALE.DAY,this.step=5;if(1728E5>a)this.scale=links.Timeline.StepDate.SCALE.DAY,this.step=2;if(864E5>a)this.scale=links.Timeline.StepDate.SCALE.DAY,this.step=1;if(144E5>a)this.scale=links.Timeline.StepDate.SCALE.HOUR,this.step=4;if(36E5>a)this.scale= links.Timeline.StepDate.SCALE.HOUR,this.step=1;if(9E5>a)this.scale=links.Timeline.StepDate.SCALE.MINUTE,this.step=15;if(6E5>a)this.scale=links.Timeline.StepDate.SCALE.MINUTE,this.step=10;if(3E5>a)this.scale=links.Timeline.StepDate.SCALE.MINUTE,this.step=5;if(6E4>a)this.scale=links.Timeline.StepDate.SCALE.MINUTE,this.step=1;if(15E3>a)this.scale=links.Timeline.StepDate.SCALE.SECOND,this.step=15;if(1E4>a)this.scale=links.Timeline.StepDate.SCALE.SECOND,this.step=10;if(5E3>a)this.scale=links.Timeline.StepDate.SCALE.SECOND, this.step=5;if(1E3>a)this.scale=links.Timeline.StepDate.SCALE.SECOND,this.step=1;if(200>a)this.scale=links.Timeline.StepDate.SCALE.MILLISECOND,this.step=200;if(100>a)this.scale=links.Timeline.StepDate.SCALE.MILLISECOND,this.step=100;if(50>a)this.scale=links.Timeline.StepDate.SCALE.MILLISECOND,this.step=50;if(10>a)this.scale=links.Timeline.StepDate.SCALE.MILLISECOND,this.step=10;if(5>a)this.scale=links.Timeline.StepDate.SCALE.MILLISECOND,this.step=5;if(1>a)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)a.getDate()>15?(a.setDate(1),a.setMonth(a.getMonth()+1)):a.setDate(1),a.setHours(0),a.setMinutes(0),a.setSeconds(0),a.setMilliseconds(0);else if(this.scale== links.Timeline.StepDate.SCALE.DAY){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)}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)}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)}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()/1E3)*1E3);break;default:a.setMilliseconds(Math.round(a.getMilliseconds()/500)*500)}else this.scale==links.Timeline.StepDate.SCALE.MILLISECOND&& (b=this.step>5?this.step/2:1,a.setMilliseconds(Math.round(a.getMilliseconds()/b)*b))}; 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.DAY:return this.current.getDate()==1;case links.Timeline.StepDate.SCALE.MONTH:return this.current.getMonth()== 0;case links.Timeline.StepDate.SCALE.YEAR:return!1;default:return!1}}; links.Timeline.StepDate.prototype.getLabelMinor=function(a){var b="Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(",");if(a==void 0)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.DAY:return String(a.getDate());case links.Timeline.StepDate.SCALE.MONTH:return b[a.getMonth()];case links.Timeline.StepDate.SCALE.YEAR:return String(a.getFullYear());default:return""}}; links.Timeline.StepDate.prototype.getLabelMajor=function(a){var b="January,February,March,April,May,June,July,August,September,October,November,December".split(","),c="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",");if(a==void 0)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[a.getMonth()]+" "+this.addZeros(a.getHours(),2)+":"+this.addZeros(a.getMinutes(),2);case links.Timeline.StepDate.SCALE.MINUTE:return c[a.getDay()]+" "+a.getDate()+" "+b[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.HOUR:return c[a.getDay()]+" "+a.getDate()+" "+b[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.DAY:return b[a.getMonth()]+" "+a.getFullYear();case links.Timeline.StepDate.SCALE.MONTH:return String(a.getFullYear());default:return""}}; links.Timeline.StepDate.prototype.addZeros=function(a,b){for(var c=""+a;c.length=0&&(b="DOMMouseScroll"),a.addEventListener(b,c,d)):a.attachEvent("on"+b,c)};links.Timeline.removeEventListener=function(a,b,c,d){a.removeEventListener?(d===void 0&&(d=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.removeEventListener(b,c,d)):a.detachEvent("on"+b,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!==void 0&&b.nodeType==3)b=b.parentNode;return b};links.Timeline.stopPropagation=function(a){if(!a)a=window.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0};links.Timeline.preventDefault=function(a){if(!a)a=window.event;a.preventDefault?a.preventDefault():a.returnValue=!1}; links.Timeline.getAbsoluteLeft=function(a){for(var b=0;a!=null;)b+=a.offsetLeft,b-=a.scrollLeft,a=a.offsetParent;!document.body.scrollLeft&&window.pageXOffset&&(b-=window.pageXOffset);return b};links.Timeline.getAbsoluteTop=function(a){for(var b=0;a!=null;)b+=a.offsetTop,b-=a.scrollTop,a=a.offsetParent;!document.body.scrollTop&&window.pageYOffset&&(b-=window.pageYOffset);return b};links.Timeline.isArray=function(a){return a instanceof Array?!0:Object.prototype.toString.call(a)==="[object Array]"};