
function hidePanes() {
  currentPaneIndex=0;
  thumbnailOn=false;
}

function getCurrentPaneIndex() {
  return currentPaneIndex;
}

function displayNextPane() {
  currentPane = document.getElementById("imagegridpane" + currentPaneIndex);
  nextPaneIndex = currentPaneIndex + 1;
  nextPane=document.getElementById("imagegridpane" + nextPaneIndex);
  if (nextPane==null) {
    nextPaneIndex = 0;
    nextPane=document.getElementById("imagegridpane" + nextPaneIndex);
  }
  currentPane.style.display="none";
  nextPane.style.display="block";
  currentPaneIndex = nextPaneIndex;
}

function displayPane(direction) {
  currentPane = document.getElementById("imagegridpane" + currentPaneIndex);
  if (direction=="next") {
    difference = 1;
  }
  if (direction=="prev") {
    difference= -1;
  }
  otherPaneIndex = currentPaneIndex + difference;
  otherPane=document.getElementById("imagegridpane" + otherPaneIndex);
  if (otherPane==null) {
    otherPaneIndex=0;
    otherPane=document.getElementById("imagegridpane" + otherPaneIndex);
  }
  currentPane.style.display="none";
  otherPane.style.display="block";
  currentPaneIndex = otherPaneIndex;
}

/* Ignore these- they were preliminary.
function swapGalleryImage(galleryImageId, newImageSource, overrideClick) {
  galleryImage = document.getElementById(galleryImageId);
  oldImageSourceFile=new String(galleryImage.getAttribute("src"));
  if ((oldImageSourceFile.search("placeholder.gif")!=-1)||(overrideClick==true)) {
    galleryImage.src=newImageSource;
  }
}

function restoreGalleryImage(galleryImageId, newImageSource, overrideClick) {
  galleryImage = document.getElementById(galleryImageId);
  if (overrideClick == true) {
    galleryImage.src=newImageSource;
  }
}
*/

function swapGalleryImage(galleryImageId, newImageSource, forceSwap) {
  //errorArea("swapGalleryImage: thumbnailOn: " + thumbnailOn + ", newImageSource: " + newImageSource + ", forceSwap: " + forceSwap);
  if (forceSwap==true || thumbnailOn==false) {
    document.getElementById(galleryImageId).setAttribute("src", newImageSource);
  }
}

function restoreGalleryImage(galleryImageId, newImageSource, forceRestore) {
  swapGalleryImage(galleryImageId, newImageSource, forceRestore);
  //if (drawThemLines==true && thumbnailOn==false) {
  //  document.getElementById(galleryImageId).style.border="0px solid #5A0CA7";
  //}
}

function clickThumbnail(galleryImageId, newImageSource, forceSwap) {
  //errorArea("gallery image src: " + document.getElementById(galleryImageId).getAttribute("src") + ", newImageSource: " + newImageSource); 
  if (document.getElementById(galleryImageId).getAttribute("src")!=newImageSource || thumbnailOn==false) {
    swapGalleryImage(galleryImageId, newImageSource, true);
    //if (drawThemLines==true) {
    //  document.getElementById(galleryImageId).style.border="2px solid #5A0CA7";
    //}
    thumbnailOn=true;
  } else {
    //errorArea("restoreGalleryImage is about to be called.");
    restoreGalleryImage(galleryImageId, "../artistsproofs/images/placeholder.gif", true);
    thumbnailOn = false;
    //if (drawThemLines==true && thumbnailOn==false) {
    //  document.getElementById(galleryImageId).style.border="0px solid #5A0CA7";
    //}
    //errorArea("thumbnailOn: " + thumbnailOn);
  }
}

function handleThumbnailMouseOver(galleryImageId, newImageSource, forceSwap) {
  //if (drawThemLines==true) {
  //  document.getElementById(galleryImageId).style.border="2px solid #5A0CA7";
  //}
  swapGalleryImage(galleryImageId, newImageSource, forceSwap);
}

function handleThumbnailMouseOut(galleryImageId, newImageSource, forceRestore) {
  //errorArea("Le Mouseout is being called.");
  restoreGalleryImage(galleryImageId, newImageSource, forceRestore);
}
