var HorzSIM=new Class({Implements:[Options],options:{overallContainer:null,elementScrolled:null,thumbsContainer:null,itemsVisible:5,itemsSelector:null,itemWidth:null,showControls:1,transition:Fx.Transitions.linear,duration:500,direction:1,autoSlide:false,mouseWheelNav:false},initialize:function(a){this.setOptions(a);this.elements=$(this.options.thumbsContainer).getElements(this.options.itemsSelector);this.totalElements=this.elements.length;this.elementWidth=this.options.itemWidth||this.elements[0].getSize().x;this.currentElement=0;this.direction=this.options.direction;this.autoSlideTotal=this.options.autoSlide+this.options.duration;this.begin()},begin:function(){this.setContainersSize();this.myFx=new Fx.Morph(this.options.thumbsContainer,{wait:true,transition:this.options.transition,duration:this.options.duration});this.addControls();if(this.options.mouseWheelNav&&!this.options.autoSlide){$(this.options.thumbsContainer).addEvent('mousewheel',function(a){new Event(a).stop();this.slide(-a.wheel)}.bind(this))}if(this.options.autoSlide)this.startAutoSlide()},setContainersSize:function(){$(this.options.overallContainer).set({styles:{'width':this.options.itemsVisible*this.elementWidth+100*this.options.showControls}});$(this.options.elementScrolled).set({styles:{'width':this.options.itemsVisible*this.elementWidth}});$(this.options.thumbsContainer).set({styles:{'width':this.totalElements*(this.elementWidth+10)}})},addControls:function(){if(this.options.showControls=="1"){this.right=new Element('span',{'class':'HorzSIM_right'});this.left=new Element('span',{'class':'HorzSIM_left'});$(this.options.overallContainer).adopt(this.right,this.left);this.right.addEvent('click',this.slide.bind(this).pass(1));this.left.addEvent('click',this.slide.bind(this).pass(-1))}},slide:function(a){if(this.started)return;this.direction=a;var b=this.currentIndex();if(this.direction==-1){this.rearange();$(this.options.thumbsContainer).setStyle('margin-left',-this.elementWidth)}this.started=true;this.myFx.start({'margin-left':this.direction==1?-this.elementWidth:0}).chain(this.rearange.bind(this).pass(true))},rearange:function(a){if(a)this.started=false;if(a&&this.direction==-1){return}this.currentElement=this.currentIndex(this.direction);$(this.options.thumbsContainer).setStyle('margin-left',0);if(this.currentElement==1&&this.direction==1){this.elements[0].injectAfter(this.elements[this.totalElements-1]);return}if((this.currentElement==0&&this.direction==1)||(this.direction==-1&&this.currentElement==this.totalElements-1)){this.rearrangeElement(this.elements.getLast(),this.direction==1?this.elements[this.totalElements-2]:this.elements[0]);return}if(this.direction==1){this.rearrangeElement(this.elements[this.currentElement-1],this.elements[this.currentElement-2])}else{this.rearrangeElement(this.elements[this.currentElement],this.elements[this.currentElement+1])}},rearrangeElement:function(a,b){this.direction==1?a.injectAfter(b):a.injectBefore(b)},currentIndex:function(){var a=null;switch(this.direction){case 1:a=this.currentElement>=this.totalElements-1?0:this.currentElement+this.direction;break;case-1:a=this.currentElement==0?this.totalElements-1:this.currentElement+this.direction;break}return a},startAutoSlide:function(){this.startIt=this.slide.bind(this).pass(this.direction||1);this.autoSlide=this.startIt.periodical(this.autoSlideTotal,this);this.elements.addEvents({'mouseover':function(){$clear(this.autoSlide)}.bind(this),'mouseout':function(){this.autoSlide=this.startIt.periodical(this.autoSlideTotal,this)}.bind(this)})}});var VertSIM=new Class({Implements:[Options],options:{overallContainer:null,elementScrolled:null,thumbsContainer:null,itemsVisible:5,itemsSelector:null,itemWidth:null,itemHeight:null,showControls:1,transition:Fx.Transitions.linear,duration:500,direction:1,autoSlide:false,mouseWheelNav:false},initialize:function(a){this.setOptions(a);this.elements=$(this.options.thumbsContainer).getElements(this.options.itemsSelector);this.totalElements=this.elements.length;this.elementHeight=this.options.itemHeight||this.elements[0].getSize().y;this.currentElement=0;this.direction=this.options.direction;this.autoSlideTotal=this.options.autoSlide+this.options.duration;this.begin()},begin:function(){this.setContainersSize();this.myFx=new Fx.Morph(this.options.thumbsContainer,{wait:true,transition:this.options.transition,duration:this.options.duration});this.addControls();if(this.options.mouseWheelNav&&!this.options.autoSlide){$(this.options.thumbsContainer).addEvent('mousewheel',function(a){new Event(a).stop();this.slide(-a.wheel)}.bind(this))}if(this.options.autoSlide)this.startAutoSlide()},setContainersSize:function(){$(this.options.overallContainer).set({styles:{'height':this.options.itemsVisible*this.elementHeight+50*this.options.showControls}});$(this.options.elementScrolled).set({styles:{'height':this.options.itemsVisible*this.elementHeight}});$(this.options.thumbsContainer).set({styles:{'height':this.totalElements*(this.elementHeight+10)}})},addControls:function(){if(this.options.showControls=="1"){this.up=new Element('span',{'class':'VertSIM_up'});this.down=new Element('span',{'class':'VertSIM_down'});$(this.options.overallContainer).adopt(this.up,this.down);this.down.addEvent('click',this.slide.bind(this).pass(1));this.up.addEvent('click',this.slide.bind(this).pass(-1))}},slide:function(a){if(this.started)return;this.direction=a;var b=this.currentIndex();if(this.direction==-1){this.rearange();$(this.options.thumbsContainer).setStyle('margin-top',-this.elementHeight)}this.started=true;this.myFx.start({'margin-top':this.direction==1?-this.elementHeight:0}).chain(this.rearange.bind(this).pass(true))},rearange:function(a){if(a)this.started=false;if(a&&this.direction==-1){return}this.currentElement=this.currentIndex(this.direction);$(this.options.thumbsContainer).setStyle('margin-top',0);if(this.currentElement==1&&this.direction==1){this.elements[0].injectAfter(this.elements[this.totalElements-1]);return}if((this.currentElement==0&&this.direction==1)||(this.direction==-1&&this.currentElement==this.totalElements-1)){this.rearrangeElement(this.elements.getLast(),this.direction==1?this.elements[this.totalElements-2]:this.elements[0]);return}if(this.direction==1){this.rearrangeElement(this.elements[this.currentElement-1],this.elements[this.currentElement-2])}else{this.rearrangeElement(this.elements[this.currentElement],this.elements[this.currentElement+1])}},rearrangeElement:function(a,b){this.direction==1?a.injectAfter(b):a.injectBefore(b)},currentIndex:function(){var a=null;switch(this.direction){case 1:a=this.currentElement>=this.totalElements-1?0:this.currentElement+this.direction;break;case-1:a=this.currentElement==0?this.totalElements-1:this.currentElement+this.direction;break}return a},startAutoSlide:function(){this.startIt=this.slide.bind(this).pass(this.direction||1);this.autoSlide=this.startIt.periodical(this.autoSlideTotal,this);this.elements.addEvents({'mouseover':function(){$clear(this.autoSlide)}.bind(this),'mouseout':function(){this.autoSlide=this.startIt.periodical(this.autoSlideTotal,this)}.bind(this)})}})