if ($index % 2 == 0) $align = 'right'; else $align = 'left';
$align = $index % 2 ? 'left' : 'right';
var sqr = function(x) { return x * x; };
var summ = 0;
for (var i in red_points)
{
var minSLen = false;
for (var j in black_points)
{
var sLen = sqr(black_points[j].x - red_points[i].x) + sqr(black_points[j].y - red_points[i].y) + sqr(black_points[j].z - red_points[i].z);
if (minSLen === false || sLen < minSLen)
minSLen = sLen;
}
if (minSLen >= 0)
summ += Math.sqrt(minSLen);
}