var CNETcarousel=new Class({initialize:function(_1,_2){ this.container=$(_1); if(!this.container.hasClass("hasCarousel")){ this.container.addClass("hasCarousel"); this.slides=[]; this.buttons=[]; this.setOptions({onRotate:Class.empty,onStop:Class.empty,onAutoPlay:Class.empty,onShowSlide:Class.empty,slidesSelector:".slide",buttonsSelector:".button",slideInterval:4000,transitionDuration:700,startIndex:0,buttonOnClass:"selected",buttonOffClass:"off",rotateAction:"none",rotateActionDuration:100,autoplay:true},_2); this.slides=$(_1).getElements(this.options.slidesSelector); this.buttons=$(_1).getElements(this.options.buttonsSelector); this.createFx(); this.showSlide(this.options.startIndex); if(this.options.autoplay){ this.autoplay(); } if(this.options.rotateAction!="none"){ this.setupAction(this.options.rotateAction); } return this; }else{ return false; } },setupAction:function(_3){ this.buttons.each(function(el,_5){ $(el).addEvent(_3,function(){ this.slideFx.setOptions(this.slideFx.options,{duration:this.options.rotateActionDuration}); if(this.currentSlide!=_5){ this.showSlide(_5); } this.stop(); }.bind(this)); },this); },createFx:function(){ this.slideFx=new Fx.Elements(this.slides,{duration:this.options.transitionDuration}); this.slides.each(function(_6){ _6.setStyle("opacity",0); }); },showSlide:function(_7){ var _8={}; this.slides.each(function(_9,_a){ if(_a==_7&&_a!=this.currentSlide){ $(this.buttons[_a]).removeClass(this.options.buttonOffClass).addClass(this.options.buttonOnClass); _8[_a.toString()]={"opacity":[1]}; }else{ $(this.buttons[_a]).removeClass(this.options.buttonOnClass).addClass(this.options.buttonOffClass); _8[_a.toString()]={"opacity":[0]}; } },this); this.fireEvent("onShowSlide",_7); this.currentSlide=_7; this.slideFx.start(_8); },autoplay:function(){ this.createFx(); this.slideshowInt=this.rotate.periodical(this.options.slideInterval,this); this.fireEvent("onAutoPlay"); },stop:function(){ clearInterval(this.slideshowInt); this.fireEvent("onStop"); },rotate:function(){ current=this.currentSlide; next=(current+1>=this.slides.length)?0:current+1; this.showSlide(next); this.fireEvent("onRotate"); },show:function(){ $(this.options.carouselContainer).setStyle("visibility","visible"); if(!$(this.options.carouselContainer).isVisible()){ $(this.options.carouselContainer).setStyle("display","block"); } },hide:function(){ $(this.options.carouselContainer).setStyle("visibility","hidden"); }}); CNETcarousel.implement(new Options); CNETcarousel.implement(new Events); var CNETcarouselWithButtons=CNETcarousel.extend({initialize:function(el,_c){ this.parent(el,$merge({bubbleButtonBGImgSelector:".bbg",buttonOnGifSrc:"http://i.i.com.com/cnwk.1d/i/fd/c/green_button.gif",buttonOffGifSrc:"http://i.i.com.com/cnwk.1d/i/fd/c/gray_button.gif"},_c)); },showSlide:function(_d){ this.buttons.each(function(_e,_f){ $(_e).getElement(this.options.bubbleButtonBGImgSelector).src=(_f==_d)?this.options.buttonOnGifSrc:this.options.buttonOffGifSrc; },this); this.parent(_d); }}); var carousel=null; window.addEvent("domready",function(){ if($("Carousel")){ carousel=new CNETcarouselWithButtons($("Carousel"),{buttonsSelector:".bubble",rotateAction:"mouseover"}); } });