$(document).ready(function(){

	// Navigation hovering
	var subNavTimer;
	$('ul#navigation > li').hover(
		function() {
			$('li.active_section').removeClass('active_section').addClass('inactive_section');
			$(this).addClass('section_hover').siblings().removeClass('section_hover');
			clearTimeout(subNavTimer);
		},
		function() {
			subNavTimer = setTimeout(function() {
				$('li.section_hover').removeClass('section_hover');
				$('li.inactive_section').removeClass('inactive_section').addClass('active_section');
			}, 5000);
		}
	);

	// Animated scrolling
	$("a[href*=#]").click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
});