Or, to set it up manually, put all the thumbnails in a hidden container, using display: none. Then instead of opening the first thumbnail directly, create a link that virtually clicks the first thumbnail:
Code: Select all
<a id="opener" href="javascript:;" onclick="return document.getElementById('gallery').onclick()">Open gallery</a>