// JavaScript Document

function SetButtonStatusesV(currentPosition, maxNumber, nb){
    if (currentPosition + maxNumber >= nb) {
        $('#downscroll img').attr({
            "src": "Images/down_disabled.png"
        });
        $('#downscroll img').unbind("click");
    }
    else {
        $('#downscroll img').attr({
            "src": "Images/down.png"
        });
        $('#downscroll img').click(ScrollV);
    }
    
    if (currentPosition <= 0) {
        $('#upscroll img').attr({
            "src": "Images/up_disabled.png"
        });
        
        $('#upscroll img').unbind("click");
    }
    else {
        $('#upscroll img').attr({
            "src": "Images/up.png"
        });
        $('#upscroll img').click(ScrollV);
    }
}

function ScrollV(){

    if ($(this).attr("alt") == "up") 
        direction = 1;
    else 
        direction = -1;
    
    var item_height = $('#vcarousel_ul li').outerHeight();
    var top_indent = parseInt($('#vcarousel_ul').css('top')) + (direction * item_height);
    var currentPosition = -parseInt(top_indent / item_height);
    
    $('#vcarousel_ul').animate({
        'top': top_indent
    }, 500, function(){
        $('#vcarousel_ul').css({
            'top': top_indent
        });
        
    });
    
    SetButtonStatusesV(currentPosition, maxNumberV, nbV);
    
    
}


$(document).ready(function(){
    nbV = $('#vcarousel_ul li').size();
    maxNumberV = 4;
    $('#upscroll img').attr({
        "src": "Images/up_disabled.png"
    });
    if (nbV > maxNumberV) {
        $('#downscroll img').click(ScrollV);
    }
    else {
        $('#downscroll img').hide();
        $('#upscroll img').hide();
    }
});

