// JavaScript Document

var thumbArray = new Array();
var largeArray = new Array();
var captionArray = new Array();
var galleryPosition = 0;


// Load just the thumbnails using a full path and filename
function preloadThumb()
{
	var args = preloadThumb.arguments

	for(var i=0; i<args.length; i++)		// for each argument
	{
		thumbArray[i] = new Image;			// create a new cell
		thumbArray[i].src = args[i];		// copy the argument into the cell
	}
}


// Load the large images based on the full path and filename
function preloadLarge()
{
	var args = preloadLarge.arguments

	for(var i=0; i<args.length; i++)
	{
		largeArray[i] = new Image;
		largeArray[i].src = args[i];
	}
}


// Load the large images based on the full path and filename
function preloadCaption()
{
	var args = preloadCaption.arguments

	for(var i=0; i<args.length; i++)
	{
		captionArray[i] = new String;
		captionArray[i] = args[i];
//		document.write(captionArray[5]);
	}
}


// changes the large image and the link to the full image
function changePicture(towhat)
{
	// defines how the link should change
	var large = '/images/art/adults/' + towhat;
	var full = '/images/art/adults/full/' + towhat;
	// defines local link
	var linkLocal = document.getElementById("tofull");
	
	// implements the change
	if (document.images)
	{
		document.images.large.src = towhat.src;
	}
}


function bawlsIncrement()
{
	if(largeArray[galleryPosition+1])
	{
		galleryPosition++;
	}
	else
	{
//		galleryPosition=0;
	}
	captionChange(captionArray[galleryPosition]);
	changePicture(largeArray[galleryPosition]);
}


function bawlsDecrement()
{
	if(galleryPosition == 0)
	{
//		make it go to the last item in the array
	}
	else
	{
	 	galleryPosition--;
	}
	captionChange(captionArray[galleryPosition]);
	changePicture(largeArray[galleryPosition]);
}


function gridChange(grid)
{
	if(largeArray[grid])
	{
		galleryPosition = grid;
	}
	captionChange(captionArray[galleryPosition]);
	changePicture(largeArray[galleryPosition]);
}


function getElement(id)
{
	if (document.getElementById)
		return document.getElementById(id);
	else if (document.all)
		return document.all[id];
	else
		return document.layers[id];
}





/*
// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];

  }
}
*/

