Caylus, var photoCount = $('#header-image img').length; if (photoCount >1) { function slideSwitch() { var $active = $('#header-image img.active'); if ($active.length === 0) $active = $('#header-image img:last'); var $next = $active.next().length ? $active.next() : $('#header-image img:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function () { $active.removeClass('active last-active'); }); } $(function () { setInterval("slideSwitch()", 12000); }); } // Join form fancybox overlay agreements