How to change floating sidebar js code so that it works with ajax pagination?
<p>I have a floating sidebar in my website <pre>www.rayshaft.com</pre> and I also have ajax pagination, so the sidebar is supposed to be floating until it reaches the footer of the page, but the problem is it works only with the 1st page, when the 2nd page is loaded via ajax the sidebar is not floating.
I was suggested to change my js code so that every time after ajax page load i need to call scroll function again or i need to recalculate maxY and footTop ech time scroll happens. I don't know any js programming so could you please help me. How can I modify this code to get what I want?</p>

<pre><code>$(window).load(function(){
$(function() {
    var top = $('#sidebar').offset().top - parseFloat($('#sidebar').css('marginTop').replace(/auto/, 0));
    var footTop = $('#footer').offset().top - parseFloat($('#footer').css('marginTop').replace(/auto/, 0));

    var maxY = footTop - $('#sidebar').outerHeight();

    $(window).scroll(function(evt) {
        var y = $(this).scrollTop();
        if (y &gt; top) {
            if (y &lt; maxY) {
                $('#sidebar').addClass('fixed').removeAttr('style');
            } else {
                $('#sidebar').removeClass('fixed').css({
                    position: 'absolute',
                    top: (maxY - top) + 'px'
                });
            }
        } else {
            $('#sidebar').removeClass('fixed');
        }
    });
</code></pre>
