// jQuery functions for joshkephart.net animations

$(document).ready( function() {
	// generic opacity adjustment to initialize IE, without this IE just makes the content div appear without fade-in the first time (no idea why) - since it is already defaulted to 0 via CSS, this won't be seen
	$('div #content').animate( { opacity: 0 }, 500);
	
	// navigation rollovers
	$('div .nav-link').hover( 
		function() {
			activerollover = $(this).attr('id');
			$('div #'+activerollover+'-rollover').addClass('rollover-active');
		}, 
		function() {
			$('div #'+activerollover+'-rollover').removeClass('rollover-active');
		}
	);
	
	// content loading based on clicked navigation item
	// set activepage to nothing on load for use in if evaluations
	activepage = 'nada';
	$('div .nav-link').click(
		function() {
			nextactivepage = $(this).attr('id');
			if(nextactivepage != activepage) {
				if(activepage != 'nada') { 
					$('div #content').animate( { opacity: 0 }, 500, function() {
						activepage = nextactivepage;
						$('div #content').load('content.html #'+activepage+'-content', function() {
							$('div #content').animate( { opacity: 1 }, 500 );
						});
					});
				}
				else {
					activepage = $(this).attr('id');
					$('div #content').load('content.html #'+activepage+'-content', function() {
						$('div #content').animate( { opacity: 1 }, 1000 );
					});
				}
			}
		}
	);
});