var currentDirection = 0;
var currentPosition = 0;
var scrollSpeed = 10;
var scrollMax;

function doScroll()
{
  if (currentDirection == 0)
    return;

  if ((currentDirection == 1 && currentPosition < 0) || (currentDirection == -1 && currentPosition > - scrollMax))
  {
    currentPosition += currentDirection;
    document.getElementById('strip_images').style.top = currentPosition + 'px';

    window.setTimeout("doScroll()", scrollSpeed);
  }
}

function setDirection(direction)
{
  currentDirection = direction;
  scrollMax = document.getElementById('strip_images').getElementsByTagName('img').length * 54 - 270;
  if (currentDirection != 0)
    window.setTimeout("doScroll()", scrollSpeed);
}

function showImage(imageobj)
{
  document.getElementById('image').childNodes[0].src = imageobj.childNodes[0].src.replace('/thumbs/', '/photos/');
  for (i = 0; i < imageobj.parentNode.getElementsByTagName('img').length; i++)
    imageobj.parentNode.getElementsByTagName('img')[i].parentNode.className = "";

  imageobj.getElementsByTagName('img')[0].parentNode.className = "selected";
  document.getElementById('image').childNodes[0].setAttribute('alt', imageobj.getElementsByTagName('img')[0].getAttribute('alt'));
}

function showNextImage()
{
  for (i = 0; i < document.getElementById('strip_images').getElementsByTagName('a').length - 1; i++)
    if (document.getElementById('strip_images').getElementsByTagName('a')[i].className == "selected")
    {
      showImage(document.getElementById('strip_images').getElementsByTagName('a')[i + 1]);
      break;
    }
}

function showPrevImage()
{
  for (i = 1; i < document.getElementById('strip_images').getElementsByTagName('a').length; i++)
    if (document.getElementById('strip_images').getElementsByTagName('a')[i].className == "selected")
    {
      showImage(document.getElementById('strip_images').getElementsByTagName('a')[i - 1]);
      break;
    }
}

