function rotateImages(){ var curphoto = $('img.current'); var nextphoto = curphoto.next(); if(nextphoto.length == 0){ nextphoto = $('.mask img:first'); } curphoto.removeClass('current').addClass('previous'); nextphoto.css({opacity:0.0}).addClass('current').animate({opacity:1.0}, 1000, function(){ curphoto.removeClass('previous'); }) } function rotateTestimonial(){ var count = $(".tmask li").length; var liwidth = 300; var total = count*liwidth; total = total - total - total; var current = parseInt($(".tmask ul").css('margin-left').replace('px', '')); left = current - liwidth; if(left <= total){ left = 0; } $('.tmask ul').animate({ marginLeft: left+"px" }); }