Js refactor

Hello, your project is cool and I thought I'd offer some JavaScript assistance to you. The JavaScript is now smaller and more code is shared between the small and large image contexts.