var lightBox = "lightBox"; // The element that holds the image
			var lightBoxCaption = "lightBox_Caption"; // The element that holds the image's caption
			var fadeOut = "fadeOut";
			var timer = null; // Timer we use to check if the image has finished loading
			var loaded = false; // Boolean check
			var xmlDoc = false;
			var screenImage = new Image(); //Object we use to preload our image
			var shotList = new Array();
			var captionList = new Array();
			var imagePrefix = "photos/finals08_";
			var imageSuffix = ".jpg";
			var nowViewing = 0;
			var showCaptions = true; // Controls display of captions - captions automatically disappear if text string is empty
			
			function fader(id, opacStart, opacEnd, millisec) {
			    //speed for each frame
			    var speed = Math.round(millisec / 100);
			    var timer = 0;

			    //determine the direction for the blending, if start and end are the same nothing happens
			    if(opacStart > opacEnd) {
			        for(i = opacStart; i >= opacEnd; i--) {
			            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			            timer++;
			        }
			    } else if(opacStart < opacEnd) {
			        for(i = opacStart; i <= opacEnd; i++)
			            {
			            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			            timer++;
			        }
			    }
			}

			
			function changeOpac(opacity, id) {
			
				//Function : change the opacity for different browsers
				var object = document.getElementById(id).style;
			    object.opacity = (opacity / 100);
			    object.MozOpacity = (opacity / 100);
			    object.KhtmlOpacity = (opacity / 100);
			    object.filter = "alpha(opacity=" + opacity + ")";
			} 
			
			function importXML() { 

				//Function : load the xml document
				if (document.implementation && document.implementation.createDocument) {
					xmlDoc = document.implementation.createDocument("", "", null);
					xmlDoc.onload = fnAddEntries;
				} else if (window.ActiveXObject) {
					xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.onreadystatechange = function () {
						if (xmlDoc.readyState == 4) fnAddEntries()
					};
				} else {
					alert('Your browser can\'t handle this script');
					return;
				}
				
				xmlDoc.load("photos.xml");
			}

			function fnAddEntries() {
			
				// Function : Traverses the XML doc
				
				// XML Format is as follows : the id makes up part of the file name along with the global vars 'imagePrefix' & 'imageSuffix'
				//<photos>
				//	<photo id="000">2nd Place - Nihilum Plasma</photo>
				//	<photo id="001">Pure Cartoons</photo>
				//</photos>
				data = xmlDoc.getElementsByTagName('photo');
				
				for(i=0; i<=data.length; i++) {
					if(data[i]) {
						var idvalue = imagePrefix + data[i].getAttribute("id") + imageSuffix;
						var capvalue = data[i].childNodes[0].nodeValue;
						shotList.push(idvalue);
						captionList.push(capvalue);
					}
				}
			
			}
			
			function fnCloseLightBox() {
			
				// Function : Hides the light box
				document.getElementById(lightBox).style.display = "none";
				document.getElementById(lightBoxCaption).style.display = "none";
				document.getElementById(fadeOut).style.display = "none";
			}
			
			function fnGoNextImage() {
			
				// Function : Move to the next image or first image if at the last
				nowViewing++;
				if (nowViewing >= shotList.length) { nowViewing = 0; }
				
				fnCloseLightBox();
				fnShowLightBox(nowViewing);
				
			}
			
			function fnGoPreviousImage() {
			
				// Function : Move to previous image or the last image if at first image
				nowViewing--;
				if (nowViewing < 0 ) { nowViewing = shotList.length - 1; }
				
				fnCloseLightBox();
				fnShowLightBox(nowViewing);
				
			}
			
			function fnShowLightBox(idvalue) {
				
				// Function : Loads up a new image and sets a timer to check for when the image has finished loading
				nowViewing = idvalue;
				
				screenImage = new Image();
				screenImage.src = shotList[idvalue];
				timer = setInterval("fnCheckImageLoaded()",250);
				
			}
			
			function fnCheckImageLoaded() {
			
				// Function : Checks to see if the image has finished loading before progressing to actually displaying it
				if (!screenImage.complete) {
					return;
				} else {
					clearInterval(timer);
					loaded = true;
					fnShowLoadedImage();
				}
			}

			function fnShowLoadedImage() {
				
				var el = document.getElementById(lightBox);
				var cap = document.getElementById(lightBoxCaption);
				
				var scrolledX, scrolledY;
				var centerX, centerY;
				
				changeOpac(0, lightBox);
				changeOpac(0, lightBoxCaption);
				
				el.style.backgroundImage = "url('" + screenImage.src + "')";
				
				if( self.pageYOffset ) {
					scrolledX = self.pageXOffset;
					scrolledY = self.pageYOffset;
				} else if( document.documentElement && document.documentElement.scrollTop ) {
					scrolledX = document.documentElement.scrollLeft;
					scrolledY = document.documentElement.scrollTop;
				} else if( document.body ) {
					scrolledX = document.body.scrollLeft;
					scrolledY = document.body.scrollTop;
				}

				if( self.innerHeight ) {
					centerX = self.innerWidth;
					centerY = self.innerHeight;
				} else if( document.documentElement && document.documentElement.clientHeight ) {
					centerX = document.documentElement.clientWidth;
					centerY = document.documentElement.clientHeight;
				} else if( document.body ) {
					centerX = document.body.clientWidth;
					centerY = document.body.clientHeight;
				}
				
				var leftOffset = scrolledX + (centerX - screenImage.width) / 2;
				var topOffset = scrolledY + (centerY - screenImage.height) / 2;
				
				if (topOffset <= 0) { topOffset = 40; }
				
				el.style.top = topOffset + "px";
				el.style.left = leftOffset + "px";
				el.style.width = screenImage.width + "px";
				el.style.height = screenImage.height + "px";
				el.style.display = "block";
			
				cap.style.top = topOffset + screenImage.height + "px";
				cap.style.left = leftOffset + "px";
				cap.style.width = screenImage.width + "px";
				cap.innerHTML = captionList[nowViewing];
				if ((!showCaptions) || (captionList[nowViewing] == "")) {
					cap.style.display = "none";
				} else {
					cap.style.display = "block";
				}
				
				loaded = false; // Reset this var ready for the next image to be loaded
				
				fader(lightBox, 0,100,500);
				fader(lightBoxCaption, 0,100,500);
				
				/*
				document.getElementById(fadeOut).style.top = "0px";
				document.getElementById(fadeOut).style.left = "0px";
				document.getElementById(fadeOut).style.width = "100%";
				document.getElementById(fadeOut).style.height = 2000 + 24 + "px";
				*/
				document.getElementById(fadeOut).style.display = "block";
			}