Still suffering from Mike's problems, here is the new code, same as the old code, it was my testing that was flawed, the code works fine.
Just after this line:
add this line:
Replace this line:
with these lines:
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0