(function($){$.ux.behavior("FeatureCycle",{initialize:function(){var self=this;this.currentIndex=1;this.cycle();this.element.hover(function(){clearTimeout(self._timeout);},function(){self.cycle();});$(this.options.indicatorSelector+" li a",this.element).bind("click",function(){clearTimeout(self._timeout);self.currentIndex=$(self.options.indicatorSelector+" li a").index(this);self.showItem();return false;});},cycle:function(){var self=this;this._timeout=setTimeout(function(){self.showItem();self.cycle();},this.options.timeout*1000);},showItem:function(){var self=this;if(self.currentIndex==self.options.items.length){self.currentIndex=0;}
var item=self.options.items[self.currentIndex];$(".container",this.element).fadeOut(function(){$(self.options.indicatorSelector+" .selected",self.element).removeClass("selected");$(self.options.indicatorSelector+" li",self.element).eq(self.currentIndex-1).addClass("selected");$("img",self.element).attr("src",item.image);$("a",self.element).attr("href",item.url).eq(0).text(item.title);$(this).fadeIn();});self.currentIndex++;}},{items:[],indicatorSelector:"",timeout:5});})(jQuery);