//Assign a timer, so it will run periodically
    var sto = setTimeout('newsslider2()', speed2); 

$(document).ready(function() {
 
    $('#gallery2 li:first').addClass('selected');
 
});
 
 
function newsslider2() {
 
    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image2 = $('#gallery2 li.selected').length ? $('#gallery2 li.selected') : $('#gallery2 li:first');
 
    //Get next sibling
    var next_image2 = (current_image2.next().next().length) ? current_image2.next().next() : $('#gallery2 li:first');
    var animSpeed2 = (current_image2.next().next().length) ? 500 : 100;
        
    //clear the selected class
    $('#gallery2 li').removeClass('selected');
     
    //reassign the selected class to current items
    next_image2.addClass('selected');
 
    //Scroll the items
    $('#mask-gallery2').scrollTo(next_image2, animSpeed2, {
        'onAfter' : setSto()
    });      
    
}

function newsslider2down() {
 
    //Get the current selected item (with selected class), if none was found, get the first item
    var current_image2 = $('#gallery2 li.selected').length ? $('#gallery2 li.selected') : $('#gallery2 li:first');
 
    //Get next sibling
    var next_image2 = (current_image2.prev().prev().length) ? current_image2.prev().prev() : $('#gallery2 li:last');
    var animSpeed2 = (current_image2.prev().prev().length) ? 500 : 100;
        
    //clear the selected class
    $('#gallery2 li').removeClass('selected');
     
    //reassign the selected class to current items
    next_image2.addClass('selected');
 
    //Scroll the items
    $('#mask-gallery2').scrollTo(next_image2, animSpeed2, {
        'onAfter' : setSto()
    });      
    
}

function setSto() {
    clearTimeout(sto);
    sto = setTimeout('newsslider2()', speed2); 
}

