// 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];
	$('year').innerHTML = "year: "+image_year[gallery_id][current_image_counter];
	$('medium').innerHTML = "medium: "+image_medium[gallery_id][current_image_counter];
	$('size').innerHTML = "size: "+image_size[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();
image_medium[0] = new Array();
image_size[0] = new Array();

//
//ONLY EDIT THE LINES BELOW
//


gallery_title[0] = "slideshow";

gallery_images[0][0] = './artwork/new_work/01_SJ.jpg';
gallery_captions[0][0] = 'And God rides high up in the Ordinary Sky';
image_year[0][0] = '2010';
image_medium[0][0] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][0] = '';

gallery_images[0][1] = './artwork/new_work/02_Tree2 Bipdem.jpg';
gallery_captions[0][1] = 'Tree2 Bipdem';
image_year[0][1] = '2010';
image_medium[0][1] = 'Archival inkjet prints with wax, encaustic and varnish';
image_size[0][1] = '';

gallery_images[0][2] = './artwork/new_work/03_BB 11-19-09-90642.jpg';
gallery_captions[0][2] = 'BB 11/19/09-90642';
image_year[0][2] = '2009';
image_medium[0][2] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][2] = '';

gallery_images[0][3] = './artwork/new_work/04_BB 11-19-09-90649.jpg';
gallery_captions[0][3] = 'BB 11/19/09-90649';
image_year[0][3] = '2009';
image_medium[0][3] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][3] = '';

gallery_images[0][4] = './artwork/new_work/08_BB August13.jpg';
gallery_captions[0][4] = 'BB August 13th';
image_year[0][4] = '2009';
image_medium[0][4] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][4] = '';

gallery_images[0][5] = './artwork/new_work/12_sw_zerkal.jpg';
gallery_captions[0][5] = 'Untitled';
image_year[0][5] = '2009';
image_medium[0][5] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][5] = '';

gallery_images[0][6] = './artwork/new_work/13_sw_zerkal.jpg';
gallery_captions[0][6] = 'Untitled';
image_year[0][6] = '2009';
image_medium[0][6] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][6] = '';

gallery_images[0][7] = './artwork/new_work/14_sw_zerkal.jpg';
gallery_captions[0][7] = 'Untitled';
image_year[0][7] = '2009';
image_medium[0][7] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][7] = '';

gallery_images[0][8] = './artwork/new_work/15_sw_zerkal.jpg';
gallery_captions[0][8] = 'Untitled';
image_year[0][8] = '2009';
image_medium[0][8] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][8] = '';

gallery_images[0][9] = './artwork/new_work/Seascape 3L.jpg';
gallery_captions[0][9] = 'Seascape 3L';
image_year[0][9] = '2010';
image_medium[0][9] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][9] = '21x37.75"';

gallery_images[0][10] = './artwork/new_work/BBMet_06.03.2010_S2257f_42x42_nails.jpg';
gallery_captions[0][10] = 'BBMet_06/03/10_S2257f';
image_year[0][10] = '2010';
image_medium[0][10] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][10] = '42x42"';

gallery_images[0][11] = './artwork/new_work/BBMet_03.15.2010_k12.2_17x33.jpg';
gallery_captions[0][11] = 'BBMet_03/15/10_k12.2';
image_year[0][11] = '2010';
image_medium[0][11] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][11] = '17x33"';

gallery_images[0][12] = './artwork/new_work/BBMet_04.16.2009_K1879_17x33.jpg';
gallery_captions[0][12] = 'BBMet_04/16/09_K1879';
image_year[0][12] = '2010';
image_medium[0][12] = 'Archival inkjet print on gelatin coated Zerkal';
image_size[0][12] = '17x33"';

gallery_images[0][13] = './artwork/new_work/BBMet_03.25.2010_k0728_21x21.jpg';
gallery_captions[0][13] = 'BBMet_03/25/10_k0728';
image_year[0][13] = '2010';
image_medium[0][13] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][13] = '21x21"';

gallery_images[0][14] = './artwork/new_work/BBMet_04.20.2010_K1151_21x21.jpg';
gallery_captions[0][14] = 'BBMet_04/20/10_K1151';
image_year[0][14] = '2010';
image_medium[0][14] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][14] = '21x21"';

gallery_images[0][15] = './artwork/new_work/BBMet_09.28.2010_s5137_42x63.jpg';
gallery_captions[0][15] = 'BBMet_09/28/10_s5137';
image_year[0][15] = '2010';
image_medium[0][15] = 'Archival inkjet print on gelatin coated Zerkall';
image_size[0][15] = '42x63"';

gallery_images[0][16] = './artwork/carbon_prints/H.jpg';
gallery_captions[0][16] = 'Guanyin';
image_year[0][16] = '2005';
image_medium[0][16] = 'Unique color carbon prints';
image_size[0][16] = '55\"x55\"';
