abstract out the gallery js into a proper js file