here's a little info on collision detection


You can go to Sampe movie and drag the balls to see example

you can get the movie source for that example at
source

Basically what I've done is to calculate the distance from ball 1 and ball 2 and if it is less than or equal to 24 then they have collided.
PHP Code:
a=abs (element ("ball1").element ("ball2").x);
b=element ("ball1").element ("ball2").y;

distsqrt (a*a+b*b);