$(document).function(){(function(){ var ct = 1; var animation = ['slide','fade','explode']; var iStack = [] $('.flickrimg').each(function(){ iStack.push( new Image($(this).parent().find('div').text())); }); var FlickerMove = function(){ if(ct == $(".flickrimg").length){ window.location.reload(); }else{ $("#swap").fadeOut(750,function(){ $("#swap").hide().attr('src',$($('.flickrimg')[ct++]).parent().find('div').text()) setTimeout(function(){ $("#swap").fadeIn(750) },100); }); } } setInterval(function(){FlickerMove();},5000); })()});