window.onload = initAll;

var currImg = 0;
var captionText = new Array(
	"Anna Kinsey, Community Outreach Director, hosts a car seat check-up on Tuesday, August 10th.",
	"Kinston's fire department volunteer at the car seat check-up.",
	"Congressman G.K. Butterfield gives the keynote address at the Hope for Equal Access Community Luncheon.",
	"Dr. Vazquez (l) and Dr. Roberson (r) are this year's CEOs Choice Award recipients.",
	"Dean Paul Cunningham from ECU's Brody School of Medicine discusses possible future collaborations with KCHC.",
	"David Hansley receives Hope for Equal Access Award from Congressman Butterfield, Carla Pellerin, CEO, and Anna Kinsey.",
	"KCHC staff and the Lyons Club offered free vision screenings at the IGA in Pink Hill, NC on Thursday, August 12th.",
	"Congressman Walter B. Jones speaks at the Cultural Heritage Community Health fair on Saturday, August 14th.",
	"Representative VanBraxton speaks at the health fair.",
	"Lenoir Community College nursing students provide free health (glucose, cholesterol, BP, and bone density) screenings."
)

function initAll() {
	document.getElementById("imgText").innerHTML = captionText[0];
	document.getElementById("prevLink").onclick = processPrevious;
	document.getElementById("nextLink").onclick = processNext;
}

function processPrevious() {
	newSlide(-1);
}

function processNext() {
	newSlide(1);
}

function newSlide(direction) {
	var imgCt = captionText.length;

	currImg = currImg + direction;
	if (currImg < 0) {
		currImg = imgCt-1;
	}
	if (currImg == imgCt) {
		currImg = 0;
	}
	document.getElementById("slideshow").src = "slideImg" + currImg + ".jpg";
	document.getElementById("imgText").innerHTML = captionText[currImg];
}
