Creating a dynamic gallery using and javascript OOP