// 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] = "PARADOXICAL SLEEP MONOLOGUES / KUNSTGALLERIET / STAVANGER / 2003";

gallery_images[0][0] = './galleri/paradoxicalsleep/bilde01.jpg';
gallery_captions[0][0] = '';
image_year[0][0] = '';
image_medium[0][0] = '';
image_size[0][0] = '';

gallery_images[0][1] = './galleri/paradoxicalsleep/bilde02.jpg';
gallery_captions[0][1] = 'One Hundred Years of Complete Boredom';
image_year[0][1] = '2003';
image_medium[0][1] = 'Mixed Media / Oil on Canvas';
image_size[0][1] = '110 x 60cm / 44 x 24in';

gallery_images[0][2] = './galleri/paradoxicalsleep/bilde03.jpg';
gallery_captions[0][2] = 'Monologues (anger managment) Trip-Tych';
image_year[0][2] = '2003';
image_medium[0][2] = 'Mixed Media / Oil on Canvas';
image_size[0][2] = '35 x 30 cm / 14 x 12 in';

gallery_images[0][3] = './galleri/paradoxicalsleep/bilde04.jpg';
gallery_captions[0][3] = 'Detail : Monologues (anger managment) I.';
image_year[0][3] = '2003';
image_medium[0][3] = 'Mixed Media / Oil on Canvas';
image_size[0][3] = '35 x 30 cm / 14 x 12 in';

gallery_images[0][4] = './galleri/paradoxicalsleep/bilde05.jpg';
gallery_captions[0][4] = 'Detail : Monologues (anger managment) II.';
image_year[0][4] = '2003';
image_medium[0][4] = 'Mixed Media / Oil on Canvas';
image_size[0][4] = '35 x 30 cm / 14 x 12 in';

gallery_images[0][5] = './galleri/paradoxicalsleep/bilde06.jpg';
gallery_captions[0][5] = 'Detail : Monologues (anger managment) III.';
image_year[0][5] = '2003';
image_medium[0][5] = 'Mixed Media / Oil on Canvas';
image_size[0][5] = '35 x 30 cm / 14 x 12 in';

gallery_images[0][6] = './galleri/paradoxicalsleep/bilde07.jpg';
gallery_captions[0][6] = 'Vestibyle (8:18 PM)';
image_year[0][6] = '2003';
image_medium[0][6] = 'Mixed Media / Oil on Canvas';
image_size[0][6] = '166 x 197 cm / 66 x 78 in';

gallery_images[0][7] = './galleri/paradoxicalsleep/bilde08.jpg';
gallery_captions[0][7] = 'Detail : Vestibyle (8:18 PM)';
image_year[0][7] = '2003';
image_medium[0][7] = 'Mixed Media / Oil on Canvas';
image_size[0][7] = '166 x 197 cm / 66 x 78 in';

gallery_images[0][8] = './galleri/paradoxicalsleep/bilde09.jpg';
gallery_captions[0][8] = 'Spitzbergen Pyramide (iceberg sighting)';
image_year[0][8] = '2003';
image_medium[0][8] = 'Mixed Media / Oil on Canvas';
image_size[0][8] = '35 x 30 cm / 14 x 12 in';

gallery_images[0][9] = './galleri/paradoxicalsleep/bilde10.jpg';
gallery_captions[0][9] = 'Pytagora Eclipse';
image_year[0][9] = '2003';
image_medium[0][9] = 'Mixed Media / Oil on Paper';
image_size[0][9] = '50 x 23 cm / 20 x 9 in';

gallery_images[0][10] = './galleri/paradoxicalsleep/bilde11.jpg';
gallery_captions[0][10] = 'One Hundred Years of Complete Boredom (pottery barn bliss) ver I.';
image_year[0][10] = '2003';
image_medium[0][10] = 'Mixed Media / Oil on Canvas';
image_size[0][10] = '205 x 166 cm / 81 x 66 in';

gallery_images[0][11] = './galleri/paradoxicalsleep/bilde12.jpg';
gallery_captions[0][11] = 'Detail : One Hundred Years of Complete Boredom (pottery barn bliss) ver I.';
image_year[0][11] = '2003';
image_medium[0][11] = 'Mixed Media / Oil on Canvas';
image_size[0][11] = '205 x 166 cm / 81 x 66 in';

gallery_images[0][12] = './galleri/paradoxicalsleep/bilde13.jpg';
gallery_captions[0][12] = 'Paradoxical Sleep Monologues';
image_year[0][12] = '2003';
image_medium[0][12] = 'Mixed Media / Oil on Canvas';
image_size[0][12] = '140 x 110 cm / 55 x 44 in';

gallery_images[0][13] = './galleri/paradoxicalsleep/bilde14.jpg';
gallery_captions[0][13] = 'Spine (convex - concave)';
image_year[0][13] = '2003';
image_medium[0][13] = 'Mixed Media / Oil on Canvas';
image_size[0][13] = '75 x 70 cm / 30 x 28 in';

gallery_images[0][14] = './galleri/paradoxicalsleep/bilde15.jpg';
gallery_captions[0][14] = 'Reversed Study (extremeties)';
image_year[0][14] = '2003';
image_medium[0][14] = 'Mixed Media / Oil on Canvas';
image_size[0][14] = '30 x 35 cm / 12 x 14 in';

gallery_images[0][15] = './galleri/paradoxicalsleep/bilde16.jpg';
gallery_captions[0][15] = 'Detail : Reversed Study (extremeties)';
image_year[0][15] = '2003';
image_medium[0][15] = 'Mixed Media / Oil on Canvas';
image_size[0][15] = '30 x 35 cm / 12 x 14 in';

gallery_images[0][16] = './galleri/paradoxicalsleep/bilde17.jpg';
gallery_captions[0][16] = 'Referendum (begonia)';
image_year[0][16] = '2003';
image_medium[0][16] = 'Mixed Media / Oil on Canvas';
image_size[0][16] = '216 x 166 cm / 85 x 66 in';

gallery_images[0][17] = './galleri/paradoxicalsleep/bilde18.jpg';
gallery_captions[0][17] = 'Detail : Referendum (begonia)';
image_year[0][17] = '2003';
image_medium[0][17] = 'Mixed Media / Oil on Canvas';
image_size[0][17] = '216 x 166 cm / 85 x 66 in';

gallery_images[0][18] = './galleri/paradoxicalsleep/bilde19.jpg';
gallery_captions[0][18] = 'Attempt to Comprehend Archimedes Law';
image_year[0][18] = '2003';
image_medium[0][18] = 'Mixed Media / Oil on Canvas';
image_size[0][18] = '45 x 45 cm / 18 x 18 in';

gallery_images[0][19] = './galleri/paradoxicalsleep/bilde20.jpg';
gallery_captions[0][1819] = 'Attempt to Comprehend Archimedes Law';
image_year[0][19] = '2003';
image_medium[0][19] = 'Mixed Media / Oil on Canvas';
image_size[0][19] = '45 x 45 cm / 18 x 18 in';


