function showPic (whichpic) {
  if (!document.getElementById) return true;
  document.getElementById('displayedimage').src = whichpic.href;
  if (whichpic.title) {
   document.getElementById('caption').childNodes[0].nodeValue = whichpic.title;
  } else {
   document.getElementById('caption').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
  }
  var gallery = document.getElementById("caseimages");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].className = '';
  }
	whichpic.className = 'current';
  return false;
}
function prepareGallery() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("caseimages")) return false;
  var gallery = document.getElementById("caseimages");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
      return showPic(this);
    }
  }
}
window.onload=prepareGallery;
