var $childinterval = new Array(); function slideSwitch() { // Primary controller var $active = $('#imgcol1 IMG.active'); if ($active.length == 0) $active = $('#imgcol1 IMG:last'); var $next = $active.next().length ? $active.next() : $('#imgcol1 IMG:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); // This is only called if we have child columns if (cols > 1) { $(function() { for (var i = 2; i <= cols; i++) { // sets up all the intervals for each child column $childinterval[i] = setInterval("slideChildren("+i+")", (600+((i-2)*offset))); } }); } } function slideChildren(col) { // Fades the children after a delay var $active = $('#imgcol'+col+' IMG.active'); if ($active.length == 0) $active = $('#imgcol'+col+' IMG:last'); var $next = $active.next().length ? $active.next() : $('#imgcol'+col+' IMG:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); clearInterval($childinterval[col]); }