$().ready(function() {

	$('.subSectionContainer .subSectionLinks a').click(function() {
		$('.moreLink').hide();
		$('.subSectionLinks > li').removeClass('selected');

		var itemIndex = $('.subSectionContainer .subSectionLinks a').index(this);
		var rootContainer = $(this).closest('.subSectionContainer');

		rootContainer.find('.subSectionLinks > li:eq('+itemIndex+')').addClass('selected');
		rootContainer.find('.subSection').removeClass('selected');
		rootContainer.find('.subSection').hide();
		rootContainer.find('.subSection .extraContent').hide();
		rootContainer.find('.subSection:eq('+itemIndex+')').show();
		rootContainer.find('.subSection:eq('+itemIndex+')').addClass('selected');
		
		
		// Show a more link if there are additional pictures.
		if (rootContainer.find('.subSection.selected .extraContent').length != 0) {
			rootContainer.find('.moreLink').show();
		}
	});
	$('.subSectionContainer .moreLink').click(function() {
		var rootContainer = $(this).closest('.subSectionContainer');
		rootContainer.find('.subSection.selected .extraContent').show();
		rootContainer.find('.moreLink').hide();
	});
	
	
	$('.subSectionContainer .subSectionLinks > li:nth-child(1) a').trigger('click');




});


/*
	Don't put in the subSectionLinks li if there are no photos for the tab.
	Don't put in the extraContent section if there are no extra photos.
	Start the page with the more link hidden.
*/
