var Rotator=Class.create({initialize:function(_1,_2,_3){
this.rotatingImageObjs=_1;
this.containerID=_2;
this.preloader=new Preloader();
this.retryDuration=1;
this.moveEffect=null;
var _4=$(this.containerID).childElements().first();
if(_4.tagName!="IMG"){
_4=_4.down("img");
}
var _5={height:String(_4.getHeight())+"px",width:String(_4.getWidth())+"px"};
this.imageWidth=_5.width;
this.imageHeight=_5.height;
this.options=Object.extend({direction:"left",transitionEquation:Effect.Transitions.sinoidal,seconds:10,pause:false},_3||{});
var _6=[];
for(var i=0;i<_1.length;i++){
_6.push(_1[i].imgPath);
}
this.preloader.addToQueue(_6);
this.preloader.startLoading();
$(this.containerID).update("<div id='"+this.containerID+"-inner'>"+$(this.containerID).innerHTML+"</div>");
$(this.containerID).makeClipping().setStyle(_5);
$(this.containerID).setStyle({overflow:"hidden",position:"relative"});
if(!this.options.pause){
this.pe=new PeriodicalExecuter(this.next.bind(this),this.options.seconds);
}
},next:function(){
if(this.pe!=null){
this.pe.stop();
}
if(this.moveEffect!=null){
return false;
}
var _8=this.rotatingImageObjs.shift();
this.rotatingImageObjs.push(_8);
if(!this.preloader.hasPathLoaded(_8.imgPath)){
new PeriodicalExecuter(this.next.bind(this),this.retryDuration);
return false;
}
var _9=this.containerID+"-inner";
if(this.options.direction=="right"||this.options.direction=="left"){
var _a=String((parseInt(this.imageWidth)*2)+10)+"px";
$(_9).setStyle({width:_a});
}else{
if(this.options.direction=="up"||this.options.direction=="down"){
var _b=String((parseInt(this.imageHeight)*2)+10)+"px";
$(_9).setStyle({height:_b});
}
}
var _c=Element.extend(document.createElement("img"));
_c.writeAttribute("src",_8.imgPath);
_c.writeAttribute("alt",_8.imgAlt);
_c.writeAttribute("width",this.imageWidth);
_c.writeAttribute("height",this.imageHeight);
var _d;
if(_8.linkUrl!=null){
_d=Element.extend(document.createElement("a"));
_d.writeAttribute("href",_8.linkUrl);
_c=_d.update(_c);
}
var _e=0;
if(this.options.direction=="left"){
$(_9).insert({bottom:_c});
_e=-parseInt(this.imageWidth);
}else{
if(this.options.direction=="right"){
$(this.containerID+"-inner").setStyle({left:0});
$(_9).insert({top:_c});
_e=parseInt(this.imageWidth);
$(this.containerID).scrollLeft=_e;
}else{
if(this.options.direction=="up"){
$(_9).insert({bottom:_c});
_e=-parseInt(this.imageHeight);
}else{
if(this.options.direction=="down"){
$(this.containerID+"-inner").setStyle({top:0});
$(_9).insert({top:_c});
_e=parseInt(this.imageHeight);
$(this.containerID).scrollTop=_e;
}
}
}
}
if(this.options.direction=="left"||this.options.direction=="right"){
this.moveEffect=new Effect.Move($(this.containerID+"-inner"),{duration:1,x:_e,afterFinish:this.onRotateFinish.bind(this),transition:this.options.transitionEquation});
}else{
if(this.options.direction=="up"||this.options.direction=="down"){
this.moveEffect=new Effect.Move($(this.containerID+"-inner"),{duration:1,y:_e,afterFinish:this.onRotateFinish.bind(this),transition:this.options.transitionEquation});
}
}
},onRotateFinish:function(_f){
this.moveEffect=null;
var _10=$(this.containerID+"-inner").childElements();
if(this.options.direction=="left"||this.options.direction=="up"){
_10.first().remove();
$(this.containerID+"-inner").setStyle({left:0,top:0});
}else{
if(this.options.direction=="right"||this.options.direction=="down"){
_10.last().remove();
}
}
if(!this.options.pause){
this.pe=new PeriodicalExecuter(this.next.bind(this),this.options.seconds);
}
}});
Rotator._BackEaseIn=function(pos){
var s=1;
return pos*pos*((s+1)*pos-s);
};
Rotator._BackEaseInOut=function(pos){
var s=1.70158;
if((pos/=0.5)<1){
return 0.5*(pos*pos*(((s*=(1.525))+1)*pos-s));
}
return 0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos+s)+2);
};


