/*

 * GQADJPG - Greg's Quick and Dirty Javascript Photo Gallery

 */

 

self.name = "main";



current = 1; // start with the first picture

indexMaxA = 11; // number of photos in gallery A

indexMaxB = 15; // number of photos in gallery B

indexMaxC = 9; // number of photos in gallery C

indexMaxD = 20; // number of photos in gallery D... don't you get this by now?

indexMaxE = 13;

indexMaxF = 11;

indexMaxG = 19;

indexMaxH = 23;

indexMaxI = 26;

indexMaxJ = 13;

indexMax = indexMaxJ; // number of photos in current gallery

galleryName = "J";



function setGallery(gallery){

	galleryName = gallery;

	if( galleryName == "A" )

		indexMax = indexMaxA;

	if( galleryName == "B" )

		indexMax = indexMaxB;
		
	if( galleryName == "C" )
	
		indexMax = indexMaxC;

	if( galleryName == "D" )

		indexMax = indexMaxD;

	if( galleryName == "E" )

		indexMax = indexMaxE;

	if( galleryName == "F" )

		indexMax = indexMaxF;

    if( galleryName == "G" )
    
        indexMax = indexMaxG;

	if( galleryName == "H" )

		indexMax = indexMaxH;

	if( galleryName == "I" )
	
		indexMax = indexMaxI;
		
	if( galleryName = "J" )
		
		indexMax = indexMaxJ;

	if( current > indexMax)

		current = 1;

		

	displayPhoto(current);

}



function gotoPhoto(index){ // someone wants a specific photo

	current = index

	if (current > indexMax) // jic

		current=1;

	

	displayPhoto(current);

}



function displayPhoto(index){



	document.getElementById("photogallery").innerHTML = '<center><a href="javascript:nextPhoto()"><img id="currentphoto" src="' + galleryName + '/' + index + '-sachs.jpg" width="600" /></a></center>';

	displayThumbnails();

}



function nextPhoto(){ 

	current++;

	if (current > indexMax)

		current=1;

	

	displayPhoto(current);

}



function previousPhoto(){

	current--;

	if (current < 1)

		current=indexMax;

	

	displayPhoto(current);

}



function displayThumbnails(){

	i = 0;

	thumbHTML = "";

	while( i < indexMax){

		i++;

		if( i == current ){

			thumbHTML += '<img id="currentthumb" src="' + galleryName + 'thumbs/' + i + '-sachs.jpg" /></a>';

		} else {

			thumbHTML += '<a href="javascript:gotoPhoto(' + i + ')"><img id="photothumb" src="' + galleryName + 'thumbs/' + i + '-sachs.jpg" /></a>';

		}

		

	}

	document.getElementById("thumbnails").innerHTML = '<center>' + thumbHTML + '</center>';

}


