/*=============================================================================

			 	 TITLE:		NetMediaOne - "Featured Item" Link Banner Rotator
		  MODIFIED:		2007.08.23
		 AUTHOR(S): 	Graham Wheeler - NetMediaOne - www.netmediaone.com
	DEPENDENCIES:		NetMediaOne Core 1.2.0
									jQuery 1.1.4

=============================================================================*/

NMO.FeaturedItemRotator = function() {
	
	return {
	
		cycleTimer: "",
		selectedItem: 0,
		transitionInterval: 6,
	
		init: function(elementRef) {
			var self = this;
			this.container = $(elementRef);
			this.links = this.container.children("a");
			this.container.show();
			$(this.links[this.selectedItem]).fadeIn(6000);
			this.cycleTimer = setTimeout( function() { self.cycle(self); }, this.transitionInterval * 1000 );
		},
		
		cycle: function(self) {
			clearTimeout( this.cycleTimer );
			var oldItem = this.selectedItem;
			if ( this.selectedItem < this.links.length - 1 ) {
				this.selectedItem++;
			} else {
				this.selectedItem = 0;
			}
			var oI = $(this.links[oldItem]);
			var cI = $(this.links[this.selectedItem]);
	
			oI.fadeOut(1000);
			cI.fadeIn(1000);
			this.cycleTimer = setTimeout( function() { self.cycle(self); }, this.transitionInterval * 1000 );
		}

	};

};

jQuery( function() {

	$(".FeaturedItemRotator").each( function() {
		new NMO.FeaturedItemRotator().init(this);
	});

});
