/*******************************************************************************

FILE: pctslidefunctions.js
AUTHOR: Lee Vine
VERSION: 1.0 - initial public release
DATE: 10/13/2007

--------------------------------------------------------------------------------

This file is part of the PCT Slide Show.
It contains the slideshow and related functions
and should NOT be modified.

It is free for anyone to use, but this header MUST be
included, and may not be modified.

*******************************************************************************/

document.write('<div id="imagesframe">');

document.write('<div id="imageswrapper"><div id="imgs">');
document.write('<table cellspacing="0" cellpadding="0" border="0"><tr>');
 
pi=0;

for (var ti=0;ti<photos.length;ti++)
  {
  document.write('<td valign="top" id="img-' + ti + '">');
  document.write('<img src="' + photofolder + '/' + photos[ti] + '" alt="' + alt + '" border="0" />');
  document.write('</td>');
  }
  
document.write('<td valign="top" id="img-' + photos.length + '">');
document.write('<img src="' + photofolder + '/' + photos[0] +  '" alt="' + alt + '" border="0" />');
document.write('</td></tr></table></div></div>');
document.write('<table cellspacing="0" cellpadding="0" border="0" width="425">');

document.write('</table>');
document.write('</div>');

var imges = document.getElementById('imgs');
var imgnum = document.getElementById('imagenumber');
var imgstyle = imges.style;
var slidedone = true;

function showphoto(direction)
{

if (!slidedone) return;

slidedone = false;
var oldpi = pi;
pi += direction;

if (pi >= photos.length)
  {
  pi = 0;
  }
else if (pi < 0)
  {
  pi = photos.length - 1;
  }

if (direction == 1)
  {
  slideleft((oldpi * photowidth) * -1, (pi * photowidth) * -1);
  }
else if (direction == -1)
  {
  slideright((oldpi * photowidth) * -1, (pi * photowidth) * -1);
  }

imgnum.innerHTML = (pi + 1) + ' of ' + photos.length;
return false;

}

function slideleft(current, limit)
{

if (current > limit || (limit == 0 && current > (photos.length * photowidth) * -1))
  {
  imgstyle.left = current + 'px';
  current -= slideincrement;
  setTimeout('slideleft(' + current + ',' + limit + ')', delay);
  }
else
  {
  imgstyle.left = limit + 'px';
  slidedone = true;
  }
  
}

function slideright(current, limit)
{

if (current == 0 && limit < 0)
  {
  current = photos.length * photowidth * -1;
  }
    
if (current < limit)
  {
  imgstyle.left = current + 'px';
  current += slideincrement;
  setTimeout('slideright(' + current + ',' + limit + ')', delay);
  }
else
  {
  imgstyle.left = limit + 'px';
  slidedone = true;
  }
  
}