/*
	Affiliates 1.0 - SH 16/1/2009
*/

var Affiliates = {
	index : 0,
	delay : 8000,
	pause : function() {
		setTimeout('Affiliates.fadeOut.animate()', Affiliates.delay);
	},
	cycle : function() {
		Affiliates.element.innerHTML =
			Affiliates.targets[++Affiliates.index %
				Affiliates.targets.length];
		Affiliates.fadeIn.animate();
	},
	start : function(targets) {
		this.element = YAHOO.util.Dom.get('affiliate');
		this.targets = targets;

		this.fadeIn = new YAHOO.util.Anim(this.element,
			{ opacity : { to : 1 } }, 0.5);
		this.fadeIn.onComplete.subscribe(Affiliates.pause);

		this.fadeOut = new YAHOO.util.Anim(this.element,
			{ opacity : { to : 0 } }, 0.5);
		this.fadeOut.onComplete.subscribe(Affiliates.cycle);

		this.pause();
	}
}

