/**
 * make motion of jump to an anchor smooth
 * 
 * $('#box a').smooth_anchor({'duration':1000, 'callback':function(){alert('OK')}});
 * 
 * Released under the MIT licence:
 * http://www.opensource.org/licenses/mit-license.php
 */
(function ($) {
	$.fn.smooth_anchor = function ($options) {
		var defaults = {
			diff: -20,
			duration: 'slow',
			easing: 'swing',
			callback: null
		};
		var conf = $.extend(defaults, $options);
		return this.each(function () {
			var self = $(this);
			var href = self.attr('href');
			self.click(function () {
				$(/safari/i.test(navigator.userAgent) ? 'body' : 'html')
					.animate({scrollTop:$(href).offset().top + conf.diff}, conf.duration, conf.easing, conf.callback);
				return false;
			});
		});
	};
})(jQuery);

