I started with the skeleton code included with this very handy demo. If you like what you see, feel free to use any part of this. Here is the source code.