Adding thumbnails in Javascript