
	showFirst = true;
	enableHighRes = true;
	
	photoPath = 'photos/';
	highResPath = 'photos/HR/';
	loadingImage = 'images/loading.gif';

	thumbnailData = document.getElementById('thumbnails');
	thumbnailImgs = new Array();	
	function selectThumbnail() {
		selectedThumb = this;
		el = document.getElementById('enlargedPhotoHolder');
		el.style.display = 'block';
		el = document.getElementById('photoCaption');
		el.innerHTML = this.alt;
		imgNameBits = this.src.split('/');
		imgName = imgNameBits[(imgNameBits.length)-1];
		selectedPhoto = photoPath+imgName;
		el = document.getElementById('enlargedPhoto');
		el.src = loadingImage;
		el.alt = this.alt;
		if (enableHighRes) {
			el.style.cursor = 'pointer';
			el.title = el.alt = 'Click to enlarge';
			el.onclick = function() {
				window.open(highResPath+imgName,'_blank');
			}
		}
		for(t=0;t<thumbnailImgs.length;t++) {
			thumb = thumbnailImgs[t];
			thumb.className = 'thumbnailUnselected';
		}
		this.className = 'thumbnailSelected';
		setTimeout('loadSelectedPhoto()',10);
	}
	
	function loadSelectedPhoto() {
		el = document.getElementById('enlargedPhoto');
		el.src = selectedPhoto;
	}
	
	for (i=0;i<thumbnailData.childNodes.length;i++) {
		child = thumbnailData.childNodes[i];
		if (child.alt) {
			thumbnailImgs[thumbnailImgs.length] = child;
			child.title = child.alt;
			child.onclick = selectThumbnail;
			child.className = 'thumbnailUnselected';
		}
	}
	
	function nextPhoto() {
		found = photoSet = false;
		for(t=0;t<thumbnailImgs.length;t++) {
			thumb = thumbnailImgs[t];
			if (found) {
				photoSet = true;
				break;
			}
			if (thumb == selectedThumb) found = true;
		}
		if (!photoSet) {
			thumb = thumbnailImgs[0];
		}
		thumb.onclick();
	}
	
	function prevPhoto() {
		found = photoSet = false;
		for(t=thumbnailImgs.length;t>=0;t--) {
			thumb = thumbnailImgs[t];
			if (found) {
				photoSet = true;
				break;
			}
			if (thumb == selectedThumb) found = true;
		}
		if (!photoSet) {
			thumb = thumbnailImgs[thumbnailImgs.length-1];
		}
		thumb.onclick();
	}
	
	if (showFirst) thumbnailImgs[0].onclick();
	
	
	
	
	// preload loading image
	// PRELOADING:
	preloadArray = new Array();
	function addPreload(imgSrc) { preloadArray[preloadArray.length] = imgSrc; }
	var preloadFlag = false;
	function preloadImages() {
		if (document.images) {
			for (i=0; i<preloadArray.length; i++) eval("preloadImage"+i+" = newImage('"+preloadArray[i]+"');");
			preloadFlag = true;
		}
	}
	function newImage(arg) {
		if (document.images) {
			rslt = new Image();
			rslt.src = arg;
			return rslt;
		}
	}
	
	// DEFINE PRELOAD IMAGES:
	addPreload(loadingImage);
	
	prevOnload = onload;
	onload = function() {
		preloadImages();
		prevOnload();
	}