var Tube=new Class({initialize:function(b){this.box=b.box;this.items=b.items;this.size=b.size||576;this.currentIndex=null;this.previousIndex=null;this.nextIndex=null;this._play=null;this.interval=b.interval||8000;this.handles=b.handles||null;this.running=false;if(this.handles){this.addHandleButtons(this.handles)}this.buttons={previous:[],next:[],play:[],stop:[],toggle:[]};if(b.addButtons){for(var a in b.addButtons){this.addActionButtons(a,$type(b.addButtons[a])=="array"?b.addButtons[a]:[b.addButtons[a]])}}this.fx=new Fx.Tween(this.box,$extend((b.fxOptions||{duration:500,wait:false,transition:Fx.Transitions.Quad.easeInOut}),{property:"left"}));this.walk(0,true)},addHandleButtons:function(b){for(var a=0;a<b.length;a++){b[a].addEvent("click",this.walk.bind(this,[a,true]))}},addActionButtons:function(c,b){for(var a=0;a<b.length;a++){switch(c){case"previous":b[a].addEvent("click",this.previous.bind(this,[true]));break;case"next":b[a].addEvent("click",this.next.bind(this,[true]));break;case"play":b[a].addEvent("click",this.play.bind(this,[this.interval,false]));break;case"stop":b[a].addEvent("click",this.stop.bind(this));break;case"toggle":b[a].addEvent("click",this.toggle.bind(this));break}this.buttons[c].push(b[a])}},previous:function(a){this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),a)},next:function(a){this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),a)},stop:function(){$clear(this._play);this.running=false},toggle:function(){if(this.running){$clear(this._play);this.running=false}else{this.running=true;this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),true)}},play:function(a,b){this.stop();if(!b){this.next(false)}this.running=true;this._play=this.next.periodical(a,this,[false])},walk:function(d,b){if(d!=this.currentIndex){this.currentIndex=d;this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);for(var a=0;a<this.handles.length;a++){var c=this.handles[a];if(a==this.currentIndex){c.store("active",true);c.setAttribute("src",c.retrieve("origSrc").replace("/tin","/tac"))}else{c.store("active",false);c.setAttribute("src",c.retrieve("origSrc"))}}if(b){this.stop()}this.fx.start(this.size*-this.currentIndex);if(b){this.play(this.interval,true)}}}});var tube;window.addEvent("domready",function(){var a=new Array();var b=0;$$("#tube img").each(function(c){a[b]=new Image();a[b].src=c.src.replace("/tin","/tac");b++;c.store("origSrc",c.src);c.addEvent("mouseover",function(){this.setAttribute("src",c.retrieve("origSrc").replace("/tin","/tac"))});c.addEvent("mouseout",function(){if(!c.retrieve("active")){this.setAttribute("src",c.retrieve("origSrc"))}})});tube=new Tube({box:$("tubeitems"),items:[0,1,2,3,4,5],size:576,handles:$$("#tubenumbers img"),addButtons:{previous:$("tubeprev"),next:$("tubenext")}})});
