Dynamically loaded slider
Few things:


You can create a plugin out of it (create divs #slider and #slides - don't use id, but just reference - and add class slider_wrap in code)
You don't put var before nextImg = new Image();
Instead of new Image you can use jQuery:

$('&lt;img/&gt;').attr('src', path).appendTo($("#slides"));
Instead of $('span.next') use elWrap.find('span.next') because it will not work if span.next is somewhere in the html.
Is always better ot use jQuery not native function because they may be different from browser to browser. So use $(window).scroll(function() { }) $(window).innerHeight() and $(window).scrollTop(); 
Inside newimg you call $("#slides") you can call that before a function and store it's value in variable.