Refactored building of HTML for the top link bar when viewing an image in lightbox