
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("caption")) return false;
	var text = whichpic.getAttribute("title") ? whichpic.getAttribute("title") : "." ;
	var description = document.getElementById("caption");
	if ( description.firstChild.nodeType == 3 ) {
		description.firstChild.nodeValue = text;
	}
	return false; // cancelling the default action of following the link
}


function prepareGallery() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("imgNav")) return false;
	var gallery = document.getElementById("imgNav");
	var links = gallery.getElementsByTagName("a");
	for ( var i=0; i < links.length; i++ ) {
		links[i].onclick = function() {
			 return showPic(this);
			 
		}
	}
}

function highlightTn() {
	if(!document.getElementsByTagName) return false;
	if (!document.getElementById("imgNav")) return false;
	var nav = document.getElementById("imgNav");
	var thumbs = nav.getElementsByTagName("img");
	for (var i=0; i<thumbs.length; i++) {
		thumbs[i].onclick = function() {
			this.style.borderColor = "#434D89";
		}
	}
}


//window.onload = prepareGallery;

window.onload = function() {
	prepareGallery();
	prepareURLs();
	highlightTn();
}