<!--  // start photos.js
                              /* GLOBAL VARIABLES */
var photoList = new Array();  /* list of photo files */
var titleList = new Array();  /* list of captions for photo files */
var pMax = "0";               /* maximum photos in lists */
var pCur = "0";               /* current photo index */
var filePath = "http://www.extranomical.com/";  /* Path for all files in lists */

var tourDetailsPage = "";     /* Tour details to open new window */
var tour_name = "";           /* Tour name for open_photo_window() */

var initFunction = new Array(); /* see initFunctionArray - ARRAY OF FUNCTIONS - photos_inits.js */

function prevPhoto()
{
 (pCur != "1") ? pCur-- : pCur = pMax;

 updPhoto(pCur);
}

function nextPhoto()
{
 (parseInt(pCur) != pMax) ? pCur++ : pCur = "1";

 updPhoto(pCur);
}

function updPhoto(inum)
{
  var i = parseInt(inum);
  
  document.curPhoto.src = photoList[i];
  pCur = i;

  document.getElementById("photoTitle").childNodes[0].nodeValue = titleList[i]; 
  document.getElementById("XofX").childNodes[0].nodeValue = "("+i+" of "+pMax+")";

  if (document.getElementById("fname"))
  {
    sTemp = photoList[i].substr(indexLast(photoList[i],"/")+1);
    document.getElementById("fname").childNodes[0].nodeValue = sTemp;  // ** TESTING **
  }
}

function doTourSelect()
{ // for photo page only
 var oTourForm = document.getElementById("tourForm");

 if ( oTourForm )
 {  
   var i = oTourForm.tourSelect.selectedIndex;
   var sValue = oTourForm.tourSelect.options[i].value;

   if (sValue != "X")
   {
     iValue = parseInt(sValue);
     if (iValue >= 0)
     {
        photoList.splice(0,photoList.length);  // clear array before reseting so length is correct
        titleList.splice(0,titleList.length);    
        initFunction[iValue]();
     }
   }
   else
   {
      if (i > 0) alert(">>> NO PHOTOS ARE AVAILABLE AT THIS TIME <<<");
   }
 }
}

function open_tour_window()
{  // for photo page only
  tour_win = window.open(tourDetailsPage,"tour_win");
}

function open_photo_window()
{
  var i = parseInt(pCur);
  window.open(photoList[i],"photo_win","height=175,width=225,scrollbars=yes,resizable=yes"); // ,"photo_win","width=800,scrollbars=yes,resizable=yes");
}

function doPhotosOnLoad(iTourNbr)
{
 var oTourForm = document.getElementById("tourForm");

 if ( oTourForm )
 {   // Photo Page selection list 
   oTourForm.tourSelect.options[0].selected = true;
   oTourForm.tourSelect.selectedIndex = 0;
 }

 initFunctionArray();
 initFunction[iTourNbr]();
}

function initStart()
{
  var oTourName = document.getElementById("tourName");
  ( oTourName ) ? oTourName.childNodes[0].nodeValue = tour_name : tourDetailsPage = "";
}

function initFinish()
{
  var oTourName = document.getElementById("tourName");
  if ( oTourName )
  {
    oTourName.childNodes[0].nodeValue = tour_name;
  }
  else // not photo page (no id="tourName")
  {
    tourDetailsPage = "";
    if ( photoList[0].length > 0 )
    {
      // use zero (tour icon photo) so shift all down one
      for (var i=photoList.length; i > 0; i--)
      {
        photoList[i] = photoList[i-1];
        titleList[i] = titleList[i-1];
      }
    }
  }

  pMax = photoList.length-1;
  pCur = "1";       /* Set current photo to first photo */
  updPhoto(pCur);   /* Show the current photo */
}


function indexLast(sString,sChar)
{
  var f = -1;
  for (var i=sString.length-1; i > 0 && f<0; i--)
  {
    if (sString.charAt(i) == sChar) f = i;
  }
  return f;
}

//  end photos.js -->

