DynoBox=Class.create({switchers:[],targets:[],active:null,timerObj:undefined,timerRunning:false,timerPeriod:4,isSwitching:false,isClicked:false,isHovered:false,initialize:function(a){if($(a)){this.portlet=$(a);this.switchers=this.portlet.select("li a");this.targets=this.portlet.select(".dynobox_content div");if(GlobalSettings.DynoBox.speed){this.timerPeriod=GlobalSettings.DynoBox.speed}if(this.switchers.length==this.targets.length){this.register()}else{throw ("DynoBox.js: incorrect switchers/targets amount for #"+a)}}else{throw ("DynoBox.js: DynoBox not found at #"+a)}},findActive:function(){find=function(b,a){if(b.visible()){active=a}};this.targets.each(find.bind(this));return active},applyEvents:function(){apply=function(b,a){b.observe("click",this.switchBoxClick.bindAsEventListener(this,a))};this.switchers.each(apply.bind(this));portletOver=function(){this.timerStop();this.isHovered=true};portletOut=function(){this.timerStart();this.isHovered=false};this.portlet.observe("mouseover",portletOver.bind(this));this.portlet.observe("mouseout",portletOut.bind(this))},switchBoxClick:function(b,a){this.isClicked=true;this.switchBox(a);b.stop()},switchBox:function(a){if(a!=this.active&&!this.isSwitching){this.isSwitching=true;if(this.isClicked&&!this.isHovered){this.timerStop()}this.switchers[this.active].removeClassName("selected");this.switchers[a].addClassName("selected");notSwitching=function(){this.isSwitching=false;if(this.isClicked){if(!this.isHovered){this.timerStart()}this.isClicked=false}};afterEffect=function(b){new Effect.Appear(b,{duration:0.3,afterFinish:notSwitching.bind(this)})};new Effect.Fade(this.targets[this.active],{duration:0.3,afterFinish:afterEffect.bind(this,this.targets[a])});this.active=a}},switchNext:function(){if(this.active==(this.switchers.length-1)){this.switchBox(0)}else{this.switchBox(this.active+1)}},notSwitching:function(){this.isSwitching=false},timerStart:function(){if(!this.timerRunning){this.timerObj=new PeriodicalExecuter(this.switchNext.bind(this),this.timerPeriod);this.timerRunning=true}},timerStop:function(){if(this.timerRunning){this.timerObj.stop();this.timerRunning=false}},register:function(){this.active=this.findActive();this.switchers[this.active].addClassName("selected");this.applyEvents();this.timerStart()}});DynoBox.Loader=Class.create({initialize:function(a){if($(a)){this.wrapper=$(a);this.dynoboxes=this.wrapper.select("div.dynobox");this.dynoboxes.each(function(b){b.identify();new DynoBox(b.id)})}else{throw ("DynoLoader: DynoBox wrapper not found at #"+a)}}});