Thanks for sharing your work here. I was able to adapt your code for use with a papervison3d based gallery. Were you able to detect for the iPhone? Did you use user agent or use flash detection?