added support for a callback function

to be used in slideshow mode