$(document).ready(function(){
	$('#gallery-navigation ol').click(function(event)
	{
		// Clear the gallery section and load the gallery html of the new category
		$('#gallery-grid').hide().load(event.target['href'] + '?ajax=section-gallery-images', function()
		{ 
			// Fade the new gallery html in
			$(this).fadeIn();
			$('#gallery-grid a.gallery-image').fancybox({
				titlePosition: 'inside'
			});
		});
		
		// Remove the selected class from the previously selected category
		$('#gallery-navigation a.selected').removeClass('selected');
		
		// Add the selected class to the newly selected category
		$(event.target).addClass('selected');
		
		// Change the title of the page to the newly selected category
		document.title = $(event.target).text() + ' - Gallery - Philip Ayers';

		// Disable any default action
		return false;
	});

	$('#gallery-grid a.gallery-image').fancybox({
		titlePosition: 'inside'
	});
});
