function photoGallery() {
	//currentPic = 0	
	var photoBig = document.getElementById('photo-big')
	var totalPic = parseInt(document.getElementById('photogallery').className.replace('totalPic',''))-1;
	thumbs = document.getElementById('gallery-thumbs')
	if (thumbs) {
		thumbs = thumbs.getElementsByTagName('a');	
		
		lastThumb = thumbs[currentPic];
		for (var n = 0;n < thumbs.length;n++) {
			thumbs[n].onclick = showPhoto
		}
	}

function showPhoto(x) {
    currentPic = parseInt(x.id.replace('t',''));
    var thumbImg = x.getElementsByTagName('img')[0];
    lastThumb.className = 'photo-thumb';
    x.className = 'photo-thumb-o';		
    lastThumb = x;	
    photoBig.src = thumbImg.src;
    photoBig.atl = thumbImg.atl;
    document.getElementById('photo-caption').innerHTML = (captions[currentPic] != '') ? captions[currentPic] : '&nbsp;';
    document.getElementById('numcur').firstChild.nodeValue = currentPic+1;
    
    //var splitURL = thisURL.split("#");
    //document.location.href = splitURL[0] + currentPic
    
    return false;    
	}
	
	document.getElementById('next-photo').onclick = function () {
		if (currentPic < totalPic) {
		  showPhoto(thumbs[currentPic+1])
		} else {
		  showPhoto(thumbs[0])
		}
		return false;
	}
	document.getElementById('prev-photo').onclick = function () {
		if (currentPic > 0) {
		  showPhoto(thumbs[currentPic-1])
		} else {
		  showPhoto(thumbs[totalPic])
		}
		return false;
	}
}
addLoadEvent(photoGallery);
