jQuery(function(){ 

  jQuery.fn.scrollToTop=function(){

    jQuery(this).hide().removeAttr("href");

    if(jQuery(window).scrollTop()!="0"){
      jQuery(this).fadeIn("slow")
    }
    
    var scrollDiv=jQuery(this);

    jQuery(window).scroll(function(){
      if(jQuery(window).scrollTop()=="0"){ 
        jQuery(scrollDiv).fadeOut("slow")
      } else{ 
        jQuery(scrollDiv).fadeIn("slow")
      }
    });
    
    jQuery(this).click(function(){
//      jQuery("html, body").animate({scrollTop:0},"slow")
          jQuery("html, body").animate({scrollTop:0}, {duration:'slow', easing: 'bounceout'});           
    })
  }
});


jQuery(document).ready(function(){
  jQuery("#toTop").hover(function(){
    jQuery("#toTop img")
    .animate({top:"-10px"}, 200).animate({top:"-4px"}, 200) // first jump
    .animate({top:"-7px"}, 100).animate({top:"-4px"}, 100) // second jump
    .animate({top:"-6px"}, 100).animate({top:"-4px"}, 100); // the last jump
  });
}); 
            
            
jQuery(function() {
  jQuery("#toTop").scrollToTop();
});