var XYZ=XYZ||{};XYZ.Rotater=new Class({Implements:[Options,Events],options:{slideInterval:5000,transitionDuration:1000,startIndex:0,autoplay:true,hover:true,hash:true,onAutoPlay:$empty,onRotate:$empty,onShowSlide:$empty,onStop:$empty,onPause:$empty,onResume:$empty},initialize:function(b,a){this.setOptions(a);this.slides=$$(b);this.createFx();this.showSlide(this.options.startIndex);if(this.slides.length<2){this.options.autoplay=false}if(this.options.autoplay){this.autoplay()}return this},createFx:function(){if(!this.slideFx){this.slideFx=new Fx.Elements(this.slides,{duration:this.options.transitionDuration,link:"cancel"})}this.slides.each(function(a){a.setStyle("opacity",0);a.setStyle("display","none")})}.protect(),setupHover:function(){var c=new Date(),b,e=this.options.slideInterval,d;var f=this._onRotate=function(){if(this.slideshowInt){c=new Date();e=this.options.slideInterval}};var g=this._onMouseEnter=function(){this.stop();b=new Date();$clear(d);this.fireEvent("onPause")}.bind(this);var a=this._onMouseLeave=function(){var h=(b-c);c=new Date()-h;d=(function(){this.autoplay();this.rotate();this.fireEvent("onResume")}).delay(e-h,this)}.bind(this);this.addEvent("onRotate",f);this.slides.addEvents({mouseenter:g,mouseleave:a})}.protect(),removeHover:function(){this.removeEvent("onRotate",this._onRotate);this.slides.removeEvents({mouseenter:this._onMouseEnter,mouseleave:this._onMouseLeave})},showSlide:function(b){if(b==this.currentSlide){return this}var a={};this.slides.each(function(c,d){if(d==b&&d!=this.currentSlide){c.setStyle("display","block");a[d.toString()]={opacity:1,}}else{c.setStyle("display","none");a[d.toString()]={opacity:0}}},this);this.fireEvent("onShowSlide",b);this.currentSlide=b;this.slideFx.start(a);return this},autoplay:function(){if(this.options.hover){this.setupHover()}this.slideshowInt=this.rotate.periodical(this.options.slideInterval,this);this.fireEvent("onAutoPlay");return this},stop:function(a){$clear(this.slideshowInt);this.fireEvent("onStop");if(a&&this.options.hover){this.removeHover()}return this},rotate:function(){var a=this.getNext();this.showSlide(a);this.fireEvent("onRotate",a);return this},random:function(){var a=Math.floor(Math.random()*this.slides.length);a=a==this.currentSlide?this.getNext():a;this.showSlide(a);this.fireEvent("onRandom",a);return this},getNext:function(){var a=this.currentSlide;return(a+1>=this.slides.length)?0:a+1}.protect()});XYZ.Tabs=new Class({Extends:XYZ.Rotater,options:{autoplay:false,onShowSlide:function(a){this.tabs.removeClass("active");this.tabs[a].addClass("active")}},initialize:function(b,c,a){this.setOptions(a);this.tabs=$$(b);this.createTabs();if(this.options.hash&&window.location.hash){var d=window.location.hash.substring(1);this.tabs.each(function(f,e){if(f.get("id")==d){a.startIndex=e}})}return this.parent(c,a)},createTabs:function(){this.tabs.each(function(b,a){b.addEvent("click",function(c){$("overlay").setStyle("height",0);c.preventDefault();this.showSlide(a);$("overlay").setStyle("height",getDocHeight()+75);this.stop(true)}.bind(this))}.bind(this))}.protect()});
