/*
	smoothScroll v1.0.0.0
=========================================*/
$.smoothScroll = {
	init: function() {
		$("a.smooth").bind("click", this.smooth)
	},
	smooth: function() {
		var ani;
		clearInterval(ani);
		var pos = $(document).scrollTop();
		var target = $($(this).attr("href")).offset().top;
		target = ($(document).height() - target) > $(window).height() ? target : $(document).height() - $(window).height();
		var edging = 0;
		var rate = 150;
		var i = 0;
		function animation() {
			var c = i / rate;
			pos += (target - pos) * (c + edging / (100 * Math.PI) * Math.sin(Math.PI * c));
			$(document).scrollTop(pos);
			i++;
			if (Math.abs(target - pos) < 1) {
				clearInterval(ani);
			}
		}
		ani = setInterval(animation, 8);
		return false;
	}
};
$(document).ready(function() {
	$.smoothScroll.init();
});

