No. No internet connection at home.
I'd say "fuck it", but I really want to learn how your design works, and what, if anything, about it is better than the one I already have. For educational purposes, if nothing else.
Ok. Check back tomorrow and you will have answers. You only need to slightly adjust your markup. You will need to add title attributes to your anchors.
EDIT: Updated with code examples.
The benefit in doing it "my" way is that your javascript is completely separated from the markup. I am using the DOM to hook into the markup to give it its behavior.
I did adjust your markup, but only to remove the onclick event handlers and the unordered list of descriptions. The descriptions are now apart of the anchor title for each thumbnail. I suppose I could have added them to the img alt description, or just left them alone and wrote something to handle it. Perhaps you can take what I have started and customize it for your needs.
imageGallery.jsfunction ChangeImageAndText(pic)
{
if(!document.getElementById) return false;
var source = pic.getAttribute("href");
var mainimg = document.getElementById("mainimg");
mainimg.setAttribute("src",source);
if (pic.getAttribute("title")) {
var text = pic.getAttribute("title");
} else {
var text = "";
}
var description = document.getElementById("text");
if (description.firstChild.nodeType == 3) {
description.firstChild.nodeValue = text;
}
return false;
}
function prepareImageLinks()
{
if(!document.getElementById) return false;
var humpics = document.getElementById("wrapper");
var links = humpics.getElementsByTagName("a");
for( var i=0; i < links.length; i++ )
{
links[i].onclick = function()
{
return ChangeImageAndText(this);
}
links[i].onkeypress = links[i].onclick;
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
addLoadEvent(prepareImageLinks);
The first function, showPic, handles the image & text swapping. prepareGallery() dynamically adds an onclick event handler to all links within "wrapper". addLoadEvent() is used to load the prepareGallery function when the page is finished loading.
The changes to your markup:
Here is where image text will be
If you disable javascript, or are using a crappy browser, then the links simply open the image in the current window. With javascript enabled, the image placeholder is swapped for the value in the href attribute of the anchor.
This could be improved for sure. But it's a start.
The goal would be a complete separation of your behaviors, styles, and markup, so that at is rawest, most simple presentation, the site is still usable.