//plugin jQuery.fn.topLink = function(settings) { settings = jQuery.extend({ min: 1, fadeSpeed: 200 }, settings); return this.each(function() { //listen for scroll var el = $(this); el.hide(); //in case the user forgot $(window).scroll(function() { if($(window).scrollTop() >= settings.min) { el.fadeIn(settings.fadeSpeed); } else { el.fadeOut(settings.fadeSpeed); } }); }); }; //usage w/ smoothscroll $(document).ready(function() { //set the link $('#top-link').topLink({ min: 400, fadeSpeed: 500 }); //smoothscroll $('#top-link').click(function(e) { e.preventDefault(); $.scrollTo(0,300); }); }); $(window).load(function () { $('.posts').masonry(), $('.masonryWrap').infinitescroll({ navSelector : "div#navigation", // selector for the paged navigation (it will be hidden) nextSelector : "div#navigation a#nextPage", // selector for the NEXT link (to page 2) itemSelector : ".box", // selector for all items you'll retrieve bufferPx : 10000, extraScrollPx: 11000, loadingImg : "http://b.imagehost.org/0548/Untitled-2.png", loadingText : "", }, // call masonry as a callback. function() { $('.posts').masonry({ appendedContent: $(this) }); } ); });