// Gallery Function
function showGallery(articleId){
	/* container which display the gallery content */
	var to = $('gallerybody');
	/* container which contain the gallery to display */
	var from = $("gallery"+articleId);
	
	to.innerHTML = from.innerHTML;
}

//Stores URL's for a specific gallery
var gallery_images = new Array();
//Stores text for a specific image caption
var gallery_captions = new Array();
//Stores the title of the gallery
var gallery_title = new Array();
//Stores the year of the image
var image_year = new Array();
//Stores the medium for the image
var image_medium = new Array();
//Stores the size of the image
var image_size = new Array();

//Stores the current gallery being browsed
var gallery_id = 0;
//Keeps track of what image we are looking at
var current_image_counter = 0;
//Used for preloading images in gallery_images
var preload = new Array();


//Switch image gallery, reset the current_image_counter to 0
//Then calls load_image() to display first image from the new gallery
function switch_gallery(section_id) {
  gallery_id = section_id;
  switch_gallery_title();
  current_image_counter = 0;
  load_image();
}

//Load images into html 'img' container named 'photo'
//Also loads the corresponding caption for the photo - see function caption()
function load_image() {
  var myFx = new Fx.Style('photo', 'opacity', {duration:250});
  myFx.start(1,0).chain(function() {
    $('photo').src = gallery_images[gallery_id][current_image_counter];
  });
	$('photo').addEvent('load', function() {
	  myFx.start(0,1).chain(function() {
    	caption();
    	show_position();  
	  });
	});
}

//Updates current_image_counter by adding 1 
//If we're at the end of that gallery, it sets current_image_counter to 0 so that we start back at the beginning
//It then calls function load_image()
function next_image() {
	if (current_image_counter == gallery_images[gallery_id].length-1) {
		current_image_counter = 0;
	} else {
	  current_image_counter++;
	}
	load_image();
}

//Updates current_image_counter by subtracting 1 
//If we're at the beginning of that gallery, it sets current_image_counter to the last image slot so that we then load the last image
//It then calls function load_image()
function previous_image() {
	if (current_image_counter == 0) {
		current_image_counter = gallery_images[gallery_id].length-1;
	} else {
	  current_image_counter--;
	}
	load_image();
}

//Displays the caption for the current displayed image in a div named 'captions'
function caption() {
	$('captions').innerHTML = gallery_captions[gallery_id][current_image_counter];
	
}

//Sets the gallery title to be displayed in the page
function switch_gallery_title() {
    title_element = document.getElementById("slideshow_title");
    title_element.innerHTML = gallery_title[gallery_id];
}

//Displays which image we are on (and out of however many images we have in our slideshow)
function show_position() {
  position_element = document.getElementById("position")
  position_element.innerHTML = current_image_counter+1 + "/" + gallery_images[gallery_id].length;
}


gallery_images[0] = new Array();
gallery_captions[0] = new Array();
image_year[0] = new Array();
//
//ONLY EDIT THE LINES BELOW
//


gallery_images[0][0] = '../photography_collections/museum/muse01.jpg';
gallery_captions[0][0] = '<p>Smithsonian magazine cover image<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][1] = '../photography_collections/museum/muse02.jpg';
gallery_captions[0][1] = '<p>Glynne Equinoctial Sundial poster image<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][2] = '../photography_collections/museum/muse03.jpg';
gallery_captions[0][2] = '<p>Smithsonian magazine cover image<br><br>photographer: Stephen Pitkin<br></p>';

gallery_images[0][3] = '../photography_collections/museum/muse04.jpg';
gallery_captions[0][3] = '<p>Marune Chronometers<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][4] = '../photography_collections/museum/muse05.jpg';
gallery_captions[0][4] = '<p>Sothebys sale catalog - the Shepro Collection<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][5] = '../photography_collections/museum/muse06.jpg';
gallery_captions[0][5] = '<p>Masterpieces From the Time Museum<br><br> contributing photographer: Stephen Pitkin</p>';

gallery_images[0][6] = '../photography_collections/museum/muse07.jpg';
gallery_captions[0][6] = '<p>Fine Watches from the Atwood Collection<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][7] = '../photography_collections/museum/muse08.jpg';
gallery_captions[0][7] = '<p>Sothebys sale catalog<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][8] = '../photography_collections/museum/muse09.jpg';
gallery_captions[0][8] = '<p>The Time Musuem introductory catalog<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][9] = '../photography_collections/museum/muse10.jpg';
gallery_captions[0][9] = '<p>Sandglasses, Water-Clocks, & Fire-Clocks<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][10] = '../photography_collections/museum/muse11.jpg';
gallery_captions[0][10] = '<p>Astrolabes & Astrolabe Related Instruments<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][11] = '../photography_collections/museum/muse12.jpg';
gallery_captions[0][11] = '<p>SOULS GROWN DEEP, Vol. I<br>Art Reference Book<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][12] = '../photography_collections/museum/muse13.jpg';
gallery_captions[0][12] = '<p>SOULS GROWN DEEP, Vol. II<br>Art Reference Book<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][13] = '../photography_collections/museum/muse14.jpg';
gallery_captions[0][13] = '<p>Wallace Nutting Furniture Collection<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][14] = '../photography_collections/museum/muse15.jpg';
gallery_captions[0][14] = '<p>Samuel Colt Arms Collection<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][15] = '../photography_collections/museum/muse16.jpg';
gallery_captions[0][15] = '<p>Adler Planetarium Western Astrolabes catalog<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][16] = '../photography_collections/museum/muse17.jpg';
gallery_captions[0][16] = '<p>THE UNIVERSE UNVEILED collection catalog<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][17] = '../photography_collections/museum/muse18.jpg';
gallery_captions[0][17] = '<p>Eastern Astrolabes from the Adler Planetarium<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][18] = '../photography_collections/museum/muse19.jpg';
gallery_captions[0][18] = '<p>American Pocket Watches<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][19] = '../photography_collections/museum/muse20.jpg';
gallery_captions[0][19] = '<p>The Beauty of the Burst<br><br>contributing photographer: Stephen Pitkin</p>';

gallery_images[0][20] = '../photography_collections/museum/muse21.jpg';
gallery_captions[0][20] = '<p>Mike Slubowski Guitar Collection<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][21] = '../photography_collections/museum/muse22.jpg';
gallery_captions[0][21] = '<p>Fender Museum promotional poster<br><br>photographer: Stephen Pitkin</p>';

gallery_images[0][22] = '../photography_collections/museum/muse23.jpg';
gallery_captions[0][22] = '<p>The Quilts of Gees Bend, Vol. I<br>Art Reference Books<br><br>photographer: Stephen Pitkin</p>';
