$(document).ready(function() {

    //rotation speed and timer
    // var speed = 5000;
    // Luc no need this var run = setInterval('rotate()', speed);   
     
    //grab the width and calculate left value
    var item_width2 = $('#slides2 li').outerWidth(); 
    var left_value2 = item_width2 * (-1); 
        
    //move the last item before first item, just in case user click prev button
//    $('#slides2 li:first').before($('#slides2 li:last'));
     
    //set the default item to the correct position 
    $('#slides2 ul').css({'left' : left_value2});
 
    //if user clicked on prev button
    $('#prev2').click(function() {
        //get the right position            
        var left_indent2 = parseInt($('#slides2 ul').css('left')) + item_width2;
 
        //slide the item            
        $('#slides2 ul').animate({'left' : left_indent2}, 400,function(){    
 
            //move the last item and put it as first item               
            $('#slides2 li:first').before($('#slides2 li:last'));           
 
            //set the default item to correct position
            $('#slides2 ul').css({'left' : left_value2});
         
        });
 
        //cancel the link behavior            
        return false;
             
    });
 
  
    //if user clicked on next button
    $('#next2').click(function() {
         
        //get the right position
        var left_indent2 = parseInt($('#slides2 ul').css('left')) - item_width2;
         
        //slide the item
        $('#slides2 ul').animate({'left' : left_indent2}, 400, function () {
             
            //move the first item and put it as last item
            $('#slides2 li:last').after($('#slides2 li:first'));                  
             
            //set the default item to correct position
            $('#slides2 ul').css({'left' : left_value2});
         
        });
                  
        //cancel the link behavior
        return false;
         
    });        
     
});
 
function rotate() {
    $('#next2').click();
}


