updated gallery and viewer that works with jquery but not well