var photoBuffer = new Array(); //Builds a cached array of img elementsfunction preloadImages(){ 	var i; 	//Ok?	if (!document.getElementById) return; 	//Get the link container	var LinkContainer = document.getElementById("photonav"); 	//Nope?	if (!LinkContainer) return; 	//Get the links	var PhotoLinks = LinkContainer.getElementsByTagName("a"); 	//Loop thru creating the buffer	for (i = 0; i < PhotoLinks.length; i++)	{  		photoBuffer[i] = {			ImgPath : PhotoLinks[i].getAttribute("href"),			Description : (PhotoLinks[i].getAttribute("title") ? PhotoLinks[i].getAttribute("title") : ""),			Element : document.createElement("img")		}		photoBuffer[i].Element.src = PhotoLinks[i].getAttribute("href");		photoBuffer[i].Element.setAttribute("id", "placeholder");  		photoBuffer[i].Element.setAttribute("alt","my image gallery");	}} //Creates the container for the imagesfunction preparePlaceholder(){	//Ok?	if (!document.createElement) return false;	if (!document.createTextNode) return false;	if (!document.getElementById) return false; 	//No container?	if (!document.getElementById("photonav")) return false; 	//Create the containers	var photo = document.createElement("div");	photo.setAttribute("id","photo");	var content = document.getElementById("content");	var text = document.getElementById("text");	content.insertBefore(photo,text);	var gallery = document.getElementById("photonav");	var links = gallery.getElementsByTagName("a");	links[0].setAttribute("class","here");	var description = document.createElement("p");	description.setAttribute("id","description");	photo.appendChild(description);	var descriptionText = document.createTextNode("");	description.appendChild(descriptionText); 	var placeholder = document.createElement("img");	placeholder.setAttribute("id","placeholder");	placeholder.setAttribute("alt","my image gallery");	photo.insertBefore(placeholder,description); 	//Load the first image	showPic(0);} //Set up linksfunction prepareGallery() {	if (!document.getElementsByTagName) return false;	if (!document.getElementById) return false;	if (!document.getElementById("photonav")) return false;	var gallery = document.getElementById("photonav");	var links = gallery.getElementsByTagName("a");	for (var i=0; i < links.length; i++) {		links[i].onclick = function() {			return showPicByLink(this);		}	}} //Shows an imagefunction showPicByLink(PicLink){	//Loop thru	for (var i = 0; i < photoBuffer.length; i++)	{		if (PicLink.getAttribute("href").toLowerCase() == photoBuffer[i].ImgPath.toLowerCase())  		return showPic(i);	}} //Shows an imagefunction showPic(whichpic){	//No place holder?	if (!document.getElementById("placeholder")) return true;	if (!document.getElementById("description")) return true; 	//Set the links 	var gallery = document.getElementById("photonav");	var links = gallery.getElementsByTagName("a");	for (var i=0; i < links.length; i++) {		links[i].className="";	}	links[whichpic].className="here"; 	//Get the existing img	var placeholder = document.getElementById("placeholder"); 	//Replace 	placeholder.parentNode.replaceChild(photoBuffer[whichpic].Element, placeholder);	placeholder = null; 	//Put in description	var description = document.getElementById("description");	if (description.firstChild.nodeType == 3) {		description.firstChild.nodeValue = photoBuffer[whichpic].Description;	}	return false;} addLoadEvent(preloadImages);addLoadEvent(preparePlaceholder);addLoadEvent(prepareGallery);