/*

 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) 2010-2012 Almende B.V.

 @author  Jos de Jong, jos@almende.org
 @date    2012-10-24
 @version 1.2
*/
typeof links==="undefined"&&(links={});
links.Graph3d=function(a){this.containerElement=a;this.height=this.width="400px";this.margin=10;this.defaultXCenter="55%";this.defaultYCenter="50%";this.style=links.Graph3d.STYLE.DOT;this.keepAspectRatio=this.showGrid=this.showPerspective=!0;this.showGrayBottom=this.showShadow=!1;this.verticalRatio=0.5;this.animationInterval=1E3;this.animationAutoPlay=this.animationPreload=!1;this.camera=new links.Graph3d.Camera;this.eye=new links.Point3d(0,0,-1);this.dataPoints=this.dataTable=null;this.colFilter=
this.colValue=this.colZ=this.colY=this.colX=void 0;this.xMin=0;this.xStep=void 0;this.xMax=1;this.yMin=0;this.yStep=void 0;this.yMax=1;this.zMin=0;this.zStep=void 0;this.zMax=1;this.valueMin=0;this.valueMax=1;this.colorAxis="#4D4D4D";this.colorGrid="#D3D3D3";this.colorDot="#7DC1FF";this.colorDotBorder="#3267D2";this.create()};
links.Graph3d.Camera=function(){this.armLocation=new links.Point3d;this.armRotation={};this.armRotation.horizontal=0;this.armRotation.vertical=0;this.armLength=1.7;this.cameraLocation=new links.Point3d;this.cameraRotation=new links.Point3d(Math.PI/2,0,0);this.calculateCameraOrientation()};links.Graph3d.Camera.prototype.setArmLocation=function(a,b,c){this.armLocation.x=a;this.armLocation.y=b;this.armLocation.z=c;this.calculateCameraOrientation()};
links.Graph3d.Camera.prototype.setArmRotation=function(a,b){if(a!==void 0)this.armRotation.horizontal=a;if(b!==void 0){this.armRotation.vertical=b;if(this.armRotation.vertical<0)this.armRotation.vertical=0;if(this.armRotation.vertical>0.5*Math.PI)this.armRotation.vertical=0.5*Math.PI}(a!==void 0||b!==void 0)&&this.calculateCameraOrientation()};links.Graph3d.Camera.prototype.getArmRotation=function(){var a={};a.horizontal=this.armRotation.horizontal;a.vertical=this.armRotation.vertical;return a};
links.Graph3d.Camera.prototype.setArmLength=function(a){if(a!==void 0){this.armLength=a;if(this.armLength<0.71)this.armLength=0.71;if(this.armLength>5)this.armLength=5;this.calculateCameraOrientation()}};links.Graph3d.Camera.prototype.getArmLength=function(){return this.armLength};links.Graph3d.Camera.prototype.getCameraLocation=function(){return this.cameraLocation};links.Graph3d.Camera.prototype.getCameraRotation=function(){return this.cameraRotation};
links.Graph3d.Camera.prototype.calculateCameraOrientation=function(){this.cameraLocation.x=this.armLocation.x-this.armLength*Math.sin(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical);this.cameraLocation.y=this.armLocation.y-this.armLength*Math.cos(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical);this.cameraLocation.z=this.armLocation.z+this.armLength*Math.sin(this.armRotation.vertical);this.cameraRotation.x=Math.PI/2-this.armRotation.vertical;this.cameraRotation.y=
0;this.cameraRotation.z=-this.armRotation.horizontal};
links.Graph3d.prototype._setScale=function(){this.scale=new links.Point3d(1/(this.xMax-this.xMin),1/(this.yMax-this.yMin),1/(this.zMax-this.zMin));if(this.keepAspectRatio)this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;this.scale.z*=this.verticalRatio;this.scale.value=1/(this.valueMax-this.valueMin);this.camera.setArmLocation((this.xMax+this.xMin)/2*this.scale.x,(this.yMax+this.yMin)/2*this.scale.y,(this.zMax+this.zMin)/2*this.scale.z)};
links.Graph3d.prototype._convert3Dto2D=function(a){return this._convertTranslationToScreen(this._convertPointToTranslation(a))};
links.Graph3d.prototype._convertPointToTranslation=function(a){var b=a.x*this.scale.x,c=a.y*this.scale.y,a=a.z*this.scale.z,e=this.camera.getCameraLocation().x,f=this.camera.getCameraLocation().y,d=this.camera.getCameraLocation().z,g=Math.sin(this.camera.getCameraRotation().x),h=Math.cos(this.camera.getCameraRotation().x),i=Math.sin(this.camera.getCameraRotation().y),j=Math.cos(this.camera.getCameraRotation().y),k=Math.sin(this.camera.getCameraRotation().z),l=Math.cos(this.camera.getCameraRotation().z);
return new links.Point3d(j*(k*(c-f)+l*(b-e))-i*(a-d),g*(j*(a-d)+i*(k*(c-f)+l*(b-e)))+h*(l*(c-f)-k*(b-e)),h*(j*(a-d)+i*(k*(c-f)+l*(b-e)))-g*(l*(c-f)-k*(b-e)))};links.Graph3d.prototype._convertTranslationToScreen=function(a){var b=this.eye.x,c=this.eye.y,e=this.eye.z,f=a.x,d=a.y,a=a.z;this.showPerspective?(b=(f-b)*(e/a),c=(d-c)*(e/a)):(b=f*-(e/this.camera.getArmLength()),c=d*-(e/this.camera.getArmLength()));return new links.Point2d(this.xcenter+b*this.frame.canvas.clientWidth,this.ycenter-c*this.frame.canvas.clientWidth)};
links.Graph3d.prototype.draw=function(a,b){var c=void 0;if(b!==void 0){if(b.width!==void 0)this.width=b.width;if(b.height!==void 0)this.height=b.height;if(b.xCenter!==void 0)this.defaultXCenter=b.xCenter;if(b.yCenter!==void 0)this.defaultYCenter=b.yCenter;if(b.style!==void 0){var e=this._getStyleNumber(b.style);if(e!==-1)this.style=e}if(b.showGrid!==void 0)this.showGrid=b.showGrid;if(b.showPerspective!==void 0)this.showPerspective=b.showPerspective;if(b.showShadow!==void 0)this.showShadow=b.showShadow;
if(b.showAnimationControls!==void 0)this.showAnimationControls=b.showAnimationControls;if(b.keepAspectRatio!==void 0)this.keepAspectRatio=b.keepAspectRatio;if(b.verticalRatio!==void 0)this.verticalRatio=b.verticalRatio;if(b.animationInterval!==void 0)this.animationInterval=b.animationInterval;if(b.animationPreload!==void 0)this.animationPreload=b.animationPreload;if(b.animationAutoStart!==void 0)this.animationAutoStart=b.animationAutoStart;if(b.xMin!==void 0)this.defaultXMin=b.xMin;if(b.xStep!==void 0)this.defaultXStep=
b.xStep;if(b.xMax!==void 0)this.defaultXMax=b.xMax;if(b.yMin!==void 0)this.defaultYMin=b.yMin;if(b.yStep!==void 0)this.defaultYStep=b.yStep;if(b.yMax!==void 0)this.defaultYMax=b.yMax;if(b.zMin!==void 0)this.defaultZMin=b.zMin;if(b.zStep!==void 0)this.defaultZStep=b.zStep;if(b.zMax!==void 0)this.defaultZMax=b.zMax;if(b.valueMin!==void 0)this.defaultValueMin=b.valueMin;if(b.valueMax!==void 0)this.defaultValueMax=b.valueMax;if(b.cameraPosition!==void 0)c=b.cameraPosition}this._setBackgroundColor(b.backgroundColor);
this.setSize(this.width,this.height);c!==void 0?(this.camera.setArmRotation(c.horizontal,c.vertical),this.camera.setArmLength(c.distance)):(this.camera.setArmRotation(1,0.5),this.camera.setArmLength(1.7));this.redraw(a);this.animationAutoStart&&this.dataFilter&&this.animationStart();google.visualization.events.trigger(this,"ready",null)};
links.Graph3d.prototype._setBackgroundColor=function(a){var b="white",c="gray",e=1;if(typeof a==="string")b=a,c="none",e=0;else if(typeof a==="object"){if(a.fill!==void 0)b=a.fill;if(a.stroke!==void 0)c=a.stroke;if(a.strokeWidth!==void 0)e=a.strokeWidth}else if(a!==void 0)throw"Unsupported type of backgroundColor";this.frame.style.backgroundColor=b;this.frame.style.borderColor=c;this.frame.style.borderWidth=e+"px";this.frame.style.borderStyle="solid"};
links.Graph3d.STYLE={DOT:0,DOTLINE:1,DOTCOLOR:2,DOTSIZE:3,LINE:4,GRID:5,SURFACE:6};links.Graph3d.prototype._getStyleNumber=function(a){switch(a){case "dot":return links.Graph3d.STYLE.DOT;case "dot-line":return links.Graph3d.STYLE.DOTLINE;case "dot-color":return links.Graph3d.STYLE.DOTCOLOR;case "dot-size":return links.Graph3d.STYLE.DOTSIZE;case "line":return links.Graph3d.STYLE.LINE;case "grid":return links.Graph3d.STYLE.GRID;case "surface":return links.Graph3d.STYLE.SURFACE}return-1};
links.Graph3d.prototype._getStyleName=function(a){switch(a){case links.Graph3d.STYLE.DOT:return"dot";case links.Graph3d.STYLE.DOTLINE:return"dot-line";case links.Graph3d.STYLE.DOTCOLOR:return"dot-color";case links.Graph3d.STYLE.DOTSIZE:return"dot-size";case links.Graph3d.STYLE.LINE:return"line";case links.Graph3d.STYLE.GRID:return"grid";case links.Graph3d.STYLE.SURFACE:return"surface"}return""};
links.Graph3d.prototype._determineColumnIndexes=function(a){if(this.style===links.Graph3d.STYLE.DOT||this.style===links.Graph3d.STYLE.DOTLINE||this.style===links.Graph3d.STYLE.LINE||this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE){if(this.colX=0,this.colY=1,this.colZ=2,this.colValue=void 0,a.getNumberOfColumns()>3)this.colFilter=3}else if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE){if(this.colX=0,this.colY=1,this.colZ=2,this.colValue=
3,a.getNumberOfColumns()>4)this.colFilter=4}else throw"Unknown style '"+this.style+"'";};
links.Graph3d.prototype._dataInitialize=function(a,b){if(!(a===void 0||a.getNumberOfRows===void 0)){this._determineColumnIndexes(a,b);this.dataTable=a;this.dataFilter=void 0;if(this.colFilter&&a.getNumberOfColumns()>=this.colFilter&&this.dataFilter===void 0){this.dataFilter=new links.Filter(a,this.colFilter,this);var c=this;this.dataFilter.setOnLoadCallback(function(){c.redraw()})}var e=a.getColumnRange(this.colX);this.xMin=this.defaultXMin!==void 0?this.defaultXMin:e.min;this.xMax=this.defaultXMax!==
void 0?this.defaultXMax:e.max;if(this.xMax<=this.xMin)this.xMax=this.xMin+1;this.xStep=this.defaultXStep!==void 0?this.defaultXStep:(this.xMax-this.xMin)/5;e=a.getColumnRange(this.colY);this.yMin=this.defaultYMin!==void 0?this.defaultYMin:e.min;this.yMax=this.defaultYMax!==void 0?this.defaultYMax:e.max;if(this.yMax<=this.yMin)this.yMax=this.yMin+1;this.yStep=this.defaultYStep!==void 0?this.defaultYStep:(this.yMax-this.yMin)/5;e=a.getColumnRange(this.colZ);this.zMin=this.defaultZMin!==void 0?this.defaultZMin:
e.min;this.zMax=this.defaultZMax!==void 0?this.defaultZMax:e.max;if(this.zMax<=this.zMin)this.zMax=this.zMin+1;this.zStep=this.defaultZStep!==void 0?this.defaultZStep:(this.zMax-this.zMin)/5;if(this.colValue!==void 0&&(e=a.getColumnRange(this.colValue),this.valueMin=this.defaultValueMin!==void 0?this.defaultValueMin:e.min,this.valueMax=this.defaultValueMax!==void 0?this.defaultValueMax:e.max,this.valueMax<=this.valueMin))this.valueMax=this.valueMin+1;this._setScale()}};
links.Graph3d.prototype._getDataPoints=function(a){var b=[];if(this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE){for(var c=[],e=[],f=0;f<a.getNumberOfRows();f++){var d=a.getValue(f,this.colX)||0,g=a.getValue(f,this.colY)||0;c.indexOf(d)===-1&&c.push(d);e.indexOf(g)===-1&&e.push(g)}f=function(a,b){return a-b};c.sort(f);e.sort(f);for(var h=[],f=0;f<a.getNumberOfRows();f++){var d=a.getValue(f,this.colX)||0,g=a.getValue(f,this.colY)||0,i=a.getValue(f,this.colZ)||0,j=c.indexOf(d),
k=e.indexOf(g);h[j]===void 0&&(h[j]=[]);var l=new links.Point3d;l.x=d;l.y=g;l.z=i;d={};d.point=l;d.trans=void 0;d.screen=void 0;h[j][k]=d;b.push(d)}for(d=0;d<h.length;d++)for(g=0;g<h[d].length;g++)if(h[d][g])h[d][g].pointRight=d<h.length-1?h[d+1][g]:void 0,h[d][g].pointTop=g<h[d].length-1?h[d][g+1]:void 0,h[d][g].pointCross=d<h.length-1&&g<h[d].length-1?h[d+1][g+1]:void 0}else for(f=0;f<a.getNumberOfRows();f++){c=new links.Point3d;c.x=a.getValue(f,this.colX)||0;c.y=a.getValue(f,this.colY)||0;c.z=
a.getValue(f,this.colZ)||0;if(this.colValue!==void 0)c.value=a.getValue(f,this.colValue)||0;d={};d.point=c;d.trans=void 0;d.screen=void 0;b.push(d)}for(f=0;f<b.length;f++)c=b[f].point,b[f].bottom=new links.Point3d(c.x,c.y,0);return b};links.Graph3d.px=function(a){return a+"px"};
links.Graph3d.prototype.create=function(){for(;this.containerElement.hasChildNodes();)this.containerElement.removeChild(this.containerElement.firstChild);this.frame=document.createElement("div");this.frame.style.position="relative";this.frame.canvas=document.createElement("canvas");this.frame.canvas.style.position="relative";this.frame.appendChild(this.frame.canvas);var a=document.createElement("DIV");a.style.color="red";a.style.fontWeight="bold";a.style.padding="10px";a.innerHTML="Error: your browser does not support HTML canvas";
this.frame.canvas.appendChild(a);this.frame.filter=document.createElement("div");this.frame.filter.style.position="absolute";this.frame.filter.style.bottom="0px";this.frame.filter.style.left="0px";this.frame.filter.style.width="100%";this.frame.appendChild(this.frame.filter);var b=this;links.addEventListener(this.frame.canvas,"keydown",function(a){b._onKeyDown(a)});links.addEventListener(this.frame.canvas,"mousedown",function(a){b._onMouseDown(a)});links.addEventListener(this.frame.canvas,"touchstart",
function(a){b._onTouchStart(a)});links.addEventListener(this.frame.canvas,"mousewheel",function(a){b._onWheel(a)});this.containerElement.appendChild(this.frame)};links.Graph3d.prototype.setSize=function(a,b){this.frame.style.width=a;this.frame.style.height=b;this._resizeCanvas()};
links.Graph3d.prototype._resizeCanvas=function(){this.frame.canvas.style.width="100%";this.frame.canvas.style.height="100%";this.frame.canvas.width=this.frame.canvas.clientWidth;this.frame.canvas.height=this.frame.canvas.clientHeight;this.frame.filter.style.width=this.frame.canvas.clientWidth-20+"px"};links.Graph3d.prototype.animationStart=function(){if(!this.frame.filter||!this.frame.filter.slider)throw"No animation available";this.frame.filter.slider.play()};
links.Graph3d.prototype.animationStop=function(){if(!this.frame.filter||!this.frame.filter.slider)throw"No animation available";this.frame.filter.slider.stop()};
links.Graph3d.prototype._resizeCenter=function(){this.xcenter=this.defaultXCenter.charAt(this.defaultXCenter.length-1)==="%"?parseFloat(this.defaultXCenter)/100*this.frame.canvas.clientWidth:parseFloat(this.defaultXCenter);this.ycenter=this.defaultYCenter.charAt(this.defaultYCenter.length-1)==="%"?parseFloat(this.defaultYCenter)/100*(this.frame.canvas.clientHeight-this.frame.filter.clientHeight):parseFloat(this.defaultYCenter)};
links.Graph3d.prototype.setCameraPosition=function(a){a!==void 0&&(a.horizontal!==void 0&&a.vertical!==void 0&&this.camera.setArmRotation(a.horizontal,a.vertical),a.distance!==void 0&&this.camera.setArmLength(a.distance),this.redraw())};links.Graph3d.prototype.getCameraPosition=function(){var a=this.camera.getArmRotation();a.distance=this.camera.getArmLength();return a};
links.Graph3d.prototype._readData=function(a){this._dataInitialize(a,this.style);this.dataPoints=this.dataFilter?this.dataFilter._getDataPoints():this._getDataPoints(this.dataTable);this._redrawFilter()};
links.Graph3d.prototype.redraw=function(a){a!==void 0&&this._readData(a);if(this.dataPoints===void 0)throw"Error: graph data not initialized";this._resizeCanvas();this._resizeCenter();this._redrawSlider();this._redrawClear();this._redrawAxis();this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE?this._redrawDataGrid():this.style===links.Graph3d.STYLE.LINE?this._redrawDataLine():this._redrawDataDot();this._redrawInfo();this._redrawLegend()};
links.Graph3d.prototype._redrawClear=function(){var a=this.frame.canvas;a.getContext("2d").clearRect(0,0,a.width,a.height)};
links.Graph3d.prototype._redrawLegend=function(){if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE){var a=this.frame.clientWidth*0.02;if(this.style===links.Graph3d.STYLE.DOTSIZE)var b=a/2,c=a/2+a*2;else c=b=20;var e=Math.max(this.frame.clientHeight*0.25,100),f=this.margin,a=this.frame.clientWidth-this.margin,d=a-c,g=f+e}var h=this.frame.canvas.getContext("2d");h.lineWidth=1;h.font="14px arial";if(this.style===links.Graph3d.STYLE.DOTCOLOR){for(var i=e,j=0;j<i;j++){var k=
this._hsv2rgb((j-0)/(i-0)*240,1,1);h.strokeStyle=k;h.beginPath();h.moveTo(d,f+j);h.lineTo(a,f+j);h.stroke()}h.strokeStyle=this.colorAxis;h.strokeRect(d,f,c,e)}if(this.style===links.Graph3d.STYLE.DOTSIZE)h.strokeStyle=this.colorAxis,h.fillStyle=this.colorDot,h.beginPath(),h.moveTo(d,f),h.lineTo(a,f),h.lineTo(a-c+b,g),h.lineTo(d,g),h.closePath(),h.fill(),h.stroke();if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE){b=new links.StepNumber(this.valueMin,this.valueMax,
(this.valueMax-this.valueMin)/5,!0);b.start();for(b.getCurrent()<this.valueMin&&b.next();!b.end();)j=g-(b.getCurrent()-this.valueMin)/(this.valueMax-this.valueMin)*e,h.beginPath(),h.moveTo(d-5,j),h.lineTo(d,j),h.stroke(),h.textAlign="right",h.textBaseline="middle",h.fillStyle=this.colorAxis,h.fillText(b.getCurrent(),d-10,j),b.next();h.textAlign="right";h.textBaseline="top";b=this.dataTable.getColumnLabel(this.colValue);h.fillText(b,a,g+this.margin)}};
links.Graph3d.prototype._redrawFilter=function(){this.frame.filter.innerHTML="";if(this.dataFilter){var a=new links.Slider(this.frame.filter,{visible:this.showAnimationControls});this.frame.filter.slider=a;this.frame.filter.style.padding="10px";a.setValues(this.dataFilter.values);a.setPlayInterval(this.animationInterval);var b=this;a.setOnChangeCallback(function(){var c=a.getIndex();b.dataFilter.selectValue(c);b.dataPoints=b.dataFilter._getDataPoints();b.redraw()})}else this.frame.filter.slider=void 0};
links.Graph3d.prototype._redrawSlider=function(){this.frame.filter.slider!==void 0&&this.frame.filter.slider.redraw()};links.Graph3d.prototype._redrawInfo=function(){if(this.dataFilter){var a=this.frame.canvas.getContext("2d");a.font="14px arial";a.lineStyle="gray";a.fillStyle="gray";a.textAlign="left";a.textBaseline="top";var b=this.margin,c=this.margin;a.fillText(this.dataFilter.getLabel()+": "+this.dataFilter.getSelectedValue(),b,c)}};
links.Graph3d.prototype._redrawAxis=function(){var a=this.frame.canvas.getContext("2d");a.font=24/this.camera.getArmLength()+"px arial";var b=0.025/this.scale.x,c=0.025/this.scale.y,e=5/this.camera.getArmLength(),f=this.camera.getArmRotation().horizontal;a.lineWidth=1;var d=this.defaultXStep===void 0,g=new links.StepNumber(this.xMin,this.xMax,this.xStep,d);g.start();for(g.getCurrent()<this.xMin&&g.next();!g.end();){var h=g.getCurrent();if(this.showGrid){var i=this._convert3Dto2D(new links.Point3d(h,
this.yMin,this.zMin)),d=this._convert3Dto2D(new links.Point3d(h,this.yMax,this.zMin));a.strokeStyle=this.colorGrid}else i=this._convert3Dto2D(new links.Point3d(h,this.yMin,this.zMin)),d=this._convert3Dto2D(new links.Point3d(h,this.yMin+b,this.zMin)),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(i.x,i.y),a.lineTo(d.x,d.y),a.stroke(),i=this._convert3Dto2D(new links.Point3d(h,this.yMax,this.zMin)),d=this._convert3Dto2D(new links.Point3d(h,this.yMax-b,this.zMin)),a.strokeStyle=this.colorAxis;a.beginPath();
a.moveTo(i.x,i.y);a.lineTo(d.x,d.y);a.stroke();d=Math.cos(f)>0?this.yMin:this.yMax;d=this._convert3Dto2D(new links.Point3d(h,d,this.zMin));Math.cos(f*2)>0?(a.textAlign="center",a.textBaseline="top",d.y+=e):(a.textAlign=Math.sin(f*2)<0?"right":"left",a.textBaseline="middle");a.fillStyle=this.colorAxis;a.fillText("  "+g.getCurrent()+"  ",d.x,d.y);g.next()}a.lineWidth=1;d=this.defaultYStep===void 0;g=new links.StepNumber(this.yMin,this.yMax,this.yStep,d);g.start();for(g.getCurrent()<this.yMin&&g.next();!g.end();)this.showGrid?
(i=this._convert3Dto2D(new links.Point3d(this.xMin,g.getCurrent(),this.zMin)),d=this._convert3Dto2D(new links.Point3d(this.xMax,g.getCurrent(),this.zMin)),a.strokeStyle=this.colorGrid):(i=this._convert3Dto2D(new links.Point3d(this.xMin,g.getCurrent(),this.zMin)),d=this._convert3Dto2D(new links.Point3d(this.xMin+c,g.getCurrent(),this.zMin)),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(i.x,i.y),a.lineTo(d.x,d.y),a.stroke(),i=this._convert3Dto2D(new links.Point3d(this.xMax,g.getCurrent(),this.zMin)),
d=this._convert3Dto2D(new links.Point3d(this.xMax-c,g.getCurrent(),this.zMin)),a.strokeStyle=this.colorAxis),a.beginPath(),a.moveTo(i.x,i.y),a.lineTo(d.x,d.y),a.stroke(),b=Math.sin(f)>0?this.xMin:this.xMax,d=this._convert3Dto2D(new links.Point3d(b,g.getCurrent(),this.zMin)),Math.cos(f*2)<0?(a.textAlign="center",a.textBaseline="top",d.y+=e):(a.textAlign=Math.sin(f*2)>0?"right":"left",a.textBaseline="middle"),a.fillStyle=this.colorAxis,a.fillText("  "+g.getCurrent()+"  ",d.x,d.y),g.next();a.lineWidth=
1;d=this.defaultZStep===void 0;g=new links.StepNumber(this.zMin,this.zMax,this.zStep,d);g.start();g.getCurrent()<this.zMin&&g.next();b=Math.cos(f)>0?this.xMin:this.xMax;for(d=Math.sin(f)<0?this.yMin:this.yMax;!g.end();)i=this._convert3Dto2D(new links.Point3d(b,d,g.getCurrent())),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(i.x,i.y),a.lineTo(i.x-e,i.y),a.stroke(),a.textAlign="right",a.textBaseline="middle",a.fillStyle=this.colorAxis,a.fillText(g.getCurrent()+" ",i.x-5,i.y),g.next();a.lineWidth=
1;i=this._convert3Dto2D(new links.Point3d(b,d,this.zMin));d=this._convert3Dto2D(new links.Point3d(b,d,this.zMax));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(i.x,i.y);a.lineTo(d.x,d.y);a.stroke();a.lineWidth=1;c=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMin,this.zMin));e=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMin,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(c.x,c.y);a.lineTo(e.x,e.y);a.stroke();c=this._convert3Dto2D(new links.Point3d(this.xMin,
this.yMax,this.zMin));e=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(c.x,c.y);a.lineTo(e.x,e.y);a.stroke();a.lineWidth=1;i=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMin,this.zMin));d=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(i.x,i.y);a.lineTo(d.x,d.y);a.stroke();i=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMin,this.zMin));
d=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(i.x,i.y);a.lineTo(d.x,d.y);a.stroke();c=this.dataTable.getColumnLabel(this.colX);if(c.length>0)e=0.1/this.scale.y,b=(this.xMin+this.xMax)/2,d=Math.cos(f)>0?this.yMin-e:this.yMax+e,d=this._convert3Dto2D(new links.Point3d(b,d,this.zMin)),Math.cos(f*2)>0?(a.textAlign="center",a.textBaseline="top"):(a.textAlign=Math.sin(f*2)<0?"right":"left",a.textBaseline="middle"),a.fillStyle=
this.colorAxis,a.fillText(c,d.x,d.y);c=this.dataTable.getColumnLabel(this.colY);if(c.length>0)e=0.1/this.scale.x,b=Math.sin(f)>0?this.xMin-e:this.xMax+e,d=(this.yMin+this.yMax)/2,d=this._convert3Dto2D(new links.Point3d(b,d,this.zMin)),Math.cos(f*2)<0?(a.textAlign="center",a.textBaseline="top"):(a.textAlign=Math.sin(f*2)>0?"right":"left",a.textBaseline="middle"),a.fillStyle=this.colorAxis,a.fillText(c,d.x,d.y);c=this.dataTable.getColumnLabel(this.colZ);if(c.length>0)b=Math.cos(f)>0?this.xMin:this.xMax,
d=Math.sin(f)<0?this.yMin:this.yMax,d=this._convert3Dto2D(new links.Point3d(b,d,(this.zMin+this.zMax)/2)),a.textAlign="right",a.textBaseline="middle",a.fillStyle=this.colorAxis,a.fillText(c,d.x-30,d.y)};
links.Graph3d.prototype._hsv2rgb=function(a,b,c){var e;b*=c;c=Math.floor(a/60);e=b*(1-Math.abs(a/60%2-1));switch(c){case 0:a=b;c=e;b=0;break;case 1:a=e;c=b;b=0;break;case 2:a=0;c=b;b=e;break;case 3:a=0;c=e;break;case 4:a=e;c=0;break;case 5:a=b;c=0;b=e;break;default:b=c=a=0}return"RGB("+parseInt(a*255)+","+parseInt(c*255)+","+parseInt(b*255)+")"};
links.Graph3d.prototype._redrawDataGrid=function(){var a=this.frame.canvas.getContext("2d");if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(var b=0;b<this.dataPoints.length;b++){var c=this._convertPointToTranslation(this.dataPoints[b].point),e=this._convertTranslationToScreen(c);this.dataPoints[b].trans=c;this.dataPoints[b].screen=e;c=this._convertPointToTranslation(this.dataPoints[b].bottom);this.dataPoints[b].transbottom=c}this.dataPoints.sort(function(a,b){return a.transbottom.z-
b.transbottom.z});if(this.style===links.Graph3d.STYLE.SURFACE)for(b=0;b<this.dataPoints.length;b++){var c=this.dataPoints[b],e=this.dataPoints[b].pointRight,f=this.dataPoints[b].pointTop,d=this.dataPoints[b].pointCross;if(c!==void 0&&e!==void 0&&f!==void 0&&d!==void 0){if(this.showGrayBottom||this.showShadow)var g=links.Point3d.subtract(d.trans,c.trans),h=links.Point3d.subtract(f.trans,e.trans),g=links.Point3d.crossProduct(g,h),h=g.length(),i=g.z>0;else i=!0;if(i){var j=(c.point.z+e.point.z+f.point.z+
d.point.z)/4,j=(1-(j-this.zMin)*this.scale.z/this.verticalRatio)*240;if(this.showShadow)var i=Math.min(1+g.x/h/2,1),j=this._hsv2rgb(j,1,i),k=this.colorAxis,k=j;else i=1,j=this._hsv2rgb(j,1,i),k=this.colorAxis}else j="gray",k=this.colorAxis;i=0.5;a.lineWidth=i;a.fillStyle=j;a.strokeStyle=k;a.beginPath();a.moveTo(c.screen.x,c.screen.y);a.lineTo(e.screen.x,e.screen.y);a.lineTo(d.screen.x,d.screen.y);a.lineTo(f.screen.x,f.screen.y);a.closePath();a.fill();a.stroke()}}else for(b=0;b<this.dataPoints.length;b++){c=
this.dataPoints[b];e=this.dataPoints[b].pointRight;f=this.dataPoints[b].pointTop;c!==void 0&&(i=this.showPerspective?2/-c.trans.z:2*-(this.eye.z/this.camera.getArmLength()));if(c!==void 0&&e!==void 0)j=(c.point.z+e.point.z)/2,j=(1-(j-this.zMin)*this.scale.z/this.verticalRatio)*240,a.lineWidth=i,a.strokeStyle=this._hsv2rgb(j,1,1),a.beginPath(),a.moveTo(c.screen.x,c.screen.y),a.lineTo(e.screen.x,e.screen.y),a.stroke();if(c!==void 0&&f!==void 0)j=(c.point.z+f.point.z)/2,j=(1-(j-this.zMin)*this.scale.z/
this.verticalRatio)*240,a.lineWidth=i,a.strokeStyle=this._hsv2rgb(j,1,1),a.beginPath(),a.moveTo(c.screen.x,c.screen.y),a.lineTo(f.screen.x,f.screen.y),a.stroke()}}};
links.Graph3d.prototype._redrawDataDot=function(){var a=this.frame.canvas.getContext("2d");if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(var b=0;b<this.dataPoints.length;b++){var c=this._convertPointToTranslation(this.dataPoints[b].point),e=this._convertTranslationToScreen(c);this.dataPoints[b].trans=c;this.dataPoints[b].screen=e}this.dataPoints.sort(function(a,b){return a.trans.z-b.trans.z});c=this.frame.clientWidth*0.02;for(b=0;b<this.dataPoints.length;b++){e=this.dataPoints[b];
if(this.style===links.Graph3d.STYLE.DOTLINE){var f=this._convert3Dto2D(new links.Point3d(e.point.x,e.point.y,this.zMin));a.lineWidth=1;a.strokeStyle=this.colorGrid;a.beginPath();a.moveTo(f.x,f.y);a.lineTo(e.screen.x,e.screen.y);a.stroke()}f=this.style===links.Graph3d.STYLE.DOTSIZE?c/2+2*c*(e.point.value-this.valueMin)/(this.valueMax-this.valueMin):c;f=this.showPerspective?f/-e.trans.z:f*-(this.eye.z/this.camera.getArmLength());f<0&&(f=0);if(this.style===links.Graph3d.STYLE.DOTCOLOR)var d=(1-(e.point.value-
this.valueMin)*this.scale.value)*240,g=this._hsv2rgb(d,1,1),d=this._hsv2rgb(d,1,0.8);else this.style===links.Graph3d.STYLE.DOTSIZE?(g=this.colorDot,d=this.colorDotBorder):(d=(1-(e.point.z-this.zMin)*this.scale.z/this.verticalRatio)*240,g=this._hsv2rgb(d,1,1),d=this._hsv2rgb(d,1,0.8));a.lineWidth=1;a.strokeStyle=d;a.fillStyle=g;a.beginPath();a.arc(e.screen.x,e.screen.y,f,0,Math.PI*2,!0);a.fill();a.stroke()}}};
links.Graph3d.prototype._redrawDataLine=function(){var a=this.frame.canvas.getContext("2d");if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(var b=0;b<this.dataPoints.length;b++){var c=this._convertPointToTranslation(this.dataPoints[b].point),e=this._convertTranslationToScreen(c);this.dataPoints[b].trans=c;this.dataPoints[b].screen=e}if(this.dataPoints.length>0)c=this.dataPoints[0],a.lineWidth=1,a.strokeStyle="blue",a.beginPath(),a.moveTo(c.screen.x,c.screen.y);for(b=1;b<this.dataPoints.length;b++)c=
this.dataPoints[b],a.lineTo(c.screen.x,c.screen.y);this.dataPoints.length>0&&a.stroke()}};
links.Graph3d.prototype._onMouseDown=function(a){a=a||window.event;this.leftButtonDown&&this._onMouseUp(a);if((this.leftButtonDown=a.which?a.which===1:a.button===1)||this.touchDown){this.startMouseX=a.clientX||a.targetTouches[0].clientX;this.startMouseY=a.clientY||a.targetTouches[0].clientY;this.startStart=new Date(this.start);this.startEnd=new Date(this.end);this.startArmRotation=this.camera.getArmRotation();this.frame.style.cursor="move";var b=this;this.onmousemove=function(a){b._onMouseMove(a)};
this.onmouseup=function(a){b._onMouseUp(a)};links.addEventListener(document,"mousemove",b.onmousemove);links.addEventListener(document,"mouseup",b.onmouseup);links.preventDefault(a)}};
links.Graph3d.prototype._onMouseMove=function(a){var a=a||window.event,b=parseFloat(a.clientX||a.targetTouches[0].clientX)-this.startMouseX,c=parseFloat(a.clientY||a.targetTouches[0].clientY)-this.startMouseY,b=this.startArmRotation.horizontal+b/200,c=this.startArmRotation.vertical+c/200,e=Math.sin(4/360*2*Math.PI);Math.abs(Math.sin(b))<e&&(b=Math.round(b/Math.PI)*Math.PI-0.001);Math.abs(Math.cos(b))<e&&(b=(Math.round(b/Math.PI-0.5)+0.5)*Math.PI-0.001);Math.abs(Math.sin(c))<e&&(c=Math.round(c/Math.PI)*
Math.PI);Math.abs(Math.cos(c))<e&&(c=(Math.round(c/Math.PI-0.5)+0.5)*Math.PI);this.camera.setArmRotation(b,c);this.redraw();b=this.getCameraPosition();google.visualization.events.trigger(this,"camerapositionchange",b);links.preventDefault(a)};links.Graph3d.prototype._onMouseUp=function(a){this.frame.style.cursor="auto";this.leftButtonDown=!1;links.removeEventListener(document,"mousemove",this.onmousemove);links.removeEventListener(document,"mouseup",this.onmouseup);links.preventDefault(a)};
links.Graph3d.prototype._onTouchStart=function(a){this.touchDown=!0;var b=this;this.ontouchmove=function(a){b._onTouchMove(a)};this.ontouchend=function(a){b._onTouchEnd(a)};links.addEventListener(document,"touchmove",b.ontouchmove);links.addEventListener(document,"touchend",b.ontouchend);this._onMouseDown(a)};links.Graph3d.prototype._onTouchMove=function(a){this._onMouseMove(a)};
links.Graph3d.prototype._onTouchEnd=function(a){this.touchDown=!1;links.removeEventListener(document,"touchmove",this.ontouchmove);links.removeEventListener(document,"touchend",this.ontouchend);this._onMouseUp(a)};
links.Graph3d.prototype._onWheel=function(a){if(!a)a=window.event;var b=0;a.wheelDelta?b=a.wheelDelta/120:a.detail&&(b=-a.detail/3);b&&(this.camera.setArmLength(this.camera.getArmLength()*(1-b/10)),this.redraw());b=this.getCameraPosition();google.visualization.events.trigger(this,"camerapositionchange",b);links.preventDefault(a)};links.Point3d=function(a,b,c){this.x=a!==void 0?a:0;this.y=b!==void 0?b:0;this.z=c!==void 0?c:0};
links.Point3d.subtract=function(a,b){var c=new links.Point3d;c.x=a.x-b.x;c.y=a.y-b.y;c.z=a.z-b.z;return c};links.Point3d.add=function(a,b){var c=new links.Point3d;c.x=a.x+b.x;c.y=a.y+b.y;c.z=a.z+b.z;return c};links.Point3d.crossProduct=function(a,b){var c=new links.Point3d;c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};links.Point3d.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};
links.Point2d=function(a,b){this.x=a!==void 0?a:0;this.y=b!==void 0?b:0};links.Filter=function(a,b,c){this.data=a;this.column=b;this.graph=c;this.value=this.index=void 0;this.values=a.getDistinctValues(this.column);this.values.length&&this.selectValue(0);this.dataPoints=[];this.loaded=!1;this.onLoadCallback=void 0;c.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0};links.Filter.prototype.isLoaded=function(){return this.loaded};
links.Filter.prototype.getLoadedProgress=function(){for(var a=this.values.length,b=0;this.dataPoints[b];)b++;return Math.round(b/a*100)};links.Filter.prototype.getLabel=function(){return this.data.getColumnLabel(this.column)};links.Filter.prototype.getColumn=function(){return this.column};links.Filter.prototype.getSelectedValue=function(){return this.index===void 0?void 0:this.values[this.index]};links.Filter.prototype.getValues=function(){return this.values};
links.Filter.prototype.getValue=function(a){if(a>=this.values.length)throw"Error: index out of range";return this.values[a]};links.Filter.prototype._getDataPoints=function(a){if(a===void 0)a=this.index;if(a===void 0)return[];var b;if(this.dataPoints[a])b=this.dataPoints[a];else{b=new google.visualization.DataView(this.data);var c={};c.column=this.column;c.value=this.values[a];c=this.data.getFilteredRows([c]);b.setRows(c);b=this.graph._getDataPoints(b);this.dataPoints[a]=b}return b};
links.Filter.prototype.setOnLoadCallback=function(a){this.onLoadCallback=a};links.Filter.prototype.selectValue=function(a){if(a>=this.values.length)throw"Error: index out of range";this.index=a;this.value=this.values[a]};
links.Filter.prototype.loadInBackground=function(a){a===void 0&&(a=0);var b=this.graph.frame;if(a<this.values.length){this._getDataPoints(a);if(b.progress===void 0)b.progress=document.createElement("DIV"),b.progress.style.position="absolute",b.progress.style.color="gray",b.appendChild(b.progress);var c=this.getLoadedProgress();b.progress.innerHTML="Loading animation... "+c+"%";b.progress.style.bottom=links.Graph3d.px(60);b.progress.style.left=links.Graph3d.px(10);var e=this;setTimeout(function(){e.loadInBackground(a+
1)},10);this.loaded=!1}else{this.loaded=!0;if(b.progress!==void 0)b.removeChild(b.progress),b.progress=void 0;if(this.onLoadCallback)this.onLoadCallback()}};links.StepNumber=function(a,b,c,e){this.end_=this.start_=0;this.step_=1;this.prettyStep=!0;this.precision=5;this.current_=0;this.setRange(a,b,c,e)};links.StepNumber.prototype.setRange=function(a,b,c,e){this.start_=a?a:0;this.end_=b?b:0;this.setStep(c,e)};
links.StepNumber.prototype.setStep=function(a,b){if(!(a===void 0||a<=0)){if(b!==void 0)this.prettyStep=b;this.step_=this.prettyStep===!0?links.StepNumber.calculatePrettyStep(a):a}};links.StepNumber.calculatePrettyStep=function(a){var b=1*Math.pow(10,Math.round(Math.log(a/1)/Math.LN10)),c=2*Math.pow(10,Math.round(Math.log(a/2)/Math.LN10)),e=5*Math.pow(10,Math.round(Math.log(a/5)/Math.LN10));Math.abs(c-a)<=Math.abs(b-a)&&(b=c);Math.abs(e-a)<=Math.abs(b-a)&&(b=e);b<=0&&(b=1);return b};
links.StepNumber.prototype.getCurrent=function(){var a=this.current_.toPrecision(this.precision);this.current_<1E5&&(a*=1);return a};links.StepNumber.prototype.getStep=function(){return this.step_};links.StepNumber.prototype.start=function(){this.current_=this.start_-this.start_%this.step_};links.StepNumber.prototype.next=function(){this.current_+=this.step_};links.StepNumber.prototype.end=function(){return this.current_>this.end_};
links.Slider=function(a,b){if(a===void 0)throw"Error: No container element defined";this.container=a;if(this.visible=b&&b.visible!=void 0?b.visible:!0){this.frame=document.createElement("DIV");this.frame.style.width="100%";this.frame.style.position="relative";this.container.appendChild(this.frame);this.frame.prev=document.createElement("INPUT");this.frame.prev.type="BUTTON";this.frame.prev.value="Prev";this.frame.appendChild(this.frame.prev);this.frame.play=document.createElement("INPUT");this.frame.play.type=
"BUTTON";this.frame.play.value="Play";this.frame.appendChild(this.frame.play);this.frame.next=document.createElement("INPUT");this.frame.next.type="BUTTON";this.frame.next.value="Next";this.frame.appendChild(this.frame.next);this.frame.bar=document.createElement("INPUT");this.frame.bar.type="BUTTON";this.frame.bar.style.position="absolute";this.frame.bar.style.border="1px solid red";this.frame.bar.style.width="100px";this.frame.bar.style.height="6px";this.frame.bar.style.borderRadius="2px";this.frame.bar.style.MozBorderRadius=
"2px";this.frame.bar.style.border="1px solid #7F7F7F";this.frame.bar.style.backgroundColor="#E5E5E5";this.frame.appendChild(this.frame.bar);this.frame.slide=document.createElement("INPUT");this.frame.slide.type="BUTTON";this.frame.slide.style.margin="0px";this.frame.slide.value=" ";this.frame.slide.style.position="relative";this.frame.slide.style.left="-100px";this.frame.appendChild(this.frame.slide);var c=this;this.frame.slide.onmousedown=function(a){c._onMouseDown(a)};this.frame.prev.onclick=function(a){c.prev(a)};
this.frame.play.onclick=function(a){c.togglePlay(a)};this.frame.next.onclick=function(a){c.next(a)}}this.onChangeCallback=void 0;this.values=[];this.playTimeout=this.index=void 0;this.playInterval=1E3;this.playLoop=!0};links.Slider.prototype.prev=function(){var a=this.getIndex();a>0&&(a--,this.setIndex(a))};links.Slider.prototype.next=function(){var a=this.getIndex();a<this.values.length-1&&(a++,this.setIndex(a))};
links.Slider.prototype.playNext=function(){var a=new Date,b=this.getIndex();b<this.values.length-1?(b++,this.setIndex(b)):this.playLoop&&this.setIndex(0);var a=Math.max(this.playInterval-(new Date-a),0),c=this;this.playTimeout=setTimeout(function(){c.playNext()},a)};links.Slider.prototype.togglePlay=function(){this.playTimeout===void 0?this.play():this.stop()};links.Slider.prototype.play=function(){this.playNext();if(this.frame)this.frame.play.value="Stop"};
links.Slider.prototype.stop=function(){clearInterval(this.playTimeout);this.playTimeout=void 0;if(this.frame)this.frame.play.value="Play"};links.Slider.prototype.setOnChangeCallback=function(a){this.onChangeCallback=a};links.Slider.prototype.setPlayInterval=function(a){this.playInterval=a};links.Slider.prototype.getPlayInterval=function(){return this.playInterval};links.Slider.prototype.setPlayLoop=function(a){this.playLoop=a};
links.Slider.prototype.onChange=function(){if(this.onChangeCallback!==void 0)this.onChangeCallback()};links.Slider.prototype.redraw=function(){if(this.frame)this.frame.bar.style.top=this.frame.clientHeight/2-this.frame.bar.offsetHeight/2+"px",this.frame.bar.style.width=this.frame.clientWidth-this.frame.prev.clientWidth-this.frame.play.clientWidth-this.frame.next.clientWidth-30+"px",this.frame.slide.style.left=this.indexToLeft(this.index)+"px"};
links.Slider.prototype.setValues=function(a){this.values=a;this.values.length>0?this.setIndex(0):this.index=void 0};links.Slider.prototype.setIndex=function(a){if(a<this.values.length)this.index=a,this.redraw(),this.onChange();else throw"Error: index out of range";};links.Slider.prototype.getIndex=function(){return this.index};links.Slider.prototype.get=function(){return this.values[this.index]};
links.Slider.prototype._onMouseDown=function(a){if(a.which?a.which===1:a.button===1){this.startClientX=a.clientX;this.startSlideX=parseFloat(this.frame.slide.style.left);this.frame.style.cursor="move";var b=this;this.onmousemove=function(a){b._onMouseMove(a)};this.onmouseup=function(a){b._onMouseUp(a)};links.addEventListener(document,"mousemove",this.onmousemove);links.addEventListener(document,"mouseup",this.onmouseup);links.preventDefault(a)}};
links.Slider.prototype.leftToIndex=function(a){var b=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,a=Math.round((a-3)/b*(this.values.length-1));a<0&&(a=0);a>this.values.length-1&&(a=this.values.length-1);return a};links.Slider.prototype.indexToLeft=function(a){var b=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10;return a/(this.values.length-1)*b+3};
links.Slider.prototype._onMouseMove=function(a){this.setIndex(this.leftToIndex(this.startSlideX+(a.clientX-this.startClientX)));links.preventDefault()};links.Slider.prototype._onMouseUp=function(){this.frame.style.cursor="auto";links.removeEventListener(document,"mousemove",this.onmousemove);links.removeEventListener(document,"mouseup",this.onmouseup);links.preventDefault()};
links.addEventListener=function(a,b,c,e){a.addEventListener?(e===void 0&&(e=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.addEventListener(b,c,e)):a.attachEvent("on"+b,c)};links.removeEventListener=function(a,b,c,e){a.removeEventListener?(e===void 0&&(e=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.removeEventListener(b,c,e)):a.detachEvent("on"+b,c)};
links.stopPropagation=function(a){if(!a)a=window.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0};links.preventDefault=function(a){if(!a)a=window.event;a.preventDefault?a.preventDefault():a.returnValue=!1};links.getAbsoluteLeft=function(a){for(var b=0;a!==null;)b+=a.offsetLeft,b-=a.scrollLeft,a=a.offsetParent;return b};links.getAbsoluteTop=function(a){for(var b=0;a!==null;)b+=a.offsetTop,b-=a.scrollTop,a=a.offsetParent;return b};
