// JavaScript Document for image transitions
// The first image should be titled:   image_prefix + first_image_index
// Each image thereafter should follow sequentially

description_array = new Array();			// description array

// enter in the descriptions here in sequential order (as they are entered in image_transition.js)
description_array[0] = "<strong>Daniel Klein</strong>, Professor <strong>Ben Raphael</strong>, and Professor <strong>William Thompson</strong> chatting during the open house.";
description_array[1] = "Everyone's favorite part, the food arrived!";
description_array[2] = "Professor <strong>Daniel Weinreich</strong> giving an overview of the Center for Computational Molecular Biology.";
description_array[3] = "Professor <strong>William Thompson</strong> addressing a question from a student.";
description_array[4] = "Computer Science Graduate students enjoying some dessert.";
description_array[5] = "Professor <strong>Daniel Weinreich</strong> awarding a raffle prize!";
description_array[6] = "Professors <strong>Daniel Weinreich</strong>, <strong>Ben Raphael</strong>, and <strong>Sorin Istrail</strong>";
description_array[7] = "Graduate Student Eric Lim arriving fashionably late.";
description_array[8] = "Professor <strong>Suzanne Sindi</strong> explaining her research to undergraduate students.";
description_array[9] = "Professor <strong>Daniel Weinreich</strong> drawing names for the raffle.";

// Required configuration variables (modify to your environment)
var number_of_images = 10;			// total number of images to display
var image_width = 200;				// width of the image in pixels
var image_height = 200;				// height of the image in pixels
var image_link = 'images/comp_bio_open_house/';
var image_prefix = 'open_house_';

// Optional variables to modify
var transition_delay = 4000;		// quantity in milliseconds
var first_image_index = 0;

// Other script variables
var current_image = 0;				// current image index, we start at the zeroth image
image_array = new Array();			// image array

// creating image array
for (i = 0; i < number_of_images; i++) {
	image_array[i] = new Image(image_width, image_height);
	image_array[i].src = image_link + image_prefix + i + '.JPG';
}

// animating
function animate(image_id, label_id) {
	
	switchImage(image_id, label_id);
	
	setTimeout("animate(\'" + image_id + "\',\'" + label_id + "\')", transition_delay);
	
}

// image transition
function switchImage(image_id, label_id) { 

	document.getElementById(image_id).src = image_array[current_image].src;
	document.getElementById(label_id).innerHTML = description_array[current_image];
	
	current_image++;
	   if(current_image == number_of_images) 
			current_image = 0; 
}