/*---------------------------------------------------*/
/* Viper Core File : js_gallery.js                   */
/*                                                   */
/* Script to change photo displayed on gallery pages */
/* Also implements slideshow                         */
/*                                                   */
/*---------------------------------------------------*/

var ssTimer;
var SlideShowOn=0;

function showPic(strUrl,strTitle,intID) {
  // This function shows the large version of the thumbnail that the user has just clicked on.
  
  stopSlideshow();  
    
  if (document.getElementById) {
    document.getElementById('placeholder').src = strUrl;  
    document.getElementById('placeholder').alt = strTitle;
    photo_offset1 = intID;
  }

}

function showPicPrevious() {
 // This function shows the previous photo in the sequence
  
 if  (SlideShowOn==1) {
   return;
 }  
  
 // Increment photo counter
 photo_offset1 = photo_offset1 - 1;

 // Start from end when moving past first photo
 if (photo_offset1<0) {
   photo_offset1=photo_file_list.length-1;
 }  
  
 document.getElementById('placeholder').src = photo_file_list[photo_offset1];
 document.getElementById('placeholder').alt = album_name + " - Photo " + (photo_offset1+1) + " of " + photo_file_list.length; 
  
}

function showPicNext() {
 // This function shows the next photo in the sequence  
 if  (SlideShowOn==1) {
   return;
 }
  
 // Increment photo counter
 photo_offset1 = photo_offset1 + 1;

 // Start from beginning when end of list is reached
 if (photo_offset1>=photo_file_list.length) {
   photo_offset1=0;
 }  
  
 document.getElementById('placeholder').src = photo_file_list[photo_offset1];
 document.getElementById('placeholder').alt = album_name + " - Photo " + (photo_offset1+1) + " of " + photo_file_list.length;
  
}

function startSlideshow() {

 //var photos_links =document.getElementsByName("photo_links");
 //var photos_thumbs=document.getElementsByName("photo_thumbs");

 SlideShowOn = 1;

 // Display next photo in list
 document.getElementById('placeholder').src = photo_file_list[photo_offset1];
 document.getElementById('placeholder').alt = album_name + " - Photo " + photo_offset1 + " of " + photo_file_list.length;

 document.getElementById("button_previous").src = image_path + "player_reverse_grey.png";
 document.getElementById("button_start").src    = image_path + "player_slideshow_grey.png";
 document.getElementById("button_stop").src     = image_path + "player_stop.png";
 document.getElementById("button_next").src     = image_path + "player_play_grey.png";
 
 // Increment photo counter
 photo_offset1 = photo_offset1 + 1;

 // Start from beginning when end of list is reached
 if (photo_offset1>=photo_file_list.length) {
   photo_offset1=0;
 }

 ssTimer=setTimeout("startSlideshow()",3000)

}

function stopSlideshow() {
  // This function stops the timer that controls
  // the slideshow.
  clearTimeout(ssTimer);
  photo_offset1=photo_offset2;
  document.getElementById("button_previous").src = image_path + "player_reverse.png";
  document.getElementById("button_start").src    = image_path + "player_slideshow.png";
  document.getElementById("button_stop").src     = image_path + "player_stop_grey.png";
  document.getElementById("button_next").src     = image_path + "player_play.png";
  
  SlideShowOn = 0;
}

function enableTable(tableid,totaltables) {

  var strTableID;
  var strLinkID;

  for(x=1; x<=totaltables; x++) {
    strTableID = "table" + x;
    strLinkID  = "link" + x;
    element1 = document.getElementById(strTableID).style;
    element2 = document.getElementById(strLinkID).style;   

    if (x==tableid) {
      element1.display='block';
      element2.fontWeight = 'bold';
      photo_offset1=(x-1) * photospertable;      
    } else {
      element1.display='none';
      element2.fontWeight = 'normal';   
    }    
 
  }

  document.getElementById('placeholder').src = photo_file_list[photo_offset1];
  document.getElementById('placeholder').alt = album_name + " - Photo " + (photo_offset1+1) + " of " + photo_file_list.length;     

}

