1 $.speed = function(s,o) {
2 if ( o && o.constructor == Function ) o = { onComplete: o };
4 var ss = {"crawl":1200,"xslow":850,"slow":600,"medium":400,"fast":200,"xfast":75,"normal":400};
5 o.duration = typeof s == "number" ? s : ss[s] || 400;
9 $.fn.hide = function(a,o) {
11 return a ? this.each(function(){
12 new fx.FadeSize(this,o).hide();
16 $.fn.show = function(a,o) {
18 return a ? this.each(function(){
19 new fx.FadeSize(this,o).show();
23 $.fn.slideDown = function(a,o) {
25 return this.each(function(){
26 new fx.Resize(this,o).show("height");
30 $.fn.slideUp = function(a,o) {
32 return this.each(function(){
33 new fx.Resize(this,o).hide("height");
37 $.fn.fadeOut = function(a,o) {
39 return a ? this.each(function(){
40 new fx.Opacity(this,o).hide();
44 $.fn.fadeIn = function(a,o) {
46 return a ? this.each(function(){
47 new fx.Opacity(this,o).show();
51 $.fn.center = function(f) {
52 return this.each(function(){
53 if ( !f && this.nodeName == 'IMG' &&
54 !this.offsetWidth && !this.offsetHeight ) {
56 setTimeout(function(){
61 var p = this.parentNode;
62 if ( $.css(p,"position") == 'static' )
63 p.style.position = 'relative';
64 s.position = 'absolute';
65 s.left = parseInt(($.css(p,"width") - $.css(this,"width"))/2) + "px";
66 s.top = parseInt(($.css(p,"height") - $.css(this,"height"))/2) + "px";
71 $.setAuto = function(e,p) {
81 * I originally wrote fx() as a clone of moo.fx and in the process
82 * of making it small in size the code became illegible to sane
83 * people. You've been warned.
86 function fx(el,op,ty,tz){
88 z.a = function(){z.el.style[ty]=z.now+z.o.unit};
89 z.max = function(){return z.el["io"+ty]||z.el["natural"+tz]||z.el["scroll"+tz]||z.cur()};
90 z.cur = function(){return parseInt($.getCSS(z.el,ty))};
91 z.show = function(){z.ss("block");z.custom(0,z.max())};
92 z.hide = function(){z.el.$o=$.getCSS(z.el,"overflow");z.el["io"+ty]=this.cur();z.custom(z.cur(),0)};
93 z.ss = function(a){if(y.display!=a)y.display=a};
94 z.toggle = function(){if(z.cur()>0)z.hide();else z.show()};
95 z.modify = function(a){z.custom(z.cur(),z.cur()+a)};
96 z.clear = function(){clearInterval(z.timer);z.timer=null};
97 z.el = el.constructor==String?document.getElementById(el):el;
100 y.overflow = "hidden";
103 duration: (op && op.duration) || 400,
104 onComplete: (op && op.onComplete) || op
106 z.step = function(f,tt){
107 var t = (new Date).getTime();
108 var p = (t - z.s) / z.o.duration;
109 if (t >= z.o.duration+z.s) {
112 setTimeout(function(){
114 if(y.height=="0px"||y.width=="0px")z.ss("none");
115 if ( ty != "opacity" ) {
116 $.setAuto( z.el, "height" );
117 $.setAuto( z.el, "width" );
119 if(z.o.onComplete.constructor == Function){z.el.$_ = z.o.onComplete;z.el.$_();}
122 z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (tt-f) + f;
125 z.custom = function(f,t){
126 if(z.timer)return;this.now=f;z.a();z.io=z.cur();z.s=(new Date).getTime();
127 z.timer=setInterval(function(){z.step(f,t);}, 13);
130 fx.fn = ["show","hide","toggle"];
131 fx.ty = ["Height","Width","Left","Top"];
132 for(var i in fx.ty){(function(){
134 fx[c] = function(a,b){
135 return new fx(a,b,c.toLowerCase(),c);};
137 fx.Opacity = function(a,b){
138 var o = new fx(a,b,"opacity");
139 o.cur = function(){return parseFloat(o.el.style.opacity);};
142 if (o.now == 1) o.now = 0.9999;
143 if (window.ActiveXObject)
144 e.filter = "alpha(opacity=" + o.now*100 + ")";
151 fx.Resize = function(e,o){
153 var h = new fx.Height(e,o);
154 if(o) o.onComplete = null;
155 var w = new fx.Width(e,o);
156 function c(a,b,c){return (!a||a==c||b==c);}
157 for(var i in fx.fn){(function(){
159 z[j] = function(a,b){
160 if(c(a,b,"height")) h[j]();
161 if(c(a,b,"width")) w[j]();
164 z.modify = function(c,d){
169 fx.FadeSize = function(e,o){
171 var r = new fx.Resize(e,o);
172 if(o) o.onComplete = null;
173 var p = new fx.Opacity(e,o);
174 for(var i in fx.fn){(function(){
176 z[j] = function(a,b){p[j]();r[j](a,b);};