var photoList = [
                    { photo: "/photos/2010kelly.jpg",
                        caption: "<b>June 2010:</b> Kelly, Chad and Rhiannon."
                    },
                    { photo: "/photos/2010becca.jpg",
                        caption: "<b>June 2010:</b> Becca, Jim and Adeline."
                    },
                    { photo: "/photos/2010sara.jpg",
                        caption: "<b>May 2010:</b> Sara, Ken and Connor."
                    },
                    { photo: "/photos/2010kellyf.jpg",
                        caption: "<b>May 2010:</b> Kelly, Brian and Lily."
                    },
                    { photo: "/photos/2010varsha.jpg",
                        caption: "<b>April 2010:</b> Varsha, R.K. and Aniruddha."
                    },
                    { photo: "/photos/2010stephanie.jpg",
                        caption: "<b>April 2010:</b> Stephanie, Rob and Malaya."
                    },
                    { photo: "/photos/2010tahisha.jpg",
                        caption: "<b>April 2010:</b> Tahisha, Kemo and Taliah."
                    },                                    
                    { photo: "/photos/2010corinne.JPG",
                        caption: "<b>March 2010:</b> Corinne, John and Cali."
                    },
                    { photo: "/photos/2010jenn.JPG",
                        caption: "<b>March 2010:</b> Jenn, J.T. and Sera."
                    },
                    { photo: "/photos/2010aprildominic.jpg",
                        caption: "<b>January 2010:</b> April, Brent and Dominic."
                    },
                    {   photo: "/photos/2009megan.jpg",
                        caption: "<b>December 2009:</b> Megan, Joel and Louisa."
                    },
                    {   photo: "/photos/2009sarahp.jpg",
                        caption: "<b>December 2009:</b> Sarah, Scott and Henry."
                    },
                    {   photo: "/photos/2009maura.jpg",
                        caption: "<b>December 2009:</b> Maura, Jordan and Micaiah."
                    },
                    {   photo: "/photos/2009sarahh.jpg",
                        caption: "<b>November 2009:</b> Sarah, Jason and Laila."
                    },                                        
                    {   photo: "/photos/2009stephanie.jpg",
                        caption: "<b>November 2009:</b> Stephanie, Ryan and Colin."
                    },
                    {   photo: "/photos/2009christina.jpg",
                        caption: "<b>October 2009:</b> Christina and Cooper."
                    },
                    {   photo: "/photos/2009niki.jpg",
                        caption: "<b>August 2009:</b> Niki, Jason and Elliot."
                    },
                    {	photo: "/photos/200908sophia.jpg",
						caption: "<b>August 2009:</b> Desiree, Bill and Sophia."
					},
					{	photo: "/photos/200908genny.jpg",
						caption: "<b>August 2009:</b> Maggie, Ken and Genny."
					},
					{	photo: "/photos/200908emily.jpg",
						caption: "<b>August 2009:</b> Emily, Joe and Lilly."
					},	
					{	photo: "/photos/200905adrienne.jpg",
						caption: "<b>June 2009:</b> Dan and Adrienne and Gabriel."
					},
					{	photo: "/photos/2009aleashaandrew.jpg",
						caption: "<b>March 2009:</b> Aleasha and Andrew with their new baby boy, Wyatt."
					},
					{	photo: "/photos/2009bethlancedillon.jpg",
						caption: "<b>March 2009:</b> Beth and Lance and newly-arrived Dylan."
					},
					{	photo: "/photos/200811matilda.jpg",
						caption: "<b>November 2008:</b> Amy helped Michelle deliver Matilda.  This was an <a target='_blank' href='http://www.operationspecialdelivery.com/'>Operation Special Delivery</a> birth."
					},
					{	photo: "/photos/2008danannikaemma.jpg",
						caption: "<b>July 2008:</b> Brenda was on hand to help Dan and Annika deliver Emma."
					},
					{	photo: "/photos/2008kellybillaiden.jpg",
						caption: "<b>June 2008:</b> Amy helped to welcome Bill and Kelly's son Aiden into the world."
					},
					{	photo: "/photos/200804farr.jpg", 
						caption: "<b>April 2008:</b> Brenda was there to welcome Amy's son Ryan into the world."
					}, 
					{	photo: "/photos/200803sarakenny.jpg", 
						caption: "<b>March 2008:</b> Brenda helped Sara and Ken bring <b>Meghan</b> into the world."
					},
					{	photo: "/photos/2007mattshainaalex.jpg",
						caption: "<b>September 2007:</b> Brenda helped Shaina and Matt (home from Iraq only 45 minutes before the birth) deliver Alex."
					},
					{	photo: "/photos/200708francoforte.jpg", 
						caption: "<b>August 2007:</b> Amy helped Jason and Nicolet add <b>Ariella</b> to the family."
					},
					{	photo: "/photos/200708miller.jpg", 
						caption: "<b>August 2007:</b> Amy assisted Shannon through her labor, and we're pleased to introduce <b>Freija Tunstall</b> to the world!"
					}, 
					{	photo: "/photos/200609elsesser.jpg", 
						caption: "<b>September 2006:</b> Katelyn and Brian's first child, <b>Trey Allen Elsesser</b>, arrived on Labor Day into the arms of a very warm and loving family with a little help from Amy."
					},
					{	photo: "/photos/200608snow.jpg", 
						caption: "<b>August 2006:</b> We're proud to introduce <b>Cooper Timothy Snow</b> to the world, Don and Emily's first child.  Emily's birth took a little longer than usual, so we tag-teamed with great success."
					},
					{	photo: "/photos/200606delia.jpg", 
						caption: "<b>June 2006:</b> Brenda provided labor support for Karen and Scott for the birth of their daughter Delia."
					},
					{	photo: "/photos/200605sheesley.jpg", 
						caption: "<b>May 2006:</b> Brenda was there to support Shawn and Jennifer through Jennifer's labor and the birth of their son Evan."
					}						
				];


var currentPhoto = 0;
var MODE_ON = 0;
var MODE_OFF = 1;

var photoTimer = setInterval("nextPhoto();", 10000);

function padL(x, width, padChar) {
	// Pads a number with [padchar] to make it [width] digits long.
	var temp = x.toString();
	if(temp.length < width) {
		for(var i = temp.length; i < width; i++) {
			temp = padChar + temp;
		}
	}
	
	return temp;	
}	

function getPhotos() {
	// Retrieves all of the photos that are to be loaded into the 
	// revolving gallery.
	for(var i = 0; i < photoList.length; i++) {
		var img = new Image();
		img.src = photoList[i].photo;
	}
}

function prevPhoto(killTimer) {
	// Move to the previous photo or back to the end of the list 
	// if we move past the first photo.
	currentPhoto--;
	if(currentPhoto < 0)
		currentPhoto = photoList.length - 1;
		
	setPhoto(currentPhoto, killTimer);
}

function nextPhoto(killTimer) {
	// Move to the next photo or back to the beginning of the list
	// if we move past the last photo.
	currentPhoto++;
	if(currentPhoto > photoList.length - 1)
		currentPhoto = 0;
		
	setPhoto(currentPhoto);
}

function setPhoto(x, killTimer) {
	// Set the photo specified into the gallery frame.
	var currentPhotoDiv = document.getElementById("currentPhotoDiv");
	var currentPhotoCaption = document.getElementById("photoLabel");	
	
	// Get our new photo ready to go.
	var img = document.createElement("img");
	img.style.border = "none";
	img.src = photoList[x].photo;

	// Remove the current photo if one exists.
	if(currentPhotoDiv.childNodes[0])
		currentPhotoDiv.removeChild(currentPhotoDiv.childNodes[0]);
	
	// Add the photo to the container.	
	currentPhotoDiv.appendChild(img);
	
	// Set the photo caption.
	currentPhotoCaption.innerHTML = photoList[x].caption;	
	
	// If we've specified that we need to kill the timer, do so.
	if(photoTimer && killTimer == true) {
		clearInterval(photoTimer);
		photoTimer = undefined;
	}
}	

function switchMe(btn, mode) {
	// Switches an image for a rollover.  This assumes that
	// the rollover image is named identically to the original
	// except that it has a "-on" suffix before the extension.
	var imgType = btn.src.substring(btn.src.lastIndexOf("."), btn.src.length);
		
	if(mode == MODE_ON) {
		btn.src = btn.src.replace(imgType, "-on" + imgType);
	} else {
		btn.src = btn.src.replace("-on" + imgType, imgType);
	}			
}