Uncaught TypeError: Cannot read property 'top' of null : conflct
<p>I wrote this code to create a floating sidebar that sticks at top of the browser window.  I am getting this error in chrome in line 3.</p>

<pre><code>Uncaught TypeError: Cannot read property 'top' of null 
</code></pre>

<p>this is causing a plugin I am using not to work.</p>

<pre><code>$(document).ready(function(){
    // Floating sidebars on page nodes
    var sidebartop = $('.page-node .panels-flexible-region-node_layout-right').offset().top;
    $(window).scroll(function(){
        if( $(window).scrollTop() &gt; sidebartop ) {
            $('.page-node .panels-flexible-region-node_layout-right').css({position: 'fixed', top: '40px', margin: '0 0 0 650px'});
        } else {
            $('.page-node .panels-flexible-region-node_layout-right').css({position: 'static', margin: '-35px 0 0 0'});
        }
    });
});
</code></pre>
