var pics = new Array();
var alts = new Array();
var caps = new Array();
var link = new Array();

pics.push("communiversity-involved"); // remove 2/16/12?
alts.push("Celebrate Idaho State: Get Involved");
caps.push("<p>It’s time again to \"Celebrate Idaho State!\" The 2nd Annual CommUniversity Event hosted by ISU is scheduled for Tuesday, March 13, 2012 from 4-7 pm in the Pond Student Union Building. With the ongoing planning and support of the CommUniversity Committee, we are asking ISU’s Colleges, Departments, Units, and Organizations to <strong><a href=\"http://www.isu.edu/communiversity/\">participate by showcasing their outstanding programs, faculty, and students</a></strong>.</p>");
link.push("http://www.isu.edu/communiversity/");

pics.push("majorfair2012"); // remove 2/15/12
alts.push("Idaho Falls Majors Fair: Love What You Do!");
caps.push("<p>Love What You Do! Find your passion at the <strong><a href=\"http://www.isu.edu/advising/pdf_view.shtml?pdf=/advising/docs/events/LoveMajorsFair_2[1]Poster.pdf\">ISU-Idaho Falls Majors Fair</a></strong>, February 14, from noon to 2 p.m. in the Bennion Student Union. The majors fair provides an opportunity to meet with many departments all in one place; explore different majors, pre-requisites, admission requirements, and career opportunities. Workshops presented by career counselors will also be available. Free food and prizes.</p>");
link.push("http://www.isu.edu/advising/pdf_view.shtml?pdf=/advising/docs/events/LoveMajorsFair_2[1]Poster.pdf");

/*pics.push("brush-great"); // remove 2/10/12
alts.push("Brush with Greatness");
caps.push("<p>As part of February Dental Health Month, Delta Dental and Idaho State University have teamed up with the <strong><a href=\"http://www.brush-great.com/\">Idaho Steelheads to 'brush' out cavities on February 10</a></strong>. Join us for this fun family event!</p>");
link.push("http://www.brush-great.com/");*/

pics.push("isom2"); 
alts.push("Idaho State of Mind");
caps.push("<p><strong><a href=\"http://www.isu.edu/idahostateofmind/\">Idaho State of Mind</a></strong> airs each Saturday on <a href=\"http://idahoptv.org/\">Idaho Public Television</a><br /><br />View all of <a href=\"http://www.isu.edu/idahostateofmind/episodes.shtml\">Season One</a> </p>");
link.push("http://www.isu.edu/idahostateofmind/index.shtml");

pics.push("honors"); // remove 2/15/12
alts.push("University Honors Program");
caps.push("<p>The <strong><a href=\"http://www.isu.edu/honors/\">University Honors Program</a></strong> at Idaho State University is an elite academic program for students who aspire to a more engaging and enriching collegiate experience. The program synthesizes the idea of a structured learning community within an interdisciplinary curriculum. The deadline for application is February 15, 2012.</p>");
link.push("http://www.isu.edu/honors/");

pics.push("BrightBest3");
alts.push("Brightest and Best");
caps.push("<p><strong><a href=\"http://www.isu.edu/brightest/\">ISU's Brightest and Best</a></strong> Profiles of students and faculty.</p>");
link.push("http://www.isu.edu/brightest/");

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

$(document).ready(function() {
	$.each(pics, function(i, pic) {
		$("<a>").text(i+1).attr({
			href: "#",
			rel: pic
		}).appendTo("#splashnav ul").wrap("<li></li>").click( function() {
			clearInterval(setIntervalID);
			$("<img>").attr({
				src: "/images/homephotos/" + $(this).attr("rel") + ".jpg"
			}).replaceAll("#splash dt a").wrap("<a href=\""+link[i]+"\"></a>");
			$("<dd>").html(caps[i]).attr({
				id: "announcements"
			}).replaceAll("#splash dd#announcements");
			$("#splash dt img").css({opacity: 0.0}).animate({opacity: 1.0}, 1000);
			$("#splash dd#announcements").css({opacity: 0.0}).animate({opacity: 1.0}, 1000);
			return false;
		});
	});
	slideshow();
});

function slideshow() {
	var randnum = Math.random();
	current = Math.round((total - 1) * randnum);
	$("<img>").attr({
		src: "/images/homephotos/" + pics[current] + ".jpg"
	}).replaceAll("#splash dt a").wrap("<a href=\""+link[current]+"\"></a>");
	$("<dd>").html(caps[current]).attr({
		id: "announcements"
	}).replaceAll("#splash dd#announcements");
	$("#splash dt img").css({opacity: 0.0}).animate({opacity: 1.0}, 500);
	$("#splash dd#announcements").css({opacity: 0.0}).animate({opacity: 1.0}, 500);
	
	setIntervalID = setInterval('nextslide()', 15000);
}

function nextslide() {
	current++;
	if(current >= total) {
		current = 0;
	}
	$("<img>").attr({
		src: "/images/homephotos/" + pics[current] + ".jpg"
	}).replaceAll("#splash dt a").wrap("<a href=\""+link[current]+"\"></a>");
	$("<dd>").html(caps[current]).attr({
		id: "announcements"
	}).replaceAll("#splash dd#announcements");
	$("#splash dt img").css({opacity: 0.0}).animate({opacity: 1.0}, 1000);
	$("#splash dd#announcements").css({opacity: 0.0}).animate({opacity: 1.0}, 1000);
}
