How can I get my div to fade back out with jquery
<p>I'm trying to fade in a div when it scrolls into view from 0.4 to 1 which works fine but I carnt get it to fade back to 0.4 when the user has scrolled past it. How can I get it to do that?</p>

<pre><code>tiles = $("#project_images img").fadeTo(0, 0.4); // set the default image opacity to semi transparent

    $(window).scroll(function(d,h) {
        tiles.each(function(i) {
            a = $(this).offset().top + $(this).height();
            b = $(window).scrollTop() + $(window).height();
            if (a &lt; b) $(this).fadeTo(1040,1); // when scrolling down over the image fade it IN.
            if (a &gt; b) $(this).fadeTo(1040, 0.4); // when scrolling down over the image fade it OUT.
        });
    });
</code></pre>

<p></p>
