Javascript Function to do Infinite Scroll