!function(o){o.fn.totopscroller=function(t){var l={showToBottom:!0,showToPrev:!0,link:!1,linkTarget:"_self",toTopHtml:'<a href="#"></a>',toBottomHtml:'<a href="#"></a>',toPrevHtml:'<a href="#"></a>',linkHtml:'<a href="#"></a>',toTopClass:"totopscroller-top",toBottomClass:"totopscroller-bottom",toPrevClass:"totopscroller-prev",linkClass:"totopscroller-lnk"},e=o.extend({},l,t),s=0,n=this,i=null,a=null,r=null,d=null,c=null,p=function(){c=o("<div></div>"),e.showToBottom&&(a=o(e.toBottomHtml),a.hide(),a.addClass(e.toBottomClass),a.appendTo(c)),e.showToPrev&&(r=o(e.toPrevHtml),r.hide(),r.addClass(e.toPrevClass),r.appendTo(c)),i=o(e.toTopHtml),i.hide(),i.addClass(e.toTopClass),i.appendTo(n),e.link&&(d=o(e.linkHtml),d.attr("target",e.linkTarget),d.attr("href",e.link),d.addClass(e.linkClass),d.appendTo(n)),c.appendTo(n),i.click(function(t){t.preventDefault(),s=o(document).scrollTop(),o("html, body").animate({scrollTop:0},{duration:"slow",complete:function(){m()}})}),e.showToBottom&&a.click(function(t){t.preventDefault(),s=0,o("html, body").animate({scrollTop:o(document).height()},{duration:"slow",complete:function(){m()}})}),e.showToPrev&&r.click(function(t){t.preventDefault(),o("html, body").animate({scrollTop:s},{duration:"slow",complete:function(){s=0,m()}})})},m=function(){o(document).scrollTop()>0?i.is(":visible")||i.fadeIn("slow"):i.is(":visible")&&i.fadeOut("slow"),o(window).scrollTop()+o(window).height()==o(document).height()||s>0?a.is(":visible")&&a.fadeOut("slow"):a.is(":visible")||a.fadeIn("slow"),s>0?r.is(":visible")||r.fadeIn("slow"):r.is(":visible")&&r.fadeOut("slow")};return o(window).scroll(function(){o("html, body").is(":animated")||m()}),p(),m(),this}}(jQuery);