You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Uoj/web/js/jquery.tagcanvas.min.js

22 lines
39 KiB

/**
* Copyright (C) 2010-2015 Graham Breach
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* jQuery.tagcanvas 2.6.1
* For more information, please contact <graham@goat1000.com>
*/
(function(am){var L,J,K=Math.abs,af=Math.sin,w=Math.cos,s=Math.max,aA=Math.min,an=Math.ceil,E=Math.sqrt,ap=Math.pow,h={},l={},m={0:"0,",1:"17,",2:"34,",3:"51,",4:"68,",5:"85,",6:"102,",7:"119,",8:"136,",9:"153,",a:"170,",A:"170,",b:"187,",B:"187,",c:"204,",C:"204,",d:"221,",D:"221,",e:"238,",E:"238,",f:"255,",F:"255,"},x,c,P,aC,G,aD,Z,C=document,p,b={};for(L=0;L<256;++L){J=L.toString(16);if(L<16){J="0"+J}l[J]=l[J.toUpperCase()]=L.toString()+","}function ag(i){return typeof i!="undefined"}function H(i){return typeof i=="object"&&i!=null}function ar(i,j,aE){return isNaN(i)?aE:aA(aE,s(j,i))}function ax(){return false}function F(){return new Date().valueOf()}function A(aE,aH){var j=[],aF=aE.length,aG;for(aG=0;aG<aF;++aG){j.push(aE[aG])}j.sort(aH);return j}function al(j){var aF=j.length-1,aE,aG;while(aF){aG=~~(Math.random()*aF);aE=j[aF];j[aF]=j[aG];j[aG]=aE;--aF}}function ac(i,aE,j){this.x=i;this.y=aE;this.z=j}G=ac.prototype;G.length=function(){return E(this.x*this.x+this.y*this.y+this.z*this.z)};G.dot=function(i){return this.x*i.x+this.y*i.y+this.z*i.z};G.cross=function(j){var i=this.y*j.z-this.z*j.y,aF=this.z*j.x-this.x*j.z,aE=this.x*j.y-this.y*j.x;return new ac(i,aF,aE)};G.angle=function(j){var i=this.dot(j),aE;if(i==0){return Math.PI/2}aE=i/(this.length()*j.length());if(aE>=1){return 0}if(aE<=-1){return Math.PI}return Math.acos(aE)};G.unit=function(){var i=this.length();return new ac(this.x/i,this.y/i,this.z/i)};function ah(aE,j){j=j*Math.PI/180;aE=aE*Math.PI/180;var i=af(aE)*w(j),aG=-af(j),aF=-w(aE)*w(j);return new ac(i,aG,aF)}function Q(i){this[1]={1:i[0],2:i[1],3:i[2]};this[2]={1:i[3],2:i[4],3:i[5]};this[3]={1:i[6],2:i[7],3:i[8]}}aC=Q.prototype;Q.Identity=function(){return new Q([1,0,0,0,1,0,0,0,1])};Q.Rotation=function(aF,i){var j=af(aF),aE=w(aF),aG=1-aE;return new Q([aE+ap(i.x,2)*aG,i.x*i.y*aG-i.z*j,i.x*i.z*aG+i.y*j,i.y*i.x*aG+i.z*j,aE+ap(i.y,2)*aG,i.y*i.z*aG-i.x*j,i.z*i.x*aG-i.y*j,i.z*i.y*aG+i.x*j,aE+ap(i.z,2)*aG])};aC.mul=function(aE){var aF=[],aI,aH,aG=(aE.xform?1:0);for(aI=1;aI<=3;++aI){for(aH=1;aH<=3;++aH){if(aG){aF.push(this[aI][1]*aE[1][aH]+this[aI][2]*aE[2][aH]+this[aI][3]*aE[3][aH])}else{aF.push(this[aI][aH]*aE)}}}return new Q(aF)};aC.xform=function(aE){var j={},i=aE.x,aG=aE.y,aF=aE.z;j.x=i*this[1][1]+aG*this[2][1]+aF*this[3][1];j.y=i*this[1][2]+aG*this[2][2]+aF*this[3][2];j.z=i*this[1][3]+aG*this[2][3]+aF*this[3][3];return j};function q(aF,aH,aM,aJ){var aI,aL,j,aK,aN=[],aG=Math.PI*(3-E(5)),aE=2/aF;for(aI=0;aI<aF;++aI){aL=aI*aE-1+(aE/2);j=E(1-aL*aL);aK=aI*aG;aN.push([w(aK)*j*aH,aL*aM,af(aK)*j*aJ])}return aN}function V(aG,aE,aJ,aP,aN){var aO,aQ=[],aH=Math.PI*(3-E(5)),aF=2/aG,aM,aL,aK,aI;for(aM=0;aM<aG;++aM){aL=aM*aF-1+(aF/2);aO=aM*aH;aK=w(aO);aI=af(aO);aQ.push(aE?[aL*aJ,aK*aP,aI*aN]:[aK*aJ,aL*aP,aI*aN])}return aQ}function M(aE,aF,aI,aO,aM,aK){var aN,aP=[],aG=Math.PI*2/aF,aL,aJ,aH;for(aL=0;aL<aF;++aL){aN=aL*aG;aJ=w(aN);aH=af(aN);aP.push(aE?[aK*aI,aJ*aO,aH*aM]:[aJ*aI,aK*aO,aH*aM])}return aP}function ak(aF,i,j,aE){return V(aF,0,i,j,aE)}function aq(aF,i,j,aE){return V(aF,1,i,j,aE)}function d(aG,i,j,aE,aF){aF=isNaN(aF)?0:aF*1;return M(0,aG,i,j,aE,aF)}function n(aG,i,j,aE,aF){aF=isNaN(aF)?0:aF*1;return M(1,aG,i,j,aE,aF)}function T(aH,i){var aG=aH,aF,aE,j=(i*1).toPrecision(3)+")";if(aH[0]==="#"){if(!h[aH]){if(aH.length===4){h[aH]="rgba("+m[aH[1]]+m[aH[2]]+m[aH[3]]}else{h[aH]="rgba("+l[aH.substr(1,2)]+l[aH.substr(3,2)]+l[aH.substr(5,2)]}}aG=h[aH]+j}else{if(aH.substr(0,4)==="rgb("||aH.substr(0,4)==="hsl("){aG=(aH.replace("(","a(").replace(")",","+j))}else{if(aH.substr(0,5)==="rgba("||aH.substr(0,5)==="hsla("){aF=aH.lastIndexOf(",")+1,aE=aH.indexOf(")");i*=parseFloat(aH.substring(aF,aE));aG=aH.substr(0,aF)+i.toPrecision(3)+")"}}}return aG}function O(i,j){if(window.G_vmlCanvasManager){return null}var aE=C.createElement("canvas");aE.width=i;aE.height=j;return aE}function aj(){var j=O(3,3),aF,aE;if(!j){return false}aF=j.getContext("2d");aF.strokeStyle="#000";aF.shadowColor="#fff";aF.shadowBlur=3;aF.globalAlpha=0;aF.strokeRect(2,2,2,2);aF.globalAlpha=1;aE=aF.getImageData(2,2,1,1);j=null;return(aE.data[0]>0)}function ai(aI,j,aH,aG){var aF=aI.createLinearGradient(0,0,j,0),aE;for(aE in aG){aF.addColorStop(1-aE,aG[aE])}aI.fillStyle=aF;aI.fillRect(0,aH,j,1)}function k(aG,aE,j){var aF=1024,aK=1,aJ=aG.weightGradient,aI,aM,aH,aL;if(aG.gCanvas){aM=aG.gCanvas.getContext("2d");aK=aG.gCanvas.height}else{if(H(aJ[0])){aK=aJ.length}else{aJ=[aJ]}aG.gCanvas=aI=O(aF,aK);if(!aI){return null}aM=aI.getContext("2d");for(aH=0;aH<aK;++aH){ai(aM,aF,aH,aJ[aH])}}j=s(aA(j||0,aK-1),0);aL=aM.getImageData(~~((aF-1)*aE),j,1,1).data;return"rgba("+aL[0]+","+aL[1]+","+aL[2]+","+(aL[3]/255)+")"}function W(aN,aG,j,aR,aQ,aO,aM,aI,aF,aP,aH,aL){var aK=aQ+(aI||0)+(aF.length&&aF[0]<0?K(aF[0]):0),aE=aO+(aI||0)+(aF.length&&aF[1]<0?K(aF[1]):0),aJ,aS;aN.font=aG;aN.textBaseline="top";aN.fillStyle=j;aM&&(aN.shadowColor=aM);aI&&(aN.shadowBlur=aI);aF.length&&(aN.shadowOffsetX=aF[0],aN.shadowOffsetY=aF[1]);for(aJ=0;aJ<aR.length;++aJ){aS=0;if(aH){if("right"==aL){aS=aP-aH[aJ]}else{if("centre"==aL){aS=(aP-aH[aJ])/2}}}aN.fillText(aR[aJ],aK+aS,aE);aE+=parseInt(aG)}}function ao(aI,i,aH,j,aF,aG,aE){if(aG){aI.beginPath();aI.moveTo(i,aH+aF-aG);aI.arcTo(i,aH,i+aG,aH,aG);aI.arcTo(i+j,aH,i+j,aH+aG,aG);aI.arcTo(i+j,aH+aF,i+j-aG,aH+aF,aG);aI.arcTo(i,aH+aF,i,aH+aF-aG,aG);aI.closePath();aI[aE?"stroke":"fill"]()}else{aI[aE?"strokeRect":"fillRect"](i,aH,j,aF)}}function g(aK,i,aI,aF,aJ,aE,aG,aH,j){this.strings=aK;this.font=i;this.width=aI;this.height=aF;this.maxWidth=aJ;this.stringWidths=aE;this.align=aG;this.valign=aH;this.scale=j}Z=g.prototype;Z.SetImage=function(aH,j,aF,i,aG,aJ,aE,aI){this.image=aH;this.iwidth=j*this.scale;this.iheight=aF*this.scale;this.ipos=i;this.ipad=aG*this.scale;this.iscale=aI;this.ialign=aJ;this.ivalign=aE};Z.Align=function(j,aE,i){var aF=0;if(i=="right"||i=="bottom"){aF=aE-j}else{if(i!="left"&&i!="top"){aF=(aE-j)/2}}return aF};Z.Create=function(aQ,aW,aP,aX,aV,aU,i,aT,aM){var aK,aI,aR,a2,aZ,aY,aG,aF,aE,j,aJ,aH,aL,aS,a1=K(i[0]),a0=K(i[1]),aN,aO;aT=s(aT,a1+aU,a0+aU);aZ=2*(aT+aX);aG=2*(aT+aX);aI=this.width+aZ;aR=this.height+aG;aE=j=aT+aX;if(this.image){aJ=aH=aT+aX;aL=this.iwidth;aS=this.iheight;if(this.ipos=="top"||this.ipos=="bottom"){if(aL<this.width){aJ+=this.Align(aL,this.width,this.ialign)}else{aE+=this.Align(this.width,aL,this.align)}if(this.ipos=="top"){j+=aS+this.ipad}else{aH+=this.height+this.ipad}aI=s(aI,aL+aZ);aR+=aS+this.ipad}else{if(aS<this.height){aH+=this.Align(aS,this.height,this.ivalign)}else{j+=this.Align(this.height,aS,this.valign)}if(this.ipos=="right"){aJ+=this.width+this.ipad}else{aE+=aL+this.ipad}aI+=aL+this.ipad;aR=s(aR,aS+aG)}}aK=O(aI,aR);if(!aK){return null}aZ=aG=aX/2;aY=aI-aX;aF=aR-aX;a2=aK.getContext("2d");if(aW){a2.fillStyle=aW;ao(a2,aZ,aG,aY,aF,aM)}if(aX){a2.strokeStyle=aP;a2.lineWidth=aX;ao(a2,aZ,aG,aY,aF,aM,true)}if(aU||a1||a0){aN=O(aI,aR);if(aN){aO=a2;a2=aN.getContext("2d")}}W(a2,this.font,aQ,this.strings,aE,j,0,0,[],this.maxWidth,this.stringWidths,this.align);if(this.image){a2.drawImage(this.image,aJ,aH,aL,aS)}if(aO){a2=aO;aV&&(a2.shadowColor=aV);aU&&(a2.shadowBlur=aU);a2.shadowOffsetX=i[0];a2.shadowOffsetY=i[1];a2.drawImage(aN,0,0)}return aK};function v(aF,j,aG){var aE=O(j,aG),aH;if(!aE){return null}aH=aE.getContext("2d");aH.drawImage(aF,(j-aF.width)/2,(aG-aF.height)/2);return aE}function au(aF,j,aG){var aE=O(j,aG),aH;if(!aE){return null}aH=aE.getContext("2d");aH.drawImage(aF,0,0,j,aG);return aE}function az(aQ,aL,aR,aV,aM,aK,aJ,aO,aH,aI){var aF=aL+((2*aO)+aK)*aV,aN=aR+((2*aO)+aK)*aV,aG=O(aF,aN),aU,aT,aE,aS,j,aW,aP;if(!aG){return null}aK*=aV;aH*=aV;aT=aE=aK/2;aS=aF-aK;j=aN-aK;aO=(aO*aV)+aT;aU=aG.getContext("2d");if(aM){aU.fillStyle=aM;ao(aU,aT,aE,aS,j,aH)}if(aK){aU.strokeStyle=aJ;aU.lineWidth=aK;ao(aU,aT,aE,aS,j,aH,true)}if(aI){aW=O(aF,aN);aP=aW.getContext("2d");aP.drawImage(aQ,aO,aO,aL,aR);aP.globalCompositeOperation="source-in";aP.fillStyle=aJ;aP.fillRect(0,0,aF,aN);aP.globalCompositeOperation="destination-over";aP.drawImage(aG,0,0);aP.globalCompositeOperation="source-over";aU.drawImage(aW,0,0)}else{aU.drawImage(aQ,aO,aO,aQ.width,aQ.height)}return{image:aG,width:aF/aV,height:aN/aV}}function Y(aK,aQ,aM,aG,aO,aP,aF){var aR=K(aF[0]),aL=K(aF[1]),aH=aQ+(aR>aP?aR+aP:aP*2)*aG,j=aM+(aL>aP?aL+aP:aP*2)*aG,aJ=aG*((aP||0)+(aF[0]<0?aR:0)),aE=aG*((aP||0)+(aF[1]<0?aL:0)),aI,aN;aI=O(aH,j);if(!aI){return null}aN=aI.getContext("2d");aO&&(aN.shadowColor=aO);aP&&(aN.shadowBlur=aP*aG);aF&&(aN.shadowOffsetX=aF[0]*aG,aN.shadowOffsetY=aF[1]*aG);aN.drawImage(aK,aJ,aE,aQ,aM);return{image:aI,width:aH/aG,height:j/aG}}function t(aQ,aI,aO){var aP=parseInt(aQ.toString().length*aO),aH=parseInt(aO*2*aQ.length),aF=O(aP,aH),aL,j,aG,aK,aN,aM,aE,aJ;if(!aF){return null}aL=aF.getContext("2d");aL.fillStyle="#000";aL.fillRect(0,0,aP,aH);W(aL,aO+"px "+aI,"#fff",aQ,0,0,0,0,[],"centre");j=aL.getImageData(0,0,aP,aH);aG=j.width;aK=j.height;aJ={min:{x:aG,y:aK},max:{x:-1,y:-1}};for(aM=0;aM<aK;++aM){for(aN=0;aN<aG;++aN){aE=(aM*aG+aN)*4;if(j.data[aE+1]>0){if(aN<aJ.min.x){aJ.min.x=aN}if(aN>aJ.max.x){aJ.max.x=aN}if(aM<aJ.min.y){aJ.min.y=aM}if(aM>aJ.max.y){aJ.max.y=aM}}}}if(aG!=aP){aJ.min.x*=(aP/aG);aJ.max.x*=(aP/aG)}if(aK!=aH){aJ.min.y*=(aP/aK);aJ.max.y*=(aP/aK)}aF=null;return aJ}function o(i){return"'"+i.replace(/(\'|\")/g,"").replace(/\s*,\s*/g,"', '")+"'"}function ab(i,j,aE){aE=aE||C;if(aE.addEventListener){aE.addEventListener(i,j,false)}else{aE.attachEvent("on"+i,j)}}function a(i,j,aE){aE=aE||C;if(aE.removeEventListener){aE.removeEventListener(i,j)}else{aE.detachEvent("on"+i,j)}}function at(aI,aE,aM,aH){var aN=aH.imageScale,aK,aF,aJ,j,aG,aL;if(!aE.complete){return ab("load",function(){at(aI,aE,aM,aH)},aE)}if(!aI.complete){return ab("load",function(){at(aI,aE,aM,aH)},aI)}aE.width=aE.width;aE.height=aE.height;if(aN){aI.width=aE.width*aN;aI.height=aE.height*aN}aM.iw=aI.width;aM.ih=aI.height;if(aH.txtOpt){aF=aI;aK=aH.zoomMax*aH.txtScale;aG=aM.iw*aK;aL=aM.ih*aK;if(aG<aE.naturalWidth||aL<aE.naturalHeight){aF=au(aI,aG,aL);if(aF){aM.fimage=aF}}else{aG=aM.iw;aL=aM.ih;aK=1}if(!aM.HasText()){if(aH.shadow){aF=Y(aM.image,aG,aL,aK,aH.shadow,aH.shadowBlur,aH.shadowOffset);if(aF){aM.fimage=aF.image;aM.w=aF.width;aM.h=aF.height}}if(aH.bgColour||aH.bgOutlineThickness){aJ=aH.bgColour=="tag"?X(aM.a,"background-color"):aH.bgColour;j=aH.bgOutline=="tag"?X(aM.a,"color"):(aH.bgOutline||aH.textColour);aG=aM.fimage.width;aL=aM.fimage.height;if(aH.outlineMethod=="colour"){aF=az(aM.fimage,aG,aL,aK,aJ,aH.bgOutlineThickness,aH.outlineColour,aH.padding,aH.bgRadius,1);if(aF){aM.oimage=aF.image}}aF=az(aM.fimage,aG,aL,aK,aJ,aH.bgOutlineThickness,j,aH.padding,aH.bgRadius);if(aF){aM.fimage=aF.image;aM.w=aF.width;aM.h=aF.height}}if(aH.outlineMethod=="size"){if(aH.outlineIncrease>0){aM.iw+=2*aH.outlineIncrease;aM.ih+=2*aH.outlineIncrease;aG=aK*aM.iw;aL=aK*aM.ih;aF=au(aM.fimage,aG,aL);aM.oimage=aF;aM.fimage=v(aM.fimage,aM.oimage.width,aM.oimage.height)}else{aG=aK*(aM.iw+(2*aH.outlineIncrease));aL=aK*(aM.ih+(2*aH.outlineIncrease));aF=au(aM.fimage,aG,aL);aM.oimage=v(aF,aM.fimage.width,aM.fimage.height)}}}}aM.Init()}function X(aF,aE){var j=C.defaultView,i=aE.replace(/\-([a-z])/g,function(aG){return aG.charAt(1).toUpperCase()});return(j&&j.getComputedStyle&&j.getComputedStyle(aF,null).getPropertyValue(aE))||(aF.currentStyle&&aF.currentStyle[i])}function u(j,aF,aE){var i=1,aG;if(aF){i=1*(j.getAttribute(aF)||aE)}else{if(aG=X(j,"font-size")){i=(aG.indexOf("px")>-1&&aG.replace("px","")*1)||(aG.indexOf("pt")>-1&&aG.replace("pt","")*1.25)||aG*3.3}}return i}function f(i){return i.target&&ag(i.target.id)?i.target.id:i.srcElement.parentNode.id}function R(aG,aH){var aF,aE,i=parseInt(X(aH,"width"))/aH.width,j=parseInt(X(aH,"height"))/aH.height;if(ag(aG.offsetX)){aF={x:aG.offsetX,y:aG.offsetY}}else{aE=aa(aH.id);if(ag(aG.changedTouches)){aG=aG.changedTouches[0]}if(aG.pageX){aF={x:aG.pageX-aE.x,y:aG.pageY-aE.y}}}if(aF&&i&&j){aF.x/=i;aF.y/=j}return aF}function B(aE){var j=aE.target||aE.fromElement.parentNode,i=y.tc[j.id];if(i){i.mx=i.my=-1;i.UnFreeze();i.EndDrag()}}function ad(aI){var aF,aE=y,j,aH,aG=f(aI);for(aF in aE.tc){j=aE.tc[aF];if(j.tttimer){clearTimeout(j.tttimer);j.tttimer=null}}if(aG&&aE.tc[aG]){j=aE.tc[aG];if(aH=R(aI,j.canvas)){j.mx=aH.x;j.my=aH.y;j.Drag(aI,aH)}j.drawn=0}}function z(aF){var j=y,i=C.addEventListener?0:1,aE=f(aF);if(aE&&aF.button==i&&j.tc[aE]){j.tc[aE].BeginDrag(aF)}}function aB(aG){var aE=y,j=C.addEventListener?0:1,aF=f(aG),i;if(aF&&aG.button==j&&aE.tc[aF]){i=aE.tc[aF];ad(aG);if(!i.EndDrag()&&!i.touched){i.Clicked(aG)}}}function S(aE){var i=y,j=f(aE);if(j&&aE.changedTouches&&i.tc[j]){i.tc[j].touched=1;i.tc[j].BeginDrag(aE)}}function r(aE){var i=y,j=f(aE);if(j&&aE.changedTouches&&i.tc[j]){aw(aE);if(!i.tc[j].EndDrag()){i.tc[j].Draw();i.tc[j].Clicked(aE)}}}function aw(aI){var aF,aE=y,j,aH,aG=f(aI);for(aF in aE.tc){j=aE.tc[aF];if(j.tttimer){clearTimeout(j.tttimer);j.tttimer=null}}if(aG&&aE.tc[aG]&&aI.changedTouches){j=aE.tc[aG];if(aH=R(aI,j.canvas)){j.mx=aH.x;j.my=aH.y;j.Drag(aI,aH)}j.drawn=0}}function ae(aE){var i=y,j=f(aE);if(j&&i.tc[j]){aE.cancelBubble=true;aE.returnValue=false;aE.preventDefault&&aE.preventDefault();i.tc[j].Wheel((aE.wheelDelta||aE.detail)>0)}}function N(){D(F())}function D(aF){var j=y.tc,aE;y.NextFrame(y.interval);aF=aF||F();for(aE in j){j[aE].Draw(aF)}}function aa(aE){var aH=C.getElementById(aE),i=aH.getBoundingClientRect(),aK=C.documentElement,aI=C.body,aJ=window,aF=aJ.pageXOffset||aK.scrollLeft,aL=aJ.pageYOffset||aK.scrollTop,aG=aK.clientLeft||aI.clientLeft,j=aK.clientTop||aI.clientTop;return{x:i.left+aF-aG,y:i.top+aL-j}}function U(j,aF,aG,aE){var i=j.radius*j.z1/(j.z1+j.z2+aF.z);return{x:aF.x*i*aG,y:aF.y*i*aE,z:aF.z,w:(j.z1-aF.z)/j.z2}}function ay(i){this.e=i;this.br=0;this.line=[];this.text=[];this.original=i.innerText||i.textContent}aD=ay.prototype;aD.Empty=function(){for(var j=0;j<this.text.length;++j){if(this.text[j].length){return false}}return true};aD.Lines=function(aG){var aF=aG?1:0,aH,j,aE;aG=aG||this.e;aH=aG.childNodes;j=aH.length;for(aE=0;aE<j;++aE){if(aH[aE].nodeName=="BR"){this.text.push(this.line.join(" "));this.br=1}else{if(aH[aE].nodeType==3){if(this.br){this.line=[aH[aE].nodeValue];this.br=0}else{this.line.push(aH[aE].nodeValue)}}else{this.Lines(aH[aE])}}}aF||this.br||this.text.push(this.line.join(" "));return this.text};aD.SplitWidth=function(aE,aL,aI,aH){var aG,aF,aK,aJ=[];aL.font=aH+"px "+aI;for(aG=0;aG<this.text.length;++aG){aK=this.text[aG].split(/\s+/);this.line=[aK[0]];for(aF=1;aF<aK.length;++aF){if(aL.measureText(this.line.join(" ")+" "+aK[aF]).width>aE){aJ.push(this.line.join(" "));this.line=[aK[aF]]}else{this.line.push(aK[aF])}}aJ.push(this.line.join(" "))}return this.text=aJ};function I(i,j){this.ts=F();this.tc=i;this.tag=j;this.x=this.y=this.w=this.h=this.sc=1;this.z=0;this.Draw=i.pulsateTo<1&&i.outlineMethod!="colour"?this.DrawPulsate:this.DrawSimple;this.radius=i.outlineRadius|0;this.SetMethod(i.outlineMethod)}x=I.prototype;x.SetMethod=function(aE){var j={block:["PreDraw","DrawBlock"],colour:["PreDraw","DrawColour"],outline:["PostDraw","DrawOutline"],classic:["LastDraw","DrawOutline"],size:["PreDraw","DrawColour"],none:["LastDraw"]},i=j[aE]||j.outline;if(aE=="none"){this.Draw=function(){return 1}}else{this.drawFunc=this[i[1]]}this[i[0]]=this.Draw};x.Update=function(aK,aJ,aL,aG,aH,aI,aF,i){var j=this.tc.outlineOffset,aE=2*j;this.x=aH*aK+aF-j;this.y=aH*aJ+i-j;this.w=aH*aL+aE;this.h=aH*aG+aE;this.sc=aH;this.z=aI};x.DrawOutline=function(aH,i,aG,j,aE,aF){aH.strokeStyle=aF;ao(aH,i,aG,j,aE,this.radius,true)};x.DrawColour=function(aF,aI,aG,aJ,aE,i,aK,j,aH){if(aK.oimage){aK.alpha=1;aK.Draw(aF,j,aH,aK.oimage);return 1}return this[aK.image?"DrawColourImage":"DrawColourText"](aF,aI,aG,aJ,aE,i,aK,j,aH)};x.DrawColourText=function(aG,aJ,aH,aK,aE,i,aL,j,aI){var aF=aL.colour;aL.colour=i;aL.alpha=1;aL.Draw(aG,j,aI);aL.colour=aF;return 1};x.DrawColourImage=function(aJ,aM,aK,aN,aI,i,aQ,j,aL){var aO=aJ.canvas,aG=~~s(aM,0),aF=~~s(aK,0),aH=aA(aO.width-aG,aN)+0.5|0,aP=aA(aO.height-aF,aI)+0.5|0,aE;if(p){p.width=aH,p.height=aP}else{p=O(aH,aP)}if(!p){return this.SetMethod("outline")}aE=p.getContext("2d");aE.drawImage(aO,aG,aF,aH,aP,0,0,aH,aP);aJ.clearRect(aG,aF,aH,aP);aQ.alpha=1;aQ.Draw(aJ,j,aL);aJ.setTransform(1,0,0,1,0,0);aJ.save();aJ.beginPath();aJ.rect(aG,aF,aH,aP);aJ.clip();aJ.globalCompositeOperation="source-in";aJ.fillStyle=i;aJ.fillRect(aG,aF,aH,aP);aJ.restore();aJ.globalCompositeOperation="destination-over";aJ.drawImage(p,0,0,aH,aP,aG,aF,aH,aP);aJ.globalCompositeOperation="source-over";return 1};x.DrawBlock=function(aH,i,aG,j,aE,aF){aH.fillStyle=aF;ao(aH,i,aG,j,aE,this.radius)};x.DrawSimple=function(aG,i,j,aF){var aE=this.tc;aG.setTransform(1,0,0,1,0,0);aG.strokeStyle=aE.outlineColour;aG.lineWidth=aE.outlineThickness;aG.shadowBlur=aG.shadowOffsetX=aG.shadowOffsetY=0;aG.globalAlpha=1;return this.drawFunc(aG,this.x,this.y,this.w,this.h,aE.outlineColour,i,j,aF)};x.DrawPulsate=function(aH,i,j,aF){var aG=F()-this.ts,aE=this.tc;aH.setTransform(1,0,0,1,0,0);aH.strokeStyle=aE.outlineColour;aH.lineWidth=aE.outlineThickness;aH.shadowBlur=aH.shadowOffsetX=aH.shadowOffsetY=0;aH.globalAlpha=aE.pulsateTo+((1-aE.pulsateTo)*(0.5+(w(2*Math.PI*aG/(1000*aE.pulsateTime))/2)));return this.drawFunc(aH,this.x,this.y,this.w,this.h,aE.outlineColour,i,j,aF)};x.Active=function(aE,i,j){return(i>=this.x&&j>=this.y&&i<=this.x+this.w&&j<=this.y+this.h)};x.PreDraw=x.PostDraw=x.LastDraw=ax;function e(aF,aP,aL,aO,aM,aG,aE,aI,aN,aH,aK,j,aJ,i){this.tc=aF;this.image=null;this.text=aP;this.text_original=i;this.line_widths=[];this.title=aL.title||null;this.a=aL;this.position=new ac(aO[0],aO[1],aO[2]);this.x=this.y=this.z=0;this.w=aM;this.h=aG;this.colour=aE||aF.textColour;this.bgColour=aI||aF.bgColour;this.bgRadius=aN|0;this.bgOutline=aH||this.colour;this.bgOutlineThickness=aK|0;this.textFont=j||aF.textFont;this.padding=aJ|0;this.sc=this.alpha=1;this.weighted=!aF.weight}c=e.prototype;c.Init=function(j){var i=this.tc;this.outline=new I(i,this);this.textHeight=i.textHeight;if(this.HasText()){this.Measure(i.ctxt,i)}else{this.w=this.iw;this.h=this.ih}this.SetShadowColour=i.shadowAlpha?this.SetShadowColourAlpha:this.SetShadowColourFixed;this.SetDraw(i)};c.Draw=ax;c.HasText=function(){return this.text&&this.text[0].length>0};c.EqualTo=function(aE){var j=aE.getElementsByTagName("img");if(this.a.href!=aE.href){return 0}if(j.length){return this.image.src==j[0].src}return(aE.innerText||aE.textContent)==this.text_original};c.SetImage=function(j){this.image=this.fimage=j};c.SetDraw=function(i){this.Draw=this.fimage?(i.ie>7?this.DrawImageIE:this.DrawImage):this.DrawText;i.noSelect&&(this.CheckActive=ax)};c.MeasureText=function(aH){var aF,aE=this.text.length,j=0,aG;for(aF=0;aF<aE;++aF){this.line_widths[aF]=aG=aH.measureText(this.text[aF]).width;j=s(j,aG)}return j};c.Measure=function(aJ,aM){var aK=t(this.text,this.textFont,this.textHeight),aN,i,aG,j,aE,aI,aL,aF,aH;aL=aK?aK.max.y+aK.min.y:this.textHeight;aJ.font=this.font=this.textHeight+"px "+this.textFont;aI=this.MeasureText(aJ);if(aM.txtOpt){aN=aM.txtScale;i=aN*this.textHeight;aG=i+"px "+this.textFont;j=[aN*aM.shadowOffset[0],aN*aM.shadowOffset[1]];aJ.font=aG;aE=this.MeasureText(aJ);aH=new g(this.text,aG,aE+aN,(aN*aL)+aN,aE,this.line_widths,aM.textAlign,aM.textVAlign,aN);if(this.image){aH.SetImage(this.image,this.iw,this.ih,aM.imagePosition,aM.imagePadding,aM.imageAlign,aM.imageVAlign,aM.imageScale)}aF=aH.Create(this.colour,this.bgColour,this.bgOutline,aN*this.bgOutlineThickness,aM.shadow,aN*aM.shadowBlur,j,aN*this.padding,aN*this.bgRadius);if(aM.outlineMethod=="colour"){this.oimage=aH.Create(aM.outlineColour,this.bgColour,aM.outlineColour,aN*this.bgOutlineThickness,aM.shadow,aN*aM.shadowBlur,j,aN*this.padding,aN*this.bgRadius)}else{if(aM.outlineMethod=="size"){aK=t(this.text,this.textFont,this.textHeight+aM.outlineIncrease);i=aK.max.y+aK.min.y;aG=(aN*(this.textHeight+aM.outlineIncrease))+"px "+this.textFont;aJ.font=aG;aE=this.MeasureText(aJ);aH=new g(this.text,aG,aE+aN,(aN*i)+aN,aE,this.line_widths,aM.textAlign,aM.textVAlign,aN);if(this.image){aH.SetImage(this.image,this.iw+aM.outlineIncrease,this.ih+aM.outlineIncrease,aM.imagePosition,aM.imagePadding,aM.imageAlign,aM.imageVAlign,aM.imageScale)}this.oimage=aH.Create(this.colour,this.bgColour,this.bgOutline,aN*this.bgOutlineThickness,aM.shadow,aN*aM.shadowBlur,j,aN*this.padding,aN*this.bgRadius);if(aM.outlineIncrease>0){aF=v(aF,this.oimage.width,this.oimage.height)}else{this.oimage=v(this.oimage,aF.width,aF.height)}}}if(aF){this.fimage=aF;aI=this.fimage.width/aN;aL=this.fimage.height/aN}this.SetDraw(aM);aM.txtOpt=!!this.fimage}this.h=aL;this.w=aI};c.SetFont=function(j,aF,aE,i){this.textFont=j;this.colour=aF;this.bgColour=aE;this.bgOutline=i;this.Measure(this.tc.ctxt,this.tc)};c.SetWeight=function(aE){var j=this.tc,aG=j.weightMode.split(/[, ]/),i,aF,aH=aE.length;if(!this.HasText()){return}this.weighted=true;for(aF=0;aF<aH;++aF){i=aG[aF]||"size";if("both"==i){this.Weight(aE[aF],j.ctxt,j,"size",j.min_weight[aF],j.max_weight[aF],aF);this.Weight(aE[aF],j.ctxt,j,"colour",j.min_weight[aF],j.max_weight[aF],aF)}else{this.Weight(aE[aF],j.ctxt,j,i,j.min_weight[aF],j.max_weight[aF],aF)}}this.Measure(j.ctxt,j)};c.Weight=function(aE,aJ,aF,j,aI,aG,aH){aE=isNaN(aE)?1:aE;var i=(aE-aI)/(aG-aI);if("colour"==j){this.colour=k(aF,i,aH)}else{if("bgcolour"==j){this.bgColour=k(aF,i,aH)}else{if("bgoutline"==j){this.bgOutline=k(aF,i,aH)}else{if("size"==j){if(aF.weightSizeMin>0&&aF.weightSizeMax>aF.weightSizeMin){this.textHeight=aF.weightSize*(aF.weightSizeMin+(aF.weightSizeMax-aF.weightSizeMin)*i)}else{this.textHeight=s(1,aE*aF.weightSize)}}}}}};c.SetShadowColourFixed=function(aE,j,i){aE.shadowColor=j};c.SetShadowColourAlpha=function(aE,j,i){aE.shadowColor=T(j,i)};c.DrawText=function(aG,aJ,aF){var aK=this.tc,aI=this.x,aH=this.y,aL=this.sc,j,aE;aG.globalAlpha=this.alpha;aG.fillStyle=this.colour;aK.shadow&&this.SetShadowColour(aG,aK.shadow,this.alpha);aG.font=this.font;aI+=aJ/aL;aH+=(aF/aL)-(this.h/2);for(j=0;j<this.text.length;++j){aE=aI;if("right"==aK.textAlign){aE+=this.w/2-this.line_widths[j]}else{if("centre"==aK.textAlign){aE-=this.line_widths[j]/2}else{aE-=this.w/2}}aG.setTransform(aL,0,0,aL,aL*aE,aL*aH);aG.fillText(this.text[j],0,0);aH+=this.textHeight}};c.DrawImage=function(aG,aN,aF,aI){var aK=this.x,aH=this.y,aO=this.sc,j=aI||this.fimage,aL=this.w,aE=this.h,aJ=this.alpha,aM=this.shadow;aG.globalAlpha=aJ;aM&&this.SetShadowColour(aG,aM,aJ);aK+=(aN/aO)-(aL/2);aH+=(aF/aO)-(aE/2);aG.setTransform(aO,0,0,aO,aO*aK,aO*aH);aG.drawImage(j,0,0,aL,aE)};c.DrawImageIE=function(aG,aK,aF){var j=this.fimage,aL=this.sc,aJ=j.width=this.w*aL,aE=j.height=this.h*aL,aI=(this.x*aL)+aK-(aJ/2),aH=(this.y*aL)+aF-(aE/2);aG.setTransform(1,0,0,1,0,0);aG.globalAlpha=this.alpha;aG.drawImage(j,aI,aH)};c.Calc=function(i,aE){var j,aH=this.tc,aG=aH.minBrightness,aF=aH.maxBrightness,aI=aH.max_radius;j=i.xform(this.position);this.xformed=j;j=U(aH,j,aH.stretchX,aH.stretchY);this.x=j.x;this.y=j.y;this.z=j.z;this.sc=j.w;this.alpha=aE*ar(aG+(aF-aG)*(aI-this.z)/(2*aI),0,1)};c.UpdateActive=function(aJ,aE,aH){var aG=this.outline,j=this.w,aF=this.h,i=this.x-j/2,aI=this.y-aF/2;aG.Update(i,aI,j,aF,this.sc,this.z,aE,aH);return aG};c.CheckActive=function(aG,i,aF){var j=this.tc,aE=this.UpdateActive(aG,i,aF);return aE.Active(aG,j.mx,j.my)?aE:null};c.Clicked=function(aH){var j=this.a,aE=j.target,aF=j.href,i;if(aE!=""&&aE!="_self"){if(self.frames[aE]){self.frames[aE].document.location=aF}else{try{if(top.frames[aE]){top.frames[aE].document.location=aF;return}}catch(aG){}window.open(aF,aE)}return}if(C.createEvent){i=C.createEvent("MouseEvents");i.initMouseEvent("click",1,1,window,0,0,0,0,0,0,0,0,0,0,null);if(!j.dispatchEvent(i)){return}}else{if(j.fireEvent){if(!j.fireEvent("onclick")){return}}}C.location=aF};function y(aK,j,aF){var aE,aH,aJ=C.getElementById(aK),aG=["id","class","innerHTML"],aI;if(!aJ){throw 0}if(ag(window.G_vmlCanvasManager)){aJ=window.G_vmlCanvasManager.initElement(aJ);this.ie=parseFloat(navigator.appVersion.split("MSIE")[1])}if(aJ&&(!aJ.getContext||!aJ.getContext("2d").fillText)){aH=C.createElement("DIV");for(aE=0;aE<aG.length;++aE){aH[aG[aE]]=aJ[aG[aE]]}aJ.parentNode.insertBefore(aH,aJ);aJ.parentNode.removeChild(aJ);throw 0}for(aE in y.options){this[aE]=aF&&ag(aF[aE])?aF[aE]:(ag(y[aE])?y[aE]:y.options[aE])}this.canvas=aJ;this.ctxt=aJ.getContext("2d");this.z1=250/this.depth;this.z2=this.z1/this.zoom;this.radius=aA(aJ.height,aJ.width)*0.0075;this.max_weight=[];this.min_weight=[];this.textFont=this.textFont&&o(this.textFont);this.textHeight*=1;this.pulsateTo=ar(this.pulsateTo,0,1);this.minBrightness=ar(this.minBrightness,0,1);this.maxBrightness=ar(this.maxBrightness,this.minBrightness,1);this.ctxt.textBaseline="top";this.lx=(this.lock+"").indexOf("x")+1;this.ly=(this.lock+"").indexOf("y")+1;this.frozen=this.dx=this.dy=this.fixedAnim=this.touched=0;this.fixedAlpha=1;this.source=j||aK;this.transform=Q.Identity();this.startTime=this.time=F();this.mx=this.my=-1;this.Animate=this.dragControl?this.AnimateDrag:this.AnimatePosition;this.animTiming=(typeof y[this.animTiming]=="function"?y[this.animTiming]:y.Smooth);if(this.shadowBlur||this.shadowOffset[0]||this.shadowOffset[1]){this.ctxt.shadowColor=this.shadow;this.shadow=this.ctxt.shadowColor;this.shadowAlpha=aj()}else{delete this.shadow}this.Load();if(j&&this.hideTags){(function(i){if(y.loaded){i.HideTags()}else{ab("load",function(){i.HideTags()},window)}})(this)}this.yaw=this.initial?this.initial[0]*this.maxSpeed:0;this.pitch=this.initial?this.initial[1]*this.maxSpeed:0;if(this.tooltip){this.ctitle=aJ.title;aJ.title="";if(this.tooltip=="native"){this.Tooltip=this.TooltipNative}else{this.Tooltip=this.TooltipDiv;if(!this.ttdiv){this.ttdiv=C.createElement("div");this.ttdiv.className=this.tooltipClass;this.ttdiv.style.position="absolute";this.ttdiv.style.zIndex=aJ.style.zIndex+1;ab("mouseover",function(i){i.target.style.display="none"},this.ttdiv);C.body.appendChild(this.ttdiv)}}}else{this.Tooltip=this.TooltipNone}if(!this.noMouse&&!b[aK]){b[aK]=[["mousemove",ad],["mouseout",B],["mouseup",aB],["touchstart",S],["touchend",r],["touchcancel",r],["touchmove",aw]];if(this.dragControl){b[aK].push(["mousedown",z]);b[aK].push(["selectstart",ax])}if(this.wheelZoom){b[aK].push(["mousewheel",ae]);b[aK].push(["DOMMouseScroll",ae])}for(aE=0;aE<b[aK].length;++aE){ab(b[aK][aE][0],b[aK][aE][1],aJ)}}if(!y.started){aI=window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;y.NextFrame=aI?y.NextFrameRAF:y.NextFrameTimeout;y.interval=this.interval;y.NextFrame(this.interval);y.started=1}}P=y.prototype;P.SourceElements=function(){if(C.querySelectorAll){return C.querySelectorAll("#"+this.source)}return[C.getElementById(this.source)]};P.HideTags=function(){var aE=this.SourceElements(),j;for(j=0;j<aE.length;++j){aE[j].style.display="none"}};P.GetTags=function(){var aI=this.SourceElements(),aH,aE=[],aG,aF;for(aG=0;aG<aI.length;++aG){aH=aI[aG].getElementsByTagName("a");for(aF=0;aF<aH.length;++aF){aE.push(aH[aF])}}return aE};P.Message=function(aJ){var aL=[],aF,j,aE=aJ.split(""),aH,aK,aI,aG;for(aF=0;aF<aE.length;++aF){if(aE[aF]!=" "){j=aF-aE.length/2;aH=C.createElement("A");aH.href="#";aH.innerText=aE[aF];aI=100*af(j/9);aG=-100*w(j/9);aK=new e(this,aE[aF],aH,[aI,0,aG],2,18,"#000","#fff",0,0,0,"monospace",2,aE[aF]);aK.Init();aL.push(aK)}}return aL};P.CreateTag=function(aI){var aL,aG,aM,aH,aK,aE,aJ,aF,j=[0,0,0];if("text"!=this.imageMode){aL=aI.getElementsByTagName("img");if(aL.length){aG=new Image;aG.src=aL[0].src;if(!this.imageMode){aM=new e(this,"",aI,j,0,0);aM.SetImage(aG);at(aG,aL[0],aM,this);return aM}}}if("image"!=this.imageMode){aK=new ay(aI);aH=aK.Lines();if(!aK.Empty()){aE=this.textFont||o(X(aI,"font-family"));if(this.splitWidth){aH=aK.SplitWidth(this.splitWidth,this.ctxt,aE,this.textHeight)}aJ=this.bgColour=="tag"?X(aI,"background-color"):this.bgColour;aF=this.bgOutline=="tag"?X(aI,"color"):this.bgOutline}else{aK=null}}if(aK||aG){aM=new e(this,aH,aI,j,2,this.textHeight+2,this.textColour||X(aI,"color"),aJ,this.bgRadius,aF,this.bgOutlineThickness,aE,this.padding,aK&&aK.original);if(aG){aM.SetImage(aG);at(aG,aL[0],aM,this)}else{aM.Init()}return aM}};P.UpdateTag=function(aE,i){var aH=this.textColour||X(i,"color"),j=this.textFont||o(X(i,"font-family")),aG=this.bgColour=="tag"?X(i,"background-color"):this.bgColour,aF=this.bgOutline=="tag"?X(i,"color"):this.bgOutline;aE.a=i;aE.title=i.title;if(aE.colour!=aH||aE.textFont!=j||aE.bgColour!=aG||aE.bgOutline!=aF){aE.SetFont(j,aH,aG,aF)}};P.Weight=function(aK){var aG=aK.length,aI,aE,aL,aH=[],j,aF=this.weightFrom?this.weightFrom.split(/[, ]/):[null],aJ=aF.length;for(aE=0;aE<aG;++aE){aH[aE]=[];for(aL=0;aL<aJ;++aL){aI=u(aK[aE].a,aF[aL],this.textHeight);if(!this.max_weight[aL]||aI>this.max_weight[aL]){this.max_weight[aL]=aI}if(!this.min_weight[aL]||aI<this.min_weight[aL]){this.min_weight[aL]=aI}aH[aE][aL]=aI}}for(aL=0;aL<aJ;++aL){if(this.max_weight[aL]>this.min_weight[aL]){j=1}}if(j){for(aE=0;aE<aG;++aE){aK[aE].SetWeight(aH[aE])}}};P.Load=function(){var aO=this.GetTags(),aJ=[],aM,aN,aI,aF,aE,j,aG,aL,aH=[],aK={sphere:q,vcylinder:ak,hcylinder:aq,vring:d,hring:n};if(aO.length){aH.length=aO.length;for(aL=0;aL<aO.length;++aL){aH[aL]=aL}this.shuffleTags&&al(aH);aF=100*this.radiusX;aE=100*this.radiusY;j=100*this.radiusZ;this.max_radius=s(aF,s(aE,j));for(aL=0;aL<aO.length;++aL){aN=this.CreateTag(aO[aH[aL]]);if(aN){aJ.push(aN)}}this.weight&&this.Weight(aJ,true);if(this.shapeArgs){this.shapeArgs[0]=aJ.length}else{aI=this.shape.toString().split(/[(),]/);aM=aI.shift();this.shape=aK[aM]||aK.sphere;this.shapeArgs=[aJ.length,aF,aE,j].concat(aI)}aG=this.shape.apply(this,this.shapeArgs);this.listLength=aJ.length;for(aL=0;aL<aJ.length;++aL){aJ[aL].position=new ac(aG[aL][0],aG[aL][1],aG[aL][2])}}if(this.noTagsMessage&&!aJ.length){aJ=this.Message("No tags")}this.taglist=aJ};P.Update=function(){var aN=this.GetTags(),aM=[],aH=this.taglist,aO,aL=[],aJ=[],aF,aK,aE,aI,aG;if(!this.shapeArgs){return this.Load()}if(aN.length){aE=this.listLength=aN.length;aK=aH.length;for(aI=0;aI<aK;++aI){aM.push(aH[aI]);aJ.push(aI)}for(aI=0;aI<aE;++aI){for(aG=0,aO=0;aG<aK;++aG){if(aH[aG].EqualTo(aN[aI])){this.UpdateTag(aM[aG],aN[aI]);aO=aJ[aG]=-1}}if(!aO){aL.push(aI)}}for(aI=0,aG=0;aI<aK;++aI){if(aJ[aG]==-1){aJ.splice(aG,1)}else{++aG}}if(aJ.length){al(aJ);while(aJ.length&&aL.length){aI=aJ.shift();aG=aL.shift();aM[aI]=this.CreateTag(aN[aG])}aJ.sort(function(j,i){return j-i});while(aJ.length){aM.splice(aJ.pop(),1)}}aG=aM.length/(aL.length+1);aI=0;while(aL.length){aM.splice(an(++aI*aG),0,this.CreateTag(aN[aL.shift()]))}this.shapeArgs[0]=aE=aM.length;aF=this.shape.apply(this,this.shapeArgs);for(aI=0;aI<aE;++aI){aM[aI].position=new ac(aF[aI][0],aF[aI][1],aF[aI][2])}this.weight&&this.Weight(aM)}this.taglist=aM};P.SetShadow=function(i){i.shadowBlur=this.shadowBlur;i.shadowOffsetX=this.shadowOffset[0];i.shadowOffsetY=this.shadowOffset[1]};P.Draw=function(aO){if(this.paused){return}var aI=this.canvas,aG=aI.width,aN=aI.height,aQ=0,aF=(aO-this.time)*y.interval/1000,aM=aG/2+this.offsetX,aL=aN/2+this.offsetY,aU=this.ctxt,aK,aV,aS,aE=-1,aH=this.taglist,aR=aH.length,j=this.frontSelect,aP=(this.centreFunc==ax),aJ;this.time=aO;if(this.frozen&&this.drawn){return this.Animate(aG,aN,aF)}aJ=this.AnimateFixed();aU.setTransform(1,0,0,1,0,0);for(aS=0;aS<aR;++aS){aH[aS].Calc(this.transform,this.fixedAlpha)}aH=A(aH,function(aW,i){return i.z-aW.z});if(aJ&&this.fixedAnim.active){aK=this.fixedAnim.tag.UpdateActive(aU,aM,aL)}else{this.active=null;for(aS=0;aS<aR;++aS){aV=this.mx>=0&&this.my>=0&&this.taglist[aS].CheckActive(aU,aM,aL);if(aV&&aV.sc>aQ&&(!j||aV.z<=0)){aK=aV;aE=aS;aK.tag=this.taglist[aS];aQ=aV.sc}}this.active=aK}this.txtOpt||(this.shadow&&this.SetShadow(aU));aU.clearRect(0,0,aG,aN);for(aS=0;aS<aR;++aS){if(!aP&&aH[aS].z<=0){try{this.centreFunc(aU,aG,aN,aM,aL)}catch(aT){alert(aT);this.centreFunc=ax}aP=true}if(!(aK&&aK.tag==aH[aS]&&aK.PreDraw(aU,aH[aS],aM,aL))){aH[aS].Draw(aU,aM,aL)}aK&&aK.tag==aH[aS]&&aK.PostDraw(aU)}if(this.freezeActive&&aK){this.Freeze()}else{this.UnFreeze();this.drawn=(aR==this.listLength)}if(this.fixedCallback){this.fixedCallback(this,this.fixedCallbackTag);this.fixedCallback=null}aJ||this.Animate(aG,aN,aF);aK&&aK.LastDraw(aU);aI.style.cursor=aK?this.activeCursor:"";this.Tooltip(aK,this.taglist[aE])};P.TooltipNone=function(){};P.TooltipNative=function(j,i){if(j){this.canvas.title=i&&i.title?i.title:""}else{this.canvas.title=this.ctitle}};P.SetTTDiv=function(aF,j){var i=this,aE=i.ttdiv.style;if(aF!=i.ttdiv.innerHTML){aE.display="none"}i.ttdiv.innerHTML=aF;j&&(j.title=i.ttdiv.innerHTML);if(aE.display=="none"&&!i.tttimer){i.tttimer=setTimeout(function(){var aG=aa(i.canvas.id);aE.display="block";aE.left=aG.x+i.mx+"px";aE.top=aG.y+i.my+24+"px";i.tttimer=null},i.tooltipDelay)}};P.TooltipDiv=function(j,i){if(j&&i&&i.title){this.SetTTDiv(i.title,i)}else{if(!j&&this.mx!=-1&&this.my!=-1&&this.ctitle.length){this.SetTTDiv(this.ctitle)}else{this.ttdiv.style.display="none"}}};P.Transform=function(aH,i,aJ){if(i||aJ){var j=af(i),aI=w(i),aK=af(aJ),aG=w(aJ),aE=new Q([aG,0,aK,0,1,0,-aK,0,aG]),aF=new Q([1,0,0,0,aI,-j,0,j,aI]);aH.transform=aH.transform.mul(aE.mul(aF))}};P.AnimateFixed=function(){var aE,j,aG,i,aF;if(this.fadeIn){j=F()-this.startTime;if(j>=this.fadeIn){this.fadeIn=0;this.fixedAlpha=1}else{this.fixedAlpha=j/this.fadeIn}}if(this.fixedAnim){if(!this.fixedAnim.transform){this.fixedAnim.transform=this.transform}aE=this.fixedAnim,j=F()-aE.t0,aG=aE.angle,i,aF=this.animTiming(aE.t,j);this.transform=aE.transform;if(j>=aE.t){this.fixedCallbackTag=aE.tag;this.fixedCallback=aE.cb;this.fixedAnim=this.yaw=this.pitch=0}else{aG*=aF}i=Q.Rotation(aG,aE.axis);this.transform=this.transform.mul(i);return(this.fixedAnim!=0)}return false};P.AnimatePosition=function(aE,aH,aF){var j=this,i=j.mx,aJ=j.my,aG,aI;if(!j.frozen&&i>=0&&aJ>=0&&i<aE&&aJ<aH){aG=j.maxSpeed,aI=j.reverse?-1:1;j.lx||(j.yaw=((i*2*aG/aE)-aG)*aI*aF);j.ly||(j.pitch=((aJ*2*aG/aH)-aG)*-aI*aF);j.initial=null}else{if(!j.initial){if(j.frozen&&!j.freezeDecel){j.yaw=j.pitch=0}else{j.Decel(j)}}}this.Transform(j,j.pitch,j.yaw)};P.AnimateDrag=function(j,aG,aF){var i=this,aE=100*aF*i.maxSpeed/i.max_radius/i.zoom;if(i.dx||i.dy){i.lx||(i.yaw=i.dx*aE/i.stretchX);i.ly||(i.pitch=i.dy*-aE/i.stretchY);i.dx=i.dy=0;i.initial=null}else{if(!i.initial){i.Decel(i)}}this.Transform(i,i.pitch,i.yaw)};P.Freeze=function(){if(!this.frozen){this.preFreeze=[this.yaw,this.pitch];this.frozen=1;this.drawn=0}};P.UnFreeze=function(){if(this.frozen){this.yaw=this.preFreeze[0];this.pitch=this.preFreeze[1];this.frozen=0}};P.Decel=function(i){var aE=i.minSpeed,aF=K(i.yaw),j=K(i.pitch);if(!i.lx&&aF>aE){i.yaw=aF>i.z0?i.yaw*i.decel:0}if(!i.ly&&j>aE){i.pitch=j>i.z0?i.pitch*i.decel:0}};P.Zoom=function(i){this.z2=this.z1*(1/i);this.drawn=0};P.Clicked=function(aE){var i=this.active;try{if(i&&i.tag){if(this.clickToFront===false||this.clickToFront===null){i.tag.Clicked(aE)}else{this.TagToFront(i.tag,this.clickToFront,function(){i.tag.Clicked(aE)},true)}}}catch(j){}};P.Wheel=function(j){var aE=this.zoom+this.zoomStep*(j?1:-1);this.zoom=aA(this.zoomMax,s(this.zoomMin,aE));this.Zoom(this.zoom)};P.BeginDrag=function(i){this.down=R(i,this.canvas);i.cancelBubble=true;i.returnValue=false;i.preventDefault&&i.preventDefault()};P.Drag=function(aG,aF){if(this.dragControl&&this.down){var aE=this.dragThreshold*this.dragThreshold,j=aF.x-this.down.x,i=aF.y-this.down.y;if(this.dragging||j*j+i*i>aE){this.dx=j;this.dy=i;this.dragging=1;this.down=aF}}};P.EndDrag=function(){var i=this.dragging;this.dragging=this.down=null;return i};P.Pause=function(){this.paused=true};P.Resume=function(){this.paused=false};P.SetSpeed=function(j){this.initial=j;this.yaw=j[0]*this.maxSpeed;this.pitch=j[1]*this.maxSpeed};P.FindTag=function(aE){if(!ag(aE)){return null}ag(aE.index)&&(aE=aE.index);if(!H(aE)){return this.taglist[aE]}var aF,aG,j;if(ag(aE.id)){aF="id",aG=aE.id}else{if(ag(aE.text)){aF="innerText",aG=aE.text}}for(j=0;j<this.taglist.length;++j){if(this.taglist[j].a[aF]==aG){return this.taglist[j]}}};P.RotateTag=function(aM,aF,aL,i,aJ,aE){var aK=aM.xformed,aH=new ac(aK.x,aK.y,aK.z),aG=ah(aL,aF),j=aH.angle(aG),aI=aH.cross(aG).unit();if(j==0){this.fixedCallbackTag=aM;this.fixedCallback=aJ}else{this.fixedAnim={angle:-j,axis:aI,t:i,t0:F(),cb:aJ,tag:aM,active:aE}}};P.TagToFront=function(i,aE,aF,j){this.RotateTag(i,0,0,aE,aF,j)};y.Start=function(aE,i,j){y.Delete(aE);y.tc[aE]=new y(aE,i,j)};function av(i,j){y.tc[j]&&y.tc[j][i]()}y.Linear=function(i,j){return j/i};y.Smooth=function(i,j){return 0.5-w(j*Math.PI/i)/2};y.Pause=function(i){av("Pause",i)};y.Resume=function(i){av("Resume",i)};y.Reload=function(i){av("Load",i)};y.Update=function(i){av("Update",i)};y.SetSpeed=function(j,i){if(H(i)&&y.tc[j]&&!isNaN(i[0])&&!isNaN(i[1])){y.tc[j].SetSpeed(i);return true}return false};y.TagToFront=function(j,i){if(!H(i)){return false}i.lat=i.lng=0;return y.RotateTag(j,i)};y.RotateTag=function(aE,i){if(H(i)&&y.tc[aE]){if(isNaN(i.time)){i.time=500}var j=y.tc[aE].FindTag(i);if(j){y.tc[aE].RotateTag(j,i.lat,i.lng,i.time,i.callback,i.active);return true}}return false};y.Delete=function(aF){var j,aE;if(b[aF]){aE=C.getElementById(aF);if(aE){for(j=0;j<b[aF].length;++j){a(b[aF][j][0],b[aF][j][1],aE)}}}delete b[aF];delete y.tc[aF]};y.NextFrameRAF=function(){requestAnimationFrame(D)};y.NextFrameTimeout=function(i){setTimeout(N,i)};y.tc={};y.options={z1:20000,z2:20000,z0:0.0002,freezeActive:false,freezeDecel:false,activeCursor:"pointer",pulsateTo:1,pulsateTime:3,reverse:false,depth:0.5,maxSpeed:0.05,minSpeed:0,decel:0.95,interval:20,minBrightness:0.1,maxBrightness:1,outlineColour:"#ffff99",outlineThickness:2,outlineOffset:5,outlineMethod:"outline",outlineRadius:0,textColour:"#ff99ff",textHeight:15,textFont:"Helvetica, Arial, sans-serif",shadow:"#000",shadowBlur:0,shadowOffset:[0,0],initial:null,hideTags:true,zoom:1,weight:false,weightMode:"size",weightFrom:null,weightSize:1,weightSizeMin:null,weightSizeMax:null,weightGradient:{0:"#f00",0.33:"#ff0",0.66:"#0f0",1:"#00f"},txtOpt:true,txtScale:2,frontSelect:false,wheelZoom:true,zoomMin:0.3,zoomMax:3,zoomStep:0.05,shape:"sphere",lock:null,tooltip:null,tooltipDelay:300,tooltipClass:"tctooltip",radiusX:1,radiusY:1,radiusZ:1,stretchX:1,stretchY:1,offsetX:0,offsetY:0,shuffleTags:false,noSelect:false,noMouse:false,imageScale:1,paused:false,dragControl:false,dragThreshold:4,centreFunc:ax,splitWidth:0,animTiming:"Smooth",clickToFront:false,fadeIn:0,padding:0,bgColour:null,bgRadius:0,bgOutline:null,bgOutlineThickness:0,outlineIncrease:4,textAlign:"centre",textVAlign:"middle",imageMode:null,imagePosition:null,imagePadding:2,imageAlign:"centre",imageVAlign:"middle",noTagsMessage:true};for(L in y.options){y[L]=y.options[L]}window.TagCanvas=y;jQuery.fn.tagcanvas=function(j,i){var aE={pause:function(){am(this).each(function(){av("Pause",am(this)[0].id)})},resume:function(){am(this).each(function(){av("Resume",am(this)[0].id)})},reload:function(){am(this).each(function(){av("Load",am(this)[0].id)})},update:function(){am(this).each(function(){av("Update",am(this)[0].id)})},tagtofront:function(){am(this).each(function(){y.TagToFront(am(this)[0].id,i)})},rotatetag:function(){am(this).each(function(){y.RotateTag(am(this)[0].id,i)})},"delete":function(){am(this).each(function(){y.Delete(am(this)[0].id)})},setspeed:function(){am(this).each(function(){y.SetSpeed(am(this)[0].id,i)})}};if(typeof j=="string"&&aE[j]){aE[j].apply(this);return this}else{y.jquery=1;am(this).each(function(){y.Start(am(this)[0].id,i,j)});return y.started}};ab("load",function(){y.loaded=1},window)})(jQuery);