(function(){ jQuery.fn.isinwindow = function(){ var top = $(window).scrollTop(); var bottom = $(window).height() + $(window).scrollTop(); var left = $(window).scrollLeft(); var right = $(window).width() + $(window).scrollLeft(); return this.offset().top >= top && this.offset().top + this.height() <= bottom && this.offset().left >= left && this.offset().left + this.width() <= right; }; jQuery.fn.in