function dump(obj, obj_name) {
  var result = "";
  for (var i in obj)
    result += obj_name + "." + i + " = "+ obj[i] + "\n"
  return result
} 


jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'xy';
	
	// Scroll initially if there's a hash (#something) in the url 
 $.localScroll.hash({
		duration: 1500,
		offset: -76,
		onBefore: function(target){
			//alert($('#site_nav').css('top'));
		},

	}); 
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	 
	 
/* 	$.localScroll({
		target: '#1231231', // could be a selector or a jQuery object too.
		queue:true,
		duration:3000,
		hash:false,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
			
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
			//alert('wow');
		}
	}); */

	$('.comment_link').localScroll({
	duration: 1000,
	offset: -76,
    onAfter: function(target){
 		$('#'+target.id).animate({ opacity: 0}, 100, function() {}).animate({ opacity: 1}, 50, function() {}).animate({ opacity: 0}, 100, function() {}).animate({ opacity: 1}, 50, function() {		
			var scrollmem = $('body').scrollTop();
			window.location.hash = "#" + ( target.id || target.name );
			$("html,body").scrollTop($(target).offset().top-76)	
			}); 
	}
	});
	
	$('.down_arrow_link').localScroll({
		target: 'body',
		duration: 1000,
		offset: -76,
		onBefore:function( e, anchor, $target ){
			},
		onAfter: function(target){
				}
	});
	
	
	
	 //var $last = $([]);//save the last link 
	$('.up_arrow_link').localScroll({
		target: 'body',
		duration: 1000,
		offset: -76,
		onBefore:function( e, anchor, $target ){
				//console.log(e.currentTarget.attributes);
				//alert(e.currentTarget.getAttribute("rel"));
				var this_href = e.currentTarget.getAttribute("href");
				var this_rel = e.currentTarget.getAttribute("rel");
				var target_id = this_href;
				var new_target_link = $(target_id+' .down_arrow_link:first').removeClass('hidden').children('a');
				$(new_target_link).attr('rel', this_rel);
			},
		onAfter: function(target){
			$('#'+target.id).animate({ opacity: 0}, 100, function() {}).animate({ opacity: 1}, 50, function() {}).animate({ opacity: 0}, 100, function() {}).animate({ opacity: 1}, 50, function() {	
				var scrollmem = $('body').scrollTop();
				window.location.hash = "#" + ( target.id || target.name );
				//alert(window.location.hash);
				$("html,body").scrollTop($(target).offset().top-76);
				
				var new_target = $('#'+target.id+' .down_arrow_link:first a');
				$(new_target).attr('href', $(new_target).attr('rel'));	
				
				});

	}
	});

});
