$(function(){
    $back = $("p#back-to-top");
    $maxHeight = document.body.offsetHeight;
     $(window).scroll(function(){
         $currHeight = $(window).scrollTop();
         if ($currHeight > 100 && $currHeight < $maxHeight ){
             $back.fadeIn(1000);
         }else if ($currHeight < 100) {
             $back.fadeOut(1000);
         }
     });

     $back.click(function(){
         $('body,html').animate({scrollTop:0},1000);
         return false;
     });
})
     

