Just a quick glance of your code, but you should probably change this:
setInterval("rotateimages()", 1000)
to this
setInterval(rotateimages, 1000);
This is because you're telling Javascript to run a specific function after 1 second. So you'll need to pass in something that is callable like a function reference or an anonymous function block. In your case, you're passing in a string which is not callable.