/*
 * smooth.js
 *
*/


jQuery.easing.easeOut = function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t*t*t*t*t + 1) + b;
};

$(document).ready(function(){
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target
      || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        var windowHeight = $(window).height();
        var bodyHeight = $("html").height();
        if ((bodyHeight - targetOffset) < windowHeight) {
        	targetOffset = bodyHeight - windowHeight;
        }
        var duration = 1500;
        $('html,body')
        .animate({ scrollTop: targetOffset }, duration, 'easeOut')
       return false;
      }
    }
  });
});
