// JavaScript Document

function showPic(whichpic) {
	if (!document.getElementById("placeholder")) return true;
	var source = whichpic.getAttribute("href");
	var placeholder = document.getElementById("placeholder");
	if (placeholder.nodeName != "IMG") return true;
	placeholder.setAttribute("src",source);
	if (!document.getElementById("details")) return false;
	var text = whichpic.getAttribute("title") ? whichpic.getAttribute("title") : "";
	var details = document.getElementById("details");
	if (details.firstChild.nodeType == 3) {
	details.firstChild.nodeValue = 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; 1 < links.length; i++) {
		links[i].onclick = function() {
			return showPic(this);
		}
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

addLoadEvent(prepareGallery);
