// path to images
var slideshowPath = "/_includes/images/home/rotating-images/";

// 5x3 matrix for 5 images with 3 attributes
var slideshowArray = new Array(5);
for (i=0; i<5; i++)
	slideshowArray[i]=new Array(3);

// alt text required, descriptions support inline html
slideshowArray[0][0] = "fennell.jpg";
slideshowArray[0][1] = "New Philadelphia excavation site";
slideshowArray[0][2] = "National Science Foundation field school students Adeola Adegbola and Hillary Livingston, along with archaeologist Chris Fennell and other excavators, investigate a 19th-century house site at New Philadelphia, Illinois, a demographically integrated town founded by a free African American in 1836.";

slideshowArray[1][0] = "farnell_florence-dance-company.jpg";
slideshowArray[1][1] = "SiLenCe dancers";
slideshowArray[1][2] = "In Florence, Italy,  Brenda Farnell documents the making of SiLenCe,  a dance work by choreographer Robert Wood (right).  This collaboration explores ways in which embodied information is generated and communicated across linguistic and cultural borders.";

slideshowArray[2][0] = "garber.jpg";
slideshowArray[2][1] = "Infant Goeldi's monkey";
slideshowArray[2][2] = "Bioanthropologist Paul Garber took this photo of an infant Goeldi's monkey (Callimico goeldii) from the Pando region of northern Bolivia. Goeldi's monkey is unusual among nonhuman primates in that adult male group members help care for the young.";

slideshowArray[3][0] = "keller.jpg";
slideshowArray[3][1] = "Pacific tattoos";
slideshowArray[3][2] = "Pacific aesthetics and new technologies combine in the popular art of tattooing at the 2004 Pacific Arts Festival in the island nation of Palau. Linguistic anthropologist Janet Keller, who researches forms of expression and performance in Oceania, took this photo.";

slideshowArray[4][0] = "moodie.jpg";
slideshowArray[4][1] = "El Salvador schoolboys";
slideshowArray[4][2] = "Schoolboys await the arrival of El Salvador's first president elected after a brutal 12-year civil war. Salvadorans hoped for peace, but were confronted by new forms of violence with the institution of neoliberal governance. Anthropologist Ellen Moodie studies stories people tell about the postwar transition.";

// dom is ready, let's go...
$(document).ready(function() {
	var $slideshow = $('#home-picture'); // slideshow image container

	// insert slideshow elements into page
	$slideshow.before('<h2>Featured Image</h2>');
	$("#home-picture-caption").html("<p></p>");
	for (var i = 0; i < slideshowArray.length; i++)
		$slideshow.append('<img src="' + slideshowPath + slideshowArray[i][0] + '" alt="' + slideshowArray[i][1] + '" />'); 
	
	// let it run...
	$slideshow.cycle({ 
	    delay:		0,			// initial delay in ms
	    speed:		1500,		// transition speed in ms
    	timeout:	10000,		// ms between slide transitions
	    random:		1,			// true for randomness
		sync:		1,			// true if in/out transitions should occur simultaneously 
		before:		onBefore	// callback as transition starts
	});
});

// callback to set description text
function onBefore() {
	var description = slideshowArray[$(this).parent().children().index(this)][2];
	$("#home-picture-caption p").slideUp(500, function() {
		$('#home-picture-caption p')
			.html(description)
			.slideDown(500);
	});
}
