$(document).ready(function () {
    var negativeMoveLeft = "";
    var negativeArrowLeft = "";

    if ($('#carousel_ul').hasClass('cornedtuna')) {
        negativeMoveLeft = '-287px';
        negativeArrowLeft = '-22px';
    }
    else if ($('#carousel_ul').hasClass('novideo')) {
        negativeMoveLeft = '-160px';
        negativeArrowLeft = '-22px';
    }
    else if ($('#carousel_ul').hasClass('withvideo')) {
        negativeMoveLeft = '-160px';
        negativeArrowLeft = '-22px';
    }

    $('#carousel_ul li:first').before($('#carousel_ul li:last'));

    $('#right_scroll img').click(function () {
        var item_width = $('#carousel_ul li').outerWidth() + 10;
        var left_indent = parseInt($('#carousel_ul').css('left')) - item_width;


        $('#carousel_ul:not(:animated)').animate({ 'left': left_indent }, 600, function () {
            $('#carousel_ul li:last').after($('#carousel_ul li:first'));
            $('#carousel_ul').css({ 'left':  negativeMoveLeft });
        });
    });

    $('#left_scroll img').click(function () {
        var item_width = $('#carousel_ul li').outerWidth() + 10;
        var left_indent = parseInt($('#carousel_ul').css('left')) + item_width;

        $('#carousel_ul:not(:animated)').animate({ 'left': left_indent }, 600, function () {
            $('#carousel_ul li:first').before($('#carousel_ul li:last'));
            $('#carousel_ul').css({ 'left':  negativeMoveLeft });
        });
    });

    $('#left_scroll img, #right_scroll img').hover(function () {
        $(this).css('margin-left', negativeArrowLeft);
    }, function () {
        $(this).css('margin-left', '0');
    });

    $('#carousel_ul li').hover(function () {
        $(this).find('p').stop().animate({ top: '114px' }, { queue: false, duration: 250 });
    }, function () {
        $(this).find('p').stop().animate({ top: '150px' }, { queue: false, duration: 250 });
    });
});

