var currentPic = 1;

function nextPic () {
	if (currentPic < numberOfPics) {
		currentPic = currentPic + 1;
		showPic(document.getElementById(currentPic));
	}	return false;
}

function prevPic () {
	if (currentPic > 1) {
		currentPic = currentPic - 1;
		showPic(document.getElementById(currentPic));
	}	return false;
}

function showPic (whichpic) {
  document.getElementById('placeholder').src = whichpic.href;
	document.getElementById('placeholdertxt').innerHTML = whichpic.title;
  currentPic = parseInt(whichpic.id);
	if (document.getElementById('caption')) {
		document.getElementById('caption').innerHTML = whichpic.name;
	}
	return false;
}

function prepareGallery() {
	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);
    }
  }
}
window.onload=prepareGallery;