(function($){$(document).ready(function(){

	/* Create a reference to the main staff photo image */
	var jMainStaffPhotoImage = $('img#staffPhoto_main');

	/* Make the main image change when the thumbnails are clicked */
	$('div#staffPhoto_container div.extras a').click(function(){

		/* Using jQuery to get the HREF so it doesn't add the full path */
		jMainStaffPhotoImage.attr('src', $(this).attr('href'));
		return false;

	});

	/* When the main photo is clicked, go to the next photo */
	jMainStaffPhotoImage.click(function(){

		/* Get the main photo's src */
		var mainHREF = jMainStaffPhotoImage.attr('src');

		/* Find the anchor tag with the same HREF as the main photo's src */
		var matchingThumb = $('div#staffPhoto_container div.extras a[@href=' + mainHREF + ']');

		/* Find the next anchor tag -OR- the first anchor tag if the matchingThumb was the last anchor tag */
		var nextThumb = matchingThumb.next().size() ? matchingThumb.next() : $('div#staffPhoto_container div.extras a:first');

		/* Update the main photo's src */
		jMainStaffPhotoImage.attr('src', nextThumb.attr('href'));

		return false;

	});

});})(jQuery);
