function showPic(whichpic,id) {
  if (typeof id == "undefined") { id = ""; }
  if (!document.getElementById("placeholder"+id)) return;
  var source = whichpic.getAttribute("picture");
  var placeholder = document.getElementById("placeholder"+id);
  placeholder.setAttribute("src",source);
  if (!document.getElementById("onderschrift"+id)) return;
  if (whichpic.getAttribute("title")) {
    var text = whichpic.getAttribute("title");
  } else {
    var text = "";
  }
  document.getElementById("onderschrift"+id).innerHTML = text;
}

function prepareGallery() {
  if (!document.getElementsByTagName) return;
  if (!document.getElementById) return;
  if (!document.getElementById("imagegallery")) return;
  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);

function swapImage(obj) {
  if (obj.src.match(/AI-Zuid-West-bewerkt_96.jpg$/g)) {
    obj.src="images/pand/Zuid-West_96.jpg"
  } 
  else if (obj.src.match(/Zuid-West_96.jpg$/g)) {
    obj.src="images/pand/AI-Noord-Oost-bewerkt_96.jpg"
  }
  else if (obj.src.match(/AI-Noord-Oost-bewerkt_96.jpg$/g)) {
    obj.src="images/pand/AI-Zuid-West-bewerkt_96.jpg"
  } 
}

function swapImage_old(obj) {
  if (obj.src.match(/AI-Zuid-West-bewerkt_96.jpg$/g)) {
    obj.src="images/pand/AI-Noord-Oost-bewerkt_96.jpg"
  } else {
    obj.src="images/pand/AI-Zuid-West-bewerkt_96.jpg"
  }
}
