function toggle(id) {
if (document.getElementById(id).style.display=='none') { document.getElementById(id).style.display='block'; } else { document.getElementById(id).style.display='none'; }
}


function showImg(whichImg) {
	if (!document.getElementById("imgMain")) return true;
	var source = whichImg.getAttribute("href");
	var imgMain = document.getElementById("imgMain");
	if (imgMain.nodeName != "IMG") return true;
	imgMain.setAttribute("src",source);

	var getAltTxt = whichImg.getAttribute("title");
	var altTxt = document.getElementById("imgMain");
	altTxt.setAttribute("alt",getAltTxt);

	return false;
}


function prepImgs() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("imgGallery")) return false;

	var gallery = document.getElementById("imgGallery");
	var links = gallery.getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {
		links[i].onclick = function() {
			return showImg(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(prepImgs);

