var imgOffset = 0;
var imgBoxOffset = 0;

function ChangeImage(imgCount, newImgOffset)
{
	// change offset
	imgOffset = newImgOffset;

	// check offset
	if(imgOffset < 0) { imgOffset = 0; }
	if(imgOffset > (imgCount - 1)) { imgOffset = imgCount - 1; }

	// box offset
	var newImgBoxOffset = Math.floor(imgOffset / 3) * 3;
	
	// change box of images
	if(newImgBoxOffset != imgBoxOffset) {
	
		// hide old box image
		for(var i = imgBoxOffset; i < (imgBoxOffset + 3); i++) {
			if($('img-box-item-' + i)) { $('img-box-item-' + i).hide(); }
		}
		
		// change box offset
		imgBoxOffset = newImgBoxOffset;

		// prev + next
		$('img-box-prev').hide();
		$('img-box-next').hide();

		if(imgCount > (imgBoxOffset + 3))
		{
			if(!imgBoxOffset) { $('img-box-next').show(); }
			else {
				$('img-box-prev').show();
				$('img-box-next').show();
			}
		}
		else
		if(imgBoxOffset) { $('img-box-prev').show(); }

		// show new box image
		for(var i = imgBoxOffset; i < (imgBoxOffset + 3); i++) {
			if($('img-box-item-' + i)) { $('img-box-item-' + i).show(); }
		}
	}

	return false;
}

function ListImageBox(imgCount, imgBoxDirection)
{
	// change image
	ChangeImage(imgCount, imgBoxOffset + imgBoxDirection);	

	return false;
}
