var Y={anim:YAHOO.util.Anim,dom:YAHOO.util.Dom,getByClass:YAHOO.util.Dom.getElementsByClassName,easing:YAHOO.util.Easing,event:YAHOO.util.Event,region:YAHOO.util.Region},Y3=YUI(),NeverEndingCarousel,CarouselItem,Gallery;Y.event.on(window,"load",function(){Y.dom.batch(document.getElementsByTagName("a"),function(c){if(Y.dom.getAttribute(c,"rel")=="new"){Y.event.on(c,"click",function(d){window.open(this.href,"newwin");Y.event.stopEvent(d)})}});Y.dom.batch(Y.getByClass("carousel"),function(c){new NeverEndingCarousel(c)});Y.dom.batch(Y.getByClass("gallery"),function(c){new Gallery(c)});var b={play:"true",loop:"false",menu:"true",quality:"high",scale:"showall",salign:"",wmode:"window",bgcolor:"#ffffff",devicefont:"false",allowscriptaccess:"always",allowfullscreen:"false"},a={id:"logo",name:"logo",align:"middle"};swfobject.embedSWF("/flash/logo.swf","logo","122","66","9.0.0","flash/expressInstall.swf",false,b,a)});NeverEndingCarousel=function(b){this.DURATION=0.4;this.EASE=Y.easing.easeOut;this.ITEM_CLASS="item";this.SHIFT_CLASS="more";this.VIEW_SIZE=2;this.SHIFT_COUNT=2;this.carousel=Y.dom.get(b);this.items=[];var c=Y.getByClass(this.ITEM_CLASS,"div",this.carousel),a;for(a=0;a<c.length;a++){this.items[a]=new CarouselItem(c[a],a,c.length)}Y.dom.setStyle(c,"position","relative");Y.event.on(Y.getByClass(this.SHIFT_CLASS,"a",this.carousel),"click",this.onShiftClick,this,true)};NeverEndingCarousel.prototype={onShiftClick:function(a){if(!this.isAnimating){this.shift()}Y.event.stopEvent(a)},shift:function(){var c=new Y.anim(null,null,this.DURATION),a=this.items.slice(0,this.VIEW_SIZE+this.SHIFT_COUNT),b;c.onTween.subscribe(function(d,e){Y.dom.batch(a,function(f){Y.dom.setStyle(f.el,"left",this.EASE(e[0].currentFrame,f.currShift,-1*f.width*this.SHIFT_COUNT,this.DURATION*1000)+"px")},this,true)},this,true);c.onComplete.subscribe(function(){Y.dom.batch(this.items,function(d){d.shift(this.SHIFT_COUNT)},this,true);for(b=0;b<this.SHIFT_COUNT;b++){this.items.push(this.items.shift())}this.isAnimating=false},this,true);this.isAnimating=true;c.animate()}};CarouselItem=function(b,a,c){this.el=Y.dom.get(b);this.width=Y.region.getRegion(this.el).width+parseInt(Y.dom.getStyle(this.el,"margin-left"))+parseInt(Y.dom.getStyle(this.el,"margin-right"));this.startPos=a*this.width;this.maxPos=c*this.width;this.currShift=0};CarouselItem.prototype={shift:function(a){this.currShift-=a*this.width;if((this.startPos+this.currShift)<0){this.currShift+=this.maxPos}}};Gallery=function(b){this.NAV_CLASS="galleryNav";this.SELECTED_CLASS="selected";this.SHOWN_CLASS="shown";this.DURATION=0.5;this.EASE=Y.easing.easeIn;this.DELAY=3;this.gallery=Y.dom.get(b);this.nav=Y.getByClass(this.NAV_CLASS,"div",this.gallery)[0];this.navButtons=this.nav.getElementsByTagName("a");this.selectedIndex=0;var a=0;Y.dom.batch(this.navButtons,function(c){Y.event.on(c,"click",this.onNavClick,a,this);if(Y.dom.hasClass(c,this.SELECTED_CLASS)){this.selectedIndex=a}a++},this,true);this.imageContainer=this.gallery.getElementsByTagName("ul")[0];this.images=this.imageContainer.getElementsByTagName("li");this.resizeToImage(this.selectedIndex,true);Y.dom.setStyle(this.images,"position","absolute");this.startAutoplay()};Gallery.prototype={resizeToImage:function(b,c){var a=Y.region.getRegion(this.images[b]).height,d=Y.region.getRegion(this.imageContainer).height;if(a>=d||c){Y.dom.setStyle(this.imageContainer,"height",a+"px")}},startAutoplay:function(){if(!this.autoplay){this.autoplay=true;this.interval=Y3.later(this.DELAY*1000,this,this.autoplayHandler,null,true)}},cancelAutoplay:function(){if(this.autoplay){this.autoplay=false;this.interval.cancel()}},autoplayHandler:function(){if(this.autoplay){this.showImage(((this.selectedIndex+1)<this.navButtons.length)?this.selectedIndex+1:0)}},onNavClick:function(b,a){this.cancelAutoplay();this.showImage(a);Y.event.stopEvent(b)},showImage:function(b){if(b==this.selectedIndex||b==this.nextIndex){return}var a=new Y.anim(null,null,this.DURATION);a.onTween.subscribe(function(c,d){Y.dom.setStyle(this.images[this.selectedIndex],"opacity",this.EASE(d[0].currentFrame,1,-1,this.DURATION*1000));Y.dom.setStyle(this.images[b],"opacity",this.EASE(d[0].currentFrame,0,1,this.DURATION*1000))},this,true);a.onComplete.subscribe(function(){Y.dom.removeClass(this.navButtons[this.selectedIndex],this.SELECTED_CLASS);Y.dom.addClass(this.navButtons[b],this.SELECTED_CLASS);Y.dom.removeClass(this.images[this.selectedIndex],this.SHOWN_CLASS);this.selectedIndex=b;this.resizeToImage(b,true)},this,true);Y.dom.setStyle(this.images[b],"opacity",0);Y.dom.addClass(this.images[b],this.SHOWN_CLASS);this.resizeToImage(b,false);this.nextIndex=b;a.animate()}};