function showLightbox( albumID )
{
  document.getElementById("lightbox").style.display = 'block';

  // Fade the screen to dark
  FadeIn(1);

  // Get the window dimensions
  windowWidth = document.documentElement.clientWidth;
  windowHeight = document.documentElement.clientHeight;

  // Define the size of the box
  boxWidth = 640;
  boxHeight = 480;


  // Determine where the box should be
  boxLeft = Math.floor( ( windowWidth - boxWidth ) / 2 );
  boxTop = Math.floor( ( windowHeight - boxHeight ) / 2 );

  document.getElementById("lightbox_contents").style.left = boxLeft + 'px';
  document.getElementById("lightbox_contents").style.top = boxTop + 'px';

  document.getElementById("lightbox_contents").style.display = 'block';

  NextImage(5000);

}

function hideLightbox()
{
  document.getElementById("lightbox_contents").style.display = 'none';

  FadeOut( 80 );
}

function NextImage( photoID )
{
  // In order to ensure that the photo reloads in the browser
  // we need to pass a parameter to the image src
  var now = new Date();
  document.getElementById('lightbox_image').src = 'files/photos/Resize_0604/' + photoID + '.jpg?' + now.getTime();

  document.getElementById('lightbox_text').innerHTML = 'Next: ' + photoID;
  photoID = photoID + 1;
  setTimeout( 'NextImage( ' + photoID + ')', 2000 );
}

function FadeIn( i )
{
  if( i <= 80 )
  {
    document.getElementById("lightbox").style.opacity = (i / 100);
    i = i + 5;
    setTimeout( 'FadeIn( ' + i + ')', 1 );
  }
}

function FadeOut( i )
{
  if( i > 0 )
  {
    document.getElementById("lightbox").style.opacity = (i / 100);
    i = i - 5;
    setTimeout( 'FadeOut( ' + i + ')', 1 );
  }
  else
  {
    document.getElementById("lightbox").style.display = 'none';
  }
}
