function showPic(whichpic) 
{
	if (!document.getElementById("placeholder")) 
	{
	  return true;
	}
	else
	{  
		var source = whichpic.getAttribute("href");
		var placeholder = document.getElementById("placeholder");
		placeholder.setAttribute("src",source);
		if (!document.getElementById("desc")) 
		{
			return false;
		}
		else
		{ 
			if (whichpic.getAttribute("title")) 
			{
				var text = whichpic.getAttribute("title");
			} 
			else 
			{
				var text = "&nbsp;";
			}
			
			document.getElementById('desc').innerHTML = text;
			return false;
		}
	}
}

function prepareGallery() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("imagegallery")) return false;
  var gallery = document.getElementById("imagegallery");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
      return showPic(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(prepareGallery);
