For some reason this piqued my interest. This may not be the best way to do it, but it seems to work, and was kind of interesting to do.
See this page on my site for more information, and this example slide-show to see it in action.
Attached is a zip file with the two PHP files, a sample PHP page using them, and some documentation.