// JavaScript Document
function showImg(img){
	EventCache.flush;
	document.getElementById('prevLink').href='javascript:void(0)';
	document.getElementById('nextLink').href='javascript:void(0)';
	for(i=0; i<imgCount; i++){
		document.getElementById('gal:'+i).href = 'javascript:void(0)';
	}
	imgIsLoaded = 0;
	img = (img>(imgCount-1)) ? 0 : img;
	img = (img<0) ? (imgCount-1) : img;
	show = img
	document.getElementById('imgCaption').innerHTML = '';
	new Effect.Fade('mainImg', { duration: 1, afterFinish: function(){ si = window.setInterval('swapImg()', 100) } });
}
function setLinks(){
	document.getElementById('prevLink').href='javascript:showImg(\'' + (parseFloat(show)-1) + '\')';
	document.getElementById('nextLink').href='javascript:showImg(\'' + (parseFloat(show)+1) + '\')';
	for(i=0; i<imgCount; i++){
		document.getElementById('gal:'+i).href = 'javascript:showImg(\'' + i + '\')';
	}
	document.getElementById('imgCaption').innerHTML = '<p>' + imgCaptionArray[show] + ' &copy; PBZ Photography Ltd</p>';
}
function swapImg(){
	window.clearInterval(si);
	document.getElementById('imgCaption').innerHTML = '<p>The next image is loading, please wait...</p>';
	document.getElementById('mainImg').src = 'images/user/' + imgArray[show];
	document.getElementById('mainImg').onload = function(){
		new Effect.Appear('mainImg', { duration: 1, afterFinish: function(){ setLinks() } });
	}
}
