window.onload = function() {
	// check to see that the browser supports the getElementsByTagName method
	// if not, exit the loop 
	if (!document.getElementsByTagName) {
		return false; 
	} 
	// create an array of objects of each link in the document 
	var popuplinks = document.getElementsByTagName("img");
	// loop through each of these links (anchor tags) 	
	for (var i=0; i < popuplinks.length; i++) {	
		// if the link has a class of "popup"...	
		if (popuplinks[i].getAttribute("class") == "jclick") {
			popuplinks[i].title = "Click to zoom in";
			// add an onclick event on the fly to pass the href attribute	
			// of the link to our second function, openPopUp
			popuplinks[i].onclick = function() {	
				showBig(this);	
			return false; 	
			} 	
		}
	} 
} 

// onclick, hide maincontent and add a new DIV with pic in, with an onclick to run a funct that removes the added DIV and shows maincontent?

function showBig(screenimage) {
// This function uses a regular expression 'method" called match. It looks at the src of what you've clicked on and, if it contains "thumbs", it replaces the img src of the object screenimage (the thing you clicked on) with "pics" and the correct image number. NOTE: thumbs and pics have to be numerical only, and be gifs/jpgs.
// To Write: a thing that looks for any other "jclick" divs that have src pics and closes them.
	var imgsrc = screenimage.getAttribute("src");
	if (imgsrc.match(/thumbs/))
	{
		var popuplinks = document.getElementsByTagName("img"); // Make all the other links into gifs (eg zoom them out when you click to zoom in on another picture).
			for (var i=0; i < popuplinks.length; i++) {
				if (popuplinks[i].getAttribute("class") == "jclick") {
					// Change the img src to the gif
					var tozoomout=popuplinks[i].getAttribute("src")
					popuplinks[i].src="thumbs/"+tozoomout.match(/[0-9]+/)+".gif";
				}
			}
		screenimage.src="pics/"+imgsrc.match(/[0-9]+/)+".jpg";
		screenimage.title="Click to zoom out";
	}
	else
	{
		screenimage.src="thumbs/"+imgsrc.match(/[0-9]+/)+".gif";	
	}
}
