var MGFX=MGFX||{};MGFX.Tabs=new Class({Implements:[Options,Events],options:{transitionDuration:240,startIndex:0,autoplay:true,hover:true,hash:true,sliding:false,onShowSlide:function(slideIndex){this.tabs.removeClass('active');this.tabs[slideIndex].addClass('active');}},initialize:function(tabs,slides,options){this.setOptions(options);this.tabs=$$(tabs);this.createTabs();this.slides=$$(slides);this.slideFx=[];this.createFx();this.showSlide(this.options.startIndex);if(this.options.hash&&window.location.hash){var hash=window.location.hash.substring(1);this.tabs.each(function(el,index){if(el.get('id')==hash){options.startIndex=index;}});}
return this;},createFx:function(){if(this.options.sliding){var _this=this;this.slides.each(function(slide){_this.slideFx.push(new Fx.Slide(slide));});}
else{if(!this.alfaFx)this.alfaFx=new Fx.Elements(this.slides,{duration:this.options.transitionDuration,link:'cancel'});this.slides.each(function(slide){slide.setStyle('opacity',0);});}}.protect(),createTabs:function(){this.tabs.each(function(tab,index){tab.addEvent('click',function(event){event.preventDefault();this.showSlide(index);}.bind(this));}.bind(this));}.protect(),showSlide:function(slideIndex){if(slideIndex==this.currentSlide)return this;if(this.options.sliding){var _this=this;this.slides.each(function(slide,index){if(index==slideIndex&&index!=this.currentSlide){_this.slideFx[index.toString()].slideIn();}else{_this.slideFx[index.toString()].slideOut();}},this);}
else{var action={};this.slides.each(function(slide,index){if(index==slideIndex&&index!=this.currentSlide){action[index.toString()]={opacity:1};}else{action[index.toString()]={opacity:0};}},this);this.alfaFx.start(action);};this.fireEvent('onShowSlide',slideIndex);this.currentSlide=slideIndex;return this;}});
