/*=============================================================================

			 TITLE:		NMO Rotating Image System
		MODIFIED:		2006.06.19
   AUTHOR(S): 	Graham Wheeler - NetMediaOne - www.netmediaone.com
		REQUIRES:		Prototype 1.5.0 ( www.conio.com )

=============================================================================*/

var ImageRotator = Class.create();
var IMG_ROTATOR_COLLECTIONS = $A( new Array() );
var IMG_ROTATOR_INTERVAL = 5;
var IMG_ROTATOR_COUNTER = 0;
var IMG_ROTATOR_PE = "";

ImageRotator.init = function()	{
	IMG_ROTATOR_COLLECTIONS = $$(".NMORotatingImageCollection");
	if ( IMG_ROTATOR_COLLECTIONS.length > 0 && IMG_ROTATOR_INTERVAL > 0 ) {
		ImageRotator.showCollection(0);
		IMG_ROTATOR_PE = new PeriodicalExecuter( ImageRotator.showNextCollection, IMG_ROTATOR_INTERVAL );
	}
}
	
ImageRotator.showCollection = function(index) {
	if ( IMG_ROTATOR_INTERVAL > 0 ) {
		if ( IMG_ROTATOR_COUNTER == (IMG_ROTATOR_COLLECTIONS.length -1) ) {
			IMG_ROTATOR_COUNTER = 0;
		} else {
			IMG_ROTATOR_COUNTER++;
		}
	}
	var col = IMG_ROTATOR_COLLECTIONS[index];
	Effect.Appear( col.id );
}

ImageRotator.hideCollection = function( el ) {
	Effect.Fade( el );
}

ImageRotator.showNextCollection = function() {
	IMG_ROTATOR_COLLECTIONS.each( function(i) {
		Effect.Fade( i.id );
	} );
	var delEx = setTimeout( "ImageRotator.showCollection( IMG_ROTATOR_COUNTER )", 1000 );
}

Event.observe( window, "load", ImageRotator.init, false );
