I tried to look a bit deeper, but that script is really a mess - no formatting, missing braces etc...
Anyway, you need to do whatever it is you do to initialize the script, only after the images have loaded. It looks like you kinda intended to do that in your startit() method when you check for the loaded boolean variable, but, you only call startit() once, and since you call the method right away, it's pretty much guaranteed that loaded is false, making it useless.
Maybe your function where you set the loaded variable to true, would be better if you just got rid of the boolean variable altogether, and just "started the slideshow" right then and there.
I still think it would have been easier to do this logic outside of that script, and just modify the script to not use document.write.