Jquery show and hide elements according to position
<p>I am trying to make a carousel of sorts. I am kind of stuck with hiding and displaying the next and precious buttons once a div moves to the far left and right of its container.</p>

<p>I think i have everything correct regarding calculating the widths but for some reason when you click the buttons, elements stay hidden irrespective of the conditional comments which should dictate when they should be hidden or shown.</p>

<p>Here is a link to what i have thus far. Click the MoveLeft and MoveRight buttons. <a href="http://www.ehbeat.com/test/" rel="nofollow">http://www.ehbeat.com/test/</a></p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function () {

        //Check width of Gallery div
        var galleryWidth = $("#Gallery").innerWidth();

        //Check width of GalleryItem
        var galleryItemWidth = $(".GalleryItem").innerWidth();

        //Check distance from left
        var position = $('.GalleryItem').position();
        var galleryItemLeft = position.left;


        $(".MoveRight").click(function () {
            $(".GalleryItem").animate({
                "left": "+=50px"
            }, "slow");
            $(".GalleryItem2").animate({
                "left": "+=100px"
            }, "slow");
        });

        $(".MoveLeft").click(function () {
            $(".GalleryItem").animate({
                "left": "-=50px"
            }, "slow");
            $(".GalleryItem2").animate({
                "left": "-=100px"
            }, "slow");
        });

        $(".Controls").live('click', function () {
            if (galleryItemLeft &gt;= "0") {
                $('.MoveRight').hide();
            }
            else {
                $('.MoveRight').show();
            }
        });

        if (galleryItemWidth == galleryWidth - galleryItemWidth) {
            $('.MoveLeft').hide();
        }


    });
&lt;/script&gt;
</code></pre>
