/**
 * @file timeline.js
 *
 * @brief
 * The Timeline is an interactive visualization chart to visualize events in
 * time, having a start and end date.
 * You can freely move and zoom in the timeline by dragging
 * and scrolling in the Timeline. Items are optionally dragable. The time
 * scale on the axis is adjusted automatically, and supports scales ranging
 * from milliseconds to years.
 *
 * Timeline is part of the CHAP Links library.
 *
 * Timeline is tested on Firefox 3.6, Safari 5.0, Chrome 6.0, Opera 10.6, and
 * Internet Explorer 6+.
 *
 * @license
 * 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, <jos@almende.org>
 * @date    2012-06-15
 * @version 2.1.2
 *//*
 * TODO
 *
 * Add zooming with pinching on Android
 * 
 * Bug: when an item contains a javascript onclick or a link, this does not work
 *      when the item is not selected (when the item is being selected,
 *      it is redrawn, which cancels any onclick or link action)
 * Bug: when an item contains an image without size, or a css max-width, it is not sized correctly
 * Bug: neglect items when they have no valid start/end, instead of throwing an error
 * Bug: Pinching on ipad does not work very well, sometimes the page will zoom when pinching vertically
 * Bug: cannot set max width for an item, like div.timeline-event-content {white-space: normal; max-width: 100px;}
 * Bug on IE in Quirks mode. When you have groups, and delete an item, the groups become invisible
 *//**
 * Declare a unique namespace for CHAP's Common Hybrid Visualisation Library,
 * "links"
 */typeof links=="undefined"&&(links={});typeof google=="undefined"&&(google=undefined);links.Timeline=function(e){this.dom={};this.conversion={};this.eventParams={};this.groups=[];this.groupIndexes={};this.items=[];this.visibleItems=0;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,dataChanged:!1,frameHeight:0,frameWidth:0,groupsLeft:0,groupsWidth:0,items:{top:0}};this.dom.container=e;this.options={width:"100%",height:"auto",minHeight:0,autoHeight:!0,eventMargin:10,eventMarginAxis:20,dragAreaWidth:10,min:undefined,max:undefined,intervalMin:10,intervalMax:31536e10,moveable:!0,zoomable:!0,selectable:!0,editable:!1,snapEvents:!0,groupChangeable:!0,mousewheel:"zoom",dblclick:"edit",showCurrentTime:!0,showCustomTime:!1,showMajorLabels:!0,showNavigation:!1,showButtonAdd:!0,groupsOnRight:!1,axisOnTop:!1,stackEvents:!0,animate:!0,animateZoom:!0,style:"box",language:"en"};this.clientTimeOffset=0;var t=this.dom;while(t.container.hasChildNodes())t.container.removeChild(t.container.firstChild);this.step=new links.Timeline.StepDate;this.data=[];this.firstDraw=!0;this.setVisibleChartRange(undefined,undefined,!1);this.redrawFrame();Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;t<this.length;t++)if(this[t]==e)return t;return-1});this.trigger("ready")};links.Timeline.prototype.draw=function(e,t){this.setOptions(t);this.setData(e);t&&t.start&&t.end?this.setVisibleChartRange(t.start,t.end):this.firstDraw&&this.setVisibleChartRangeAuto();this.firstDraw=!1};links.Timeline.prototype.setOptions=function(e){if(e)for(var t in e)e.hasOwnProperty(t)&&(this.options[t]=e[t]);this.options.autoHeight=this.options.height==="auto"};links.Timeline.prototype.getOptions=function(){return this.options};links.Timeline.prototype.setData=function(e){this.unselectItem();e||(e=[]);this.items=[];this.data=e;var t=this.items,n=this.options;this.setGroups(e);if(google&&google.visualization&&e instanceof google.visualization.DataTable){var r=e.getNumberOfColumns()>3;for(var i=0,s=e.getNumberOfRows();i<s;i++)t.push(this.createItem({start:e.getValue(i,0),end:e.getValue(i,1),content:e.getValue(i,2),group:r?e.getValue(i,3):undefined}))}else{if(!links.Timeline.isArray(e))throw"Unknown data type. DataTable or Array expected.";for(var i=0,s=e.length;i<s;i++){var o=e[i],u=this.createItem(o);t.push(u)}}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.setGroups=function(e){this.deleteGroups();var t=this.groups,n=this.groupIndexes;if(google&&google.visualization&&e instanceof google.visualization.DataTable){var r=e.getNumberOfColumns()>3;if(r){var i=e.getDistinctValues(3);for(var s=0,o=i.length;s<o;s++)this.addGroup(i[s])}}else{if(!links.Timeline.isArray(e))throw"Unknown data type. DataTable or Array expected.";for(var s=0,o=e.length;s<o;s++){var u=e[s],a=u.group;a&&this.addGroup(a)}}};links.Timeline.prototype.getData=function(){return this.data};links.Timeline.prototype.updateData=function(e,t){var n=this.data;if(google&&google.visualization&&n instanceof google.visualization.DataTable){var r=e+1-n.getNumberOfRows();r>0&&n.addRows(r);t.start&&n.setValue(e,0,t.start);t.end&&n.setValue(e,1,t.end);t.content&&n.setValue(e,2,t.content);t.group&&n.getNumberOfColumns()>3&&n.setValue(e,3,t.group)}else{if(!links.Timeline.isArray(n))throw"Cannot update data, unknown type of data";var i=n[e];if(i==undefined){i={};n[e]=i}t.start&&(i.start=t.start);t.end&&(i.end=t.end);t.content&&(i.content=t.content);t.group&&(i.group=t.group)}};links.Timeline.prototype.getItemIndex=function(e){var t=e,n=this.dom,r=this.items,i=undefined;while(t.parentNode&&t.parentNode!==n.items.frame)t=t.parentNode;if(t.parentNode===n.items.frame)for(var s=0,o=r.length;s<o;s++)if(r[s].dom===t){i=s;break}return i};links.Timeline.prototype.setSize=function(e,t){if(e){this.options.width=e;this.dom.frame.style.width=e}if(t){this.options.height=t;this.options.autoHeight=this.options.height==="auto";t!=="auto"&&(this.dom.frame.style.height=t)}this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame()};links.Timeline.prototype.setVisibleChartRange=function(e,t,n){if(e==undefined){e=new Date;e.setDate(e.getDate()-3)}if(t==undefined){t=new Date;t.setDate(e.getDate()+4)}if(t.valueOf()<=e.valueOf()){t=new Date(e);t.setDate(t.getDate()+7)}var r=this.options.min?this.options.min.valueOf():undefined;r&&e.valueOf()<r&&(e=new Date(r));var i=this.options.max?this.options.max.valueOf():undefined;i&&t.valueOf()>i&&(t=new Date(i));this.applyRange(e,t);if(n==undefined||n==1){this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame()}else this.recalcConversion()};links.Timeline.prototype.setVisibleChartRangeAuto=function(){var e=this.items,t=undefined,n=undefined;for(var r=0,i=e.length;r<i;r++){var s=e[r],o=s.start?s.start.valueOf():undefined,u=s.end?s.end.valueOf():o;t!==undefined&&o!==undefined?t=Math.min(t,o):t=o;n!==undefined&&u!==undefined?n=Math.max(n,u):n=u}if(t!==undefined&&n!==undefined){var a=(n+t)/2,f=n-t;t-=f*.05;n+=f*.05;this.setVisibleChartRange(new Date(t),new Date(n))}else this.setVisibleChartRange(undefined,undefined)};links.Timeline.prototype.setVisibleChartRangeNow=function(){var e=new Date,t=this.end.getTime()-this.start.getTime(),n=new Date(e.getTime()-t/2),r=new Date(n.getTime()+t);this.setVisibleChartRange(n,r)};links.Timeline.prototype.getVisibleChartRange=function(){var e={start:new Date(this.start),end:new Date(this.end)};return e};links.Timeline.prototype.redrawFrame=function(){var e=this.dom,t=this.options,n=this.size;if(!e.frame){e.frame=document.createElement("DIV");e.frame.className="timeline-frame";e.frame.style.position="relative";e.frame.style.overflow="hidden";e.container.appendChild(e.frame)}t.autoHeight?e.frame.style.height=n.frameHeight+"px":e.frame.style.height=t.height||"100%";e.frame.style.width=t.width||"100%";this.redrawContent();this.redrawGroups();this.redrawCurrentTime();this.redrawCustomTime();this.redrawNavigation()};links.Timeline.prototype.redrawContent=function(){var e=this.dom,t=this.size;if(!e.content){e.content=document.createElement("DIV");e.content.style.position="relative";e.content.style.overflow="hidden";e.frame.appendChild(e.content);var n=document.createElement("DIV");n.style.position="absolute";n.style.left="0px";n.style.top="0px";n.style.height="100%";n.style.width="0px";e.content.appendChild(n);e.contentTimelines=n;var r=this.eventParams,i=this;if(!r.onMouseDown){r.onMouseDown=function(e){i.onMouseDown(e)};links.Timeline.addEventListener(e.content,"mousedown",r.onMouseDown)}if(!r.onTouchStart){r.onTouchStart=function(e){i.onTouchStart(e)};links.Timeline.addEventListener(e.content,"touchstart",r.onTouchStart)}if(!r.onMouseWheel){r.onMouseWheel=function(e){i.onMouseWheel(e)};links.Timeline.addEventListener(e.content,"mousewheel",r.onMouseWheel)}if(!r.onDblClick){r.onDblClick=function(e){i.onDblClick(e)};links.Timeline.addEventListener(e.content,"dblclick",r.onDblClick)}}e.content.style.left=t.contentLeft+"px";e.content.style.top="0px";e.content.style.width=t.contentWidth+"px";e.content.style.height=t.frameHeight+"px";this.redrawAxis();this.redrawItems();this.redrawDeleteButton();this.redrawDragAreas()};links.Timeline.prototype.redrawAxis=function(){var e=this.dom,t=this.options,n=this.size,r=this.step,i=e.axis;if(!i){i={};e.axis=i}n.axis.properties===undefined&&(n.axis.properties={});i.minorTexts===undefined&&(i.minorTexts=[]);i.minorLines===undefined&&(i.minorLines=[]);i.majorTexts===undefined&&(i.majorTexts=[]);i.majorLines===undefined&&(i.majorLines=[]);if(!i.frame){i.frame=document.createElement("DIV");i.frame.style.position="absolute";i.frame.style.left="0px";i.frame.style.top="0px";i.frame.className="axis";e.content.appendChild(i.frame)}e.content.removeChild(i.frame);i.frame.style.width=n.contentWidth+"px";i.frame.style.height=n.axis.height+"px";var s=this.screenToTime(0),o=this.screenToTime(n.contentWidth),u=n.contentWidth;this.minimumStep=this.screenToTime(n.axis.characterMinorWidth*6).valueOf()-this.screenToTime(0).valueOf();r.setRange(s,o,this.minimumStep);this.redrawAxisCharacters();this.redrawAxisStartOverwriting();r.start();var a=undefined;while(!r.end()){var f=r.getCurrent(),l=this.timeToScreen(f),c=r.isMajor();this.redrawAxisMinorText(l,r.getLabelMinor(undefined,t.language));if(c&&t.showMajorLabels){if(l>0){a===undefined&&(a=l);this.redrawAxisMajorText(l,r.getLabelMajor(undefined,t.language))}this.redrawAxisMajorLine(l)}else this.redrawAxisMinorLine(l);r.next()}if(t.showMajorLabels){var h=this.screenToTime(0),p=this.step.getLabelMajor(h,t.language),u=p.length*n.axis.characterMajorWidth+10;(a===undefined||u<a)&&this.redrawAxisMajorText(0,p,h)}this.redrawAxisHorizontal();this.redrawAxisEndOverwriting();e.content.insertBefore(i.frame,e.content.firstChild)};links.Timeline.prototype.redrawAxisCharacters=function(){var e=this.dom,t=e.axis;if(!t.characterMinor){var n=document.createTextNode("0"),r=document.createElement("DIV");r.className="timeline-axis-text timeline-axis-text-minor";r.appendChild(n);r.style.position="absolute";r.style.visibility="hidden";r.style.paddingLeft="0px";r.style.paddingRight="0px";t.frame.appendChild(r);t.characterMinor=r}if(!t.characterMajor){var n=document.createTextNode("0"),i=document.createElement("DIV");i.className="timeline-axis-text timeline-axis-text-major";i.appendChild(n);i.style.position="absolute";i.style.visibility="hidden";i.style.paddingLeft="0px";i.style.paddingRight="0px";t.frame.appendChild(i);t.characterMajor=i}};links.Timeline.prototype.redrawAxisStartOverwriting=function(){var e=this.size.axis.properties;e.minorTextNum=0;e.minorLineNum=0;e.majorTextNum=0;e.majorLineNum=0};links.Timeline.prototype.redrawAxisEndOverwriting=function(){var e=this.dom,t=this.size.axis.properties,n=this.dom.axis.frame,r=e.axis.minorTexts,i=t.minorTextNum;while(r.length>i){var s=r[i];n.removeChild(s);r.splice(i,1)}var o=e.axis.minorLines,i=t.minorLineNum;while(o.length>i){var u=o[i];n.removeChild(u);o.splice(i,1)}var a=e.axis.majorTexts,i=t.majorTextNum;while(a.length>i){var f=a[i];n.removeChild(f);a.splice(i,1)}var l=e.axis.majorLines,i=t.majorLineNum;while(l.length>i){var c=l[i];n.removeChild(c);l.splice(i,1)}};links.Timeline.prototype.redrawAxisHorizontal=function(){var e=this.dom.axis,t=this.size;if(!e.backgroundLine){var n=document.createElement("DIV");n.className="timeline-axis";n.style.position="absolute";n.style.left="0px";n.style.width="100%";n.style.border="none";e.frame.insertBefore(n,e.frame.firstChild);e.backgroundLine=n}e.backgroundLine.style.top=t.axis.top+"px";e.backgroundLine.style.height=t.axis.height+"px";if(e.line){var r=e.frame.removeChild(e.line);e.frame.appendChild(r)}else{var r=document.createElement("DIV");r.className="timeline-axis";r.style.position="absolute";r.style.left="0px";r.style.width="100%";r.style.height="0px";e.frame.appendChild(r);e.line=r}e.line.style.top=t.axis.line+"px"};links.Timeline.prototype.redrawAxisMinorText=function(e,t){var n=this.size,r=this.dom,i=n.axis.properties,s=r.axis.frame,o=r.axis.minorTexts,u=i.minorTextNum,a;if(u<o.length)a=o[u];else{var f=document.createTextNode(""),a=document.createElement("DIV");a.appendChild(f);a.className="timeline-axis-text timeline-axis-text-minor";a.style.position="absolute";s.appendChild(a);o.push(a)}a.childNodes[0].nodeValue=t;a.style.left=e+"px";a.style.top=n.axis.labelMinorTop+"px";i.minorTextNum++};links.Timeline.prototype.redrawAxisMinorLine=function(e){var t=this.size.axis,n=this.dom,r=t.properties,i=n.axis.frame,s=n.axis.minorLines,o=r.minorLineNum,u;if(o<s.length)u=s[o];else{u=document.createElement("DIV");u.className="timeline-axis-grid timeline-axis-grid-minor";u.style.position="absolute";u.style.width="0px";i.appendChild(u);s.push(u)}u.style.top=t.lineMinorTop+"px";u.style.height=t.lineMinorHeight+"px";u.style.left=e-t.lineMinorWidth/2+"px";r.minorLineNum++};links.Timeline.prototype.redrawAxisMajorText=function(e,t){var n=this.size,r=n.axis.properties,i=this.dom.axis.frame,s=this.dom.axis.majorTexts,o=r.majorTextNum,u;if(o<s.length)u=s[o];else{var a=document.createTextNode(t);u=document.createElement("DIV");u.className="timeline-axis-text timeline-axis-text-major";u.appendChild(a);u.style.position="absolute";u.style.top="0px";i.appendChild(u);s.push(u)}u.childNodes[0].nodeValue=t;u.style.top=n.axis.labelMajorTop+"px";u.style.left=e+"px";r.majorTextNum++};links.Timeline.prototype.redrawAxisMajorLine=function(e){var t=this.size,n=t.axis.properties,r=this.size.axis,i=this.dom.axis.frame,s=this.dom.axis.majorLines,o=n.majorLineNum,u;if(o<s.length)var u=s[o];else{u=document.createElement("DIV");u.className="timeline-axis-grid timeline-axis-grid-major";u.style.position="absolute";u.style.top="0px";u.style.width="0px";i.appendChild(u);s.push(u)}u.style.left=e-r.lineMajorWidth/2+"px";u.style.height=t.frameHeight+"px";n.majorLineNum++};links.Timeline.prototype.redrawItems=function(){var e=this.dom,t=this.options,n=t.box&&t.box.align?t.box.align:undefined,r=this.size,i=r.contentWidth,s=this.items,o=[];e.items||(e.items={});var u=e.items.frame;if(!u){u=document.createElement("DIV");u.style.position="relative";e.content.appendChild(u);e.items.frame=u}u.style.left="0px";u.style.top=r.items.top+"px";u.style.height=r.frameHeight-r.axis.height+"px";var a=e.items.ranges;if(!a){a=[];e.items.ranges=a}var f=e.items.boxes;if(!f){f=[];e.items.boxes=f}var l=e.items.dots;if(!l){l=[];e.items.dots=l}e.content.removeChild(u);if(r.dataChanged){var c=a.length,h=f.length,p=l.length,d=0,v=0,m=0,g=s.length;for(var y=0,b=s.length;y<b;y++){var w=s[y];switch(w.type){case"range":if(d<c){var E=a[d];E.firstChild.innerHTML=w.content;E.style.display="";w.dom=E;d++}else{var E=this.createEventRange(w.content);a[d]=E;u.appendChild(E);w.dom=E;d++;c++}break;case"box":if(v<h){var E=f[v];E.firstChild.innerHTML=w.content;E.style.display="";w.dom=E;v++}else{var E=this.createEventBox(w.content);f[v]=E;u.appendChild(E);u.insertBefore(E.line,u.firstChild);u.appendChild(E.dot);w.dom=E;v++;h++}break;case"dot":if(m<p){var E=l[m];E.firstChild.innerHTML=w.content;E.style.display="";w.dom=E;m++}else{var E=this.createEventDot(w.content);l[m]=E;u.appendChild(E);w.dom=E;m++;p++}break;default:}}for(var y=d;y<c;y++)u.removeChild(a[y]);a.splice(d,c-d);for(var y=v;y<h;y++){var S=f[y];u.removeChild(S.line);u.removeChild(S.dot);u.removeChild(S)}f.splice(v,h-v);for(var y=m;y<p;y++)u.removeChild(l[y]);l.splice(m,p-m)}for(var y=0,b=this.items.length;y<b;y++){w=this.items[y];E=w.dom;switch(w.type){case"range":E.style.top=w.top+"px";E.style.left=w.left+"px";E.style.width=Math.max(w.right-w.left,1)+"px";break;case"box":var x=t.axisOnTop,T=r.axis.height,N=r.axis.top;E.style.top=w.top+"px";n=="right"?E.style.left=w.left-w.width+"px":n=="left"?E.style.left=w.left+"px":E.style.left=w.left-w.width/2+"px";var C=E.line;C.style.left=w.left-w.lineWidth/2+"px";if(x){C.style.top="0px";C.style.height=Math.max(w.top,0)+"px"}else{C.style.top=w.top+w.height+"px";C.style.height=Math.max(N-w.top-w.height,0)+"px"}var k=E.dot;k.style.left=w.left-w.dotWidth/2+"px";k.style.top=N-w.dotHeight/2+"px";break;case"dot":E.style.top=w.top+"px";E.style.left=w.left-w.dotWidth/2+"px";E.content.style.marginLeft=1.5*w.dotWidth+"px";E.dot.style.top=(w.height-w.dotHeight)/2+"px";break;default:}}if(this.selection){var w=this.selection.item;u.removeChild(w);u.appendChild(w)}e.content.appendChild(u)};links.Timeline.prototype.createEventBox=function(e){var t=document.createElement("DIV");t.style.position="absolute";t.style.left="0px";t.style.top="0px";t.className="timeline-event timeline-event-box";var n=document.createElement("DIV");n.className="timeline-event-content";n.innerHTML=e;t.appendChild(n);var r=document.createElement("DIV");r.style.position="absolute";r.style.width="0px";r.className="timeline-event timeline-event-line";t.line=r;var i=document.createElement("DIV");i.style.position="absolute";i.style.width="0px";i.style.height="0px";i.className="timeline-event timeline-event-dot";t.dot=i;return t};links.Timeline.prototype.createEventDot=function(e){var t=document.createElement("DIV");t.style.position="absolute";var n=document.createElement("DIV");n.className="timeline-event-content";n.innerHTML=e;t.appendChild(n);var r=document.createElement("DIV");r.style.position="absolute";r.className="timeline-event timeline-event-dot";r.style.width="0px";r.style.height="0px";t.appendChild(r);t.content=n;t.dot=r;return t};links.Timeline.prototype.createEventRange=function(e){var t=document.createElement("DIV");t.style.position="absolute";t.className="timeline-event timeline-event-range";var n=document.createElement("DIV");n.className="timeline-event-content";n.innerHTML=e;t.appendChild(n);return t};links.Timeline.prototype.redrawGroups=function(){var e=this.dom,t=this.options,n=this.size,r=this.groups;e.groups===undefined&&(e.groups={});var i=e.groups.labels;if(!i){i=[];e.groups.labels=i}var s=e.groups.labelLines;if(!s){s=[];e.groups.labelLines=s}var o=e.groups.itemLines;if(!o){o=[];e.groups.itemLines=o}var u=e.groups.frame;if(!u){u=document.createElement("DIV");u.className="timeline-groups-axis";u.style.position="absolute";u.style.overflow="hidden";u.style.top="0px";u.style.height="100%";e.frame.appendChild(u);e.groups.frame=u}u.style.left=n.groupsLeft+"px";u.style.width=t.groupsWidth!==undefined?t.groupsWidth:n.groupsWidth+"px";r.length==0?u.style.display="none":u.style.display="";if(n.dataChanged){var a=i.length,f=r.length;for(var l=0,c=Math.min(a,f);l<c;l++){var h=r[l],p=i[l];p.innerHTML=h.content;p.style.display=""}for(var l=a;l<f;l++){var h=r[l],p=document.createElement("DIV");p.className="timeline-groups-text";p.style.position="absolute";t.groupsWidth===undefined&&(p.style.whiteSpace="nowrap");p.innerHTML=h.content;u.appendChild(p);i[l]=p;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";u.appendChild(d);s[l]=d;var v=document.createElement("DIV");v.className="timeline-axis-grid timeline-axis-grid-minor";v.style.position="absolute";v.style.left="0px";v.style.width="100%";v.style.height="0px";v.style.borderTopStyle="solid";e.content.insertBefore(v,e.content.firstChild);o[l]=v}for(var l=f;l<a;l++){var p=i[l],d=s[l],v=o[l];u.removeChild(p);u.removeChild(d);e.content.removeChild(v)}i.splice(f,a-f);s.splice(f,a-f);o.splice(f,a-f);u.style.borderStyle=t.groupsOnRight?"none none none solid":"none solid none none"}for(var l=0,c=r.length;l<c;l++){var h=r[l],p=i[l],d=s[l],v=o[l];p.style.top=h.labelTop+"px";d.style.top=h.lineTop+"px";v.style.top=h.lineTop+"px";v.style.width=n.contentWidth+"px"}if(!e.groups.background){var m=document.createElement("DIV");m.className="timeline-axis";m.style.position="absolute";m.style.left="0px";m.style.width="100%";m.style.border="none";u.appendChild(m);e.groups.background=m}e.groups.background.style.top=n.axis.top+"px";e.groups.background.style.height=n.axis.height+"px";if(!e.groups.line){var g=document.createElement("DIV");g.className="timeline-axis";g.style.position="absolute";g.style.left="0px";g.style.width="100%";g.style.height="0px";u.appendChild(g);e.groups.line=g}e.groups.line.style.top=n.axis.line+"px"};links.Timeline.prototype.redrawCurrentTime=function(){var e=this.options,t=this.dom,n=this.size;if(!e.showCurrentTime){if(t.currentTime){t.contentTimelines.removeChild(t.currentTime);delete t.currentTime}return}if(!t.currentTime){var r=document.createElement("DIV");r.className="timeline-currenttime";r.style.position="absolute";r.style.top="0px";r.style.height="100%";t.contentTimelines.appendChild(r);t.currentTime=r}var i=new Date,s=new Date(i.getTime()+this.clientTimeOffset),o=this.timeToScreen(s),u=o>-n.contentWidth&&o<2*n.contentWidth;t.currentTime.style.display=u?"":"none";t.currentTime.style.left=o+"px";t.currentTime.title="Current time: "+s;if(this.currentTimeTimer!=undefined){clearTimeout(this.currentTimeTimer);delete this.currentTimeTimer}var a=this,f=function(){a.redrawCurrentTime()},l=1/this.conversion.factor/2;l<30&&(l=30);this.currentTimeTimer=setTimeout(f,l)};links.Timeline.prototype.redrawCustomTime=function(){var e=this.options,t=this.dom,n=this.size;if(!e.showCustomTime){if(t.customTime){t.contentTimelines.removeChild(t.customTime);delete t.customTime}return}if(!t.customTime){var r=document.createElement("DIV");r.className="timeline-customtime";r.style.position="absolute";r.style.top="0px";r.style.height="100%";var i=document.createElement("DIV");i.style.position="relative";i.style.top="0px";i.style.left="-10px";i.style.height="100%";i.style.width="20px";r.appendChild(i);t.contentTimelines.appendChild(r);t.customTime=r;this.customTime=new Date}var s=this.timeToScreen(this.customTime),o=s>-n.contentWidth&&s<2*n.contentWidth;t.customTime.style.display=o?"":"none";t.customTime.style.left=s+"px";t.customTime.title="Time: "+this.customTime};links.Timeline.prototype.redrawDeleteButton=function(){var e=this,t=this.options,n=this.dom,r=this.size,i=n.items.frame;if(!t.editable)return;var s=n.items.deleteButton;if(!s){s=document.createElement("DIV");s.className="timeline-navigation-delete";s.style.position="absolute";i.appendChild(s);n.items.deleteButton=s}if(this.selection){var o=this.selection.index,u=this.items[o],a=this.selection.item,f,l=u.top;switch(u.type){case"range":f=this.timeToScreen(u.end);break;case"box":f=this.timeToScreen(u.start)+u.width/2;break;case"dot":f=this.timeToScreen(u.start)+u.width}f<-r.contentWidth&&(f=-r.contentWidth);f>2*r.contentWidth&&(f=2*r.contentWidth);s.style.left=f+"px";s.style.top=l+"px";s.style.display="";i.removeChild(s);i.appendChild(s)}else s.style.display="none"};links.Timeline.prototype.redrawDragAreas=function(){var e=this,t=this.options,n=this.dom,r=this.size,i=this.dom.items.frame;if(!t.editable)return;var s=n.items.dragLeft;if(!s){s=document.createElement("DIV");s.className="timeline-event-range-drag-left";s.style.width=t.dragAreaWidth+"px";s.style.position="absolute";i.appendChild(s);n.items.dragLeft=s}var o=n.items.dragRight;if(!o){o=document.createElement("DIV");o.className="timeline-event-range-drag-right";o.style.width=t.dragAreaWidth+"px";o.style.position="absolute";i.appendChild(o);n.items.dragRight=o}if(this.selection){var u=this.selection.index,a=this.items[u];if(a.type=="range"){var f=a.dom,l=this.timeToScreen(a.start),c=this.timeToScreen(a.end),h=a.top,p=a.height;s.style.left=l+"px";s.style.top=h+"px";s.style.height=p+"px";s.style.display="";i.removeChild(s);i.appendChild(s);o.style.left=c-t.dragAreaWidth+"px";o.style.top=h+"px";o.style.height=p+"px";o.style.display="";i.removeChild(o);i.appendChild(o)}}else{s.style.display="none";o.style.display="none"}};links.Timeline.prototype.redrawNavigation=function(){var e=this,t=this.options,n=this.dom,r=n.frame,i=n.navBar;if(!i){if(t.editable||t.showNavigation){i=document.createElement("DIV");i.style.position="absolute";i.className="timeline-navigation";t.groupsOnRight?i.style.left="10px":i.style.right="10px";t.axisOnTop?i.style.bottom="10px":i.style.top="10px";n.navBar=i;r.appendChild(i)}if(t.editable&&t.showButtonAdd){i.addButton=document.createElement("DIV");i.addButton.className="timeline-navigation-new";i.addButton.title="Create new event";var s=function(n){links.Timeline.preventDefault(n);links.Timeline.stopPropagation(n);var r=e.size.contentWidth,i=r/2,s=e.screenToTime(i-r/10),o=e.screenToTime(i+r/10);if(t.snapEvents){e.step.snap(s);e.step.snap(o)}var u="New",a=e.groups.length?e.groups[0].content:undefined;e.addItem({start:s,end:o,content:u,group:a});var f=e.items.length-1;e.selectItem(f);e.applyAdd=!0;e.trigger("add");e.applyAdd||e.deleteItem(f);e.redrawDeleteButton();e.redrawDragAreas()};links.Timeline.addEventListener(i.addButton,"mousedown",s);i.appendChild(i.addButton)}if(t.editable&&t.showButtonAdd&&t.showNavigation){i.addButton.style.borderRightWidth="1px";i.addButton.style.borderRightStyle="solid"}if(t.showNavigation){i.zoomOutButton=document.createElement("DIV");i.zoomOutButton.className="timeline-navigation-zoom-out";i.zoomOutButton.title="Zoom out";var o=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.zoom(-0.7);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.zoomOutButton,"mousedown",o);i.appendChild(i.zoomOutButton);i.zoomInButton=document.createElement("DIV");i.zoomInButton.className="timeline-navigation-zoom-in";i.zoomInButton.title="Zoom in";var u=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.zoom(.7);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.zoomInButton,"mousedown",u);i.appendChild(i.zoomInButton);i.moveLeftButton=document.createElement("DIV");i.moveLeftButton.className="timeline-navigation-move-left";i.moveLeftButton.title="Move left";var a=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.move(-0.2);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.moveLeftButton,"mousedown",a);i.appendChild(i.moveLeftButton);i.moveRightButton=document.createElement("DIV");i.moveRightButton.className="timeline-navigation-move-right";i.moveRightButton.title="Move right";var f=function(t){links.Timeline.preventDefault(t);links.Timeline.stopPropagation(t);e.move(.2);e.trigger("rangechange");e.trigger("rangechanged")};links.Timeline.addEventListener(i.moveRightButton,"mousedown",f);i.appendChild(i.moveRightButton)}}};links.Timeline.prototype.setCurrentTime=function(e){var t=new Date;this.clientTimeOffset=e.getTime()-t.getTime();this.redrawCurrentTime()};links.Timeline.prototype.getCurrentTime=function(){var e=new Date;return new Date(e.getTime()+this.clientTimeOffset)};links.Timeline.prototype.setCustomTime=function(e){this.customTime=new Date(e);this.redrawCustomTime()};links.Timeline.prototype.getCustomTime=function(){return new Date(this.customTime)};links.Timeline.prototype.setScale=function(e,t){this.step.setScale(e,t);this.redrawFrame()};links.Timeline.prototype.setAutoScale=function(e){this.step.setAutoScale(e);this.redrawFrame()};links.Timeline.prototype.redraw=function(){this.setData(this.data)};links.Timeline.prototype.checkResize=function(){var e=this.recalcSize();e=this.repositionItems();e&&this.redrawFrame()};links.Timeline.filterImageUrls=function(e,t){var n=e.firstChild;while(n){if(n.tagName=="IMG"){var r=n.src;t.indexOf(r)==-1&&t.push(r)}links.Timeline.filterImageUrls(n,t);n=n.nextSibling}};links.Timeline.prototype.recalcSize=function(){var e=!1,t=this,n=this.size,r=this.options,i=r.axisOnTop,s=this.dom,o=s.axis,u=this.groups,a=s.groups.labels,f=this.items,l=n.groupsWidth,c=o.characterMinor?o.characterMinor.clientWidth:0,h=o.characterMinor?o.characterMinor.clientHeight:0,p=o.characterMajor?o.characterMajor.clientWidth:0,d=o.characterMajor?o.characterMajor.clientHeight:0,v=h+(r.showMajorLabels?d:0),m=n.actualHeight||v;if(n.dataChanged){var g=[];for(var y=0,b=f.length;y<b;y++){var w=f[y],E=w.dom;E&&links.Timeline.filterImageUrls(E,g)}if(g.length)for(var y=0;y<g.length;y++){var S=g[y],x=function(e){t.redraw()},T=!1;links.imageloader.load(S,x,T)}}if(n.dataChanged){l=0;for(var y=0,b=a.length;y<b;y++){var N=u[y];N.width=a[y].clientWidth;N.height=a[y].clientHeight;N.labelHeight=N.height;l=Math.max(l,N.width)}var e=this.recalcSizeItems();m=v+2*r.eventMarginAxis;for(var y=0,b=u.length;y<b;y++)m+=u[y].height+r.eventMargin}if(u.length==0&&r.autoHeight){var C=0,k=0;if(this.animation&&this.animation.finalItems){var L=this.animation.finalItems,A=L[0];A&&A.top&&(C=A.top,k=A.top+A.height);for(var y=1,b=L.length;y<b;y++){A=L[y];C=Math.min(C,A.top);k=Math.max(k,A.top+A.height)}}else{var w=f[0];w&&w.top&&(C=w.top,k=w.top+w.height);for(var y=1,b=f.length;y<b;y++){var w=f[y];if(w.top){C=Math.min(C,w.top);k=Math.max(k,w.top+w.height)}}}m=k-C+2*r.eventMarginAxis+v;if(n.actualHeight!=m&&r.autoHeight&&!r.axisOnTop){var O=m-n.actualHeight;if(this.animation&&this.animation.finalItems){var L=this.animation.finalItems;for(var y=0,b=L.length;y<b;y++){L[y].top+=O;L[y].item.top+=O}}else for(var y=0,b=f.length;y<b;y++)f[y].top+=O}}var M=s.frame?s.frame.offsetWidth:0,_=Math.max(r.autoHeight?m:s.frame?s.frame.clientHeight:0,r.minHeight),D=i?0:_-v,P=i?v:D,H=i?v:0,B=Math.max(_-v,0);r.groupsWidth!==undefined&&(l=s.groups.frame?s.groups.frame.clientWidth:0);var j=r.groupsOnRight?M-l:0;if(n.dataChanged){var F=r.eventMargin,I=i?r.eventMarginAxis+F/2:B-r.eventMarginAxis+F/2;for(var y=0,b=u.length;y<b;y++){var N=u[y];if(i){N.top=I;N.labelTop=I+v+(N.height-N.labelHeight)/2;N.lineTop=I+v+N.height+F/2;I+=N.height+F}else{I-=N.height+F;N.top=I;N.labelTop=I+(N.height-N.labelHeight)/2;N.lineTop=I-F/2}}for(var y=0,b=f.length;y<b;y++){var w=f[y],N=w.group;N&&(w.top=N.top)}e=!0}e=e||n.groupsWidth!==l;e=e||n.groupsLeft!==j;e=e||n.actualHeight!==m;n.groupsWidth=l;n.groupsLeft=j;n.actualHeight=m;e=e||n.frameWidth!==M;e=e||n.frameHeight!==_;n.frameWidth=M;n.frameHeight=_;e=e||n.groupsWidth!==l;n.groupsWidth=l;n.contentLeft=r.groupsOnRight?0:l;n.contentWidth=Math.max(M-l,0);n.contentHeight=B;e=e||n.axis.top!==D;e=e||n.axis.line!==P;e=e||n.axis.height!==v;e=e||n.items.top!==H;n.axis.top=D;n.axis.line=P;n.axis.height=v;n.axis.labelMajorTop=r.axisOnTop?0:P+h;n.axis.labelMinorTop=r.axisOnTop?r.showMajorLabels?d:0:P;n.axis.lineMinorTop=r.axisOnTop?n.axis.labelMinorTop:0;n.axis.lineMinorHeight=r.showMajorLabels?_-d:_;n.axis.lineMinorWidth=s.axis.minorLines.length?s.axis.minorLines[0].offsetWidth:1;n.axis.lineMajorWidth=s.axis.majorLines.length?s.axis.majorLines[0].offsetWidth:1;n.items.top=H;e=e||n.axis.characterMinorWidth!==c;e=e||n.axis.characterMinorHeight!==h;e=e||n.axis.characterMajorWidth!==p;e=e||n.axis.characterMajorHeight!==d;n.axis.characterMinorWidth=c;n.axis.characterMinorHeight=h;n.axis.characterMajorWidth=p;n.axis.characterMajorHeight=d;this.recalcConversion();return e};links.Timeline.prototype.recalcSizeItems=function(e){e=e||!1;for(var t=0,n=this.items.length;t<n;t++){var r=this.items[t],i=r.dom,s=r.group,o=i?i.clientWidth:0,u=i?i.clientHeight:0;e=e||r.width!=o;e=e||r.height!=u;r.width=o;r.height=u;switch(r.type){case"range":break;case"box":r.dotHeight=i.dot.offsetHeight;r.dotWidth=i.dot.offsetWidth;r.lineWidth=i.line.offsetWidth;break;
case"dot":r.dotHeight=i.dot.offsetHeight;r.dotWidth=i.dot.offsetWidth;r.contentHeight=i.content.offsetHeight}s&&(s.height=s.height?Math.max(s.height,r.height):r.height)}return e};links.Timeline.prototype.recalcConversion=function(){this.conversion.offset=parseFloat(this.start.valueOf());this.conversion.factor=parseFloat(this.size.contentWidth)/parseFloat(this.end.valueOf()-this.start.valueOf())};links.Timeline.prototype.screenToTime=function(e){var t=this.conversion,n=new Date(parseFloat(e)/t.factor+t.offset);return n};links.Timeline.prototype.timeToScreen=function(e){var t=this.conversion,n=(e.valueOf()-t.offset)*t.factor;return n};links.Timeline.prototype.onTouchStart=function(e){var t=this.eventParams,n=this.dom,r=this;if(t.touchDown)return;t.touchDown=!0;t.zoomed=!1;this.onMouseDown(e);if(!t.onTouchMove){t.onTouchMove=function(e){r.onTouchMove(e)};links.Timeline.addEventListener(document,"touchmove",t.onTouchMove)}if(!t.onTouchEnd){t.onTouchEnd=function(e){r.onTouchEnd(e)};links.Timeline.addEventListener(document,"touchend",t.onTouchEnd)}};links.Timeline.prototype.onTouchMove=function(e){var t=this.eventParams;e.scale&&e.scale!==1&&(t.zoomed=!0);if(!t.zoomed)this.onMouseMove(e);else if(this.options.zoomable){t.zoomed=!0;var n=e.scale,r=t.end.valueOf()-t.start.valueOf(),i=r/n,s=i-r,o=new Date(parseInt(t.start.valueOf()-s/2)),u=new Date(parseInt(t.end.valueOf()+s/2));this.setVisibleChartRange(o,u);timeline.trigger("rangechange");links.Timeline.preventDefault(e)}};links.Timeline.prototype.onTouchEnd=function(e){var t=this.eventParams;t.touchDown=!1;t.zoomed&&timeline.trigger("rangechanged");if(t.onTouchMove){links.Timeline.removeEventListener(document,"touchmove",t.onTouchMove);delete t.onTouchMove}if(t.onTouchEnd){links.Timeline.removeEventListener(document,"touchend",t.onTouchEnd);delete t.onTouchEnd}this.onMouseUp(e)};links.Timeline.prototype.onMouseDown=function(e){e=e||window.event;var t=this.eventParams,n=this.options,r=this.dom,i=e.which?e.which==1:e.button==1;if(!i&&!t.touchDown)return;this.recalcSize();if(!t.touchDown){t.mouseX=e.clientX;t.mouseY=e.clientY}else{t.mouseX=e.targetTouches[0].clientX;t.mouseY=e.targetTouches[0].clientY}t.mouseX===undefined&&(t.mouseX=0);t.mouseY===undefined&&(t.mouseY=0);t.frameLeft=links.Timeline.getAbsoluteLeft(this.dom.content);t.frameTop=links.Timeline.getAbsoluteTop(this.dom.content);t.previousLeft=0;t.previousOffset=0;t.moved=!1;t.start=new Date(this.start);t.end=new Date(this.end);t.target=links.Timeline.getTarget(e);t.itemDragLeft=t.target===this.dom.items.dragLeft;t.itemDragRight=t.target===this.dom.items.dragRight;t.itemDragLeft||t.itemDragRight?t.itemIndex=this.selection?this.selection.index:undefined:t.itemIndex=this.getItemIndex(t.target);t.customTime=t.target===r.customTime||t.target.parentNode===r.customTime?this.customTime:undefined;t.addItem=n.editable&&e.ctrlKey;if(t.addItem){var s=t.mouseX-t.frameLeft,o=t.mouseY-t.frameTop,u=this.screenToTime(s);n.snapEvents&&this.step.snap(u);var a=new Date(u),f="New",l=this.getGroupFromHeight(o);this.addItem({start:u,end:a,content:f,group:l.content});t.itemIndex=this.items.length-1;this.selectItem(t.itemIndex);t.itemDragRight=!0}t.editItem=n.editable?this.isSelected(t.itemIndex):undefined;if(t.editItem){var c=this.items[t.itemIndex];t.itemStart=c.start;t.itemEnd=c.end;t.itemType=c.type;if(t.itemType=="range"){t.itemLeft=this.timeToScreen(c.start);t.itemRight=this.timeToScreen(c.end)}else t.itemLeft=this.timeToScreen(c.start)}else this.dom.frame.style.cursor="move";if(!t.touchDown){var h=this;if(!t.onMouseMove){t.onMouseMove=function(e){h.onMouseMove(e)};links.Timeline.addEventListener(document,"mousemove",t.onMouseMove)}if(!t.onMouseUp){t.onMouseUp=function(e){h.onMouseUp(e)};links.Timeline.addEventListener(document,"mouseup",t.onMouseUp)}links.Timeline.preventDefault(e)}};links.Timeline.prototype.onMouseMove=function(e){e=e||window.event;var t=this.eventParams,n=this.size,r=this.dom,i=this.options,s,o;if(!t.touchDown){s=e.clientX;o=e.clientY}else{s=e.targetTouches[0].clientX;o=e.targetTouches[0].clientY}s===undefined&&(s=0);o===undefined&&(o=0);t.mouseX===undefined&&(t.mouseX=s);t.mouseY===undefined&&(t.mouseY=o);var u=parseFloat(s)-t.mouseX,a=parseFloat(o)-t.mouseY;t.moved=!0;if(t.customTime){var f=this.timeToScreen(t.customTime),l=f+u;this.customTime=this.screenToTime(l);this.redrawCustomTime();this.trigger("timechange")}else if(t.editItem){var c=this.items[t.itemIndex],h=c.dom,p,d;if(t.itemDragLeft){p=t.itemLeft+u;d=t.itemRight;c.start=this.screenToTime(p);if(i.snapEvents){this.step.snap(c.start);p=this.timeToScreen(c.start)}if(p>d){p=d;c.start=this.screenToTime(p)}}else if(t.itemDragRight){p=t.itemLeft;d=t.itemRight+u;c.end=this.screenToTime(d);if(i.snapEvents){this.step.snap(c.end);d=this.timeToScreen(c.end)}if(d<p){d=p;c.end=this.screenToTime(d)}}else{p=t.itemLeft+u;c.start=this.screenToTime(p);if(i.snapEvents){this.step.snap(c.start);p=this.timeToScreen(c.start)}if(c.end){d=p+(t.itemRight-t.itemLeft);c.end=this.screenToTime(d)}}this.repositionItem(c,p,d);if(this.groups.length==0){this.stackEvents(i.animate);i.animate||this.redrawFrame()}else if(i.groupsChangeable){var v=o-t.frameTop,m=this.getGroupFromHeight(v);if(c.group!==m){var g=this.items.indexOf(c);this.changeItem(g,{group:m.content});c.top=m.top;this.repositionItem(c)}}this.redrawDeleteButton();this.redrawDragAreas()}else i.moveable&&this.moveFrame(u);links.Timeline.preventDefault(e)};links.Timeline.prototype.moveFrame=function(e){var t=this.eventParams,n=this.size,r=this.dom,i=this.options,s=t.end.valueOf()-t.start.valueOf(),o=Math.round(parseFloat(-e)/n.contentWidth*s),u=new Date(t.start.valueOf()+o),a=new Date(t.end.valueOf()+o);this.applyRange(u,a);var f=this.start.valueOf()-u.valueOf();f&&(o+=f);this.recalcConversion();var l=t.previousLeft||0,c=parseFloat(r.items.frame.style.left)||0,h=t.previousOffset||0,p=h+(c-l),d=Math.round(-o/s*n.contentWidth+p);t.previousOffset=p;t.previousLeft=d;r.items.frame.style.left=d+"px";this.redrawCurrentTime();this.redrawCustomTime();this.redrawAxis();this.trigger("rangechange")};links.Timeline.prototype.onMouseUp=function(e){var t=this.eventParams,n=this.options;e=e||window.event;this.dom.frame.style.cursor="auto";if(t.onMouseMove){links.Timeline.removeEventListener(document,"mousemove",t.onMouseMove);delete t.onMouseMove}if(t.onMouseUp){links.Timeline.removeEventListener(document,"mouseup",t.onMouseUp);delete t.onMouseUp}if(t.customTime)this.trigger("timechanged");else if(t.editItem){var r=this.items[t.itemIndex];if(t.moved||t.addItem){this.applyChange=!0;this.applyAdd=!0;this.updateData(t.itemIndex,{start:r.start,end:r.end});this.trigger(t.addItem?"add":"change");if(t.addItem)this.applyAdd?this.updateData(t.itemIndex,{start:r.start,end:r.end,content:r.content,group:r.group?r.group.content:undefined}):this.deleteItem(t.itemIndex);else if(this.applyChange)this.updateData(t.itemIndex,{start:r.start,end:r.end});else{delete this.applyChange;delete this.applyAdd;var r=this.items[t.itemIndex],i=r.dom;r.start=t.itemStart;r.end=t.itemEnd;this.repositionItem(r,t.itemLeft,t.itemRight)}this.recalcSize();this.repositionItems();this.stackEvents(n.animate);n.animate||this.redrawFrame();this.redrawDeleteButton();this.redrawDragAreas()}}else this.endMoveFrame()};links.Timeline.prototype.endMoveFrame=function(){var e=this.eventParams,t=this.options;if(!e.moved&&!e.zoomed){if(t.editable&&e.target===this.dom.items.deleteButton){this.selection&&this.confirmDeleteItem(this.selection.index);this.redrawFrame()}else if(t.selectable)if(e.itemIndex!==undefined){if(!this.isSelected(e.itemIndex)){this.selectItem(e.itemIndex);this.redrawDeleteButton();this.redrawDragAreas();this.trigger("select")}}else{this.unselectItem();this.redrawDeleteButton();this.redrawDragAreas()}}else{this.repositionItems();this.stackEvents(t.animate);t.animate||this.redrawFrame();(e.moved&&t.moveable||e.zoomed&&t.zoomable)&&this.trigger("rangechanged")}};links.Timeline.prototype.onDblClick=function(e){var t=this.eventParams,n=this.options,r=this.dom,i=this.size;e=e||window.event;if(!n.editable&&!n.zoomable)return;switch(n.dblclick){case"edit":if(!n.editable)return;if(t.itemIndex!==undefined)this.trigger("edit");else{var s=e.clientX-links.Timeline.getAbsoluteLeft(r.content),o=e.clientY-links.Timeline.getAbsoluteTop(r.content),u=this.screenToTime(s),a=this.screenToTime(s+i.frameWidth/10);if(n.snapEvents){this.step.snap(u);this.step.snap(a)}var f="New",l=this.getGroupFromHeight(o);this.addItem({start:u,end:a,content:f,group:l.content});t.itemIndex=this.items.length-1;this.selectItem(t.itemIndex);this.applyAdd=!0;this.trigger("add");this.applyAdd||this.deleteItem(t.itemIndex);this.redrawDeleteButton();this.redrawDragAreas()}break;case"zoom":if(!n.zoomable)return;var s=e.clientX-links.Timeline.getAbsoluteLeft(r.content),c=i.frameWidth/5,u=this.screenToTime(s-c),a=this.screenToTime(s+c);this.setVisibleChartRange(u,a)}links.Timeline.preventDefault(e)};links.Timeline.prototype.onMouseWheel=function(e){if(!this.options.zoomable&&!this.options.moveable)return;e||(e=window.event);var t=0;e.wheelDelta?t=e.wheelDelta/120:e.detail&&(t=-e.detail/3);if(t)switch(this.options.mousewheel){case"zoom":this.onMouseWheelZoom(e,t);break;case"move":this.onMouseWheelMove(e,t);break;default:}links.Timeline.preventDefault(e)};links.Timeline.prototype.onMouseWheelZoom=function(e,t){if(!this.options.zoomable)return;var n=this,r=function(){n.recalcSize();var r=t/5,i=links.Timeline.getAbsoluteLeft(n.dom.content),s=e.clientX!=undefined&&i!=undefined?n.screenToTime(e.clientX-i):undefined;n.zoom(r,s);n.trigger("rangechange");n.trigger("rangechanged")};r()};links.Timeline.prototype.onMouseWheelMove=function(e,t){if(!this.options.moveable)return;var n=this.eventParams;if(n.scrolled===undefined||!n.scrolled){n.start=new Date(this.start);n.end=new Date(this.end);n.scrolled=!0;n.wheelScrolledX=0;n.previousLeft=0;n.previousOffset=0;n.dif}n.wheelScrolledX+=Math.round(t*11);this.moveFrame(n.wheelScrolledX);this.eventParams.wheelEnderTimer!==undefined&&clearTimeout(this.eventParams.wheelEnderTimer);var r=this;this.eventParams.wheelEnderTimer=setTimeout(function(){n.scrolled=!1;r.endMoveFrame()},100)};links.Timeline.prototype.zoom=function(e,t){t==undefined&&(t=new Date((this.start.valueOf()+this.end.valueOf())/2));e>=1&&(e=.9);e<=-1&&(e=-0.9);e<0&&(e/=1+e);var n=parseFloat(this.start.valueOf()-t.valueOf()),r=parseFloat(this.end.valueOf()-t.valueOf()),i=new Date(this.start.valueOf()-n*e),s=new Date(this.end.valueOf()-r*e);this.applyRange(i,s,t);this.recalcSize();var o=this.options.animate?this.options.animateZoom:!1;this.repositionItems();this.stackEvents(o);(!o||this.groups.length>0)&&this.redrawFrame()};links.Timeline.prototype.move=function(e){var t=parseFloat(this.end.valueOf()-this.start.valueOf()),n=new Date(this.start.valueOf()+t*e),r=new Date(this.end.valueOf()+t*e);this.applyRange(n,r);this.recalcConversion();this.repositionItems();this.stackEvents(this.options.animate);this.options.animate||this.redrawFrame()};links.Timeline.prototype.repositionItem=function(e,t,n){var r=e.dom;switch(e.type){case"range":r.style.left=t+"px";r.style.width=Math.max(n-t,1)+"px";break;case"box":r.style.left=t-e.width/2+"px";r.line.style.left=t-e.lineWidth/2+"px";r.dot.style.left=t-e.dotWidth/2+"px";break;case"dot":r.style.left=t-e.dotWidth/2+"px"}this.groups.length>0&&(r.style.top=e.top+"px")};links.Timeline.prototype.applyRange=function(e,t,n){var r=e.valueOf(),i=t.valueOf(),s=i-r,o=this.options,u=31536e6,a=Number(o.intervalMin)||10;a<10&&(a=10);var f=Number(o.intervalMax)||1e4*u;f>1e4*u&&(f=1e4*u);f<a&&(f=a);var l=o.min?o.min.valueOf():undefined,c=o.max?o.max.valueOf():undefined;if(l&&c){if(l>=c){var h=864e5;c=l+h}f>c-l&&(f=c-l);a>c-l&&(a=c-l)}r>=i&&(i+=864e5);if(s<a){var p=a-s,d=n?(n.valueOf()-r)/s:.5;r-=Math.round(p*d);i+=Math.round(p*(1-d))}if(s>f){var p=s-f,d=n?(n.valueOf()-r)/s:.5;r+=Math.round(p*d);i-=Math.round(p*(1-d))}if(l){var p=r-l;if(p<0){r-=p;i-=p}}if(c){var p=c-i;if(p<0){r+=p;i+=p}}this.start=new Date(r);this.end=new Date(i)};links.Timeline.prototype.confirmDeleteItem=function(e){this.applyDelete=!0;this.isSelected(e)||this.selectItem(e);this.trigger("delete");this.applyDelete&&this.deleteItem(e);delete this.applyDelete};links.Timeline.prototype.deleteItem=function(e){if(e>=this.items.length)throw"Cannot delete row, index out of range";this.unselectItem();this.items.splice(e,1);if(this.data)if(google&&google.visualization&&this.data instanceof google.visualization.DataTable)this.data.removeRow(e);else{if(!links.Timeline.isArray(this.data))throw"Cannot delete row from data, unknown data type";this.data.splice(e,1)}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();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))throw"Cannot delete row from data, unknown data type";this.data.splice(0,this.data.length)}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(this.options.animate);this.options.animate||this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.getGroupFromHeight=function(e){var t=this.groups,n=this.options,r=this.size,i=e-(n.axisOnTop?r.axis.height:0);if(t){var s;for(var o=t.length-1;o>=0;o--){s=t[o];if(i>s.top)return s}return s}return undefined};links.Timeline.prototype.getItem=function(e){if(e>=this.items.length)throw"Cannot get item, index out of range";var t=this.items[e],n={};n.start=new Date(t.start);t.end&&(n.end=new Date(t.end));n.content=t.content;t.group&&(n.group=t.group.content);return n};links.Timeline.prototype.addItem=function(e){var t=[e];this.addItems(t)};links.Timeline.prototype.addItems=function(e){var t=e,n=this.items;for(var r=0,i=t.length;r<i;r++){var s=e[r];this.addGroup(s.group);n.push(this.createItem(s));var o=n.length-1;this.updateData(o,s)}this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.createItem=function(e){var t={start:e.start,end:e.end,content:e.content,type:e.end?"range":this.options.style,group:this.findGroup(e.group),top:0,left:0,width:0,height:0,lineWidth:0,dotWidth:0,dotHeight:0};return t};links.Timeline.prototype.changeItem=function(e,t){if(e>=this.items.length)throw"Cannot change item, index out of range";var n=this.options.style,r=this.items[e];t.start&&(r.start=t.start);t.end&&(r.end=t.end);t.content&&(r.content=t.content);t.group&&(r.group=this.addGroup(t.group));this.updateData(e,t);this.size.dataChanged=!0;this.redrawFrame();this.recalcSize();this.repositionItems();this.stackEvents(!1);this.redrawFrame();this.size.dataChanged=!1};links.Timeline.prototype.findGroup=function(e){var t=this.groupIndexes[e];return t!=undefined?this.groups[t]:undefined};links.Timeline.prototype.deleteGroups=function(){this.groups=[];this.groupIndexes={}};links.Timeline.prototype.addGroup=function(e){var t=this.groups,n=this.groupIndexes,r=undefined,i=n[e];if(i===undefined&&e!==undefined){r={content:e,labelTop:0,lineTop:0};t.push(r);t=t.sort(function(e,t){return e.content>t.content?1:e.content<t.content?-1:0});for(var s=0,o=t.length;s<o;s++)n[t[s].content]=s}else r=t[i];return r};links.Timeline.prototype.cancelChange=function(){this.applyChange=!1};links.Timeline.prototype.cancelDelete=function(){this.applyDelete=!1};links.Timeline.prototype.cancelAdd=function(){this.applyAdd=!1};links.Timeline.prototype.setSelection=function(e){if(e!=undefined&&e.length>0){if(e[0].row!=undefined){var t=e[0].row;if(this.items[t]){var n=this.items[t];this.selectItem(t);var r=n.start,i=n.end,s;i!=undefined?s=new Date((i.valueOf()+r.valueOf())/2):s=new Date(r);var o=this.end.valueOf()-this.start.valueOf(),u=new Date(s.valueOf()-o/2),a=new Date(s.valueOf()+o/2);this.setVisibleChartRange(u,a);return!0}}}else this.unselectItem();return!1};links.Timeline.prototype.getSelection=function(){var e=[];this.selection&&e.push({row:this.selection.index});return e};links.Timeline.prototype.selectItem=function(e){this.unselectItem();this.selection=undefined;if(this.items[e]!==undefined){var t=this.items[e],n=t.dom;this.selection={index:e,item:n};this.options.editable&&(n.style.cursor="move");switch(t.type){case"range":n.className="timeline-event timeline-event-selected timeline-event-range";break;case"box":n.className="timeline-event timeline-event-selected timeline-event-box";n.line.className="timeline-event timeline-event-selected timeline-event-line";n.dot.className="timeline-event timeline-event-selected timeline-event-dot";break;case"dot":n.className="timeline-event timeline-event-selected";n.dot.className="timeline-event timeline-event-selected timeline-event-dot"}}};links.Timeline.prototype.isSelected=function(e){return this.selection&&this.selection.index===e};links.Timeline.prototype.unselectItem=function(){if(this.selection){var e=this.items[this.selection.index];if(e&&e.dom){var t=e.dom;t.style.cursor="";switch(e.type){case"range":t.className="timeline-event timeline-event-range";break;case"box":t.className="timeline-event timeline-event-box";t.line.className="timeline-event timeline-event-line";t.dot.className="timeline-event timeline-event-dot";break;case"dot":t.className="";t.dot.className="timeline-event timeline-event-dot"}}}this.selection=undefined};links.Timeline.prototype.repositionItems=function(){var e=this.size,t=e.contentWidth,n,r,i=[];for(var s=0,o=this.items.length;s<o;s++){n=this.items[s];r=n.dom;switch(n.type){case"range":n.left=this.timeToScreen(n.start);n.right=this.timeToScreen(n.end);n.left<-t&&(n.left=-t);n.right>2*t&&(n.right=2*t);var u=n.right>-t&&n.left<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display=""}}else if(!n.hidden){r.style.display="none";n.hidden=!0}break;case"box":n.left=this.timeToScreen(n.start);var u=n.left+n.width/2>-t&&n.left-n.width/2<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display="";r.line.style.display="";r.dot.style.display=""}}else if(!n.hidden){r.style.display="none";r.line.style.display="none";r.dot.style.display="none";n.hidden=!0}break;case"dot":n.left=this.timeToScreen(n.start);var u=n.left+n.width>-t&&n.left<2*t;if(u||e.dataChanged){if(n.hidden){n.hidden=!1;r.style.display=""}}else if(!n.hidden){r.style.display="none";n.hidden=!0}break;default:}n.hidden||i.push(n);this.items[s]=n}this.visibleItems.length!=i.length?this.visibleItemsChanged=!0:this.visibleItemsChanged=!1;this.visibleItems=i;this.itemsSizeChanged=!1};links.Timeline.prototype.stackEvents=function(e){this.trigger("on-before-stack-events");this.itemsSizeChanged&&this.recalcSizeItems();if(this.groups.length>0)return;e==undefined&&(e=!1);var t=this.stackOrder(this.items),n=this.stackCalculateFinal(t,e);if(e){var r=this.animation;if(!r){r={};this.animation=r}r.finalItems=n;var i=this,s=function(){var e=i.stackMoveOneStep(t,r.finalItems);i.recalcSize();i.repositionItems();i.redrawFrame();if(!e)r.timer=setTimeout(s,30);else{delete r.finalItems;delete r.timer}};r.timer||(r.timer=setTimeout(s,30))}else{this.stackMoveToFinal(t,n);this.recalcSize()}};links.Timeline.prototype.stackOrder=function(e){var t=e.concat([]),n=function(e,t){return e.type=="range"&&t.type!="range"?-1:e.type!="range"&&t.type=="range"?1:e.left-t.left};t.sort(n);return t};links.Timeline.prototype.stackCalculateFinal=function(e){var t=this.size,n=t.axis.top,r=this.options,i=r.axisOnTop,s=r.eventMargin,o=r.eventMarginAxis,u=[];for(var a=0,f=e.length;a<f;a++){var l=e[a],c,h,p,d,v=l.height,m=l.width;i?c=n+o+s/2:c=n-v-o-s/2;d=c+v;switch(l.type){case"range":case"dot":h=this.timeToScreen(l.start);p=l.end?this.timeToScreen(l.end):h+m;break;case"box":h=this.timeToScreen(l.start)-m/2;p=h+m}u[a]={left:h,top:c,right:p,bottom:d,height:v,item:l}}if(this.options.stackEvents)for(var a=0,f=u.length;a<f;a++){var g=u[a],y=null;do{y=this.stackEventsCheckOverlap(u,a,0,a-1);if(y!=null){i?g.top=y.top+y.height+s:g.top=y.top-g.height-s;g.bottom=g.top+g.height}}while(y)}return u};links.Timeline.prototype.stackMoveOneStep=function(e,t){var n=!0;for(i=0,iMax=e.length;i<iMax;i++){var r=t[i],s=r.item,o=parseInt(s.top),u=parseInt(r.top),a=u-o;if(a){var f=u==o?0:u>o?1:-1;Math.abs(a)>4&&(f=a/4);var l=parseInt(o+f);l!=u&&(n=!1);s.top=l;s.bottom=s.top+s.height}else{s.top=r.top;s.bottom=r.bottom}s.left=r.left;s.right=r.right}return n};links.Timeline.prototype.stackMoveToFinal=function(e,t){for(i=0,iMax=e.length;i<iMax;i++){var n=e[i],r=t[i];n.left=r.left;n.top=r.top;n.right=r.right;n.bottom=r.bottom}};links.Timeline.prototype.stackEventsCheckOverlap=function(e,t,n,r){var i=this.options.eventMargin,s=this.collision,o=e[t];for(var u=r;u>=n;u--){var a=e[u];if(s(o,a,i)&&u!=t)return a}return undefined};links.Timeline.prototype.collision=function(e,t,n){n==undefined&&(n=0);return e.left-n<t.right&&e.right+n>t.left&&e.top-n<t.bottom&&e.bottom+n>t.top};links.Timeline.prototype.trigger=function(e){var t=null;switch(e){case"rangechange":case"rangechanged":t={start:new Date(this.start),end:new Date(this.end)};break;case"timechange":case"timechanged":t={time:new Date(this.customTime)}}links.events.trigger(this,e,t);google&&google.visualization&&google.visualization.events.trigger(this,e,t)};links.events=links.events||{listeners:[],indexOf:function(e){var t=this.listeners;for(var n=0,r=this.listeners.length;n<r;n++){var i=t[n];if(i&&i.object==e)return n}return-1},addListener:function(e,t,n){var r=this.indexOf(e),i=this.listeners[r];if(!i){i={object:e,events:{}};this.listeners.push(i)}var s=i.events[t];if(!s){s=[];i.events[t]=s}s.indexOf(n)==-1&&s.push(n)},removeListener:function(e,t,n){var r=this.indexOf(e),i=this.listeners[r];if(i){var s=i.events[t];if(s){var r=s.indexOf(n);r!=-1&&s.splice(r,1);s.length==0&&delete i.events[t]}var o=0,u=i.events;for(var a in u)u.hasOwnProperty(a)&&o++;o==0&&delete this.listeners[r]}},removeAllListeners:function(){this.listeners=[]},trigger:function(e,t,n){var r=this.indexOf(e),i=this.listeners[r];if(i){var s=i.events[t];if(s)for(var o=0,u=s.length;o<u;o++)s[o](n)}}};links.Timeline.StepDate=function(e,t,n){this.current=new Date;this._start=new Date;this._end=new Date;this.autoScale=!0;this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1;this.setRange(e,t,n)};links.Timeline.StepDate.SCALE={MILLISECOND:1,SECOND:2,MINUTE:3,HOUR:4,DAY:5,MONTH:6,YEAR:7};links.Timeline.StepDate.prototype.setRange=function(e,t,n){if(isNaN(e)||isNaN(t))return;this._start=e!=undefined?new Date(e):new Date;this._end=t!=undefined?new Date(t):new Date;this.autoScale&&this.setMinimumStep(n)};links.Timeline.StepDate.prototype.start=function(){this.current=new Date(this._start);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: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.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:}};links.Timeline.StepDate.prototype.end=function(){return this.current.getTime()>this._end.getTime()};links.Timeline.StepDate.prototype.next=function(){var e=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*1e3*60);break;case links.Timeline.StepDate.SCALE.HOUR:this.current=new Date(this.current.getTime()+this.step*1e3*60*60);var t=this.current.getHours();this.current.setHours(t-t%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);break;default:}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);break;default:}if(this.step!=1)switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:this.current.getMilliseconds()<this.step&&this.current.setMilliseconds(0);break;case links.Timeline.StepDate.SCALE.SECOND:this.current.getSeconds()<this.step&&this.current.setSeconds(0);break;case links.Timeline.StepDate.SCALE.MINUTE:this.current.getMinutes()<this.step&&this.current.setMinutes(0);break;case links.Timeline.StepDate.SCALE.HOUR:this.current.getHours()<this.step&&this.current.setHours(0);break;case links.Timeline.StepDate.SCALE.DAY:this.current.getDate()<this.step+1&&this.current.setDate(1);break;case links.Timeline.StepDate.SCALE.MONTH:this.current.getMonth()<this.step&&this.current.setMonth(0);break;case links.Timeline.StepDate.SCALE.YEAR:break;default:}this.current.getTime()==e&&(this.current=new Date(this._end))};links.Timeline.StepDate.prototype.getCurrent=function(){return this.current};links.Timeline.StepDate.prototype.setScale=function(e,t){this.scale=e;t>0&&(this.step=t);this.autoScale=!1};links.Timeline.StepDate.prototype.setAutoScale=function(e){this.autoScale=e};links.Timeline.StepDate.prototype.setMinimumStep=function(e){if(e==undefined)return;var t=31104e6,n=2592e6,r=864e5,i=36e5,s=6e4,o=1e3,u=1;if(t*1e3>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1e3}if(t*500>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=500}if(t*100>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=100}if(t*50>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=50}if(t*10>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=10}if(t*5>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=5}if(t>e){this.scale=links.Timeline.StepDate.SCALE.YEAR;this.step=1}if(n*3>e){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=3}if(n>e){this.scale=links.Timeline.StepDate.SCALE.MONTH;this.step=1}if(r*5>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=5}if(r*2>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=2}if(r>e){this.scale=links.Timeline.StepDate.SCALE.DAY;this.step=1}if(i*4>e){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=4}if(i>e){this.scale=links.Timeline.StepDate.SCALE.HOUR;this.step=1}if(s*15>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=15}if(s*10>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=10}if(s*5>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=5}if(s>e){this.scale=links.Timeline.StepDate.SCALE.MINUTE;this.step=1}if(o*15>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=15}if(o*10>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=10}if(o*5>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=5}if(o>e){this.scale=links.Timeline.StepDate.SCALE.SECOND;this.step=1}if(u*200>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=200}if(u*100>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=100}if(u*50>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=50}if(u*10>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=10}if(u*5>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=5}if(u>e){this.scale=links.Timeline.StepDate.SCALE.MILLISECOND;this.step=1}};links.Timeline.StepDate.prototype.snap=function(e){if(this.scale==links.Timeline.StepDate.SCALE.YEAR){var t=e.getFullYear()+Math.round(e.getMonth()/12);e.setFullYear(Math.round(t/this.step)*this.step);e.setMonth(0);e.setDate(0);e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.MONTH){if(e.getDate()>15){e.setDate(1);e.setMonth(e.getMonth()+1)}else e.setDate(1);e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.DAY){switch(this.step){case 5:case 2:e.setHours(Math.round(e.getHours()/24)*24);break;default:e.setHours(Math.round(e.getHours()/12)*12)}e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.HOUR){switch(this.step){case 4:e.setMinutes(Math.round(e.getMinutes()/60)*60);break;default:e.setMinutes(Math.round(e.getMinutes()/30)*30)}e.setSeconds(0);e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.MINUTE){switch(this.step){case 15:case 10:e.setMinutes(Math.round(e.getMinutes()/5)*5);e.setSeconds(0);break;case 5:e.setSeconds(Math.round(e.getSeconds()/60)*60);break;default:e.setSeconds(Math.round(e.getSeconds()/30)*30)}e.setMilliseconds(0)}else if(this.scale==links.Timeline.StepDate.SCALE.SECOND)switch(this.step){case 15:case 10:e.setSeconds(Math.round(e.getSeconds()/5)*5);e.setMilliseconds(0);break;case 5:e.setMilliseconds(Math.round(e.getMilliseconds()/1e3)*1e3);break;default:e.setMilliseconds(Math.round(e.getMilliseconds()/500)*500)}else if(this.scale==links.Timeline.StepDate.SCALE.MILLISECOND){var n=this.step>5?this.step/2:1;e.setMilliseconds(Math.round(e.getMilliseconds()/n)*n)}};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(e,t){switch(t){case"fr":var n=new Array("Jan","Fev","Mar","Avr","Mai","Juin","Juil","Aout","Sep","Oct","Nov","Dec");break;case"en":default:var n=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")}e==undefined&&(e=this.current);switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return String(e.getMilliseconds());case links.Timeline.StepDate.SCALE.SECOND:return String(e.getSeconds());case links.Timeline.StepDate.SCALE.MINUTE:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.HOUR:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.DAY:return String(e.getDate());case links.Timeline.StepDate.SCALE.MONTH:return n[e.getMonth(
)];case links.Timeline.StepDate.SCALE.YEAR:return String(e.getFullYear());default:return""}};links.Timeline.StepDate.prototype.getLabelMajor=function(e,t){switch(t){case"fr":var n=new Array("Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"),r=new Array("Dimanche","Lundi","Mardi","mercredi","Jeudi","Vendredi","Samedi");break;case"en":default:var n=new Array("January","February","March","April","May","June","July","August","September","October","November","December"),r=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")}e==undefined&&(e=this.current);switch(this.scale){case links.Timeline.StepDate.SCALE.MILLISECOND:return this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2)+":"+this.addZeros(e.getSeconds(),2);case links.Timeline.StepDate.SCALE.SECOND:return e.getDate()+" "+n[e.getMonth()]+" "+this.addZeros(e.getHours(),2)+":"+this.addZeros(e.getMinutes(),2);case links.Timeline.StepDate.SCALE.MINUTE:return r[e.getDay()]+" "+e.getDate()+" "+n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.HOUR:return r[e.getDay()]+" "+e.getDate()+" "+n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.DAY:return n[e.getMonth()]+" "+e.getFullYear();case links.Timeline.StepDate.SCALE.MONTH:return String(e.getFullYear());default:return""}};links.Timeline.StepDate.prototype.addZeros=function(e,t){var n=""+e;while(n.length<t)n="0"+n;return n};links.imageloader=function(){function n(t){if(e[t]==1)return!0;var n=new Image;n.src=t;return n.complete?!0:!1}function r(e){return t[e]!=undefined}function i(i,s,o){o==undefined&&(o=!0);if(n(i)){o&&s(i);return}if(r(i)&&!o)return;var u=t[i];if(!u){var a=new Image;a.src=i;u=[];t[i]=u;a.onload=function(n){e[i]=!0;delete t[i];for(var r=0;r<u.length;r++)u[r](i)}}u.indexOf(s)==-1&&u.push(s)}var e={},t={};return{isLoaded:n,isLoading:r,load:i}}();links.Timeline.addEventListener=function(e,t,n,r){if(e.addEventListener){r===undefined&&(r=!1);t==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(t="DOMMouseScroll");e.addEventListener(t,n,r)}else e.attachEvent("on"+t,n)};links.Timeline.removeEventListener=function(e,t,n,r){if(e.removeEventListener){r===undefined&&(r=!1);t==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(t="DOMMouseScroll");e.removeEventListener(t,n,r)}else e.detachEvent("on"+t,n)};links.Timeline.getTarget=function(e){e||(e=window.event);var t;e.target?t=e.target:e.srcElement&&(t=e.srcElement);t.nodeType!==undefined&&t.nodeType==3&&(t=t.parentNode);return t};links.Timeline.stopPropagation=function(e){e||(e=window.event);e.stopPropagation?e.stopPropagation():e.cancelBubble=!0};links.Timeline.preventDefault=function(e){e||(e=window.event);e.preventDefault?e.preventDefault():e.returnValue=!1};links.Timeline.getAbsoluteLeft=function(e){var t=0;while(e!=null){t+=e.offsetLeft;t-=e.scrollLeft;e=e.offsetParent}!document.body.scrollLeft&&window.pageXOffset&&(t-=window.pageXOffset);return t};links.Timeline.getAbsoluteTop=function(e){var t=0;while(e!=null){t+=e.offsetTop;t-=e.scrollTop;e=e.offsetParent}!document.body.scrollTop&&window.pageYOffset&&(t-=window.pageYOffset);return t};links.Timeline.isArray=function(e){return e instanceof Array?!0:Object.prototype.toString.call(e)==="[object Array]"};