//*********************************************************************
//
// Thumbnail slider
//
// Copyright (c) 2008, MFM Communication Software, Inc.
//
//*********************************************************************
//
// thumbslider.js
// $Id: thumbslider.js,v 1.2 2008/09/29 14:18:51 lbettag Exp $
//
// Scroll listing thumbnail images using next/last buttons
//
//*********************************************************************
//
// Tell jsjam.pl to not change these identifier and function names
//
// jsjam-keep:moveImg
// jsjam-keep:popCurrPhoto
// jsjam-keep:popNumPhotos
// jsjam-keep:swapImg

//*********************************************************************

function moveImg(dir)
{
  var num = popCurrPhoto;
  if (dir == "next" && popCurrPhoto < popNumPhotos - 1)
  {
    num = parseInt(popCurrPhoto) + 1;
  }
  else if (dir == "prev" && popCurrPhoto > 0)
  {
    num = parseInt(popCurrPhoto) - 1;
  }
  
  var contwidth = parseInt(document.getElementById('tsliderdiv').style.width);
  var imgleft = document.getElementById('thumb' + num).offsetLeft;
  var imgwidth = document.getElementById('thumb' + num).width;
  
  if (imgleft + imgwidth > contwidth)
  {
     document.getElementById('tsliderdiv').scrollLeft = (imgleft - (contwidth / 2));
  }
  if (imgleft < contwidth)
  {
     document.getElementById('tsliderdiv').scrollLeft = 0;
  }

  swapImg(num)
}

