var ads = [];var currentIndex = 0;var transitionTime = 5000;var timeout = null;var firstLoad = true;var adRotator = {    start: function (target) {        $(target).each(function () { ads.push($(this)); });        this.transition();    },    transition: function () {        ads[currentIndex].fadeOut(function () {            if (currentIndex < ads.length - 1 && !firstLoad)                currentIndex++;            else                currentIndex = 0;            ads[currentIndex].fadeIn();            if (timeout != null)                clearTimeout(timeout);            timeout = setTimeout(adRotator.transition, transitionTime);            firstLoad = false;        });    }}$(document).ready(function () {    adRotator.start("#adRotator div");});
