where the setPosition is the number of image and $(images).size() is the total of images in the gallery.
setPosition should be less than $(images).size(), if I want that expresion (image_set && setPosition < $(images).size()) returns true.
The correct is: if(image_set && setPosition < $(images).size()) nextImage.src = images[setPosition + 1];
After this small correction the preloader works good.
P.S. I sent it to your gmail account but probably you did not read it.