Javascript Ball color change - on Ball to ball collision
<p>I have 5 balls inside a square stage , which are moving and bouncing . I generated code for the balls , that they bounce when they reach the borders of the stage .With this code below, i detect how the balls reach the boundaries and they are bounced back inside the stage . Can anyone please help how to detect when the ball collides with each other or does anyone have a javascript code similar to what I need. On collision , the color of the collided balls should change . </p>

<pre><code>Ball.prototype.move = function(){
var diameter = this.radius * 2;                                               
var radius = this.radius;  
if (this.center.x - radius &lt; 0 || this.center.x + radius &gt; this.boundaryWidth ) {
  this.dx = -this.dx;
}
if (this.center.y - radius &lt; 0 || this.center.y  + radius &gt; this.boundaryHeight ) {
  this.dy = -this.dy;
}
this.placeAtCenter(this.center.x + this.dx ,this.center.y +this.dy);
</code></pre>
