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.


function DisplayCategories() { // Lists out the categories.
  TotalCategories = SuzyCategory.length;

  for (loop=0; loop < TotalCategories; loop++)  
  {


    for (i=0; i < MainArray.length; i++) 
    {
        Cat = MainArray[i].CatVal;

        if (Cat == SuzyCategory[loop]) 
	{

            //document.write('<a href="#" onclick=\'ShowCategory("' + Cat + '");\'><img src="Website photos/' + MainArray[i].PicVal + '2.jpg"><br>' + Cat + '</a><br>');    
	    document.write('<a href="#" onclick=\'ShowCategory("' + Cat + '");\'>' + Cat + '</a><br>');  
break;     
	}
    }
  }
}


function LoadPiclist() 
{ // Loads initial list of pictures on web page.

	ShowCategory(SuzyCategory[0]);
}

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 PreviousPic() { // Flips to the previous photo.

i =  current - 1;
  if(i<0) i = ActiveVar - 1;
  ShowPic(i);
}


function ShowNextPic() { // Flips to the next photo.
  
  i = current + 1;
  if (i>=ActiveVar) i = 0;
  ShowPic(i);
}

LoadThis = 0;
function PreLoader() { // If checked, preloads all images into cache.  Five second interval between pics.
  if ( ++LoadThis < ActiveVar) {
    ShowingImage = new Image();
    ShowingImage.src = "Website photos/" + ActiveArray[LoadThis].PicVal + ".jpg";
	window.status="Pre-Loading image... '" + ActiveArray[LoadThis].PicVal + "'";
    RunLoader();
  } 
  else {
	window.status=" ";
  }
}




function RunLoader() { // Pre-loads all images every 5 seconds, if checkbox is selected.
  timerLoad = setTimeout("PreLoader()",3000)
}

function RunSlideShow() { // Shuffles the photos in a slide show.
    timerSlideShow = setTimeout("ShowNextPic();",5*1000)
}

function ShowCategory(picked) 
{ // Shows the pictures in that category.

  ActiveArray.length = 0;
  ActiveVar = 0;
  current = 0;
  document.getElementById('title').innerHTML = picked ;

  var PicList = ""

  for (loop=0; loop < MainVar; loop++) 
  {
    if (MainArray[loop].CatVal== picked) 
    {
	if (MainArray[loop].DatVal != "")
	{
		 document.getElementById('title').innerHTML = picked + "&nbsp; &nbsp;<small>" + MainArray[loop].DatVal + "</small>";		

	}
     ActiveArray[ActiveVar] = new Fix(MainArray[loop].DatVal, MainArray[loop].PicVal, MainArray[loop].TitVal, MainArray[loop].CatVal, MainArray[loop].TxtVal)
    PicList = PicList + "<li><a onClick='ShowPic(" + ActiveVar + ");'><img src='Website photos/" + MainArray[loop].PicVal + "tiny.jpg' id='thumb" + ActiveVar  + "'></a>";  
 

	ActiveVar++;
    } 
  }

  document.getElementById("PicSpot").innerHTML = PicList;
  ShowPic(0);

LoadThis =0;
//RunLoader();
}

function ShowPic(newpic) { // Shows the photo and text on the page.
  document.getElementById("thumb"+current).className = '';
  current = newpic;

  document.getElementById("PicShowing").src = "Website photos/" + ActiveArray[current].PicVal + '.jpg';
  document.getElementById("Journal").innerHTML = '<b>' + ActiveArray[current].TitVal + '</b>';

  document.getElementById("thumb"+newpic).className = 'hot';
  if (document.SuzyForm.SelectedMode.checked) 
  {

    timerSlideShow = setTimeout("ShowNextPic()", 5 * 1000);

  } 

    LoadNextPic();

}
























