function prepareGallery()	{

	/* check the browser is capable of recognising the DOM objects
	   we need to implement the script - otherwise return false and allow the normal link to be executed */
	   
	if(!document.getElementsByTagName) return false;
	if(!document.getElementById) return false;
	if(!document.getElementById("thumbnails")) return false;

	
	/* get the reference to the thumbnails object and then create an array 
	   of all the <img> tags found in the array. To each tag assign a function to
	   the onclick method - which calls the showPic function. */
	   
	var gallery = document.getElementById("thumbnails");
	var links = gallery.getElementsByTagName("img");
	
	for(i = 0; i < links.length; i++) {
		
		links[i].onclick = function() {
			
			//alert(this)

			return showPic(this);
	/* If the showPic function returns true then the normal link will be followed,
	   if it returns false the normal link will be cancelled and the img src is the only
	    element on the page to be updated */
		}
		
	}
	
	
}


var displayingThisElement

function showPic(whichPic)  {
	
	/* If we don't find an image with the unique id then exit the function */
	if(!document.getElementById("displayImage")) return true;	
	
	/* get the alt attribute which contains the actual image filename we want to display,
	   and then get the reference to the actual image object itself */
	   
	var source = whichPic.getAttribute("alt");
	var website = "http://www." + whichPic.getAttribute("title")
	var displayImage = document.getElementById("displayImage")
	
	
	/* finally go get the new image and change the src attribute, returning false to prevent the
	   normal link from being executed */
	displayImage.setAttribute("src", "images/portfolio/large/" + source + ".jpg");
	displayImage.parentNode.href = website
	displayImage.title = "click to view the " + whichPic.getAttribute("title") + " website"
	
			if(document.getElementById(displayingThisElement)) {
			
			document.getElementById(displayingThisElement).style.display = "none"
		}
	
	
	if(document.getElementById(source)) {
		

		
		document.getElementById(source).style.display = "block"
		displayingThisElement = source

	}
	
	return false;
	
}