added gallery controller and separated js select functions