var BlendueSlider=new Class({options:{type:"none",direction:"none",duration:400,goTo:0,auto:"none",time:4000},initialize:function(container,options){this.container=container;this.setOptions(options);if(this.options.auto=="loop"||this.options.auto=="once"){var automated;this.automated=this.slider.periodical(this.options.time,this,$(this.container));}else{this.slider($(this.container))}},slider:function(container){var direction;if(this.options)direction=this.options.direction;else direction="forward";var child;if(this.options.goTo){var goTo=this.options.goTo.toInt();goTo-=1;} var children=container.getChildren().getChildren()[0];children.each(function(e){if(e.id=="currentChild"){child=e;}});if(goTo||goTo==0){if(container.getChildren()[0].getChildren()[goTo])child=container.getChildren()[0].getChildren()[goTo];else alert("Slide "+goTo+" does not exist");}else{if(!child){if(direction=="forward"){child=children[0].getNext();} else if(direction=="back"){child=container.getChildren()[0].getLast();}}else{if(direction=="forward"){var lastElement=container.getChildren()[0].getLast();if(lastElement==child.getNext()&&this.options.auto=="once")$clear(this.automated);if(lastElement==child){child=children[0];}else{child=child.getNext();}} else if(direction=="back"){var firstElement=container.getChildren()[0].getFirst();if(firstElement==child.getPrevious()&&this.options.auto=="once")$clear(this.automated);if(firstElement==child){child=container.getChildren()[0].getLast();}else{child=child.getPrevious();}}}} if(child){if(this.options.type=="scroll")this.scroll(container,children,child);else if(this.options.type=="fade")this.fade(container,children,child);}},scroll:function(container,children,child){var scroll=new Fx.Scroll(container,{duration:this.options.duration,transition:Fx.Transitions.Quart.easeInOut,onComplete:function(){children.each(function(e){e.id="";});child.id="currentChild";}}).toElement(child);},fade:function(container,children,child){var fade=new Fx.Style(container,'opacity',{duration:this.options.duration,transition:Fx.Transitions.Quart.easeInOut,onComplete:function(){new Fx.Scroll(container,{duration:1,onComplete:function(){children.each(function(e){e.id="";});child.id="currentChild";new Fx.Style(container,'opacity').start(0.01,1);}}).toElement(child);}}) fade.start(1,0.01);}});BlendueSlider.implement(new Options);