jQuery - Infinite scrolling

jQuery - Infinite scrolling

I'm trying to implement infinite scrolling on my page, how ever something has messed up, instead of triggering at the bottom of the page it's triggering when I scroll back to the top. Does anyone know what could be triggering this?

$(window).scroll(function()
{
   
if($(window).scrollTop() == $(document).height() - $(window).height())
   
{
        alert
("hello");
   
}
});

I'm currently using the code above, which works in jsfiddle just fine. I also tried an alternative of -

if($(window).scrollTop() + $(window).height() == $(document).height())

Note: I'm using CodeIgniter (although im not sure this would cause the problem?)

If you'd like to take a look at what I mean you can check out the test page athttp://carllawl.kwebserv.info/recent (just scroll down then back up to see what I mean)