var currentPicture = 1;
var totalPictures = 54;

var pictureDescription = new Array(54); 
pictureDescription[0] = ""; 
pictureDescription[1] = "The Beginning..."; 
pictureDescription[2] = "The site.";
pictureDescription[3] = "The bride arrives!";
pictureDescription[4] = "The groom is ready!";
pictureDescription[5] = "Does it still fit?";
pictureDescription[6] = "Last minute primping.";
pictureDescription[7] = "Ah... the hairdo.";
pictureDescription[8] = "Thank you Weight Watchers!";
pictureDescription[9] = "Kristin and Denise.";
pictureDescription[10] = "Proud Mom and her daughter.";
pictureDescription[11] = "The bride can hardly wait!";
pictureDescription[12] = "Knock knock...";
pictureDescription[13] = "Who's there?";
pictureDescription[14] = "Love.";
pictureDescription[15] = "Love who?  Love you!";
pictureDescription[16] = "Greg";
pictureDescription[17] = "The classic bridal pose.";
pictureDescription[18] = "Aren't the fall colours wonderful?";
pictureDescription[19] = "Sigh! I can't believe we're getting married today!";
pictureDescription[20] = "Denise, Chris, Greg, Kristin, Jennie, and Dave.";
pictureDescription[21] = "The happy couple with the brides parents.";
pictureDescription[22] = "Both sets of proud parents.";
pictureDescription[23] = "The Peres' and Baba Boyuk.";
pictureDescription[24] = "The Dorsey clan and Greg.";
pictureDescription[25] = "A proud Papa and his Tootlebug.";
pictureDescription[26] = "Big brother and little sis.";
pictureDescription[27] = "'Skinny mommy' and her son. :D";
pictureDescription[28] = "Like father... Like son.";
pictureDescription[29] = "The three Peres boys.  Two for sale... Cheap!";
pictureDescription[30] = "What's that she's saying?";
pictureDescription[31] = "They're on their way.";
pictureDescription[32] = "Breathtaking.";
pictureDescription[33] = "A pretty cute couple.";
pictureDescription[34] = "Sanctuary.";
pictureDescription[35] = "No words necessary.";
pictureDescription[36] = "Going to the chapel... Well not really.";
pictureDescription[37] = "Which one is more nervous?";
pictureDescription[38] = "And we're gonna get married...";
pictureDescription[39] = "You may kiss the bride!";
pictureDescription[40] = "Gregory and Kristin Peres";
pictureDescription[41] = "The reception hall.";
pictureDescription[42] = "The first toast.";
pictureDescription[43] = "Noni smiling.";
pictureDescription[44] = "The lights of the city and a new husband and wife.";
pictureDescription[45] = "The first dance.";
pictureDescription[46] = "Is her man suave or what?";
pictureDescription[47] = "Daddy and his girl.";
pictureDescription[48] = "Kristin with her new (god)father-in-law.";
pictureDescription[49] = "Greg and his beautiful mom.";
pictureDescription[50] = "Neil and Jess, still hot after 5 months.";
pictureDescription[51] = "Cutting the cake.";
pictureDescription[52] = "Or is he dueling with the cake?";
pictureDescription[53] = "All that work was worth it.";
pictureDescription[54] = "Off to the honeymoon!";

function checkNumeric()
{
	var key = window.event.keyCode;
	theString = String.fromCharCode(key);
	if ( key > 47 && key < 58 ) return;
   	else
   	{
   		changeAlert("<b>'" + theString + "' is <i>NOT</i> a number. Please try again.</b>");
   		window.event.returnValue = null;
   	}
}

function getElement(id)
{
	return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null;
}

function changeCounter(counterNumber)
{
	var anElement = getElement("theCounter");
	if (anElement && typeof anElement.innerHTML != 'undefined') 
	{
		anElement.innerHTML = "Wedding Photo #" + counterNumber + " of "+ totalPictures +".";
	}
}

function changeMessage(theMessage)
{
	var anElement = getElement("theMessage");
	if (anElement && typeof anElement.innerHTML != 'undefined') 
	{
		anElement.innerHTML = theMessage;
	}
}

function changeAlert(alertMessage)
{
	var anElement = getElement("anAlert");
	if (anElement && typeof anElement.innerHTML != 'undefined') 
	{
		anElement.innerHTML = alertMessage;
	}
}

function home()
{
	currentPicture = 1;
	document.WeddingPhotos.thePicture.src = "/images/WeddingPhotos/" + currentPicture + ".jpg";
	changeCounter(currentPicture);
	changeMessage(pictureDescription[currentPicture]);
	changeAlert("&nbsp;");
	document.WeddingPhotos.jumpTo.value = "";
}

function next()
{
	currentPicture++;
	if(currentPicture > totalPictures) currentPicture = 1;
	document.WeddingPhotos.thePicture.src = "/images/WeddingPhotos/" + currentPicture + ".jpg";
	changeCounter(currentPicture);
	changeMessage(pictureDescription[currentPicture]);
	changeAlert("&nbsp;");
	document.WeddingPhotos.jumpTo.value = "";
}

function previous()
{
	currentPicture--;
	if(currentPicture < 1) currentPicture = 54;
	document.WeddingPhotos.thePicture.src = "/images/WeddingPhotos/" + currentPicture + ".jpg";
	changeCounter(currentPicture);
	changeMessage(pictureDescription[currentPicture]);
	changeAlert("&nbsp;");
	document.WeddingPhotos.jumpTo.value = "";
}

function jumpToPicture()
{
	var imageNumber = document.WeddingPhotos.jumpTo.value;
	
	// Check to make sure the image is in the correct range.
	if ((imageNumber > totalPictures) || (imageNumber < 1))
	{
		changeAlert("<b>Please enter a number between <i>1 and " + totalPictures + "</i>.</b>");
		document.WeddingPhotos.jumpTo.value = "";
	}
	else
	{
		document.WeddingPhotos.thePicture.src = "/images/WeddingPhotos/" + imageNumber + ".jpg";
		changeCounter(imageNumber);
		changeMessage(pictureDescription[document.WeddingPhotos.jumpTo.value]);
		changeAlert("&nbsp;");
		document.WeddingPhotos.jumpTo.value = "";
	}
}
