refactor javascript code
refactor imagepanel js stuff