function loadNextImage() {
	//get Element with sequential src
	var myImage = document.getElementById('specialistImage');
	var myHeadline = document.getElementById('specialistName');
	var myLink = document.getElementById('specialistLink');
	
	//declare home banner path and images array
	var thePath = "/library/";
	var theImages = new Array();
	var theSpecialists = new Array();
	var theSite = document.location.hostname;
	var theLinks = new Array();
	theImages[0] = "jeanlapp_promo.jpg"; 
		theSpecialists[0] = "<strong>Jean Lapp</strong> serves Anchorage.";
		theLinks[0] = "/jean_lapp.html";
	theImages[1] = "maryannpierre_promo.jpg"; 
		theSpecialists[1] = "<strong>Mary Ann Pierre</strong> serves Eagle River.";
		theLinks[1] = "/mary_ann_pierre.html";
	theImages[2] = "mikescott_promo.jpg"; 
		theSpecialists[2] = "<strong>Mike Scott</strong> serves Anchorage.";
		theLinks[2] = "/mike_scott.html";
	theImages[3] = "jozetteboyd_promo.jpg"; 
		theSpecialists[3] = "<strong>Jozette Boyd</strong> serves Fairbanks.";
		theLinks[3] = "/jozette_boyd.html";
	theImages[4] = "marilynpipkin_promo.jpg"; 
		theSpecialists[4] = "<strong>Marilyn Pipkin</strong> serves Kenai &amp; Soldotna.";
		theLinks[4] = "/marilyn_pipkin.html";
	theImages[5] = "karrieyoungblood_promo.jpg"; 
		theSpecialists[5] = "<strong>Karrie Youngblood</strong> serves Homer.";
		theLinks[5] = "/karrie_youngblood.html";
	theImages[6] = "katier_promo.jpg"; 
		theSpecialists[6] = "<strong>Katie Richardson</strong> serves Wasilla.";
		theLinks[6] = "/katie_r.html";
	theImages[7] = "monicabarton_promo.jpg"; 
		theSpecialists[7] = "<strong>Monica Barton</strong> serves Wasilla.";
		theLinks[7] = "/monica_barton.html";
	theImages[8] = "tinachowaniec_promo.jpg"; 
		theSpecialists[8] = "<strong>Tina Chowaniec</strong> serves Wasilla.";
		theLinks[8] = "/tina_chowaniec.html";
	theImages[9] = "shirlenewells_promo.jpg"; 
		theSpecialists[9] = "<strong>Shirlene Wells</strong> serves Bethel, Cordova, Glennallen, Haines, Healy, Juneau, Kodiak, Kuskokwim, Seward, Sitka &amp; Valdez.";
		theLinks[9] = "/shirlene_wells.html";
	theImages[10] = "vivienlafevers_promo.jpg"; 
		theSpecialists[9] = "<strong>Vivien LaFevers</strong> serves Anchorage.";
		theLinks[9] = "/vivien_lafevers.html";		

	// IMPORTANT Keep the array numbers above this line consistent with rotating_subpage.js. This will keep the syncing of these two scripts much simpler!
	
	//get current cookie value
	var currentIndex = parseInt(getCookie());
	var imgPath = thePath + theImages[currentIndex];
	var linkPath = 'http://' + theSite + theLinks[currentIndex];
	
	//apply swaps to Elements
	myImage.src = imgPath;
	myHeadline.innerHTML = theSpecialists[currentIndex];
	myLink.href = linkPath;
	
	//set next cookie index
	currentIndex += 1;
	if(currentIndex > (theImages.length - 1)) {
		currentIndex = 0;
	}
	setCookie(currentIndex);
}

function setCookie(someint) {
	var now = new Date();
	var addDays = now.getDate() + 7
	now.setDate(addDays); // cookie expires in 7 days
	var theString = 'imgID=' + escape(someint) + ';expires=' + now.toUTCString();
	document.cookie = theString;
}

function getCookie() {
	var output = "0";
	if(document.cookie.length > 0) {
		var temp = unescape(document.cookie);
		temp = temp.split(';');
		for(var i = 0; i < temp.length; i++) {
			if(temp[i].indexOf('imgID') != -1) {
				temp = temp[i].split('=');
				output = temp.pop();
				break;
			}
		}
	}
	return output;
}

addLoadEvent(loadNextImage);
