

var tripwire = true;

function nextPhoto () {
	if (curPhoto < totalPhotos) {
		curPhoto++;
		renderCurPhoto ();
		if (curPhoto < totalPhotos) {
			theNextPhoto = curPhoto + 1;
			preloadPhoto ();
		}
		if (safariJunk) {
			safariJunk = false;
		} else {
			scrollerJump ();
		}
	}
	tripwire = false;
}

function prevPhoto () {
	if (curPhoto > 1) {
		curPhoto--;
		renderCurPhoto ();
		if (curPhoto > 2) {
			theNextPhoto = curPhoto - 1;
			preloadPhoto ();
		}
		scrollerJump ();
	}
}

function jumpToPhoto (newPhoto) {
	if (newPhoto == 1 && tripwire == true) return false;
	tripwire = false;
	curPhoto = newPhoto;
	renderCurPhoto ();
}

function renderCurPhoto () {
	hires = 'images/full/picture' + curPhoto + '.jpg';
	// Safari 2.04 image swap distortion bug
	if (isSafari2) {
		$('realPhoto').style.display = 'none';
		$('realPhoto').src = hires;
		$('realPhoto').style.display = 'block';
	}else{
		$('realPhoto').src = hires;
	}
	if (loadedPhotos[curPhoto] != true) {
		$('loading').style.display = 'block';
		eval ('img' + curPhoto + ' = new Image();');
		eval ('img' + curPhoto + '.src = hires;');
		$('realPhoto').onload = showPhoto;
	}
	//showCaption ();
	//$('photoTracker').innerHTML = curPhoto + ' of ' + totalPhotos;
}

function showCaption () {
	$('caption').innerHTML = myCaptions[curPhoto];
}

function preloadPhoto () {
	if (loadedPhotos[theNextPhoto] != true) {
		eval ('img' + theNextPhoto + ' = new Image();');
		eval ('img' + theNextPhoto + '.src = "images/full/picture' + theNextPhoto + '.jpg";');
		eval ('img' + theNextPhoto + '.onload = addToLoadedArray;');
	}
}

function addToLoadedArray() {
	loadedPhotos[theNextPhoto] = true;
}

function showPhoto () {
/*
	photoHold = new Image();
	photoHold.src = $('realPhoto').src;
	$('realPhoto').src = '../images/graphics/blank.gif';
	$('realPhoto').src = photoHold.src;

*/	
	$('realPhoto').display = 'none';
	$('realPhoto').display = 'block';
	$('realPhoto').className = '';
	$('loading').style.display = 'none';
	loadedPhotos[curPhoto] = true;
	//showCaption();
}

function moveKnob () {
	newScroll = Math.round((windowWidth - 13) * (newX / (scrollWidth - windowWidth))) * -1;
	$('knob').style.left = newScroll + 'px';
}

function scrollerJump () {
	// move scrollbar + thumbnail array
	newX = moves[curPhoto]; // newX is how far to move thumbnails, gotten from 'moves' Array
	if (newX < the_end) newX = the_end;
	pb.style.left = newX + 'px';
	moveKnob();
}

var loadedPhotos = new Array();









