// Image rotator script which fades out to the next image
//	relies on image IDs with image_ prefix

var frame=1;	
var nframes = 0;

function fadeOut() {
	Effect.Fade('image_' + frame, { afterFinish: fadeIn, delay: 5.0, duration: 3.0} );
}

function fadeIn() {
	if (frame == nframes) { frame = 1; } else { frame = frame + 1; }
	Effect.Appear('image_' + frame, { afterFinish: fadeOut, delay:0, duration: 3.0 } );
}


function init() {
	if (!$('rotator')) return;
	//nframes = $('rotator').childElementCount;
	nframes = $('rotator').getElementsByTagName('img').length;
	fadeOut();
		
}

Event.observe(window, 'load', init, true);

