var Fx={};
Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(p){
return -(Math.cos(Math.PI*p)-1)/2;
},duration:500,unit:"px",wait:true,fps:50},initialize:function(_177){
this.element=this.element||null;
this.setOptions(_177);
if(this.options.initialize){
this.options.initialize.call(this);
}
},step:function(){
var time=$time();
if(time<this.time+this.options.duration){
this.delta=this.options.transition((time-this.time)/this.options.duration);
this.setNow();
this.increase();
}else{
this.stop(true);
this.set(this.to);
this.fireEvent("onComplete",this.element,10);
this.callChain();
}
},set:function(to){
this.now=to;
this.increase();
return this;
},setNow:function(){
this.now=this.compute(this.from,this.to);
},compute:function(from,to){
return (to-from)*this.delta+from;
},start:function(from,to){
if(!this.options.wait){
this.stop();
}else{
if(this.timer){
return this;
}
}
this.from=from;
this.to=to;
this.change=this.to-this.from;
this.time=$time();
this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);
this.fireEvent("onStart",this.element);
return this;
},stop:function(end){
if(!this.timer){
return this;
}
this.timer=$clear(this.timer);
if(!end){
this.fireEvent("onCancel",this.element);
}
return this;
},custom:function(from,to){
return this.start(from,to);
},clearTimer:function(end){
return this.stop(end);
}});
Fx.Base.implement(new Chain,new Events,new Options);
Fx.CSS={select:function(_182,to){
if(_182.test(/color/i)){
return this.Color;
}
var type=$type(to);
if((type=="array")||(type=="string"&&to.contains(" "))){
return this.Multi;
}
return this.Single;
},parse:function(el,_186,_187){
if(!_187.push){
_187=[_187];
}
var from=_187[0],to=_187[1];
if(!$chk(to)){
to=from;
from=el.getStyle(_186);
}
var css=this.select(_186,to);
return {"from":css.parse(from),"to":css.parse(to),"css":css};
}};
Fx.CSS.Single={parse:function(_18a){
return parseFloat(_18a);
},getNow:function(from,to,fx){
return fx.compute(from,to);
},getValue:function(_18e,unit,_190){
if(unit=="px"&&_190!="opacity"){
_18e=Math.round(_18e);
}
return _18e+unit;
}};
Fx.CSS.Multi={parse:function(_191){
return _191.push?_191:_191.split(" ").map(function(v){
return parseFloat(v);
});
},getNow:function(from,to,fx){
var now=[];
for(var i=0;i<from.length;i++){
now[i]=fx.compute(from[i],to[i]);
}
return now;
},getValue:function(_198,unit,_19a){
if(unit=="px"&&_19a!="opacity"){
_198=_198.map(Math.round);
}
return _198.join(unit+" ")+unit;
}};
Fx.CSS.Color={parse:function(_19b){
return _19b.push?_19b:_19b.hexToRgb(true);
},getNow:function(from,to,fx){
var now=[];
for(var i=0;i<from.length;i++){
now[i]=Math.round(fx.compute(from[i],to[i]));
}
return now;
},getValue:function(_1a1){
return "rgb("+_1a1.join(",")+")";
}};
Fx.Style=Fx.Base.extend({initialize:function(el,_1a3,_1a4){
this.element=$(el);
this.property=_1a3;
this.parent(_1a4);
},hide:function(){
return this.set(0);
},setNow:function(){
this.now=this.css.getNow(this.from,this.to,this);
},set:function(to){
this.css=Fx.CSS.select(this.property,to);
return this.parent(this.css.parse(to));
},start:function(from,to){
if(this.timer&&this.options.wait){
return this;
}
var _1a8=Fx.CSS.parse(this.element,this.property,[from,to]);
this.css=_1a8.css;
return this.parent(_1a8.from,_1a8.to);
},increase:function(){
this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property));
}});
Element.extend({effect:function(_1a9,_1aa){
return new Fx.Style(this,_1a9,_1aa);
}});
Fx.Styles=Fx.Base.extend({initialize:function(el,_1ac){
this.element=$(el);
this.parent(_1ac);
},setNow:function(){
for(var p in this.from){
this.now[p]=this.css[p].getNow(this.from[p],this.to[p],this);
}
},set:function(to){
var _1af={};
this.css={};
for(var p in to){
this.css[p]=Fx.CSS.select(p,to[p]);
_1af[p]=this.css[p].parse(to[p]);
}
return this.parent(_1af);
},start:function(obj){
if(this.timer&&this.options.wait){
return this;
}
this.now={};
this.css={};
var from={},to={};
for(var p in obj){
var _1b4=Fx.CSS.parse(this.element,p,obj[p]);
from[p]=_1b4.from;
to[p]=_1b4.to;
this.css[p]=_1b4.css;
}
return this.parent(from,to);
},increase:function(){
for(var p in this.now){
this.element.setStyle(p,this.css[p].getValue(this.now[p],this.options.unit,p));
}
}});
Element.extend({effects:function(_1b6){
return new Fx.Styles(this,_1b6);
}});
Fx.Elements=Fx.Base.extend({initialize:function(_1b7,_1b8){
this.elements=$$(_1b7);
this.parent(_1b8);
},setNow:function(){
for(var i in this.from){
var _1ba=this.from[i],iTo=this.to[i],iCss=this.css[i],iNow=this.now[i]={};
for(var p in _1ba){
iNow[p]=iCss[p].getNow(_1ba[p],iTo[p],this);
}
}
},set:function(to){
var _1bd={};
this.css={};
for(var i in to){
var iTo=to[i],iCss=this.css[i]={},iParsed=_1bd[i]={};
for(var p in iTo){
iCss[p]=Fx.CSS.select(p,iTo[p]);
iParsed[p]=iCss[p].parse(iTo[p]);
}
}
return this.parent(_1bd);
},start:function(obj){
if(this.timer&&this.options.wait){
return this;
}
this.now={};
this.css={};
var from={},to={};
for(var i in obj){
var _1c4=obj[i],iFrom=from[i]={},iTo=to[i]={},iCss=this.css[i]={};
for(var p in _1c4){
var _1c6=Fx.CSS.parse(this.elements[i],p,_1c4[p]);
iFrom[p]=_1c6.from;
iTo[p]=_1c6.to;
iCss[p]=_1c6.css;
}
}
return this.parent(from,to);
},increase:function(){
for(var i in this.now){
var iNow=this.now[i],iCss=this.css[i];
for(var p in iNow){
this.elements[i].setStyle(p,iCss[p].getValue(iNow[p],this.options.unit,p));
}
}
}});
Fx.Scroll=Fx.Base.extend({options:{overflown:[],offset:{"x":0,"y":0},wheelStops:true},initialize:function(_1ca,_1cb){
this.now=[];
this.element=$(_1ca);
this.bound={"stop":this.stop.bind(this,false)};
this.parent(_1cb);
if(this.options.wheelStops){
this.addEvent("onStart",function(){
document.addEvent("mousewheel",this.bound.stop);
}.bind(this));
this.addEvent("onComplete",function(){
document.removeEvent("mousewheel",this.bound.stop);
}.bind(this));
}
},setNow:function(){
for(var i=0;i<2;i++){
this.now[i]=this.compute(this.from[i],this.to[i]);
}
},scrollTo:function(x,y){
if(this.timer&&this.options.wait){
return this;
}
var el=this.element.getSize();
var _1d0={"x":x,"y":y};
for(var z in el.size){
var max=el.scrollSize[z]-el.size[z];
if($chk(_1d0[z])){
_1d0[z]=($type(_1d0[z])=="number")?_1d0[z].limit(0,max):max;
}else{
_1d0[z]=el.scroll[z];
}
_1d0[z]+=this.options.offset[z];
}
return this.start([el.scroll.x,el.scroll.y],[_1d0.x,_1d0.y]);
},toTop:function(){
return this.scrollTo(false,0);
},toBottom:function(){
return this.scrollTo(false,"full");
},toLeft:function(){
return this.scrollTo(0,false);
},toRight:function(){
return this.scrollTo("full",false);
},toElement:function(el){
var _1d4=this.element.getPosition(this.options.overflown);
var _1d5=$(el).getPosition(this.options.overflown);
return this.scrollTo(_1d5.x-_1d4.x,_1d5.y-_1d4.y);
},increase:function(){
this.element.scrollTo(this.now[0],this.now[1]);
}});
Fx.Slide=Fx.Base.extend({options:{mode:"vertical"},initialize:function(el,_1d7){
this.element=$(el);
this.wrapper=new Element("div",{"styles":$extend(this.element.getStyles("margin"),{"overflow":"hidden"})}).injectAfter(this.element).adopt(this.element);
this.element.setStyle("margin",0);
this.setOptions(_1d7);
this.now=[];
this.parent(this.options);
this.open=true;
this.addEvent("onComplete",function(){
this.open=(this.now[0]===0);
});
if(window.webkit419){
this.addEvent("onComplete",function(){
if(this.open){
this.element.remove().inject(this.wrapper);
}
});
}
},setNow:function(){
for(var i=0;i<2;i++){
this.now[i]=this.compute(this.from[i],this.to[i]);
}
},vertical:function(){
this.margin="margin-top";
this.layout="height";
this.offset=this.element.offsetHeight;
},horizontal:function(){
this.margin="margin-left";
this.layout="width";
this.offset=this.element.offsetWidth;
},slideIn:function(mode){
this[mode||this.options.mode]();
return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[0,this.offset]);
},slideOut:function(mode){
this[mode||this.options.mode]();
return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[-this.offset,0]);
},hide:function(mode){
this[mode||this.options.mode]();
this.open=false;
return this.set([-this.offset,0]);
},show:function(mode){
this[mode||this.options.mode]();
this.open=true;
return this.set([0,this.offset]);
},toggle:function(mode){
if(this.wrapper.offsetHeight==0||this.wrapper.offsetWidth==0){
return this.slideIn(mode);
}
return this.slideOut(mode);
},increase:function(){
this.element.setStyle(this.margin,this.now[0]+this.options.unit);
this.wrapper.setStyle(this.layout,this.now[1]+this.options.unit);
}});
Fx.Transition=function(_1de,_1df){
_1df=_1df||[];
if($type(_1df)!="array"){
_1df=[_1df];
}
return $extend(_1de,{easeIn:function(pos){
return _1de(pos,_1df);
},easeOut:function(pos){
return 1-_1de(1-pos,_1df);
},easeInOut:function(pos){
return (pos<=0.5)?_1de(2*pos,_1df)/2:(2-_1de(2*(1-pos),_1df))/2;
}});
};
Fx.Transitions=new Abstract({linear:function(p){
return p;
}});
Fx.Transitions.extend=function(_1e4){
for(var _1e5 in _1e4){
Fx.Transitions[_1e5]=new Fx.Transition(_1e4[_1e5]);
Fx.Transitions.compat(_1e5);
}
};
Fx.Transitions.compat=function(_1e6){
["In","Out","InOut"].each(function(_1e7){
Fx.Transitions[_1e6.toLowerCase()+_1e7]=Fx.Transitions[_1e6]["ease"+_1e7];
});
};
Fx.Transitions.extend({Pow:function(p,x){
return Math.pow(p,x[0]||6);
},Expo:function(p){
return Math.pow(2,8*(p-1));
},Circ:function(p){
return 1-Math.sin(Math.acos(p));
},Sine:function(p){
return 1-Math.sin((1-p)*Math.PI/2);
},Back:function(p,x){
x=x[0]||1.618;
return Math.pow(p,2)*((x+1)*p-x);
},Bounce:function(p){
var _1f0;
for(var a=0,b=1;1;a+=b,b/=2){
if(p>=(7-4*a)/11){
_1f0=-Math.pow((11-6*a-11*p)/4,2)+b*b;
break;
}
}
return _1f0;
},Elastic:function(p,x){
return Math.pow(2,10*--p)*Math.cos(20*p*Math.PI*(x[0]||1)/3);
}});
["Quad","Cubic","Quart","Quint"].each(function(_1f4,i){
Fx.Transitions[_1f4]=new Fx.Transition(function(p){
return Math.pow(p,[i+2]);
});
Fx.Transitions.compat(_1f4);
});
