var HU = {
	rotator: {
		// Depends: Protoype, Scriptaculous
		images: 0,
		img_id: null,
		img_base: '',
		img_ext: '.jpg',
		seconds: 5,
		timer: null,
		index: 0,
		effect: 'fade',
		
		startTimer: function()
		{
			HU.rotator.timer = setTimeout("HU.rotator.nextImage();", HU.rotator.seconds * 1000);
		},
		endTimer: function()
		{
			clearTimeout(HU.rotator.timer);
		},
		nextImage: function()
		{
			if(HU.rotator.index + 1 >= HU.rotator.images)
				HU.rotator.switchToImage(0);
			else
				HU.rotator.switchToImage(HU.rotator.index + 1);
		},
		switchToImage: function($i)
		{
			if($i < 0 || $i >= HU.rotator.images)
				return false;
			HU.rotator.endTimer();
			eval('HU.rotator.'+HU.rotator.effect+'('+$i+')');
		},
		fade: function($i)
		{
			new Effect.Parallel([
					new Effect.Fade(HU.rotator.img_id+HU.rotator.index, { sync: true, from: 1, to: 0 }),
					new Effect.Appear(HU.rotator.img_id+$i, { sync: true, from: 0, to: 1 })
								], { duration: 1.5, afterFinish: function() {
											HU.rotator.index = $i;
											if(HU.rotator.images > 0)
												HU.rotator.startTimer();
																			} });
		}
	}
};