Tidied up. moved some functionalities into a jQuery plugin huba/jquery-slideshow.