var direction = -1;
var oldDirection = direction;
var currPhoto = -1;

function getImage(newPhoto)
{
	if (currPhoto >= 0)
	{
		document.getElementById("bigphoto_" + currPhoto).style.display = "none";
		document.getElementById("photo_" + currPhoto).style.border = "none";
	}
	document.getElementById("bigphoto_" + newPhoto).style.display = "block";
	document.getElementById("photo_" + newPhoto).style.border = "none";
	currPhoto = newPhoto;
}

function changeDirection(n) {
			oldDirection = direction;
            direction = n;
}


function move()
{
	for (i = 1; i<=nphoto; i++)
	{	
		box = document.getElementById('photo_'+i);
		box.style.left = parseInt(box.offsetLeft) + direction + 'px';
		if (direction < 0 && (parseInt(box.offsetLeft) + parseInt(box.offsetWidth)) < 0)
		{
			if (i===1){
				rboxn = nphoto;
			}else{
				rboxn = i - 1;
			}
			rbox = document.getElementById('photo_' + rboxn);
			box.style.left = parseInt(rbox.offsetLeft) + parseInt(rbox.offsetWidth) + 0 + 'px';
		}
		if (direction > 0 && parseInt(box.offsetLeft) > parseInt(photoCont.offsetWidth))
		{	
			if (i === nphoto){
				lboxn = 1;
			}else{
				lboxn = i + 1;
			}
			lbox = document.getElementById('photo_' + lboxn);
			xoff = 1;
			if (i === nphoto) xoff = 2;
			box.style.left = parseInt(lbox.offsetLeft) - parseInt(box.offsetWidth) + xoff + 'px';
		}
	}
}
