
// --- Photo Gallery Navigational Control Program ---

// --- Programming and Code Copyright Notice:
// Developed by LCC Enterprises, 2004
// Contains original JavaScript programming code
// ©2004 by LCC Enterprises.   All rights reserved.
// ---
// This installation under license for use by the Barefoot Hawaiian, Inc.

// --- Description:
// Processes all events (clicks and mouseovers) in the photo image chooser pallet 
// and in particular controls which large image is displayed in the portfolio window
// and which text is displayed in the photo description area

// -------------------------------------------------------------------------
// --- Dependencies:

// This program requires that the following program files be preloaded before loading this program file:
//     > BrowserDetectLite.js

// This program requires that the following program files be loaded after loading this program file
// but before calling any functions in this program file.
//     > PhotoCaptionList.js
//       (This file contains the initPhotoGalleryCaptionList function)


// -------------------------------------------------------------------------
// Call Browser detection information script and store data into brwser object

  var brwsr = new BrowserDetectLite();


// -------------------------------------------------------------------------
// Define global variables:
// Previous Image Number in the Gallery in order to revert that
// thumbnail image upon clicking a new thumbnail image

  var prevgalleryNum = 0;
  var galleryName = null;
  var currentgalleryNum = 0;
  var previmageNum = 0;
  var imageName = null;
  var GallerySize = 35;
  var PhotoCaption1 = new Array();
  var PhotoCaption2 = new Array();
  var PhotoCaption3 = new Array();
  var PhotoCaption4 = new Array();
  var PhotoCaption5 = new Array();
  var PhotoCaption6 = new Array();
  var PhotoCaption7 = new Array();
  var PhotoCaption8 = new Array();
  initPhotoGalleryCaptionList();
  clearImage      = new Image();
  clearImage.src  = "genimages/spacer.gif";


// -------------------------------------------------------------------------
// Determine mouseover cursor for links.
// Standard is "pointer" for all modern browsers but previous IE browsers like IE4&5 understand
// only "hand" and produce script error with "pointer".  IE6 understands both.
// All versions of IE understand "hand".  NS understands only "pointer".
// Create global variable that can be referred to for correct cursor

  var LinkCursor = null;
  if (brwsr.isIE && !brwsr.isIE6up) {
    LinkCursor = "hand";              // Use "hand" if previous versions IE
  }
  else {
    LinkCursor = "pointer";           // Otherwise use "pointer"
  }



// -------------------------------------------------------------------------
// FUNCTION DECLARATIONS - 
// For functions called from this script
// -------------------------------------------------------------------------


// -------------------------------------------------------------------------
  function clearPhotoGallery() {
    var tnaili = 0;
    for (tnaili = 1; tnaili < GallerySize+1; tnaili++) {
      imageName = "imageID"+tnaili;
      document[imageName].src = clearImage.src;
      document[imageName].className = "gallerypalletimage";
      document.photocaptionarea.photocaptionfield.value = "";
    }
  }


// -------------------------------------------------------------------------
  function initPhotoGallery(galleryNum) {
    var tnaili = 0;
    var imageText = "";
    for (tnaili = 1; tnaili < GallerySize+1; tnaili++) {
      imageText = eval("PhotoCaption"+galleryNum+"["+tnaili+"]");
      if (imageText > "") {
        imageName = "imageID"+tnaili;
        if (tnaili < 10) {tnailiStr = "0"+tnaili;}
        else {tnailiStr = ""+tnaili;}
        document[imageName].src = "photos/img"+galleryNum+tnailiStr+"t.jpg";
        document[imageName].className = "gallerypalletimageused";
      }
    }
  }


// -------------------------------------------------------------------------
// FUNCTION DECLARATIONS - 
// For functions called from web page or from user initialized events
// -------------------------------------------------------------------------


// -------------------------------------------------------------------------
  function updateGallery(galleryNum) {
    if (prevgalleryNum != galleryNum) {
      if (prevgalleryNum != 0) {
        prevgalleryName = "galleryID"+prevgalleryNum;
        document[prevgalleryName].className = "galleryselectimage";
        clearPhotoGallery();
      }
      document[galleryName].className = "galleryselectimageselected";
      prevgalleryNum = galleryNum;
      document.largeimagearea.src = "photos/img"+galleryNum+"00.gif";
      document.photocaptionarea.photocaptionfield.value = "Click desired thumbnail to view full size photo";
      initPhotoGallery(galleryNum);
      previmageNum = 0;
      currentgalleryNum = galleryNum;
    }
  }


// -------------------------------------------------------------------------
  function gmon(galleryNum) {
    if (prevgalleryNum != galleryNum) {
      galleryName = "galleryID"+galleryNum;
      document[galleryName].style.cursor = LinkCursor;
      document[galleryName].className = "galleryselectimagemouseover";
      window.status = "";
    }
  }


// -------------------------------------------------------------------------
  function gmout(galleryNum) {
    if (prevgalleryNum != galleryNum) {
      galleryName = "galleryID"+galleryNum;
      document[galleryName].style.cursor = "auto";
      document[galleryName].className = "galleryselectimage";
      window.status = "";
    }
  }


// -------------------------------------------------------------------------
  function updateImageDisplayArea(imageNum) {
    var imageText = "";
    if (currentgalleryNum > 0) {imageText = eval("PhotoCaption"+currentgalleryNum+"["+imageNum+"]");}
    if (imageText > "") {
      if (imageNum < 10) {imageStrNum = "0"+imageNum;}
      else {imageStrNum = ""+imageNum;}
      if (previmageNum != imageNum) {
        if (previmageNum != 0) {
          previmageName = "imageID"+previmageNum;
          document[previmageName].className = "gallerypalletimageused";
        }
        imageName = "imageID"+imageNum;
        document[imageName].className = "gallerypalletimageselected";
        previmageNum = imageNum;
        document.largeimagearea.src = "photos/img"+currentgalleryNum+imageStrNum+"l.jpg";
        document.photocaptionarea.photocaptionfield.value = imageText;
      }
    }
  }


// -------------------------------------------------------------------------
  function mon(imageNum) {
    var imageText = "";
    if (currentgalleryNum > 0) {imageText = eval("PhotoCaption"+currentgalleryNum+"["+imageNum+"]");}
    if (imageText > "") {
      if (previmageNum != imageNum) {
        imageName = "imageID"+imageNum;
        document[imageName].style.cursor = LinkCursor;
        document[imageName].className = "gallerypalletimagemouseover";
        if (imageText > " ") {document[imageName].title = imageText;}
        window.status = imageText;
      }
    }
  }


// -------------------------------------------------------------------------
  function mout(imageNum) {
    var imageText = "";
    if (currentgalleryNum > 0) {imageText = eval("PhotoCaption"+currentgalleryNum+"["+imageNum+"]");}
    if (imageText > "") {
      if (previmageNum != imageNum) {
        imageName = "imageID"+imageNum;
        document[imageName].style.cursor = "auto";
        document[imageName].className = "gallerypalletimageused";
        window.status = "";
      }
    }
  }


