I'm much better at php than javascript, and I'm having some problems getting images to rotate using the scriptaculous libraries.

It's better to see it, you should be able to tell what I'm trying to do.

The homepage pretty much works correctly. Click on gallery and it seems like it's just switching them randomly. Seems like it has problems when it uses multiple sets of images.

Here's the code I wrote...
Code JavaScript:
function runPortal(portal_number){
	var portal = document.getElementById('portal'+portal_number); // represents the div that holds the images
	var thumbs = portal.getElementsByTagName('a'); // represents all the images within the div that will be rotated
  // Hide everything
  for (var i=0;i<thumbs.length;i++){
    if (i==0) continue; // Don't hide the first one
    thumbs[i].childNodes[0].style.display = 'none';
	// Set up the image rotator
	var rotator = new PeriodicalExecuter(nextImage, 2);
	rotator.i = 0;
	rotator.thumbs = thumbs;
function nextImage(){
	if (this.i == this.thumbs.length){
		this.i = 0;
	Effect.dglPuff(this.thumbs[this.last].childNodes[0], {duration:.6, from:.7});
	this.last = this.i;

Can anyone help? Let me know if I was unclear at all.