var pics = new Array();

pics.push("home1");
pics.push("home2");
pics.push("home3");
pics.push("home4");
pics.push("home5");

var total = pics.length;
var current;
var setIntervalID;

$(document).ready(function() {
	slideshow();
});

function slideshow() {
	var randnum = Math.random();
	current = Math.round((total - 1) * randnum);
	$("<img>").attr({
		src: "images/" + pics[current] + ".jpg",
		alt: "Idaho Museum of Natural History"
	}).replaceAll("#slideshow ul li").wrap("<li></li>");
	$("#slideshow ul li").css({opacity: 0.0}).animate({opacity: 1.0}, 500);
	
	setIntervalID = setInterval('nextslide()', 5000);
}

function nextslide() {
	current++;
	if(current >= total) {
		current = 0;
	}
	$("<img>").attr({
		src: "images/" + pics[current] + ".jpg",
		alt: "Idaho Museum of Natural History"
	}).replaceAll("#slideshow ul li").wrap("<li></li>");;
	$("#slideshow ul li").css({opacity: 0.0}).animate({opacity: 1.0}, 500);
}
