// 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] = "/ UNDERTOW / GALLERI BI-Z / CHRISTIANSSAND / OCT 2004";

gallery_images[0][0] = './galleri/undertow/bilde01.jpg';
gallery_captions[0][0] = 'Phases (Split Sky) / trip-tych';
image_year[0][0] = '2004';
image_medium[0][0] = 'Mixed Media / Oil on Canvas';
image_size[0][0] = 'Each panel 60 x 135 cm / 24 x 54 in';

gallery_images[0][1] = './galleri/undertow/bilde02.jpg';
gallery_captions[0][1] = 'Esterel Components';
image_year[0][1] = '2004';
image_medium[0][1] = 'Mixed Media / Oil on Canvas';
image_size[0][1] = '60 x 60 cm / 24 x 24 in';

gallery_images[0][2] = './galleri/undertow/bilde03.jpg';
gallery_captions[0][2] = 'October (Declining Nude)';
image_year[0][2] = '2004';
image_medium[0][2] = 'Mixed Media / Oil on Canvas';
image_size[0][2] = '46 x 112 cm / 18 x 44 in';

gallery_images[0][3] = './galleri/undertow/bilde04.jpg';
gallery_captions[0][3] = 'Surrogat';
image_year[0][3] = '2004';
image_medium[0][3] = 'Mixed Media / Oil on Canvas';
image_size[0][3] = '42 x 110 cm / 16 x 43 in';

gallery_images[0][4] = './galleri/undertow/bilde05.jpg';
gallery_captions[0][4] = 'Family Secret';
image_year[0][4] = '2004';
image_medium[0][4] = 'Mixed Media / Oil on Canvas';
image_size[0][4] = '120 x 135 cm / 47 x 54 in';

gallery_images[0][5] = './galleri/undertow/bilde06.jpg';
gallery_captions[0][5] = '';
image_year[0][5] = '2004';
image_medium[0][5] = 'Mixed Media / Oil on Canvas';
image_size[0][5] = '';

gallery_images[0][6] = './galleri/undertow/bilde07.jpg';
gallery_captions[0][6] = 'Heritage (Son / Father / Figure)';
image_year[0][6] = '2004';
image_medium[0][6] = 'Mixed Media / Oil on Canvas';
image_size[0][6] = '30 x 35 cm / 12 x 14 in';

gallery_images[0][7] = './galleri/undertow/bilde08.jpg';
gallery_captions[0][7] = 'Detail : ';
image_year[0][7] = '2004';
image_medium[0][7] = 'Mixed Media / Oil on Canvas';
image_size[0][7] = '';

gallery_images[0][8] = './galleri/undertow/bilde09.jpg';
gallery_captions[0][8] ='Cluster / Pendulum II.';
image_year[0][8] = '2004';
image_medium[0][8] = 'Mixed Media / Oil on Canvas';
image_size[0][8] = '205 x 165 cm / 81 x 65 in';

gallery_images[0][9] = './galleri/undertow/bilde10.jpg';
gallery_captions[0][9] ='Cluster / Pendulum I.';
image_year[0][9] = '2004';
image_medium[0][9] = 'Mixed Media / Oil on Canvas';
image_size[0][9] = '205 x 165 cm / 81 x 65 in';

gallery_images[0][10] = './galleri/undertow/bilde11.jpg';
gallery_captions[0][10] ='Cluster / Pendulum (yellow)';
image_year[0][10] = '2004';
image_medium[0][10] = 'Mixed Media / Oil on Canvas';
image_size[0][10] = '162 x 202 cm / 64 x 80 in';

gallery_images[0][11] = './galleri/undertow/bilde12.jpg';
gallery_captions[0][11] = 'Phases ver. I - III.';
image_year[0][11] = '2004';
image_medium[0][11] = 'Photosculpture on 3x Plexiglas';
image_size[0][11] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][12] = './galleri/undertow/bilde13.jpg';
gallery_captions[0][12] = 'Phases ver. I - III.';
image_year[0][12] = '2004';
image_medium[0][12] = 'Photosculpture on 3x Plexiglas';
image_size[0][12] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][13] = './galleri/undertow/bilde14.jpg';
gallery_captions[0][13] = 'Phases ver. I - III.';
image_year[0][13] = '2004';
image_medium[0][13] = 'Photosculpture on 3x Plexiglas';
image_size[0][13] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][14] = './galleri/undertow/bilde15.jpg';
gallery_captions[0][14] = 'Phases ver. IV - VI.';
image_year[0][14] = '2004';
image_medium[0][14] = 'Photosculpture on 3x Plexiglas';
image_size[0][14] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][15] = './galleri/undertow/bilde16.jpg';
gallery_captions[0][15] = 'Phases ver. IV - VI.';
image_year[0][15] = '2004';
image_medium[0][15] = 'Photosculpture on 3x Plexiglas';
image_size[0][15] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][16] = './galleri/undertow/bilde17.jpg';
gallery_captions[0][16] = 'Phases ver. IV - VI.';
image_year[0][16] = '2004';
image_medium[0][16] = 'Photosculpture on 3x Plexiglas';
image_size[0][16] = '19 x 24 cm / 7,5 x 9,5 in';

gallery_images[0][17] = './galleri/undertow/bilde18.jpg';
gallery_captions[0][17] = 'Declining Nude / ASF 30,960 KB T3';
image_year[0][17] = '2004';
image_medium[0][17] = 'Mixed Media / Oil on Canvas';
image_size[0][17] = '137 x 223 c, / 54 x 88 in';

gallery_images[0][18] = './galleri/undertow/bilde19.jpg';
gallery_captions[0][18] = '';
image_year[0][18] = '2004';
image_medium[0][18] = 'Mixed Media / Oil on Canvas';
image_size[0][18] = '';

gallery_images[0][19] = './galleri/undertow/bilde20.jpg';
gallery_captions[0][19] = 'Cantate IV. / ASF 24,878 KB T1';
image_year[0][19] = '2004';
image_medium[0][19] = 'Phototransfer on Ikea plates';
image_size[0][19] = '29 x 50 cm / 11 x 20 in';

gallery_images[0][20] = './galleri/undertow/bilde21.jpg';
gallery_captions[0][20] = 'Cantate V. / MPG 7,353 KB Cable';
image_year[0][20] = '2004';
image_medium[0][20] = 'Phototransfer on Ikea plates';
image_size[0][20] = '29 x 50 cm / 11 x 20 in';

gallery_images[0][21] = './galleri/undertow/bilde22.jpg';
gallery_captions[0][21] = '';
image_year[0][21] = '2004';
image_medium[0][21] = 'Mixed Media / Phototransfer on Paper';
image_size[0][21] = '';

gallery_images[0][22] = './galleri/undertow/bilde23.jpg';
gallery_captions[0][22] = 'Boy (Muybridge dilemma)';
image_year[0][22] = '2004';
image_medium[0][22] = 'Mixed Media / Phototransfer on Paper';
image_size[0][22] = '30 x 30 cm / 12 x 12 in';

gallery_images[0][23] = './galleri/undertow/bilde24.jpg';
gallery_captions[0][23] = 'Airfield / ASF 14,098 KB T1';
image_year[0][23] = '2004';
image_medium[0][23] = 'Phototransfer on Paper';
image_size[0][23] = '30 x 30 cm / 12 x 12 in';

