(function($) {

	// Define rating object with some default config settings
	$.scroller = {
		defaults: {
			duration: 1000, // Animation time
			ease:			"swing" // Animation easing effect
		}
	};

	// Extend jquery with the plugin
	$.fn.extend({
		scroller:function(custom_config) {
			// Use defaults or properties supplied by user
			var config = $.extend({}, $.scroller.defaults, custom_config);
			config.contentElement = this;
			
			// Call function to create scrolling effect 
			scroller(config);
			// Return the jquery object for chaining
			return this;
		}
	});
	
  // Create animated scrolling effect 
	function scroller(config) {
    $('a[href*=#]').bind("click", function(e) {
       //prevent the "normal" behaviour which would be a "hard" jump
       e.preventDefault();
       //Get the target
       var target = $(this).attr("href").replace('#','');
       var position = $("a[name="+target+"]").offset().top;
       // var position = 1000; 

       //perform animated scrolling
       $('html,body').stop().animate({
           //get top-position of target-element and set it as scroll target
           scrollTop: position
           //scrolldelay: 2 seconds
       }, config.duration, config.ease ,function(){
           //attach the hash (#jumptarget) to the pageurl
           location.hash = target;
       });
    }
    );
    return false;
	}
})(jQuery);


