var imgTimer;
var currentImage=-1;
var galleryPlaying=true;
var galleryID = "imgGallery";
var galleryAction = "imgGalleryAction";
var galleryActionTitle = "spanGalleryAction";
function doGallery()
{
  if (galleryPlaying == true) { galleryPause(); }
  else { galleryPlay(); }
}
function getDisplay(which)
{
  display = "";
  if ((which+1) < 10) { display+= "0"; }
  display+= which+1;
  return display;
}
function showGallery(which)
{
  galleryPause();
  swapImage(galleryID,imageDir+galleryDir+"/slides/"+galleryImages[which]+".jpg",1);
  document.getElementById("spanGallery["+currentImage+"]").innerHTML = getDisplay(currentImage);
  currentImage=which;
  document.getElementById("spanGallery["+currentImage+"]").innerHTML = "<font color=#0F0464>"+getDisplay(currentImage)+"</font>";
}
function galleryPause()
{
  clearTimeout(imgTimer);
  document.getElementById(galleryAction).src=imageDir+"play.gif";
  document.getElementById(galleryActionTitle).innerHTML="play";
  galleryPlaying=false;
}
function galleryPlay()
{
  clearTimeout(imgTimer);
  var totalImages = galleryImages.length;
  if (currentImage >= 0)
  { document.getElementById("spanGallery["+currentImage+"]").innerHTML = getDisplay(currentImage); }
  if ((currentImage+1) >= totalImages) { currentImage = 0; } else { currentImage = currentImage+1; }
  swapImage(galleryID,imageDir+galleryDir+"/slides/"+galleryImages[currentImage]+".jpg",1);
  document.getElementById("spanGallery["+currentImage+"]").innerHTML = "<font color=#0F0464>"+getDisplay(currentImage)+"</font>";
  imgTimer = setTimeout("galleryPlay()",8000);
  document.getElementById(galleryAction).src=imageDir+"pause.gif";
  document.getElementById(galleryActionTitle).innerHTML="pause";
  galleryPlaying=true;
}
function swapImage(which,newImage,delay)
{
  if (document.all && window.print)
  {
    if (delay == null) { delay = 1; }
    document.getElementById(which).style.filter="blendTrans(duration="+delay+")";
    document.getElementById(which).filters.blendTrans(duration=delay).Apply();
    document.getElementById(which).filters.blendTrans.Play();
  }
  document.getElementById(which).src = newImage;
}
function moveGalleryDivs(isIE)
{
  var navLeft = (x - 780) / 2;
  if (isIE != 1) { navLeft = navLeft - 10; }
  if (navLeft < 0) { navLeft = 0; }
  document.getElementById("divGalleryThumb").style.left = (navLeft+226)+"px";
  document.getElementById("divGalleryArrow").style.left = (navLeft+226)+"px";
  if (isIE != 1)
  {
  }
}
function galleryShowThumb(which,isIE)
{
  var navLeft = (x - 780) / 2;
  if (isIE != 1) { navLeft = navLeft - 10; }
  if (navLeft < 0) { navLeft = 0; }
  var arrowLeft = navLeft+226+13+(20*which);
  var thumbLeft = arrowLeft - 52;
  if (thumbLeft < (navLeft+226)) { thumbLeft = navLeft+226; }
  if (isIE != 1)
  {
    arrowLeft = navLeft+226+13+(18*which);
    document.getElementById("divGalleryThumb").style.top = "325px";
    document.getElementById("divGalleryArrow").style.top = "379px";
  }
  document.getElementById("divGalleryThumb").style.left = thumbLeft+"px";
  document.getElementById("divGalleryArrow").style.left = arrowLeft+"px";
  document.getElementById("imgGalleryThumb").src = imageDir+galleryDir+"/slides/thumbs/"+galleryImages[which]+".jpg";
  document.getElementById("divGalleryThumb").style.display = "block";
  document.getElementById("divGalleryArrow").style.display = "block";
}
function galleryHideThumb()
{
  document.getElementById("divGalleryThumb").style.display = "none";
  document.getElementById("divGalleryArrow").style.display = "none";
}