preload_list= new Array("Images/2009/Cornfield2009.jpg","Images/2009/FieldoutsideWormit.jpg","Images/2009/Gold.jpg","Images/2009/Haybales2009.jpg","Images/2009/HaybalesnearLogie.jpg","Images/2009/OvercastSunset.jpg");

if (document.images) {
   var image_list= new Array();
   for (var preload_counter=0; preload_counter<preload_list.length; preload_counter++) {
   image_list[preload_counter]= new Image();
   image_list[preload_counter].src=preload_list[preload_counter];
   }
}

/*getElementByClass function assigns all elements with the .classname attribute to the thumbnails array. Through this identity the elements may be accessed. Therefore, with multiple images on a page, in addition to thumbnails, the thumbnails may be accessed independantly.With the document.images method, one does not know for certain the index for each image.*/
/*preload_thumbnails function loads the first image in the preload_list array above into the first thumbnail, etc.*/
var thumbnails=new Array();

function getElementByClass(classname) {
var inc=0;
var alltags=document.all? document.all : document.getElementsByTagName("*");
for(i=0; i<alltags.length; i++) {
if (alltags[i].className==classname)
thumbnails[inc++]=alltags[i];
	}
}
function preload_thumbnails() {
for(i=0;i<thumbnails.length;i++){
thumbnails[i].src=preload_list[i];
thumbnails[i].width=90;
	}
}
/*records an array of initial values for the position of each image, stored in variables, where image[0] indicates the first image in the preload_list array.*/

var image=new Array();
for(i=0;i<preload_list.length;i++) {
image[i]=i;
}

/*rotate function increments the initial value of each image and assigns this as an index into the image_list array, effectively incrementing the image located in each element of the thumbnails array. Important to set the loop's parameters to operate within the limits of the thumbnails array, and not the preload_list array. n must not exceed the number of elements in the thumbnails array .Otherwise the script would search for thumbnails[6] or thumbnails[7] etc, which do not exist. */  

function Rotate() {
for (n=0;n<thumbnails.length;n++) {
image[n]=(image[n] + 1) % preload_list.length;
thumbnails[n].src=image_list[image[n]].src;
	}
}

function RotateBack() {
for (n=0;n<thumbnails.length;n++) {
image[n]=(image[n]==0)? preload_list.length-1:image[n]-1
thumbnails[n].src=image_list[image[n]].src;
	}
}


