Repeating code

I can’t figure out how to use if/else and setInterval statements on the cross fade slideshow. I am trying to edit the code to have the xml slideshow loop back to the first image and play continuously. I am ok following existing code, not great at writing/editing my own. I thought I needed to work within the nextImage function, and add a slideshow (); function. I haven’t been able to get it right. Here is the code minus the xml loading part:

var id, current;
var k = 0, p = 0;
var slide = 1;

function preloadPic() {
clearInterval(id);
var con = picture.duplicateMovieClip(“con”+k, 9984+k);
con.loadMovie(image[p]);
preloader._visible = 1;
preloader.swapDepths(con.getDepth()+3);
con._alpha = 0;
var temp = _root.createEmptyMovieClip(“temp”+k, 99+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
if (slide) {
id = setInterval(nextImage, 1000);
}
delete this.onEnterFrame;
}
};
}

MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 10;
this._alpha += 10;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};

function nextImage() {
if (p<(total-1)) {
p++;
preloadPic();
} else {
p=0;
preloadPic();
}
}

Disregard. The code is working fine. Loops and all. I have no idea what I did, but I wasted all morning on it. Sigh.