js function for centering an image in its parent element