function currentPhoto()
{
	for (var i = 0; i < aPhotoList.length; i++) {
		if (document.getElementById('photoName').innerHTML == aPhotoList[i][0]) {
			return i;
		}
	}
	return 0;
}

function updateNav(j)
{
/*
	if (aPhotoList.length <= j+2) {
		document.getElementById('photoNavNext').innerHTML = '&nbsp;';
	} else {
		document.getElementById('photoNavNext').innerHTML = 'next';
	}
	if (j-1 == 0) {
		document.getElementById('photoNavPrevious').innerHTML = '&nbsp;';
	} else {
		document.getElementById('photoNavPrevious').innerHTML = 'previous';
	}
*/
}

function nextPhoto()
{
	var j = currentPhoto();
	if (aPhotoList.length > j+1) {
		var name = aPhotoList[j+1][0];
		showPhoto(name);
	}
	updateNav(j);
}

function previousPhoto()
{
	var j = currentPhoto();
	if (j > 0) {
		var name = aPhotoList[j-1][0];
		showPhoto(name);
	}
	updateNav(j);
	
}

function showPhoto(name)
{
	for (var i = 0; i < aPhotoList.length; i++) {	
		if(aPhotoList[i][0] == name) {
			document.getElementById('photoName').innerHTML = name;
			if (aPhotoList[i][2] != '') {
				document.getElementById('photoDescription').innerHTML = aPhotoList[i][2];
			} 
			else {
				document.getElementById('photoDescription').innerHTML = '&nbsp;';
			}
			
			if (aPhotoList[i][3] != '') {
				if (aPhotoList[i][4] != '') {
					document.getElementById('photoPhotographer').innerHTML = 'Photo by: <a href="' + aPhotoList[i][4] + '">' + aPhotoList[i][3] + '</a>';
				} 
				else {
					document.getElementById('photoPhotographer').innerHTML = 'Photo by: ' + aPhotoList[i][3];
				}
			} 
			else {
				document.getElementById('photoPhotographer').innerHTML = '&nbsp;';
			}
			
			document.getElementById('imgPhoto').src = aPhotoList[i][5].src;
			
			//if we are using safari and changing images, we need to update height and width
			if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
				
			
				if (aPhotoList[i][5].height != "") {
					document.getElementById('imgPhoto').height = aPhotoList[i][5].height;
				}
			
				if (aPhotoList[i][5].width) {
					document.getElementById('imgPhoto').width = aPhotoList[i][5].width;
				}
			}
			
			document.getElementById(name).className = 'Thumbs_On';
		} 
		else {
			document.getElementById(aPhotoList[i][0]).className = 'Thumbs';
		}
	}	
	
}


