YAHOO.namespace("indico");
YAHOO.indico.fadeLib = function(){
	var sContID, aItems, oOut, nInc = 0, aHeight = [];
	
	return {
		init : function(sID, nDelay){
			sContID = sID;
			aItems = document.getElementById(sContID).getElementsByTagName("li");
			if(!aItems.length){
				return;
			}
			YAHOO.util.Dom.addClass(aItems[0].parentNode, "js");
			YAHOO.util.Dom.setStyle(aItems, "opacity", 0);
			YAHOO.util.Dom.setStyle(aItems[0], "opacity", 1);
			//for(var i=0, j=aItems.length; i<j; i++){
			//	aHeight.push(aItems[i].offsetHeight);
			//}
			//document.getElementById(sContID).style.height = aHeight.max() + "px";
			this.play();
			YAHOO.lang.later(nDelay*1000, this, function(){this.play()}, null, true);
		},
		play : function(){
			YAHOO.util.Dom.setStyle(aItems[nInc], "display", "block");
			new YAHOO.util.Anim(aItems[nInc], {opacity:{to:1}}, .5).animate();
			oOut = aItems[(nInc) ? nInc-1 : aItems.length-1];
			var o = new YAHOO.util.Anim(oOut, {opacity:{to:0}}, .5);
			o.onComplete.subscribe(function(){YAHOO.util.Dom.setStyle(oOut, "display", "none")});
			o.animate();
			if(nInc ++ == aItems.length-1){
				nInc = 0;
			}
		}
	}
}();

Array.prototype.max = function(){
    return Math.max.apply(Math, this);
};