]> Creatis software - creaWT.git/commitdiff
#Fast CGI configuration
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 5 Aug 2015 13:44:39 +0000 (15:44 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 5 Aug 2015 13:44:39 +0000 (15:44 +0200)
wt/appli/CMakeLists.txt
wt/data/infoConf_server_fcgi/Readme.txt [new file with mode: 0644]
wt/data/infoConf_server_fcgi/Readme.txt~ [new file with mode: 0644]
wt/data/infoConf_server_fcgi/bbiWeb.php [new file with mode: 0644]
wt/data/infoConf_server_fcgi/bbtk.conf [new file with mode: 0644]
wt/data/infoConf_server_fcgi/fastcgi-wt.conf [new file with mode: 0644]
wt/data/reosurcesXTK/styleWT.css [new file with mode: 0644]
wt/data/reosurcesXTK/xtk.js [new file with mode: 0644]
wt/data/reosurcesXTK/xtk_xdat.gui.js [new file with mode: 0644]

index 8f6fdf4cbc187a7c092223854e94a8897718ddff..87b79a8ec81f0e03e43cc05cff72da5f2908f3b6 100644 (file)
@@ -28,3 +28,4 @@
 # ADD_SUBDIRECTORY(MyApp1)
 # ADD_SUBDIRECTORY(MyApp2)
 ADD_SUBDIRECTORY(myFierceAppli)
+
diff --git a/wt/data/infoConf_server_fcgi/Readme.txt b/wt/data/infoConf_server_fcgi/Readme.txt
new file mode 100644 (file)
index 0000000..442ef99
--- /dev/null
@@ -0,0 +1,119 @@
+
+As root or with sudo command:
+
+0)
+yum install fcgi-devel
+yum install mod_fcgid
+
+1) ld configuration
+cp bbtk.conf/etc/ld.so.conf.d/.
+ldconfig
+
+2) Create virtual site apache
+mkdir /var/www/testwtdbg
+mkdir /var/www/testwtdbg/docroot
+
+<rootBbtkWt> = /var/www/testwtdbg/docroot
+
+
+3)  Apache configuration
+cp fastcgi-wt.conf /etc/httpd/conf.modules.d/.
+service httpd restart
+
+4) wt temporary diractory
+mkdir /run/wt
+chown apache:apache /run/wt
+
+5) Prepare wt application site 
+
+mkdir <rootBbtkWt>/<appliBtkWt>
+mkdir <rootBbtkWt>/<appliBtkWt>/imagesTMP
+cp bbiWeb.php <rootBbtkWt>/<appliBtkWt>/.
+ln -s <INSTALATION_WT>/share/Wt/resources <rootBbtkWt>/<appliBbtkWt>/resources
+ln -s <INSTALATION_creaWT>/wt/data/reosurcesXTK <rootBbtkWt>/resourcesXTK
+ln -s <INSTALATION_BBTK>/bin/bbiWeb.wt <rootBbtkWt>/bbiWeb.wt
+
+
+6) Call application from browser
+http://localhost/<appliBbtkWt>/bbiWeb.php
+
+
+
+
+------------------------------------------------------
+
+Genaral Notes:
+--------------
+
+http://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache
+
+https://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-fedora-13
+
+.OK.
+http://redmine.webtoolkit.eu/projects/wt/wiki/Wt_+_Apache_+_mod_fcgid_+_Valgrind_+_gdb_+_SELinux_-_Deploy_and_Debug
+
+0) Fast CGI (FCGI) devel+apache:
+yum install fcgi-devel
+yum install mod_fcgid
+
+wtBin  -> ccmake -> 
+  CONNECTOR_FCGI ON
+  CONNECTOR_FCGI ON
+  ENABLE_EXT
+make -j8
+wtBin cmake -DEXAMPLES_CONNECTOR="wtfcgi" .
+make -C examples -j8
+
+
+
+
+FastCGI configuration:
+/etc/httpd/conf.modules.d/fastcgi-wt.conf     
+
+
+Configuration LD_libray_path  for all users
+1)
+/etc/ld.so.conf.d/bbtk.conf
+  /tmpEED/Creatis/creaTools/creatools_install/lib64/creatools
+  /tmpEED/tplI/lib/wt-3.3.4
+  /tmpEED/tplI/lib/gdcm
+  /tmpEED/tplI/lib/InsightToolkit
+  /tmpEED/tplI/lib/vtk-5.10
+2)
+Luego ejecutar> ldconfig 
+
+Appache
+ service httpd start
+ service httpd stop
+ service httpd restart
+
+See errors:
+  systemctl status httpd.service
+ /etc/httpd/logs/
+
+
+
+
+
+-------
+
+
+wt
+http://www.webtoolkit.eu/widgets
+
+
+
+---
+
+php
+-system ou exec  ??:
+http://php.net/manual/fr/function.system.php
+
+-Redirect a page:
+http://www.apprendre-php.com/tutoriels/tutoriel-15-faire-une-redirection-vers-une-autre-page.html
+
+-unique Id
+http://php.net/manual/fr/function.uniqid.php
+
+
+
diff --git a/wt/data/infoConf_server_fcgi/Readme.txt~ b/wt/data/infoConf_server_fcgi/Readme.txt~
new file mode 100644 (file)
index 0000000..148d4a5
--- /dev/null
@@ -0,0 +1,120 @@
+
+As root or with sudo command:
+
+0)
+yum install fcgi-devel
+yum install mod_fcgid
+
+1) ld configuration
+cp bbtk.conf/etc/ld.so.conf.d/.
+ldconfig
+
+2) Create virtual site apache
+mkdir /var/www/testwtdbg
+mkdir /var/www/testwtdbg/docroot
+
+<rootBbtkWt> = /var/www/testwtdbg/docroot
+
+
+3)  Apache configuration
+cp fastcgi-wt.conf /etc/httpd/conf.modules.d/.
+service httpd restart
+
+4) wt temporary diractory
+mkdir /run/wt
+chown apache:apache /run/wt
+
+5) Prepare wt application site 
+
+mkdir <rootBbtkWt>/<appliBtkWt>
+mkdir <rootBbtkWt>/<appliBtkWt>/imagesTMP
+cp bbiWeb.php <rootBbtkWt>/<appliBtkWt>/.
+ln -s <INSTALATION_WT>/share/Wt/resources <rootBbtkWt>/<appliBbtkWt>/resources
+ln -s <INSTALATION_creaWT>/wt/data/reosurcesXTK <rootBbtkWt>/resourcesXTK
+ln -s <INSTALATION_BBTK>/bin/bbiWeb.wt <rootBbtkWt>/bbiWeb.wt
+
+
+6) Call application from browser
+http://localhost/<appliBbtkWt>/bbiWeb.php
+
+
+
+
+------------------------------------------------------
+
+Genaral Notes:
+--------------
+
+http://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache
+
+https://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-fedora-13
+
+.OK.
+http://redmine.webtoolkit.eu/projects/wt/wiki/Wt_+_Apache_+_mod_fcgid_+_Valgrind_+_gdb_+_SELinux_-_Deploy_and_Debug
+
+0) Fast CGI (FCGI) devel+apache:
+yum install fcgi-devel
+yum install mod_fcgid
+
+wtBin  -> ccmake -> 
+  CONNECTOR_FCGI ON
+  CONNECTOR_FCGI ON
+  ENABLE_EXT
+make -j8
+wtBin cmake -DEXAMPLES_CONNECTOR="wtfcgi" .
+make -C examples -j8
+
+
+
+Creados por EED
+
+FastCGI configuration:
+/etc/httpd/conf.modules.d/fastcgi-wt.conf     
+
+
+Configuration LD_libray_path  for all users
+1)
+/etc/ld.so.conf.d/bbtk.conf
+  /tmpEED/Creatis/creaTools/creatools_install/lib64/creatools
+  /tmpEED/tplI/lib/wt-3.3.4
+  /tmpEED/tplI/lib/gdcm
+  /tmpEED/tplI/lib/InsightToolkit
+  /tmpEED/tplI/lib/vtk-5.10
+2)
+Luego ejecutar> ldconfig 
+
+Appache
+ service httpd start
+ service httpd stop
+ service httpd restart
+
+See errors:
+  systemctl status httpd.service
+ /etc/httpd/logs/
+
+
+
+
+
+-------
+
+
+wt
+http://www.webtoolkit.eu/widgets
+
+
+
+---
+
+php
+-system ou exec  ??:
+http://php.net/manual/fr/function.system.php
+
+-Redirect a page:
+http://www.apprendre-php.com/tutoriels/tutoriel-15-faire-une-redirection-vers-une-autre-page.html
+
+-unique Id
+http://php.net/manual/fr/function.uniqid.php
+
+
+
diff --git a/wt/data/infoConf_server_fcgi/bbiWeb.php b/wt/data/infoConf_server_fcgi/bbiWeb.php
new file mode 100644 (file)
index 0000000..23c7f39
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+ $fileNameId=uniqid('bbiWeb_').'.wt';
+ $last_line = system('ln -s bbiWeb.wt '.$fileNameId, $retval);
+ header('Location: '.$fileNameId);
+ exit;
+?> 
+;
diff --git a/wt/data/infoConf_server_fcgi/bbtk.conf b/wt/data/infoConf_server_fcgi/bbtk.conf
new file mode 100644 (file)
index 0000000..72bbca3
--- /dev/null
@@ -0,0 +1,6 @@
+/tmpEED/Creatis/creaTools/creatools_install/lib64/creatools
+/tmpEED/tplI/lib/wt-3.3.4
+/tmpEED/tplI/lib/gdcm
+/tmpEED/tplI/lib/InsightToolkit
+/tmpEED/tplI/lib/vtk-5.10
+
diff --git a/wt/data/infoConf_server_fcgi/fastcgi-wt.conf b/wt/data/infoConf_server_fcgi/fastcgi-wt.conf
new file mode 100644 (file)
index 0000000..573ba11
--- /dev/null
@@ -0,0 +1,29 @@
+<IfModule mod_fcgid.c>
+    NameVirtualHost *:80
+    # [+] For debugging.
+    FcgidMaxProcesses 30
+    # [-] For debugging.
+    <VirtualHost *:80>
+        # Add this servername into the /etc/hosts file.
+        ServerName www.testwtdbg.com
+        ServerAlias testwtdbg.com
+        DocumentRoot /var/www/testwtdbg/docroot
+        AddHandler fcgid-script wt
+        DirectoryIndex testwtdbg.wt
+        <Directory /var/www/testwtdbg/docroot>
+            Order Deny,Allow
+            Allow from all
+            Options +ExecCGI -Indexes
+        </Directory>
+        FcgidInitialEnv WT_APP_ROOT /var/www/testwtdbg/approot/
+
+        # [+] For debugging.
+        # Increase timeout of application process for debugging.
+        FcgidIOTimeout 300
+        FcgidConnectTimeout 300
+        # Reduce the number of processes spawned to 1 so that it is easy for debugging.
+        FcgidMaxProcessesPerClass 1
+        FcgidMinProcessesPerClass 1
+        # [-] For debugging.
+    </VirtualHost>
+</IfModule>
diff --git a/wt/data/reosurcesXTK/styleWT.css b/wt/data/reosurcesXTK/styleWT.css
new file mode 100644 (file)
index 0000000..85a7d47
--- /dev/null
@@ -0,0 +1,27 @@
+.yellow-box {
+    background-color: #ffffb4;
+    border: 1px solid black;
+    margin-top: 1ex;
+    margin-bottom: 1ex;
+}
+
+.green-box {
+    background-color: #c4ffb4;
+    min-height: 30px;
+    text-align: center;
+    padding: 3px;
+}
+
+.blue-box {
+    background-color: #65dae8;
+    min-height: 30px;
+    text-align: center;
+    padding: 3px;
+}
+
+.black-box {
+    background-color: #000000;
+    min-height: 30px;
+    text-align: center;
+    padding: 3px;
+}
diff --git a/wt/data/reosurcesXTK/xtk.js b/wt/data/reosurcesXTK/xtk.js
new file mode 100644 (file)
index 0000000..4bac033
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * 
+ *                  xxxxxxx      xxxxxxx
+ *                   x:::::x    x:::::x 
+ *                    x:::::x  x:::::x  
+ *                     x:::::xx:::::x   
+ *                      x::::::::::x    
+ *                       x::::::::x     
+ *                       x::::::::x     
+ *                      x::::::::::x    
+ *                     x:::::xx:::::x   
+ *                    x:::::x  x:::::x  
+ *                   x:::::x    x:::::x 
+ *              THE xxxxxxx      xxxxxxx TOOLKIT
+ *                    
+ *                  http://www.goXTK.com
+ *                   
+ * Copyright (c) 2012 The X Toolkit Developers <dev@goXTK.com>
+ *                   
+ *    The X Toolkit (XTK) is licensed under the MIT License:
+ *      http://www.opensource.org/licenses/mit-license.php
+ * 
+ *      "Free software" is a matter of liberty, not price.
+ *      "Free" as in "free speech", not as in "free beer".
+ *                                         - Richard M. Stallman
+ * 
+ * FUELED BY:
+ *  - the wonderful Constructive Solid Geometry library by Evan Wallace (http://madebyevan.com)
+ *    LICENSE: https://raw.github.com/xtk/X/master/lib/csg/LICENSE
+ *
+ *  - parts of the Google Closure Library (http://code.google.com/closure/library)
+ *    LICENSE: https://raw.github.com/xtk/google-closure-library/master/LICENSE
+ *
+ *  - zlib.js, the ultimate gzip/zlib javascript implementation (https://github.com/imaya/zlib.js)
+ *    LICENSE: https://raw.github.com/imaya/zlib.js/master/LICENSE
+ *
+ * MORE CREDITS: https://raw.github.com/xtk/X/master/LICENSE
+ *
+ */
+function m(a){throw a;}var p=void 0,q=!0,t=null,u=!1;function aa(){return function(){}}function ca(a){return function(b){this[a]=b}}function v(a){return function(){return this[a]}}var w,fa=this;function ga(){}
+function ha(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
+else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ia(a){return a!==p}function ja(a){return"array"==ha(a)}function ma(a){var b=ha(a);return"array"==b||"object"==b&&"number"==typeof a.length}function na(a){return"string"==typeof a}function x(a){return"number"==typeof a}function oa(a){return"function"==ha(a)}function pa(a){var b=typeof a;return"object"==b&&a!=t||"function"==b}function qa(a){return a[ra]||(a[ra]=++sa)}var ra="closure_uid_"+(1E9*Math.random()>>>0),sa=0;
+function ta(a,b,c){return a.call.apply(a.bind,arguments)}function ua(a,b,c){a||m(Error());if(2<arguments.length){var e=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,e);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function va(a,b,c){va=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ta:ua;return va.apply(t,arguments)}
+function wa(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=Array.prototype.slice.call(arguments);b.unshift.apply(b,c);return a.apply(this,b)}}var xa=Date.now||function(){return+new Date};function A(a,b){var c=a.split("."),e=fa;!(c[0]in e)&&e.execScript&&e.execScript("var "+c[0]);for(var d;c.length&&(d=c.shift());)!c.length&&ia(b)?e[d]=b:e=e[d]?e[d]:e[d]={}}
+function C(a,b){function c(){}c.prototype=b.prototype;a.u=b.prototype;a.prototype=new c;a.prototype.constructor=a};function ya(a,b,c){this.Za=this.Ya=this.Xa=0;3==arguments.length?(this.Xa=Number(a),this.Ya=Number(b),this.Za=Number(c)):a instanceof ya?(this.Xa=Number(a.x()),this.Ya=Number(a.y()),this.Za=Number(a.d())):(this.Xa=Number(a[0]),this.Ya=Number(a[1]),this.Za=Number(a[2]))}
+ya.prototype={l:function(){return new ya(this.Xa,this.Ya,this.Za)},ac:function(a){return this.Xa*a.x()+this.Ya*a.y()+this.Za*a.d()},se:function(a,b){return za(this,Aa(Ca(a,this),b))},length:function(){return Math.sqrt(this.ac(this))},sc:function(a){return new ya(this.Ya*a.d()-this.Za*a.y(),this.Za*a.x()-this.Xa*a.d(),this.Xa*a.y()-this.Ya*a.x())},x:v("Xa"),y:v("Ya"),d:v("Za")};function Da(a){var b=a.length();return new ya(a.Xa/b,a.Ya/b,a.Za/b)}
+function Aa(a,b){return new ya(a.Xa*b,a.Ya*b,a.Za*b)}function Ca(a,b){return new ya(a.Xa-b.x(),a.Ya-b.y(),a.Za-b.d())}function za(a,b){return new ya(a.Xa+b.x(),a.Ya+b.y(),a.Za+b.d())}function Ea(a){return new ya(-a.Xa,-a.Ya,-a.Za)};var D=D||{};D.zk=q;D.Ja=function(a){eval("X.DEV === undefined")||window.console.time(a)};D.Da=function(a){eval("X.DEV === undefined")||window.console.timeEnd(a)};window["X.counter"]=new function(){this.Wh=0;this.qk=function(){return this.Wh++}};function Fa(a,b){for(var c in b){var e=b.__lookupGetter__(c),d=b.__lookupSetter__(c);c in a||(e||d?(e&&a.__defineGetter__(c,e),d&&a.__defineSetter__(c,d)):a[c]=b[c])}}var Ha=window.Lh;
+Function.prototype.bind||(Function.prototype.bind=function(a){function b(){return f.apply(this instanceof c?this:a||window,d.concat(e.call(arguments)))}function c(){}"function"!==typeof this&&m(new TypeError("Function.prototype.bind - what is trying to be bound is not callable"));var e=Array.prototype.slice,d=e.call(arguments,1),f=this;c.prototype=this.prototype;b.prototype=new c;return b});
+for(var Ia=0,Ja=["ms","moz","webkit","o"],Ka=0;Ka<Ja.length&&!window.requestAnimationFrame;++Ka)window.requestAnimationFrame=window[Ja[Ka]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[Ja[Ka]+"CancelAnimationFrame"]||window[Ja[Ka]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(a){var b=Date.now(),c=Math.max(0,16-(b-Ia)),e=window.setTimeout(function(){a(b+c)},c);Ia=b+c;return e});
+window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)});
+"slice"in ArrayBuffer.prototype||(ArrayBuffer.prototype.slice=function(a,b){a===p&&m(Error("Not enough arguments."));var c=b||this.byteLength;0>a&&(a=this.byteLength+a);0>c&&(c=this.byteLength+c);c<a&&(c=a=0);0>a&&(a=0);0>c&&(c=0);a>this.byteLength&&(a=this.byteLength);c>this.byteLength&&(c=this.byteLength);for(var e=new ArrayBuffer(c-a),d=new Uint8Array(this),f=new Uint8Array(e),g=a,h=0;g<c;++g,++h)f[h]=d[g];return e});A("$",Ha);A("Function.prototype.bind",Function.prototype.bind);
+A("window.requestAnimationFrame",window.requestAnimationFrame);A("window.cancelAnimationFrame",window.cancelAnimationFrame);var La=0;function Ma(){}w=Ma.prototype;w.key=0;w.xc=u;w.ie=u;w.Ca=function(a,b,c,e,d,f){oa(a)?this.Ug=q:a&&a.handleEvent&&oa(a.handleEvent)?this.Ug=u:m(Error("Invalid listener argument"));this.bc=a;this.oh=b;this.src=c;this.type=e;this.capture=!!d;this.uf=f;this.ie=u;this.key=++La;this.xc=u};w.handleEvent=function(a){return this.Ug?this.bc.call(this.uf||this.src,a):this.bc.handleEvent.call(this.bc,a)};function Na(a,b){for(var c in a)b.call(p,a[c],c,a)}function Oa(a){var b=[],c=0,e;for(e in a)b[c++]=a[e];return b}var Pa="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Qa(a,b){for(var c,e,d=1;d<arguments.length;d++){e=arguments[d];for(c in e)a[c]=e[c];for(var f=0;f<Pa.length;f++)c=Pa[f],Object.prototype.hasOwnProperty.call(e,c)&&(a[c]=e[c])}};function Ra(a){if(!Sa.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(Ta,"&amp;"));-1!=a.indexOf("<")&&(a=a.replace(Ua,"&lt;"));-1!=a.indexOf(">")&&(a=a.replace(Va,"&gt;"));-1!=a.indexOf('"')&&(a=a.replace(Wa,"&quot;"));return a}var Ta=/&/g,Ua=/</g,Va=/>/g,Wa=/\"/g,Sa=/[&<>\"]/;var Xa,Ya,Za,$a,ab,bb,db;function eb(){return fa.navigator?fa.navigator.userAgent:t}function fb(){return fa.navigator}$a=Za=Ya=Xa=u;var gb;if(gb=eb()){var hb=fb();Xa=0==gb.indexOf("Opera");Ya=!Xa&&-1!=gb.indexOf("MSIE");Za=!Xa&&-1!=gb.indexOf("WebKit");$a=!Xa&&!Za&&"Gecko"==hb.product}var ib=Xa,K=Ya,jb=$a,lb=Za,mb,pb=fb();mb=pb&&pb.platform||"";ab=-1!=mb.indexOf("Mac");bb=-1!=mb.indexOf("Win");db=-1!=mb.indexOf("Linux");var qb=!!fb()&&-1!=(fb().appVersion||"").indexOf("X11");
+function rb(){var a=fa.document;return a?a.documentMode:p}var sb;a:{var wb="",xb;if(ib&&fa.opera)var yb=fa.opera.version,wb="function"==typeof yb?yb():yb;else if(jb?xb=/rv\:([^\);]+)(\)|;)/:K?xb=/MSIE\s+([^\);]+)(\)|;)/:lb&&(xb=/WebKit\/(\S+)/),xb)var zb=xb.exec(eb()),wb=zb?zb[1]:"";if(K){var Ab=rb();if(Ab>parseFloat(wb)){sb=String(Ab);break a}}sb=wb}var Bb={};
+function Cb(a){var b;if(!(b=Bb[a])){b=0;for(var c=String(sb).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=Math.max(c.length,e.length),f=0;0==b&&f<d;f++){var g=c[f]||"",h=e[f]||"",l=RegExp("(\\d*)(\\D*)","g"),j=RegExp("(\\d*)(\\D*)","g");do{var k=l.exec(g)||["","",""],n=j.exec(h)||["","",""];if(0==k[0].length&&0==n[0].length)break;b=((0==k[1].length?0:parseInt(k[1],10))<(0==n[1].length?0:parseInt(n[1],10))?-1:(0==k[1].length?0:parseInt(k[1],
+10))>(0==n[1].length?0:parseInt(n[1],10))?1:0)||((0==k[2].length)<(0==n[2].length)?-1:(0==k[2].length)>(0==n[2].length)?1:0)||(k[2]<n[2]?-1:k[2]>n[2]?1:0)}while(0==b)}b=Bb[a]=0<=b}return b}var Db=fa.document,Eb=!Db||!K?p:rb()||("CSS1Compat"==Db.compatMode?parseInt(sb,10):5);var Fb=!K||K&&9<=Eb,Gb=K&&!Cb("9");!lb||Cb("528");jb&&Cb("1.9b")||K&&Cb("8")||ib&&Cb("9.5")||lb&&Cb("528");jb&&!Cb("8")||K&&Cb("9");var Hb=Array.prototype,Ib=Hb.indexOf?function(a,b,c){return Hb.indexOf.call(a,b,c)}:function(a,b,c){c=c==t?0:0>c?Math.max(0,a.length+c):c;if(na(a))return!na(b)||1!=b.length?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},Jb=Hb.forEach?function(a,b,c){Hb.forEach.call(a,b,c)}:function(a,b,c){for(var e=a.length,d=na(a)?a.split(""):a,f=0;f<e;f++)f in d&&b.call(c,d[f],f,a)},Lb=Hb.map?function(a,b,c){return Hb.map.call(a,b,c)}:function(a,b,c){for(var e=a.length,d=Array(e),f=
+na(a)?a.split(""):a,g=0;g<e;g++)g in f&&(d[g]=b.call(c,f[g],g,a));return d},Mb=Hb.some?function(a,b,c){return Hb.some.call(a,b,c)}:function(a,b,c){for(var e=a.length,d=na(a)?a.split(""):a,f=0;f<e;f++)if(f in d&&b.call(c,d[f],f,a))return q;return u};function Nb(a,b){var c=Ib(a,b);0<=c&&Hb.splice.call(a,c,1)}function Ob(a,b,c){return 2>=arguments.length?Hb.slice.call(a,b):Hb.slice.call(a,b,c)};function Pb(){0!=Qb&&(this.xl=Error().stack,qa(this))}var Qb=0;function Rb(a,b){this.type=a;this.currentTarget=this.target=b}w=Rb.prototype;w.wc=u;w.defaultPrevented=u;w.ye=q;w.stopPropagation=function(){this.wc=q};w.preventDefault=function(){this.defaultPrevented=q;this.ye=u};function Sb(a){Sb[" "](a);return a}Sb[" "]=ga;function Tb(a,b){a&&this.Ca(a,b)}C(Tb,Rb);w=Tb.prototype;w.target=t;w.relatedTarget=t;w.offsetX=0;w.offsetY=0;w.clientX=0;w.clientY=0;w.screenX=0;w.screenY=0;w.button=0;w.keyCode=0;w.charCode=0;w.ctrlKey=u;w.altKey=u;w.shiftKey=u;w.metaKey=u;w.Wj=u;w.sb=t;
+w.Ca=function(a,b){var c=this.type=a.type;Rb.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var e=a.relatedTarget;if(e){if(jb){var d;a:{try{Sb(e.nodeName);d=q;break a}catch(f){}d=u}d||(e=t)}}else"mouseover"==c?e=a.fromElement:"mouseout"==c&&(e=a.toElement);this.relatedTarget=e;this.offsetX=lb||a.offsetX!==p?a.offsetX:a.layerX;this.offsetY=lb||a.offsetY!==p?a.offsetY:a.layerY;this.clientX=a.clientX!==p?a.clientX:a.pageX;this.clientY=a.clientY!==p?a.clientY:a.pageY;this.screenX=
+a.screenX||0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||("keypress"==c?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.Wj=ab?a.metaKey:a.ctrlKey;this.state=a.state;this.sb=a;a.defaultPrevented&&this.preventDefault();delete this.wc};w.stopPropagation=function(){Tb.u.stopPropagation.call(this);this.sb.stopPropagation?this.sb.stopPropagation():this.sb.cancelBubble=q};
+w.preventDefault=function(){Tb.u.preventDefault.call(this);var a=this.sb;if(a.preventDefault)a.preventDefault();else if(a.returnValue=u,Gb)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};w.Gi=v("sb");var Ub={},Vb={},Wb={},Xb={};function L(a,b,c,e,d){if(ja(b)){for(var f=0;f<b.length;f++)L(a,b[f],c,e,d);return t}a=Yb(a,b,c,u,e,d);b=a.key;Ub[b]=a;return b}
+function Yb(a,b,c,e,d,f){b||m(Error("Invalid event type"));d=!!d;var g=Vb;b in g||(g[b]={oa:0,Na:0});g=g[b];d in g||(g[d]={oa:0,Na:0},g.oa++);var g=g[d],h=qa(a),l;g.Na++;if(g[h]){l=g[h];for(var j=0;j<l.length;j++)if(g=l[j],g.bc==c&&g.uf==f){if(g.xc)break;e||(l[j].ie=u);return l[j]}}else l=g[h]=[],g.oa++;var k=Zb,n=Fb?function(a){return k.call(n.src,n.bc,a)}:function(a){a=k.call(n.src,n.bc,a);if(!a)return a},j=n,g=new Ma;g.Ca(c,j,a,b,d,f);g.ie=e;j.src=a;j.bc=g;l.push(g);Wb[h]||(Wb[h]=[]);Wb[h].push(g);
+a.addEventListener?(a==fa||!a.customEvent_)&&a.addEventListener(b,j,d):a.attachEvent(b in Xb?Xb[b]:Xb[b]="on"+b,j);return g}function $b(a,b,c,e,d){if(ja(b))for(var f=0;f<b.length;f++)$b(a,b[f],c,e,d);else a=Yb(a,b,c,q,e,d),Ub[a.key]=a}function ac(a,b,c,e,d){if(ja(b))for(var f=0;f<b.length;f++)ac(a,b[f],c,e,d);else{e=!!e;a:{f=Vb;if(b in f&&(f=f[b],e in f&&(f=f[e],a=qa(a),f[a]))){a=f[a];break a}a=t}if(a)for(f=0;f<a.length;f++)if(a[f].bc==c&&a[f].capture==e&&a[f].uf==d){bc(a[f].key);break}}}
+function bc(a){var b=Ub[a];if(!b||b.xc)return u;var c=b.src,e=b.type,d=b.oh,f=b.capture;c.removeEventListener?(c==fa||!c.customEvent_)&&c.removeEventListener(e,d,f):c.detachEvent&&c.detachEvent(e in Xb?Xb[e]:Xb[e]="on"+e,d);c=qa(c);Wb[c]&&(d=Wb[c],Nb(d,b),0==d.length&&delete Wb[c]);b.xc=q;if(b=Vb[e][f][c])b.fh=q,cc(e,f,c,b);delete Ub[a];return q}
+function cc(a,b,c,e){if(!e.te&&e.fh){for(var d=0,f=0;d<e.length;d++)e[d].xc?e[d].oh.src=t:(d!=f&&(e[f]=e[d]),f++);e.length=f;e.fh=u;0==f&&(delete Vb[a][b][c],Vb[a][b].oa--,0==Vb[a][b].oa&&(delete Vb[a][b],Vb[a].oa--),0==Vb[a].oa&&delete Vb[a])}}function dc(a){var b=0;if(a!=t){if(a=qa(a),Wb[a]){a=Wb[a];for(var c=a.length-1;0<=c;c--)bc(a[c].key),b++}}else Na(Ub,function(a,c){bc(c);b++})}
+function ec(a,b){var c=qa(a),e=Wb[c];if(e){var d=ia(b),f=ia(p);return d&&f?(e=Vb[b],!!e&&!!e[p]&&c in e[p]):!d&&!f?q:Mb(e,function(a){return d&&a.type==b||f&&a.capture==p})}return u}function fc(a,b,c,e,d){var f=1;b=qa(b);if(a[b]){var g=--a.Na,h=a[b];h.te?h.te++:h.te=1;try{for(var l=h.length,j=0;j<l;j++){var k=h[j];k&&!k.xc&&(f&=gc(k,d)!==u)}}finally{a.Na=Math.max(g,a.Na),h.te--,cc(c,e,b,h)}}return Boolean(f)}function gc(a,b){a.ie&&bc(a.key);return a.handleEvent(b)}
+function Zb(a,b){if(a.xc)return q;var c=a.type,e=Vb;if(!(c in e))return q;var e=e[c],d,f;if(!Fb){var g;if(!(g=b))a:{g=["window","event"];for(var h=fa;d=g.shift();)if(h[d]!=t)h=h[d];else{g=t;break a}g=h}d=g;g=q in e;h=u in e;if(g){if(0>d.keyCode||d.returnValue!=p)return q;a:{var l=u;if(0==d.keyCode)try{d.keyCode=-1;break a}catch(j){l=q}if(l||d.returnValue==p)d.returnValue=q}}l=new Tb;l.Ca(d,this);d=q;try{if(g){for(var k=[],n=l.currentTarget;n;n=n.parentNode)k.push(n);f=e[q];f.Na=f.oa;for(var s=k.length-
+1;!l.wc&&0<=s&&f.Na;s--)l.currentTarget=k[s],d&=fc(f,k[s],c,q,l);if(h){f=e[u];f.Na=f.oa;for(s=0;!l.wc&&s<k.length&&f.Na;s++)l.currentTarget=k[s],d&=fc(f,k[s],c,u,l)}}else d=gc(a,l)}finally{k&&(k.length=0)}return d}c=new Tb(b,this);return d=gc(a,c)}var hc=0;function ic(a){return a+"_"+hc++};function jc(){Pb.call(this);this.Bl={};this.ul=this}C(jc,Pb);jc.prototype.customEvent_=q;w=jc.prototype;w.Mf=t;w.Qf=ca("Mf");w.addEventListener=function(a,b,c,e){L(this,a,b,c,e)};w.removeEventListener=function(a,b,c,e){ac(this,a,b,c,e)};
+w.dispatchEvent=function(a){var b=a.type||a,c=Vb;if(b in c){if(na(a))a=new Rb(a,this);else if(a instanceof Rb)a.target=a.target||this;else{var e=a;a=new Rb(b,this);Qa(a,e)}var e=1,d,c=c[b],b=q in c,f;if(b){d=[];for(f=this;f;f=f.Mf)d.push(f);f=c[q];f.Na=f.oa;for(var g=d.length-1;!a.wc&&0<=g&&f.Na;g--)a.currentTarget=d[g],e&=fc(f,d[g],a.type,q,a)&&a.ye!=u}if(u in c)if(f=c[u],f.Na=f.oa,b)for(g=0;!a.wc&&g<d.length&&f.Na;g++)a.currentTarget=d[g],e&=fc(f,d[g],a.type,u,a)&&a.ye!=u;else for(d=this;!a.wc&&
+d&&f.Na;d=d.Mf)a.currentTarget=d,e&=fc(f,d,a.type,u,a)&&a.ye!=u;a=Boolean(e)}else a=q;return a};function M(){jc.call(this);this.f="base";this.qa=window["X.counter"].qk();this.j=u}C(M,jc);M.prototype.__defineGetter__("classname",v("f"));M.prototype.__defineGetter__("id",v("qa"));A("X.base",M);function kc(a,b){this.Wa=new ya(a);this.va=new ya(b)}kc.prototype={l:function(){return new kc(this.Wa.l(),this.va.l())},uc:function(){this.va=Ea(this.va)}};function lc(a,b){this.va=a;this.Pd=b}lc.prototype={l:function(){return new lc(this.va.l(),this.Pd)},uc:function(){this.va=Ea(this.va);this.Pd=-this.Pd}};function mc(a,b){this.Lb=a;this.Ee=b;var c=a[0].Wa,e=a[2].Wa,e=Da(Ca(a[1].Wa,c).sc(Ca(e,c)));this.Va=new lc(e,e.ac(c))}mc.prototype={l:function(){var a=this.Lb.map(function(a){return a.l()});return new mc(a,this.Ee)},uc:function(){this.Lb.reverse().map(function(a){a.uc()});this.Va.uc()}};
+function nc(a,b,c,e,d,f){for(var g=0,h=[],l=0;l<a.Lb.length;l++){var j=b.va.ac(a.Lb[l].Wa)-b.Pd,j=-1E-5>j?2:1E-5<j?1:0,g=g|j;h.push(j)}switch(g){case 0:(0<b.va.ac(a.Va.va)?c:e).push(a);break;case 1:d.push(a);break;case 2:f.push(a);break;case 3:c=[];e=[];for(l=0;l<a.Lb.length;l++){var k=(l+1)%a.Lb.length,j=h[l],n=h[k],g=a.Lb[l],k=a.Lb[k];2!=j&&c.push(g);1!=j&&e.push(2!=j?g.l():g);3==(j|n)&&(j=(b.Pd-b.va.ac(g.Wa))/b.va.ac(Ca(k.Wa,g.Wa)),j=new kc(g.Wa.se(k.Wa,j),g.va.se(k.va,j)),c.push(j),e.push(j.l()))}3<=
+c.length&&d.push(new mc(c,a.Ee));3<=e.length&&f.push(new mc(e,a.Ee))}};function oc(a){this.Aa=this.Ba=this.Va=t;this.Z=[];a&&pc(this,a)}oc.prototype={l:function(){var a=new oc,b=this.Va&&this.Va.l();a.Va=b;b=this.Ba&&this.Ba.l();a.Ba=b;b=this.Aa&&this.Aa.l();a.Aa=b;a.De(this.Z.map(function(a){return a.l()}));return a},Y:function(){for(var a=0;a<this.Z.length;a++)this.Z[a].uc();this.Va.uc();this.Ba&&this.Ba.Y();this.Aa&&this.Aa.Y();a=this.Ba;this.Ba=this.Aa;this.Aa=a},De:ca("Z")};
+function pc(a,b){if(b.length){a.Va||(a.Va=b[0].Va.l());for(var c=[],e=[],d=0;d<b.length;d++)nc(b[d],a.Va,a.Z,a.Z,c,e);c.length&&(a.Ba||(a.Ba=new oc),pc(a.Ba,c));e.length&&(a.Aa||(a.Aa=new oc),pc(a.Aa,e))}}function qc(a){var b=a.Z.slice();a.Ba&&(b=b.concat(qc(a.Ba)));a.Aa&&(b=b.concat(qc(a.Aa)));return b}function rc(a,b){a.Z=sc(b,a.Z);a.Ba&&rc(a.Ba,b);a.Aa&&rc(a.Aa,b)}
+function sc(a,b){if(!a.Va)return b.slice();for(var c=[],e=[],d=0;d<b.length;d++)nc(b[d],a.Va,c,e,c,e);a.Ba&&(c=sc(a.Ba,c));e=a.Aa?sc(a.Aa,e):[];return c.concat(e)};function tc(){this.Z=[]}function uc(a){var b=new tc;b.De(a);return b}
+tc.prototype={l:function(){var a=new tc;a.De(this.Z.map(function(a){return a.l()}));return a},Xf:function(a){var b=new oc(this.l().Z);a=new oc(a.l().Z);rc(b,a);rc(a,b);a.Y();rc(a,b);a.Y();pc(b,qc(a));return uc(qc(b))},wa:function(a){var b=new oc(this.l().Z);a=new oc(a.l().Z);b.Y();rc(b,a);rc(a,b);a.Y();rc(a,b);a.Y();pc(b,qc(a));b.Y();return uc(qc(b))},wf:function(a){var b=new oc(this.l().Z);a=new oc(a.l().Z);b.Y();rc(a,b);a.Y();rc(b,a);rc(a,b);pc(b,qc(a));b.Y();return uc(qc(b))},inverse:function(){var a=
+this.l();a.Z.map(function(a){a.uc()});return a},De:ca("Z")};function vc(){M.call(this);this.f="indexer";this.cf=[];this.pl=[];this.Ka={}}C(vc,M);vc.prototype.add=function(a){a==t&&m(Error("Invalid object."));var b=window.JSON.stringify(a);b in this.Ka||(this.Ka[b]=this.cf.length,this.cf.push(a));return this.Ka[b]};vc.prototype.unique=v("cf");function wc(a){M.call(this);this.f="file";this.$d=a;this.j=q}C(wc,M);function xc(){this.$a=this.r=t}xc.prototype.__defineSetter__("file",function(a){if(a==t||ja(a)&&0==a.length)this.r=t;else{if(ja(a)){if(1==a.length){this.r=new wc(a[0]);return}this.r=Lb(a,function(a){var c=new P;c.r=new wc(a);return c})}else this.r=new wc(a);this.$a=t}});xc.prototype.__defineGetter__("file",function(){return!this.r?"":ja(this.r)?this.r.map(function(a){return a.r.$d}):this.r.$d});
+xc.prototype.__defineGetter__("filedata",function(){return ja(this.r)?this.r.map(function(a){return a.$a}):this.$a});xc.prototype.__defineSetter__("filedata",function(a){if(a==t||ja(a)&&0==a.length)this.$a=t;if(ja(a))if(1==a.length)this.$a=a[0];else{var b=this.r.length,c;for(c=0;c<b;c++)this.r[c].$a=a[c]}else this.$a=a});function yc(a){if("function"==typeof a.Dd)return a.Dd();if(na(a))return a.split("");if(ma(a)){for(var b=[],c=a.length,e=0;e<c;e++)b.push(a[e]);return b}return Oa(a)};function zc(a,b){this.ga={};this.S=[];var c=arguments.length;if(1<c){c%2&&m(Error("Uneven number of arguments"));for(var e=0;e<c;e+=2)this.set(arguments[e],arguments[e+1])}else a&&this.ef(a)}w=zc.prototype;w.oa=0;w.Zf=0;w.tf=v("oa");w.Dd=function(){Ac(this);for(var a=[],b=0;b<this.S.length;b++)a.push(this.ga[this.S[b]]);return a};function Bc(a){for(var b=0;b<a.S.length;b++){var c=a.S[b];if(Cc(a.ga,c)&&a.ga[c]==u)return q}return u}w.clear=function(){this.ga={};this.Zf=this.oa=this.S.length=0};
+w.remove=function(a){return Cc(this.ga,a)?(delete this.ga[a],this.oa--,this.Zf++,this.S.length>2*this.oa&&Ac(this),q):u};function Ac(a){if(a.oa!=a.S.length){for(var b=0,c=0;b<a.S.length;){var e=a.S[b];Cc(a.ga,e)&&(a.S[c++]=e);b++}a.S.length=c}if(a.oa!=a.S.length){for(var d={},c=b=0;b<a.S.length;)e=a.S[b],Cc(d,e)||(a.S[c++]=e,d[e]=1),b++;a.S.length=c}}w.get=function(a,b){return Cc(this.ga,a)?this.ga[a]:b};w.set=function(a,b){Cc(this.ga,a)||(this.oa++,this.S.push(a),this.Zf++);this.ga[a]=b};
+w.ef=function(a){var b;if(a instanceof zc)Ac(a),b=a.S.concat(),a=a.Dd();else{b=[];var c=0,e;for(e in a)b[c++]=e;a=Oa(a)}for(c=0;c<b.length;c++)this.set(b[c],a[c])};w.l=function(){return new zc(this)};w.Wf=function(){for(var a=new zc,b=0;b<this.S.length;b++){var c=this.S[b];a.set(this.ga[c],c)}return a};function Cc(a,b){return Object.prototype.hasOwnProperty.call(a,b)};function Dc(){M.call(this);this.f="colortable";this.Ka=new zc;Fa(this,new xc)}C(Dc,M);Dc.prototype.add=function(a,b,c,e,d,f){(!x(a)||!x(c)||!x(e)||!x(d)||!x(f))&&m(Error("Invalid color table entry."));this.Ka.set(a,[b,c,e,d,f]);this.j=q};Dc.prototype.get=function(a){return this.Ka.get(a)};A("X.colortable.prototype.get",Dc.prototype.get);function Ec(a,b,c){this.x=ia(a)?a:0;this.y=ia(b)?b:0;this.d=ia(c)?c:0}Ec.prototype.l=function(){return new Ec(this.x,this.y,this.d)};function R(a,b,c){this.x=a;this.y=b;this.d=c}C(R,Ec);w=R.prototype;w.l=function(){return new R(this.x,this.y,this.d)};w.Ib=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.d*this.d)};w.scale=function(a){this.x*=a;this.y*=a;this.d*=a;return this};w.Y=function(){this.x=-this.x;this.y=-this.y;this.d=-this.d;return this};w.normalize=function(){return this.scale(1/this.Ib())};w.add=function(a){this.x+=a.x;this.y+=a.y;this.d+=a.d;return this};
+w.wa=function(a){this.x-=a.x;this.y-=a.y;this.d-=a.d;return this};function Fc(a,b){var c=a.x-b.x,e=a.y-b.y,d=a.d-b.d;return Math.sqrt(c*c+e*e+d*d)}function Gc(a,b){var c=a.x-b.x,e=a.y-b.y,d=a.d-b.d;return c*c+e*e+d*d}function Hc(a,b){return new R(a.x+b.x,a.y+b.y,a.d+b.d)}function Ic(a,b){return new R(a.y*b.d-a.d*b.y,a.d*b.x-a.x*b.d,a.x*b.y-a.y*b.x)};D.m=R;w=D.m.prototype;w.l=R.prototype.l;w.Ib=R.prototype.Ib;w.scale=R.prototype.scale;w.Y=R.prototype.Y;w.add=R.prototype.add;w.wa=R.prototype.wa;w.normalize=function(){var a=this.Ib();return 0==a?this.scale(0):this.scale(1/a)};D.m.ac=function(a,b){return a.x*b.x+a.y*b.y+a.d*b.d};D.m.sc=Ic;D.m.sf=Fc;D.m.se=function(a,b,c){return new R(a.x+c*(b.x-a.x),a.y+c*(b.y-a.y),a.d+c*(b.d-a.d))};D.m.prototype.__defineGetter__("xx",v("x"));D.m.prototype.__defineGetter__("yy",v("y"));
+D.m.prototype.__defineGetter__("zz",v("d"));A("X.vector",D.m);A("X.vector.prototype.clone",D.m.prototype.l);A("X.vector.prototype.magnitude",D.m.prototype.Ib);A("X.vector.prototype.scale",D.m.prototype.scale);A("X.vector.prototype.invert",D.m.prototype.Y);A("X.vector.prototype.normalize",D.m.prototype.normalize);A("X.vector.prototype.add",D.m.prototype.add);A("X.vector.prototype.subtract",D.m.prototype.wa);A("X.vector.dot",D.m.ac);A("X.vector.cross",D.m.sc);A("X.vector.distance",D.m.sf);
+A("X.vector.lerp",D.m.se);function Jc(a){this.length=a.length||a;for(var b=0;b<this.length;b++)this[b]=a[b]||0}Jc.prototype.BYTES_PER_ELEMENT=8;Jc.prototype.set=function(a,b){b=b||0;for(var c=0;c<a.length&&b+c<this.length;c++)this[b+c]=a[c]};Jc.prototype.toString=Array.prototype.join;if("undefined"==typeof Float64Array){try{Jc.BYTES_PER_ELEMENT=8}catch(Kc){}Jc.prototype.BYTES_PER_ELEMENT=Jc.prototype.BYTES_PER_ELEMENT;Jc.prototype.set=Jc.prototype.set;Jc.prototype.toString=Jc.prototype.toString;A("Float64Array",Jc)};function Lc(a){this.length=a.length||a;for(var b=0;b<this.length;b++)this[b]=a[b]||0}Lc.prototype.BYTES_PER_ELEMENT=4;Lc.prototype.set=function(a,b){b=b||0;for(var c=0;c<a.length&&b+c<this.length;c++)this[b+c]=a[c]};Lc.prototype.toString=Array.prototype.join;"undefined"==typeof Float32Array&&(Lc.BYTES_PER_ELEMENT=4,Lc.prototype.BYTES_PER_ELEMENT=Lc.prototype.BYTES_PER_ELEMENT,Lc.prototype.set=Lc.prototype.set,Lc.prototype.toString=Lc.prototype.toString,A("Float32Array",Lc));function Mc(){return new Float32Array(3)}function Nc(a,b,c){var e=Mc();e[0]=a;e[1]=b;e[2]=c;return e}function Oc(a,b){var c=a[0],e=a[1],d=a[2],c=1/Math.sqrt(c*c+e*e+d*d);b[0]=a[0]*c;b[1]=a[1]*c;b[2]=a[2]*c};function Pc(){return new Float32Array(4)}function Qc(a,b,c,e){var d=Pc();d[0]=a;d[1]=b;d[2]=c;d[3]=e;return d};function Rc(){return new Float32Array(16)}function Sc(){var a=Rc();a[0]=a[5]=a[10]=a[15]=1;return a}function Tc(a,b,c,e,d,f,g,h,l,j,k,n,s,r,y,z,F){a[0]=b;a[1]=c;a[2]=e;a[3]=d;a[4]=f;a[5]=g;a[6]=h;a[7]=l;a[8]=j;a[9]=k;a[10]=n;a[11]=s;a[12]=r;a[13]=y;a[14]=z;a[15]=F;return a}function Uc(a,b,c,e,d){a[12]=b;a[13]=c;a[14]=e;a[15]=d;return a}function Vc(a,b,c){b*=4;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3]}function Wc(a,b,c){b*=4;c[0]=a[b];c[1]=a[b+1];c[2]=a[b+2];c[3]=a[b+3]}
+function T(a,b,c,e,d,f){a[b]=c;a[b+4]=e;a[b+8]=d;a[b+12]=f}function Xc(a,b,c){a[b]=c[0];a[b+4]=c[1];a[b+8]=c[2];a[b+12]=c[3]}function Yc(a,b,c){c[0]=a[b];c[1]=a[b+4];c[2]=a[b+8];c[3]=a[b+12]}
+function $c(a,b,c){var e=a[0],d=a[1],f=a[2],g=a[3],h=a[4],l=a[5],j=a[6],k=a[7],n=a[8],s=a[9],r=a[10],y=a[11],z=a[12],F=a[13],G=a[14];a=a[15];var H=b[0],B=b[1],E=b[2],I=b[3],N=b[4],Q=b[5],O=b[6],S=b[7],da=b[8],J=b[9],ba=b[10],la=b[11],U=b[12],V=b[13],Ga=b[14];b=b[15];c[0]=e*H+h*B+n*E+z*I;c[1]=d*H+l*B+s*E+F*I;c[2]=f*H+j*B+r*E+G*I;c[3]=g*H+k*B+y*E+a*I;c[4]=e*N+h*Q+n*O+z*S;c[5]=d*N+l*Q+s*O+F*S;c[6]=f*N+j*Q+r*O+G*S;c[7]=g*N+k*Q+y*O+a*S;c[8]=e*da+h*J+n*ba+z*la;c[9]=d*da+l*J+s*ba+F*la;c[10]=f*da+j*J+r*ba+
+G*la;c[11]=g*da+k*J+y*ba+a*la;c[12]=e*U+h*V+n*Ga+z*b;c[13]=d*U+l*V+s*Ga+F*b;c[14]=f*U+j*V+r*Ga+G*b;c[15]=g*U+k*V+y*Ga+a*b;return c}
+function ad(a,b){var c=a[0],e=a[1],d=a[2],f=a[3],g=a[4],h=a[5],l=a[6],j=a[7],k=a[8],n=a[9],s=a[10],r=a[11],y=a[12],z=a[13],F=a[14],G=a[15],H=c*h-e*g,B=c*l-d*g,E=c*j-f*g,I=e*l-d*h,N=e*j-f*h,Q=d*j-f*l,O=k*z-n*y,S=k*F-s*y,da=k*G-r*y,J=n*F-s*z,ba=n*G-r*z,la=s*G-r*F,U=H*la-B*ba+E*J+I*da-N*S+Q*O;if(0==U)return u;U=1/U;b[0]=(h*la-l*ba+j*J)*U;b[1]=(-e*la+d*ba-f*J)*U;b[2]=(z*Q-F*N+G*I)*U;b[3]=(-n*Q+s*N-r*I)*U;b[4]=(-g*la+l*da-j*S)*U;b[5]=(c*la-d*da+f*S)*U;b[6]=(-y*Q+F*E-G*B)*U;b[7]=(k*Q-s*E+r*B)*U;b[8]=(g*
+ba-h*da+j*O)*U;b[9]=(-c*ba+e*da-f*O)*U;b[10]=(y*N-z*E+G*H)*U;b[11]=(-k*N+n*E-r*H)*U;b[12]=(-g*J+h*S-l*O)*U;b[13]=(c*J-e*S+d*O)*U;b[14]=(-y*I+z*B-F*H)*U;b[15]=(k*I-n*B+s*H)*U;return q}function bd(a,b,c){var e=b[0],d=b[1];b=b[2];c[0]=e*a[0]+d*a[4]+b*a[8]+a[12];c[1]=e*a[1]+d*a[5]+b*a[9]+a[13];c[2]=e*a[2]+d*a[6]+b*a[10]+a[14]}
+function cd(a,b,c){var e=b[0],d=b[1],f=b[2];b=b[3];c[0]=e*a[0]+d*a[4]+f*a[8]+b*a[12];c[1]=e*a[1]+d*a[5]+f*a[9]+b*a[13];c[2]=e*a[2]+d*a[6]+f*a[10]+b*a[14];c[3]=e*a[3]+d*a[7]+f*a[11]+b*a[15];return c}function dd(a,b,c,e){return Uc(a,a[0]*b+a[4]*c+a[8]*e+a[12],a[1]*b+a[5]*c+a[9]*e+a[13],a[2]*b+a[6]*c+a[10]*e+a[14],a[3]*b+a[7]*c+a[11]*e+a[15])}new Float64Array(3);new Float64Array(3);new Float64Array(4);new Float64Array(4);new Float64Array(4);new Float64Array(16);D.g={};D.g.Xg=function(a,b,c,e){c=c.wa(b);c.normalize();e=D.m.sc(c,e);e.normalize();var d=D.m.sc(e,c);d.normalize();c.Y();T(a,0,e.x,e.y,e.d,0);T(a,1,d.x,d.y,d.d,0);T(a,2,c.x,c.y,c.d,0);dd(a,-b.x,-b.y,-b.d);return a};D.g.ba=function(a,b,c,e){var d=1/(b*a[3]+c*a[7]+e*a[11]+a[15]);return new D.m((b*a[0]+c*a[4]+e*a[8]+a[12])*d,(b*a[1]+c*a[5]+e*a[9]+a[13])*d,(b*a[2]+c*a[6]+e*a[10]+a[14])*d)};
+D.g.nk=function(a,b,c){var e=new Float32Array(4),d=new Float32Array(4);Yc(a,b,e);Yc(a,c,d);Xc(a,b,d);Xc(a,c,e);return a};D.g.mk=function(a,b,c){var e=new Float32Array(4),d=new Float32Array(4);Wc(a,b,e);Wc(a,c,d);Vc(a,b,d);Vc(a,c,e);return a};D.g.Ed=Sc;D.g.l=function(a){var b=Rc();b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b};
+D.g.Wf=function(a,b){if(b==a){var c=a[1],e=a[2],d=a[3],f=a[6],g=a[7],h=a[11];b[1]=a[4];b[2]=a[8];b[3]=a[12];b[4]=c;b[6]=a[9];b[7]=a[13];b[8]=e;b[9]=f;b[11]=a[14];b[12]=d;b[13]=g;b[14]=h}else b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15];return b};
+D.g.ti=function(a){var b=a[0],c=a[1],e=a[2],d=a[3],f=a[4],g=a[5],h=a[6],l=a[7],j=a[8],k=a[9],n=a[10],s=a[11],r=a[12],y=a[13],z=a[14];a=a[15];return(b*g-c*f)*(n*a-s*z)-(b*h-e*f)*(k*a-s*y)+(b*l-d*f)*(k*z-n*y)+(c*h-e*g)*(j*a-s*r)-(c*l-d*g)*(j*z-n*r)+(e*l-d*h)*(j*y-k*r)};D.g.Y=ad;D.g.zf=function(a,b,c,e,d){var f=b/2;b=d-e;var g=Math.sin(f);if(0==b||0==g||0==c)return a;f=Math.cos(f)/g;return Tc(a,f/c,0,0,0,0,f,0,0,0,0,-(d+e)/b,-1,0,0,-(2*e*d)/b,0)};
+D.g.dj=function(a,b,c,e,d,f,g){return Tc(a,2*f/(c-b),0,0,0,0,2*f/(d-e),0,0,(c+b)/(c-b),(d+e)/(d-e),-(g+f)/(g-f),-1,0,0,-(2*g*f)/(g-f),0)};D.g.ej=function(a,b,c,e,d,f,g){return Tc(a,2/(c-b),0,0,0,0,2/(d-e),0,0,0,0,-2/(g-f),0,-(c+b)/(c-b),-(d+e)/(d-e),-(g+f)/(g-f),1)};D.g.multiply=$c;D.g.ah=cd;D.g.translate=dd;D.g.scale=function(a,b,c,e){return Tc(a,a[0]*b,a[1]*b,a[2]*b,a[3]*b,a[4]*c,a[5]*c,a[6]*c,a[7]*c,a[8]*e,a[9]*e,a[10]*e,a[11]*e,a[12],a[13],a[14],a[15])};
+D.g.rotate=function(a,b,c,e,d){var f=a[0],g=a[1],h=a[2],l=a[3],j=a[4],k=a[5],n=a[6],s=a[7],r=a[8],y=a[9],z=a[10],F=a[11],G=Math.cos(b),H=Math.sin(b),B=1-G;b=c*c*B+G;var E=c*e*B+d*H,I=c*d*B-e*H,N=c*e*B-d*H,Q=e*e*B+G,O=e*d*B+c*H,S=c*d*B+e*H;c=e*d*B-c*H;d=d*d*B+G;return Tc(a,f*b+j*E+r*I,g*b+k*E+y*I,h*b+n*E+z*I,l*b+s*E+F*I,f*N+j*Q+r*O,g*N+k*Q+y*O,h*N+n*Q+z*O,l*N+s*Q+F*O,f*S+j*c+r*d,g*S+k*c+y*d,h*S+n*c+z*d,l*S+s*c+F*d,a[12],a[13],a[14],a[15])};
+D.g.ze=function(a,b){var c=a[4],e=a[5],d=a[6],f=a[7],g=a[8],h=a[9],l=a[10],j=a[11],k=Math.cos(b),n=Math.sin(b);a[4]=c*k+g*n;a[5]=e*k+h*n;a[6]=d*k+l*n;a[7]=f*k+j*n;a[8]=c*-n+g*k;a[9]=e*-n+h*k;a[10]=d*-n+l*k;a[11]=f*-n+j*k;return a};D.g.Ae=function(a,b){var c=a[0],e=a[1],d=a[2],f=a[3],g=a[8],h=a[9],l=a[10],j=a[11],k=Math.cos(b),n=Math.sin(b);a[0]=c*k+g*-n;a[1]=e*k+h*-n;a[2]=d*k+l*-n;a[3]=f*k+j*-n;a[8]=c*n+g*k;a[9]=e*n+h*k;a[10]=d*n+l*k;a[11]=f*n+j*k;return a};
+D.g.Be=function(a,b){var c=a[0],e=a[1],d=a[2],f=a[3],g=a[4],h=a[5],l=a[6],j=a[7],k=Math.cos(b),n=Math.sin(b);a[0]=c*k+g*n;a[1]=e*k+h*n;a[2]=d*k+l*n;a[3]=f*k+j*n;a[4]=c*-n+g*k;a[5]=e*-n+h*k;a[6]=d*-n+l*k;a[7]=f*-n+j*k;return a};A("X.matrix.identity",D.g.Ed);A("X.matrix.clone",D.g.l);A("X.matrix.transpose",D.g.Wf);A("X.matrix.determinant",D.g.ti);A("X.matrix.invert",D.g.Y);A("X.matrix.multiply",D.g.multiply);A("X.matrix.multiplyByVector",D.g.ba);A("X.matrix.multiplyByVec4",D.g.ah);
+A("X.matrix.makePerspective",D.g.zf);A("X.matrix.makeFrustum",D.g.dj);A("X.matrix.makeOrtho",D.g.ej);A("X.matrix.makeLookAt",D.g.Xg);A("X.matrix.translate",D.g.translate);A("X.matrix.scale",D.g.scale);A("X.matrix.rotate",D.g.rotate);A("X.matrix.rotateX",D.g.ze);A("X.matrix.rotateY",D.g.Ae);A("X.matrix.rotateZ",D.g.Be);A("X.matrix.swapRows",D.g.nk);A("X.matrix.swapCols",D.g.mk);function ed(){M.call(this);this.f="transform";this.Q=D.g.Ed()}C(ed,M);ed.prototype.__defineGetter__("matrix",v("Q"));ed.prototype.__defineSetter__("matrix",function(a){(a==t||!(a instanceof Float32Array))&&m(Error("Invalid matrix."));this.Q=a;this.q()});w=ed.prototype;w.ze=function(a){(!x(a)||-360>a||360<a)&&m(Error("Invalid angle."));D.g.ze(this.Q,a*Math.PI/180);this.q()};w.Ae=function(a){(!x(a)||-360>a||360<a)&&m(Error("Invalid angle."));D.g.Ae(this.Q,a*Math.PI/180);this.q()};
+w.Be=function(a){(!x(a)||-360>a||360<a)&&m(Error("Invalid angle."));D.g.Be(this.Q,a*Math.PI/180);this.q()};w.Dh=function(a){x(a)||m(Error("Invalid distance."));D.g.translate(this.Q,a,0,0);this.q()};w.Eh=function(a){x(a)||m(Error("Invalid distance."));D.g.translate(this.Q,0,a,0);this.q()};w.Fh=function(a){x(a)||m(Error("Invalid distance."));D.g.translate(this.Q,0,0,a);this.q()};function fd(a,b,c){a.Q[b+4*c]*=-1;a.q()}w.Bi=function(){fd(this,0,0)};w.Ci=function(){fd(this,1,1)};
+w.Di=function(){fd(this,2,2)};w.q=function(){this.j=q};A("X.transform",ed);A("X.transform.prototype.rotateX",ed.prototype.ze);A("X.transform.prototype.rotateY",ed.prototype.Ae);A("X.transform.prototype.rotateZ",ed.prototype.Be);A("X.transform.prototype.translateX",ed.prototype.Dh);A("X.transform.prototype.translateY",ed.prototype.Eh);A("X.transform.prototype.translateZ",ed.prototype.Fh);A("X.transform.prototype.flipX",ed.prototype.Bi);A("X.transform.prototype.flipY",ed.prototype.Ci);
+A("X.transform.prototype.flipZ",ed.prototype.Di);A("X.transform.prototype.modified",ed.prototype.q);function gd(){M.call(this);this.f="texture";this.Wb=this.jb=this.r=t;this.Xe=this.Ye=0;this.hg=u;Fa(this,new xc)}C(gd,M);gd.prototype.__defineSetter__("rawData",function(a){this.Wb=a;this.j=q});gd.prototype.__defineSetter__("rawDataHeight",function(a){this.Xe=a;this.j=q});gd.prototype.__defineSetter__("rawDataWidth",function(a){this.Ye=a;this.j=q});gd.prototype.__defineSetter__("grayscale",function(a){this.hg=a;this.j=q});A("X.texture",gd);function W(a,b){M.call(this);this.f="triplets";this.nb=Infinity;this.kb=-Infinity;this.ob=Infinity;this.lb=-Infinity;this.pb=Infinity;this.mb=-Infinity;this.Rd=[0,0,0];this.gg=q;this.C=0;this.da=new Float32Array(a);b!=t&&(this.da=b.da.subarray(0,b.da.length),this.C=this.da.length,this.nb=b.nb,this.kb=b.kb,this.ob=b.ob,this.lb=b.lb,this.pb=b.pb,this.mb=b.mb,this.Rd=b.Rd.slice(),this.gg=u)}C(W,M);w=W.prototype;
+w.add=function(a,b,c){this.nb=Math.min(this.nb,a);this.kb=Math.max(this.kb,a);this.ob=Math.min(this.ob,b);this.lb=Math.max(this.lb,b);this.pb=Math.min(this.pb,c);this.mb=Math.max(this.mb,c);this.Rd=[(this.nb+this.kb)/2,(this.ob+this.lb)/2,(this.pb+this.mb)/2];this.gg=u;this.j=q;this.da[this.C++]=a;this.da[this.C++]=b;this.da[this.C++]=c;return this.C/3};w.Jb=function(){if(this.C!=this.da.length){var a=new Float32Array(this.C);a.set(this.da.subarray(0,this.C));this.da=a}};
+w.get=function(a){a*=3;return[this.da[a],this.da[a+1],this.da[a+2]]};w.remove=function(){m(Error("Not implemented."))};w.clear=function(){this.da=new Float32Array(this.da.length);this.j=q};W.prototype.__defineGetter__("count",function(){this.Jb();return this.da.length/3});W.prototype.__defineGetter__("length",function(){this.Jb();return this.da.length});A("X.triplets",W);A("X.triplets.prototype.add",W.prototype.add);A("X.triplets.prototype.resize",W.prototype.Jb);A("X.triplets.prototype.get",W.prototype.get);
+A("X.triplets.prototype.remove",W.prototype.remove);A("X.triplets.prototype.clear",W.prototype.clear);function hd(){this.Ia=id;this.ja=new ed;this.w=[1,1,1];this.nc=this.G=this.pa=this.n=this.h=t;this.Nc=[];this.O=q;this.Lc=this.sd=1;this.Dc=t;this.jd=u;this.za=1;this.ya=0;this.rd=q}var id="TRIANGLES";hd.prototype.__defineSetter__("type",function(a){return this.Ia=a});hd.prototype.__defineGetter__("type",v("Ia"));hd.prototype.__defineGetter__("texture",function(){this.G||(this.G=new gd);return this.G});hd.prototype.__defineGetter__("transform",v("ja"));hd.prototype.__defineGetter__("points",v("h"));
+hd.prototype.__defineSetter__("points",ca("h"));hd.prototype.__defineGetter__("normals",v("n"));hd.prototype.__defineSetter__("normals",ca("n"));hd.prototype.__defineGetter__("colors",v("pa"));hd.prototype.__defineSetter__("colors",ca("pa"));hd.prototype.__defineGetter__("color",v("w"));hd.prototype.__defineSetter__("color",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid color."));for(var b=this.c,c=b.length,e=0,e=0;e<c;e++)b[e].color=a;this.w=a;this.j=q});
+hd.prototype.__defineGetter__("opacity",v("za"));hd.prototype.__defineSetter__("opacity",function(a){(!x(a)||1<a||0>a)&&m(Error("Invalid opacity."));for(var b=this.c,c=b.length,e=0,e=0;e<c;e++)b[e]!=t&&(b[e].opacity=a);this.za=a;this.j=q});hd.prototype.__defineGetter__("caption",v("Dc"));hd.prototype.__defineSetter__("caption",function(a){this.Dc=a;this.j=q});hd.prototype.__defineGetter__("visible",v("O"));
+hd.prototype.__defineSetter__("visible",function(a){for(var b=this.c,c=b.length,e=0,e=0;e<c;e++)b[e]!=t&&(b[e].visible=a);this.O=a;this.j=q});hd.prototype.__defineGetter__("pointsize",v("sd"));hd.prototype.__defineSetter__("pointsize",function(a){x(a)||m(Error("Invalid point size."));this.sd=a;this.j=q});hd.prototype.__defineGetter__("magicmode",v("jd"));hd.prototype.__defineSetter__("magicmode",function(a){"boolean"!=typeof a&&m(Error("Invalid magic mode setting."));this.jd=a;this.j=q});
+hd.prototype.__defineGetter__("linewidth",v("Lc"));hd.prototype.__defineSetter__("linewidth",function(a){x(a)||m(Error("Invalid line width."));this.Lc=a;this.j=q});hd.prototype.__defineGetter__("pickable",v("rd"));hd.prototype.__defineSetter__("pickable",function(a){"boolean"!=typeof a&&m(Error("Invalid pickable setting."));this.rd=a;this.j=q});hd.prototype.__defineGetter__("textureCoordinateMap",v("nc"));hd.prototype.__defineSetter__("textureCoordinateMap",ca("sl"));function jd(){this.ra=Infinity;this.U=this.ia=-Infinity;this.W=Infinity;this.Rb=[0,0,0];this.Pb=[1,1,1]}jd.prototype.__defineGetter__("lowerThreshold",v("U"));jd.prototype.__defineSetter__("lowerThreshold",ca("U"));jd.prototype.__defineGetter__("upperThreshold",v("W"));jd.prototype.__defineSetter__("upperThreshold",ca("W"));jd.prototype.__defineGetter__("min",v("ra"));jd.prototype.__defineGetter__("max",v("ia"));jd.prototype.__defineGetter__("minColor",v("Rb"));
+jd.prototype.__defineSetter__("minColor",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid min. color."));this.Rb=a});jd.prototype.__defineGetter__("maxColor",v("Pb"));jd.prototype.__defineSetter__("maxColor",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid max. color."));this.Pb=a});function kd(){M.call(this);this.f="scalars";this.dd=this.I=t;this.ug=q;this.Me=0;Fa(this,new xc);Fa(this,new jd);this.Rb=[0,1,0];this.Pb=[1,0,0]}C(kd,M);kd.prototype.__defineGetter__("array",v("I"));kd.prototype.__defineSetter__("array",function(a){this.dd=this.I=a;this.j=q});kd.prototype.__defineGetter__("interpolation",v("Me"));kd.prototype.__defineSetter__("interpolation",ca("Me"));A("X.scalars",kd);function Y(a){M.call(this);this.f="object";this.c=[];this.F=this.xa=t;Fa(this,new hd);a!=t&&this.rc(a)}C(Y,M);
+Y.prototype.rc=function(a){this.Ia=a.Ia;this.ja=new ed;this.ja.Q=new Float32Array(a.ja.Q);this.w=a.w.slice();a.h&&(this.h=new W(a.h.length,a.h));a.n&&(this.n=new W(a.n.length,a.n));a.pa&&(this.pa=new W(a.pa.length,a.pa));this.G=a.G;this.nc=a.nc;a.r&&(this.r=new wc((new String(a.r.$d)).toString()));this.za=a.za;this.c.length=0;var b=a.c;if(b)for(var c=b.length,e=0,e=0;e<c;e++)this.c.push(new D[b[e].f](b[e]));this.O=a.O;this.sd=a.sd;this.Lc=a.Lc;a.Dc&&(this.Dc=(new String(a.Dc)).toString());this.jd=
+a.jd;this.rd=a.rd;this.Nc=a.Nc.slice();this.j=q};Y.prototype.__defineGetter__("colortable",function(){this.xa||(this.xa=new Dc);return this.xa});Y.prototype.__defineGetter__("scalars",function(){this.F||(this.F=new kd);return this.F});Y.prototype.__defineGetter__("children",v("c"));Y.prototype.q=function(){var a=new ld;a.D=this;this.dispatchEvent(a)};Y.prototype.remove=function(){var a=new md;a.D=this;this.dispatchEvent(a)};
+Y.prototype.Ta=function(){dc(this);if(0<this.c.length)for(var a=this.c,b=a.length,c=0,c=0;c<b;c++)"undefined"!=typeof a[c]&&this.c[c].Ta();this.c.length=0;this.F=this.xa=t};function nd(a,b){(a==t||b==t||!(a instanceof Y)||!(b instanceof Y))&&m(Error("Fatal: Two valid X.objects are required for comparison."));return 1==a.za?-1:1==b.za?1:a.ya!=t&&b.ya!=t&&a.ya>b.ya?-1:1}A("X.object",Y);A("X.object.prototype.modified",Y.prototype.q);A("X.object.prototype.remove",Y.prototype.remove);
+A("X.object.prototype.destroy",Y.prototype.Ta);function od(){}function pd(a){for(var b=a.h.count,c=[],e=0,e=0;e<b;e+=3){var d=a.h.get(e),f=a.h.get(e+1),g=a.h.get(e+2),h=a.n.get(e),l=a.n.get(e+1),j=a.n.get(e+2),k=a.w;a.pa&&0<a.pa.length&&(k=a.pa.get(e));var n=[];n.push(new kc(d,h));n.push(new kc(f,l));n.push(new kc(g,j));c.push(new mc(n,k))}return uc(c)}
+function qd(a,b){(b==t||!(b instanceof tc))&&m(Error("Invalid CSG object."));var c=new vc,e=[];Lb(b.Z,function(a){var b=[],g=a.Ee,b=Lb(a.Lb,function(a){a.color=g;return c.add(a)});for(a=a=2;a<b.length;a++)e.push([b[0],b[a-1],b[a]])}.bind(a));a.Vh=Lb(c.unique(),function(a){return[a.Wa.x(),a.Wa.y(),a.Wa.d()]});a.Uh=Lb(c.unique(),function(a){return[a.va.x(),a.va.y(),a.va.d()]});a.Th=Lb(c.unique(),function(a){return!a.color?t:[a.color[0],a.color[1],a.color[2]]});a.h=new W(9*e.length);a.n=new W(9*e.length);
+a.pa=new W(9*e.length);Lb(e,function(a){var b=a[0],c=a[1];a=a[2];var e=this.Vh,l=this.Uh,j=this.Th;this.h.add(e[b][0],e[b][1],e[b][2]);this.h.add(e[c][0],e[c][1],e[c][2]);this.h.add(e[a][0],e[a][1],e[a][2]);this.n.add(l[b][0],l[b][1],l[b][2]);this.n.add(l[c][0],l[c][1],l[c][2]);this.n.add(l[a][0],l[a][1],l[a][2]);j[b]&&this.pa.add(j[b][0],j[b][1],j[b][2]);j[c]&&this.pa.add(j[c][0],j[c][1],j[c][2]);j[a]&&this.pa.add(j[a][0],j[a][1],j[a][2])}.bind(a));0==a.pa.C&&(a.pa=t);a.Ia=id}
+od.prototype.Xf=function(a){(a==t||!(a instanceof tc)&&!(a instanceof Y))&&m(Error("Invalid object."));var b=a;a instanceof Y&&(b=pd(b));a=new Y;Fa(a,new od);qd(a,pd(this).Xf(b));return a};od.prototype.wa=function(a){(a==t||!(a instanceof tc)&&!(a instanceof Y))&&m(Error("Invalid object."));var b=a;a instanceof Y&&(b=pd(b));a=new Y;Fa(a,new od);qd(a,pd(this).wa(b));return a};
+od.prototype.wf=function(a){(a==t||!(a instanceof tc)&&!(a instanceof Y))&&m(Error("Invalid object."));var b=a;a instanceof Y&&(b=pd(b));a=new Y;Fa(a,new od);qd(a,pd(this).wf(b));return a};od.prototype.inverse=function(){var a=new Y;Fa(a,new od);qd(a,pd(this).inverse());return a};A("X.constructable",od);A("X.constructable.prototype.intersect",od.prototype.wf);A("X.constructable.prototype.inverse",od.prototype.inverse);A("X.constructable.prototype.subtract",od.prototype.wa);
+A("X.constructable.prototype.union",od.prototype.Xf);function rd(a){Rb.call(this,a);this.f="event"}C(rd,Rb);var sd=ic("pan"),td=ic("rotate"),ud=ic("zoom"),vd=ic("scroll");ic("render");var wd=ic("resetview"),xd=ic("windowlevel"),yd=ic("modified"),zd=ic("remove"),Ad=ic("progress"),Bd=ic("hover"),Cd=ic("hover_end"),Dd=ic("computing"),Ed=ic("computing_end"),Fd=ic("computing_progress");function Gd(){rd.call(this,xd);this.Re=this.df=0}C(Gd,rd);function Hd(){rd.call(this,sd);this.ya=new D.m(0,0,0)}C(Hd,rd);
+function Id(){rd.call(this,td);this.ya=new D.m(0,0,0)}C(Id,rd);function Jd(){rd.call(this,ud);this.ib=this.vb=u}C(Jd,rd);function Kd(){rd.call(this,vd);this.V=u}C(Kd,rd);function Ld(){rd.call(this,Bd);this.ge=this.fe=0}C(Ld,rd);function Md(){rd.call(this,Cd)}C(Md,rd);function Nd(){rd.call(this,wd)}C(Nd,rd);function ld(){rd.call(this,yd);this.v=this.D=t}C(ld,rd);function md(){rd.call(this,zd);this.v=this.D=t}C(md,rd);function Od(){rd.call(this,Ad);this.Ad=0}C(Od,rd);
+function Pd(){rd.call(this,Dd);this.D=t}C(Pd,rd);function Qd(){rd.call(this,Fd);this.Ad=0}C(Qd,rd);function Rd(){rd.call(this,Ed);this.D=t}C(Rd,rd);A("X.event.events.PAN",sd);A("X.event.events.ROTATE",td);A("X.event.events.ZOOM",ud);A("X.event.events.SCROLL",vd);function Sd(a,b,c){a==t&&m(Error("Invalid GL Buffer."));b==t&&m(Error("Invalid number of items."));c==t&&m(Error("Invalid item size."));M.call(this);this.f="buffer";this.P=a;this.ed=b;this.Ob=c}C(Sd,M);var Td;function Ud(a,b){var c;c=a.className;c=na(c)&&c.match(/\S+/g)||[];for(var e=Ob(arguments,1),d=c.length+e.length,f=c,g=0;g<e.length;g++)0<=Ib(f,e[g])||f.push(e[g]);a.className=c.join(" ");return c.length==d};function Vd(a,b){this.width=a;this.height=b}w=Vd.prototype;w.l=function(){return new Vd(this.width,this.height)};w.ceil=function(){this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};w.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};w.round=function(){this.width=Math.round(this.width);this.height=Math.round(this.height);return this};w.scale=function(a,b){var c=x(b)?b:a;this.width*=a;this.height*=c;return this};var Wd=!K||K&&9<=Eb;!jb&&!K||K&&K&&9<=Eb||jb&&Cb("1.9.1");K&&Cb("9");function Xd(a,b){this.x=ia(a)?a:0;this.y=ia(b)?b:0}w=Xd.prototype;w.l=function(){return new Xd(this.x,this.y)};function Yd(a,b){return new Xd(a.x-b.x,a.y-b.y)}w.ceil=function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this};w.floor=function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this};w.round=function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this};
+w.translate=function(a,b){a instanceof Xd?(this.x+=a.x,this.y+=a.y):(this.x+=a,x(b)&&(this.y+=b));return this};w.scale=function(a,b){var c=x(b)?b:a;this.x*=a;this.y*=c;return this};function Zd(a){return a?new $d(ae(a)):Td||(Td=new $d)}function be(a){return na(a)?document.getElementById(a):a}var ce={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function de(a,b,c){return ee(document,arguments)}
+function ee(a,b){var c=b[0],e=b[1];if(!Wd&&e&&(e.name||e.type)){c=["<",c];e.name&&c.push(' name="',Ra(e.name),'"');if(e.type){c.push(' type="',Ra(e.type),'"');var d={};Qa(d,e);delete d.type;e=d}c.push(">");c=c.join("")}var f=a.createElement(c);e&&(na(e)?f.className=e:ja(e)?Ud.apply(t,[f].concat(e)):Na(e,function(a,b){"style"==b?f.style.cssText=a:"class"==b?f.className=a:"for"==b?f.htmlFor=a:b in ce?f.setAttribute(ce[b],a):0==b.lastIndexOf("aria-",0)||0==b.lastIndexOf("data-",0)?f.setAttribute(b,a):
+f[b]=a}));if(2<b.length){e=function(b){b&&f.appendChild(na(b)?a.createTextNode(b):b)};for(c=2;c<b.length;c++){var g=b[c];if(ma(g)&&!(pa(g)&&0<g.nodeType)){var d=Jb,h;a:{if((h=g)&&"number"==typeof h.length){if(pa(h)){h="function"==typeof h.item||"string"==typeof h.item;break a}if(oa(h)){h="function"==typeof h.item;break a}}h=u}if(h)if(h=g.length,0<h){for(var l=Array(h),j=0;j<h;j++)l[j]=g[j];g=l}else g=[];d(g,e)}else e(g)}}return f}function fe(a){a&&a.parentNode&&a.parentNode.removeChild(a)}
+function ge(a){for(;a&&1!=a.nodeType;)a=a.nextSibling;return a}function he(a,b){if(a.contains&&1==b.nodeType)return a==b||a.contains(b);if("undefined"!=typeof a.compareDocumentPosition)return a==b||Boolean(a.compareDocumentPosition(b)&16);for(;b&&a!=b;)b=b.parentNode;return b==a}function ae(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function $d(a){this.ka=a||fa.document||document}w=$d.prototype;w.ne=Zd;w.t=function(a){return na(a)?this.ka.getElementById(a):a};w.Lh=$d.prototype.t;
+w.Wc=function(a,b,c){return ee(this.ka,arguments)};w.createElement=function(a){return this.ka.createElement(a)};w.createTextNode=function(a){return this.ka.createTextNode(String(a))};function ie(a){return"CSS1Compat"==a.ka.compatMode}function je(a){var b=a.ka;a=!lb&&"CSS1Compat"==b.compatMode?b.documentElement:b.body;b=b.parentWindow||b.defaultView;return K&&Cb("10")&&b.pageYOffset!=a.scrollTop?new Xd(a.scrollLeft,a.scrollTop):new Xd(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)}
+w.appendChild=function(a,b){a.appendChild(b)};w.contains=he;function ke(a,b,c,e){this.top=a;this.right=b;this.bottom=c;this.left=e}w=ke.prototype;w.l=function(){return new ke(this.top,this.right,this.bottom,this.left)};w.contains=function(a){return!this||!a?u:a instanceof ke?a.left>=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom:a.x>=this.left&&a.x<=this.right&&a.y>=this.top&&a.y<=this.bottom};
+w.ceil=function(){this.top=Math.ceil(this.top);this.right=Math.ceil(this.right);this.bottom=Math.ceil(this.bottom);this.left=Math.ceil(this.left);return this};w.floor=function(){this.top=Math.floor(this.top);this.right=Math.floor(this.right);this.bottom=Math.floor(this.bottom);this.left=Math.floor(this.left);return this};w.round=function(){this.top=Math.round(this.top);this.right=Math.round(this.right);this.bottom=Math.round(this.bottom);this.left=Math.round(this.left);return this};
+w.translate=function(a,b){a instanceof Xd?(this.left+=a.x,this.right+=a.x,this.top+=a.y,this.bottom+=a.y):(this.left+=a,this.right+=a,x(b)&&(this.top+=b,this.bottom+=b));return this};w.scale=function(a,b){var c=x(b)?b:a;this.left*=a;this.right*=a;this.top*=c;this.bottom*=c;return this};function le(a,b,c,e){this.left=a;this.top=b;this.width=c;this.height=e}w=le.prototype;w.l=function(){return new le(this.left,this.top,this.width,this.height)};w.Tg=function(a){var b=Math.max(this.left,a.left),c=Math.min(this.left+this.width,a.left+a.width);if(b<=c){var e=Math.max(this.top,a.top);a=Math.min(this.top+this.height,a.top+a.height);if(e<=a)return this.left=b,this.top=e,this.width=c-b,this.height=a-e,q}return u};
+w.contains=function(a){return a instanceof le?this.left<=a.left&&this.left+this.width>=a.left+a.width&&this.top<=a.top&&this.top+this.height>=a.top+a.height:a.x>=this.left&&a.x<=this.left+this.width&&a.y>=this.top&&a.y<=this.top+this.height};function me(a,b){var c=b.x<a.left?a.left-b.x:Math.max(b.x-(a.left+a.width),0),e=b.y<a.top?a.top-b.y:Math.max(b.y-(a.top+a.height),0);return c*c+e*e}w.sf=function(a){return Math.sqrt(me(this,a))};
+w.ceil=function(){this.left=Math.ceil(this.left);this.top=Math.ceil(this.top);this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};w.floor=function(){this.left=Math.floor(this.left);this.top=Math.floor(this.top);this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};w.round=function(){this.left=Math.round(this.left);this.top=Math.round(this.top);this.width=Math.round(this.width);this.height=Math.round(this.height);return this};
+w.translate=function(a,b){a instanceof Xd?(this.left+=a.x,this.top+=a.y):(this.left+=a,x(b)&&(this.top+=b));return this};w.scale=function(a,b){var c=x(b)?b:a;this.left*=a;this.width*=a;this.top*=c;this.height*=c;return this};function ne(a,b){var c=ae(a);return c.defaultView&&c.defaultView.getComputedStyle&&(c=c.defaultView.getComputedStyle(a,t))?c[b]||c.getPropertyValue(b)||"":""}function oe(a,b){return ne(a,b)||(a.currentStyle?a.currentStyle[b]:t)||a.style&&a.style[b]}function pe(a){a=a?ae(a):document;return K&&!(K&&9<=Eb)&&!ie(Zd(a))?a.body:a.documentElement}
+function qe(a){var b=a.getBoundingClientRect();K&&(a=a.ownerDocument,b.left-=a.documentElement.clientLeft+a.body.clientLeft,b.top-=a.documentElement.clientTop+a.body.clientTop);return b}
+function re(a){if(K&&!(K&&8<=Eb))return a.offsetParent;var b=ae(a),c=oe(a,"position"),e="fixed"==c||"absolute"==c;for(a=a.parentNode;a&&a!=b;a=a.parentNode)if(c=oe(a,"position"),e=e&&"static"==c&&a!=b.documentElement&&a!=b.body,!e&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight||"fixed"==c||"absolute"==c||"relative"==c))return a;return t}
+function se(a){for(var b=new ke(0,Infinity,Infinity,0),c=Zd(a),e=c.ka.body,d=c.ka.documentElement,f=!lb&&"CSS1Compat"==c.ka.compatMode?c.ka.documentElement:c.ka.body;a=re(a);)if((!K||0!=a.clientWidth)&&(!lb||0!=a.clientHeight||a!=e)&&a!=e&&a!=d&&"visible"!=oe(a,"overflow")){var g=te(a),h;h=a;if(jb&&!Cb("1.9")){var l=parseFloat(ne(h,"borderLeftWidth"));if(ue(h))var j=h.offsetWidth-h.clientWidth-l-parseFloat(ne(h,"borderRightWidth")),l=l+j;h=new Xd(l,parseFloat(ne(h,"borderTopWidth")))}else h=new Xd(h.clientLeft,
+h.clientTop);g.x+=h.x;g.y+=h.y;b.top=Math.max(b.top,g.y);b.right=Math.min(b.right,g.x+a.clientWidth);b.bottom=Math.min(b.bottom,g.y+a.clientHeight);b.left=Math.max(b.left,g.x)}e=f.scrollLeft;f=f.scrollTop;b.left=Math.max(b.left,e);b.top=Math.max(b.top,f);c=(c.ka.parentWindow||c.ka.defaultView||window).document;c="CSS1Compat"==c.compatMode?c.documentElement:c.body;c=new Vd(c.clientWidth,c.clientHeight);b.right=Math.min(b.right,e+c.width);b.bottom=Math.min(b.bottom,f+c.height);return 0<=b.top&&0<=b.left&&
+b.bottom>b.top&&b.right>b.left?b:t}
+function te(a){var b,c=ae(a),e=oe(a,"position"),d=jb&&c.getBoxObjectFor&&!a.getBoundingClientRect&&"absolute"==e&&(b=c.getBoxObjectFor(a))&&(0>b.screenX||0>b.screenY),f=new Xd(0,0),g=pe(c);if(a==g)return f;if(a.getBoundingClientRect)b=qe(a),a=je(Zd(c)),f.x=b.left+a.x,f.y=b.top+a.y;else if(c.getBoxObjectFor&&!d)b=c.getBoxObjectFor(a),a=c.getBoxObjectFor(g),f.x=b.screenX-a.screenX,f.y=b.screenY-a.screenY;else{b=a;do{f.x+=b.offsetLeft;f.y+=b.offsetTop;b!=a&&(f.x+=b.clientLeft||0,f.y+=b.clientTop||0);
+if(lb&&"fixed"==oe(b,"position")){f.x+=c.body.scrollLeft;f.y+=c.body.scrollTop;break}b=b.offsetParent}while(b&&b!=a);if(ib||lb&&"absolute"==e)f.y-=c.body.offsetTop;for(b=a;(b=re(b))&&b!=c.body&&b!=g;)if(f.x-=b.scrollLeft,!ib||"TR"!=b.tagName)f.y-=b.scrollTop}return f}
+function ve(a){var b=new Xd;if(1==a.nodeType){if(a.getBoundingClientRect){var c=qe(a);b.x=c.left;b.y=c.top}else{var c=je(Zd(a)),e=te(a);b.x=e.x-c.x;b.y=e.y-c.y}if(jb&&!Cb(12)){var d;K?d="-ms-transform":lb?d="-webkit-transform":ib?d="-o-transform":jb&&(d="-moz-transform");var f;d&&(f=oe(a,d));f||(f=oe(a,"transform"));f?(a=f.match(we),a=!a?new Xd(0,0):new Xd(parseFloat(a[1]),parseFloat(a[2]))):a=new Xd(0,0);b=new Xd(b.x+a.x,b.y+a.y)}}else d=oa(a.Gi),f=a,a.targetTouches?f=a.targetTouches[0]:d&&a.sb.targetTouches&&
+(f=a.sb.targetTouches[0]),b.x=f.clientX,b.y=f.clientY;return b}function xe(a,b){"number"==typeof a&&(a=(b?Math.round(a):a)+"px");return a}function ye(a){if("none"!=oe(a,"display"))return ze(a);var b=a.style,c=b.display,e=b.visibility,d=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";a=ze(a);b.display=c;b.position=d;b.visibility=e;return a}
+function ze(a){var b=a.offsetWidth,c=a.offsetHeight,e=lb&&!b&&!c;return(!ia(b)||e)&&a.getBoundingClientRect?(a=qe(a),new Vd(a.right-a.left,a.bottom-a.top)):new Vd(b,c)}function Ae(a,b){a.style.display=b?"":"none"}function ue(a){return"rtl"==oe(a,"direction")}function Be(a,b){if(/^\d+px?$/.test(b))return parseInt(b,10);var c=a.style.left,e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=b;var d=a.style.pixelLeft;a.style.left=c;a.runtimeStyle.left=e;return d}
+function Ce(a,b){var c=a.currentStyle?a.currentStyle[b]:t;return c?Be(a,c):0}var De={thin:2,medium:4,thick:6};function Ee(a,b){if("none"==(a.currentStyle?a.currentStyle[b+"Style"]:t))return 0;var c=a.currentStyle?a.currentStyle[b+"Width"]:t;return c in De?De[c]:Be(a,c)}var we=/matrix\([0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, ([0-9\.\-]+)p?x?, ([0-9\.\-]+)p?x?\)/;function Fe(a,b){jc.call(this);this.H=a;var c=pa(this.H)&&1==this.H.nodeType?this.H:this.H?this.H.body:t;this.aj=!!c&&ue(c);this.Jl=L(this.H,jb?"DOMMouseScroll":"mousewheel",this,b)}C(Fe,jc);
+Fe.prototype.handleEvent=function(a){var b=0,c=0,e=0;a=a.sb;if("mousewheel"==a.type){c=1;if(K||lb&&(bb||Cb("532.0")))c=40;e=Ge(-a.wheelDelta,c);ia(a.wheelDeltaX)?(b=Ge(-a.wheelDeltaX,c),c=Ge(-a.wheelDeltaY,c)):c=e}else e=a.detail,100<e?e=3:-100>e&&(e=-3),ia(a.axis)&&a.axis===a.HORIZONTAL_AXIS?b=e:c=e;x(this.Yg)&&(b=Math.min(Math.max(b,-this.Yg),this.Yg));x(this.Zg)&&(c=Math.min(Math.max(c,-this.Zg),this.Zg));this.aj&&(b=-b);b=new He(e,a,b,c);this.dispatchEvent(b)};
+function Ge(a,b){return lb&&(ab||db)&&0!=a%b?a:a/b}function He(a,b,c,e){b&&this.Ca(b,p);this.type="mousewheel";this.detail=a;this.yl=c;this.Xc=e}C(He,Tb);K||lb&&Cb("525");function Ie(a){M.call(this);this.f="interactor";this.Oa=a;this.Se=this.og=this.ng=this.pg=this.mg=this.qg=t;this.Yd=q;this.Xb=this.Qb=this.wb=u;this.ua=[0,0];this.Ne=new D.m(0,0,0);this.gd=new D.m(0,0,0);this.Vg=0;this.xg=this.Wd=t;this.wg=u;this.R={MOUSEWHEEL_ENABLED:q,MOUSECLICKS_ENABLED:q,KEYBOARD_ENABLED:q,HOVERING_ENABLED:q,CONTEXTMENU_ENABLED:u,TOUCH_ENABLED:q,TOUCH_BOUNCING_ENABLED:u}}C(Ie,M);Ie.prototype.__defineGetter__("config",v("R"));Ie.prototype.__defineGetter__("leftButtonDown",v("wb"));
+Ie.prototype.__defineGetter__("middleButtonDown",v("Qb"));Ie.prototype.__defineGetter__("rightButtonDown",v("Xb"));
+Ie.prototype.Ca=function(){this.R.MOUSEWHEEL_ENABLED?(this.Se=new Fe(this.Oa),this.qg=L(this.Se,"mousewheel",this.Kd.bind(this))):(bc(this.qg),this.Se=t);this.R.MOUSECLICKS_ENABLED?(this.mg=L(this.Oa,"mousedown",this.vj.bind(this)),this.pg=L(this.Oa,"mouseup",this.Aj.bind(this))):(bc(this.mg),bc(this.pg));this.Oa.oncontextmenu=this.R.CONTEXTMENU_ENABLED?t:function(){return u};window.onkeydown=this.R.KEYBOARD_ENABLED?this.ih.bind(this):t;this.R.TOUCH_ENABLED?(this.R.TOUCH_BOUNCING_ENABLED||document.body.addEventListener("touchmove",
+function(a){a.preventDefault()},u),this.ci=L(this.Oa,"touchstart",this.Pj.bind(this)),this.bi=L(this.Oa,"touchmove",this.Nj.bind(this)),this.ai=L(this.Oa,"touchend",this.Jj.bind(this))):(bc(this.ci),bc(this.bi),bc(this.ai));bc(this.ng);bc(this.og);this.ng=L(this.Oa,"mousemove",this.xj.bind(this));this.og=L(this.Oa,"mouseout",this.yj.bind(this))};
+Ie.prototype.vj=function(a){0==a.button?this.wb=q:1==a.button?this.Qb=q:2==a.button&&(this.Xb=q);eval("this.onMouseDown("+this.wb+","+this.Qb+","+this.Xb+")");Je(this);a.preventDefault()};Ie.prototype.uj=aa();Ie.prototype.Aj=function(a){0==a.button?this.wb=u:1==a.button?this.Qb=u:2==a.button&&(this.Xb=u);eval("this.onMouseUp("+this.wb+","+this.Qb+","+this.Xb+")");Je(this);a.preventDefault()};Ie.prototype.__defineGetter__("mousePosition",v("ua"));w=Ie.prototype;w.zj=aa();
+w.yj=function(a){this.Yd=u;this.R.KEYBOARD_ENABLED&&(window.onkeydown=t);this.Xb=this.Qb=this.wb=u;Je(this);this.Ne=new D.m(0,0,0);a.preventDefault()};w.wj=aa();w.Pj=function(a){a.preventDefault();a.Ca(a.sb.targetTouches[0],a.currentTarget);eval("this.onTouchStart("+a.clientX+","+a.clientY+")");this.gd=new D.m(a.clientX,a.clientY,0);this.xg=setTimeout(this.Lj.bind(this,a),500)};w.Oj=aa();
+w.Lj=function(a){eval("this.onTouchHover("+a.clientX+","+a.clientY+")");a=new Jd;a.vb=q;a.ib=this instanceof Ke;this.dispatchEvent(a);this.be=q};w.Kj=aa();function Le(a){clearTimeout(a.xg);if(a.be){var b=new Jd;b.vb=u;b.ib=a instanceof Ke;a.dispatchEvent(b)}a.be=u}w.Jj=function(a){a.preventDefault();eval("this.onTouchEnd()");Le(this)};w.Ij=aa();
+w.Nj=function(a){a.preventDefault();this.be||Le(this);this.touchmoveEvent=a=a.sb;eval("this.onTouchMove(this['touchmoveEvent'])");var b=a.targetTouches;if(1==b.length){a=b[0];var c=[a.clientX,a.clientY];a=new D.m(c[0],c[1],0);var b=c[0]>3*this.Oa.clientWidth/4,e=c[0]<this.Oa.clientWidth/4,d=c[1]<this.Oa.clientHeight/4,c=c[1]>3*this.Oa.clientHeight/4,c=!b&&!e&&!d&&!c,d=this.gd.wa(a);this.gd=a.l();if(this.be)a=new Hd,5<d.x?d.x=1:-5>d.x&&(d.x=-1),5<d.y?d.y=1:-5>d.y&&(d.y=-1),a.ya=d,this.dispatchEvent(a);
+else if(this instanceof Me&&(b||e))a=new Kd,a.V=0>d.y,this.dispatchEvent(a);else if(this instanceof Ke||c)d.scale(3),a=new Id,a.ya=d,this.dispatchEvent(a)}else 2==b.length&&(a=b[0],b=b[1],a=[a.clientX,a.clientY],b=[b.clientX,b.clientY],a=new D.m(a[0],a[1],0),b=new D.m(b[0],b[1],0),d=Gc(a,b),b=d-this.Vg,this.Vg=d,this.gd.wa(a),this.gd=a.l(),10<Math.abs(b)&&(a=new Jd,a.vb=0<b,a.ib=this instanceof Ke,this.dispatchEvent(a)))};w.Mj=aa();
+w.xj=function(a){this.mousemoveEvent=a;eval("this.onMouseMove(this['mousemoveEvent'])");this.Yd=q;this.R.KEYBOARD_ENABLED&&window.onkeydown==t&&(window.onkeydown=this.ih.bind(this));a.preventDefault();var b=a.shiftKey;this.wg=b;this.ua=[a.offsetX,a.offsetY];var c=new D.m(this.ua[0],this.ua[1],0);a=this.Ne.wa(c);this.Ne=c.l();this.R.HOVERING_ENABLED&&((0<Math.abs(a.x)||0<Math.abs(a.y)||this.Qb||this.wb||this.Xb)&&Je(this),this.Wd=setTimeout(function(){Je(this);var a=new Ld;a.fe=c.x;a.ge=c.y;this.dispatchEvent(a);
+this.Wd=t}.bind(this),300));0!=a.Ib()&&(this.wb&&!b?(b=new Id,a.scale(3),b.ya=a,this.dispatchEvent(b)):this.Qb||this.wb&&b?(b=new Hd,b.ya=a,this.dispatchEvent(b)):this.Xb&&(b=new Jd,b.vb=0<a.y,b.ib=u,this.dispatchEvent(b)))};function Je(a){a.Wd&&clearTimeout(a.Wd);a.dispatchEvent(new Md)}w.Bj=aa();w.Kd=function(a){this.mouseWheelEvent=a;eval("this.onMouseWheel(this['mouseWheelEvent'])");Je(this);a.preventDefault()};w.sj=aa();
+w.ih=function(a){if(this.Yd){this.keyEvent=a;eval("this.onKey(this['keyEvent'])");Je(this);var b=a.altKey,c=a.ctrlKey,e=a.metaKey,d=a.shiftKey,f=a.keyCode;82==f&&!b&&!c&&!e&&!d?(a.preventDefault(),a=new Nd,this.dispatchEvent(a)):37<=f&&40>=f&&(a.preventDefault(),d?a=new Hd:b?a=new Jd:(a=new Id,this instanceof Me&&(a=new Kd)),a&&(c=new D.m(0,0,0),37==f?(c.x=5,a.V=u,b&&(a.V=q,a.vb=q,a.ib=u)):39==f?(c.x=-5,a.V=q,b&&(a.vb=u,a.ib=u)):38==f?(c.y=5,a.V=q,b&&(a.vb=q,a.ib=q)):40==f&&(c.y=-5,a.V=u,b&&(a.vb=
+u,a.ib=q)),a.ya=c,this.dispatchEvent(a)))}};A("X.interactor",Ie);A("X.interactor.prototype.init",Ie.prototype.Ca);A("X.interactor.prototype.onMouseDown",Ie.prototype.uj);A("X.interactor.prototype.onMouseUp",Ie.prototype.zj);A("X.interactor.prototype.onMouseMove",Ie.prototype.wj);A("X.interactor.prototype.onMouseWheel",Ie.prototype.Bj);A("X.interactor.prototype.onKey",Ie.prototype.sj);A("X.interactor.prototype.onTouchStart",Ie.prototype.Oj);A("X.interactor.prototype.onTouchMove",Ie.prototype.Mj);
+A("X.interactor.prototype.onTouchEnd",Ie.prototype.Ij);A("X.interactor.prototype.onTouchHover",Ie.prototype.Kj);function Me(a){Ie.call(this,a);this.f="interactor2D"}C(Me,Ie);Me.prototype.Kd=function(a){Me.u.Kd.call(this,a);var b=new Kd;a.Xc==t&&(a.Xc=0);b.V=0>a.Xc;this.dispatchEvent(b)};function Ne(){M.call(this);this.f="parser";this.J=t;this.C=0;this.Zh=0<(new Int8Array((new Int16Array([1])).buffer))[0];this.Mc=q;this.rl=-Infinity;this.ql=Infinity}C(Ne,M);Ne.prototype.parse=function(){m(Error("The function parse() should be overloaded."))};function Oe(a){for(var b=Infinity,c=-Infinity,e=a.length,d=0,d=0;d<e;d++)if(!isNaN(a[d]))var f=a[d],b=Math.min(b,f),c=Math.max(c,f);return[b,c]}
+function Pe(a,b,c){b===p&&(b=0);c===p&&(c=a.length);for(var e="",d=0,d=b;d<c;++d)e+=String.fromCharCode(a[d]);return e}
+function Z(a,b,c){c!=t||(c=1);var e=1,d=Uint8Array;switch(b){case "schar":d=Int8Array;break;case "ushort":d=Uint16Array;e=2;break;case "sshort":d=Int16Array;e=2;break;case "uint":d=Uint32Array;e=4;break;case "sint":d=Int32Array;e=4;break;case "float":d=Float32Array;e=4;break;case "complex":d=Float64Array;e=8;break;case "double":d=Float64Array,e=8}b=new d(a.J.slice(a.C,a.C+=c*e));if(a.Zh!=a.Mc){a=b;b=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);for(d=0;d<a.byteLength;d+=e)for(var f=d+e-1,g=d;f>
+g;f--,g++){var h=b[g];b[g]=b[f];b[f]=h}b=a}return 1==c?b[0]:b}
+function Qe(a,b){var c=[Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE],e=Qc(0,0,0,1),d=Pc();cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(0,0,b[2]-1,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(0,b[1]-
+1,0,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(b[0]-1,0,0,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(b[0]-1,b[1]-1,0,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];
+c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(b[0]-1,0,b[2]-1,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(0,b[1]-1,b[2]-1,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];e=Qc(b[0]-1,b[1]-1,b[2]-1,1);cd(a,e,d);c[0]=d[0]<c[0]?d[0]:c[0];c[1]=d[0]>c[1]?d[0]:c[1];c[2]=d[1]<c[2]?d[1]:
+c[2];c[3]=d[1]>c[3]?d[1]:c[3];c[4]=d[2]<c[4]?d[2]:c[4];c[5]=d[2]>c[5]?d[2]:c[5];return c}
+function Re(a,b){var c=Sc();if(!(a.length==b.length&&a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2])){var e=Math.acos(a[2]),d=Mc(),f=a[0],g=a[1],h=a[2],l=b[0],j=b[1],k=b[2];d[0]=g*k-h*j;d[1]=h*l-f*k;d[2]=f*j-g*l;Oc(d,d);f=Math.cos(e/2);g=Math.sin(e/2)*d[0];h=Math.sin(e/2)*d[1];e=Math.sin(e/2)*d[2];T(c,0,f*f+g*g-h*h-e*e,2*(g*h-f*e),2*(g*e+f*h),0);T(c,1,2*(g*h+f*e),f*f+h*h-g*g-e*e,2*(h*e-f*g),0);T(c,2,2*(g*e-f*h),2*(h*e+f*g),f*f+e*e-h*h-g*g,0)}e=Rc();ad(c,e);return[c,e]}
+function Se(a,b,c,e,d,f,g,h,l){var j=new Te;Oc(c,c);for(var k=[],n=[],s=0;6>s;s++)for(var r=Math.floor(s/2),y=(r+1)%3,z=(r+2)%3,F=(4+2*r)%6,G=0;2>G;G++){var H=(2+G+2*r)%6,B=-(c[r]*(d[s]-a[r])+c[y]*(d[H]-a[y]))/c[z]+a[z];if(B>=d[F]&&B<=d[F+1]||B<=d[F]&&B>=d[F+1]){var E=[];E[r]=d[s];E[y]=d[H];E[z]=B;k.push(E)}else E=[],E[r]=d[s],E[y]=d[H],E[z]=B,n.push(E)}a=Nc(0,0,1);a=Re(c,a);d=a[0];a=a[1];r=[];for(n=0;n<k.length;++n)s=Qc(k[n][0],k[n][1],k[n][2],1),y=Pc(),cd(d,s,y),r.push([y[0],y[1],y[2]]);d=Nc(1,
+0,0);k=Mc();bd(a,d,k);n=Nc(0,1,0);d=Mc();bd(a,n,d);s=[Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE];for(n=n=0;n<r.length;++n)r[n][0]<s[0]&&(s[0]=r[n][0]),r[n][0]>s[1]&&(s[1]=r[n][0]),r[n][1]<s[2]&&(s[2]=r[n][1]),r[n][1]>s[3]&&(s[3]=r[n][1]),r[n][2]<s[4]&&(s[4]=r[n][2]),r[n][2]>s[5]&&(s[5]=r[n][2]);n=Qc(s[0]+(s[1]-s[0])/2,s[2]+(s[3]-s[2])/2,s[4]+(s[5]-s[4])/2,0);r=Pc();$c(a,n,r);y=Math.floor(s[0]);z=Math.ceil(s[1]);y==z&&z++;F=z-y;G=Math.floor(s[2]);
+H=Math.ceil(s[3]);G==H&&H++;B=H-G;E=b[0];b=b[1];var n=Math.ceil(F/E),I=Math.ceil(B/b),N=new Uint8Array(4*n*I),Q=new gd;Q.Ye=n;Q.Xe=I;var I=Pc(),O=Qc(0,0,s[4],1),S=Rc();$c(g.Qh,a,S);for(var da=H-1E-7,J=z-1E-7,ba=0,la=0,U=0,V=G,V=G;V<=da;V+=b){U++;la=0;O[1]=V;for(n=y;n<=J;n+=E){la++;O[0]=n;cd(S,O,I);var Ga=4*ba,tb=Math.floor(I[2]),ub=Math.floor(I[1]),vb=Math.floor(I[0]);if(0<=vb&&vb<g.ca[0]&&0<=ub&&ub<g.ca[1]&&0<=tb&&tb<g.ca[2]){var kb=f[tb][ub][vb],Zc=vb=ub=tb=0;l?((kb=l.get(kb))||(kb=[0,0.61,0,0,
+1]),tb=255*kb[1],ub=255*kb[2],vb=255*kb[3],Zc=255*kb[4]):(tb=ub=vb=255*((kb-g.ra)/(g.ia-g.ra)),Zc=255);N[Ga]=tb;N[++Ga]=ub;N[++Ga]=vb;N[++Ga]=Zc}else N[Ga]=0,N[++Ga]=0,N[++Ga]=0,N[++Ga]=0;ba++}}Q.Wb=N;j.G=Q;j.ei=s;j.Sh=a;j.Rh=S;j.Yh=G;j.ol=H;j.di=y;j.tl=z;j.jg=la;j.ig=U;j.Vc=E;j.K=F;j.Gc=b;j.A=B;j.z=[r[0],r[1],r[2]];j.gc=[c[0],c[1],c[2]];j.Oc=[k[0],k[1],k[2]];j.V=[d[0],d[1],d[2]];j.O=u;j.yb=g;j.Bb=g.yb!=t&&!h?u:q;j.ec=e;j.Gb();j.O=u;return j}
+function Ue(a,b,c,e){var d;d=e.ma;for(var f=[],g=[],h=0;6>h;h++){var l=Math.floor(h/2),j=(l+1)%3,k=(l+2)%3,n=(2+2*l)%6,s=(4+2*l)%6,r=(d[h]-b[l])*(1/c[l]);if(Infinity!=r&&-Infinity!=r){var y=b[j]+c[j]*r,r=b[k]+c[k]*r;y>=d[n]&&y<=d[n+1]&&r>=d[s]&&r<=d[s+1]?(n=[],n[l]=d[h],n[j]=y,n[k]=r,f.push(n)):(n=[],n[l]=d[h],n[j]=y,n[k]=r,g.push(n))}}d=[f,g];b=d[0];e.b[a].k=d;d=Fc(new R(b[0][0],b[0][1],b[0][2]),new R(b[1][0],b[1][1],b[1][2]));e.b[a].nl=d;f=Nc(0,0,1);g=Re(c,f)[0];h=Qc(e.ad[0],e.ad[1],e.ad[2],0);
+f=Pc();cd(g,h,f);g=Pc();h=f[2];g[0]=c[0]*h;g[1]=c[1]*h;g[2]=c[2]*h;g[3]=c[3]*h;0.1>Math.abs(f[0])&&(f[0]=0.1);0.1>Math.abs(f[1])&&(f[1]=0.1);f[0]/=e.ae;f[1]/=e.ae;e.b[a].Ga=[Math.abs(f[0]),Math.abs(f[1])];e.b[a].Sc=f[2];e.b[a].B=g;d=Math.floor(Math.abs(d/f[2]));e.ud[a]=d+1;e.b[a].p=d+1;e.b[a].k[0][0][0]>e.b[a].k[0][1][0]?0<g[0]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d):e.b[a].k[0][0][0]<e.b[a].k[0][1][0]?0>g[0]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=
+d):e.b[a].k[0][0][1]>e.b[a].k[0][1][1]?0<g[1]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d):e.b[a].k[0][0][1]<e.b[a].k[0][1][1]?0>g[1]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d):e.b[a].k[0][0][2]>e.b[a].k[0][1][2]?0<g[2]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d):e.b[a].k[0][0][2]<e.b[a].k[0][1][2]&&0>g[2]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d);e.b[a].Ue=-(c[0]*b[0][0]+c[1]*b[0][1]+c[2]*b[0][2])}
+function Ve(a,b){var c;c=b.J;for(var e=b.ca,d=b.ia,f=b.ra,g=Array(e[2]),h=Array(e[2]),l=e[1]*e[0],j=0,k=0,n=0,s=0,r=0,s=0;s<e[2];s++){var y=c.subarray(s*l,(s+1)*l),r=0;h[s]=Array(e[1]);g[s]=Array(e[1]);for(n=0;n<e[1];n++){h[s][n]=new c.constructor(e[0]);g[s][n]=new c.constructor(e[0]);for(k=0;k<e[0];k++)j=y[r],h[s][n][k]=255*((j-f)/(d-f)),g[s][n][k]=j,r++}}c=[g,h];b.$=c[0];b.bg=c[1];D.Ja(a.f+".reslice");b.L=b.e!=t;b.xa&&(b.cd=b.xa.Ka);b.Sl=[0,0,0];b.s=[b.Ea[0]+(b.hb[0]-1)/2,b.Ea[1]+(b.hb[1]-1)/2,
+b.Ea[2]+(b.hb[2]-1)/2];b.ma=[Math.min(b.Ea[0],b.Ea[0]+b.hb[0]-1),Math.max(b.Ea[0],b.Ea[0]+b.hb[0]-1),Math.min(b.Ea[1],b.Ea[1]+b.hb[1]-1),Math.max(b.Ea[1],b.Ea[1]+b.hb[1]-1),Math.min(b.Ea[2],b.Ea[2]+b.hb[2]-1),Math.max(b.Ea[2],b.Ea[2]+b.hb[2]-1)];b.b=[{},{},{}];c=Nc(b.s[0],b.s[1],b.s[2]);b.b[0].vd=c;e=Nc(1,0,0);Oc(e,e);b.b[0].i=e;d=[1,0,0];b.b[0].w=d;Ue(0,c,e,b);b.c[0].c=Array(b.b[0].p);c[0]=b.b[0].k[0][0][0]+b.b[0].B[0]*Math.floor(b.b[0].p/2);c[1]=b.b[0].k[0][0][1]+b.b[0].B[1]*Math.floor(b.b[0].p/
+2);c[2]=b.b[0].k[0][0][2]+b.b[0].B[2]*Math.floor(b.b[0].p/2);c=Se(c,b.b[0].Ga,b.b[0].i,b.b[0].w,b.ma,b.$,b,b.L,b.cd);b.L&&(c.e=b.e.c[0].c[Math.floor(b.b[0].p/2)].G);b.c[0].c[Math.floor(b.b[0].p/2)]=c;b.Cb=Math.floor(b.b[0].p/2);b.Hc=Math.floor(b.b[0].p/2);c=Nc(b.s[0],b.s[1],b.s[2]);b.b[1].vd=c;e=Nc(0,1,0);Oc(e,e);b.b[1].i=e;d=[0,1,0];b.b[1].w=d;Ue(1,c,e,b);b.c[1].c=Array(b.b[1].p);c[0]=b.b[1].k[0][0][0]+b.b[1].B[0]*Math.floor(b.b[1].p/2);c[1]=b.b[1].k[0][0][1]+b.b[1].B[1]*Math.floor(b.b[1].p/2);c[2]=
+b.b[1].k[0][0][2]+b.b[1].B[2]*Math.floor(b.b[1].p/2);c=Se(c,b.b[1].Ga,b.b[1].i,b.b[1].w,b.ma,b.$,b,b.L,b.cd);b.L&&(c.e=b.e.c[1].c[Math.floor(b.b[1].p/2)].G);b.c[1].c[Math.floor(b.b[1].p/2)]=c;b.Db=Math.floor(b.b[1].p/2);b.Ic=Math.floor(b.b[1].p/2);c=Nc(b.s[0],b.s[1],b.s[2]);b.b[2].vd=c;e=Nc(0,0,1);Oc(e,e);b.b[2].i=e;d=[0,0.392,0.804];b.b[2].w=d;Ue(2,c,e,b);b.c[2].c=Array(b.b[2].p);c[0]=b.b[2].k[0][0][0]+b.b[2].B[0]*Math.floor(b.b[2].p/2);c[1]=b.b[2].k[0][0][1]+b.b[2].B[1]*Math.floor(b.b[2].p/2);c[2]=
+b.b[2].k[0][0][2]+b.b[2].B[2]*Math.floor(b.b[2].p/2);c=Se(c,b.b[2].Ga,b.b[2].i,b.b[2].w,b.ma,b.$,b,b.L,b.cd);b.L&&(c.e=b.e.c[2].c[Math.floor(b.b[2].p/2)].G);b.c[2].c[Math.floor(b.b[2].p/2)]=c;b.Eb=Math.floor(b.b[2].p/2);b.Jc=Math.floor(b.b[2].p/2);D.Da(a.f+".reslice");return b.$};function Te(a){Y.call(this);this.f="slice";this.z=[0,0,0];this.gc=[0,0,1];this.V=[0,1,0];this.Oc=[1,0,0];this.A=this.K=10;this.nc=[0,1,0,0,1,1,1,1,1,0,0,0];this.e=this.yb=t;this.Bb=q;this.ec=[1,1,1];a!=t&&this.rc(a)}C(Te,Y);Te.prototype.rc=function(a){this.z=a.z.slice();this.gc=a.gc.slice();this.V=a.V.slice();this.K=a.K;this.A=a.A;this.yb=a.yb;this.e=a.e;this.Bb=a.Bb;this.ec=a.ec;this.Xh=a.Xh;Te.u.rc.call(this,a)};Te.prototype.__defineSetter__("height",ca("A"));
+Te.prototype.__defineSetter__("width",ca("K"));Te.prototype.__defineGetter__("up",v("V"));Te.prototype.__defineGetter__("right",v("Oc"));Te.prototype.create=function(){this.Gb()};Te.prototype.Ta=function(){Te.u.Ta.call(this);this.z.length=0;this.gc.length=0;this.V.length=0;this.Oc.length=0;this.nc.length=0;this.e=this.yb=t;this.ec.length=0};
+Te.prototype.Gb=function(){var a=(new R(this.gc[0],this.gc[1],this.gc[2])).normalize(),b=new R(this.V[0],this.V[1],this.V[2]),c=new R(this.Oc[0],this.Oc[1],this.Oc[2]),e=new R(this.z[0],this.z[1],this.z[2]),d=Hc(c.l().Y().scale(this.K/2),b.l().Y().scale(this.A/2)),f=new R(d.x+e.x,d.y+e.y,d.d+e.d),d=Hc(c.l().Y().scale(this.K/2),b.l().scale(this.A/2)),g=new R(d.x+e.x,d.y+e.y,d.d+e.d),d=Hc(c.l().scale(this.K/2),b.l().Y().scale(this.A/2)),h=new R(d.x+e.x,d.y+e.y,d.d+e.d),d=Hc(c.l().scale(this.K/2),b.l().scale(this.A/
+2)),b=new R(d.x+e.x,d.y+e.y,d.d+e.d);this.h=new W(18);this.n=new W(18);this.h.add(f.x,f.y,f.d);this.h.add(g.x,g.y,g.d);this.h.add(h.x,h.y,h.d);this.h.add(h.x,h.y,h.d);this.h.add(b.x,b.y,b.d);this.h.add(g.x,g.y,g.d);this.n.add(a.x,a.y,a.d);this.n.add(a.x,a.y,a.d);this.n.add(a.x,a.y,a.d);this.n.add(a.x,a.y,a.d);this.n.add(a.x,a.y,a.d);this.n.add(a.x,a.y,a.d);this.Bb&&(a=new Y,a.h=new W(24),a.n=new W(24),a.h.add(f.x,f.y,f.d),a.h.add(g.x,g.y,g.d),a.h.add(g.x,g.y,g.d),a.h.add(b.x,b.y,b.d),a.h.add(b.x,
+b.y,b.d),a.h.add(h.x,h.y,h.d),a.h.add(h.x,h.y,h.d),a.h.add(f.x,f.y,f.d),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.n.add(0,0,0),a.w=[this.ec[0],this.ec[1],this.ec[2]],a.Ia="LINES",a.Lc=2,this.c.push(a))};A("X.slice",Te);A("X.slice.prototype.create",Te.prototype.create);A("X.slice.prototype.destroy",Te.prototype.Ta);function P(a){Y.call(this);this.f="volume";this.z=[0,0,0];this.ca=[10,10,10];this.ma=[1,1,1];this.ud=[10,10,10];this.qb=[1,1,1];this.jb=[];this.Jc=this.Eb=this.Ic=this.Db=this.Hc=this.Cb=0;this.kc=new Y;this.lc=new Y;this.mc=new Y;this.ee=this.Ra=u;this.X=-1;this.de=[];this.e=t;this.Bb=q;this.fa=Infinity;this.ea=-Infinity;this.vg=q;this.ae=1;this.ia=0;this.J=t;this.b=[];this.s=[0,0,0];this.hb=[0,0,0];this.ad=[0,0,0];this.$=[];this.bg=[];this.$a=t;Fa(this,new xc);Fa(this,new jd);a!=t&&this.rc(a)}
+C(P,Y);P.prototype.rc=function(a){this.z=a.z.slice();this.ca=a.ca.slice();this.qb=a.qb.slice();this.Cb=a.Cb;this.Hc=a.Hc;this.Db=a.Db;this.Ic=a.Ic;this.Eb=a.Eb;this.Jc=a.Jc;this.dg=a.dg.slice();this.kc=new Y(a.kc);this.lc=new Y(a.lc);this.mc=new Y(a.mc);this.ia=a.ia;this.J=a.J;this.Ra=a.Ra;this.ee=a.ee;this.X=a.X;this.e=a.e;this.Bb=a.Bb;P.u.rc.call(this,a)};
+P.prototype.Gb=function(a){this.c.length=0;this.kc.c.length=0;this.lc.c.length=0;this.mc.c.length=0;this.c.push(this.kc);this.c.push(this.lc);this.c.push(this.mc);this.Ea=a.Ac;this.ad=a.Bc;this.hb=a.zc;this.Cc=a.eb;this.Qh=a.gb;this.ia=a.max;this.J=a.data;this.j=q};
+P.prototype.Ta=function(){P.u.Ta.call(this);this.jb.length=0;this.c.length=0;this.kc.c.length=0;this.kc.length=0;this.lc.c.length=0;this.lc.length=0;this.mc.c.length=0;this.mc.length=0;this.J=t;this.ma.length=0;this.b.length=0;this.s.length=0;this.hb.length=0;this.ad.length=0;this.$.length=0;this.bg.length=0;this.$a=t};
+P.prototype.q=function(a){a="undefined"!==typeof a?a:q;if(0<this.c.length){this.Ra!=this.ee&&(!this.Ra&&-1!=this.X&&(this.c[this.X].visible=u),this.j=q,this.ee=this.Ra);if(!this.O)return;for(var b=0,b=0;3>b;b++){var c=this.c[b],e=0,d=0;0==b?(e=this.Cb,d=this.Hc,this.Hc=this.Cb):1==b?(e=this.Db,d=this.Ic,this.Ic=this.Db):2==b&&(e=this.Eb,d=this.Jc,this.Jc=this.Eb);if(this.c[b].c[parseInt(e,10)]==t){var f=Mc();f[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*parseInt(e,10);f[1]=this.b[b].k[0][0][1]+this.b[b].B[1]*
+parseInt(e,10);f[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*parseInt(e,10);if(this.L){var g=Se(f,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.e.$,this.e,this.e.L,this.e.xa.Ka);this.e.c[b].c[parseInt(e,10)]=g;this.e.c[b].q(q)}f=Se(f,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);this.L&&(f.e=f.G,f.e=this.e.c[b].c[parseInt(e,10)].G);c.c[parseInt(e,10)]=f;this.c[b].q(q)}d=c.c[parseInt(d,10)];this.Ra||(d.visible=u);c=c.c[parseInt(e,10)];c.visible=q;c.za=1;this.Ra&&(c.c[0].O=u,b!=this.X&&
+(c.visible=u,c.za=0))}this.Ra&&-1!=this.X&&We(this,this.X)}a&&P.u.q.call(this)};P.prototype.__defineGetter__("dimensions",v("ca"));P.prototype.__defineSetter__("dimensions",ca("ca"));P.prototype.__defineGetter__("spacing",v("qb"));P.prototype.__defineSetter__("spacing",ca("qb"));P.prototype.__defineGetter__("bbox",v("ma"));P.prototype.__defineGetter__("range",v("ud"));P.prototype.__defineGetter__("dimensionsRAS",v("dg"));P.prototype.__defineGetter__("volumeRendering",v("Ra"));
+P.prototype.__defineSetter__("volumeRendering",function(a){this.Ra=a;this.q(u)});P.prototype.__defineGetter__("visible",v("O"));P.prototype.__defineSetter__("visible",function(a){if(a)this.O=a,this.q(u);else{for(var b=this.c,c=b.length,e=0,e=0;e<c;e++)b[e].visible=a;this.O=a;this.j=q}});P.prototype.__defineGetter__("center",v("z"));P.prototype.__defineSetter__("center",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid center."));this.z=a});
+P.prototype.__defineGetter__("volumeRenderingCache",v("de"));P.prototype.__defineSetter__("volumeRenderingCache",function(a){(a==t||!ja(a)||!(3>=a.length))&&m(Error("Invalid volumeRederingCache."));this.de=a});P.prototype.__defineGetter__("image",v("jb"));P.prototype.__defineGetter__("labelmap",function(){this.e||(this.e=new Xe(this));return this.e});P.prototype.__defineGetter__("indexX",v("Cb"));P.prototype.__defineSetter__("indexX",function(a){x(a)&&(0<=a&&a<this.kc.c.length)&&(this.Cb=a,this.q(u))});
+P.prototype.__defineGetter__("indexY",v("Db"));P.prototype.__defineSetter__("indexY",function(a){x(a)&&(0<=a&&a<this.lc.c.length)&&(this.Db=a,this.q(u))});P.prototype.__defineGetter__("indexZ",v("Eb"));P.prototype.__defineSetter__("indexZ",function(a){x(a)&&(0<=a&&a<this.mc.c.length)&&(this.Eb=a,this.q(u))});P.prototype.__defineGetter__("windowLow",v("fa"));P.prototype.__defineSetter__("windowLow",ca("fa"));P.prototype.__defineGetter__("windowHigh",v("ea"));
+P.prototype.__defineSetter__("windowHigh",ca("ea"));P.prototype.__defineGetter__("borders",v("Bb"));P.prototype.__defineSetter__("borders",ca("Bb"));P.prototype.__defineGetter__("reslicing",v("vg"));P.prototype.__defineSetter__("reslicing",ca("vg"));P.prototype.__defineGetter__("resolutionFactor",v("ae"));P.prototype.__defineSetter__("resolutionFactor",ca("ae"));P.prototype.__defineSetter__("xNormX",function(a){this.b[0].i[0]=a});P.prototype.__defineGetter__("xNormX",function(){return this.b[0].i[0]});
+P.prototype.__defineSetter__("xNormY",function(a){this.b[0].i[1]=a});P.prototype.__defineGetter__("xNormY",function(){return this.b[0].i[1]});P.prototype.__defineSetter__("xNormZ",function(a){this.b[0].i[2]=a});P.prototype.__defineGetter__("xNormZ",function(){return this.b[0].i[2]});P.prototype.__defineSetter__("xColor",function(a){this.b[0].w=a});P.prototype.__defineGetter__("xColor",function(){return this.b[0].w});P.prototype.__defineSetter__("yNormX",function(a){this.b[1].i[0]=a});
+P.prototype.__defineGetter__("yNormX",function(){return this.b[1].i[0]});P.prototype.__defineSetter__("yNormY",function(a){this.b[1].i[1]=a});P.prototype.__defineGetter__("yNormY",function(){return this.b[1].i[1]});P.prototype.__defineSetter__("yNormZ",function(a){this.b[1].i[2]=a});P.prototype.__defineGetter__("yNormZ",function(){return this.b[1].i[2]});P.prototype.__defineSetter__("yColor",function(a){this.b[1].w=a});P.prototype.__defineGetter__("yColor",function(){return this.b[1].w});
+P.prototype.__defineSetter__("zNormX",function(a){this.b[2].i[0]=a});P.prototype.__defineGetter__("zNormX",function(){return this.b[2].i[0]});P.prototype.__defineSetter__("zNormY",function(a){this.b[2].i[1]=a});P.prototype.__defineGetter__("zNormY",function(){return this.b[2].i[1]});P.prototype.__defineSetter__("zNormZ",function(a){this.b[2].i[2]=a});P.prototype.__defineGetter__("zNormZ",function(){return this.b[2].i[2]});P.prototype.__defineSetter__("zColor",function(a){this.b[2].w=a});
+P.prototype.__defineGetter__("zColor",function(){return this.b[2].w});
+P.prototype.gk=function(a){this.c[a].visible=u;for(var b=0;b<this.c[a].c.length;b++)"undefined"!=typeof this.c[a].c[b]&&(this.L&&(this.e.c[a].c[b].remove(),this.e.c[a].c[b]=t),this.c[a].c[b].remove(),this.c[a].c[b]=t);Oc(this.b[a].i,this.b[a].i);Ue(a,this.b[a].vd,this.b[a].i,this);this.c[a].c=[];this.c[a].c=Array(this.b[a].p);this.L&&(b=Se(this.b[a].vd,this.b[a].Ga,this.b[a].i,this.b[a].w,this.ma,this.e.$,this.e,this.e.L,this.e.xa.Ka),this.e.c[a].c=[],this.e.c[a].c=Array(this.b[a].p),this.e.c[a].c[Math.floor(this.b[a].p/
+2)]=b,this.e.c[a].q());b=Se(this.b[a].vd,this.b[a].Ga,this.b[a].i,this.b[a].w,this.ma,this.$,this,q,t);window.console.log("modified!");this.L&&(b.e=b.G,b.e=this.e.c[a].c[Math.floor(this.b[a].p/2)].G);this.c[a].c[Math.floor(this.b[a].p/2)]=b;0==a?(this.Cb=Math.floor(this.b[a].p/2),this.Hc=Math.floor(this.b[a].p/2)):1==a?(this.Db=Math.floor(this.b[a].p/2),this.Ic=Math.floor(this.b[a].p/2)):(this.Eb=Math.floor(this.b[a].p/2),this.Jc=Math.floor(this.b[a].p/2));this.c[a].q();this.c[a].c[Math.floor(this.b[a].p/
+2)].O=q};
+function We(a,b){if(!a.Sd)if(!a.Ra||!a.j&&b==a.X)a.X=b;else if(-1==a.de.indexOf(b)){a.de.push(b);a.Sd=q;var c=new Pd;c.D=a;a.dispatchEvent(c);a.onComputing(b);setTimeout(function(){var a=t;0<=this.X&&(a=this.c[this.X],a.visible=u);var a=this.c[b],c=a.c.length,d=Math.floor(c/4),e;for(e=0;e<1*d;e++){if(a.c[e]==t){var j=Mc();j[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*e;j[1]=this.b[b].k[0][0][1]+this.b[b].B[1]*e;j[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*e;if(this.L){var k=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,
+this.ma,this.e.$,this.e,this.e.L,this.e.xa.Ka);this.e.c[b].c[e]=k;this.e.c[b].q(q)}j=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);j.c[0].O=u;this.L&&(j.e=j.G,j.e=this.e.c[b].c[e].G);a.c[e]=j}a.c[e].O=q}$e(this,0.25);setTimeout(function(){for(;e<2*d;e++){if(a.c[e]==t){var j=Mc();j[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*e;j[1]=this.b[b].k[0][0][1]+this.b[b].B[1]*e;j[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*e;if(this.L){var k=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.e.$,
+this.e,this.e.L,this.e.xa.Ka);this.e.c[b].c[e]=k;this.e.c[b].q(q)}j=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);j.c[0].O=u;this.L&&(j.e=j.G,j.e=this.e.c[b].c[e].G);a.c[e]=j}a.c[e].O=q}$e(this,0.5);setTimeout(function(){for(;e<3*d;e++){if(a.c[e]==t){var j=Mc();j[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*e;j[1]=this.b[b].k[0][0][1]+this.b[b].B[1]*e;j[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*e;if(this.L){var k=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.e.$,this.e,this.e.L,
+this.e.xa.Ka);this.e.c[b].c[e]=k;this.e.c[b].q(q)}j=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);j.c[0].O=u;this.L&&(j.e=j.G,j.e=this.e.c[b].c[e].G);a.c[e]=j}a.c[e].O=q}$e(this,0.75);setTimeout(function(){for(e=3*d;e<c;e++){if(a.c[e]==t){var j=Mc();j[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*e;j[1]=this.b[b].k[0][0][1]+this.b[b].B[1]*e;j[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*e;if(this.L){var k=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.e.$,this.e,this.e.L,this.e.xa.Ka);
+this.e.c[b].c[e]=k;this.e.c[b].q(q)}j=Se(j,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);j.c[0].O=u;this.L&&(j.e=j.G,j.e=this.e.c[b].c[e].G);a.c[e]=j}a.c[e].O=q}$e(this,1);setTimeout(function(){this.Sd&&this.c[b].q(q);this.X=b;this.j=u;if(this.Sd){var a=new Rd;a.D=this;this.dispatchEvent(a);this.onComputingEnd(b)}this.Sd=u}.bind(this),10)}.bind(this),10)}.bind(this),10)}.bind(this),10)}.bind(a),10)}else{c=a.c[a.X];c.visible=u;var c=a.c[b],e=c.c.length,d;for(d=0;d<e;d++)c.c[d].O=q;
+a.X=b;a.j=u}}function $e(a,b){var c=new Qd;c.Ad=b;a.dispatchEvent(c);a.onComputingProgress(100*b)}P.prototype.Ff=aa();P.prototype.Hf=aa();P.prototype.Gf=aa();A("X.volume",P);A("X.volume.prototype.modified",P.prototype.q);A("X.volume.prototype.destroy",P.prototype.Ta);A("X.volume.prototype.sliceInfoChanged",P.prototype.gk);A("X.volume.prototype.onComputing",P.prototype.Ff);A("X.volume.prototype.onComputingProgress",P.prototype.Hf);A("X.volume.prototype.onComputingEnd",P.prototype.Gf);function af(){Ne.call(this);this.f="parserOFF"}C(af,Ne);
+af.prototype.parse=function(a,b,c){function e(){l===d&&m(Error("End of file reached unexpectedly."));for(var a=l;a<d;++a)if(10===f[a]){var b=Pe(f,l,a);l=a+1;return b}l=d;return Pe(f,l,d-1)}D.Ja(this.f+".parse");this.J=c;var d=c.byteLength,f=Z(this,"uchar",d);c=[];b.h=new W(d);b.n=new W(d);for(var g=b.h,h=b.n,l=0,j=e(),j=("OFF"===j?e():j).split(" "),k=j[0],j=j[1];k--;){var n=e(),n=n.split(" ");c.push([parseFloat(n[0]),parseFloat(n[1]),parseFloat(n[2])])}for(;j--;){var n=e(),n=n.split(" "),s=c[parseInt(n[1],
+10)],k=c[parseInt(n[2],10)],n=c[parseInt(n[3],10)];g.add(s[0],s[1],s[2]);g.add(k[0],k[1],k[2]);g.add(n[0],n[1],n[2]);s=new R(s[0],s[1],s[2]);n=new R(n[0],n[1],n[2]);k=Ic((new R(k[0],k[1],k[2])).wa(s),n.wa(s));k.normalize();h.add(k.x,k.y,k.d);h.add(k.x,k.y,k.d);h.add(k.x,k.y,k.d)}D.Da(this.f+".parse");c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};A("X.parserOFF",af);A("X.parserOFF.prototype.parse",af.prototype.parse);function bf(){Ne.call(this);this.f="parserDCM"}C(bf,Ne);
+bf.prototype.parse=function(a,b,c){b.yc={};b.yc.yf=0;this.vc(c,b);if(b.r.length==t||b.ta.length==b.r.length){b.yc.yf=b.r.length;var e={};c={};for(var d=0;d<b.ta.length;d++)e.hasOwnProperty(b.ta[d].series_instance_uid)||(e[b.ta[d].series_instance_uid]=[],c[b.ta[d].series_instance_uid]={}),c[b.ta[d].series_instance_uid].hasOwnProperty(b.ta[d].sop_instance_uid)||(c[b.ta[d].series_instance_uid][b.ta[d].sop_instance_uid]=q,e[b.ta[d].series_instance_uid].push(b.ta[d]));var f=Object.keys(e)[0],d=e[f],g=
+d.length;c={};var h="image_position_patient";1==g?(h="image_position_patient",e[f][0].dist=0):d[0].image_position_patient[0]!=d[1].image_position_patient[0]||d[0].image_position_patient[1]!=d[1].image_position_patient[1]||d[0].image_position_patient[2]!=d[1].image_position_patient[2]?(h="image_position_patient",e=new R(d[0].image_orientation_patient[0],d[0].image_orientation_patient[1],d[0].image_orientation_patient[2]),f=new R(d[0].image_orientation_patient[3],d[0].image_orientation_patient[4],d[0].image_orientation_patient[5]),
+e=Ic(e,f),d.map(function(a,b){b.dist=b.image_position_patient[0]*a.x+b.image_position_patient[1]*a.y+b.image_position_patient[2]*a.d;return b}.bind(t,e)),d.sort(function(a,b){return a.dist-b.dist})):d[0].instance_number!=d[1].instance_number?(h="instance_number",d.sort(function(a,b){return a.instance_number-b.instance_number})):window.console.log("Could not resolve the ordering mode");isNaN(d[0].pixel_spacing[0])&&(d[0].pixel_spacing[0]=1);isNaN(d[0].pixel_spacing[1])&&(d[0].pixel_spacing[1]=1);if(1<
+g)switch(h){case "image_position_patient":var l=d[0].image_position_patient,e=d[1].image_position_patient,f=e[0]-l[0],j=e[1]-l[1],k=e[2]-l[2];d[0].pixel_spacing[2]=Math.sqrt(f*f+j*j+k*k);break;case "instance_number":d[0].pixel_spacing[2]=1;break;default:window.console.log("Unkown ordering mode - returning: "+h)}else d[0].pixel_spacing[2]=1;e=1;switch(h){case "image_position_patient":var l=d[0].image_position_patient,n=d[g-1].image_position_patient,f=n[0]-l[0],j=n[1]-l[1],k=n[2]-l[2],f=Math.sqrt(f*
+f+j*j+k*k),e=e+Math.round(f/d[0].pixel_spacing[2]);break;case "instance_number":e+=Math.abs(d[g-1].instance_number-d[0].instance_number);break;default:window.console.log("Unkown ordering mode - returning: "+h)}l=d[0].columns*d[0].rows;f=l*e;n=t;switch(d[0].gf){case 8:n=new Uint8Array(f);break;case 16:n=new Uint16Array(f);break;case 32:n=new Uint32Array(f);default:window.console.log("Unknown number of bits allocated - using default: 32 bits")}b.qb=d[0].pixel_spacing;for(var s=0;s<g;s++){var r=d[s].data,
+f=0;switch(h){case "image_position_patient":f=d[s].image_position_patient[0]-d[0].image_position_patient[0];j=d[s].image_position_patient[1]-d[0].image_position_patient[1];k=d[s].image_position_patient[2]-d[0].image_position_patient[2];f=Math.round(Math.sqrt(f*f+j*j+k*k)/d[0].pixel_spacing[2]);break;case "instance_number":f=d[s].instance_number-d[0].instance_number;break;default:window.console.log("Unkown ordering mode - returning: "+h)}n.set(r,f*l)}c.data=n;b.J=n;b.ca=[d[0].columns,d[0].rows,e];
+c.zl=b.ca;e=Oe(n);g=e[0];e=e[1];c.min=b.ra=b.fa=g;c.max=b.ia=b.ea=e;-Infinity==b.U&&(b.U=g);Infinity==b.W&&(b.W=e);j=d[0].image_position_patient;g=Rc();if("false"==b.reslicing||b.reslicing==u)T(g,0,d[0].pixel_spacing[0],0,0,0),T(g,1,0,d[0].pixel_spacing[1],0,0),T(g,2,0,0,d[0].pixel_spacing[2],0),T(g,3,0,0,0,1);else switch(h){case "image_position_patient":e=new R(d[0].image_orientation_patient[0],d[0].image_orientation_patient[1],d[0].image_orientation_patient[2]);f=new R(d[0].image_orientation_patient[3],
+d[0].image_orientation_patient[4],d[0].image_orientation_patient[5]);e=Ic(e,f);T(g,0,-d[0].image_orientation_patient[0]*d[0].pixel_spacing[0],-d[0].image_orientation_patient[3]*d[0].pixel_spacing[1],-e.x*d[0].pixel_spacing[2],-j[0]);T(g,1,-d[0].image_orientation_patient[1]*d[0].pixel_spacing[0],-d[0].image_orientation_patient[4]*d[0].pixel_spacing[1],-e.y*d[0].pixel_spacing[2],-j[1]);T(g,2,d[0].image_orientation_patient[2]*d[0].pixel_spacing[0],d[0].image_orientation_patient[5]*d[0].pixel_spacing[1],
+e.d*d[0].pixel_spacing[2],j[2]);T(g,3,0,0,0,1);break;case "instance_number":T(g,0,-1,0,0,-j[0]);T(g,1,-0,-1,-0,-j[1]);T(g,2,0,0,1,j[2]);T(g,3,0,0,0,1);break;default:window.console.log("Unkown ordering mode - returning: "+h)}c.eb=g;c.gb=Rc();ad(c.eb,c.gb);h=Qc(0,0,0,1);d=Pc();cd(g,h,d);h=Qc(1,1,1,1);e=Pc();cd(g,h,e);c.Bc=[e[0]-d[0],e[1]-d[1],e[2]-d[2]];d=Qe(g,[b.ca[0],b.ca[1],b.ca[2]]);c.zc=[d[1]-d[0]+1,d[3]-d[2]+1,d[5]-d[4]+1];c.Ac=[d[0],d[2],d[4]];b.Gb(c);b.jb=Ve(this,b)}c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};
+function cf(a,b,c,e){switch(c){case 16975:case 20819:case 20053:case 22351:c=function(a){for(var b="",c=128;1<=c;c/=2)b+=a&c?"1":"0";return b};e=a[b++];a=a[b++];e=parseInt(c((a&65280)>>8)+c(a&255)+(c((e&65280)>>8)+c(e&255)),2);4294967295==e&&(e=0);b+=e/2;break;default:b+=e/2}return b}
+bf.prototype.vc=function(a,b){this.J=a;if("undefined"==typeof b.ta||b.ta==t)b.ta=[];for(var c={pixel_spacing:[0.1,0.1,Infinity],image_orientation_patient:[1,0,0,0,1,0],image_position_patient:[0,0,0],transfer_syntax_uid:"no_transfer_syntax_uid"},e=Z(this,"ushort",this.J.byteLength),d=66,f=t,g=t,h=t,l=t;d<e.length;)switch(f=e[d++],g=e[d++],h=e[d++],l=e[d++],"1.2.840.10008.1.2"==c.transfer_syntax_uid&&0==l&&(l=h),f){case 2:switch(g){case 16:for(var j="",f=f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>
+8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);c.transfer_syntax_uid=j.replace(/\0/g,"");break;default:d=cf(e,d,h,l)}break;case 40:switch(g){case 16:c.rows=e[d];d+=l/2;break;case 17:c.columns=e[d];d+=l/2;break;case 256:c.gf=e[d];d+=l/2;break;case 257:c.bits_stored=e[d];d+=l/2;break;case 2:c.number_of_images=e[d];d+=l/2;break;case 48:j="";for(f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);j=j.split("\\");c.pixel_spacing=[parseFloat(j[0]),parseFloat(j[1]),
+Infinity];break;default:d=cf(e,d,h,l)}break;case 32:switch(g){case 14:c.series_instance_uid="";for(f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,c.series_instance_uid+=String.fromCharCode(g),c.series_instance_uid+=String.fromCharCode(h);break;case 19:j="";for(f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);c.instance_number=parseInt(j,10);break;case 50:j="";for(f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);
+j=j.split("\\");c.image_position_patient=[parseFloat(j[0]),parseFloat(j[1]),parseFloat(j[2])];break;case 55:j="";for(f=0;f<l/2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);j=j.split("\\");c.image_orientation_patient=[parseFloat(j[0]),parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3]),parseFloat(j[4]),parseFloat(j[5])];break;default:d=cf(e,d,h,l)}break;case 65534:switch(g){default:l=0,d+=l/2}break;case 8:switch(g){case 24:c.sop_instance_uid="";for(f=0;f<l/
+2;f++)h=e[d++],g=h&255,h=(h&65280)>>8,c.sop_instance_uid+=String.fromCharCode(g),c.sop_instance_uid+=String.fromCharCode(h);break;default:d=cf(e,d,h,l)}break;case 16:switch(g){case 8720:for(f=0;f<l/2;f++)d++;break;default:d=cf(e,d,h,l)}break;default:d=cf(e,d,h,l)}switch(c.gf){case 8:c.data=new Uint8Array(c.columns*c.rows);break;case 16:c.data=new Uint16Array(c.columns*c.rows);break;case 32:c.data=new Uint32Array(c.columns*c.rows)}this.C=this.J.byteLength-2*c.columns*c.rows;e=t;switch(c.gf){case 8:e=
+Z(this,"uchar",c.columns*c.rows);break;case 16:e=Z(this,"ushort",c.columns*c.rows);break;case 32:e=Z(this,"uint",c.columns*c.rows)}c.data=e;b.ta.push(c);return b};A("X.parserDCM",bf);A("X.parserDCM.prototype.parse",bf.prototype.parse);function df(){Ne.call(this);this.f="parserVTK"}C(df,Ne);
+df.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");var e=b.h,d=b.n,f=new Uint8Array(c),g="";b.h=e=new W(c.byteLength);b.n=d=new W(c.byteLength);c=0;for(var h=f.length;c<h;c+=32768)g+=Pe(f,c,Math.min(c+32768,h));f=g.split("\n");g=f.length;this.yd=this.zd=t;this.hc=[];this.Pa=id;this.Te=this.Tb=this.Nb=this.Ub=u;c=0;for(h=g%8;h--;)ef(this,f[c]),c++;for(h=0.125*g^0;h--;)ef(this,f[c]),c++,ef(this,f[c]),c++,ef(this,f[c]),c++,ef(this,f[c]),c++,ef(this,f[c]),c++,ef(this,f[c]),c++,ef(this,f[c]),c++,
+ef(this,f[c]),c++;c=this.zd;var f=this.yd,g=f.length,l=h=this.hc.length;do{var j=this.hc[h-l],k=j.length,n;for(n=0;n<k&&!("LINES"==this.Pa&&n+1>=k);n++){var s=parseInt(j[n],10),r=c.get(s);e.add(r[0],r[1],r[2]);var y=s,z=r;"LINES"==this.Pa?(y=parseInt(j[n+1],10),z=c.get(y),e.add(z[0],z[1],z[2])):"TRIANGLE_STRIPS"==this.Pa&&(0==n||n==k-1)&&e.add(r[0],r[1],r[2]);s<g?(z=f.get(s),d.add(z[0],z[1],z[2]),"LINES"==this.Pa?(y=f.get(y),d.add(y[0],y[1],y[2])):"TRIANGLE_STRIPS"==this.Pa&&(0==n||n==k-1)&&d.add(z[0],
+z[1],z[2])):(y=new R(r[0],r[1],r[2]),y.normalize(),d.add(y.x,y.y,y.d),"LINES"==this.Pa?(y=new R(z[0],z[1],z[2]),y.normalize(),d.add(y.x,y.y,y.d)):"TRIANGLE_STRIPS"==this.Pa&&(0==n||n==k-1)&&d.add(y.x,y.y,y.d))}l--}while(0<l);b.Ia=this.Pa;D.Da(this.f+".parse");e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};
+function ef(a,b){b=b.replace(/^\s+|\s+$/g,"");var c=b.split(" "),e=c.length,d=c[0];switch(d){case "POINTS":a.Ub=q;a.Nb=u;a.Tb=u;c=parseInt(c[1],10);a.zd=new W(3*c);a.yd=new W(3*c);return;case "VERTICES":a.Nb=q;a.Ub=u;a.Tb=u;c=parseInt(c[1],10);3<=c?a.Pa=id:1==c?a.Pa="POINTS":m(Error("This VTK file is not supported!"));a.hc=[];return;case "TRIANGLE_STRIPS":a.Nb=q;a.Ub=u;a.Tb=u;a.Pa="TRIANGLE_STRIPS";a.hc=[];return;case "LINES":a.Nb=q;a.Ub=u;a.Tb=u;a.Pa="LINES";a.hc=[];return;case "POLYGONS":a.Nb=q;
+a.Ub=u;a.Tb=u;a.Pa="POLYGONS";a.hc=[];return;case "POINT_DATA":a.Tb=q;a.Ub=u;a.Nb=u;return}if(a.Ub)if(1==e||isNaN(parseFloat(d)))a.Ub=u;else{if(3<=e){var d=parseFloat(c[0]),f=parseFloat(c[1]),g=parseFloat(c[2]);a.zd.add(d,f,g)}6<=e&&(d=parseFloat(c[3]),f=parseFloat(c[4]),g=parseFloat(c[5]),a.zd.add(d,f,g));9<=e&&(e=parseFloat(c[6]),d=parseFloat(c[7]),c=parseFloat(c[8]),a.zd.add(e,d,c))}else a.Nb?1==e||isNaN(parseFloat(d))?a.Nb=u:(c=c.slice(1),a.hc.push(c)):a.Tb&&("NORMALS"==d?a.Te=q:1==e||isNaN(parseFloat(d))?
+(a.Tb=u,a.Te=u):a.Te&&(3<=e&&(d=parseFloat(c[0]),f=parseFloat(c[1]),g=parseFloat(c[2]),a.yd.add(d,f,g)),6<=e&&(d=parseFloat(c[3]),f=parseFloat(c[4]),g=parseFloat(c[5]),a.yd.add(d,f,g)),9<=e&&(e=parseFloat(c[6]),d=parseFloat(c[7]),c=parseFloat(c[8]),a.yd.add(e,d,c))))}A("X.parserVTK",df);A("X.parserVTK.prototype.parse",df.prototype.parse);function ff(){Ne.call(this);this.f="parserFSM";this.Mc=u}C(ff,Ne);
+ff.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;var e=b.h,d=b.n;b.Nc=[];var f=b.Nc;c=0;var g;do g=Z(this,"uchar"),c++;while(200>c&&10!=g);Z(this,"uchar");d=Z(this,"uint");c=Z(this,"uint");var h=Z(this,"float",3*d);g=Z(this,"uint",3*c);var l=new Uint32Array(d),j=new Float32Array(9*c);b.h=e=new W(9*c);b.n=d=new W(9*c);var k;for(k=0;k<c;k++){var n=3*k,s=g[n],r=g[n+1],y=g[n+2];f.push(s);f.push(r);f.push(y);l[s]+=1;l[r]+=1;l[y]+=1;var n=3*s,z=3*r,F=3*y,G=h[n],H=h[n+1],B=h[n+2],r=h[z],
+y=h[z+1],s=h[z+2],E=h[F],I=h[F+1],N=h[F+2];e.add(G,H,B);e.add(r,y,s);e.add(E,I,N);G=new R(G,H,B);E=new R(E,I,N);r=(new R(r,y,s)).l().wa(G);y=E.l().wa(G);r=Ic(r,y).normalize();j[n]+=r.x;j[n+1]+=r.y;j[n+2]+=r.d;j[z]+=r.x;j[z+1]+=r.y;j[z+2]+=r.d;j[F]+=r.x;j[F+1]+=r.y;j[F+2]+=r.d}for(k=0;k<c;k++)n=3*k,s=g[n],r=g[n+1],y=g[n+2],n=3*s,z=3*r,F=3*y,f=new R(j[z],j[z+1],j[z+2]),h=new R(j[F],j[F+1],j[F+2]),n=(new R(j[n],j[n+1],j[n+2])).scale(1/l[s]).normalize(),f=f.scale(1/l[r]).normalize(),h=h.scale(1/l[y]).normalize(),
+d.add(n.x,n.y,n.d),d.add(f.x,f.y,f.d),d.add(h.x,h.y,h.d);c=Z(this,"uchar",this.J.byteLength-this.C);g=t;for(n=0;n<c.length;n++)if(99==c[n]&&114==c[n+1]&&97==c[n+2]&&115==c[n+3]){for(d=g=n+9;10!=c[n]&&n<c.length;)d++,n++;g=Pe(c.subarray(g,d)).split(" ");break}g&&(b.ja.Dh(parseFloat(g[0])),b.ja.Eh(parseFloat(g[1])),b.ja.Fh(parseFloat(g[2])));b.Ia=id;D.Da(this.f+".parse");c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};A("X.parserFSM",ff);A("X.parserFSM.prototype.parse",ff.prototype.parse);var gf={lf:function(a,b,c){return gf.update(a,0,b,c)},update:function(a,b,c,e){var d=gf.Mh,f="number"===typeof c?c:c=0;e="number"===typeof e?e:a.length;b^=4294967295;for(f=e&7;f--;++c)b=b>>>8^d[(b^a[c])&255];for(f=e>>3;f--;c+=8)b=b>>>8^d[(b^a[c])&255],b=b>>>8^d[(b^a[c+1])&255],b=b>>>8^d[(b^a[c+2])&255],b=b>>>8^d[(b^a[c+3])&255],b=b>>>8^d[(b^a[c+4])&255],b=b>>>8^d[(b^a[c+5])&255],b=b>>>8^d[(b^a[c+6])&255],b=b>>>8^d[(b^a[c+7])&255];return(b^4294967295)>>>0}};
+gf.Mh=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,
+3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,
+366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,
+3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,
+1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,
+1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function hf(a){var b=a.length,c=0,e=Number.POSITIVE_INFINITY,d,f,g,h,l,j,k,n,s;for(n=0;n<b;++n)a[n]>c&&(c=a[n]),a[n]<e&&(e=a[n]);d=1<<c;f=new Uint32Array(d);g=1;h=0;for(l=2;g<=c;){for(n=0;n<b;++n)if(a[n]===g){j=0;k=h;for(s=0;s<g;++s)j=j<<1|k&1,k>>=1;for(s=j;s<d;s+=l)f[s]=g<<16|n;++h}++g;h<<=1;l<<=1}return[f,c,e]};function jf(a,b){this.hf=[];this.jf=32768;this.rb=this.Bd=this.M=this.Vf=0;this.input=new Uint8Array(a);this.Ag=u;this.kf=kf;this.Jb=u;if(b||!(b={}))b.index&&(this.M=b.index),b.bufferSize&&(this.jf=b.bufferSize),b.bufferType&&(this.kf=b.bufferType),b.resize&&(this.Jb=b.resize);switch(this.kf){case lf:this.la=32768;this.Ua=new Uint8Array(32768+this.jf+258);break;case kf:this.la=0;this.Ua=new Uint8Array(this.jf);this.tc=this.xi;this.Dg=this.mi;this.rf=this.ri;break;default:m(Error("invalid inflate mode"))}}
+var lf=0,kf=1;
+jf.prototype.Yb=function(){for(;!this.Ag;){var a=mf(this,3);a&1&&(this.Ag=q);a>>>=1;switch(a){case 0:var a=this.input,b=this.M,c=this.Ua,e=this.la,d=p,f=p,g=p,h=c.length,d=p;this.rb=this.Bd=0;d=a[b++];d===p&&m(Error("invalid uncompressed block header: LEN (first byte)"));f=d;d=a[b++];d===p&&m(Error("invalid uncompressed block header: LEN (second byte)"));f|=d<<8;d=a[b++];d===p&&m(Error("invalid uncompressed block header: NLEN (first byte)"));g=d;d=a[b++];d===p&&m(Error("invalid uncompressed block header: NLEN (second byte)"));g|=
+d<<8;f===~g&&m(Error("invalid uncompressed block header: length verify"));b+f>a.length&&m(Error("input buffer is broken"));switch(this.kf){case lf:for(;e+f>c.length;)d=h-e,f-=d,c.set(a.subarray(b,b+d),e),e+=d,b+=d,this.la=e,c=this.tc(),e=this.la;break;case kf:for(;e+f>c.length;)c=this.tc({Jg:2});break;default:m(Error("invalid inflate mode"))}c.set(a.subarray(b,b+f),e);e+=f;this.M=b+=f;this.la=e;this.Ua=c;break;case 1:this.rf(nf,of);break;case 2:pf(this);break;default:m(Error("unknown BTYPE: "+a))}}return this.Dg()};
+var qf=new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rf=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]),sf=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]),tf=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]),uf=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),vf=new Uint8Array(288),
+wf,xf;wf=0;for(xf=vf.length;wf<xf;++wf)vf[wf]=143>=wf?8:255>=wf?9:279>=wf?7:8;var nf=hf(vf),yf=new Uint8Array(30),zf,Af;zf=0;for(Af=yf.length;zf<Af;++zf)yf[zf]=5;var of=hf(yf);function mf(a,b){for(var c=a.Bd,e=a.rb,d=a.input,f=a.M,g;e<b;)g=d[f++],g===p&&m(Error("input buffer is broken")),c|=g<<e,e+=8;g=c&(1<<b)-1;a.Bd=c>>>b;a.rb=e-b;a.M=f;return g}
+function Bf(a,b){for(var c=a.Bd,e=a.rb,d=a.input,f=a.M,g=b[0],h=b[1],l;e<h;)l=d[f++],l===p&&m(Error("input buffer is broken")),c|=l<<e,e+=8;d=g[c&(1<<h)-1];g=d>>>16;a.Bd=c>>g;a.rb=e-g;a.M=f;return d&65535}
+function pf(a){function b(a,b,c){var d,e,f;for(f=0;f<a;)switch(d=Bf(this,b),d){case 16:for(d=3+mf(this,2);d--;)c[f++]=e;break;case 17:for(d=3+mf(this,3);d--;)c[f++]=0;e=0;break;case 18:for(d=11+mf(this,7);d--;)c[f++]=0;e=0;break;default:e=c[f++]=d}return c}var c=mf(a,5)+257,e=mf(a,5)+1,d=mf(a,4)+4,f=new Uint8Array(qf.length),g;for(g=0;g<d;++g)f[qf[g]]=mf(a,3);d=hf(f);f=new Uint8Array(c);g=new Uint8Array(e);a.rf(hf(b.call(a,c,d,f)),hf(b.call(a,e,d,g)))}w=jf.prototype;
+w.rf=function(a,b){var c=this.Ua,e=this.la;this.Gg=a;for(var d=c.length-258,f,g,h;256!==(f=Bf(this,a));)if(256>f)e>=d&&(this.la=e,c=this.tc(),e=this.la),c[e++]=f;else{f-=257;h=rf[f];0<sf[f]&&(h+=mf(this,sf[f]));f=Bf(this,b);g=tf[f];0<uf[f]&&(g+=mf(this,uf[f]));e>=d&&(this.la=e,c=this.tc(),e=this.la);for(;h--;)c[e]=c[e++-g]}for(;8<=this.rb;)this.rb-=8,this.M--;this.la=e};
+w.ri=function(a,b){var c=this.Ua,e=this.la;this.Gg=a;for(var d=c.length,f,g,h;256!==(f=Bf(this,a));)if(256>f)e>=d&&(c=this.tc(),d=c.length),c[e++]=f;else{f-=257;h=rf[f];0<sf[f]&&(h+=mf(this,sf[f]));f=Bf(this,b);g=tf[f];0<uf[f]&&(g+=mf(this,uf[f]));e+h>d&&(c=this.tc(),d=c.length);for(;h--;)c[e]=c[e++-g]}for(;8<=this.rb;)this.rb-=8,this.M--;this.la=e};
+w.tc=function(){var a=new Uint8Array(this.la-32768),b=this.la-32768,c=this.Ua;a.set(c.subarray(32768,a.length));this.hf.push(a);this.Vf+=a.length;c.set(c.subarray(b,b+32768));this.la=32768;return c};w.xi=function(a){var b=this.input.length/this.M+1|0,c=this.input,e=this.Ua;a&&("number"===typeof a.Jg&&(b=a.Jg),"number"===typeof a.fi&&(b+=a.fi));2>b?(a=(c.length-this.M)/this.Gg[2],a=258*(a/2)|0,a=a<e.length?e.length+a:e.length<<1):a=e.length*b;a=new Uint8Array(a);a.set(e);return this.Ua=a};
+w.Dg=function(){var a=0,b=this.Ua,c=this.hf,e,d=new Uint8Array(this.Vf+(this.la-32768)),f,g,h,l;if(0===c.length)return this.Ua.subarray(32768,this.la);f=0;for(g=c.length;f<g;++f){e=c[f];h=0;for(l=e.length;h<l;++h)d[a++]=e[h]}f=32768;for(g=this.la;f<g;++f)d[a++]=b[f];this.hf=[];return this.buffer=d};w.mi=function(){var a,b=this.la;this.Jb?(a=new Uint8Array(b),a.set(this.Ua.subarray(0,b))):a=this.Ua.subarray(0,b);return this.buffer=a};new Uint8Array(256);var Cf;for(Cf=0;256>Cf;++Cf)for(var Df=Cf,Ef=7,Df=Df>>>1;Df;Df>>>=1)--Ef;var Ff=[],Gf;for(Gf=0;288>Gf;Gf++)switch(q){case 143>=Gf:Ff.push([Gf+48,8]);break;case 255>=Gf:Ff.push([Gf-144+400,9]);break;case 279>=Gf:Ff.push([Gf-256+0,7]);break;case 287>=Gf:Ff.push([Gf-280+192,8]);break;default:m("invalid literal: "+Gf)}
+function Hf(){var a=If;switch(q){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-
+31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:m("invalid length: "+a)}}var Jf=[],If,Kf;
+for(If=3;258>=If;If++)Kf=Hf(),Jf[If]=Kf[2]<<24|Kf[1]<<16|Kf[0];new Uint32Array(Jf);function Lf(){};function Mf(a){this.input=a;this.M=0;this.member=[]}
+Mf.prototype.Yb=function(){for(var a=this.input.length;this.M<a;){var b=new Lf,c=p,e=p,d=p,f=c=d=p,g=p,c=c=p,h=this.input,e=this.M;b.Pg=h[e++];b.Qg=h[e++];(31!==b.Pg||139!==b.Qg)&&m(Error("invalid file signature:",b.Pg,b.Qg));b.Cg=h[e++];switch(b.Cg){case 8:break;default:m(Error("unknown compression method: "+b.Cg))}b.me=h[e++];c=h[e++]|h[e++]<<8|h[e++]<<16|h[e++]<<24;b.Ml=new Date(1E3*c);b.Xl=h[e++];b.Rl=h[e++];0<(b.me&4)&&(b.He=h[e++]|h[e++]<<8,e+=b.He);if(0<(b.me&8)){g=[];for(f=0;0<(c=h[e++]);)g[f++]=
+String.fromCharCode(c);b.name=g.join("")}if(0<(b.me&16)){g=[];for(f=0;0<(c=h[e++]);)g[f++]=String.fromCharCode(c);b.comment=g.join("")}0<(b.me&2)&&(b.ni=gf.lf(h,0,e)&65535,b.ni!==(h[e++]|h[e++]<<8)&&m(Error("invalid header crc16")));c=h[h.length-4]|h[h.length-3]<<8|h[h.length-2]<<16|h[h.length-1]<<24;h.length-e-4-4<512*c&&(d=c);e=new jf(h,{index:e,bufferSize:d});b.data=d=e.Yb();e=e.M;b.wl=c=(h[e++]|h[e++]<<8|h[e++]<<16|h[e++]<<24)>>>0;gf.lf(d)!==c&&m(Error("invalid CRC-32 checksum: 0x"+gf.lf(d).toString(16)+
+" / 0x"+c.toString(16)));b.Fl=c=(h[e++]|h[e++]<<8|h[e++]<<16|h[e++]<<24)>>>0;(d.length&4294967295)!==c&&m(Error("invalid input size: "+(d.length&4294967295)+" / "+c));this.member.push(b);this.M=e}a=this.member;b=d=e=0;for(h=a.length;b<h;++b)d+=a[b].data.length;d=new Uint8Array(d);for(b=0;b<h;++b)d.set(a[b].data,e),e+=a[b].data.length;return d};function Nf(){Ne.call(this);this.f="parserMGZ";this.Mc=u}C(Nf,Ne);
+Nf.prototype.parse=function(a,b,c,e){D.Ja(this.f+".parse");window.console.log(b);e&&(c=(new Mf(new Uint8Array(c))).Yb(),c=c.buffer);e=this.vc(c);var d=[e.Bf,e.Cf,e.Df];b.ca=d;var f=e.Gh;b.qb=f;c=e.min;var g=e.max;b.ra=b.fa=c;b.ia=b.ea=g;-Infinity==b.U&&(b.U=c);Infinity==b.W&&(b.W=g);c=Rc();if("false"==b.reslicing||b.reslicing==u)T(c,0,b.qb[0],0,0,0),T(c,1,0,b.qb[1],0,0),T(c,2,0,0,b.qb[2],0),T(c,3,0,0,0,1),Uc(c,0,0,0,1);else{T(c,0,e.fb[0][0],e.fb[1][0],e.fb[2][0],0);T(c,1,e.fb[0][1],e.fb[1][1],e.fb[2][1],
+0);T(c,2,e.fb[0][2],e.fb[1][2],e.fb[2][2],0);T(c,3,0,0,0,1);for(var g=d[0]/2,h=d[1]/2,d=d[2]/2,l=[0,0,0],j=0;3>j;++j)l[j]=e.fb[3][j]-(c[j+0]*f[0]*g+c[j+4]*f[1]*h+c[j+8]*f[2]*d);Uc(c,l[0],l[1],l[2],1)}e.eb=c;e.gb=Rc();ad(e.eb,e.gb);g=Qc(0,0,0,1);f=Pc();cd(c,g,f);h=Qc(1,1,1,1);g=Pc();cd(c,h,g);c=Qe(c,b.ca);e.Bc=[g[0]-f[0],g[1]-f[1],g[2]-f[2]];e.zc=[c[1]-c[0]+1,c[3]-c[2]+1,c[5]-c[4]+1];e.Ac=[c[0],c[2],c[4]];b.Gb(e);D.Da(this.f+".parse");b.jb=Ve(this,b);e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};
+Nf.prototype.vc=function(a){this.J=a;a={version:0,Ph:0,Nh:0,Ei:0,Oh:0,Bf:0,Cf:0,Df:0,nj:0,type:0,vi:0,vh:0,Ck:t,fb:t,Gh:t,data:t,min:Infinity,max:-Infinity};a.version=Z(this,"uint");a.Bf=Z(this,"uint");a.Cf=Z(this,"uint");a.Df=Z(this,"uint");a.nj=Z(this,"uint");a.type=Z(this,"uint");a.vi=Z(this,"uint");a.vh=Z(this,"ushort");if(0<a.vh){a.Gh=Z(this,"float",3);var b=[];b.push(Z(this,"float",3));b.push(Z(this,"float",3));b.push(Z(this,"float",3));b.push(Z(this,"float",3));a.fb=b}this.C=284;b=a.Bf*a.Cf*
+a.Df;switch(a.type){case 0:a.data=Z(this,"uchar",b);break;case 1:a.data=Z(this,"uint",b);break;case 3:a.data=Z(this,"float",b);break;case 4:a.data=Z(this,"ushort",b);break;default:m(Error("Unsupported MGH/MGZ data type: "+a.type))}b=Oe(a.data);a.min=b[0];a.max=b[1];this.C+16<this.J.byteLength&&(a.Ph=Z(this,"float"),a.Ei=Z(this,"float"),a.Nh=Z(this,"float"),a.Oh=Z(this,"float"));return a};A("X.parserMGZ",Nf);A("X.parserMGZ.prototype.parse",Nf.prototype.parse);function Of(){Ne.call(this);this.f="parserLBL"}C(Of,Ne);
+Of.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");var e=b.Nc,d=e.length;0==d&&m(Error("No _pointIndices defined on the X.object."));this.J=c;var f=[],g=Z(this,"uchar",c.byteLength),h=g.length,l=u,j=0;for(c=1;c<h;c++)10==g[c-1]?(j=c,l=q):l&&32==g[c]&&(f.push(parseInt(Pe(g,j,c),10)),l=u);g=b.F.I?b.F.I:new Float32Array(d);h=f.length;for(c=0;c<h;c++)g[f[c]]=1;f=new Float32Array(3*d);for(c=h=0;c<d;c++)l=e[c],l>d&&m(Error("Could not find scalar for vertex.")),l=g[l],f[h++]=l,f[h++]=l,f[h++]=l;b.F.I=
+g;b.F.dd=f;b.F.j=q;D.Da(this.f+".parse");e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};A("X.parserLBL",Of);A("X.parserLBL.prototype.parse",Of.prototype.parse);function Pf(){Ne.call(this);this.f="parserCRV";this.Mc=u}C(Pf,Ne);
+Pf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");var e=b.Nc;0==e.length&&m(Error("No _pointIndices defined on the X.object."));this.J=c;this.C=3;var d=Z(this,"uint");Z(this,"uint");Z(this,"uint");var f=0,g=0,h=0,l=0,j=0,k=0,n=0,s=0,r=0,y=0,z=0;c=Array(2);var F=Array(2),G=Z(this,"float",d),H;for(H=0;H<d;H++){var B=G[H];0==H&&(c[0]=F[0]=B);0<=B?(f++,l+=B):(g++,h+=B);r+=B;z++;F[0]=Math.max(B,F[0]);c[0]=Math.min(B,c[0]);G[H]=B}0!=f&&(j=l/f);0!=g&&(k=h/g);0!=z&&(y=r/z);for(z=r=h=l=0;z<d;z++)B=
+G[z],H=0,0<=B?(H=Math.pow(B-j,2),l+=H):(H=Math.pow(B-k,2),h+=H),H=Math.pow(B-y,2),r+=H;1<f&&(n=Math.sqrt(l/(f-1)));1<g&&(s=Math.sqrt(h/(g-1)));c[1]=k-2.5*s;F[1]=j+2.5*n;d=e.length;f=new Float32Array(3*d);for(z=0;z<d;z++)g=G[e[z]],h=3*z,f[h]=g,f[h+1]=g,f[h+2]=g;b.F.ra=c[1];b.F.ia=F[1];-Infinity==b.F.U&&(b.F.U=c[1]);Infinity==b.F.W&&(b.F.W=F[1]);b.F.I=G;b.F.dd=f;b.F.j=q;D.Da(this.f+".parse");e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};A("X.parserCRV",Pf);A("X.parserCRV.prototype.parse",Pf.prototype.parse);function Qf(a,b){var c,e;this.input=a;this.M=0;if(b||!(b={}))b.index&&(this.M=b.index),b.verify&&(this.tk=b.verify);c=a[this.M++];e=a[this.M++];switch(c&15){case 8:this.method=8;break;default:m(Error("unsupported compression method"))}0!==((c<<8)+e)%31&&m(Error("invalid fcheck flag:"+((c<<8)+e)%31));e&32&&m(Error("fdict flag is not supported"));this.wh=new jf(a,{index:this.M,bufferSize:b.bufferSize,bufferType:b.bufferType,resize:b.resize})}
+Qf.prototype.Yb=function(){var a=this.input,b;b=this.wh.Yb();this.M=this.wh.M;if(this.tk){var a=(a[this.M++]<<24|a[this.M++]<<16|a[this.M++]<<8|a[this.M++])>>>0,c=b;if("string"===typeof c){var c=c.split(""),e,d;e=0;for(d=c.length;e<d;e++)c[e]=(c[e].charCodeAt(0)&255)>>>0}e=1;d=0;for(var f=c.length,g,h=0;0<f;){g=1024<f?1024:f;f-=g;do e+=c[h++],d+=e;while(--g);e%=65521;d%=65521}a!==(d<<16|e)>>>0&&m(Error("invalid adler-32 checksum"))}return b};function Rf(){Ne.call(this);this.f="parserRAW"}C(Rf,Ne);
+Rf.prototype.parse=function(a,b,c,e){D.Ja(this.f+".parse");e&&(c=(new Qf(new Uint8Array(c))).Yb(),c=c.buffer);e={};e.data=new Uint8Array(c);var d=Oe(e.data);c=d[0];d=d[1];e.min=b.ra=b.fa=c;e.max=b.ia=b.ea=d;-Infinity==b.U&&(b.U=c);Infinity==b.W&&(b.W=d);d=Sc();e.eb=d;e.gb=Sc();var f=Qc(0,0,0,1);c=Pc();cd(d,f,c);var g=Qc(1,1,1,1),f=Pc();cd(d,g,f);d=Qe(d,b.ca);e.Bc=[f[0]-c[0],f[1]-c[1],f[2]-c[2]];e.zc=[d[1]-d[0]+1,d[3]-d[2]+1,d[5]-d[4]+1];e.Ac=[d[0],d[2],d[4]];b.Gb(e);D.Da(this.f+".parse");b.jb=Ve(this,
+b);e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};A("X.parserRAW",Rf);A("X.parserRAW.prototype.parse",Rf.prototype.parse);function Sf(){Ne.call(this);this.f="parserIMAGE"}C(Sf,Ne);Sf.prototype.parse=function(a,b,c,e){c instanceof ArrayBuffer||m(Error());for(var d=new Uint8Array(c),f=d.length,g=Array(f);f--;)g[f]=String.fromCharCode(d[f]);d=window.btoa(g.join(""));f=new Image;$b(f,"load",this.Uj.bind(this,f,a,b,c,e));f.src="data:image/"+e+";base64,"+d};Sf.prototype.Uj=function(a,b,c){b.jb=a;b.Wb=t;a=new ld;a.D=c;a.v=b;this.dispatchEvent(a)};A("X.parserIMAGE",Sf);A("X.parserIMAGE.prototype.parse",Sf.prototype.parse);function Tf(){Ne.call(this);this.f="parserLUT"}C(Tf,Ne);
+Tf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=Z(this,"uchar",c.byteLength);var e=c.length,d=0,f;for(f=0;f<e;f++)if(10==c[f]){var g=Pe(c,d,f),d=f+1,g=g.replace(/^\s+|\s+$/g,"");"#"!=g[0]&&(g=g.split(" "),g=g.filter(function(a){return""!=a}),6==g.length&&(g[2]=parseInt(g[2],10)/255,g[3]=parseInt(g[3],10)/255,g[4]=parseInt(g[4],10)/255,g[5]=parseInt(g[5],10)/255,a.add(parseInt(g[0],10),g[1],g[2],g[3],g[4],g[5],10)))}D.Da(this.f+".parse");c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};
+A("X.parserLUT",Tf);A("X.parserLUT.prototype.parse",Tf.prototype.parse);function Uf(){Ne.call(this);this.f="parserMRC"}C(Uf,Ne);
+Uf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");c=this.vc(c);var e=c.min,d=c.max;b.ca=[c.Hd,c.Id,c.Jd];b.qb=[c.He/c.bh,c.Jh/c.dh,c.Kh/c.eh];b.ra=b.fa=e;b.ia=b.ea=d;-Infinity==b.U&&(b.U=e);Infinity==b.W&&(b.W=d);d=Rc();T(d,3,0,0,0,1);T(d,0,-1,0,0,c.Hd);T(d,1,0,0,-1,c.Id);T(d,2,0,-1,0,c.Jd);c.eb=d;c.gb=Rc();ad(c.eb,c.gb);var f=Qc(0,0,0,1),e=Pc();cd(d,f,e);var g=Qc(1,1,1,1),f=Pc();cd(d,g,f);g=[c.Hd,c.Id,c.Jd];d=Qe(d,g);c.Bc=[f[0]-e[0],f[1]-e[1],f[2]-e[2]];c.zc=[d[1]+d[0]+1,d[3]-d[2]+1,d[5]-
+d[4]+1];c.Ac=[d[0],d[2],d[4]];b.ca=g;b.Gb(c);b.jb=Ve(this,b);D.Da(this.f+".parse");c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};
+Uf.prototype.vc=function(a){this.J=a;a={Hd:0,Id:0,Jd:0,mode:0,Ol:0,Pl:0,Ql:0,bh:0,dh:0,eh:0,He:0,Jh:0,Kh:0,alpha:0,ii:0,Fi:0,fj:0,gj:0,hj:0,ff:0,he:0,qc:0,Hl:0,next:0,oi:0,zi:t,oj:0,qj:0,zi:t,Ti:0,El:0,Ri:0,bj:0,kj:0,lj:0,rk:0,sk:0,ok:t,uk:0,wk:0,xk:0,vl:0,Wl:0,ak:0,pj:0,data:t,min:Infinity,max:-Infinity,Ll:0,zh:t,Vl:t,Tl:t,orientation:t,Nl:t};this.C=0;a.Hd=Z(this,"sint");a.Id=Z(this,"sint");a.Jd=Z(this,"sint");a.mode=Z(this,"sint");var b=a.Hd*a.Id*a.Jd;this.C=1024;switch(a.mode){case 0:a.data=Z(this,
+"schar",b);break;case 1:a.data=Z(this,"sshort",b);break;case 2:a.data=Z(this,"float",b);break;case 3:a.data=Z(this,"uint",b);break;case 4:a.data=Z(this,"double",b);break;case 6:a.data=Z(this,"ushort",b);break;case 16:a.data=Z(this,"uchar",b);break;default:m(Error("Unsupported MRC data type: "+a.mode))}this.C=28;a.bh=Z(this,"sint");a.dh=Z(this,"sint");a.eh=Z(this,"sint");a.He=Z(this,"float");a.Jh=Z(this,"float");a.Kh=Z(this,"float");a.alpha=Z(this,"float");a.ii=Z(this,"float");a.Fi=Z(this,"float");
+a.fj=Z(this,"sint");a.gj=Z(this,"sint");a.hj=Z(this,"sint");a.ff=Z(this,"float");a.he=Z(this,"float");a.qc=Z(this,"float");a.Gl=Z(this,"sint");a.next=Z(this,"sint");a.oi=Z(this,"short");a.oj=Z(this,"short");a.qj=Z(this,"short");a.Ti=Z(this,"sint");a.Dl=Z(this,"sint");a.Ri=Z(this,"short");a.bj=Z(this,"short");a.kj=Z(this,"short");a.lj=Z(this,"short");a.rk=Z(this,"short");a.sk=Z(this,"short");a.ok=Z(this,"float",6);this.C=196;a.uk=Z(this,"float");a.wk=Z(this,"float");a.xk=Z(this,"float");this.C=216;
+a.ak=Z(this,"float");a.pj=Z(this,"sint");a.Il=Z(this,"schar",10);if(0!=a.next)switch(this.C=parseInt(a.next+1024,10),a.mode){case 0:a.data=Z(this,"schar",b);break;case 1:a.data=Z(this,"sshort",b);break;case 2:a.data=Z(this,"float",b);break;case 3:a.data=Z(this,"uint",b);break;case 4:a.data=Z(this,"double",b);break;case 6:a.data=Z(this,"ushort",b);break;case 16:a.data=Z(this,"uchar",b);break;default:m(Error("Unsupported MRC data type: "+a.mode))}0>a.qc-(a.he-a.qc)?(a.min=a.ff,a.max=a.qc+(a.qc-a.ff)):
+(a.min=a.qc-(a.he-a.qc),a.max=a.he);return a};A("X.parserMRC",Uf);A("X.parserMRC.prototype.parse",Uf.prototype.parse);function Vf(){Ne.call(this);this.f="parserNRRD"}C(Vf,Ne);
+Vf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=Z(this,"uchar",c.byteLength);var e=c.length,d=t,f=0,g;for(g=1;g<e;g++)if(10==c[g-1]&&10==c[g]){d=Pe(c,0,g-2);f=g+1;break}var h,l,j,k,e=d.split(/\r?\n/),d=0;for(g=e.length;d<g;d++)if(h=e[d],h.match(/NRRD\d+/))this.$i=q;else if(!h.match(/^#/)&&(k=h.match(/(.*):(.*)/)))l=k[1].trim(),h=k[2].trim(),(j=this.Ai[l])?j.call(this,h):this[l]=h;this.$i||m(Error("Not an NRRD file"));"raw"!==this.encoding&&("gzip"!==this.encoding&&"gz"!==this.encoding)&&
+m(Error("Only raw or gz/gzip encoding is allowed"));if(!this.ha&&(this.ha=[new R(1,0,0),new R(0,1,0),new R(0,0,1)],this.Tf)){e=[];for(k=0;2>=k;k++)e.push(!isNaN(this.Tf[k])?this.ha[k].scale(this.Tf[k]):p)}f=c.subarray(f);if("gzip"==this.encoding||"gz"==this.encoding)f=(new Mf(new Uint8Array(f))).Yb();f=f.buffer;c={data:t,min:Infinity,max:-Infinity};c.data=new this.Mb(f);k=Oe(c.data);f=c.min=k[0];k=c.max=k[1];b.ra=b.fa=f;b.ia=b.ea=k;b.ca=[this.Rf[0],this.Rf[1],this.Rf[2]];e=(new R(this.ha[0][0],this.ha[0][1],
+this.ha[0][2])).Ib();d=(new R(this.ha[1][0],this.ha[1][1],this.ha[1][2])).Ib();g=(new R(this.ha[2][0],this.ha[2][1],this.ha[2][2])).Ib();b.qb=[e,d,g];-Infinity==b.U&&(b.U=f);Infinity==b.W&&(b.W=k);e=k=1;"left-posterior-superior"==this.zh&&(e=k=-1);f=Sc();"false"==b.reslicing||b.reslicing==u?(T(f,0,k,0,0,0),T(f,1,0,e,0,0),T(f,2,0,0,1,0)):(T(f,0,k*this.ha[0][0],k*this.ha[1][0],k*this.ha[2][0],k*this.Sf[0]),T(f,1,e*this.ha[0][1],e*this.ha[1][1],e*this.ha[2][1],e*this.Sf[1]),T(f,2,1*this.ha[0][2],1*this.ha[1][2],
+1*this.ha[2][2],1*this.Sf[2]));T(f,3,0,0,0,1);c.eb=f;c.gb=Rc();ad(c.eb,c.gb);e=Qc(0,0,0,1);k=Pc();cd(f,e,k);d=Qc(1,1,1,1);e=Pc();cd(f,d,e);f=Qe(f,b.ca);c.Bc=[e[0]-k[0],e[1]-k[1],e[2]-k[2]];c.zc=[f[1]-f[0]+1,f[3]-f[2]+1,f[5]-f[4]+1];c.Ac=[f[0],f[2],f[4]];b.Gb(c);D.Da(this.f+".parse");b.jb=Ve(this,b);c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};
+Vf.prototype.Ai={type:function(a){switch(a){case "uchar":case "unsigned char":case "uint8":case "uint8_t":this.Mb=Uint8Array;break;case "signed char":case "int8":case "int8_t":this.Mb=Int8Array;break;case "short":case "short int":case "signed short":case "signed short int":case "int16":case "int16_t":this.Mb=Int16Array;break;case "ushort":case "unsigned short":case "unsigned short int":case "uint16":case "uint16_t":this.Mb=Uint16Array;break;case "int":case "signed int":case "int32":case "int32_t":this.Mb=
+Int32Array;break;case "uint":case "unsigned int":case "uint32":case "uint32_t":this.Mb=Uint32Array;break;case "float":this.Mb=Float32Array;break;case "double":this.Mb=Float64Array;break;default:m(Error("Unsupported NRRD data type: "+a))}return this.type=a},endian:function(a){return this.Al=a},encoding:function(a){return this.encoding=a},dimension:function(a){return this.Zb=parseInt(a,10)},sizes:function(a){var b,c,e,d;e=a.split(/\s+/);d=[];b=0;for(c=e.length;b<c;b++)a=e[b],d.push(parseInt(a,10));
+return this.Rf=d},space:function(a){return this.zh=a},"space origin":function(a){return this.Sf=a.split("(")[1].split(")")[0].split(",")},"space directions":function(a){var b,c;a=a.match(/\(.*?\)/g);var e,d,f;f=[];e=0;for(d=a.length;e<d;e++)c=a[e],f.push(function(){var a,d,e,f;e=c.slice(1,-1).split(/,/);f=[];a=0;for(d=e.length;a<d;a++)b=e[a],f.push(parseFloat(b));return f}());return this.ha=f},spacings:function(a){var b;b=a.split(/\s+/);var c,e,d;d=[];c=0;for(e=b.length;c<e;c++)a=b[c],d.push(parseFloat(a));
+return this.Tf=d}};A("X.parserNRRD",Vf);A("X.parserNRRD.prototype.parse",Vf.prototype.parse);function Wf(){Ne.call(this);this.f="parserSTL"}C(Wf,Ne);
+Wf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;var e=b.h,d=b.n;if("solid"==Pe(Z(this,"uchar",5))){b.h=e=new W(c.byteLength);b.n=d=new W(c.byteLength);var f=e,e=d,d=Z(this,"uchar",c.byteLength-5);c=d.length;var g=u,h=u,l=0,j;for(j=0;j<c;j++)if(10==d[j]){if(g||h){var k=Pe(d,l,j).split(" "),h=parseFloat(k[0]),n=parseFloat(k[1]),k=parseFloat(k[2]);g?(e.add(h,n,k),e.add(h,n,k),e.add(h,n,k)):f.add(h,n,k);h=g=u}}else 32==d[j-1]&&(102==d[j]?(l=j+=13,g=q):118==d[j]&&(l=j+=7,h=q))}else{this.C=
+80;f=Z(this,"uint");b.h=e=new W(9*f);b.n=d=new W(9*f);for(c=c=0;c<f;c++)g=Z(this,"float",12),l=g[0],j=g[1],h=g[2],d.add(l,j,h),d.add(l,j,h),d.add(l,j,h),e.add(g[3],g[4],g[5]),e.add(g[6],g[7],g[8]),e.add(g[9],g[10],g[11]),this.C+=2}D.Da(this.f+".parse");f=new ld;f.D=b;f.v=a;this.dispatchEvent(f)};A("X.parserSTL",Wf);A("X.parserSTL.prototype.parse",Wf.prototype.parse);function Xf(){Ne.call(this);this.f="parserNII"}C(Xf,Ne);
+Xf.prototype.parse=function(a,b,c){if(!Yf(c))try{c=(new Mf(new Uint8Array(c))).Yb().buffer,Yf(c)||(this.Mc=u)}catch(e){this.Mc=u}c=this.vc(c);var d=c.min,f=c.max;b.ra=b.fa=d;b.ia=b.ea=f;-Infinity==b.U&&(b.U=d);Infinity==b.W&&(b.W=f);d=Rc();T(d,3,0,0,0,1);if("false"==b.reslicing||b.reslicing==u){var g=f=1,h=1;0<c.sa[1]&&(f=c.sa[1]);0<c.sa[2]&&(g=c.sa[2]);0<c.sa[2]&&(h=c.sa[3]);0>c.sa[0]&&(h=-h);T(d,0,f,0,0,0);T(d,1,0,g,0,0);T(d,2,0,0,h,0)}else if(0<c.Of){var l=0,j=c.sh,k=c.th,n=c.uh,h=g=f=1,s=c.ph,
+r=c.qh,y=c.rh,l=1-(j*j+k*k+n*n);1E-7>l?(l=1/Math.sqrt(j*j+k*k+n*n),j*=l,k*=l,n*=l,l=0):l=Math.sqrt(l);0<c.sa[1]&&(f=c.sa[1]);0<c.sa[2]&&(g=c.sa[2]);0<c.sa[2]&&(h=c.sa[3]);0>c.sa[0]&&(h=-h);T(d,0,(l*l+j*j-k*k-n*n)*f,2*(j*k-l*n)*g,2*(j*n+l*k)*h,s);T(d,1,2*(j*k+l*n)*f,(l*l+k*k-j*j-n*n)*g,2*(k*n-l*j)*h,r);T(d,2,2*(j*n-l*k)*f,2*(k*n+l*j)*g,(l*l+n*n-k*k-j*j)*h,y)}else 0<c.xh?(f=c.Ah,g=c.Bh,h=c.Ch,T(d,0,f[0],f[1],f[2],f[3]),T(d,1,g[0],g[1],g[2],g[3]),T(d,2,h[0],h[1],h[2],h[3])):0==c.Of?(T(d,0,c.sa[1],0,
+0,0),T(d,1,0,c.sa[2],0,0),T(d,2,0,0,c.sa[3],0)):window.console.log("UNKNOWN METHOD IN PARSER NII");c.eb=d;c.gb=Rc();ad(c.eb,c.gb);g=Qc(0,0,0,1);f=Pc();cd(d,g,f);h=Qc(1,1,1,1);g=Pc();cd(d,h,g);h=[c.Zb[1],c.Zb[2],c.Zb[3]];d=Qe(d,h);c.Bc=[g[0]-f[0],g[1]-f[1],g[2]-f[2]];c.zc=[d[1]-d[0]+1,d[3]-d[2]+1,d[5]-d[4]+1];c.Ac=[d[0],d[2],d[4]];b.ca=h;b.Gb(c);b.jb=Ve(this,b);c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};
+Xf.prototype.vc=function(a){this.J=a;a={fk:0,pi:t,qi:t,yi:0,dk:0,Yj:0,ui:t,Zb:t,Wi:0,Xi:0,Yi:0,Ui:0,qf:0,ji:0,kk:0,sa:t,Hh:0,ck:0,bk:0,jk:0,hk:t,vk:t,ki:0,li:0,ik:0,pk:0,Hi:0,Ii:0,si:t,hi:t,Of:0,xh:0,sh:0,th:0,uh:0,ph:0,qh:0,rh:0,Ah:t,Bh:t,Ch:t,Vi:t,cj:t,data:t,min:Infinity,max:-Infinity};a.fk=Z(this,"uint");a.pi=Z(this,"uchar",10);a.qi=Z(this,"uchar",18);a.yi=Z(this,"uint");a.dk=Z(this,"ushort");a.Yj=Z(this,"uchar");a.ui=Z(this,"uchar");a.Zb=Z(this,"ushort",8);a.Wi=Z(this,"float");a.Xi=Z(this,"float");
+a.Yi=Z(this,"float");a.Ui=Z(this,"ushort");a.qf=Z(this,"ushort");a.ji=Z(this,"ushort");a.kk=Z(this,"ushort");a.sa=Z(this,"float",8);a.Hh=Z(this,"float");a.ck=Z(this,"float");a.bk=Z(this,"float");a.jk=Z(this,"ushort");a.hk=Z(this,"uchar");a.vk=Z(this,"uchar");a.ki=Z(this,"float");a.li=Z(this,"float");a.ik=Z(this,"float");a.pk=Z(this,"float");a.Hi=Z(this,"uint",1);a.Ii=Z(this,"uint",1);a.si=Z(this,"uchar",80);a.hi=Z(this,"uchar",24);a.Of=Z(this,"ushort");a.xh=Z(this,"ushort");a.sh=Z(this,"float");a.th=
+Z(this,"float");a.uh=Z(this,"float");a.ph=Z(this,"float");a.qh=Z(this,"float");a.rh=Z(this,"float");a.Ah=Z(this,"float",4);a.Bh=Z(this,"float",4);a.Ch=Z(this,"float",4);a.Vi=Z(this,"uchar",16);a.cj=Z(this,"uchar",4);this.C=parseInt(a.Hh,10);var b=a.Zb[1]*a.Zb[2]*a.Zb[3];switch(a.qf){case 2:a.data=Z(this,"uchar",b);break;case 4:a.data=Z(this,"sshort",b);break;case 8:a.data=Z(this,"sint",b);break;case 16:a.data=Z(this,"float",b);break;case 32:a.data=Z(this,"complex",b);break;case 64:a.data=Z(this,"double",
+b);break;case 256:a.data=Z(this,"schar",b);break;case 512:a.data=Z(this,"ushort",b);break;case 768:a.data=Z(this,"uint",b);break;default:m(Error("Unsupported NII data type: "+a.qf))}b=Oe(a.data);a.min=b[0];a.max=b[1];return a};function Yf(a){var b=-1,b="undefined"==typeof DataView?(new Int32Array(a,0,1))[0]:(new DataView(a,0)).getInt32(0,q);return 348==b?q:u}A("X.parserNII",Xf);A("X.parserNII.prototype.parse",Xf.prototype.parse);function Zf(){Ne.call(this);this.f="parserTRK"}C(Zf,Ne);
+Zf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");var e=b.h,d=b.n,f=b.pa;this.J=c;Z(this,"uchar",6);Z(this,"ushort",3);var g=Z(this,"float",3);Z(this,"float",3);var h=Z(this,"ushort");Z(this,"uchar",200);Z(this,"ushort");Z(this,"uchar",200);c=Z(this,"float",16);Z(this,"uchar",444);Z(this,"uchar",4);Z(this,"uchar",4);Z(this,"float",6);Z(this,"uchar",2);Z(this,"uchar");Z(this,"uchar");Z(this,"uchar");Z(this,"uchar");Z(this,"uchar");Z(this,"uchar");var l=Z(this,"uint");Z(this,"uint");var j=Z(this,
+"uint"),k=0===l?Infinity:l,n=[],s=[],l=Infinity,r=-Infinity,y=t,z=t,F=t,G=t,d=e=t,H=Z(this,"uint",(this.J.byteLength-1E3)/4);this.C=j;for(var B=Z(this,"float",(this.J.byteLength-1E3)/4),E=0,j=f=0;j<k;j++){if("undefined"===typeof H[E]){k=j;break}for(var I=H[E],N=new W(3*I),Q=0,O=0;O<I;O++){var S=B[E+3*O+O*h+1],da=B[E+3*O+O*h+2],J=B[E+3*O+O*h+3],S=S/g[0],da=da/g[1],J=J/g[2];N.add(S,da,J);if(0<O)var ba=N.get(O-1),Q=Q+Math.sqrt(Math.pow(S-ba[0],2)+Math.pow(da-ba[1],2)+Math.pow(J-ba[2],2));O<I-1&&(f+=
+6)}E+=3*I+I*h+1;O=N.nb;I=N.kb;S=N.ob;da=N.lb;J=N.pb;ba=N.mb;if(!y||O<y)y=O;if(!z||I>z)z=I;if(!F||S<F)F=S;if(!G||da>G)G=da;if(!e||J<e)e=J;if(!d||ba>d)d=ba;n.push(N);s.push(Q)}g=(y+z)/2;h=(F+G)/2;G=(e+d)/2;F=new Float32Array(f);b.h=e=new W(f);b.n=d=new W(f);b.pa=f=new W(f);for(j=y=0;j<k;j++){z=n[j];H=z.count;Q=s[j];l=Math.min(l,Q);r=Math.max(r,Q);for(O=0;O<H-1;O++){E=z.get(O);B=z.get(O+1);e.add(E[0],E[1],E[2]);e.add(B[0],B[1],B[2]);var N=E[0]-g,I=E[1]-h,S=E[2]-G,da=Math.sqrt(N*N+I*I+S*S),J=B[0]-g,ba=
+B[1]-h,la=B[2]-G,U=Math.sqrt(J*J+ba*ba+la*la);d.add(N/da,I/da,S/da);d.add(J/U,ba/U,la/U);B=[Math.abs(B[0]-E[0]),Math.abs(B[1]-E[1]),Math.abs(B[2]-E[2])];E=Math.sqrt(B[0]*B[0]+B[1]*B[1]+B[2]*B[2]);B[0]/=E;B[1]/=E;B[2]/=E;f.add(B[0],B[1],B[2]);f.add(B[0],B[1],B[2]);F[y++]=Q;F[y++]=Q;F[y++]=Q;F[y++]=Q;F[y++]=Q;F[y++]=Q}}b.Ia="LINES";k=new kd;k.ra=l;k.ia=r;k.U=l;k.W=r;k.dd=F;k.ug=u;k.j=q;b.F=k;l=u;for(j=0;16>j;j++)if(0!=c[j]){l=q;break}l==u&&(c[0]=c[5]=c[10]=c[15]=1);D.Da(this.f+".parse");D.g.Wf(c,b.ja.Q);
+c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};A("X.parserTRK",Zf);A("X.parserTRK.prototype.parse",Zf.prototype.parse);function $f(){Ne.call(this);this.f="parserOBJ"}C($f,Ne);
+$f.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=c.byteLength;var e=Z(this,"uchar",c),d=[];b.h=new W(c);b.n=new W(c);var f=b.h,g=b.n,h=0,l;for(l=0;l<c;++l)if(10==e[l]){var j=Pe(e,h,l).replace(/\s{2,}/g," ").split(" ");if("v"==j[0])d.push([parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])]);else if("f"==j[0]){var k=d[parseInt(j[1],10)-1],h=d[parseInt(j[2],10)-1],j=d[parseInt(j[3],10)-1];f.add(k[0],k[1],k[2]);f.add(h[0],h[1],h[2]);f.add(j[0],j[1],j[2]);k=new R(k[0],k[1],k[2]);j=
+new R(j[0],j[1],j[2]);h=Ic((new R(h[0],h[1],h[2])).wa(k),j.wa(k));h.normalize();g.add(h.x,h.y,h.d);g.add(h.x,h.y,h.d);g.add(h.x,h.y,h.d)}h=l+1}D.Da(this.f+".parse");c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};A("X.parserOBJ",$f);A("X.parserOBJ.prototype.parse",$f.prototype.parse);function ag(){M.call(this);this.f="loader";this.Kc=new zc;this.td=0}C(ag,M);function bg(a,b){a.td+=b/a.Kc.tf()/3;a.td=Math.min(1,a.td);var c=new Od;c.Ad=a.td;a.dispatchEvent(c)}function cg(a){a=a.r.$d;var b=a.split(".").pop().toUpperCase();b==a.toUpperCase()&&(b="");b in dg||m(Error("The "+b+" file format is not supported."));return[a,b,dg[b][0],dg[b][1],dg[b][2]]}
+ag.prototype.load=function(a,b){(!a||!b)&&m(Error("No container or object to load."));if(!Cc(this.Kc.ga,a.qa)||this.Kc.get(a.qa)){this.Kc.set(a.qa,u);var c=cg(a)[0];if(a.$a!=t)this.parse(t,a,b);else{var e=new XMLHttpRequest;L(e,"abort",this.Ig.bind(this,e,a,b));L(e,"error",this.Ig.bind(this,e,a,b));L(e,"load",this.parse.bind(this,e,a,b));e.open("GET",c,q);e.responseType="arraybuffer";e.send(t)}}};
+ag.prototype.parse=function(a,b,c){bg(this,1);setTimeout(function(){var e=cg(b),d=e[3],e=new e[2];$b(e,yd,this.complete.bind(this));var f=b.$a;f==t&&(f=a.response,b.$a=f);e.parse(b,c,f,d)}.bind(this),100)};ag.prototype.complete=function(a){bg(this,1);setTimeout(function(){var b=a.v,c=a.D;b.r.j=u;b.j=q;c.q();this.Kc.set(b.qa,q)}.bind(this),100)};ag.prototype.Ig=function(a,b,c){m(Error("Loading failed: ",b,c))};
+var dg={OBJ:[$f,t],OFF:[af,t],STL:[Wf,t],VTK:[df,t],TRK:[Zf,t],MRC:[Uf,t],ST:[Uf,t],FSM:[ff,t],INFLATED:[ff,t],SMOOTHWM:[ff,t],SPHERE:[ff,t],PIAL:[ff,t],ORIG:[ff,t],NRRD:[Vf,t],NII:[Xf,t],GZ:[Xf,t],DCM:[bf,t],DICOM:[bf,t],"":[bf,t],CRV:[Pf,t],LABEL:[Of,t],MGH:[Nf,u],MGZ:[Nf,q],RAW:[Rf,u],RZ:[Rf,q],TXT:[Tf,t],LUT:[Tf,t],PNG:[Sf,"png"],JPG:[Sf,"jpeg"],JPEG:[Sf,"jpeg"],GIF:[Sf,"gif"]};function eg(a,b){(!x(a)||!x(b))&&m(Error("A camera needs valid width and height values."));M.call(this);this.f="camera";this.ic=new D.m(0,100,0);this.Fc=new D.m(0,0,0);this.V=new D.m(0,0,1);this.K=a;this.A=b;this.o=this.ue(this.ic,this.Fc)}C(eg,M);eg.prototype.observe=function(a){(a==t||!(a instanceof Ie))&&m(Error("Could not observe the interactor."));L(a,td,this.Fj.bind(this));L(a,sd,this.Cj.bind(this));L(a,ud,this.Sj.bind(this))};
+eg.prototype.Fj=function(a){a instanceof Id||m(Error("Received no valid rotate event."));this.rotate(a.ya)};eg.prototype.Sj=function(a){a instanceof Jd||m(Error("Received no valid zoom event."));a.vb?this.$f(a.ib):this.ag(a.ib)};eg.prototype.Cj=function(a){a instanceof Hd||m(Error("Received no valid pan event."));this.Lf(a.ya)};eg.prototype.__defineGetter__("view",v("o"));
+eg.prototype.__defineSetter__("view",function(a){(a==t||!(a instanceof Float32Array))&&m(Error("Invalid view matrix."));this.o=a});eg.prototype.__defineGetter__("position",function(){return[this.ic.x,this.ic.y,this.ic.d]});eg.prototype.__defineSetter__("position",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid position."));this.ic=new D.m(a[0],a[1],a[2]);this.reset()});eg.prototype.__defineGetter__("focus",function(){return[this.Fc.x,this.Fc.y,this.Fc.d]});
+eg.prototype.__defineSetter__("focus",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid focus"));this.Fc=new D.m(a[0],a[1],a[2]);this.reset()});eg.prototype.__defineGetter__("up",function(){return[this.V.x,this.V.y,this.V.d]});eg.prototype.__defineSetter__("up",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid up vector."));this.V=new D.m(a[0],a[1],a[2]);this.reset()});w=eg.prototype;w.reset=function(){this.o=this.ue(this.ic,this.Fc)};
+w.rotate=function(a){ja(a)&&2==a.length?a=new D.m(a[0],a[1],0):a instanceof D.m||m(Error("Invalid distance vector for rotate operation."));return a};w.Lf=function(a){ja(a)&&2==a.length?a=new D.m(a[0],a[1],0):a instanceof D.m||m(Error("Invalid distance vector for pan operation."));this.o[12]-=a.x;this.o[13]+=a.y};w.$f=function(a){var b=20;a!=t&&!a&&(b=1);this.o[14]+=b};w.ag=function(a){var b=20;a!=t&&!a&&(b=1);this.o[14]-=b};
+w.ue=function(a,b){(!(a instanceof D.m)||!(b instanceof D.m))&&m(Error("3D vectors required for calculating the view."));return D.g.Ed()};A("X.camera",eg);A("X.camera.prototype.pan",eg.prototype.Lf);A("X.camera.prototype.rotate",eg.prototype.rotate);A("X.camera.prototype.zoomIn",eg.prototype.$f);A("X.camera.prototype.zoomOut",eg.prototype.ag);function fg(a){function b(a,b,e){b=2*b*Math.PI;b=za(Aa(l,Math.cos(b)),Aa(j,Math.sin(b)));a=za(za(c,Aa(d,a)),Aa(b,f));e=za(Aa(b,1-Math.abs(e)),Aa(g,e));return new kc(a,e)}this.Z=[];a=a||{};var c=new ya(a.start||[0,-1,0]),e=new ya(a.end||[0,1,0]),d=Ca(e,c),f=a.zb||1;a=a.ta||16;for(var g=Da(d),h=0.5<Math.abs(g.y()),l=Da((new ya(h,!h,0)).sc(g)),j=Da(l.sc(g)),h=new kc(c,Ea(g)),e=new kc(e,Da(g)),k=[],n=0;n<a;n++){var s=n/a,r=(n+1)/a;k.push(new mc([h,b(0,s,-1),b(0,r,-1)]));k.push(new mc([b(0,r,0),b(0,s,
+0),b(1,s,0),b(1,r,0)]));k.push(new mc([e,b(1,r,1),b(1,s,1)]))}return uc(k)}C(fg,tc);function gg(){Y.call(this);this.f="cylinder";this.bf=[-10,-10,-10];this.Le=[10,10,10];this.jc=10;this.cb=32;Fa(this,new od)}C(gg,Y);gg.prototype.__defineGetter__("start",v("bf"));gg.prototype.__defineSetter__("start",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid start"));this.bf=a});gg.prototype.__defineGetter__("end",v("Le"));gg.prototype.__defineSetter__("end",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid end"));this.Le=a});gg.prototype.__defineGetter__("radius",v("jc"));
+gg.prototype.__defineSetter__("radius",function(a){x(a)||m(Error("Invalid radius."));this.jc=a});gg.prototype.q=function(){qd(this,new fg({start:this.bf,end:this.Le,zb:this.jc,ta:this.cb}));gg.u.q.call(this)};A("X.cylinder",gg);A("X.cylinder.prototype.modified",gg.prototype.q);function hg(a){function b(a,b){a*=2*Math.PI;b*=Math.PI;var d=new ya(Math.cos(a)*Math.sin(b),Math.cos(b),Math.sin(a)*Math.sin(b));g.push(new kc(za(c,Aa(d,e)),d))}this.Z=[];a=a||{};var c=new ya(a.mf||[0,0,0]),e=a.zb||1,d=a.ta||16;a=a.lk||8;for(var f=[],g=[],h=0;h<d;h++)for(var l=0;l<a;l++)g=[],b(h/d,l/a),0<l&&b((h+1)/d,l/a),l<a-1&&b((h+1)/d,(l+1)/a),b(h/d,(l+1)/a),f.push(new mc(g));return uc(f)}C(hg,tc);function ig(){Y.call(this);this.f="sphere";this.z=[0,0,0];this.jc=5;this.cb=32;this.$h=16;Fa(this,new od)}C(ig,Y);ig.prototype.__defineGetter__("center",v("z"));ig.prototype.__defineSetter__("center",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid center"));this.z=a});ig.prototype.__defineGetter__("radius",v("jc"));ig.prototype.__defineSetter__("radius",function(a){x(a)||m(Error("Invalid radius."));this.jc=a});
+ig.prototype.q=function(){qd(this,new hg({mf:this.z,zb:this.jc,ta:this.cb,lk:this.$h}));ig.u.q.call(this)};A("X.sphere",ig);A("X.sphere.prototype.modified",ig.prototype.q);function Xe(a){P.call(this);this.f="labelmap";this.yb=a;this.af=new Float32Array([-255,-255,-255,-255])}C(Xe,P);Xe.prototype.q=function(){var a=new ld;a.D=this;this.dispatchEvent(a);this.yb.q()};Xe.prototype.__defineSetter__("showOnly",function(a){var b=[-1,-1,-1,-1];a!=t&&(ja(a)&&4==a.length?b=a:(this.xa||m(Error("No colortable assigned.")),b=this.xa.Ka.get(a).slice(1,5)));this.af=new Float32Array([Math.floor(255*b[0]),Math.floor(255*b[1]),Math.floor(255*b[2]),Math.floor(255*b[3])])});
+A("X.labelmap",Xe);function jg(a){this.Z=[];a=a||{};var b=new ya(a.mf||[0,0,0]),c=!a.zb?[1,1,1]:a.zb.length?a.zb:[a.zb,a.zb,a.zb];return uc([[[0,4,6,2],[-1,0,0]],[[1,3,7,5],[1,0,0]],[[0,1,5,4],[0,-1,0]],[[2,6,7,3],[0,1,0]],[[0,2,3,1],[0,0,-1]],[[4,5,7,6],[0,0,1]]].map(function(a){return new mc(a[0].map(function(d){d=new ya(b.x()+c[0]*(2*!!(d&1)-1),b.y()+c[1]*(2*!!(d&2)-1),b.d()+c[2]*(2*!!(d&4)-1));return new kc(d,new ya(a[1]))}))}))}C(jg,tc);function kg(){Y.call(this);this.f="cube";this.z=[0,0,0];this.Qe=this.Pe=this.Oe=20;this.nc=[0,1,1,1,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,0,0,0,1,1,0,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0];Fa(this,new od)}C(kg,Y);kg.prototype.__defineGetter__("center",v("z"));kg.prototype.__defineSetter__("center",function(a){(a==t||!ja(a)||3!=a.length)&&m(Error("Invalid center"));this.z=a});kg.prototype.__defineGetter__("lengthX",v("Oe"));
+kg.prototype.__defineSetter__("lengthX",function(a){x(a)||m(Error("Invalid lengthX."));this.Oe=a});kg.prototype.__defineGetter__("lengthY",v("Pe"));kg.prototype.__defineSetter__("lengthY",function(a){x(a)||m(Error("Invalid lengthY."));this.Pe=a});kg.prototype.__defineGetter__("lengthZ",v("Qe"));kg.prototype.__defineSetter__("lengthZ",function(a){x(a)||m(Error("Invalid lengthZ."));this.Qe=a});kg.prototype.q=function(){qd(this,new jg({mf:this.z,zb:[this.Oe/2,this.Pe/2,this.Qe/2]}));kg.u.q.call(this)};
+A("X.cube",kg);A("X.cube.prototype.modified",kg.prototype.q);function Ke(a){Ie.call(this,a);this.f="interactor3D";this.ml=u}C(Ke,Ie);Ke.prototype.Kd=function(a){Ke.u.Kd.call(this,a);var b=new Jd;a.Xc==t&&(a.Xc=0);b.vb=0>a.Xc;b.ib=q;this.dispatchEvent(b)};function lg(a){M.call(this);this.f="array";this.I=[];this.cg=a}C(lg,M);function mg(a,b,c){for(var e=0;4>e;e++)if(a[e+0]!==b[e+c])return u;return q}lg.prototype.add=function(a){this.I.push(a);return q};lg.prototype.remove=function(a){a=this.I.indexOf(a);-1<a&&this.I.splice(a,1);return q};lg.prototype.clear=function(){this.I.length=0};
+function ng(a,b,c){var e=c-b;if(!(2>e)){e=b+Math.floor(e/2);ng(a,b,e);for(ng(a,e,c);b<e;++b)if(0<a.cg(a.I[b],a.I[e])){var d=a.I[b];a.I[b]=a.I[e];for(var f=a,g=e,h=c;g+1<h&&0>f.cg(f.I[g+1],d);){var l=f,j=g+1,k=l.I[g];l.I[g]=l.I[j];l.I[j]=k;++g}f.I[g]=d}}}lg.prototype.sort=function(){ng(this,0,this.I.length)};function og(a,b){eg.call(this,a,b);this.f="camera2D"}C(og,eg);og.prototype.rotate=function(a){a=og.u.rotate.call(this,a);var b=new Gd;0<a.x?b.df--:0>a.x&&b.df++;0<a.y?b.Re++:0>a.y&&b.Re--;this.dispatchEvent(b)};og.prototype.$f=function(a){var b=20;a!=t&&!a&&(b=0.02);this.o[14]+=b};og.prototype.ag=function(a){var b=20;a!=t&&!a&&(b=0.02);this.o[14]-=b};
+og.prototype.Lf=function(a){ja(a)&&2==a.length?a=new D.m(a[0],a[1],0):a instanceof D.m||m(Error("Invalid distance vector for pan operation."));this.o[12]-=a.x/this.o[14];this.o[13]+=a.y/this.o[14]};function pg(a,b){eg.call(this,a,b);this.f="camera3D";this.eg=45;this.We=D.g.zf(D.g.Ed(),this.eg,a/b,1,1E4)}C(pg,eg);pg.prototype.rotate=function(a){a=pg.u.rotate.call(this,a);var b=-a.x/5*Math.PI/180;a=-a.y/5*Math.PI/180;var c=new D.m(this.o[1],this.o[5],this.o[9]),e=new D.m(this.o[0],this.o[4],this.o[8]);c.normalize();e.normalize();D.g.rotate(this.o,b,c.x,c.y,c.d);D.g.rotate(this.o,a,e.x,e.y,e.d)};pg.prototype.ue=function(a,b){var c=pg.u.ue.call(this,a,b);D.g.Xg(c,a,b,this.V);return c};
+function qg(a,b,c,e){var d=new Float32Array(4),f=new Float32Array(4),g=new Float32Array(16),h=new Float32Array(16);new Float32Array(16);D.g.multiply(a.We,a.o,h);D.g.Y(h,g);d[0]=b;d[1]=c;d[2]=2*e-1;d[3]=1;D.g.ah(g,d,f);f[3]=1/f[3];f[0]*=f[3];f[1]*=f[3];f[2]*=f[3];return f}A("X.camera3D",pg);function rg(a){Pb.call(this);this.Hb=a;this.S=[]}C(rg,Pb);var sg=[];function tg(a,b,c,e,d){ja(c)||(sg[0]=c,c=sg);for(var f=0;f<c.length;f++){var g=L(b,c[f],e||a,d||u,a.Hb||a);a.S.push(g)}}rg.prototype.xe=function(){Jb(this.S,bc);this.S.length=0};rg.prototype.handleEvent=function(){m(Error("EventHandler.handleEvent not implemented"))};function ug(){}ug.Kg=function(){return ug.Sg?ug.Sg:ug.Sg=new ug};ug.prototype.mj=0;ug.Kg();function vg(a){jc.call(this);this.$b=a||Zd();this.$j=wg}C(vg,jc);vg.prototype.Qi=ug.Kg();var wg=t;w=vg.prototype;w.Rg=t;w.Zc=u;w.H=t;w.$j=t;w.Ld=t;w.Cd=t;w.nf=t;w.t=v("H");w.Qf=function(a){this.Ld&&this.Ld!=a&&m(Error("Method not supported"));vg.u.Qf.call(this,a)};w.ne=v("$b");w.Wc=function(){this.H=this.$b.createElement("div")};w.cc=function(a){this.dc(a)};
+w.dc=function(a,b){this.Zc&&m(Error("Component already rendered"));this.H||this.Wc();a?a.insertBefore(this.H,b||t):this.$b.ka.body.appendChild(this.H);(!this.Ld||this.Ld.Zc)&&this.ke()};w.ke=function(){function a(a){!a.Zc&&a.t()&&a.ke()}this.Zc=q;this.Cd&&Jb(this.Cd,a,p)};w.le=function(){function a(a){a.Zc&&a.le()}this.Cd&&Jb(this.Cd,a,p);this.Ji&&this.Ji.xe();this.Zc=u};
+w.removeChild=function(a,b){if(a){var c=na(a)?a:a.Rg||(a.Rg=":"+(a.Qi.mj++).toString(36)),e;this.nf&&c?(e=this.nf,e=(c in e?e[c]:p)||t):e=t;a=e;c&&a&&(e=this.nf,c in e&&delete e[c],Nb(this.Cd,a),b&&(a.le(),a.H&&fe(a.H)),c=a,c==t&&m(Error("Unable to set parent component")),c.Ld=t,vg.u.Qf.call(c,t))}a||m(Error("Child is not in parent component"));return a};function xg(){jc.call(this)}C(xg,jc);w=xg.prototype;w.Yf=0;w.Gd=0;w.Af=100;w.Hg=0;w.Uf=1;w.Zi=u;w.jj=u;w.Od=function(a){a=yg(this,a);this.Yf!=a&&(this.Yf=a+this.Hg>this.Af?this.Af-this.Hg:a<this.Gd?this.Gd:a,!this.Zi&&!this.jj&&this.dispatchEvent("change"))};w.qe=function(){return yg(this,this.Yf)};w.pe=function(){return yg(this,this.Gd)};w.oe=function(){return yg(this,this.Af)};function yg(a,b){return a.Uf==t?b:a.Gd+Math.round((b-a.Gd)/a.Uf)*a.Uf};function zg(a){vg.call(this,a);this.Md=new xg;L(this.Md,"change",this.Ki,u,this)}C(zg,vg);var Bg={vertical:"progress-bar-vertical",horizontal:"progress-bar-horizontal"};w=zg.prototype;w.Wc=function(){this.Ab=this.ne().Wc("div","progress-bar-thumb");var a=Bg[this.mh];this.H=this.ne().Wc("div",a,this.Ab);Cg(this);a=this.pe();this.t().setAttribute("aria-valuemin",a);a=this.oe();this.t().setAttribute("aria-valuemax",a)};
+w.ke=function(){zg.u.ke.call(this);K&&7>sb&&L(this.t(),"resize",this.Ge,u,this);this.Ge();var a=this.t();a.setAttribute("role","progressbar");a.setAttribute("aria-live","polite")};w.le=function(){zg.u.le.call(this);K&&7>sb&&ac(this.t(),"resize",this.Ge,u,this)};w.qe=function(){return this.Md.qe()};w.Od=function(a){this.Md.Od(a);this.t()&&Cg(this)};function Cg(a){var b=a.qe();a.t().setAttribute("aria-valuenow",b)}w.pe=function(){return this.Md.pe()};w.oe=function(){return this.Md.oe()};w.mh="horizontal";
+w.Ki=function(){this.Ge();this.dispatchEvent("change")};w.Ge=function(){if(this.Ab){var a=this.pe(),b=this.oe(),a=(this.qe()-a)/(b-a),b=Math.round(100*a);"vertical"==this.mh?K&&7>sb?(this.Ab.style.top=0,this.Ab.style.height="100%",b=this.Ab.offsetHeight,a=Math.round(a*b),this.Ab.style.top=b-a+"px",this.Ab.style.height=a+"px"):(this.Ab.style.top=100-b+"%",this.Ab.style.height=b+"%"):this.Ab.style.width=b+"%"}};function Dg(a,b){a==t&&m(Error("No valid parent element."));b==t&&m(Error("Invalid initial value."));zg.call(this);this.f="progressbar";this.bb=a;this.Ve="";this.Td=this.Fb=t;this.fc=[];var c;c=".progress-bar-horizontal {\n  position: relative;\n  border: 1px solid #949dad;\n";c+="  background: white;\n";c+="  padding: 1px;\n";c+="  overflow: hidden;\n";c+="  margin: 2px;\n";c+="  width: 100px;\n";c+="  height: 5px;\n";c+="}";var e;e=".progress-bar-thumb {\n  position: relative;\n  background: #F62217;\n";
+e+="  overflow: hidden;\n";e+="  width: 0%;\n";e+="  height: 100%;\n";e+="}";var d;d=".progress-bar-thumb-done {\n  background: #57E964;\n}";this.fc=[c,e,d];this.Od(b);this.vf()}C(Dg,zg);
+Dg.prototype.vf=function(){var a=ne(this.bb,"position");if("static"==a||""==a)this.Ve=this.bb.style.position,this.bb.style.position="relative";var a=document.getElementsByTagName("head")[0],b=de("style");b.type="text/css";b.media="screen";var c=document.createTextNode(String(this.fc[0])),e=document.createTextNode(String(this.fc[1])),d=document.createTextNode(String(this.fc[2]));a.appendChild(b);b.appendChild(c);b.appendChild(e);b.appendChild(d);this.Fb=b;this.cc(this.bb);a=this.t();a.style.position=
+"absolute";a.style.top=(this.bb.clientHeight-5)/2+"px";a.style.left=(this.bb.clientWidth-100)/2+"px";a.classList.add("xtk-progress-bar")};function Eg(a){var b=a.t().style.top,c=a.t().style.left;fe(a.t());var e=new Dg(a.bb,100),d=e.t();d.style.position="absolute";d.style.top=b;d.style.left=c;d.classList.add("xtk-progress-bar");(d.firstElementChild!=p?d.firstElementChild:ge(d.firstChild)).classList.add("progress-bar-thumb-done");a.Td=e}
+Dg.prototype.Fd=function(){this.Fb&&fe(this.Fb);this.t()&&fe(this.t());this.Td&&fe(this.Td.t());this.Td=this.Fb=t;this.Ve&&(this.bb.style.position=this.Ve)};function Fg(a,b,c){oa(a)?c&&(a=va(a,c)):a&&"function"==typeof a.handleEvent?a=va(a.handleEvent,a):m(Error("Invalid listener argument"));return 2147483647<b?-1:fa.setTimeout(a,b||0)};function Gg(){M.call(this);this.f="renderer";this.v=window.document.body;this.K=this.v.clientWidth;this.A=this.v.clientHeight;this.T=this.N=this.na=t;this.ab=new lg(nd);this.Ha=[];this.aa=t;this.Zd=this.hd=this.Xd=u;this.a=this.Vb=this.La=t;this.R={PROGRESSBAR_ENABLED:q,INTERMEDIATE_RENDERING:u,SLICENAVIGATORS:q};this.Ie=-1;window.console.log("XTK release 10 -- 2015-06-04 10:34:13 -- http://www.goXTK.com -- @goXTK")}C(Gg,M);w=Gg.prototype;
+w.Ff=function(){window.cancelAnimationFrame(this.Ie);this.R.PROGRESSBAR_ENABLED&&(this.Vb=new Dg(this.v,3))};w.Gf=function(){this.R.PROGRESSBAR_ENABLED&&this.Vb&&(Eg(this.Vb),this.Qd=Fg(function(){this.Qd=t;this.Vb&&(this.Vb.Fd(),this.Vb=t);this.hd=this.Zd=q;this.cc()}.bind(this),700))};w.Hf=function(a){this.Vb&&this.Vb.Od(100*a.Ad)};w.Dj=function(a){this.La&&this.La.Od(100*a.Ad)};w.tj=function(a){a!=t&&a instanceof ld&&a.D&&this.ub(a.D)};w.Ej=function(a){a!=t&&a instanceof md&&a.D&&this.remove(a.D)};
+w.xe=function(){this.ab.clear()};w.Jf=function(a){(a==t||!(a instanceof Ld))&&m(Error("Invalid hover event."))};w.ve=function(){var a=be(this.v);this.K=a.clientWidth;this.A=a.clientHeight;a=be(this.na);a.width=this.K;a.height=this.A;"renderer3D"==this.f&&(this.a.viewport(0,0,this.K,this.A),this.N.We=D.g.zf(D.g.Ed(),this.N.eg,this.na.width/this.na.height,1,1E4))};w.Kf=function(a){(a==t||!(a instanceof Kd))&&m(Error("Invalid scroll event."))};Gg.prototype.__defineGetter__("config",v("R"));
+Gg.prototype.__defineGetter__("interactor",v("T"));Gg.prototype.__defineGetter__("camera",v("N"));Gg.prototype.__defineGetter__("loadingCompleted",v("hd"));Gg.prototype.__defineGetter__("container",v("v"));Gg.prototype.__defineSetter__("container",function(a){a==t&&m(Error("An ID to a valid container (<div>..) is required."));var b=a;na(b)&&(b=be(a));pa(b)&&1==b.nodeType||m(Error("Could not find the given container."));this.v=b});w=Gg.prototype;w.Nd=function(){this.N.reset()};
+w.Ca=function(a){var b=de("canvas");this.v.appendChild(b);this.K=this.v.clientWidth;this.A=this.v.clientHeight;b.width=this.K;b.height=this.A;try{var c=b.getContext(a);c||m(Error())}catch(e){var d="Sorry, "+a+' context is <strong>not supported</strong> on this machine! See <a href="http://crash.goXTK.com" target="_blank">http://crash.goXTK.com</a> for requirements..';this.v.innerHTML='<h3 style="color:red;font-family:sans-serif;">Oooops..</h3><p style="color:red;font-family:sans-serif;">'+d+"</p>";
+m(Error(d))}this.aa=new ag;L(this.aa,Ad,this.Dj.bind(this));this.na=b;this.a=c;b=new Ke(this.na);"2d"==a&&(b=new Me(this.na));b.Ca();L(b,wd,this.Nd.bind(this));L(b,Bd,this.Jf.bind(this));L(b,vd,this.Kf.bind(this));this.T=b;b=new pg(this.K,this.A);"2d"==a&&(b=new og(this.K,this.A));b.observe(this.T);this.N=b;L(window,"resize",this.ve,u,this)};w.add=function(a){(a instanceof kg||a instanceof ig||a instanceof gg)&&a.q();this.Ha.push(a);this.ub(a)};
+w.remove=function(a){(!this.na||!this.a)&&m(Error("The renderer was not initialized properly."));if(a!=t){dc(a);var b=this.Ha.length,c;for(c=0;c<b;c++)if(this.Ha[c].qa==a.qa)return this.Ha[c]=t,this.Ha.splice(c,1),q}return u};w.ub=function(a){(!this.na||!this.a)&&m(Error("The renderer was not initialized properly."));a!=t&&(ec(a,yd)||L(a,yd,this.tj.bind(this)),ec(a,zd)||L(a,zd,this.Ej.bind(this)),ec(a,Dd)||L(a,Dd,this.Ff.bind(this)),ec(a,Fd)||L(a,Fd,this.Hf.bind(this)),ec(a,Ed)||L(a,Ed,this.Gf.bind(this)))};
+w.get=function(a){a==t&&m(Error("Invalid object id."));for(var b=this.ab.I,c=b.length,e=0,e=0;e<c;e++)if(b[e].qa==a)return b[e];return t};
+w.cc=function(){(!this.na||!this.a)&&m(Error("The renderer was not initialized properly."));if(this.tg==t){if(Bc(this.aa.Kc)){if(this.R.PROGRESSBAR_ENABLED&&!this.La&&(this.La=new Dg(this.v,3)),this.Zd=this.hd=u,this.tg=Fg(function(){this.tg=t;this.cc()}.bind(this),100),!this.R.INTERMEDIATE_RENDERING)return}else if(!this.hd&&!this.Zd&&(this.Zd=q,eval("this.onShowtime()"),this.hd=q),this.La){this.R.PROGRESSBAR_ENABLED&&(this.La&&!this.Qd)&&(Eg(this.La),this.Qd=Fg(function(){this.Qd=t;this.La&&(this.La.Fd(),
+this.La=t);this.cc()}.bind(this),700));return}this.Ie=window.requestAnimationFrame(this.cc.bind(this));eval("this.onRender()");this.dc(u,q);eval("this.afterRender()")}};w.lh=aa();w.jh=aa();w.yg=aa();w.dc=aa();
+w.Ta=function(){dc(this);ac(window,"resize",this.ve,u,this);window.cancelAnimationFrame(this.Ie);this.aa&&(delete this.aa,this.aa=t);this.La&&(this.La.Fd(),delete this.La,this.La=t);this.ab.clear();delete this.ab;this.Ha.length=0;delete this.Ha;delete this.aa;this.aa=t;delete this.N;this.N=t;delete this.T;this.T=t;delete this.a;this.a=t;fe(this.na);delete this.na;this.na=t};function Hg(a,b,c,e,d,f,g,h){var l,j;if(l=c.offsetParent){var k="HTML"==l.tagName||"BODY"==l.tagName;if(!k||"static"!=oe(l,"position"))j=te(l),k||(k=(k=ue(l))&&jb?-l.scrollLeft:k&&(!K||!Cb("8"))&&"visible"!=oe(l,"overflowX")?l.scrollWidth-l.clientWidth-l.scrollLeft:l.scrollLeft,j=Yd(j,new Xd(k,l.scrollTop)))}l=j||new Xd;j=te(a);k=ye(a);j=new le(j.x,j.y,k.width,k.height);(k=se(a))&&j.Tg(new le(k.left,k.top,k.right-k.left,k.bottom-k.top));var k=Zd(a),n=Zd(c);if(k.ka!=n.ka){var s=k.ka.body,n=n.ka.parentWindow||
+n.ka.defaultView,r=new Xd(0,0),y=ae(s)?ae(s).parentWindow||ae(s).defaultView:window,z=s;do{var F=y==n?te(z):ve(z);r.x+=F.x;r.y+=F.y}while(y&&y!=n&&(z=y.frameElement)&&(y=y.parent));s=Yd(r,te(s));K&&!ie(k)&&(s=Yd(s,je(k)));j.left+=s.x;j.top+=s.y}a=(b&4&&ue(a)?b^2:b)&-5;b=new Xd(a&2?j.left+j.width:j.left,a&1?j.top+j.height:j.top);b=Yd(b,l);d&&(b.x+=(a&2?-1:1)*d.x,b.y+=(a&1?-1:1)*d.y);var G;if(g&&(G=se(c)))G.top-=l.y,G.right-=l.x,G.bottom-=l.y,G.left-=l.x;return Ig(b,c,e,f,G,g,h)}
+function Ig(a,b,c,e,d,f,g){a=a.l();var h=0,l=(c&4&&ue(b)?c^2:c)&-5;c=ye(b);g=g?g.l():c.l();if(e||0!=l)l&2?a.x-=g.width+(e?e.right:0):e&&(a.x+=e.left),l&1?a.y-=g.height+(e?e.bottom:0):e&&(a.y+=e.top);if(f){if(d){h=a;e=0;if(65==(f&65)&&(h.x<d.left||h.x>=d.right))f&=-2;if(132==(f&132)&&(h.y<d.top||h.y>=d.bottom))f&=-5;h.x<d.left&&f&1&&(h.x=d.left,e|=1);h.x<d.left&&(h.x+g.width>d.right&&f&16)&&(g.width=Math.max(g.width-(h.x+g.width-d.right),0),e|=4);h.x+g.width>d.right&&f&1&&(h.x=Math.max(d.right-g.width,
+d.left),e|=1);f&2&&(e|=(h.x<d.left?16:0)|(h.x+g.width>d.right?32:0));h.y<d.top&&f&4&&(h.y=d.top,e|=2);h.y<=d.top&&(h.y+g.height<d.bottom&&f&32)&&(g.height=Math.max(g.height-(d.top-h.y),0),h.y=0,e|=8);h.y>=d.top&&(h.y+g.height>d.bottom&&f&32)&&(g.height=Math.max(g.height-(h.y+g.height-d.bottom),0),e|=8);h.y+g.height>d.bottom&&f&4&&(h.y=Math.max(d.bottom-g.height,d.top),e|=2);f&8&&(e|=(h.y<d.top?64:0)|(h.y+g.height>d.bottom?128:0));h=e}else h=256;if(h&496)return h}f=a;d=jb&&(ab||qb)&&Cb("1.9");f instanceof
+Xd?(a=f.x,f=f.y):(a=f,f=p);b.style.left=xe(a,d);b.style.top=xe(f,d);if(!(c==g||(!c||!g?0:c.width==g.width&&c.height==g.height)))a=ie(Zd(ae(b))),K&&(!a||!Cb("8"))?(c=b.style,a?(K?(a=Ce(b,"paddingLeft"),d=Ce(b,"paddingRight"),f=Ce(b,"paddingTop"),e=Ce(b,"paddingBottom"),a=new ke(f,d,e,a)):(a=ne(b,"paddingLeft"),d=ne(b,"paddingRight"),f=ne(b,"paddingTop"),e=ne(b,"paddingBottom"),a=new ke(parseFloat(f),parseFloat(d),parseFloat(e),parseFloat(a))),K?(d=Ee(b,"borderLeft"),f=Ee(b,"borderRight"),e=Ee(b,"borderTop"),
+b=Ee(b,"borderBottom"),b=new ke(e,f,b,d)):(d=ne(b,"borderLeftWidth"),f=ne(b,"borderRightWidth"),e=ne(b,"borderTopWidth"),b=ne(b,"borderBottomWidth"),b=new ke(parseFloat(e),parseFloat(f),parseFloat(b),parseFloat(d))),c.pixelWidth=g.width-b.left-a.left-a.right-b.right,c.pixelHeight=g.height-b.top-a.top-a.bottom-b.bottom):(c.pixelWidth=g.width,c.pixelHeight=g.height)):(b=b.style,jb?b.MozBoxSizing="border-box":lb?b.WebkitBoxSizing="border-box":b.boxSizing="border-box",b.width=Math.max(g.width,0)+"px",
+b.height=Math.max(g.height,0)+"px");return h};function Jg(){}Jg.prototype.tb=aa();function Kg(a,b){this.of=a instanceof Xd?a:new Xd(a,b)}C(Kg,Jg);Kg.prototype.tb=function(a,b,c,e){Hg(pe(a),0,a,b,this.of,c,t,e)};function Lg(a,b,c){this.element=a;this.Fg=b;this.Tj=c}C(Lg,Jg);Lg.prototype.tb=function(a,b,c){Hg(this.element,this.Fg,a,b,p,c,this.Tj)};function Mg(a,b){jc.call(this);this.Hb=new rg(this);this.Pf(a||t);b&&(this.$c=b)}C(Mg,jc);w=Mg.prototype;w.H=t;w.gi=q;w.zg=t;w.Ma=u;w.ek=u;w.xf=-1;w.Wg=-1;w.Pi=u;w.wi=q;w.$c="toggle_display";w.t=v("H");w.Pf=function(a){this.Ma&&m(Error("Can not change this state of the popup while showing."));this.H=a};
+function Ng(a,b){a.Fe&&a.Fe.stop();a.re&&a.re.stop();if(b){if(!a.Ma&&a.Ef()){a.H||m(Error("Caller must call setElement before trying to show the popup"));a.tb();var c=ae(a.H);a.Pi&&tg(a.Hb,c,"keydown",a.rj,q);if(a.gi)if(tg(a.Hb,c,"mousedown",a.hh,q),K){var e;try{e=c.activeElement}catch(d){}for(;e&&"IFRAME"==e.nodeName;){try{var f=e.contentDocument||e.contentWindow.document}catch(g){break}c=f;e=c.activeElement}tg(a.Hb,c,"mousedown",a.hh,q);tg(a.Hb,c,"deactivate",a.gh)}else tg(a.Hb,c,"blur",a.gh);"toggle_display"==
+a.$c?(a.H.style.visibility="visible",Ae(a.H,q)):"move_offscreen"==a.$c&&a.tb();a.Ma=q;a.Fe?($b(a.Fe,"end",a.kh,u,a),a.Fe.play()):a.kh()}}else Og(a)}w.tb=ga;function Og(a,b){if(!a.Ma||!a.dispatchEvent({type:"beforehide",target:b}))return u;a.Hb&&a.Hb.xe();a.Ma=u;a.Wg=xa();a.re?($b(a.re,"end",wa(a.Eg,b),u,a),a.re.play()):a.Eg(b);return q}w.Eg=function(a){"toggle_display"==this.$c?this.ek?Fg(this.Og,0,this):this.Og():"move_offscreen"==this.$c&&(this.H.style.top="-10000px");this.If(a)};
+w.Og=function(){this.H.style.visibility="hidden";Ae(this.H,u)};w.Ef=function(){return this.dispatchEvent("beforeshow")};w.kh=function(){this.xf=xa();this.Wg=-1;this.dispatchEvent("show")};w.If=function(a){this.dispatchEvent({type:"hide",target:a})};w.hh=function(a){a=a.target;!he(this.H,a)&&((!this.zg||he(this.zg,a))&&!(150>xa()-this.xf))&&Og(this,a)};w.rj=function(a){27==a.keyCode&&Og(this,a.target)&&(a.preventDefault(),a.stopPropagation())};
+w.gh=function(a){if(this.wi){var b=ae(this.H);if(K||ib){if(a=b.activeElement,!a||he(this.H,a)||"BODY"==a.tagName)return}else if(a.target!=b)return;150>xa()-this.xf||Og(this)}};function Pg(a,b){this.Xj=4;this.we=b||p;Mg.call(this,a)}C(Pg,Mg);Pg.prototype.tb=function(){if(this.we){var a=!this.Ma&&"move_offscreen"!=this.$c,b=this.t();a&&(b.style.visibility="hidden",Ae(b,q));this.we.tb(b,this.Xj,this.Kl);a&&Ae(b,u)}};function Qg(a){this.ga=new zc;a&&this.ef(a)}function Rg(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+qa(a):b.substr(0,1)+a}w=Qg.prototype;w.tf=function(){return this.ga.tf()};w.add=function(a){this.ga.set(Rg(a),a)};w.ef=function(a){a=yc(a);for(var b=a.length,c=0;c<b;c++)this.add(a[c])};w.xe=function(a){a=yc(a);for(var b=a.length,c=0;c<b;c++)this.remove(a[c])};w.remove=function(a){return this.ga.remove(Rg(a))};w.clear=function(){this.ga.clear()};
+w.contains=function(a){a=Rg(a);return Cc(this.ga.ga,a)};w.Tg=function(a){var b=new Qg;a=yc(a);for(var c=0;c<a.length;c++){var e=a[c];this.contains(e)&&b.add(e)}return b};w.Dd=function(){return this.ga.Dd()};w.l=function(){return new Qg(this)};function Sg(a,b,c){this.$b=c||(a?Zd(be(a)):Zd());Pg.call(this,this.$b.Wc("div",{style:"position:absolute;display:none;"}));this.pf=new Xd(1,1);this.je=new Qg;a&&Tg(this,a);if(b!=t)if(a=this.t(),"textContent"in a)a.textContent=b;else if(a.firstChild&&3==a.firstChild.nodeType){for(;a.lastChild!=a.firstChild;)a.removeChild(a.lastChild);a.firstChild.data=b}else{for(;c=a.firstChild;)a.removeChild(c);a.appendChild(ae(a).createTextNode(String(b)))}}C(Sg,Pg);var Ug=[];w=Sg.prototype;w.Sa=t;w.className="goog-tooltip";
+w.yh=500;w.Oi=0;w.ne=v("$b");function Tg(a,b){b=be(b);a.je.add(b);L(b,"mouseover",a.Ni,u,a);L(b,"mouseout",a.Lg,u,a);L(b,"mousemove",a.Mi,u,a);L(b,"focus",a.Li,u,a);L(b,"blur",a.Lg,u,a)}w.Pf=function(a){var b=this.t();b&&fe(b);Sg.u.Pf.call(this,a);a&&(b=this.$b.ka.body,b.insertBefore(a,b.lastChild))};
+w.Ef=function(){if(!Mg.prototype.Ef.call(this))return u;if(this.anchor)for(var a,b=0;a=Ug[b];b++)he(a.t(),this.anchor)||Ng(a,u);0<=Ib(Ug,this)||Ug.push(this);a=this.t();a.className=this.className;Vg(this);L(a,"mouseover",this.Ng,u,this);L(a,"mouseout",this.Mg,u,this);Wg(this);return q};
+w.If=function(){Nb(Ug,this);for(var a=this.t(),b,c=0;b=Ug[c];c++)b.anchor&&he(a,b.anchor)&&Ng(b,u);this.nh&&Xg(this.nh);ac(a,"mouseover",this.Ng,u,this);ac(a,"mouseout",this.Mg,u,this);this.anchor=p;if(0==(this.Kb?this.Ma?4:1:this.Yc?3:this.Ma?2:0))this.Ce=u;Mg.prototype.If.call(this)};w.$g=function(a,b){this.anchor==a&&this.je.contains(this.anchor)&&(this.Ce||!this.Ul?(Ng(this,u),this.Ma||(this.anchor=a,this.we=b||Yg(this,0)||p,this.Ma&&this.tb(),Ng(this,q))):this.anchor=p);this.Kb=p};
+w.ij=function(a){this.Yc=p;a==this.anchor&&(this.Sa==t||this.Sa!=this.t()&&!this.je.contains(this.Sa))&&(!this.Bg||!this.Bg.Sa)&&Ng(this,u)};function Zg(a,b){var c=je(a.$b);a.pf.x=b.clientX+c.x;a.pf.y=b.clientY+c.y}w.Ni=function(a){var b=$g(this,a.target);this.Sa=b;Vg(this);b!=this.anchor&&(this.anchor=b,this.Kb||(this.Kb=Fg(va(this.$g,this,b,p),this.yh)),ah(this),Zg(this,a))};function $g(a,b){try{for(;b&&!a.je.contains(b);)b=b.parentNode;return b}catch(c){return t}}
+w.Mi=function(a){Zg(this,a);this.Ce=q};w.Li=function(a){this.Sa=a=$g(this,a.target);this.Ce=q;if(this.anchor!=a){this.anchor=a;var b=Yg(this,1);Vg(this);this.Kb||(this.Kb=Fg(va(this.$g,this,a,b),this.yh));ah(this)}};function Yg(a,b){if(0==b){var c=a.pf.l();return new bh(c)}return new ch(a.Sa)}function ah(a){if(a.anchor)for(var b,c=0;b=Ug[c];c++)he(b.t(),a.anchor)&&(b.Bg=a,a.nh=b)}
+w.Lg=function(a){var b=$g(this,a.target),c=$g(this,a.relatedTarget);b!=c&&(b==this.Sa&&(this.Sa=t),Wg(this),this.Ce=u,this.Ma&&(!a.relatedTarget||!he(this.t(),a.relatedTarget))?Xg(this):this.anchor=p)};w.Ng=function(){var a=this.t();this.Sa!=a&&(Vg(this),this.Sa=a)};w.Mg=function(a){var b=this.t();if(this.Sa==b&&(!a.relatedTarget||!he(b,a.relatedTarget)))this.Sa=t,Xg(this)};function Wg(a){a.Kb&&(fa.clearTimeout(a.Kb),a.Kb=p)}
+function Xg(a){if(2==(a.Kb?a.Ma?4:1:a.Yc?3:a.Ma?2:0))a.Yc=Fg(va(a.ij,a,a.anchor),a.Oi)}function Vg(a){a.Yc&&(fa.clearTimeout(a.Yc),a.Yc=p)}function bh(a,b){Kg.call(this,a,b)}C(bh,Kg);bh.prototype.tb=function(a,b,c){b=pe(a);b=se(b);c=c?new ke(c.top+10,c.right,c.bottom,c.left+10):new ke(10,0,0,10);Ig(this.of,a,4,c,b,9)&496&&Ig(this.of,a,4,c,b,5)};function ch(a){Lg.call(this,a,3)}C(ch,Lg);
+ch.prototype.tb=function(a,b,c){var e=new Xd(10,0);Hg(this.element,this.Fg,a,b,e,c,9)&496&&Hg(this.element,2,a,1,e,c,5)};function dh(a,b,c,e){a==t&&m(Error("No valid parent element."));(!x(b)||!x(c))&&m(Error("Invalid coordinates."));(e==t||!(e instanceof Ie))&&m(Error("Invalid interactor."));Sg.call(this);this.f="caption";this.bb=a;this.fe=b;this.ge=c;this.T=e;this.Fb=t;this.fc=[];a=".x-tooltip {\n  background: #C0C0FF;\n  color: #000000;\n";a+="  border: 1px solid infotext;\n";a+="  padding: 1px;\n";a+="  font-family: sans-serif;\n";a+="}";this.fc=[a];$b(e,Cd,this.Fd.bind(this));this.vf()}C(dh,Sg);
+dh.prototype.vf=function(){var a=ne(this.bb,"position");if("static"==a||""==a)this.bb.style.position="relative";var a=document.getElementsByTagName("head")[0],b=de("style");b.type="text/css";b.media="screen";var c=document.createTextNode(String(this.fc[0]));a.appendChild(b);b.appendChild(c);this.Fb=b;this.we=new Kg(this.fe,this.ge)||p;this.Ma&&this.tb();Ng(this,q);Tg(this,this.bb);this.t().classList.add("x-tooltip")};
+dh.prototype.Fd=function(){Ng(this,u);this.Fb&&fe(this.Fb);this.t()&&fe(this.t());this.Fb=t};function eh(){M.call(this);this.f="shaders";this.ce="";var a;a="precision mediump float;\n\n";a+="attribute vec3 vertexPosition;\n";a+="attribute vec3 vertexNormal;\n";a+="attribute vec3 vertexColor;\n";a+="attribute vec2 vertexTexturePos;\n";a+="attribute float vertexScalar;\n";a+="\n";a+="uniform mat4 view;\n";a+="uniform mat4 perspective;\n";a+="uniform vec3 center;\n";a+="uniform mat4 objectTransform;\n";a+="uniform bool useObjectColor;\n";a+="uniform bool useScalars;\n";a+="uniform bool scalarsReplaceMode;\n";
+a+="uniform float scalarsMin;\n";a+="uniform float scalarsMax;\n";a+="uniform vec3 scalarsMinColor;\n";a+="uniform vec3 scalarsMaxColor;\n";a+="uniform float scalarsMinThreshold;\n";a+="uniform float scalarsMaxThreshold;\n";a+="uniform int scalarsInterpolation;\n";a+="uniform vec3 objectColor;\n";a+="uniform float pointSize;\n";a+="\n";a+="varying float fDiscardNow;\n";a+="varying vec4 fVertexPosition;\n";a+="varying vec3 fragmentColor;\n";a+="varying vec2 fragmentTexturePos;\n";a+="varying vec3 fVertexNormal;\n";
+a+="varying vec3 fTransformedVertexNormal;\n";a+="\n";a+="void main(void) {\n";a+="  fTransformedVertexNormal = mat3(view[0].xyz,view[1].xyz,view[2].xyz) * ";a+="mat3(objectTransform[0].xyz,objectTransform[1].xyz,objectTransform[2].xyz) * ";a+="vertexNormal;\n";a+="  fVertexNormal = vertexNormal;\n";a+="  fDiscardNow = 0.0;\n";a+="  vec3 vertexPosition2 = vertexPosition - center;\n";a+="  fVertexPosition = view * objectTransform * vec4(vertexPosition2, 1.0);\n";a+="  fragmentTexturePos = vertexTexturePos;\n";
+a+="  if (useScalars) {\n";a+="    float scalarValue = vertexScalar;\n";a+="    if (scalarValue < scalarsMinThreshold || scalarValue > scalarsMaxThreshold) {\n";a+="      if (scalarsReplaceMode) {\n";a+="        fragmentColor = objectColor;\n";a+="      } else {\n";a+="        fDiscardNow = 1.0;\n";a+="      }\n";a+="    } else {\n";a+="      if (scalarsReplaceMode) {\n";a+="        if (scalarsInterpolation == 1) {\n";a+="            vec3 zeroMaxColor;\n";a+="            vec3 zeroMinColor;\n";a+=
+"            zeroMaxColor[0] = scalarsMaxColor[0]*0.33;\n";a+="            zeroMaxColor[1] = scalarsMaxColor[1]*0.33;\n";a+="            zeroMaxColor[2] = scalarsMaxColor[2]*0.33;\n";a+="            zeroMinColor[0] = scalarsMinColor[0]*0.33;\n";a+="            zeroMinColor[1] = scalarsMinColor[1]*0.33;\n";a+="            zeroMinColor[2] = scalarsMinColor[2]*0.33;\n";a+="            if(scalarValue < 0.0) {fragmentColor = scalarValue/(scalarsMin) * scalarsMinColor + (1.0 - scalarValue/(scalarsMin)) * (zeroMinColor);}\n";
+a+="            else {fragmentColor = scalarValue/(scalarsMax) * scalarsMaxColor + (1.0 - scalarValue/(scalarsMax)) * (zeroMaxColor);}\n";a+="        } else {\n";a+="            fragmentColor = scalarValue * scalarsMaxColor + (1.0 - scalarValue) * scalarsMinColor;\n";a+="          }\n";a+="      } else {\n";a+="        fragmentColor = vertexColor;\n";a+="      }\n";a+="    }\n";a+="  } else if (useObjectColor) {\n";a+="    fragmentColor = objectColor;\n";a+="  } else {\n";a+="    fragmentColor = vertexColor;\n";
+a+="  }\n";a+="  gl_PointSize = pointSize;\n";a+="  gl_Position = perspective * fVertexPosition;\n";this.ce=a+="}\n";this.Ud="";a="precision mediump float;\n\n";a+="uniform bool usePicking;\n";a+="uniform bool useTexture;\n";a+="uniform bool volumeTexture;\n";a+="uniform bool useLabelMapTexture;\n";a+="uniform sampler2D textureSampler;\n";a+="uniform sampler2D textureSampler2;\n";a+="uniform float objectOpacity;\n";a+="uniform float labelmapOpacity;\n";a+="uniform vec4 labelmapColor;\n";a+="uniform float volumeLowerThreshold;\n";
+a+="uniform float volumeUpperThreshold;\n";a+="uniform float volumeScalarMin;\n";a+="uniform float volumeScalarMax;\n";a+="uniform vec3 volumeScalarMinColor;\n";a+="uniform vec3 volumeScalarMaxColor;\n";a+="uniform float volumeWindowLow;\n";a+="uniform float volumeWindowHigh;\n";a+="\n";a+="varying float fDiscardNow;\n";a+="varying vec4 fVertexPosition;\n";a+="varying vec3 fragmentColor;\n";a+="varying vec2 fragmentTexturePos;\n";a+="varying vec3 fVertexNormal;\n";a+="varying vec3 fTransformedVertexNormal;\n";
+a+="\n";a+="void main(void) {\n";a+=" if (fDiscardNow > 0.0) {\n";a+="   discard;\n";a+=" }\n";a+=" if (usePicking) {\n";a+="   gl_FragColor = vec4(fragmentColor, 1.0);\n";a+=" } else if (useTexture) {\n";a+="   vec4 texture1 = texture2D(textureSampler,fragmentTexturePos);\n";a+="   vec4 textureSum = texture1;\n";a+="   if (volumeTexture) {\n";a+="     float _windowLow = ((volumeWindowLow - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin));\n";a+="     float _windowHigh = ((volumeWindowHigh - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin));\n";
+a+="     vec3 _minrange = vec3(_windowLow,_windowLow,_windowLow);\n";a+="     vec3 _maxrange = vec3(_windowHigh,_windowHigh,_windowHigh);\n";a+="     vec3 fac = _maxrange - _minrange;\n";a+="     textureSum = vec4((textureSum.r - _minrange)/fac,1);\n";a+="     textureSum = textureSum.r * vec4(volumeScalarMaxColor,1) + (1.0 - textureSum.r) * vec4(volumeScalarMinColor,1);\n";a+="   }\n";a+="   if (useLabelMapTexture) {\n";a+="     vec4 texture2 = texture2D(textureSampler2,fragmentTexturePos);\n";a+=
+"     if (texture2.a > 0.0) {\n";a+="         if (labelmapColor.a != -255.0) {\n";a+="           if (all(equal(floor(texture2 * vec4(255)), labelmapColor))) {\n";a+="             if (labelmapOpacity < 1.0) {\n";a+="               textureSum = mix(texture2, textureSum, 1.0 - labelmapOpacity);\n";a+="             } else {\n";a+="               textureSum = texture2;\n";a+="             }\n";a+="           }\n";a+="         } else {\n";a+="           if (labelmapOpacity < 1.0) {\n";a+="             textureSum = mix(texture2, textureSum, 1.0 - labelmapOpacity);\n";
+a+="           } else {\n";a+="             textureSum = texture2;\n";a+="           }\n";a+="         }\n";a+="     }\n";a+="   }\n";a+="   if (volumeTexture) {\n";a+="     float _volumeLowerThreshold = (volumeLowerThreshold - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin);\n";a+="     float _volumeUpperThreshold = (volumeUpperThreshold - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin);\n";a+="     if (texture1.r < _volumeLowerThreshold ||\n";a+="         texture1.r > _volumeUpperThreshold ||\n";
+a+="         texture1.a == 0.0 ) {\n";a+="       discard;\n";a+="     };\n";a+="   };\n";a+="   gl_FragColor = textureSum;\n";a+="   gl_FragColor.a = objectOpacity;\n";a+=" } else {\n";a+="   vec3 nNormal = normalize(fTransformedVertexNormal);\n";a+="   if (fVertexNormal == vec3(0.0,0.0,0.0)) {\n";a+="     gl_FragColor = vec4(fragmentColor,1.0);\n";a+="     return;\n";a+="   }\n";a+="   vec3 light = vec3(0.0, 0.0, 1.0);\n";a+="   vec3 lightDirection = vec3(0,0,-10);\n";a+="   lightDirection = normalize(lightDirection);\n";
+a+="   vec3 eyeDirection = normalize(-fVertexPosition.xyz);\n";a+="   vec3 reflectionDirection = reflect(-lightDirection, nNormal);\n";a+="   float specular = pow(max(dot(reflectionDirection, eyeDirection), 0.0), 10.0);\n";a+="   float diffuse = 0.8 * max(dot(nNormal, light), 0.0);\n";a+="   float ambient = 0.3;\n";a+="   gl_FragColor = vec4(fragmentColor * ambient +\n";a+="                       fragmentColor * diffuse +\n";a+="                       vec3(0.2, 0.2, 0.2) * specular,\n";a+="                       objectOpacity);\n";
+a+=" }\n";this.Ud=a+="}\n"}C(eh,M);
+var fh={$k:"vertexPosition",Zk:"vertexNormal",Yk:"vertexColor",bl:"vertexTexturePos",al:"vertexScalar"},gh={cl:"view",Hk:"perspective",yk:"center",Gk:"objectTransform",Uk:"useObjectColor",Ek:"objectColor",Wk:"useScalars",Qk:"scalarsReplaceMode",Nk:"scalarsMin",Kk:"scalarsMax",Ok:"scalarsMinColor",Lk:"scalarsMaxColor",Pk:"scalarsMinThreshold",Mk:"scalarsMaxThreshold",Jk:"scalarsInterpolation",Ik:"pointSize",Fk:"objectOpacity",Dk:"normal",Vk:"usePicking",Xk:"useTexture",Tk:"useLabelMapTexture",Bk:"labelmapOpacity",
+Ak:"labelmapColor",Rk:"textureSampler",Sk:"textureSampler2",dl:"volumeLowerThreshold",jl:"volumeUpperThreshold",gl:"volumeScalarMin",el:"volumeScalarMax",hl:"volumeScalarMinColor",fl:"volumeScalarMaxColor",ll:"volumeWindowLow",kl:"volumeWindowHigh",il:"volumeTexture"};function hh(){Gg.call(this);this.f="renderer3D";this.md=this.pd=this.ld=this.od=this.kd=this.nd=this.Ze=this.$e=t;this.z=[0,0,0];this.bd=[0,0,0];this.rg=t;this.Je=new zc;this.xd=new zc;this.pc=new zc;this.qd=new zc;this.Ec=new zc;this.Pc=new zc;this.oc=new zc;this.wd=new zc;this.R={PROGRESSBAR_ENABLED:q,PICKING_ENABLED:q,ORDERING_ENABLED:q,STATISTICS_ENABLED:u,INTERMEDIATE_RENDERING:u}}C(hh,Gg);hh.prototype.__defineGetter__("config",v("R"));w=hh.prototype;
+w.Zj=function(){this.md=this.pd=this.ld=this.od=this.kd=this.nd=t;this.z=[0,0,0]};w.Jf=function(a){hh.u.Jf.call(this,a);var b=a.fe;a=a.ge;var c=this.Nf(b,a);if(c=this.get(c))if(c=c.Dc){var e=ve(this.v);(new dh(this.v,e.x+b+10,e.y+a+10,this.T)).t().innerHTML=c}};
+w.Ca=function(){hh.u.Ca.call(this,"experimental-webgl");try{if(this.a.viewport(0,0,this.K,this.A),this.a.clearColor(this.bd[0],this.bd[1],this.bd[2],0),this.a.enable(this.a.BLEND),this.a.blendEquation(this.a.FUNC_ADD),this.a.blendFunc(this.a.SRC_ALPHA,this.a.ONE_MINUS_SRC_ALPHA),this.a.enable(this.a.DEPTH_TEST),this.a.depthFunc(this.a.LEQUAL),this.a.clear(this.a.COLOR_BUFFER_BIT|this.a.DEPTH_BUFFER_BIT),this.R.PICKING_ENABLED){var a=this.a.createFramebuffer(),b=this.a.createRenderbuffer(),c=this.a.createTexture();
+this.a.bindTexture(this.a.TEXTURE_2D,c);this.a.texImage2D(this.a.TEXTURE_2D,0,this.a.RGB,this.K,this.A,0,this.a.RGB,this.a.UNSIGNED_BYTE,t);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_S,this.a.CLAMP_TO_EDGE);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_T,this.a.CLAMP_TO_EDGE);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MAG_FILTER,this.a.NEAREST);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MIN_FILTER,this.a.NEAREST);this.a.bindFramebuffer(this.a.FRAMEBUFFER,
+a);this.a.bindRenderbuffer(this.a.RENDERBUFFER,b);this.a.renderbufferStorage(this.a.RENDERBUFFER,this.a.DEPTH_COMPONENT16,this.K,this.A);this.a.bindRenderbuffer(this.a.RENDERBUFFER,t);this.a.framebufferTexture2D(this.a.FRAMEBUFFER,this.a.COLOR_ATTACHMENT0,this.a.TEXTURE_2D,c,0);this.a.framebufferRenderbuffer(this.a.FRAMEBUFFER,this.a.DEPTH_ATTACHMENT,this.a.RENDERBUFFER,b);this.a.bindFramebuffer(this.a.FRAMEBUFFER,t);this.rg=a}}catch(e){m(Error("Exception while accessing GL Context!\n"+e))}a=new eh;
+(this.na==t||this.a==t||this.N==t)&&m(Error("Renderer was not initialized properly."));(a==t||!(a instanceof eh))&&m(Error("Could not add shaders."));b=Object.keys(gh);Object.keys(fh).every(function(a){a=fh[a];return-1!=this.ce.search(a)||-1!=this.Ud.search(a)}.bind(a))||m(Error("Could not find all attributes in the shader sources."));b.every(function(a){a=gh[a];return-1!=this.ce.search(a)||-1!=this.Ud.search(a)}.bind(a))||m(Error("Could not find all uniforms in the shader sources."));b=this.a.createShader(this.a.FRAGMENT_SHADER);
+c=this.a.createShader(this.a.VERTEX_SHADER);this.a.shaderSource(b,a.Ud);this.a.shaderSource(c,a.ce);this.a.compileShader(b);this.a.compileShader(c);this.a.getShaderParameter(b,this.a.COMPILE_STATUS)||m(Error("Fragement Shader compilation failed!\n"+this.a.getShaderInfoLog(b)));this.a.getShaderParameter(c,this.a.COMPILE_STATUS)||m(Error("Vertex Shader compilation failed!\n"+this.a.getShaderInfoLog(c)));var d=this.a.createProgram();this.a.attachShader(d,c);this.a.attachShader(d,b);this.a.linkProgram(d);
+this.a.getProgramParameter(d,this.a.LINK_STATUS)||m(Error("Could not create shader program!\n"+this.a.getShaderInfoLog(b)+"\n"+this.a.getShaderInfoLog(c)+"\n"+this.a.getProgramInfoLog(d)));this.a.useProgram(d);this.Ze=d;Object.keys(fh).forEach(function(a){a=fh[a];this.Je.set(a,this.a.getAttribLocation(this.Ze,a));this.a.enableVertexAttribArray(this.Je.get(a))}.bind(this));Object.keys(gh).forEach(function(a){a=gh[a];this.xd.set(a,this.a.getUniformLocation(this.Ze,a))}.bind(this));this.$e=a};
+w.ub=function(a){hh.u.ub.call(this,a);var b=u;if(a!=t){this.get(a.qa)&&(b=q);var c=a.qa,e=a.h,d=a.n,f=a.pa,g=a.G,h=a.r,l=a.ja,j=a.xa,k=a.e,n=a.F;if(k!=t&&k.r!=t&&k.r.j)this.ub(k);else if(k!=t&&k.j&&this.ub(k),j!=t&&j.r!=t&&j.r.j)this.aa.load(j,a);else if(g!=t&&g.r!=t&&g.r.j)this.aa.load(g,a);else{if(h!=t&&ja(h))if(a.yc!=t){if(a.yc.yf!=h.length||!a.j)return}else{b=0;c=h.length;for(b=0;b<c;b++)this.aa.load(h[b],a);return}else{if(h!=t&&h.j){this.aa.load(a,a);return}if(n!=t&&n.r!=t&&n.r.j){this.aa.load(n,
+a);return}}if(0<a.c.length){h=a.c;j=h.length;for(k=k=0;k<j;k++)this.ub(h[k])}if(e){for(h=0;this.Xd;)h++,window.console.log("Possible thread lock avoided: "+h);this.Xd=q;j=a instanceof Te&&a.yb instanceof Xe;b&&(g!=t&&g.j)&&(h=this.oc.get(c),h!=t&&this.a.isBuffer(h.P)&&this.a.deleteBuffer(h.P));h=t;g!=t&&(!b||g.j?(h=a.nc,h==t&&m(Error("Can not add an object and texture without valid coordinate mapping! Set the textureCoordinateMap!")),k=u,g.Wb&&(k=q),this.a.pixelStorei(this.a.UNPACK_FLIP_Y_WEBGL,k),
+k=this.a.createTexture(),k.Si=g.jb,this.wd.set(g.qa,k),this.a.bindTexture(this.a.TEXTURE_2D,k),g.Wb?(k=this.a.RGBA,g.hg&&(k=this.a.LUMINANCE,this.a.pixelStorei(this.a.UNPACK_ALIGNMENT,1)),this.a.texImage2D(this.a.TEXTURE_2D,0,k,g.Ye,g.Xe,0,k,this.a.UNSIGNED_BYTE,g.Wb)):this.a.texImage2D(this.a.TEXTURE_2D,0,this.a.RGBA,this.a.RGBA,this.a.UNSIGNED_BYTE,k.Si),this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_S,this.a.CLAMP_TO_EDGE),this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_T,
+this.a.CLAMP_TO_EDGE),j?(this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MAG_FILTER,this.a.NEAREST),this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MIN_FILTER,this.a.NEAREST)):(this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MAG_FILTER,this.a.LINEAR),this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MIN_FILTER,this.a.LINEAR)),this.a.bindTexture(this.a.TEXTURE_2D,t),k=this.a.createBuffer(),this.a.bindBuffer(this.a.ARRAY_BUFFER,k),this.a.bufferData(this.a.ARRAY_BUFFER,new Float32Array(h),
+this.a.STATIC_DRAW),h=new Sd(k,h.length,2),this.oc.set(c,h),g.j=u):h=this.oc.get(c));bg(this.aa,0.1);if(j)this.Xd=u,D.Da(this.f+".update"),bg(this.aa,0.9);else{if(!b||e.j||l.j){j=l.Q;g=D.g.ba(j,e.nb,e.ob,e.pb);j=D.g.ba(j,e.kb,e.lb,e.mb);if(this.nd===t||g.x<this.nd)this.nd=g.x;if(this.kd===t||j.x>this.kd)this.kd=j.x;if(this.od===t||g.y<this.od)this.od=g.y;if(this.ld===t||j.y>this.ld)this.ld=j.y;if(this.pd===t||g.d<this.pd)this.pd=g.d;if(this.md===t||j.d>this.md)this.md=j.d;this.z=[(this.nd+this.kd)/
+2,(this.od+this.ld)/2,(this.pd+this.md)/2];l.j=u}b&&e.j&&(l=this.pc.get(c),l!=t&&this.a.isBuffer(l.P)&&this.a.deleteBuffer(l.P));l=t;!b||e.j?(l=this.a.createBuffer(),e.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER,l),this.a.bufferData(this.a.ARRAY_BUFFER,e.da,this.a.STATIC_DRAW),l=new Sd(l,e.count,3),e.j=u):l=this.pc.get(c);bg(this.aa,0.3);b&&d.j&&(g=this.pc.get(c),g!=t&&this.a.isBuffer(g.P)&&this.a.deleteBuffer(g.P));g=t;!b||d.j?(g=this.a.createBuffer(),d.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER,
+g),this.a.bufferData(this.a.ARRAY_BUFFER,d.da,this.a.STATIC_DRAW),g=new Sd(g,d.count,3),d.j=u):g=this.qd.get(c);bg(this.aa,0.3);b&&(f&&f.j)&&(d=this.Ec.get(c),d!=t&&this.a.isBuffer(d.P)&&this.a.deleteBuffer(d.P));d=t;f&&(!b||f.j?(f.length!=e.length&&m(Error("Mismatch between points and point colors.")),d=this.a.createBuffer(),f.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER,d),this.a.bufferData(this.a.ARRAY_BUFFER,f.da,this.a.STATIC_DRAW),d=new Sd(d,f.count,3),f.j=u):d=this.Ec.get(c));bg(this.aa,0.2);
+b&&(n&&n.j)&&(f=this.Pc.get(c),f!=t&&this.a.isBuffer(f.P)&&this.a.deleteBuffer(f.P));f=t;n&&(f=n.dd,!b||n.j?(f.length!=e.length&&m(Error("Mismatch between points and scalars.")),e=this.a.createBuffer(),this.a.bindBuffer(this.a.ARRAY_BUFFER,e),this.a.bufferData(this.a.ARRAY_BUFFER,f,this.a.STATIC_DRAW),f=new Sd(e,f.length,3),n.j=u):f=this.Pc.get(c));bg(this.aa,0.1);b||this.ab.add(a);this.pc.set(c,l);this.qd.set(c,g);this.Ec.set(c,d);this.oc.set(c,h);this.Pc.set(c,f);this.Xd=a.j=u}}else a.j=u}}};
+w.Nf=function(a,b){if(this.R.PICKING_ENABLED){this.dc(q,u);var c=new Uint8Array(4);this.a.readPixels(a,this.A-b,1,1,this.a.RGBA,this.a.UNSIGNED_BYTE,c);return c[0]+255*c[1]+65025*c[2]}return-1};
+w.dc=function(a,b){hh.u.dc.call(this,a,b);this.a.viewport(0,0,this.K,this.A);this.a.clear(this.a.COLOR_BUFFER_BIT|this.a.DEPTH_BUFFER_BIT);var c=this.ab.I,e=c.length;if(0!=e){a?this.a.bindFramebuffer(this.a.FRAMEBUFFER,this.rg):this.a.bindFramebuffer(this.a.FRAMEBUFFER,t);var d=this.N.We,f=this.N.o;this.a.uniformMatrix4fv(this.xd.get("perspective"),u,d);this.a.uniformMatrix4fv(this.xd.get("view"),u,f);d=this.z;this.a.uniform3f(this.xd.get("center"),parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2]));
+f=this.Ha.length;for(d=0;d<f;++d){var g=this.Ha[d];if(g instanceof P){var h=D.g.ba(this.N.o,g.s[0]+g.b[0].i[0],g.s[1]+g.b[0].i[1],g.s[2]+g.b[0].i[2]),l=D.g.ba(this.N.o,g.s[0]-g.b[0].i[0],g.s[1]-g.b[0].i[1],g.s[2]-g.b[0].i[2]),j=Math.abs(h.d-l.d),h=D.g.ba(this.N.o,g.s[0]+g.b[1].i[0],g.s[1]+g.b[1].i[1],g.s[2]+g.b[1].i[2]),l=D.g.ba(this.N.o,g.s[0]-g.b[1].i[0],g.s[1]-g.b[1].i[1],g.s[2]+-g.b[1].i[2]),k=Math.abs(h.d-l.d),h=D.g.ba(this.N.o,g.s[0]+g.b[2].i[0],g.s[1]+g.b[2].i[1],g.s[2]+g.b[2].i[2]),l=D.g.ba(this.N.o,
+g.s[0]-g.b[2].i[0],g.s[1]-g.b[2].i[1],g.s[2]-g.b[2].i[2]),h=Math.max(j,k,Math.abs(h.d-l.d));h==j?We(g,0):h==k?We(g,1):We(g,2)}}if(this.R.ORDERING_ENABLED){j=u;f=this.Ha;g=f.length-1;do if(d=f[g],d instanceof P&&d.Ra&&-1!=d.X){var j=d.c[d.X].c,k=d.X,h=D.g.ba(this.N.o,d.s[0]+d.b[k].B[0],d.s[1]+d.b[k].B[1],d.s[2]+d.b[k].B[2]),l=D.g.ba(this.N.o,d.s[0]-d.b[k].B[0],d.s[1]-d.b[k].B[1],d.s[2]-d.b[k].B[2]),h=h.d-l.d,l=Math.max(d.Cc[d.X],Math.max(d.Cc[d.X+4],d.Cc[d.X+8])),n=Math.min(d.Cc[d.X],Math.min(d.Cc[d.X+
+4],d.Cc[d.X+8]));if(0>h*(l+n))for(h=h=0;h<d.ud[k]-1;h++)j[h]&&(j[h].za=d.za,j[h].ya=d.b[k].Sc*h);else for(h=d.ud[k]-1;0<=h;h--)j[h]&&(j[h].za=d.za,j[h].ya=(d.ud[k]-1)*d.b[k].Sc-d.b[k].Sc*h);j=q}while(g--);f=this.ab.I;g=f.length-1;do if(d=f[g],d.O&&!(1==d.za||d instanceof Te))j=d,k=d.h.Rd,d=D.g.ba(d.ja.Q,k[0],k[1],k[2]),d=D.g.ba(this.N.o,d.x,d.y,d.d),d=D.m.sf(this.N.ic,d),d=Math.round(1E3*d)/1E3,j.ya=d,j=q;while(g--);j&&this.ab.sort()}if(f=!a&&b!=t&&b&&this.R.STATISTICS_ENABLED)var s=0;var d=this.Je,
+g=d.get("vertexPosition"),j=d.get("vertexNormal"),k=d.get("vertexColor"),h=d.get("vertexTexturePos"),l=d.get("vertexScalar"),d=this.xd,n=d.get("usePicking"),r=d.get("useObjectColor"),y=d.get("objectColor"),z=d.get("useScalars"),F=d.get("scalarsReplaceMode"),G=d.get("scalarsMin"),H=d.get("scalarsMax"),B=d.get("scalarsMinColor"),E=d.get("scalarsMaxColor"),I=d.get("scalarsInterpolation"),N=d.get("scalarsMinThreshold"),Q=d.get("scalarsMaxThreshold"),O=d.get("objectOpacity"),S=d.get("labelmapOpacity"),
+da=d.get("labelmapColor"),J=d.get("useTexture"),ba=d.get("useLabelMapTexture"),la=d.get("textureSampler"),U=d.get("textureSampler2"),V=d.get("volumeLowerThreshold"),Ga=d.get("volumeUpperThreshold"),tb=d.get("volumeScalarMin"),ub=d.get("volumeScalarMax"),vb=d.get("volumeWindowLow"),kb=d.get("volumeWindowHigh"),Zc=d.get("volumeScalarMinColor"),lh=d.get("volumeScalarMaxColor"),Ag=d.get("volumeTexture"),mh=d.get("objectTransform"),nh=d.get("pointSize"),d=e;do{var ea=c[e-d];if(ea){var ka=t;ea instanceof
+Te&&ea.yb&&(ka=ea.yb);if(ea.O&&(!ka||ka.O)&&(!a||ea.rd)){var Ba=ea.qa,cb=ea.jd,nb=this.pc.get(Ba),ob=this.qd.get(Ba),Ye=this.Ec.get(Ba),Kb=this.Pc.get(Ba),Ze=this.oc.get(Ba);this.a.bindBuffer(this.a.ARRAY_BUFFER,nb.P);this.a.vertexAttribPointer(g,nb.Ob,this.a.FLOAT,u,0,0);this.a.bindBuffer(this.a.ARRAY_BUFFER,ob.P);this.a.vertexAttribPointer(j,ob.Ob,this.a.FLOAT,u,0,0);a?this.a.uniform1i(n,q):this.a.uniform1i(n,u);Ye&&!a&&!cb?(this.a.uniform1i(r,u),this.a.bindBuffer(this.a.ARRAY_BUFFER,Ye.P),this.a.vertexAttribPointer(k,
+Ye.Ob,this.a.FLOAT,u,0,0)):(ob=1,cb&&!a&&(ob=0),this.a.uniform1i(r,ob),ob=ea.w,a&&(ob=[Math.floor(Ba%65025%255)/255,Math.floor(Ba%65025/255)/255,Math.floor(Ba/65025)/255]),this.a.uniform3f(y,parseFloat(ob[0]),parseFloat(ob[1]),parseFloat(ob[2])),this.a.vertexAttribPointer(k,nb.Ob,this.a.FLOAT,u,0,0));Kb&&!a&&!cb?(this.a.uniform1i(z,q),this.a.uniform1i(F,ea.F.ug),Ba=ea.F.Rb,cb=ea.F.Pb,this.a.uniform3f(B,parseFloat(Ba[0]),parseFloat(Ba[1]),parseFloat(Ba[2])),this.a.uniform3f(E,parseFloat(cb[0]),parseFloat(cb[1]),
+parseFloat(cb[2])),this.a.uniform1f(N,parseFloat(ea.F.U)),this.a.uniform1f(Q,parseFloat(ea.F.W)),this.a.uniform1f(G,parseFloat(ea.F.ra)),this.a.uniform1f(H,parseFloat(ea.F.ia)),this.a.uniform1i(I,parseInt(ea.F.Me,10)),this.a.bindBuffer(this.a.ARRAY_BUFFER,Kb.P),this.a.vertexAttribPointer(l,Kb.Ob,this.a.FLOAT,u,0,0)):(this.a.uniform1i(z,u),this.a.vertexAttribPointer(l,nb.Ob,this.a.FLOAT,u,0,0));this.a.uniform1f(O,parseFloat(ea.za));ea.G&&Ze&&!a?(this.a.uniform1i(J,q),this.a.activeTexture(this.a.TEXTURE0),
+this.a.bindTexture(this.a.TEXTURE_2D,this.wd.get(ea.G.qa)),this.a.uniform1i(la,0),this.a.bindBuffer(this.a.ARRAY_BUFFER,Ze.P),this.a.vertexAttribPointer(h,Ze.Ob,this.a.FLOAT,u,0,0),this.a.uniform1i(Ag,u)):(this.a.uniform1i(J,u),this.a.vertexAttribPointer(h,nb.Ob,this.a.FLOAT,u,0,0));ka&&(this.a.uniform1i(Ag,q),this.a.uniform1f(V,ka.U),this.a.uniform1f(Ga,ka.W),this.a.uniform1f(tb,ka.ra),this.a.uniform1f(ub,ka.ia),Ba=ka.Rb,cb=ka.Pb,this.a.uniform3f(Zc,parseFloat(Ba[0]),parseFloat(Ba[1]),parseFloat(Ba[2])),
+this.a.uniform3f(lh,parseFloat(cb[0]),parseFloat(cb[1]),parseFloat(cb[2])),this.a.uniform1f(vb,ka.fa),this.a.uniform1f(kb,ka.ea),Kb=ka.e,this.a.uniform1i(ba,u),ka.Ra?this.a.uniform1f(O,parseFloat(ka.za)):Kb&&Kb.O&&(ka=ea.e.qa,this.a.uniform1i(ba,q),this.a.activeTexture(this.a.TEXTURE1),this.a.bindTexture(this.a.TEXTURE_2D,this.wd.get(ka)),this.a.uniform1i(U,1),this.a.uniform1f(S,Kb.za),this.a.uniform4fv(da,Kb.af)));this.a.uniformMatrix4fv(mh,u,ea.ja.Q);ka=1;"POINTS"==ea.Ia&&(ka=ea.sd);this.a.uniform1f(nh,
+ka);ka=-1;ea.Ia==id?(ka=this.a.TRIANGLES,f&&(s+=nb.ed/3)):"LINES"==ea.Ia?(this.a.lineWidth(ea.Lc),ka=this.a.LINES):"POINTS"==ea.Ia?ka=this.a.POINTS:"TRIANGLE_STRIPS"==ea.Ia?(ka=this.a.TRIANGLE_STRIP,f&&(s+=nb.ed/3)):"POLYGONS"==ea.Ia&&(ka=0==nb.ed%3?this.a.TRIANGLES:this.a.TRIANGLE_FAN,f&&(s+=nb.ed/3));this.a.drawArrays(ka,0,nb.ed)}}}while(--d);f&&Math.round(s)}};
+w.remove=function(a){hh.u.remove.call(this,a);if(0<a.c.length)for(var b=a.c,c=b.length,e=0,e=0;e<c;e++)"undefined"!=typeof b[e]&&this.remove(b[e]);b=a.qa;c=this.oc.get(b);c!=t&&this.a.isBuffer(c.P)&&this.a.deleteBuffer(c.P);if(a.G&&(c=this.wd.get(a.G.qa)))this.a.deleteTexture(c),this.wd.remove(a.G.qa);c=this.pc.get(b);c!=t&&this.a.isBuffer(c.P)&&this.a.deleteBuffer(c.P);c=this.qd.get(b);c!=t&&this.a.isBuffer(c.P)&&this.a.deleteBuffer(c.P);c=this.Ec.get(b);c!=t&&this.a.isBuffer(c.P)&&this.a.deleteBuffer(c.P);
+c=this.Pc.get(b);c!=t&&this.a.isBuffer(c.P)&&this.a.deleteBuffer(c.P);this.pc.remove(b);this.qd.remove(b);this.Ec.remove(b);this.oc.remove(b);this.Pc.remove(b);this.ab.remove(a);return q};w.Ta=function(){this.$e=t;delete this.$e;this.a.clear(this.a.COLOR_BUFFER_BIT|this.a.DEPTH_BUFFER_BIT);hh.u.Ta.call(this)};hh.prototype.__defineGetter__("bgColor",v("bd"));hh.prototype.__defineSetter__("bgColor",ca("bd"));
+hh.prototype.Vj=function(a,b,c,e,d){c!=t||(c=4);e!=t||(e=2);if(d==t){d=this.Nf(a,b);if(-1==d)return t;d=this.get(d);if(!d)return t}var f=qg(this.N,2*(a/this.K)-1,2*((this.A-b)/this.A)-1,0);a=qg(this.N,2*(a/this.K)-1,2*((this.A-b)/this.A)-1,1);f[0]+=this.z[0];f[1]+=this.z[1];f[2]+=this.z[2];a[0]+=this.z[0];a[1]+=this.z[1];a[2]+=this.z[2];b=[d.h.nb,d.h.ob,d.h.pb];var g=[d.h.kb,d.h.ob,d.h.pb],h=[d.h.kb,d.h.lb,d.h.pb],l=[d.h.nb,d.h.lb,d.h.pb],j=[d.h.nb,d.h.lb,d.h.mb],k=[d.h.nb,d.h.ob,d.h.mb],n=[d.h.kb,
+d.h.lb,d.h.mb],s=[d.h.kb,d.h.ob,d.h.mb];b=[D.g.ba(d.ja.Q,b[0],b[1],b[2]),D.g.ba(d.ja.Q,g[0],g[1],g[2]),D.g.ba(d.ja.Q,h[0],h[1],h[2]),D.g.ba(d.ja.Q,l[0],l[1],l[2]),D.g.ba(d.ja.Q,j[0],j[1],j[2]),D.g.ba(d.ja.Q,k[0],k[1],k[2]),D.g.ba(d.ja.Q,n[0],n[1],n[2]),D.g.ba(d.ja.Q,s[0],s[1],s[2])];var g=[Infinity,-Infinity,Infinity,-Infinity,Infinity,-Infinity],r;for(r in b)r=b[r],g=[Math.min(g[0],r.x),Math.max(g[1],r.x),Math.min(g[2],r.y),Math.max(g[3],r.y),Math.min(g[4],r.d),Math.max(g[5],r.d)];r=g;b=[];g=[];
+for(h=0;6>h;h++){var l=Math.floor(h/2),j=(l+1)%3,k=(l+2)%3,s=(2+2*l)%6,y=(4+2*l)%6,z=(r[h]-f[l])*(1/a[l]);Infinity!=z&&-Infinity!=z&&(n=f[j]+a[j]*z,z=f[k]+a[k]*z,n>=r[s]&&n<=r[s+1]&&z>=r[y]&&z<=r[y+1]?(s=[],s[l]=r[h],s[j]=n,s[k]=z,b.push(s)):(s=[],s[l]=r[h],s[j]=n,s[k]=z,g.push(s)))}a=[b,g];a=a[0];if(0==a.length)return t;g=Array(2);for(r=0;2>r;r++)b=a[r],g[r]=Math.sqrt((b[0]-f[0])*(b[0]-f[0])+(b[1]-f[1])*(b[1]-f[1])+(b[2]-f[2])*(b[2]-f[2]));f=b=r=t;g[0]<g[1]?(r=a[0],b=a[1]):(r=a[1],b=a[0]);f=Math.sqrt((r[0]-
+b[0])*(r[0]-b[0])+(r[1]-b[1])*(r[1]-b[1])+(r[2]-b[2])*(r[2]-b[2]));f/=c;a=r;r=[b[0]-r[0],b[1]-r[1],b[2]-r[2]];b=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);g=[r[0]/b,r[1]/b,r[2]/b];h=d.h.da;l=h.length;for(r=0;r<f;r+=c){a=[a[0]+c*g[0],a[1]+c*g[1],a[2]+c*g[2]];for(b=0;b<l;b+=3)if(j=h[b],k=h[b+1],n=h[b+2],s=new D.m(j,k,n),s=D.g.ba(d.ja.Q,j,k,n),Math.sqrt((a[0]-s.x)*(a[0]-s.x)+(a[1]-s.y)*(a[1]-s.y)+(a[2]-s.d)*(a[2]-s.d))<=e)return[s.x,s.y,s.d]}return t};A("X.renderer3D",hh);
+A("X.renderer3D.prototype.init",hh.prototype.Ca);A("X.renderer3D.prototype.add",hh.prototype.add);A("X.renderer3D.prototype.remove",hh.prototype.remove);A("X.renderer3D.prototype.onShowtime",hh.prototype.lh);A("X.renderer3D.prototype.onRender",hh.prototype.jh);A("X.renderer3D.prototype.get",hh.prototype.get);A("X.renderer3D.prototype.render",hh.prototype.cc);A("X.renderer3D.prototype.destroy",hh.prototype.Ta);A("X.renderer3D.prototype.remove",hh.prototype.remove);
+A("X.renderer3D.prototype.resetBoundingBox",hh.prototype.Zj);A("X.renderer3D.prototype.resetViewAndRender",hh.prototype.Nd);A("X.renderer3D.prototype.pick",hh.prototype.Nf);A("X.renderer3D.prototype.pick3d",hh.prototype.Vj);A("X.renderer3D.prototype.afterRender",hh.prototype.yg);function ih(){Y.call(this);this.f="mesh";Fa(this,new xc)}C(ih,Y);A("X.mesh",ih);function jh(){Y.call(this);this.f="fibers";Fa(this,new xc)}C(jh,Y);A("X.fibers",jh);function kh(){Gg.call(this);this.f="renderer2D";this.Qa=t;this.Fa=-1;this.Sb=[];this.kg=this.fd=this.fg=this.Vd=t;this.Rc=this.Uc=this.Qc=this.Tc=0;this.ea=this.fa=this.W=this.U=this.Ke=-1;this.lg=new Float32Array([-255,-255,-255,-255]);this.sg=q;this.xb=1}C(kh,Gg);w=kh.prototype;w.remove=function(a){kh.u.remove.call(this,a);this.ab.remove(a);return q};w.Gj=aa();w.Qj=aa();
+w.Kf=function(a){kh.u.Kf.call(this,a);var b=this.Ha[0];if(b){var c="",c=0==this.Fa?"indexX":1==this.Fa?"indexY":"indexZ";b[c]=a.V?b[c]+1:b[c]-1;eval("this.onScroll();")}};w.Rj=function(a){var b=this.Ha[0];if(b){var c=b.ea-b.fa,e=c/2,d=parseInt(c+c/15*-a.df,10);a=parseInt(e+e/15*a.Re,10);c==d&&d++;e==a&&a++;b.fa-=parseInt(e-a,10);b.fa-=parseInt(c-d,10);b.fa=Math.max(b.fa,b.ra);b.ea-=parseInt(e-a,10);b.ea+=parseInt(c-d,10);b.ea=Math.min(b.ea,b.ia);eval("this.onWindowLevel();")}};
+kh.prototype.__defineGetter__("orientation",v("Qa"));kh.prototype.__defineSetter__("orientation",function(a){a=a.toUpperCase();"AXIAL"==a?(a="Z",this.Fa=2):"SAGITTAL"==a?(a="X",this.Fa=0):"CORONAL"==a&&(a="Y",this.Fa=1);"X"!=a&&("Y"!=a&&"Z"!=a)&&m(Error("Invalid orientation."));this.Qa=a});kh.prototype.__defineGetter__("radiological",v("sg"));kh.prototype.__defineGetter__("normalizedScale",v("xb"));kh.prototype.__defineGetter__("canvasWidth",function(){return this.na.width});
+kh.prototype.__defineGetter__("canvasHeight",function(){return this.na.height});kh.prototype.__defineGetter__("sliceWidth",v("Tc"));kh.prototype.__defineGetter__("sliceHeight",v("Qc"));kh.prototype.__defineSetter__("radiological",ca("sg"));w=kh.prototype;
+w.Ca=function(){this.Qa||m(Error("No 2D orientation set."));kh.u.Ca.call(this,"2d");this.a.fillStyle="rgba(50,50,50,0)";this.a.fillRect(0,0,this.na.width,this.na.height);this.Vd=de("canvas");this.fd=de("canvas");this.fd.style.Cl="pixelated";L(this.N,xd,this.Rj.bind(this))};w.ve=function(){kh.u.ve.call(this);oh(this)};w.Nd=function(){kh.u.Nd.call(this);oh(this);var a=this.Ha[0];a&&(a.ea=a.ia,a.fa=a.ra)};w.update=function(a){this.ub(a);this.Ke=-1};
+w.ub=function(a){kh.u.ub.call(this,a);var b=u;this.get(a.qa)&&(b=q);if(a instanceof P){var c=a.r,e=a.e,d=a.xa;if(e!=t&&e.r!=t&&e.r.j)this.ub(e);else if(d!=t&&d.r!=t&&d.r.j)this.aa.load(d,a);else{if(c!=t&&ja(c))if(a.yc!=t){if(a.yc.yf!=c.length)return}else{b=0;e=c.length;for(b=0;b<e;b++)this.aa.load(c[b],a);return}else if(c!=t&&c.j){this.aa.load(a,a);return}this.Fa="X"==this.Qa?0:"Y"==this.Qa?1:2;this.cb=a.c[this.Fa].c;d=t;d=0==this.Fa?a.indexX:1==this.Fa?a.indexY:a.indexZ;c=a.c[this.Fa].c[d].jg;e=
+a.c[this.Fa].c[d].ig;this.Uc=a.c[this.Fa].c[d].Vc;this.Rc=a.c[this.Fa].c[d].Gc;this.Tc=c;this.Qc=e;d=this.Vd;d.width=c;d.height=e;var f=this.fd;f.width=c;f.height=e;this.fg=d.getContext("2d");this.kg=f.getContext("2d");b||(this.ab.add(a),oh(this))}}};function oh(a){var b=Math.min(a.K/(a.Tc*a.Uc),a.A/(a.Qc*a.Rc));a.N.o[14]=b}w.Hj=aa();
+w.Ih=function(a,b){var c=this.Ha[0],e=this.N.o,d=t,f=this.Tc,g=this.Qc,h=t,l=t;if("Y"==this.Qa)d=this.cb[parseInt(c.indexY,10)],h=d.Vc,l=d.Gc,this.Sb[0]="rgba(255,0,0,.3)",this.Sb[1]="rgba(0,0,255,.3)";else if("Z"==this.Qa)d=this.cb[parseInt(c.indexZ,10)],h=d.Vc,l=d.Gc,this.Sb[0]="rgba(255,0,0,.3)",this.Sb[1]="rgba(0,255,0,.3)";else{d=this.cb[parseInt(c.indexX,10)];h=d.Gc;l=d.Vc;this.Sb[0]="rgba(0,255,0,.3)";this.Sb[1]="rgba(0,0,255,.3)";var j=f,f=g,g=j}var k=1*e[12],e=-1*e[13],j=[this.K/2,this.A/
+2],h=f*h*this.xb,l=g*l*this.xb,n=j[0]-h/2,j=j[1]-l/2,n=n+k*this.xb,j=j+e*this.xb;return a>n&&a<n+h&&b>j&&b<j+l?(k=(a-n)/h*f,e=(b-j)/l*g,l=d.ei[4],"X"==this.Qa?(j=f-k,k=e,e=j):"Y"==this.Qa?k=f-k:"Z"==this.Qa&&(k=f-k,e=g-e),k=d.di+k*d.Vc,e=d.Yh+e*d.Gc,k=Qc(k,e,l,1),f=Rc(),cd(d.Rh,k,f),f=[Math.floor(f[0]),Math.floor(f[1]),Math.floor(f[2])],g=Rc(),cd(d.Sh,k,g),d=Math.round((c.b[0].i[0]*g[0]+c.b[0].i[1]*g[1]+c.b[0].i[2]*g[2]+c.b[0].Ue)/c.b[0].Sc),d>=c.b[0].p?d=c.b[0].p-1:0>d&&(d=0),k=Math.round((c.b[1].i[0]*
+g[0]+c.b[1].i[1]*g[1]+c.b[1].i[2]*g[2]+c.b[1].Ue)/c.b[1].Sc),k>=c.b[1].p?k=c.b[1].p-1:0>k&&(k=0),e=Math.round((c.b[2].i[0]*g[0]+c.b[2].i[1]*g[1]+c.b[2].i[2]*g[2]+c.b[2].Ue)/c.b[2].Sc),e>=c.b[2].p?e=c.b[2].p-1:0>e&&(e=0),[[d,k,e],[f[0],f[1],f[2]],[g[0],g[1],g[2]]]):t};
+w.dc=function(a,b){kh.u.dc.call(this,a,b);if(0!=this.ab.I.length){var c=this.Ha[0],e=t,e=0==this.Fa?c.indexX:1==this.Fa?c.indexY:c.indexZ,d=this.cb[parseInt(e,10)].jg,f=this.cb[parseInt(e,10)].ig;this.Uc=this.cb[parseInt(e,10)].Vc;this.Rc=this.cb[parseInt(e,10)].Gc;this.Tc=d;this.Qc=f;var g=this.K,h=this.A,l=this.N.o;this.a.save();this.a.clearRect(-g,-h,2*g,2*h);this.a.restore();this.xb=Math.max(l[14],1E-4);this.a.setTransform(this.xb,0,0,this.xb,0,0);var j=1*l[12],l=-1*l[13],k=t;c.e&&(k=c.e.af);
+var n=this.cb[parseInt(e,10)],s=n.G.Wb,n=n.e,r=t;n&&(r=n.Wb);var y=this.Tc,z=this.Qc,F=this.fg,G=this.kg,H=F.getImageData(0,0,y,z),B=G.getImageData(0,0,y,z),E=H.data,I=B.data,N=E.length,Q=c.U,O=c.W,S=c.fa,da=c.ea;if(this.Ke!=e||this.U!=Q||this.W!=O||this.fa!=S||this.ea!=da||k&&!mg(k,this.lg,0)){var J=this.Vd;J.width=d;J.height=f;J=this.fd;J.width=d;J.height=f;d=0;do{var J=[0,0,0,0],f=[0,0,0,0],ba=s[d]/255*(c.ia-c.ra)+c.ra,la=da-S,U=la/2+S,V=0,V=ba<U-la/2?0:ba>U+la/2?255:255*(ba-(U-la/2))/la;ba>=Q&&
+ba<=O&&(J=new R(c.Rb[0],c.Rb[1],c.Rb[2]),J=(new R(c.Pb[0],c.Pb[1],c.Pb[2])).scale(V).add(J.scale(255-V)),J=[Math.floor(J.x),Math.floor(J.y),Math.floor(J.d),255],n&&(-255==k[3]?f=[r[d],r[d+1],r[d+2],r[d+3]]:mg(k,r,d)&&(f=[r[d],r[d+1],r[d+2],r[d+3]])));"X"==this.Qa?(E[d]=J[0],E[d+1]=J[1],E[d+2]=J[2],E[d+3]=J[3],I[d]=f[0],I[d+1]=f[1],I[d+2]=f[2],I[d+3]=f[3]):"Y"==this.Qa?(V=Math.floor(d/(4*y)),V=4*V*y+(4*(y-1)-(d-4*V*y)),E[V]=J[0],E[V+1]=J[1],E[V+2]=J[2],E[V+3]=J[3],I[V]=f[0],I[V+1]=f[1],I[V+2]=f[2],
+I[V+3]=f[3]):(V=N-1-d,E[V-3]=J[0],E[V-2]=J[1],E[V-1]=J[2],E[V]=J[3],I[V-3]=f[0],I[V-2]=f[1],I[V-1]=f[2],I[V]=f[3]);d+=4}while(d<N);F.putImageData(H,0,0);G.putImageData(B,0,0);this.Ke=e;this.U=Q;this.W=O;this.fa=S;this.ea=da;n&&(this.lg=k)}this.a.globalAlpha=1;this.a.translate(g/2/this.xb,h/2/this.xb);"X"==this.Qa&&(this.a.rotate(0.5*Math.PI),e=j,j=l,l=-e);j=-y*this.Uc/2+j;l=-z*this.Rc/2+l;this.a.drawImage(this.Vd,j,l,y*this.Uc,z*this.Rc);n&&c.e.O&&(this.a.globalAlpha=1,this.a.drawImage(this.fd,j,
+l,y*this.Uc,z*this.Rc));if(this.R.SLICENAVIGATORS)if(this.na.style.cursor="none",this.T.Yd&&this.T.wg&&!this.T.wb){if(j=this.T.ua,j=this.Ih(j[0],j[1]))c.Cb=j[0][0],c.Db=j[0][1],c.Eb=j[0][2],c.q(u),this.onSliceNavigation(),this.a.setTransform(1,0,0,1,0,0),this.a.beginPath(),this.a.moveTo(this.T.ua[0],0),this.a.lineTo(this.T.ua[0],this.T.ua[1]-1),this.a.moveTo(this.T.ua[0],this.T.ua[1]+1),this.a.lineTo(this.T.ua[0],this.A),this.a.strokeStyle=this.Sb[0],this.a.stroke(),this.a.closePath(),this.a.beginPath(),
+this.a.moveTo(0,this.T.ua[1]),this.a.lineTo(this.T.ua[0]-1,this.T.ua[1]),this.a.moveTo(this.T.ua[0]+1,this.T.ua[1]),this.a.lineTo(this.K,this.T.ua[1]),this.a.strokeStyle=this.Sb[1],this.a.stroke(),this.a.closePath(),this.a.font="10pt Arial",this.a.textAlign="left",this.a.textBaseline="top",this.a.fillStyle="white",this.a.fillText("RAS: "+j[2][0].toFixed(2)+", "+j[2][1].toFixed(2)+", "+j[2][2].toFixed(2),0,0),y=n=l="undefined","undefined"!=typeof c.$[j[1][2].toFixed(0)]&&"undefined"!=typeof c.$[j[1][2].toFixed(0)][j[1][1].toFixed(0)]&&
+(l=c.$[j[1][2].toFixed(0)][j[1][1].toFixed(0)][j[1][0].toFixed(0)],c.L&&(n=c.e.$[j[1][2].toFixed(0)][j[1][1].toFixed(0)][j[1][0].toFixed(0)],c.e.cd&&(y=c.e.cd.get(n),"undefined"!=typeof y&&(y=y[0])))),this.a.fillText("Background:  "+l+" ("+j[1][0].toFixed(0)+", "+j[1][1].toFixed(0)+", "+j[1][2].toFixed(0)+")",0,15),c.L&&this.a.fillText("Labelmap:  "+y+" ("+n+")",0,30)}else this.na.style.cursor="default"}};A("X.renderer2D",kh);A("X.renderer2D.prototype.init",kh.prototype.Ca);
+A("X.renderer2D.prototype.add",kh.prototype.add);A("X.renderer2D.prototype.onShowtime",kh.prototype.lh);A("X.renderer2D.prototype.onRender",kh.prototype.jh);A("X.renderer2D.prototype.onScroll",kh.prototype.Gj);A("X.renderer2D.prototype.onWindowLevel",kh.prototype.Qj);A("X.renderer2D.prototype.get",kh.prototype.get);A("X.renderer2D.prototype.resetViewAndRender",kh.prototype.Nd);A("X.renderer2D.prototype.xy2ijk",kh.prototype.Ih);A("X.renderer2D.prototype.render",kh.prototype.cc);
+A("X.renderer2D.prototype.destroy",kh.prototype.Ta);A("X.renderer2D.prototype.onSliceNavigation",kh.prototype.Hj);A("X.renderer2D.prototype.afterRender",kh.prototype.yg);
diff --git a/wt/data/reosurcesXTK/xtk_xdat.gui.js b/wt/data/reosurcesXTK/xtk_xdat.gui.js
new file mode 100644 (file)
index 0000000..1a49ac2
--- /dev/null
@@ -0,0 +1,3665 @@
+/**
+ * dat-gui JavaScript Controller Library
+ * http://code.google.com/p/dat-gui
+ *
+ * Copyright 2011 Data Arts Team, Google Creative Lab
+ *
+ * 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
+ */
+
+/** @namespace */
+var dat = dat || {};
+
+/** @namespace */
+dat.gui = dat.gui || {};
+
+/** @namespace */
+dat.utils = dat.utils || {};
+
+/** @namespace */
+dat.controllers = dat.controllers || {};
+
+/** @namespace */
+dat.dom = dat.dom || {};
+
+/** @namespace */
+dat.color = dat.color || {};
+
+dat.utils.css = (function () {
+  return {
+    load: function (url, doc) {
+      doc = doc || document;
+      var link = doc.createElement('link');
+      link.type = 'text/css';
+      link.rel = 'stylesheet';
+      link.href = url;
+      doc.getElementsByTagName('head')[0].appendChild(link);
+    },
+    inject: function(css, doc) {
+      doc = doc || document;
+      var injected = document.createElement('style');
+      injected.type = 'text/css';
+      injected.innerHTML = css;
+      doc.getElementsByTagName('head')[0].appendChild(injected);
+    }
+  }
+})();
+
+
+dat.utils.common = (function () {
+
+  var ARR_EACH = Array.prototype.forEach;
+  var ARR_SLICE = Array.prototype.slice;
+
+  /**
+   * Band-aid methods for things that should be a lot easier in JavaScript.
+   * Implementation and structure inspired by underscore.js
+   * http://documentcloud.github.com/underscore/
+   */
+
+  return {
+
+    BREAK: {},
+
+    extend: function(target) {
+
+      this.each(ARR_SLICE.call(arguments, 1), function(obj) {
+
+        for (var key in obj)
+          if (!this.isUndefined(obj[key]))
+            target[key] = obj[key];
+
+      }, this);
+
+      return target;
+
+    },
+
+    defaults: function(target) {
+
+      this.each(ARR_SLICE.call(arguments, 1), function(obj) {
+
+        for (var key in obj)
+          if (this.isUndefined(target[key]))
+            target[key] = obj[key];
+
+      }, this);
+
+      return target;
+
+    },
+
+    compose: function() {
+      var toCall = ARR_SLICE.call(arguments);
+            return function() {
+              var args = ARR_SLICE.call(arguments);
+              for (var i = toCall.length -1; i >= 0; i--) {
+                args = [toCall[i].apply(this, args)];
+              }
+              return args[0];
+            }
+    },
+
+    each: function(obj, itr, scope) {
+
+
+      if (ARR_EACH && obj.forEach === ARR_EACH) {
+
+        obj.forEach(itr, scope);
+
+      } else if (obj.length === obj.length + 0) { // Is number but not NaN
+
+        for (var key = 0, l = obj.length; key < l; key++)
+          if (key in obj && itr.call(scope, obj[key], key) === this.BREAK)
+            return;
+
+      } else {
+
+        for (var key in obj)
+          if (itr.call(scope, obj[key], key) === this.BREAK)
+            return;
+
+      }
+
+    },
+
+    defer: function(fnc) {
+      setTimeout(fnc, 0);
+    },
+
+    toArray: function(obj) {
+      if (obj.toArray) return obj.toArray();
+      return ARR_SLICE.call(obj);
+    },
+
+    isUndefined: function(obj) {
+      return obj === undefined;
+    },
+
+    isNull: function(obj) {
+      return obj === null;
+    },
+
+    isNaN: function(obj) {
+      return obj !== obj;
+    },
+
+    isArray: Array.isArray || function(obj) {
+      return obj.constructor === Array;
+    },
+
+    isObject: function(obj) {
+      return obj === Object(obj);
+    },
+
+    isNumber: function(obj) {
+      return obj === obj+0;
+    },
+
+    isString: function(obj) {
+      return obj === obj+'';
+    },
+
+    isBoolean: function(obj) {
+      return obj === false || obj === true;
+    },
+
+    isFunction: function(obj) {
+      return Object.prototype.toString.call(obj) === '[object Function]';
+    }
+
+  };
+
+})();
+
+
+dat.controllers.Controller = (function (common) {
+
+  /**
+   * @class An "abstract" class that represents a given property of an object.
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   *
+   * @member dat.controllers
+   */
+  var Controller = function(object, property) {
+
+    this.initialValue = object[property];
+
+    /**
+     * Those who extend this class will put their DOM elements in here.
+     * @type {DOMElement}
+     */
+    this.domElement = document.createElement('div');
+
+    /**
+     * The object to manipulate
+     * @type {Object}
+     */
+    this.object = object;
+
+    /**
+     * The name of the property to manipulate
+     * @type {String}
+     */
+    this.property = property;
+
+    /**
+     * The function to be called on change.
+     * @type {Function}
+     * @ignore
+     */
+    this.__onChange = undefined;
+
+    /**
+     * The function to be called on finishing change.
+     * @type {Function}
+     * @ignore
+     */
+    this.__onFinishChange = undefined;
+
+  };
+
+  common.extend(
+
+      Controller.prototype,
+
+      /** @lends dat.controllers.Controller.prototype */
+      {
+
+        /**
+         * Specify that a function fire every time someone changes the value with
+         * this Controller.
+         *
+         * @param {Function} fnc This function will be called whenever the value
+         * is modified via this Controller.
+         * @returns {dat.controllers.Controller} this
+         */
+        onChange: function(fnc) {
+          this.__onChange = fnc;
+          return this;
+        },
+
+        /**
+         * Specify that a function fire every time someone "finishes" changing
+         * the value wih this Controller. Useful for values that change
+         * incrementally like numbers or strings.
+         *
+         * @param {Function} fnc This function will be called whenever
+         * someone "finishes" changing the value via this Controller.
+         * @returns {dat.controllers.Controller} this
+         */
+        onFinishChange: function(fnc) {
+          this.__onFinishChange = fnc;
+          return this;
+        },
+
+        /**
+         * Change the value of <code>object[property]</code>
+         *
+         * @param {Object} newValue The new value of <code>object[property]</code>
+         */
+        setValue: function(newValue) {
+          this.object[this.property] = newValue;
+          if (this.__onChange) {
+            this.__onChange.call(this, newValue);
+          }
+          this.updateDisplay();
+          return this;
+        },
+
+        /**
+         * Gets the value of <code>object[property]</code>
+         *
+         * @returns {Object} The current value of <code>object[property]</code>
+         */
+        getValue: function() {
+          return this.object[this.property];
+        },
+
+        /**
+         * Refreshes the visual display of a Controller in order to keep sync
+         * with the object's current value.
+         * @returns {dat.controllers.Controller} this
+         */
+        updateDisplay: function() {
+          return this;
+        },
+
+        /**
+         * @returns {Boolean} true if the value has deviated from initialValue
+         */
+        isModified: function() {
+          return this.initialValue !== this.getValue()
+        }
+
+      }
+
+  );
+
+  return Controller;
+
+
+})(dat.utils.common);
+
+
+dat.dom.dom = (function (common) {
+
+  var EVENT_MAP = {
+    'HTMLEvents': ['change'],
+    'MouseEvents': ['click','mousemove','mousedown','mouseup', 'mouseover'],
+    'KeyboardEvents': ['keydown']
+  };
+
+  var EVENT_MAP_INV = {};
+  common.each(EVENT_MAP, function(v, k) {
+    common.each(v, function(e) {
+      EVENT_MAP_INV[e] = k;
+    });
+  });
+
+  var CSS_VALUE_PIXELS = /(\d+(\.\d+)?)px/;
+
+  function cssValueToPixels(val) {
+
+    if (val === '0' || common.isUndefined(val)) return 0;
+
+    var match = val.match(CSS_VALUE_PIXELS);
+
+    if (!common.isNull(match)) {
+      return parseFloat(match[1]);
+    }
+
+    // TODO ...ems? %?
+
+    return 0;
+
+  }
+
+  /**
+   * @namespace
+   * @member dat.dom
+   */
+  var dom = {
+
+    /**
+     *
+     * @param elem
+     * @param selectable
+     */
+    makeSelectable: function(elem, selectable) {
+
+      if (elem === undefined || elem.style === undefined) return;
+
+      elem.onselectstart = selectable ? function() {
+        return false;
+      } : function() {
+      };
+
+      elem.style.MozUserSelect = selectable ? 'auto' : 'none';
+      elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none';
+      elem.unselectable = selectable ? 'on' : 'off';
+
+    },
+
+    /**
+     *
+     * @param elem
+     * @param horizontal
+     * @param vertical
+     */
+    makeFullscreen: function(elem, horizontal, vertical) {
+
+      if (common.isUndefined(horizontal)) horizontal = true;
+      if (common.isUndefined(vertical)) vertical = true;
+
+      elem.style.position = 'absolute';
+
+      if (horizontal) {
+        elem.style.left = 0;
+        elem.style.right = 0;
+      }
+      if (vertical) {
+        elem.style.top = 0;
+        elem.style.bottom = 0;
+      }
+
+    },
+
+    /**
+     *
+     * @param elem
+     * @param eventType
+     * @param params
+     */
+    fakeEvent: function(elem, eventType, params, aux) {
+      params = params || {};
+      var className = EVENT_MAP_INV[eventType];
+      if (!className) {
+        throw new Error('Event type ' + eventType + ' not supported.');
+      }
+      var evt = document.createEvent(className);
+      switch (className) {
+        case 'MouseEvents':
+          var clientX = params.x || params.clientX || 0;
+          var clientY = params.y || params.clientY || 0;
+          evt.initMouseEvent(eventType, params.bubbles || false,
+              params.cancelable || true, window, params.clickCount || 1,
+              0, //screen X
+              0, //screen Y
+              clientX, //client X
+              clientY, //client Y
+              false, false, false, false, 0, null);
+          break;
+        case 'KeyboardEvents':
+          var init = evt.initKeyboardEvent || evt.initKeyEvent; // webkit || moz
+          common.defaults(params, {
+            cancelable: true,
+            ctrlKey: false,
+            altKey: false,
+            shiftKey: false,
+            metaKey: false,
+            keyCode: undefined,
+            charCode: undefined
+          });
+          init(eventType, params.bubbles || false,
+              params.cancelable, window,
+              params.ctrlKey, params.altKey,
+              params.shiftKey, params.metaKey,
+              params.keyCode, params.charCode);
+          break;
+        default:
+          evt.initEvent(eventType, params.bubbles || false,
+              params.cancelable || true);
+          break;
+      }
+      common.defaults(evt, aux);
+      elem.dispatchEvent(evt);
+    },
+
+    /**
+     *
+     * @param elem
+     * @param event
+     * @param func
+     * @param bool
+     */
+    bind: function(elem, event, func, bool) {
+      bool = bool || false;
+      if (elem.addEventListener)
+        elem.addEventListener(event, func, bool);
+      else if (elem.attachEvent)
+        elem.attachEvent('on' + event, func);
+      return dom;
+    },
+
+    /**
+     *
+     * @param elem
+     * @param event
+     * @param func
+     * @param bool
+     */
+    unbind: function(elem, event, func, bool) {
+      bool = bool || false;
+      if (elem.removeEventListener)
+        elem.removeEventListener(event, func, bool);
+      else if (elem.detachEvent)
+        elem.detachEvent('on' + event, func);
+      return dom;
+    },
+
+    /**
+     *
+     * @param elem
+     * @param className
+     */
+    addClass: function(elem, className) {
+      if (elem.className === undefined) {
+        elem.className = className;
+      } else if (elem.className !== className) {
+        var classes = elem.className.split(/ +/);
+        if (classes.indexOf(className) == -1) {
+          classes.push(className);
+          elem.className = classes.join(' ').replace(/^\s+/, '').replace(/\s+$/, '');
+        }
+      }
+      return dom;
+    },
+
+    /**
+     *
+     * @param elem
+     * @param className
+     */
+    removeClass: function(elem, className) {
+      if (className) {
+        if (elem.className === undefined) {
+          // elem.className = className;
+        } else if (elem.className === className) {
+          elem.removeAttribute('class');
+        } else {
+          var classes = elem.className.split(/ +/);
+          var index = classes.indexOf(className);
+          if (index != -1) {
+            classes.splice(index, 1);
+            elem.className = classes.join(' ');
+          }
+        }
+      } else {
+        elem.className = undefined;
+      }
+      return dom;
+    },
+
+    hasClass: function(elem, className) {
+      return new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)').test(elem.className) || false;
+    },
+
+    /**
+     *
+     * @param elem
+     */
+    getWidth: function(elem) {
+
+      var style = getComputedStyle(elem);
+
+      return cssValueToPixels(style['border-left-width']) +
+          cssValueToPixels(style['border-right-width']) +
+          cssValueToPixels(style['padding-left']) +
+          cssValueToPixels(style['padding-right']) +
+          cssValueToPixels(style['width']);
+    },
+
+    /**
+     *
+     * @param elem
+     */
+    getHeight: function(elem) {
+
+      var style = getComputedStyle(elem);
+
+      return cssValueToPixels(style['border-top-width']) +
+          cssValueToPixels(style['border-bottom-width']) +
+          cssValueToPixels(style['padding-top']) +
+          cssValueToPixels(style['padding-bottom']) +
+          cssValueToPixels(style['height']);
+    },
+
+    /**
+     *
+     * @param elem
+     */
+    getOffset: function(elem) {
+      var offset = {left: 0, top:0};
+      if (elem.offsetParent) {
+        do {
+          offset.left += elem.offsetLeft;
+          offset.top += elem.offsetTop;
+        } while (elem = elem.offsetParent);
+      }
+      return offset;
+    },
+
+    // http://stackoverflow.com/posts/2684561/revisions
+    /**
+     *
+     * @param elem
+     */
+    isActive: function(elem) {
+      return elem === document.activeElement && ( elem.type || elem.href );
+    }
+
+  };
+
+  return dom;
+
+})(dat.utils.common);
+
+
+dat.controllers.OptionController = (function (Controller, dom, common) {
+
+  /**
+   * @class Provides a select input to alter the property of an object, using a
+   * list of accepted values.
+   *
+   * @extends dat.controllers.Controller
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   * @param {Object|string[]} options A map of labels to acceptable values, or
+   * a list of acceptable string values.
+   *
+   * @member dat.controllers
+   */
+  var OptionController = function(object, property, options) {
+
+    OptionController.superclass.call(this, object, property);
+
+    var _this = this;
+
+    /**
+     * The drop down menu
+     * @ignore
+     */
+    this.__select = document.createElement('select');
+
+    if (common.isArray(options)) {
+      var map = {};
+      common.each(options, function(element) {
+        map[element] = element;
+      });
+      options = map;
+    }
+
+    common.each(options, function(value, key) {
+
+      var opt = document.createElement('option');
+      opt.innerHTML = key;
+      opt.setAttribute('value', value);
+      _this.__select.appendChild(opt);
+
+    });
+
+    // Acknowledge original value
+    this.updateDisplay();
+
+    dom.bind(this.__select, 'change', function() {
+      var desiredValue = this.options[this.selectedIndex].value;
+      _this.setValue(desiredValue);
+    });
+
+    this.domElement.appendChild(this.__select);
+
+  };
+
+  OptionController.superclass = Controller;
+
+  common.extend(
+
+      OptionController.prototype,
+      Controller.prototype,
+
+      {
+
+        setValue: function(v) {
+          var toReturn = OptionController.superclass.prototype.setValue.call(this, v);
+          if (this.__onFinishChange) {
+            this.__onFinishChange.call(this, this.getValue());
+          }
+          return toReturn;
+        },
+
+        updateDisplay: function() {
+          this.__select.value = this.getValue();
+          return OptionController.superclass.prototype.updateDisplay.call(this);
+        }
+
+      }
+
+  );
+
+  return OptionController;
+
+})(dat.controllers.Controller,
+dat.dom.dom,
+dat.utils.common);
+
+
+dat.controllers.NumberController = (function (Controller, common) {
+
+  /**
+   * @class Represents a given property of an object that is a number.
+   *
+   * @extends dat.controllers.Controller
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   * @param {Object} [params] Optional parameters
+   * @param {Number} [params.min] Minimum allowed value
+   * @param {Number} [params.max] Maximum allowed value
+   * @param {Number} [params.step] Increment by which to change value
+   *
+   * @member dat.controllers
+   */
+  var NumberController = function(object, property, params) {
+
+    NumberController.superclass.call(this, object, property);
+
+    params = params || {};
+
+    this.__min = params.min;
+    this.__max = params.max;
+    this.__step = params.step;
+
+    if (common.isUndefined(this.__step)) {
+
+      if (this.initialValue == 0) {
+        this.__impliedStep = 1; // What are we, psychics?
+      } else {
+        // Hey Doug, check this out.
+        this.__impliedStep = Math.pow(10, Math.floor(Math.log(this.initialValue)/Math.LN10))/10;
+      }
+
+    } else {
+
+       this.__impliedStep = this.__step;
+
+    }
+
+    this.__precision = numDecimals(this.__impliedStep);
+
+
+  };
+
+  NumberController.superclass = Controller;
+
+  common.extend(
+
+      NumberController.prototype,
+      Controller.prototype,
+
+      /** @lends dat.controllers.NumberController.prototype */
+      {
+
+        setValue: function(v) {
+
+          if (this.__min !== undefined && v < this.__min) {
+            v = this.__min;
+          } else if (this.__max !== undefined && v > this.__max) {
+            v = this.__max;
+          }
+
+          if (this.__step !== undefined && v % this.__step != 0) {
+            v = Math.round(v / this.__step) * this.__step;
+          }
+
+          return NumberController.superclass.prototype.setValue.call(this, v);
+
+        },
+
+        /**
+         * Specify a minimum value for <code>object[property]</code>.
+         *
+         * @param {Number} minValue The minimum value for
+         * <code>object[property]</code>
+         * @returns {dat.controllers.NumberController} this
+         */
+        min: function(v) {
+          this.__min = v;
+          return this;
+        },
+
+        /**
+         * Specify a maximum value for <code>object[property]</code>.
+         *
+         * @param {Number} maxValue The maximum value for
+         * <code>object[property]</code>
+         * @returns {dat.controllers.NumberController} this
+         */
+        max: function(v) {
+          this.__max = v;
+          return this;
+        },
+
+        /**
+         * Specify a step value that dat.controllers.NumberController
+         * increments by.
+         *
+         * @param {Number} stepValue The step value for
+         * dat.controllers.NumberController
+         * @default if minimum and maximum specified increment is 1% of the
+         * difference otherwise stepValue is 1
+         * @returns {dat.controllers.NumberController} this
+         */
+        step: function(v) {
+          this.__step = v;
+          return this;
+        }
+
+      }
+
+  );
+
+  function numDecimals(x) {
+    x = x.toString();
+    if (x.indexOf('.') > -1) {
+      return x.length - x.indexOf('.') - 1;
+    } else {
+      return 0;
+    }
+  }
+
+  return NumberController;
+
+})(dat.controllers.Controller,
+dat.utils.common);
+
+
+dat.controllers.NumberControllerBox = (function (NumberController, dom, common) {
+
+  /**
+   * @class Represents a given property of an object that is a number and
+   * provides an input element with which to manipulate it.
+   *
+   * @extends dat.controllers.Controller
+   * @extends dat.controllers.NumberController
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   * @param {Object} [params] Optional parameters
+   * @param {Number} [params.min] Minimum allowed value
+   * @param {Number} [params.max] Maximum allowed value
+   * @param {Number} [params.step] Increment by which to change value
+   *
+   * @member dat.controllers
+   */
+  var NumberControllerBox = function(object, property, params) {
+
+    this.__truncationSuspended = false;
+
+    NumberControllerBox.superclass.call(this, object, property, params);
+
+    var _this = this;
+
+    /**
+     * {Number} Previous mouse y position
+     * @ignore
+     */
+    var prev_y;
+
+    this.__input = document.createElement('input');
+    this.__input.setAttribute('type', 'text');
+
+    // Makes it so manually specified values are not truncated.
+
+    dom.bind(this.__input, 'change', onChange);
+    dom.bind(this.__input, 'blur', onBlur);
+    dom.bind(this.__input, 'mousedown', onMouseDown);
+    dom.bind(this.__input, 'keydown', function(e) {
+
+      // When pressing entire, you can be as precise as you want.
+      if (e.keyCode === 13) {
+        _this.__truncationSuspended = true;
+        this.blur();
+        _this.__truncationSuspended = false;
+      }
+
+    });
+
+    function onChange() {
+      var attempted = parseFloat(_this.__input.value);
+      if (!common.isNaN(attempted)) _this.setValue(attempted);
+    }
+
+    function onBlur() {
+      onChange();
+      if (_this.__onFinishChange) {
+        _this.__onFinishChange.call(_this, _this.getValue());
+      }
+    }
+
+    function onMouseDown(e) {
+      dom.bind(window, 'mousemove', onMouseDrag);
+      dom.bind(window, 'mouseup', onMouseUp);
+      prev_y = e.clientY;
+    }
+
+    function onMouseDrag(e) {
+
+      var diff = prev_y - e.clientY;
+      _this.setValue(_this.getValue() + diff * _this.__impliedStep);
+
+      prev_y = e.clientY;
+
+    }
+
+    function onMouseUp() {
+      dom.unbind(window, 'mousemove', onMouseDrag);
+      dom.unbind(window, 'mouseup', onMouseUp);
+    }
+
+    this.updateDisplay();
+
+    this.domElement.appendChild(this.__input);
+
+  };
+
+  NumberControllerBox.superclass = NumberController;
+
+  common.extend(
+
+      NumberControllerBox.prototype,
+      NumberController.prototype,
+
+      {
+
+        updateDisplay: function() {
+
+          this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision);
+          return NumberControllerBox.superclass.prototype.updateDisplay.call(this);
+        }
+
+      }
+
+  );
+
+  function roundToDecimal(value, decimals) {
+    var tenTo = Math.pow(10, decimals);
+    return Math.round(value * tenTo) / tenTo;
+  }
+
+  return NumberControllerBox;
+
+})(dat.controllers.NumberController,
+dat.dom.dom,
+dat.utils.common);
+
+
+dat.controllers.NumberControllerSlider = (function (NumberController, dom, css, common, styleSheet) {
+
+  /**
+   * @class Represents a given property of an object that is a number, contains
+   * a minimum and maximum, and provides a slider element with which to
+   * manipulate it. It should be noted that the slider element is made up of
+   * <code>&lt;div&gt;</code> tags, <strong>not</strong> the html5
+   * <code>&lt;slider&gt;</code> element.
+   *
+   * @extends dat.controllers.Controller
+   * @extends dat.controllers.NumberController
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   * @param {Number} minValue Minimum allowed value
+   * @param {Number} maxValue Maximum allowed value
+   * @param {Number} stepValue Increment by which to change value
+   *
+   * @member dat.controllers
+   */
+  var NumberControllerSlider = function(object, property, min, max, step) {
+
+    NumberControllerSlider.superclass.call(this, object, property, { min: min, max: max, step: step });
+
+    var _this = this;
+
+    this.__background = document.createElement('div');
+    this.__foreground = document.createElement('div');
+
+
+
+    dom.bind(this.__background, 'mousedown', onMouseDown);
+
+    dom.addClass(this.__background, 'slider');
+    dom.addClass(this.__foreground, 'slider-fg');
+
+    function onMouseDown(e) {
+
+      dom.bind(window, 'mousemove', onMouseDrag);
+      dom.bind(window, 'mouseup', onMouseUp);
+
+      onMouseDrag(e);
+    }
+
+    function onMouseDrag(e) {
+
+      e.preventDefault();
+
+      var offset = dom.getOffset(_this.__background);
+      var width = dom.getWidth(_this.__background);
+
+      _this.setValue(
+       map(e.clientX, offset.left, offset.left + width, _this.__min, _this.__max)
+      );
+
+      return false;
+
+    }
+
+    function onMouseUp() {
+      dom.unbind(window, 'mousemove', onMouseDrag);
+      dom.unbind(window, 'mouseup', onMouseUp);
+      if (_this.__onFinishChange) {
+        _this.__onFinishChange.call(_this, _this.getValue());
+      }
+    }
+
+    this.updateDisplay();
+
+    this.__background.appendChild(this.__foreground);
+    this.domElement.appendChild(this.__background);
+
+  };
+
+  NumberControllerSlider.superclass = NumberController;
+
+  /**
+   * Injects default stylesheet for slider elements.
+   */
+  NumberControllerSlider.useDefaultStyles = function() {
+    css.inject(styleSheet);
+  };
+
+  common.extend(
+
+      NumberControllerSlider.prototype,
+      NumberController.prototype,
+
+      {
+
+        updateDisplay: function() {
+          var pct = (this.getValue() - this.__min)/(this.__max - this.__min);
+          this.__foreground.style.width = pct*100+'%';
+          return NumberControllerSlider.superclass.prototype.updateDisplay.call(this);
+        }
+
+      }
+
+
+
+  );
+
+       function map(v, i1, i2, o1, o2) {
+               return o1 + (o2 - o1) * ((v - i1) / (i2 - i1));
+       }
+
+  return NumberControllerSlider;
+
+})(dat.controllers.NumberController,
+dat.dom.dom,
+dat.utils.css,
+dat.utils.common,
+".slider {\n  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n  height: 1em;\n  border-radius: 1em;\n  background-color: #eee;\n  padding: 0 0.5em;\n  overflow: hidden;\n}\n\n.slider-fg {\n  padding: 1px 0 2px 0;\n  background-color: #aaa;\n  height: 1em;\n  margin-left: -0.5em;\n  padding-right: 0.5em;\n  border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n  display: inline-block;\n  border-radius: 1em;\n  background-color: #fff;\n  border:  1px solid #aaa;\n  content: '';\n  float: right;\n  margin-right: -1em;\n  margin-top: -1px;\n  height: 0.9em;\n  width: 0.9em;\n}");
+
+
+dat.controllers.FunctionController = (function (Controller, dom, common) {
+
+  /**
+   * @class Provides a GUI interface to fire a specified method, a property of an object.
+   *
+   * @extends dat.controllers.Controller
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   *
+   * @member dat.controllers
+   */
+  var FunctionController = function(object, property, text) {
+
+    FunctionController.superclass.call(this, object, property);
+
+    var _this = this;
+
+    this.__button = document.createElement('div');
+    this.__button.innerHTML = text === undefined ? 'Fire' : text;
+    dom.bind(this.__button, 'click', function(e) {
+      e.preventDefault();
+      _this.fire();
+      return false;
+    });
+
+    dom.addClass(this.__button, 'button');
+
+    this.domElement.appendChild(this.__button);
+
+
+  };
+
+  FunctionController.superclass = Controller;
+
+  common.extend(
+
+      FunctionController.prototype,
+      Controller.prototype,
+      {
+
+        fire: function() {
+          if (this.__onChange) {
+            this.__onChange.call(this);
+          }
+          if (this.__onFinishChange) {
+            this.__onFinishChange.call(this, this.getValue());
+          }
+          this.getValue().call(this.object);
+        }
+      }
+
+  );
+
+  return FunctionController;
+
+})(dat.controllers.Controller,
+dat.dom.dom,
+dat.utils.common);
+
+
+dat.controllers.BooleanController = (function (Controller, dom, common) {
+
+  /**
+   * @class Provides a checkbox input to alter the boolean property of an object.
+   * @extends dat.controllers.Controller
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   *
+   * @member dat.controllers
+   */
+  var BooleanController = function(object, property) {
+
+    BooleanController.superclass.call(this, object, property);
+
+    var _this = this;
+    this.__prev = this.getValue();
+
+    this.__checkbox = document.createElement('input');
+    this.__checkbox.setAttribute('type', 'checkbox');
+
+
+    dom.bind(this.__checkbox, 'change', onChange, false);
+
+    this.domElement.appendChild(this.__checkbox);
+
+    // Match original value
+    this.updateDisplay();
+
+    function onChange() {
+      _this.setValue(!_this.__prev);
+    }
+
+  };
+
+  BooleanController.superclass = Controller;
+
+  common.extend(
+
+      BooleanController.prototype,
+      Controller.prototype,
+
+      {
+
+        setValue: function(v) {
+          var toReturn = BooleanController.superclass.prototype.setValue.call(this, v);
+          if (this.__onFinishChange) {
+            this.__onFinishChange.call(this, this.getValue());
+          }
+          this.__prev = this.getValue();
+          return toReturn;
+        },
+
+        updateDisplay: function() {
+
+          if (this.getValue() === true) {
+            this.__checkbox.setAttribute('checked', 'checked');
+            this.__checkbox.checked = true;
+          } else {
+              this.__checkbox.checked = false;
+          }
+
+          return BooleanController.superclass.prototype.updateDisplay.call(this);
+
+        }
+
+
+      }
+
+  );
+
+  return BooleanController;
+
+})(dat.controllers.Controller,
+dat.dom.dom,
+dat.utils.common);
+
+
+dat.color.toString = (function (common) {
+
+  return function(color) {
+
+    if (color.a == 1 || common.isUndefined(color.a)) {
+
+      var s = color.hex.toString(16);
+      while (s.length < 6) {
+        s = '0' + s;
+      }
+
+      return '#' + s;
+
+    } else {
+
+      return 'rgba(' + Math.round(color.r) + ',' + Math.round(color.g) + ',' + Math.round(color.b) + ',' + color.a + ')';
+
+    }
+
+  }
+
+})(dat.utils.common);
+
+
+dat.color.interpret = (function (toString, common) {
+
+  var result, toReturn;
+
+  var interpret = function() {
+
+    toReturn = false;
+
+    var original = arguments.length > 1 ? common.toArray(arguments) : arguments[0];
+
+    common.each(INTERPRETATIONS, function(family) {
+
+      if (family.litmus(original)) {
+
+        common.each(family.conversions, function(conversion, conversionName) {
+
+          result = conversion.read(original);
+
+          if (toReturn === false && result !== false) {
+            toReturn = result;
+            result.conversionName = conversionName;
+            result.conversion = conversion;
+            return common.BREAK;
+
+          }
+
+        });
+
+        return common.BREAK;
+
+      }
+
+    });
+
+    return toReturn;
+
+  };
+
+  var INTERPRETATIONS = [
+
+    // Strings
+    {
+
+      litmus: common.isString,
+
+      conversions: {
+
+        THREE_CHAR_HEX: {
+
+          read: function(original) {
+
+            var test = original.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);
+            if (test === null) return false;
+
+            return {
+              space: 'HEX',
+              hex: parseInt(
+                  '0x' +
+                      test[1].toString() + test[1].toString() +
+                      test[2].toString() + test[2].toString() +
+                      test[3].toString() + test[3].toString())
+            };
+
+          },
+
+          write: toString
+
+        },
+
+        SIX_CHAR_HEX: {
+
+          read: function(original) {
+
+            var test = original.match(/^#([A-F0-9]{6})$/i);
+            if (test === null) return false;
+
+            return {
+              space: 'HEX',
+              hex: parseInt('0x' + test[1].toString())
+            };
+
+          },
+
+          write: toString
+
+        },
+
+        CSS_RGB: {
+
+          read: function(original) {
+
+            var test = original.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
+            if (test === null) return false;
+
+            return {
+              space: 'RGB',
+              r: parseFloat(test[1]),
+              g: parseFloat(test[2]),
+              b: parseFloat(test[3])
+            };
+
+          },
+
+          write: toString
+
+        },
+
+        CSS_RGBA: {
+
+          read: function(original) {
+
+            var test = original.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);
+            if (test === null) return false;
+
+            return {
+              space: 'RGB',
+              r: parseFloat(test[1]),
+              g: parseFloat(test[2]),
+              b: parseFloat(test[3]),
+              a: parseFloat(test[4])
+            };
+
+          },
+
+          write: toString
+
+        }
+
+      }
+
+    },
+
+    // Numbers
+    {
+
+      litmus: common.isNumber,
+
+      conversions: {
+
+        HEX: {
+          read: function(original) {
+            return {
+              space: 'HEX',
+              hex: original,
+              conversionName: 'HEX'
+            }
+          },
+
+          write: function(color) {
+            return color.hex;
+          }
+        }
+
+      }
+
+    },
+
+    // Arrays
+    {
+
+      litmus: common.isArray,
+
+      conversions: {
+
+        RGB_ARRAY: {
+          read: function(original) {
+            if (original.length != 3) return false;
+            return {
+              space: 'RGB',
+              r: original[0]*255,
+              g: original[1]*255,
+              b: original[2]*255
+            };
+          },
+
+          write: function(color) {
+            return [color.r/255, color.g/255, color.b/255];
+          }
+
+        },
+
+        RGBA_ARRAY: {
+          read: function(original) {
+            if (original.length != 4) return false;
+            return {
+              space: 'RGB',
+              r: original[0],
+              g: original[1],
+              b: original[2],
+              a: original[3]
+            };
+          },
+
+          write: function(color) {
+            return [color.r, color.g, color.b, color.a];
+          }
+
+        }
+
+      }
+
+    },
+
+    // Objects
+    {
+
+      litmus: common.isObject,
+
+      conversions: {
+
+        RGBA_OBJ: {
+          read: function(original) {
+            if (common.isNumber(original.r) &&
+                common.isNumber(original.g) &&
+                common.isNumber(original.b) &&
+                common.isNumber(original.a)) {
+              return {
+                space: 'RGB',
+                r: original.r,
+                g: original.g,
+                b: original.b,
+                a: original.a
+              }
+            }
+            return false;
+          },
+
+          write: function(color) {
+            return {
+              r: color.r,
+              g: color.g,
+              b: color.b,
+              a: color.a
+            }
+          }
+        },
+
+        RGB_OBJ: {
+          read: function(original) {
+            if (common.isNumber(original.r) &&
+                common.isNumber(original.g) &&
+                common.isNumber(original.b)) {
+              return {
+                space: 'RGB',
+                r: original.r,
+                g: original.g,
+                b: original.b
+              }
+            }
+            return false;
+          },
+
+          write: function(color) {
+            return {
+              r: color.r,
+              g: color.g,
+              b: color.b
+            }
+          }
+        },
+
+        HSVA_OBJ: {
+          read: function(original) {
+            if (common.isNumber(original.h) &&
+                common.isNumber(original.s) &&
+                common.isNumber(original.v) &&
+                common.isNumber(original.a)) {
+              return {
+                space: 'HSV',
+                h: original.h,
+                s: original.s,
+                v: original.v,
+                a: original.a
+              }
+            }
+            return false;
+          },
+
+          write: function(color) {
+            return {
+              h: color.h,
+              s: color.s,
+              v: color.v,
+              a: color.a
+            }
+          }
+        },
+
+        HSV_OBJ: {
+          read: function(original) {
+            if (common.isNumber(original.h) &&
+                common.isNumber(original.s) &&
+                common.isNumber(original.v)) {
+              return {
+                space: 'HSV',
+                h: original.h,
+                s: original.s,
+                v: original.v
+              }
+            }
+            return false;
+          },
+
+          write: function(color) {
+            return {
+              h: color.h,
+              s: color.s,
+              v: color.v
+            }
+          }
+
+        }
+
+      }
+
+    }
+
+
+  ];
+
+  return interpret;
+
+
+})(dat.color.toString,
+dat.utils.common);
+
+
+dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, controllerFactory, Controller, BooleanController, FunctionController, NumberControllerBox, NumberControllerSlider, OptionController, ColorController, requestAnimationFrame, CenteredDiv, dom, common) {
+
+  css.inject(styleSheet);
+
+  /** Outer-most className for GUI's */
+  var CSS_NAMESPACE = 'dg';
+
+  var HIDE_KEY_CODE = 72;
+
+  /** The only value shared between the JS and SCSS. Use caution. */
+  var CLOSE_BUTTON_HEIGHT = 20;
+
+  var DEFAULT_DEFAULT_PRESET_NAME = 'Default';
+
+  var SUPPORTS_LOCAL_STORAGE = (function() {
+    try {
+      return 'localStorage' in window && window['localStorage'] !== null;
+    } catch (e) {
+      return false;
+    }
+  })();
+
+  var SAVE_DIALOGUE;
+
+  /** Have we yet to create an autoPlace GUI? */
+  var auto_place_virgin = true;
+
+  /** Fixed position div that auto place GUI's go inside */
+  var auto_place_container;
+
+  /** Are we hiding the GUI's ? */
+  var hide = false;
+
+  /** GUI's which should be hidden */
+  var hideable_guis = [];
+
+  /**
+   * A lightweight controller library for JavaScript. It allows you to easily
+   * manipulate variables and fire functions on the fly.
+   * @class
+   *
+   * @member dat.gui
+   *
+   * @param {Object} [params]
+   * @param {String} [params.name] The name of this GUI.
+   * @param {Object} [params.load] JSON object representing the saved state of
+   * this GUI.
+   * @param {Boolean} [params.auto=true]
+   * @param {dat.gui.GUI} [params.parent] The GUI I'm nested in.
+   * @param {Boolean} [params.closed] If true, starts closed
+   */
+  var GUI = function(params) {
+
+    var _this = this;
+
+    /**
+     * Outermost DOM Element
+     * @type DOMElement
+     */
+    this.domElement = document.createElement('div');
+    this.__ul = document.createElement('ul');
+    this.domElement.appendChild(this.__ul);
+
+    dom.addClass(this.domElement, CSS_NAMESPACE);
+
+    /**
+     * Nested GUI's by name
+     * @ignore
+     */
+    this.__folders = {};
+
+    this.__controllers = [];
+
+    /**
+     * List of objects I'm remembering for save, only used in top level GUI
+     * @ignore
+     */
+    this.__rememberedObjects = [];
+
+    /**
+     * Maps the index of remembered objects to a map of controllers, only used
+     * in top level GUI.
+     *
+     * @private
+     * @ignore
+     *
+     * @example
+     * [
+     *  {
+     *    propertyName: Controller,
+     *    anotherPropertyName: Controller
+     *  },
+     *  {
+     *    propertyName: Controller
+     *  }
+     * ]
+     */
+    this.__rememberedObjectIndecesToControllers = [];
+
+    this.__listening = [];
+
+    params = params || {};
+
+    // Default parameters
+    params = common.defaults(params, {
+      autoPlace: true,
+      width: GUI.DEFAULT_WIDTH
+    });
+
+    params = common.defaults(params, {
+      resizable: params.autoPlace,
+      hideable: params.autoPlace
+    });
+
+
+    if (!common.isUndefined(params.load)) {
+
+      // Explicit preset
+      if (params.preset) params.load.preset = params.preset;
+
+    } else {
+
+      params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME };
+
+    }
+
+    if (common.isUndefined(params.parent) && params.hideable) {
+      hideable_guis.push(this);
+    }
+
+    // Only root level GUI's are resizable.
+    params.resizable = common.isUndefined(params.parent) && params.resizable;
+
+
+    if (params.autoPlace && common.isUndefined(params.scrollable)) {
+      params.scrollable = true;
+    }
+//    params.scrollable = common.isUndefined(params.parent) && params.scrollable === true;
+
+    // Not part of params because I don't want people passing this in via
+    // constructor. Should be a 'remembered' value.
+    var use_local_storage =
+        SUPPORTS_LOCAL_STORAGE &&
+            localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true';
+
+    Object.defineProperties(this,
+
+        /** @lends dat.gui.GUI.prototype */
+        {
+
+          /**
+           * The parent <code>GUI</code>
+           * @type dat.gui.GUI
+           */
+          parent: {
+            get: function() {
+              return params.parent;
+            }
+          },
+
+          scrollable: {
+            get: function() {
+              return params.scrollable;
+            }
+          },
+
+          /**
+           * Handles <code>GUI</code>'s element placement for you
+           * @type Boolean
+           */
+          autoPlace: {
+            get: function() {
+              return params.autoPlace;
+            }
+          },
+
+          /**
+           * The identifier for a set of saved values
+           * @type String
+           */
+          preset: {
+
+            get: function() {
+              if (_this.parent) {
+                return _this.getRoot().preset;
+              } else {
+                return params.load.preset;
+              }
+            },
+
+            set: function(v) {
+              if (_this.parent) {
+                _this.getRoot().preset = v;
+              } else {
+                params.load.preset = v;
+              }
+              setPresetSelectIndex(this);
+              _this.revert();
+            }
+
+          },
+
+          /**
+           * The width of <code>GUI</code> element
+           * @type Number
+           */
+          width: {
+            get: function() {
+              return params.width;
+            },
+            set: function(v) {
+              params.width = v;
+              setWidth(_this, v);
+            }
+          },
+
+          /**
+           * The name of <code>GUI</code>. Used for folders. i.e
+           * a folder's name
+           * @type String
+           */
+          name: {
+            get: function() {
+              return params.name;
+            },
+            set: function(v) {
+              // TODO Check for collisions among sibling folders
+              params.name = v;
+              if (title_row_name) {
+                title_row_name.innerHTML = params.name;
+              }
+            }
+          },
+
+          /**
+           * Whether the <code>GUI</code> is collapsed or not
+           * @type Boolean
+           */
+          closed: {
+            get: function() {
+              return params.closed;
+            },
+            set: function(v) {
+              params.closed = v;
+              if (params.closed) {
+                dom.addClass(_this.__ul, GUI.CLASS_CLOSED);
+              } else {
+                dom.removeClass(_this.__ul, GUI.CLASS_CLOSED);
+              }
+              // For browsers that aren't going to respect the CSS transition,
+              // Lets just check our height against the window height right off
+              // the bat.
+              this.onResize();
+
+              if (_this.__closeButton) {
+                _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED;
+              }
+            }
+          },
+
+          /**
+           * Contains all presets
+           * @type Object
+           */
+          load: {
+            get: function() {
+              return params.load;
+            }
+          },
+
+          /**
+           * Determines whether or not to use <a href="https://developer.mozilla.org/en/DOM/Storage#localStorage">localStorage</a> as the means for
+           * <code>remember</code>ing
+           * @type Boolean
+           */
+          useLocalStorage: {
+
+            get: function() {
+              return use_local_storage;
+            },
+            set: function(bool) {
+              if (SUPPORTS_LOCAL_STORAGE) {
+                use_local_storage = bool;
+                if (bool) {
+                  dom.bind(window, 'unload', saveToLocalStorage);
+                } else {
+                  dom.unbind(window, 'unload', saveToLocalStorage);
+                }
+                localStorage.setItem(getLocalStorageHash(_this, 'isLocal'), bool);
+              }
+            }
+
+          }
+
+        });
+
+    // Are we a root level GUI?
+    if (common.isUndefined(params.parent)) {
+
+      params.closed = false;
+
+      dom.addClass(this.domElement, GUI.CLASS_MAIN);
+      dom.makeSelectable(this.domElement, false);
+
+      // Are we supposed to be loading locally?
+      if (SUPPORTS_LOCAL_STORAGE) {
+
+        if (use_local_storage) {
+
+          _this.useLocalStorage = true;
+
+          var saved_gui = localStorage.getItem(getLocalStorageHash(this, 'gui'));
+
+          if (saved_gui) {
+            params.load = JSON.parse(saved_gui);
+          }
+
+        }
+
+      }
+
+      this.__closeButton = document.createElement('div');
+      this.__closeButton.innerHTML = GUI.TEXT_CLOSED;
+      dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON);
+      this.domElement.appendChild(this.__closeButton);
+
+      dom.bind(this.__closeButton, 'click', function() {
+
+        _this.closed = !_this.closed;
+
+
+      });
+
+
+      // Oh, you're a nested GUI!
+    } else {
+
+      if (params.closed === undefined) {
+        params.closed = true;
+      }
+
+      var title_row_name = document.createTextNode(params.name);
+      dom.addClass(title_row_name, 'controller-name');
+
+      var title_row = addRow(_this, title_row_name);
+
+      var on_click_title = function(e) {
+        e.preventDefault();
+        _this.closed = !_this.closed;
+        return false;
+      };
+
+      dom.addClass(this.__ul, GUI.CLASS_CLOSED);
+
+      dom.addClass(title_row, 'title');
+      dom.bind(title_row, 'click', on_click_title);
+
+      if (!params.closed) {
+        this.closed = false;
+      }
+
+    }
+
+    if (params.autoPlace) {
+
+      if (common.isUndefined(params.parent)) {
+
+        if (auto_place_virgin) {
+          auto_place_container = document.createElement('div');
+          dom.addClass(auto_place_container, CSS_NAMESPACE);
+          dom.addClass(auto_place_container, GUI.CLASS_AUTO_PLACE_CONTAINER);
+          document.body.appendChild(auto_place_container);
+          auto_place_virgin = false;
+        }
+
+        // Put it in the dom for you.
+        auto_place_container.appendChild(this.domElement);
+
+        // Apply the auto styles
+        dom.addClass(this.domElement, GUI.CLASS_AUTO_PLACE);
+
+      }
+
+
+      // Make it not elastic.
+      if (!this.parent) setWidth(_this, params.width);
+
+    }
+
+    dom.bind(window, 'resize', function() { _this.onResize() });
+    dom.bind(this.__ul, 'webkitTransitionEnd', function() { _this.onResize(); });
+    dom.bind(this.__ul, 'transitionend', function() { _this.onResize() });
+    dom.bind(this.__ul, 'oTransitionEnd', function() { _this.onResize() });
+    this.onResize();
+
+
+    if (params.resizable) {
+      addResizeHandle(this);
+    }
+
+    function saveToLocalStorage() {
+      localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject()));
+    }
+
+    var root = _this.getRoot();
+    function resetWidth() {
+             var root = _this.getRoot();
+             root.width += 1;
+             common.defer(function() {
+               root.width -= 1;
+             });
+           }
+
+           if (!params.parent) {
+             resetWidth();
+           }
+
+  };
+
+  GUI.toggleHide = function() {
+
+    hide = !hide;
+    common.each(hideable_guis, function(gui) {
+      gui.domElement.style.zIndex = hide ? -999 : 999;
+      gui.domElement.style.opacity = hide ? 0 : 1;
+    });
+  };
+
+  GUI.CLASS_AUTO_PLACE = 'a';
+  GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';
+  GUI.CLASS_MAIN = 'main';
+  GUI.CLASS_CONTROLLER_ROW = 'cr';
+  GUI.CLASS_TOO_TALL = 'taller-than-window';
+  GUI.CLASS_CLOSED = 'closed';
+  GUI.CLASS_CLOSE_BUTTON = 'close-button';
+  GUI.CLASS_DRAG = 'drag';
+
+  GUI.DEFAULT_WIDTH = 245;
+  GUI.TEXT_CLOSED = 'Close Controls';
+  GUI.TEXT_OPEN = 'Open Controls';
+
+  dom.bind(window, 'keydown', function(e) {
+
+    if (document.activeElement.type !== 'text' &&
+        (e.which === HIDE_KEY_CODE || e.keyCode == HIDE_KEY_CODE)) {
+      GUI.toggleHide();
+    }
+
+  }, false);
+
+  common.extend(
+
+      GUI.prototype,
+
+      /** @lends dat.gui.GUI */
+      {
+
+        /**
+         * @param object
+         * @param property
+         * @returns {dat.controllers.Controller} The new controller that was added.
+         * @instance
+         */
+        add: function(object, property) {
+
+          return add(
+              this,
+              object,
+              property,
+              {
+                factoryArgs: Array.prototype.slice.call(arguments, 2)
+              }
+          );
+
+        },
+
+        /**
+         * @param object
+         * @param property
+         * @returns {dat.controllers.ColorController} The new controller that was added.
+         * @instance
+         */
+        addColor: function(object, property) {
+
+          return add(
+              this,
+              object,
+              property,
+              {
+                color: true
+              }
+          );
+
+        },
+
+        /**
+         * @param controller
+         * @instance
+         */
+        remove: function(controller) {
+
+          // TODO listening?
+          this.__ul.removeChild(controller.__li);
+          this.__controllers.slice(this.__controllers.indexOf(controller), 1);
+          var _this = this;
+          common.defer(function() {
+            _this.onResize();
+          });
+
+        },
+
+        destroy: function() {
+
+          if (this.autoPlace) {
+            auto_place_container.removeChild(this.domElement);
+          }
+
+        },
+
+        /**
+         * @param name
+         * @returns {dat.gui.GUI} The new folder.
+         * @throws {Error} if this GUI already has a folder by the specified
+         * name
+         * @instance
+         */
+        addFolder: function(name) {
+
+          // We have to prevent collisions on names in order to have a key
+          // by which to remember saved values
+          if (this.__folders[name] !== undefined) {
+            throw new Error('You already have a folder in this GUI by the' +
+                ' name "' + name + '"');
+          }
+
+          var new_gui_params = { name: name, parent: this };
+
+          // We need to pass down the autoPlace trait so that we can
+          // attach event listeners to open/close folder actions to
+          // ensure that a scrollbar appears if the window is too short.
+          new_gui_params.autoPlace = this.autoPlace;
+
+          // Do we have saved appearance data for this folder?
+
+          if (this.load && // Anything loaded?
+              this.load.folders && // Was my parent a dead-end?
+              this.load.folders[name]) { // Did daddy remember me?
+
+            // Start me closed if I was closed
+            new_gui_params.closed = this.load.folders[name].closed;
+
+            // Pass down the loaded data
+            new_gui_params.load = this.load.folders[name];
+
+          }
+
+          var gui = new GUI(new_gui_params);
+          this.__folders[name] = gui;
+
+          var li = addRow(this, gui.domElement);
+          dom.addClass(li, 'folder');
+          return gui;
+
+        },
+
+        open: function() {
+          this.closed = false;
+        },
+
+        close: function() {
+          this.closed = true;
+        },
+
+        onResize: function() {
+
+          var root = this.getRoot();
+
+          if (root.scrollable) {
+
+            var top = dom.getOffset(root.__ul).top;
+            var h = 0;
+
+            common.each(root.__ul.childNodes, function(node) {
+              if (! (root.autoPlace && node === root.__save_row))
+                h += dom.getHeight(node);
+            });
+
+            if (window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h) {
+              dom.addClass(root.domElement, GUI.CLASS_TOO_TALL);
+              root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px';
+            } else {
+              dom.removeClass(root.domElement, GUI.CLASS_TOO_TALL);
+              root.__ul.style.height = 'auto';
+            }
+
+          }
+
+          if (root.__resize_handle) {
+            common.defer(function() {
+              root.__resize_handle.style.height = root.__ul.offsetHeight + 'px';
+            });
+          }
+
+          if (root.__closeButton) {
+            root.__closeButton.style.width = root.width + 'px';
+          }
+
+        },
+
+        /**
+         * Mark objects for saving. The order of these objects cannot change as
+         * the GUI grows. When remembering new objects, append them to the end
+         * of the list.
+         *
+         * @param {Object...} objects
+         * @throws {Error} if not called on a top level GUI.
+         * @instance
+         */
+        remember: function() {
+
+          if (common.isUndefined(SAVE_DIALOGUE)) {
+            SAVE_DIALOGUE = new CenteredDiv();
+            SAVE_DIALOGUE.domElement.innerHTML = saveDialogueContents;
+          }
+
+          if (this.parent) {
+            throw new Error("You can only call remember on a top level GUI.");
+          }
+
+          var _this = this;
+
+          common.each(Array.prototype.slice.call(arguments), function(object) {
+            if (_this.__rememberedObjects.length == 0) {
+              addSaveMenu(_this);
+            }
+            if (_this.__rememberedObjects.indexOf(object) == -1) {
+              _this.__rememberedObjects.push(object);
+            }
+          });
+
+          if (this.autoPlace) {
+            // Set save row width
+            setWidth(this, this.width);
+          }
+
+        },
+
+        /**
+         * @returns {dat.gui.GUI} the topmost parent GUI of a nested GUI.
+         * @instance
+         */
+        getRoot: function() {
+          var gui = this;
+          while (gui.parent) {
+            gui = gui.parent;
+          }
+          return gui;
+        },
+
+        /**
+         * @returns {Object} a JSON object representing the current state of
+         * this GUI as well as its remembered properties.
+         * @instance
+         */
+        getSaveObject: function() {
+
+          var toReturn = this.load;
+
+          toReturn.closed = this.closed;
+
+          // Am I remembering any values?
+          if (this.__rememberedObjects.length > 0) {
+
+            toReturn.preset = this.preset;
+
+            if (!toReturn.remembered) {
+              toReturn.remembered = {};
+            }
+
+            toReturn.remembered[this.preset] = getCurrentPreset(this);
+
+          }
+
+          toReturn.folders = {};
+          common.each(this.__folders, function(element, key) {
+            toReturn.folders[key] = element.getSaveObject();
+          });
+
+          return toReturn;
+
+        },
+
+        save: function() {
+
+          if (!this.load.remembered) {
+            this.load.remembered = {};
+          }
+
+          this.load.remembered[this.preset] = getCurrentPreset(this);
+          markPresetModified(this, false);
+
+        },
+
+        saveAs: function(presetName) {
+
+          if (!this.load.remembered) {
+
+            // Retain default values upon first save
+            this.load.remembered = {};
+            this.load.remembered[DEFAULT_DEFAULT_PRESET_NAME] = getCurrentPreset(this, true);
+
+          }
+
+          this.load.remembered[presetName] = getCurrentPreset(this);
+          this.preset = presetName;
+          addPresetOption(this, presetName, true);
+
+        },
+
+        revert: function(gui) {
+
+          common.each(this.__controllers, function(controller) {
+            // Make revert work on Default.
+            if (!this.getRoot().load.remembered) {
+              controller.setValue(controller.initialValue);
+            } else {
+              recallSavedValue(gui || this.getRoot(), controller);
+            }
+          }, this);
+
+          common.each(this.__folders, function(folder) {
+            folder.revert(folder);
+          });
+
+          if (!gui) {
+            markPresetModified(this.getRoot(), false);
+          }
+
+
+        },
+
+        listen: function(controller) {
+
+          var init = this.__listening.length == 0;
+          this.__listening.push(controller);
+          if (init) updateDisplays(this.__listening);
+
+        }
+
+      }
+
+  );
+
+  function add(gui, object, property, params) {
+
+    if (object[property] === undefined) {
+      throw new Error("Object " + object + " has no property \"" + property + "\"");
+    }
+
+    var controller;
+
+    if (params.color) {
+
+      controller = new ColorController(object, property);
+
+    } else {
+
+      var factoryArgs = [object,property].concat(params.factoryArgs);
+      controller = controllerFactory.apply(gui, factoryArgs);
+
+    }
+
+    if (params.before instanceof Controller) {
+      params.before = params.before.__li;
+    }
+
+    recallSavedValue(gui, controller);
+
+    dom.addClass(controller.domElement, 'c');
+
+    var name = document.createElement('span');
+    dom.addClass(name, 'property-name');
+    name.innerHTML = controller.property;
+
+    var container = document.createElement('div');
+    container.appendChild(name);
+    container.appendChild(controller.domElement);
+
+    var li = addRow(gui, container, params.before);
+
+    dom.addClass(li, GUI.CLASS_CONTROLLER_ROW);
+
+    if (params.color) {
+      dom.addClass(li, 'string');
+    } else {
+      dom.addClass(li, typeof controller.getValue());
+    }
+
+    augmentController(gui, li, controller);
+
+    gui.__controllers.push(controller);
+
+    return controller;
+
+  }
+
+  /**
+   * Add a row to the end of the GUI or before another row.
+   *
+   * @param gui
+   * @param [dom] If specified, inserts the dom content in the new row
+   * @param [liBefore] If specified, places the new row before another row
+   */
+  function addRow(gui, dom, liBefore) {
+    var li = document.createElement('li');
+    if (dom) li.appendChild(dom);
+    if (liBefore) {
+      gui.__ul.insertBefore(li, params.before);
+    } else {
+      gui.__ul.appendChild(li);
+    }
+    gui.onResize();
+    return li;
+  }
+
+  function augmentController(gui, li, controller) {
+
+    controller.__li = li;
+    controller.__gui = gui;
+
+    common.extend(controller, {
+
+      options: function(options) {
+
+        if (arguments.length > 1) {
+          controller.remove();
+
+          return add(
+              gui,
+              controller.object,
+              controller.property,
+              {
+                before: controller.__li.nextElementSibling,
+                factoryArgs: [common.toArray(arguments)]
+              }
+          );
+
+        }
+
+        if (common.isArray(options) || common.isObject(options)) {
+          controller.remove();
+
+          return add(
+              gui,
+              controller.object,
+              controller.property,
+              {
+                before: controller.__li.nextElementSibling,
+                factoryArgs: [options]
+              }
+          );
+
+        }
+
+      },
+
+      name: function(v) {
+        controller.__li.firstElementChild.firstElementChild.innerHTML = v;
+        return controller;
+      },
+
+      listen: function() {
+        controller.__gui.listen(controller);
+        return controller;
+      },
+
+      remove: function() {
+        controller.__gui.remove(controller);
+        return controller;
+      }
+
+    });
+
+    // All sliders should be accompanied by a box.
+    if (controller instanceof NumberControllerSlider) {
+
+      var box = new NumberControllerBox(controller.object, controller.property,
+          { min: controller.__min, max: controller.__max, step: controller.__step });
+
+      common.each(['updateDisplay', 'onChange', 'onFinishChange'], function(method) {
+        var pc = controller[method];
+        var pb = box[method];
+        controller[method] = box[method] = function() {
+          var args = Array.prototype.slice.call(arguments);
+          pc.apply(controller, args);
+          return pb.apply(box, args);
+        }
+      });
+
+      dom.addClass(li, 'has-slider');
+      controller.domElement.insertBefore(box.domElement, controller.domElement.firstElementChild);
+
+    }
+    else if (controller instanceof NumberControllerBox) {
+
+      var r = function(returned) {
+
+        // Have we defined both boundaries?
+        if (common.isNumber(controller.__min) && common.isNumber(controller.__max)) {
+
+          // Well, then lets just replace this with a slider.
+          controller.remove();
+          return add(
+              gui,
+              controller.object,
+              controller.property,
+              {
+                before: controller.__li.nextElementSibling,
+                factoryArgs: [controller.__min, controller.__max, controller.__step]
+              });
+
+        }
+
+        return returned;
+
+      };
+
+      controller.min = common.compose(r, controller.min);
+      controller.max = common.compose(r, controller.max);
+
+    }
+    else if (controller instanceof BooleanController) {
+
+      dom.bind(li, 'click', function() {
+        dom.fakeEvent(controller.__checkbox, 'click');
+      });
+
+      dom.bind(controller.__checkbox, 'click', function(e) {
+        e.stopPropagation(); // Prevents double-toggle
+      })
+
+    }
+    else if (controller instanceof FunctionController) {
+
+      dom.bind(li, 'click', function() {
+        dom.fakeEvent(controller.__button, 'click');
+      });
+
+      dom.bind(li, 'mouseover', function() {
+        dom.addClass(controller.__button, 'hover');
+      });
+
+      dom.bind(li, 'mouseout', function() {
+        dom.removeClass(controller.__button, 'hover');
+      });
+
+    }
+    else if (controller instanceof ColorController) {
+
+      dom.addClass(li, 'color');
+      controller.updateDisplay = common.compose(function(r) {
+        li.style.borderLeftColor = controller.__color.toString();
+        return r;
+      }, controller.updateDisplay);
+
+      controller.updateDisplay();
+
+    }
+
+    controller.setValue = common.compose(function(r) {
+      if (gui.getRoot().__preset_select && controller.isModified()) {
+        markPresetModified(gui.getRoot(), true);
+      }
+      return r;
+    }, controller.setValue);
+
+  }
+
+  function recallSavedValue(gui, controller) {
+
+    // Find the topmost GUI, that's where remembered objects live.
+    var root = gui.getRoot();
+
+    // Does the object we're controlling match anything we've been told to
+    // remember?
+    var matched_index = root.__rememberedObjects.indexOf(controller.object);
+
+    // Why yes, it does!
+    if (matched_index != -1) {
+
+      // Let me fetch a map of controllers for thcommon.isObject.
+      var controller_map =
+          root.__rememberedObjectIndecesToControllers[matched_index];
+
+      // Ohp, I believe this is the first controller we've created for this
+      // object. Lets make the map fresh.
+      if (controller_map === undefined) {
+        controller_map = {};
+        root.__rememberedObjectIndecesToControllers[matched_index] =
+            controller_map;
+      }
+
+      // Keep track of this controller
+      controller_map[controller.property] = controller;
+
+      // Okay, now have we saved any values for this controller?
+      if (root.load && root.load.remembered) {
+
+        var preset_map = root.load.remembered;
+
+        // Which preset are we trying to load?
+        var preset;
+
+        if (preset_map[gui.preset]) {
+
+          preset = preset_map[gui.preset];
+
+        } else if (preset_map[DEFAULT_DEFAULT_PRESET_NAME]) {
+
+          // Uhh, you can have the default instead?
+          preset = preset_map[DEFAULT_DEFAULT_PRESET_NAME];
+
+        } else {
+
+          // Nada.
+
+          return;
+
+        }
+
+
+        // Did the loaded object remember thcommon.isObject?
+        if (preset[matched_index] &&
+
+          // Did we remember this particular property?
+            preset[matched_index][controller.property] !== undefined) {
+
+          // We did remember something for this guy ...
+          var value = preset[matched_index][controller.property];
+
+          // And that's what it is.
+          controller.initialValue = value;
+          controller.setValue(value);
+
+        }
+
+      }
+
+    }
+
+  }
+
+  function getLocalStorageHash(gui, key) {
+    // TODO how does this deal with multiple GUI's?
+    return document.location.href + '.' + key;
+
+  }
+
+  function addSaveMenu(gui) {
+
+    var div = gui.__save_row = document.createElement('li');
+
+    dom.addClass(gui.domElement, 'has-save');
+
+    gui.__ul.insertBefore(div, gui.__ul.firstChild);
+
+    dom.addClass(div, 'save-row');
+
+    var gears = document.createElement('span');
+    gears.innerHTML = '&nbsp;';
+    dom.addClass(gears, 'button gears');
+
+    // TODO replace with FunctionController
+    var button = document.createElement('span');
+    button.innerHTML = 'Save';
+    dom.addClass(button, 'button');
+    dom.addClass(button, 'save');
+
+    var button2 = document.createElement('span');
+    button2.innerHTML = 'New';
+    dom.addClass(button2, 'button');
+    dom.addClass(button2, 'save-as');
+
+    var button3 = document.createElement('span');
+    button3.innerHTML = 'Revert';
+    dom.addClass(button3, 'button');
+    dom.addClass(button3, 'revert');
+
+    var select = gui.__preset_select = document.createElement('select');
+
+    if (gui.load && gui.load.remembered) {
+
+      common.each(gui.load.remembered, function(value, key) {
+        addPresetOption(gui, key, key == gui.preset);
+      });
+
+    } else {
+      addPresetOption(gui, DEFAULT_DEFAULT_PRESET_NAME, false);
+    }
+
+    dom.bind(select, 'change', function() {
+
+
+      for (var index = 0; index < gui.__preset_select.length; index++) {
+        gui.__preset_select[index].innerHTML = gui.__preset_select[index].value;
+      }
+
+      gui.preset = this.value;
+
+    });
+
+    div.appendChild(select);
+    div.appendChild(gears);
+    div.appendChild(button);
+    div.appendChild(button2);
+    div.appendChild(button3);
+
+    if (SUPPORTS_LOCAL_STORAGE) {
+
+      var saveLocally = document.getElementById('dg-save-locally');
+      var explain = document.getElementById('dg-local-explain');
+
+      saveLocally.style.display = 'block';
+
+      var localStorageCheckBox = document.getElementById('dg-local-storage');
+
+      if (localStorage.getItem(getLocalStorageHash(gui, 'isLocal')) === 'true') {
+        localStorageCheckBox.setAttribute('checked', 'checked');
+      }
+
+      function showHideExplain() {
+        explain.style.display = gui.useLocalStorage ? 'block' : 'none';
+      }
+
+      showHideExplain();
+
+      // TODO: Use a boolean controller, fool!
+      dom.bind(localStorageCheckBox, 'change', function() {
+        gui.useLocalStorage = !gui.useLocalStorage;
+        showHideExplain();
+      });
+
+    }
+
+    var newConstructorTextArea = document.getElementById('dg-new-constructor');
+
+    dom.bind(newConstructorTextArea, 'keydown', function(e) {
+      if (e.metaKey && (e.which === 67 || e.keyCode == 67)) {
+        SAVE_DIALOGUE.hide();
+      }
+    });
+
+    dom.bind(gears, 'click', function() {
+      newConstructorTextArea.innerHTML = JSON.stringify(gui.getSaveObject(), undefined, 2);
+      SAVE_DIALOGUE.show();
+      newConstructorTextArea.focus();
+      newConstructorTextArea.select();
+    });
+
+    dom.bind(button, 'click', function() {
+      gui.save();
+    });
+
+    dom.bind(button2, 'click', function() {
+      var presetName = prompt('Enter a new preset name.');
+      if (presetName) gui.saveAs(presetName);
+    });
+
+    dom.bind(button3, 'click', function() {
+      gui.revert();
+    });
+
+//    div.appendChild(button2);
+
+  }
+
+  function addResizeHandle(gui) {
+
+    gui.__resize_handle = document.createElement('div');
+
+    common.extend(gui.__resize_handle.style, {
+
+      width: '6px',
+      marginLeft: '-3px',
+      height: '200px',
+      cursor: 'ew-resize',
+      position: 'absolute'
+//      border: '1px solid blue'
+
+    });
+
+    var pmouseX;
+
+    dom.bind(gui.__resize_handle, 'mousedown', dragStart);
+    dom.bind(gui.__closeButton, 'mousedown', dragStart);
+
+    gui.domElement.insertBefore(gui.__resize_handle, gui.domElement.firstElementChild);
+
+    function dragStart(e) {
+
+      e.preventDefault();
+
+      pmouseX = e.clientX;
+
+      dom.addClass(gui.__closeButton, GUI.CLASS_DRAG);
+      dom.bind(window, 'mousemove', drag);
+      dom.bind(window, 'mouseup', dragStop);
+
+      return false;
+
+    }
+
+    function drag(e) {
+
+      e.preventDefault();
+
+      gui.width += pmouseX - e.clientX;
+      gui.onResize();
+      pmouseX = e.clientX;
+
+      return false;
+
+    }
+
+    function dragStop() {
+
+      dom.removeClass(gui.__closeButton, GUI.CLASS_DRAG);
+      dom.unbind(window, 'mousemove', drag);
+      dom.unbind(window, 'mouseup', dragStop);
+
+    }
+
+  }
+
+  function setWidth(gui, w) {
+    gui.domElement.style.width = w + 'px';
+    // Auto placed save-rows are position fixed, so we have to
+    // set the width manually if we want it to bleed to the edge
+    if (gui.__save_row && gui.autoPlace) {
+      gui.__save_row.style.width = w + 'px';
+    }if (gui.__closeButton) {
+      gui.__closeButton.style.width = w + 'px';
+    }
+  }
+
+  function getCurrentPreset(gui, useInitialValues) {
+
+    var toReturn = {};
+
+    // For each object I'm remembering
+    common.each(gui.__rememberedObjects, function(val, index) {
+
+      var saved_values = {};
+
+      // The controllers I've made for thcommon.isObject by property
+      var controller_map =
+          gui.__rememberedObjectIndecesToControllers[index];
+
+      // Remember each value for each property
+      common.each(controller_map, function(controller, property) {
+        saved_values[property] = useInitialValues ? controller.initialValue : controller.getValue();
+      });
+
+      // Save the values for thcommon.isObject
+      toReturn[index] = saved_values;
+
+    });
+
+    return toReturn;
+
+  }
+
+  function addPresetOption(gui, name, setSelected) {
+    var opt = document.createElement('option');
+    opt.innerHTML = name;
+    opt.value = name;
+    gui.__preset_select.appendChild(opt);
+    if (setSelected) {
+      gui.__preset_select.selectedIndex = gui.__preset_select.length - 1;
+    }
+  }
+
+  function setPresetSelectIndex(gui) {
+    for (var index = 0; index < gui.__preset_select.length; index++) {
+      if (gui.__preset_select[index].value == gui.preset) {
+        gui.__preset_select.selectedIndex = index;
+      }
+    }
+  }
+
+  function markPresetModified(gui, modified) {
+    var opt = gui.__preset_select[gui.__preset_select.selectedIndex];
+//    console.log('mark', modified, opt);
+    if (modified) {
+      opt.innerHTML = opt.value + "*";
+    } else {
+      opt.innerHTML = opt.value;
+    }
+  }
+
+  function updateDisplays(controllerArray) {
+
+
+    if (controllerArray.length != 0) {
+
+      requestAnimationFrame(function() {
+        updateDisplays(controllerArray);
+      });
+
+    }
+
+    common.each(controllerArray, function(c) {
+      c.updateDisplay();
+    });
+
+  }
+
+  return GUI;
+
+})(dat.utils.css,
+"<div id=\"dg-save\" class=\"dg dialogue\">\n\n  Here's the new load parameter for your <code>GUI</code>'s constructor:\n\n  <textarea id=\"dg-new-constructor\"></textarea>\n\n  <div id=\"dg-save-locally\">\n\n    <input id=\"dg-local-storage\" type=\"checkbox\"/> Automatically save\n    values to <code>localStorage</code> on exit.\n\n    <div id=\"dg-local-explain\">The values saved to <code>localStorage</code> will\n      override those passed to <code>dat.GUI</code>'s constructor. This makes it\n      easier to work incrementally, but <code>localStorage</code> is fragile,\n      and your friends may not see the same values you do.\n      \n    </div>\n    \n  </div>\n\n</div>",
+".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n",
+dat.controllers.factory = (function (OptionController, NumberControllerBox, NumberControllerSlider, StringController, FunctionController, BooleanController, common) {
+
+      return function(object, property) {
+
+        var initialValue = object[property];
+
+        // Providing options?
+        if (common.isArray(arguments[2]) || common.isObject(arguments[2])) {
+          return new OptionController(object, property, arguments[2]);
+        }
+
+        // Providing a map?
+
+        if (common.isNumber(initialValue)) {
+
+          if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) {
+
+            // Has min and max.
+            return new NumberControllerSlider(object, property, arguments[2], arguments[3]);
+
+          } else {
+
+            return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] });
+
+          }
+
+        }
+
+        if (common.isString(initialValue)) {
+          return new StringController(object, property);
+        }
+
+        if (common.isFunction(initialValue)) {
+          return new FunctionController(object, property, '');
+        }
+
+        if (common.isBoolean(initialValue)) {
+          return new BooleanController(object, property);
+        }
+
+      }
+
+    })(dat.controllers.OptionController,
+dat.controllers.NumberControllerBox,
+dat.controllers.NumberControllerSlider,
+dat.controllers.StringController = (function (Controller, dom, common) {
+
+  /**
+   * @class Provides a text input to alter the string property of an object.
+   *
+   * @extends dat.controllers.Controller
+   *
+   * @param {Object} object The object to be manipulated
+   * @param {string} property The name of the property to be manipulated
+   *
+   * @member dat.controllers
+   */
+  var StringController = function(object, property) {
+
+    StringController.superclass.call(this, object, property);
+
+    var _this = this;
+
+    this.__input = document.createElement('input');
+    this.__input.setAttribute('type', 'text');
+
+    dom.bind(this.__input, 'keyup', onChange);
+    dom.bind(this.__input, 'change', onChange);
+    dom.bind(this.__input, 'blur', onBlur);
+    dom.bind(this.__input, 'keydown', function(e) {
+      if (e.keyCode === 13) {
+        this.blur();
+      }
+    });
+
+
+    function onChange() {
+      _this.setValue(_this.__input.value);
+    }
+
+    function onBlur() {
+      if (_this.__onFinishChange) {
+        _this.__onFinishChange.call(_this, _this.getValue());
+      }
+    }
+
+    this.updateDisplay();
+
+    this.domElement.appendChild(this.__input);
+
+  };
+
+  StringController.superclass = Controller;
+
+  common.extend(
+
+      StringController.prototype,
+      Controller.prototype,
+
+      {
+
+        updateDisplay: function() {
+          // Stops the caret from moving on account of:
+          // keyup -> setValue -> updateDisplay
+          if (!dom.isActive(this.__input)) {
+            this.__input.value = this.getValue();
+          }
+          return StringController.superclass.prototype.updateDisplay.call(this);
+        }
+
+      }
+
+  );
+
+  return StringController;
+
+})(dat.controllers.Controller,
+dat.dom.dom,
+dat.utils.common),
+dat.controllers.FunctionController,
+dat.controllers.BooleanController,
+dat.utils.common),
+dat.controllers.Controller,
+dat.controllers.BooleanController,
+dat.controllers.FunctionController,
+dat.controllers.NumberControllerBox,
+dat.controllers.NumberControllerSlider,
+dat.controllers.OptionController,
+dat.controllers.ColorController = (function (Controller, dom, Color, interpret, common) {
+
+  var ColorController = function(object, property) {
+
+    ColorController.superclass.call(this, object, property);
+
+    this.__color = new Color(this.getValue());
+    this.__temp = new Color(0);
+
+    var _this = this;
+
+    this.domElement = document.createElement('div');
+
+    dom.makeSelectable(this.domElement, false);
+
+    this.__selector = document.createElement('div');
+    this.__selector.className = 'selector';
+
+    this.__saturation_field = document.createElement('div');
+    this.__saturation_field.className = 'saturation-field';
+
+    this.__field_knob = document.createElement('div');
+    this.__field_knob.className = 'field-knob';
+    this.__field_knob_border = '2px solid ';
+
+    this.__hue_knob = document.createElement('div');
+    this.__hue_knob.className = 'hue-knob';
+
+    this.__hue_field = document.createElement('div');
+    this.__hue_field.className = 'hue-field';
+
+    this.__input = document.createElement('input');
+    this.__input.type = 'text';
+    this.__input_textShadow = '0 1px 1px ';
+
+    dom.bind(this.__input, 'keydown', function(e) {
+      if (e.keyCode === 13) { // on enter
+        onBlur.call(this);
+      }
+    });
+
+    dom.bind(this.__input, 'blur', onBlur);
+
+    dom.bind(this.__selector, 'mousedown', function(e) {
+
+      dom
+        .addClass(this, 'drag')
+        .bind(window, 'mouseup', function(e) {
+          dom.removeClass(_this.__selector, 'drag');
+        });
+
+    });
+
+    var value_field = document.createElement('div');
+
+    common.extend(this.__selector.style, {
+      width: '122px',
+      height: '102px',
+      padding: '3px',
+      backgroundColor: '#222',
+      boxShadow: '0px 1px 3px rgba(0,0,0,0.3)'
+    });
+
+    common.extend(this.__field_knob.style, {
+      position: 'absolute',
+      width: '12px',
+      height: '12px',
+      border: this.__field_knob_border + (this.__color.v < .5 ? '#fff' : '#000'),
+      boxShadow: '0px 1px 3px rgba(0,0,0,0.5)',
+      borderRadius: '12px',
+      zIndex: 1
+    });
+
+    common.extend(this.__hue_knob.style, {
+      position: 'absolute',
+      width: '15px',
+      height: '2px',
+      borderRight: '4px solid #fff',
+      zIndex: 1
+    });
+
+    common.extend(this.__saturation_field.style, {
+      width: '100px',
+      height: '100px',
+      border: '1px solid #555',
+      marginRight: '3px',
+      display: 'inline-block',
+      cursor: 'pointer'
+    });
+
+    common.extend(value_field.style, {
+      width: '100%',
+      height: '100%',
+      background: 'none'
+    });
+
+    linearGradient(value_field, 'top', 'rgba(0,0,0,0)', '#000');
+
+    common.extend(this.__hue_field.style, {
+      width: '15px',
+      height: '100px',
+      display: 'inline-block',
+      border: '1px solid #555',
+      cursor: 'ns-resize'
+    });
+
+    hueGradient(this.__hue_field);
+
+    common.extend(this.__input.style, {
+      outline: 'none',
+//      width: '120px',
+      textAlign: 'center',
+//      padding: '4px',
+//      marginBottom: '6px',
+      color: '#fff',
+      border: 0,
+      fontWeight: 'bold',
+      textShadow: this.__input_textShadow + 'rgba(0,0,0,0.7)'
+    });
+
+    dom.bind(this.__saturation_field, 'mousedown', fieldDown);
+    dom.bind(this.__field_knob, 'mousedown', fieldDown);
+
+    dom.bind(this.__hue_field, 'mousedown', function(e) {
+      setH(e);
+      dom.bind(window, 'mousemove', setH);
+      dom.bind(window, 'mouseup', unbindH);
+    });
+
+    function fieldDown(e) {
+      setSV(e);
+      // document.body.style.cursor = 'none';
+      dom.bind(window, 'mousemove', setSV);
+      dom.bind(window, 'mouseup', unbindSV);
+    }
+
+    function unbindSV() {
+      dom.unbind(window, 'mousemove', setSV);
+      dom.unbind(window, 'mouseup', unbindSV);
+      // document.body.style.cursor = 'default';
+    }
+
+    function onBlur() {
+      var i = interpret(this.value);
+      if (i !== false) {
+        _this.__color.__state = i;
+        _this.setValue(_this.__color.toOriginal());
+      } else {
+        this.value = _this.__color.toString();
+      }
+    }
+
+    function unbindH() {
+      dom.unbind(window, 'mousemove', setH);
+      dom.unbind(window, 'mouseup', unbindH);
+    }
+
+    this.__saturation_field.appendChild(value_field);
+    this.__selector.appendChild(this.__field_knob);
+    this.__selector.appendChild(this.__saturation_field);
+    this.__selector.appendChild(this.__hue_field);
+    this.__hue_field.appendChild(this.__hue_knob);
+
+    this.domElement.appendChild(this.__input);
+    this.domElement.appendChild(this.__selector);
+
+    this.updateDisplay();
+
+    function setSV(e) {
+
+      e.preventDefault();
+
+      var w = dom.getWidth(_this.__saturation_field);
+      var o = dom.getOffset(_this.__saturation_field);
+      var s = (e.clientX - o.left + document.body.scrollLeft) / w;
+      var v = 1 - (e.clientY - o.top + document.body.scrollTop) / w;
+
+      if (v > 1) v = 1;
+      else if (v < 0) v = 0;
+
+      if (s > 1) s = 1;
+      else if (s < 0) s = 0;
+
+      _this.__color.v = v;
+      _this.__color.s = s;
+
+      _this.setValue(_this.__color.toOriginal());
+
+
+      return false;
+
+    }
+
+    function setH(e) {
+
+      e.preventDefault();
+
+      var s = dom.getHeight(_this.__hue_field);
+      var o = dom.getOffset(_this.__hue_field);
+      var h = 1 - (e.clientY - o.top + document.body.scrollTop) / s;
+
+      if (h > 1) h = 1;
+      else if (h < 0) h = 0;
+
+      _this.__color.h = h * 360;
+
+      _this.setValue(_this.__color.toOriginal());
+
+      return false;
+
+    }
+
+  };
+
+  ColorController.superclass = Controller;
+
+  common.extend(
+
+      ColorController.prototype,
+      Controller.prototype,
+
+      {
+
+        updateDisplay: function() {
+
+          var i = interpret(this.getValue());
+
+          if (i !== false) {
+
+            var mismatch = false;
+
+            // Check for mismatch on the interpreted value.
+
+            common.each(Color.COMPONENTS, function(component) {
+              if (!common.isUndefined(i[component]) &&
+                  !common.isUndefined(this.__color.__state[component]) &&
+                  i[component] !== this.__color.__state[component]) {
+                mismatch = true;
+                return {}; // break
+              }
+            }, this);
+
+            // If nothing diverges, we keep our previous values
+            // for statefulness, otherwise we recalculate fresh
+            if (mismatch) {
+              common.extend(this.__color.__state, i);
+            }
+
+          }
+
+          common.extend(this.__temp.__state, this.__color.__state);
+
+          this.__temp.a = 1;
+
+          var flip = (this.__color.v < .5 || this.__color.s > .5) ? 255 : 0;
+          var _flip = 255 - flip;
+
+          common.extend(this.__field_knob.style, {
+            marginLeft: 100 * this.__color.s - 7 + 'px',
+            marginTop: 100 * (1 - this.__color.v) - 7 + 'px',
+            backgroundColor: this.__temp.toString(),
+            border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip +')'
+          });
+
+          this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px'
+
+          this.__temp.s = 1;
+          this.__temp.v = 1;
+
+          linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toString());
+
+          common.extend(this.__input.style, {
+            backgroundColor: this.__input.value = this.__color.toString(),
+            color: 'rgb(' + flip + ',' + flip + ',' + flip +')',
+            textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip +',.7)'
+          });
+
+        }
+
+      }
+
+  );
+
+  var vendors = ['-moz-','-o-','-webkit-','-ms-',''];
+
+  function linearGradient(elem, x, a, b) {
+    elem.style.background = '';
+    common.each(vendors, function(vendor) {
+      elem.style.cssText += 'background: ' + vendor + 'linear-gradient('+x+', '+a+' 0%, ' + b + ' 100%); ';
+    });
+  }
+
+  function hueGradient(elem) {
+    elem.style.background = '';
+    elem.style.cssText += 'background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);'
+    elem.style.cssText += 'background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
+    elem.style.cssText += 'background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
+    elem.style.cssText += 'background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
+    elem.style.cssText += 'background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'
+  }
+
+
+  return ColorController;
+
+})(dat.controllers.Controller,
+dat.dom.dom,
+dat.color.Color = (function (interpret, math, toString, common) {
+
+  var Color = function() {
+
+    this.__state = interpret.apply(this, arguments);
+
+    if (this.__state === false) {
+      throw 'Failed to interpret color arguments';
+    }
+
+    this.__state.a = this.__state.a || 1;
+
+
+  };
+
+  Color.COMPONENTS = ['r','g','b','h','s','v','hex','a'];
+
+  common.extend(Color.prototype, {
+
+    toString: function() {
+      return toString(this);
+    },
+
+    toOriginal: function() {
+      return this.__state.conversion.write(this);
+    }
+
+  });
+
+  defineRGBComponent(Color.prototype, 'r', 2);
+  defineRGBComponent(Color.prototype, 'g', 1);
+  defineRGBComponent(Color.prototype, 'b', 0);
+
+  defineHSVComponent(Color.prototype, 'h');
+  defineHSVComponent(Color.prototype, 's');
+  defineHSVComponent(Color.prototype, 'v');
+
+  Object.defineProperty(Color.prototype, 'a', {
+
+    get: function() {
+      return this.__state.a;
+    },
+
+    set: function(v) {
+      this.__state.a = v;
+    }
+
+  });
+
+  Object.defineProperty(Color.prototype, 'hex', {
+
+    get: function() {
+
+      if (!this.__state.space !== 'HEX') {
+        this.__state.hex = math.rgb_to_hex(this.r, this.g, this.b);
+      }
+
+      return this.__state.hex;
+
+    },
+
+    set: function(v) {
+
+      this.__state.space = 'HEX';
+      this.__state.hex = v;
+
+    }
+
+  });
+
+  function defineRGBComponent(target, component, componentHexIndex) {
+
+    Object.defineProperty(target, component, {
+
+      get: function() {
+
+        if (this.__state.space === 'RGB') {
+          return this.__state[component];
+        }
+
+        recalculateRGB(this, component, componentHexIndex);
+
+        return this.__state[component];
+
+      },
+
+      set: function(v) {
+
+        if (this.__state.space !== 'RGB') {
+          recalculateRGB(this, component, componentHexIndex);
+          this.__state.space = 'RGB';
+        }
+
+        this.__state[component] = v;
+
+      }
+
+    });
+
+  }
+
+  function defineHSVComponent(target, component) {
+
+    Object.defineProperty(target, component, {
+
+      get: function() {
+
+        if (this.__state.space === 'HSV')
+          return this.__state[component];
+
+        recalculateHSV(this);
+
+        return this.__state[component];
+
+      },
+
+      set: function(v) {
+
+        if (this.__state.space !== 'HSV') {
+          recalculateHSV(this);
+          this.__state.space = 'HSV';
+        }
+
+        this.__state[component] = v;
+
+      }
+
+    });
+
+  }
+
+  function recalculateRGB(color, component, componentHexIndex) {
+
+    if (color.__state.space === 'HEX') {
+
+      color.__state[component] = math.component_from_hex(color.__state.hex, componentHexIndex);
+
+    } else if (color.__state.space === 'HSV') {
+
+      common.extend(color.__state, math.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v));
+
+    } else {
+
+      throw 'Corrupted color state';
+
+    }
+
+  }
+
+  function recalculateHSV(color) {
+
+    var result = math.rgb_to_hsv(color.r, color.g, color.b);
+
+    common.extend(color.__state,
+        {
+          s: result.s,
+          v: result.v
+        }
+    );
+
+    if (!common.isNaN(result.h)) {
+      color.__state.h = result.h;
+    } else if (common.isUndefined(color.__state.h)) {
+      color.__state.h = 0;
+    }
+
+  }
+
+  return Color;
+
+})(dat.color.interpret,
+dat.color.math = (function () {
+
+  var tmpComponent;
+
+  return {
+
+    hsv_to_rgb: function(h, s, v) {
+
+      var hi = Math.floor(h / 60) % 6;
+
+      var f = h / 60 - Math.floor(h / 60);
+      var p = v * (1.0 - s);
+      var q = v * (1.0 - (f * s));
+      var t = v * (1.0 - ((1.0 - f) * s));
+      var c = [
+        [v, t, p],
+        [q, v, p],
+        [p, v, t],
+        [p, q, v],
+        [t, p, v],
+        [v, p, q]
+      ][hi];
+
+      return {
+        r: c[0] * 255,
+        g: c[1] * 255,
+        b: c[2] * 255
+      };
+
+    },
+
+    rgb_to_hsv: function(r, g, b) {
+
+      var min = Math.min(r, g, b),
+          max = Math.max(r, g, b),
+          delta = max - min,
+          h, s;
+
+      if (max != 0) {
+        s = delta / max;
+      } else {
+        return {
+          h: NaN,
+          s: 0,
+          v: 0
+        };
+      }
+
+      if (r == max) {
+        h = (g - b) / delta;
+      } else if (g == max) {
+        h = 2 + (b - r) / delta;
+      } else {
+        h = 4 + (r - g) / delta;
+      }
+      h /= 6;
+      if (h < 0) {
+        h += 1;
+      }
+
+      return {
+        h: h * 360,
+        s: s,
+        v: max / 255
+      };
+    },
+
+    rgb_to_hex: function(r, g, b) {
+      var hex = this.hex_with_component(0, 2, r);
+      hex = this.hex_with_component(hex, 1, g);
+      hex = this.hex_with_component(hex, 0, b);
+      return hex;
+    },
+
+    component_from_hex: function(hex, componentIndex) {
+      return (hex >> (componentIndex * 8)) & 0xFF;
+    },
+
+    hex_with_component: function(hex, componentIndex, value) {
+      return value << (tmpComponent = componentIndex * 8) | (hex & ~ (0xFF << tmpComponent));
+    }
+
+  }
+
+})(),
+dat.color.toString,
+dat.utils.common),
+dat.color.interpret,
+dat.utils.common),
+dat.utils.requestAnimationFrame = (function () {
+
+  /**
+   * requirejs version of Paul Irish's RequestAnimationFrame
+   * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+   */
+
+  return window.webkitRequestAnimationFrame ||
+      window.mozRequestAnimationFrame ||
+      window.oRequestAnimationFrame ||
+      window.msRequestAnimationFrame ||
+      function(callback, element) {
+
+        window.setTimeout(callback, 1000 / 60);
+
+      };
+})(),
+dat.dom.CenteredDiv = (function (dom, common) {
+
+
+  var CenteredDiv = function() {
+
+    this.backgroundElement = document.createElement('div');
+    common.extend(this.backgroundElement.style, {
+      backgroundColor: 'rgba(0,0,0,0.8)',
+      top: 0,
+      left: 0,
+      display: 'none',
+      zIndex: '1000',
+      opacity: 0,
+      WebkitTransition: 'opacity 0.2s linear'
+    });
+
+    dom.makeFullscreen(this.backgroundElement);
+    this.backgroundElement.style.position = 'fixed';
+
+    this.domElement = document.createElement('div');
+    common.extend(this.domElement.style, {
+      position: 'fixed',
+      display: 'none',
+      zIndex: '1001',
+      opacity: 0,
+      WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear'
+    });
+
+
+    document.body.appendChild(this.backgroundElement);
+    document.body.appendChild(this.domElement);
+
+    var _this = this;
+    dom.bind(this.backgroundElement, 'click', function() {
+      _this.hide();
+    });
+
+
+  };
+
+  CenteredDiv.prototype.show = function() {
+
+    var _this = this;
+
+
+
+    this.backgroundElement.style.display = 'block';
+
+    this.domElement.style.display = 'block';
+    this.domElement.style.opacity = 0;
+//    this.domElement.style.top = '52%';
+    this.domElement.style.webkitTransform = 'scale(1.1)';
+
+    this.layout();
+
+    common.defer(function() {
+      _this.backgroundElement.style.opacity = 1;
+      _this.domElement.style.opacity = 1;
+      _this.domElement.style.webkitTransform = 'scale(1)';
+    });
+
+  };
+
+  CenteredDiv.prototype.hide = function() {
+
+    var _this = this;
+
+    var hide = function() {
+
+      _this.domElement.style.display = 'none';
+      _this.backgroundElement.style.display = 'none';
+
+      dom.unbind(_this.domElement, 'webkitTransitionEnd', hide);
+      dom.unbind(_this.domElement, 'transitionend', hide);
+      dom.unbind(_this.domElement, 'oTransitionEnd', hide);
+
+    };
+
+    dom.bind(this.domElement, 'webkitTransitionEnd', hide);
+    dom.bind(this.domElement, 'transitionend', hide);
+    dom.bind(this.domElement, 'oTransitionEnd', hide);
+
+    this.backgroundElement.style.opacity = 0;
+//    this.domElement.style.top = '48%';
+    this.domElement.style.opacity = 0;
+    this.domElement.style.webkitTransform = 'scale(1.1)';
+
+  };
+
+  CenteredDiv.prototype.layout = function() {
+    this.domElement.style.left = window.innerWidth/2 - dom.getWidth(this.domElement) / 2 + 'px';
+    this.domElement.style.top = window.innerHeight/2 - dom.getHeight(this.domElement) / 2 + 'px';
+  };
+
+  function lockScroll(e) {
+    console.log(e);
+  }
+
+  return CenteredDiv;
+
+})(dat.dom.dom,
+dat.utils.common),
+dat.dom.dom,
+dat.utils.common);