
$(document).ready(function() {
	
	var end_of_timeline = $('#invite-box').offset().top - 230;
	var $timeline_pointer = $('#timeline-pointer');
	
	/* initialize smoothscroll, set points for auto active state in nav */
	var vertical_marks = new Array();
	$('a.smoothscroll').each(function(i,n){
		var link = $(this).attr('href');
		vertical_marks[i] = link;
	}).smoothScroll();

	/* bind window scroll to update active state */
	$(window).scroll(function() {
		var y = window.pageYOffset;
		var active_menu_item = '';
		$(vertical_marks).each(function(i,n){
			if( y >= $(n).offset().top - 100 ) {
				active_menu_item = $(n).attr('id');
			}
		});
		$('a.smoothscroll').removeClass('active');
		$('#link_for_'+active_menu_item).addClass('active');
		if( $(window).scrollTop() > end_of_timeline ) {
			$timeline_pointer.addClass('hidden');
		} else {
			$timeline_pointer.removeClass('hidden');
		}
	});

});

