f='R=LH=[];F"BQ"BGi-1|j-1)Hi*(22,j*(37])C=[];C125,35$$$]FHBQHBGi%2==j%2&i<=j&i>j+8BC75+i*12,j*2$$$V+"V+"V])}}R(onmousedown=LG!C[BR()}else G@(44)+(44))<60&&@Z*Z+Z*Z)<.1BZ=8;Z=8setInterval(Lz04$$25$40`;z061$1$23$38`;lineWidth=2;QHB020";zH^,	}FCBQCBG?*?+:*:<400&&i<jBA=_atan(:/?S=(@*+E*E)+@*+D*D)-(O>)+.5=S*_cos(A=S*_sin(AE;Dz~4]O,N;zO,N,5,Gj!=0BK}KText(j-1,O-3,N+3O+=E;N+=D;EDGO<2++}GO>23--}GN<2++}GN>38--}QH)G()+(N-	N-	)<100)C[j]=0};})~C[j][zbeginPath(K`()_Math.^[i][ZC[[V"+_flo_random()*10)U]-(e.pageQfi in O~N~1]Lfunction(eBKfillJ-8))/Gif(Ffj in E~D~B){@_sqrt(?(-O):(1]-N)$0,.push([;arc();(Z0UXJ(Z1UYJStyle=_PI*2,C^0";rect(000")*(stroke0BEE;O0BDD;N"#0]2]3]0)/2+15*=.995;	H^1]}};c.fff",1$`0K(O-H^or(=-';for(i in g='	$:?@BDEFGJKLNOQUVZ^_`z~')e=f.split(g[i]),f=e.join(e.pop());eval(f)
          N = c.getContext("2d");
c.width = w = 250;
c.height = h = 400;
Reset = function() {
//	Holes =	[[ X , Y ],...]
    Holes = [];
    for (var j = 0; j < 3; j++) {
        for (var i = 0; i < 3; i++) {
            if (i - 1 | j - 1){ Holes.push([i * (w - 30) / 2 + 15, j * (h - 30) / 2 + 15])}
        }
    }
//	Balls =	[[ X , Y , Xvel , Yvel , Color ],...]
    Balls = [];
//	Add the white ball
    Balls.push([125, 350, 0, 0, "#fff"]);
//	Make a triangle with balls
    for (j in Holes) {
        for (i in Holes) {
            if (i % 2 == j % 2 & i <= j & i >= -j + 8) {
                Balls.push([75 + i * 12, j * 20, 0, 0, "#" + Math.floor(Math.random() * 10) + "" + Math.floor(Math.random() * 10) + "" + Math.floor(Math.random() * 10)]);
            }
        }
    }
}
//	Set a new velocity with the mouse
onmousedown = function(e) {
    if (!Balls[0]) {
        Reset();
    } else if (Math.sqrt(Math.pow((Balls[0][0] - (e.pageX - 8)) / 4, 2) + Math.pow((Balls[0][1] - (e.pageY - 8)) / 4, 2)) < 60 && Math.sqrt(Math.pow(Balls[0][2], 2) + Math.pow(Balls[0][3], 2)) < .1) {
        Balls[0][2] = (Balls[0][0] - (e.pageX - 8)) / 8;
        Balls[0][3] = (Balls[0][1] - (e.pageY - 8)) / 8;
    }
};
//	Main loop
setInterval(function() {
    N.lineWidth = 2;
    N.strokeStyle = "#020";
    N.beginPath();
    N.fillStyle = "#040";
    N.rect(0, 0, w, h);
    N.fill();
    N.stroke();
    
    N.beginPath();
    N.fillStyle = "#060";
    N.rect(10, 10, w - 20, h - 20);
    N.fill();
    N.stroke();
    //	Draw holes
    for (i in Holes) {
        N.beginPath();
        N.fillStyle = "#000";
        N.arc(Holes[i][0], Holes[i][1], 10, Math.PI * 2, 0);
        N.fill();
        N.stroke();
    }
    for (j in Balls) {
        for (i in Balls) {
        	//	if ball 'i' and ball 'j' colides, change speeds
            if (Math.pow(Balls[i][0] - Balls[j][0], 2) + Math.pow(Balls[i][1] - Balls[j][1], 2) < 400 && i < j) {
                Angle = Math.atan((Balls[i][1] - Balls[j][1]) / (Balls[i][0] - Balls[j][0]));
                Velocity = (Math.sqrt(Math.pow(Balls[i][2], 2) + Math.pow(Balls[j][2], 2)) + Math.sqrt(Math.pow(Balls[i][3], 2) + Math.pow(Balls[j][3], 2))) * (-(Balls[j][0] > Balls[i][0]) + .5);
                Balls[i][2] = Velocity * Math.cos(Angle);
                Balls[i][3] = Velocity * Math.sin(Angle);
                Balls[j][2] = -Balls[i][2];
                Balls[j][3] = -Balls[i][3];
            }
        }
    //	Draw balls
        N.beginPath();
        N.fillStyle = Balls[j][4];
        N.arc(Balls[j][0], Balls[j][1], 10, Math.PI * 2, 0);
        N.fill();
        N.stroke(); 
        N.beginPath();
        N.fillStyle = "#fff";
        N.arc(Balls[j][0], Balls[j][1], 5, Math.PI * 2, 0);
        N.fill();
        if (j != 0) {
            N.fillStyle = "#000";
        }
        N.fillText(j-1, Balls[j][0] - 3, Balls[j][1] + 3);
  
    	//	Set Xvel and Yvel to X and Y position
        Balls[j][0] += Balls[j][2];
        Balls[j][1] += Balls[j][3];
   
    	//	Velocity reduction
        Balls[j][2] *= .995;
        Balls[j][3] *= .995;
    	//	Border collisions
        if (Balls[j][0] < 20) {
            Balls[j][2] = -Balls[j][2];
            Balls[j][0]++;
        }
        if (Balls[j][0] > w - 20) {
            Balls[j][2] = -Balls[j][2];
            Balls[j][0]--;
        }
        if (Balls[j][1] < 20) {
            Balls[j][3] = -Balls[j][3];
            Balls[j][1]++;
        }
        if (Balls[j][1] > h - 20) {
            Balls[j][3] = -Balls[j][3];
            Balls[j][1]--;
        }
        //	Remove balls over the holes
        for (i in Holes)
            if (Math.pow(Balls[j][0] - Holes[i][0], 2) + Math.pow(Balls[j][1] - Holes[i][1], 2) < 100) {
				Balls[j] = 0
            }
    }
})
//	Start
Reset();