			var slideshow;

			document.onclick = function(){ slideshowActive = false; if( typeof self.slideshow == 'number' ) self.clearTimeout(self.slideshow) }

			function nextImage(){
				var curImage = getCurrentImage();
				var thumbs = document.getElementById('thumbs');
				for(i=0; i<aryPics.length; i++){
					if( aryPics[i] == curImage ){
						j = ( i == (aryPics.length - 1 )) ? 0 : i+1;
						objImage = getObjectFromPath(aryPics[j]);
						break;
					}
				}
				if( j == 0 ){
					slideshowActive = false;
				}
				setCurrentImage(objImage);
				if( slideshowActive == true){
					self.slideshow = self.setTimeout('nextImage()', delay);
				}
			}

		
			function prevImage(){
				var curImage = getCurrentImage();
				var thumbs = document.getElementById('thumbs');
				for(i=0; i<aryPics.length; i++){
					if( aryPics[i] == curImage ){
						j = ( i == 0 ) ? aryPics.length -1 : i-1;
						objImage = getObjectFromPath(aryPics[j]);
						break;
					}
				}
				setCurrentImage(objImage);
			}


			function getCurrentImage(){
				var mainImage = document.getElementById('mainImage');
				imgsrc = mainImage.src;
				lastSlash = imgsrc.lastIndexOf('/') + 1;
				imgsrc = imgsrc.substring(lastSlash)
				return imgsrc
			}


			function getObjectFromPath(path){
				var thumbs = document.getElementById('thumbs');
				for(i=0; i<thumbs.childNodes.length; i++){
					if( thumbs.childNodes[i].nodeType == 1 && thumbs.childNodes[i].nodeName =='A' ){
						thumbPath = thumbs.childNodes[i].toString();
						if( thumbPath.substr( thumbPath.lastIndexOf('/') + 1) == path ){
							return thumbs.childNodes[i];
						}
					}
				}
			}


			function setCurrentImage(img){
				var imageContainer = document.getElementById('imageContainer');
				imageContainer.childNodes[0].removeChild(imageContainer.childNodes[0].firstChild);
				mainImage = document.createElement('IMG');
				mainImage.src = img;
				mainImage.id = 'mainImage';
				imageContainer.childNodes[0].appendChild(mainImage);
				var thumbs = document.getElementById('thumbs');
				for(i=0; i<thumbs.childNodes.length; i++){
					if( thumbs.childNodes[i].nodeType == 1 && thumbs.childNodes[i].nodeName =='A' ){
						thumbs.childNodes[i].className='thumb';
						if( thumbs.childNodes[i] == img ){
							if( document.all ){ 
								j = i 
								document.getElementById('x-of-y').firstChild.data = i+1 + ' / ' + aryThumbs.length;
							}
							else{ 
								j = i-1 
								document.getElementById('x-of-y').firstChild.data = i + ' / ' + aryThumbs.length;
							}
							document.getElementById('caption').innerHTML = aryPicCaptions[j];
							document.getElementById('mainImage').title = aryPicAlts[j];
						}
					}
				}
				img.className = 'thumb-active';
			}


			function slideshow(){
				if( slideshowActive == true ){
					self.slideshow = self.setTimeout('nextImage()', delay);
				}
			}
