$(document).ready(function(){

	/*

	if(window.location.hash) {
		$('html,body').animate({scrollTop: $(window.location.hash).offset().top - 50},'slow');
	}	

	$("nav a").click(function(event) {
		var target = $(this).attr("id").split("-")[1];
		
		if(target == "welcome" && $("nav").hasClass("sticky")) {
			$('html,body').animate({scrollTop: $("#"+target).offset().top},'slow');
		}
		else {
			$('html,body').animate({scrollTop: $("#"+target).offset().top - 50},'slow');
		}
				
		event.preventDefault();
	});

	$(window).scroll(function () { 
		checkActiveNavigation();		
	});
	
	function checkActiveNavigation() {
		$("section").each(function() {
			element = $(this);
			windowOffset = $(window).scrollTop();
			elementOffset = element.offset().top - 50;
			elementHeight = element.height();
			
			if(windowOffset >= elementOffset - ($(window).height()/2) && windowOffset < elementOffset + (elementHeight - $(window).height()/4))
			{
				link = $("#goto-"+element.attr("id"));
				if(link.hasClass("active") == false)
				{
					$("nav .wrapper a.active").removeClass("active");
					link.addClass("active");
				}
			}			
		});		

		if($(window).scrollTop() > 165 && $("nav").hasClass("sticky") == false) {			
			$("nav").addClass("sticky");
			$("#welcome").css("padding-top", "100px");
		}
		if($(window).scrollTop() <= 164 && $("nav").hasClass("sticky") == true) {	
			$("nav").removeClass("sticky");
			$("#welcome").css("padding-top", "50px");
		}
	};
	
	*/

});
