Index: trunk/FACT++/www/viewer/index.js
===================================================================
--- trunk/FACT++/www/viewer/index.js	(revision 17775)
+++ trunk/FACT++/www/viewer/index.js	(revision 17788)
@@ -884,53 +884,4 @@
 }
 
-function getIndex(id, mouse)
-{
-    var canv = document.getElementById(id);
-
-    var scale = 83;
-
-    var w = Math.min(canv.width/scale, canv.height/scale);
-
-    //ctx.translate(canv.width/2, canv.height/2);
-    //ctx.scale(w*2, w*2);
-    //ctx.scale(1, Math.sqrt(3)/2);
-    //ctx.translate(-0.5, 0);
-
-    mouse.x -= canv.width/2;
-    mouse.y -= canv.height/2;
-    mouse.x /= w*2;
-    mouse.y /= w*2;
-    mouse.y /= Math.sqrt(3)/2;
-    mouse.x -= -0.5;
-
-    if (isInside(0, 0, mouse))
-        return 0;
-
-    var cnt = 1;
-    for (var ring=1; ring<24; ring++)
-    {
-        for (var s=0; s<6; s++)
-        {
-            for (var i=1; i<=ring; i++)
-            {
-                var pos = new Position(s, ring, i);
-                if (pos.d() - pos.x > 395.75)
-                    continue;
-
-                if (isInside(pos.x, pos.y, mouse))
-                    return cnt;
-                cnt++;
-            }
-        }
-    }
-
-    if (isInside(7, -22, mouse))
-        return 1438;
-    if (isInside(7, 22, mouse))
-        return 1439;
-
-    return -1;
-}
-
 var inprogress = { };
 function moveElement(id, n, target, callback)
@@ -1232,4 +1183,32 @@
 initCameraCoordinates();
 
+function getIndex(id, mouse)
+{
+    var canv = document.getElementById(id);
+
+    var scale = 83;
+
+    var w = Math.min(canv.width/scale, canv.height/scale);
+
+    //ctx.translate(canv.width/2, canv.height/2);
+    //ctx.scale(w*2, w*2);
+    //ctx.scale(1, Math.sqrt(3)/2);
+    //ctx.translate(-0.5, 0);
+
+    mouse.x -= canv.width/2;
+    mouse.y -= canv.height/2;
+    mouse.x /= w*2;
+    mouse.y /= w*2;
+    mouse.y /= Math.sqrt(3)/2;
+    mouse.x -= -0.5;
+
+    for (var i=0; i<1440; i++)
+        if (isInside(coord[i][0], coord[i][1], mouse))
+            return i;
+
+    return -1;
+}
+
+
 function hueToRGB(hue)
 {
@@ -1314,7 +1293,4 @@
 }
 
-var positions = new Array(1440);
-
-
 function drawFullCam(id)
 {
