self.name = "main"; // If you are using frames, change "main" to the name of the frame that the photoalbum is in.

current = 0; // Sets the current picture being shown to the first one.

ActiveVar = 0; // Sets up the variable that counts the pictures.
var ActiveArray = new Array() // Sets up the active array.
for (loop=0; loop < MainVar; loop++) {
  ActiveArray[ActiveVar++] = new Fix(MainArray[loop].DatVal, MainArray[loop].PicVal, MainArray[loop].TitVal, MainArray[loop].CatVal, MainArray[loop].TxtVal)
}


function LoadNextPic()  { // Loads next picture for faster operation.
	NextImage = new Image();
	NextPic = current + 1;
    if (NextPic>=ActiveVar) NextPic = 0;
    NextImage.src = ActiveArray[NextPic].PicVal;
}

function NextSuzyPic() { // Flips to the next photo.
  current++;
  if (current>=ActiveVar) current = 0;
  ShowSuzyPic(current);
}

LoadThis = 0;
function PreLoader() { // If checked, preloads all images into cache.  Five second interval between pics.
  if (SuzyForm.PreloadPics.checked && ++LoadThis < MainVar) {
    ShowingImage = new Image();
    ShowingImage.src = MainArray[LoadThis].PicVal;
	window.status="Pre-Loading image... '" + MainArray[LoadThis].PicVal + "'";
    RunLoader();
  } else {
	window.status=" ";
  }
}

function PreviousSuzyPic() { // Flips to the previous photo.
  current--;
  if(current<0) current = ActiveVar - 1;
  ShowSuzyPic(current);
}

function RandomSuzyPic() { // Shows a random photo.
  randompic = Math.floor(Math.random()*ActiveVar);
  ShowSuzyPic(randompic);
}


function RunLoader() { // Pre-loads all images every 5 seconds, if checkbox is selected.
  timerLoad = setTimeout("PreLoader()",5000)
}

function RunSlideShow() { // Shuffles the photos in a slide show.
    timerSlideShow = setTimeout("NextSuzyPic();",document.SuzyForm.Timer.value*1000)
}


function ShowSuzyPic(newpic) { // Shows the photo and text on the page.
  current = newpic;
  document.getElementById("SuzySpot").innerHTML = '<img name="PicShowing" src=' + ActiveArray[current].PicVal + ' height=600 width=800 border=0>';
  document.getElementById("Journal").outerHTML = '<div id=journal><b>' + ActiveArray[current].TitVal + '</b><br><i>' + ActiveArray[current].DatVal + '</i><p>' + ActiveArray[current].TxtVal + '</div>';
   if (document.SuzyForm.SelectedMode[0].checked) {
    timerSlideShow = setTimeout("NextSuzyPic();",document.SuzyForm.Timer.value*1000)
	LoadNextPic();
  } else {
    LoadNextPic();
  }
}
