// 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] = "THE XINGU CHRONICLES PORTFOLIO";

gallery_images[0][0] = './galleri/xingu_paper/bilde01.jpg';
gallery_captions[0][0] = 'Panasonic';
image_year[0][0] = '1998';
image_medium[0][0] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][0] = 'Paper Size 30 x 22 inches';

gallery_images[0][1] = './galleri/xingu_paper/bilde02.jpg';
gallery_captions[0][1] = 'Visiting Village Storytellers';
image_year[0][1] = '1998';
image_medium[0][1] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][1] = 'Paper Size 30 x 22 inches';

gallery_images[0][2] = './galleri/xingu_paper/bilde03.jpg';
gallery_captions[0][2] = 'Under the Southern Cross';
image_year[0][2] = '1998';
image_medium[0][2] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][2] = 'Paper Size 30 x 22 inches';

gallery_images[0][3] = './galleri/xingu_paper/bilde04.jpg';
gallery_captions[0][3] = 'Village Video';
image_year[0][3] = '1998';
image_medium[0][3] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][3] = 'Paper Size 30 x 22 inches';

gallery_images[0][4] = './galleri/xingu_paper/bilde05.jpg';
gallery_captions[0][4] = 'Little Boy Power';
image_year[0][4] = '1998';
image_medium[0][4] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][4] = 'Paper Size 30 x 22 inches';

gallery_images[0][5] = './galleri/xingu_paper/bilde06.jpg';
gallery_captions[0][5] = 'Young Boy Fishing';
image_year[0][5] = '1998';
image_medium[0][5] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][5] = 'Paper Size 30 x 22 inches';

gallery_images[0][6] = './galleri/xingu_paper/bilde07.jpg';
gallery_captions[0][6] = 'Underwatergirls';
image_year[0][6] = '1998';
image_medium[0][6] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][6] = 'Paper Size 30 x 22 inches';

gallery_images[0][7] = './galleri/xingu_paper/bilde08.jpg';
gallery_captions[0][7] = 'Riverplay';
image_year[0][7] = '1998';
image_medium[0][7] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][7] = 'Paper Size 30 x 22 inches';

gallery_images[0][8] = './galleri/xingu_paper/bilde09.jpg';
gallery_captions[0][8] = 'Avian Prey';
image_year[0][8] = '1998';
image_medium[0][8] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][8] = 'Paper Size 30 x 22 inches';

gallery_images[0][9] = './galleri/xingu_paper/bilde10.jpg';
gallery_captions[0][9] = 'Riverbank Dawn';
image_year[0][9] = '1998';
image_medium[0][9] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][9] = 'Paper Size 30 x 22 inches';

gallery_images[0][10] = './galleri/xingu_paper/bilde11.jpg';
gallery_captions[0][10] = 'The Newborn';
image_year[0][10] = '1998';
image_medium[0][10] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][10] = 'Paper Size 30 x 22 inches';

gallery_images[0][11] = './galleri/xingu_paper/bilde12.jpg';
gallery_captions[0][11] = 'Roofbuilder';
image_year[0][11] = '1998';
image_medium[0][11] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][11] = 'Paper Size 30 x 22 inches';

gallery_images[0][12] = './galleri/xingu_paper/bilde13.jpg';
gallery_captions[0][12] = 'Basketweaver and Son';
image_year[0][12] = '1998';
image_medium[0][12] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][12] = 'Paper Size 30 x 22 inches';

gallery_images[0][13] = './galleri/xingu_paper/bilde14.jpg';
gallery_captions[0][13] = 'Spinning Cotton';
image_year[0][13] = '1998';
image_medium[0][13] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][13] = 'Paper Size 30 x 22 inches';

gallery_images[0][14] = './galleri/xingu_paper/bilde15.jpg';
gallery_captions[0][14] = 'Basketweaver';
image_year[0][14] = '1998';
image_medium[0][14] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][14] = 'Paper Size 30 x 22 inches';

gallery_images[0][15] = './galleri/xingu_paper/bilde16.jpg';
gallery_captions[0][15] = 'Turtle Egg Harvest';
image_year[0][15] = '1998';
image_medium[0][15] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][15] = 'Paper Size 30 x 22 inches';

gallery_images[0][16] = './galleri/xingu_paper/bilde17.jpg';
gallery_captions[0][16] = 'Manjak Beer drinkers';
image_year[0][16] = '1998';
image_medium[0][16] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][16] = 'Paper Size 30 x 22 inches';

gallery_images[0][17] = './galleri/xingu_paper/bilde18.jpg';
gallery_captions[0][17] = 'Sweepers at Dawn of Day';
image_year[0][17] = '1998';
image_medium[0][17] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][17] = 'Paper Size 30 x 22 inches';

gallery_images[0][18] = './galleri/xingu_paper/bilde19.jpg';
gallery_captions[0][18] = 'Tranquil Morning';
image_year[0][18] = '1998';
image_medium[0][18] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][18] = 'Paper Size 30 x 22 inches';

gallery_images[0][19] = './galleri/xingu_paper/bilde20.jpg';
gallery_captions[0][19] = 'Burning Bush';
image_year[0][19] = '1998';
image_medium[0][19] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][19] = 'Paper Size 30 x 22 inches';

gallery_images[0][20] = './galleri/xingu_paper/bilde21.jpg';
gallery_captions[0][20] = 'Night Worriors';
image_year[0][20] = '1998';
image_medium[0][20] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][20] = 'Paper Size 30 x 22 inches';

gallery_images[0][21] = './galleri/xingu_paper/bilde22.jpg';
gallery_captions[0][21] = 'Linedance / Suya';
image_year[0][21] = '1998';
image_medium[0][21] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][21] = 'Paper Size 30 x 22 inches';

gallery_images[0][22] = './galleri/xingu_paper/bilde23.jpg';
gallery_captions[0][22] = 'Territorial Dance';
image_year[0][22] = '1998';
image_medium[0][22] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][22] = 'Paper Size 30 x 22 inches';

gallery_images[0][23] = './galleri/xingu_paper/bilde24.jpg';
gallery_captions[0][23] = 'Ripple';
image_year[0][23] = '1998';
image_medium[0][23] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][23] = 'Paper Size 30 x 22 inches';

gallery_images[0][24] = './galleri/xingu_paper/bilde25.jpg';
gallery_captions[0][24] = 'Waiting for the Shaman / Prepori';
image_year[0][24] = '1998';
image_medium[0][24] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][24] = 'Paper Size 30 x 22 inches';

gallery_images[0][25] = './galleri/xingu_paper/bilde26.jpg';
gallery_captions[0][25] = 'The Feather Silence';
image_year[0][25] = '1998';
image_medium[0][25] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][25] = 'Paper Size 30 x 22 inches';

gallery_images[0][26] = './galleri/xingu_paper/bilde27.jpg';
gallery_captions[0][26] = 'Portrait of Young Mother';
image_year[0][26] = '1998';
image_medium[0][26] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][26] = 'Paper Size 30 x 22 inches';

gallery_images[0][27] = './galleri/xingu_paper/bilde28.jpg';
gallery_captions[0][27] = 'Young Cameraman';
image_year[0][27] = '1998';
image_medium[0][27] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][27] = 'Paper Size 30 x 22 inches';

gallery_images[0][28] = './galleri/xingu_paper/bilde29.jpg';
gallery_captions[0][28] = 'Infiltration';
image_year[0][28] = '2006-2007';
image_medium[0][28] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][28] = 'Paper Size 30 x 22 inches';

gallery_images[0][29] = './galleri/xingu_paper/bilde30.jpg';
gallery_captions[0][29] = 'The Fare Well';
image_year[0][29] = '1998';
image_medium[0][29] = 'Silicon Intaglio Print / Edition of 35 / Printed by Arak Kanofsky Studios, New York';
image_size[0][29] = 'Paper Size 30 x 22 inches';
