C# solution to http://www.chilton.com/~jimw/ballclk.html