// Stores our current index value (of the image) that we're viewing
var iCurIndex = 0;

// Our image loader array
var img_loader = new Array();

// Preload all of our images
for ( var x = 0; x < imgs.length ; x++ )
{
	img_loader[x] = new Image();
	img_loader[x].src = imgs[x];		
}

function swapLeft( div_name )
{
	// Only move left if we can
	if ( iCurIndex > 0 )
	{
		iCurIndex--;

		swapImage( div_name, imgs[iCurIndex] );
	}
}

function swapRight( div_name )
{
	// Only move left if we can
	if ( iCurIndex+1 < imgs.length )
	{
		iCurIndex++;

		swapImage( div_name, imgs[iCurIndex] );
	}
}

// Function will simply swap an image
function swapImage( img_name, img_src )
{
	document[img_name].src=img_src;
	
	var photo_num_id = document.getElementById('photo_num');
	var photo_comment_id = document.getElementById('photo_comment');
	
	if ( photo_num_id )
	{
		photo_num_id.innerHTML = "Photo " + (iCurIndex + 1) + " of " + imgs.length;
	}
	
	if ( photo_comment_id )
	{
		if ( comments[iCurIndex] != 'undefined' )
		{
			photo_comment_id.innerHTML = comments[iCurIndex];
		}
		else
		{
			photo_comment_id.innerHTML = '';
		}
	}
}