$(document).ready(function() {
    //move the last list item before the first item. The purpose of this is if the user clicks previous he will be able to see the last item.
    $('#gallery-1 ul li:first').before($('#gallery-1 ul li:last'));

    //when user clicks the image for sliding right
    $('#gall1-right').click(function() {

        //get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '
        var item_width = 127;  //$('#gallery-1 ul li').outerWidth() + 42;

        //calculate the new left indent of the unordered list
        var left_indent = parseInt($('#gallery-1 ul').css('left')) - item_width;

        //make the sliding effect using jquery's anumate function '

        $('#gallery-1 ul').animate({
            left: left_indent
        }, 500, function() {
            // Animation complete.

            //and get the left indent to the default -127px
            $('#gallery-1 ul').css({ 'left': '-127px' });
            //get the first list item and put it after the last list item (that's how the infinite effects is made) '
            $('#gallery-1 ul li:last').after($('#gallery-1 ul li:first'));



        });

    });

    //when user clicks the image for sliding left
    $('#gall1-left').click(function() {

        var item_width = 127;

        /* same as for sliding right except that it's current left indent + the item width (for the sliding right it's - item_width) */
        var left_indent = parseInt($('#gallery-1 ul').css('left')) + item_width;

        $('#gallery-1 ul').animate({
            left: left_indent
        }, 500, function() {
            // Animation complete.
            /* and again, when we make that change we are setting the left indent of our unordered list to the default -127px */
            $('#gallery-1 ul').css({ 'left': '-127px' });

            /* when sliding to left we are moving the last item before the first item */
            $('#gallery-1 ul li:first').before($('#gallery-1 ul li:last'));
        });

        //  $('#gallery-1 ul').animate({ 'left': left_indent }, { queue: false, duration: 500 }, function() {




    });
});

$(document).ready(function() {
    //move the last list item before the first item. The purpose of this is if the user clicks previous he will be able to see the last item.
    $('#gallery-2 ul li:first').before($('#gallery-2 ul li:last'));

    //when user clicks the image for sliding right
    $('#gall2-right').click(function() {

        //get the width of the items ( i like making the jquery part dynamic, so if you change the width in the css you won't have o change it here too ) '
        var item_width = 127;  //$('#gallery-2 ul li').outerWidth() + 42;

        //calculate the new left indent of the unordered list
        var left_indent = parseInt($('#gallery-2 ul').css('left')) - item_width;

        //make the sliding effect using jquery's anumate function '

        $('#gallery-2 ul').animate({
            left: left_indent
        }, 500, function() {
            // Animation complete.

            //and get the left indent to the default -127px
            $('#gallery-2 ul').css({ 'left': '-127px' });
            //get the first list item and put it after the last list item (that's how the infinite effects is made) '
            $('#gallery-2 ul li:last').after($('#gallery-2 ul li:first'));



        });

    });

    //when user clicks the image for sliding left
    $('#gall2-left').click(function() {

        var item_width = 127;

        /* same as for sliding right except that it's current left indent + the item width (for the sliding right it's - item_width) */
        var left_indent = parseInt($('#gallery-2 ul').css('left')) + item_width;

        $('#gallery-2 ul').animate({
            left: left_indent
        }, 500, function() {
            // Animation complete.
            /* and again, when we make that change we are setting the left indent of our unordered list to the default -127px */
            $('#gallery-2 ul').css({ 'left': '-127px' });

            /* when sliding to left we are moving the last item before the first item */
            $('#gallery-2 ul li:first').before($('#gallery-2 ul li:last'));
        });

        //  $('#gallery-2 ul').animate({ 'left': left_indent }, { queue: false, duration: 500 }, function() {




    });
});
