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




function insertAfter(newElement, targetElement) {
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement, targetElement.nextSibling);
	} 
}




function preparePlaceholder() {
	// run tests to see that the browser supports the DOM
	if (!document.createElement) return false;
	if (!document.createTextNode) return false;
	if (!document.getElementById) return false;
    if (!document.getElementById("imagegallery")) return false;
	
	var placeholder = document.createElement("img");
	placeholder.setAttribute("id", "placeholder");
	placeholder.setAttribute("src", "images/placeholder1.jpg");
	placeholder.setAttribute("alt", "");
	
	
	
	
	var gallery = document.getElementById("imagegallery");
	gallery.parentNode.insertBefore(placeholder, gallery);
	
}


function setGallery() {
	// run tests to see that the browser supports the DOM, if not.... ignore this
	if (!document.getElementById) return false;
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById("imagegallery")) return false;
	
	var gallery = document.getElementById("imagegallery");
	var links = gallery.getElementsByTagName("a");
	
	for (var i=0; i<links.length; i++) {
		links[i].onmouseover = function() {
			return showPic(this);
			return false;
		}
	}
}
	
	
	




function showPic(myPic) {
	// image placeholder
	if (!document.getElementById("placeholder")) return true;
	var imageSource = myPic.getAttribute("href");
	var imagePlaceholder = document.getElementById("placeholder");
	imagePlaceholder.setAttribute("src", imageSource);
	
	
	
	return false;
}












	
	

addLoadEvent(setGallery);
addLoadEvent(preparePlaceholder);
	
	
	
	
	
	
	
	
	
	
	
	
