Balls SVG by accouting

by sikuda

HTML

<div id='paperRaphael'></div>
<audio id='sound_web'>
<source...

JavaScript

var width = 300;
var height = 550;
var w = 9;
var h = 21;
var paper = SVG('paperRaphael').size(width, height);
var audio = document.getElementById('sound_web');
var text_Result = paper.text("0.00"); //.move(300,50).font({ 'font-size': 48, family: 'Inconsolata' });
/* attr({
    'font-size': 48,
        'text-anchor': 'end'
});
 */
 var values = [];

function PlaySound(url) {
    if (window.HTMLAudioElement) {
        audio.play();
    } else {
        //for old IE and 1C
        document.all.sound_think.volume = 0
        document.all.sound_think.src = url_sound_think;
    }
}
var balls = [];
var clickBall = function () {
    if (this.onRight) {
        values[this.row] = this.col - 1;
        this.animate({
            transform: "t 0, 0"
        }, 100, "swing");
        for (var k = 10;
        (k > this.col) || !this.col; k--) {
            balls[this.row][k].animateWith(this, null, {
                transform: "t 0, 0"
            }, 100, "swing");
            balls[this.row][k].onRight = false;
        }
        this.onRight = false;
    } else {
        values[this.row] = this.col;
        this.animate({
            transform: "t " + (-width + 2 * 11 * w) + ", 0"
        }, 100, "swing");
        for (var k = 1;
        (k < this.col) || !this.col; k++) {
            balls[this.row][k].animateWith(this, null, {
                transform: "t " + (-width + 2 * 11 * w) + ", 0"
            }, 100, "swing");
            balls[this.row][k].onRight = true;
        }
        this.onRight = true;
    }
    PlaySound();
    var valueResult = 0;
    for (var n = 7; n > -3; n--) {
        if (n > 0) valueResult = valueResult + values[n] * Math.pow(10, n - 1);
        else if (n < 0) valueResult = valueResult + values[n] * Math.pow(10, n);
    }
    text_Result.attr({
        text: (valueResult.toFixed(2))
    })
}

for (var n = 7; n > -3; n--) {
    balls[n] = [];
    var c = height - 2 * h * n - 3 * 2 * h - 5 * Math.floor((n - 1) / 3);
    var line = paper.path("M...