$(document).ready(function(){
    var nombre_image_defilement = 3;
    var sizeMoveSlide = nombre_image_defilement * 166;
    var position = new Array()
    var indice_img = new Array();
    var last_img = new Array();
    var universe_id = 0;

    position[2] = 0;
    indice_img[2] = 1;
    last_img[2] = $('#2').children().length;
    if(indice_img[2] >= (last_img[2] - nombre_image_defilement))
    {
        $('#2').parent().next().css('visibility','hidden');
    }
    $('.program_list_left_arrow').css('visibility','hidden');
    $('.program_list_right_arrow').click(function()
    {
        universe_id = $(this).prev().children().attr('id');
        if(indice_img[universe_id] < (last_img[universe_id] - nombre_image_defilement))
        {
            $(this).prev().prev().css('visibility','visible');
            position[universe_id] -= sizeMoveSlide;
            $(this).prev().children().animate({left:position[universe_id]},'slow');
            indice_img[universe_id] += nombre_image_defilement;
            if(indice_img[universe_id] >= (last_img[universe_id] - nombre_image_defilement))
            {
                $(this).css('visibility','hidden');
            }
        }
    });

    $('.program_list_left_arrow').click(function()
    {
        universe_id = $(this).next().children().attr('id');
        if(position[universe_id] != 0)
        {
            $(this).next().next().css('visibility','visible');
            indice_img[universe_id] -= nombre_image_defilement;
            position[universe_id] += sizeMoveSlide;
            $(this).next().children().animate({left:position[universe_id]},'slow');
        }
        if(position[universe_id] == 0)
        {
            $(this).css('visibility','hidden');
        }
    });
});
