var Fx=fx={};Fx.Base=function(){};Fx.Base.prototype={setOptions:function(a){this.options=Object.extend({onStart:function(){},onComplete:function(){},transition:Fx.Transitions.sineInOut,duration:500,unit:"px",wait:true,fps:50},a||{})},step:function(){var a=new Date().getTime();if(a<this.time+this.options.duration){this.cTime=a-this.time;this.setNow()}else{setTimeout(this.options.onComplete.bind(this,this.element),10);this.clearTimer();this.now=this.to}this.increase();return this},setNow:function(){this.now=this.compute(this.from,this.to);return this},compute:function(c,b){var a=b-c;return this.options.transition(this.cTime,c,a,this.options.duration)},clearTimer:function(){clearInterval(this.timer);this.timer=null;return this},start:function(b,a){if(!this.options.wait){this.clearTimer()}if(this.timer){return this}setTimeout(this.options.onStart.bind(this,this.element),10);if(arguments.length==1){this.to=b;this.from=parseInt(this.getStyle(this.element,this.property))}else{this.to=a;this.from=b}this.time=new Date().getTime();this.timer=setInterval(this.step.bind(this),Math.round(1000/this.options.fps));return this},custom:function(b,a){return this.start(b,a)},set:function(a){this.now=a;this.increase();return this},hide:function(){return this.set(0)},setStyle:function(c,b,a){if(b=="opacity"){if(a==0&&c.style.visibility!="hidden"){c.style.visibility="hidden";c.style.display="none"}else{if(a!=0&&c.style.visibility!="visible"){c.style.visibility="visible";c.style.display=""}}if(a==1&&(/Gecko/.test(navigator.userAgent)&&!/Konqueror|Safari|KHTML/.test(navigator.userAgent))){a=1}if(window.ActiveXObject){c.style.filter="alpha(opacity="+a*100+")"}else{c.style.opacity=a}}else{c.style[b]=a+this.options.unit}return this},getStyle:function(c,b){var a;if(c.style[b]!==""){a=c.style}else{a=(document.defaultView)?document.defaultView.getComputedStyle(c,null):c.currentStyle}return a[b]},setElement:function(a){this.element=$(a);return this},getElement:function(){return this.element}};Fx.Style=Class.create();Fx.Style.prototype=Object.extend(new Fx.Base(),{initialize:function(b,c,a){this.setElement(b);this.setOptions(a);this.property=c.camelize()},increase:function(){return this.setStyle(this.element,this.property,this.now)}});Fx.Shield=Class.create();Fx.Shield.prototype=Object.extend(new Fx.Base(),{subject:null,initialize:function(b,a){this.setOptions(a);var c;if(this.options.id&&document.getElementById(this.options.id)){c=document.getElementById(this.options.id)}else{c=document.createElement("DIV");if(this.options.id){c.id=this.options.id}}c.className="shield";c.style.position="absolute";this.setStyle(c,"opacity",0);this.setElement(c);this.subject=$(b);this.subject.appendChild(this.element)},increase:function(){return this.setStyle(this.element,"opacity",this.now)},matchSubject:function(){if((this.subject==document.body)){this.matchViewport();Event.observe(window,"resize",this.matchViewport.bind(this))}else{this.element.clonePosition(this.subject)}return this},matchViewport:function(){var b=document.viewport.getDimensions();var c=(Prototype.Browser.IE6)?"absolute":"fixed";var a={height:b.height+"px",width:b.width+"px",top:0,left:0,position:"fixed"};a=(Prototype.Browser.IE6)?this._matchViewportIE6(a):a;this.element.setStyle(a)},_matchViewportIE6:function(a){var b=document.viewport.getScrollOffsets();Object.extend(a,{top:b.top+"px",position:"absolute"});return a},start:function(b,a){this.matchSubject();Fx.Base.prototype.start.call(this,b,a);return this}});Fx.Overlay=Class.create({initialize:function(c,b){var a=this;this.element=$(c);Object.extend(this.options,b);this.fx=new Fx.Style(this.element,"opacity",{options:this.options.duration,onComplete:function(){if(window.ActiveXObject){this.element.style.filter=""}}});if(this.options.dismiss){var d=function(e){if(Event.KEY_ESC==e.keyCode){this.hide();e.stop();Event.stopObserving(document,"keypress");Event.stopObserving(document,"keydown")}};Event.observe(document,"keypress",d.bindAsEventListener(this));Event.observe(document,"keydown",d.bindAsEventListener(this))}this.shield=new Fx.Shield(document.body,this.options);this.shield.element.parentNode.appendChild(this.element)},element:null,fx:null,options:{opacity:0.75,duration:500,id:"overlay",dismiss:false},show:function(){this._showIE();this.position();this.shield.start(0,this.options.opacity);this.fx.start(0,1);Fx.Overlay.visible=this;return this},_showIE:function(){if(Prototype.Browser.IE6){$$("html, body").each(function(c){c.setStyle({height:"100%",overflow:"hidden"})});var a=$(this.shield.element);var b=a.getWidth();a.setStyle({width:(b+20)+"px"});$$("select, embed, object").each(function(c){c.style.visibility="hidden"})}},hide:function(){this.shield.start(this.options.opacity,0);this.fx.start(1,0);Fx.Overlay.visible=null;this._hideIE();return this},_hideIE:function(){if(Prototype.Browser.IE6){$$("html, body").each(function(b){b.setStyle({height:"auto",overflow:""})});var a=$(this.shield.element).getWidth();$(this.shield.element).setStyle({width:(a-20)+"px"});$$("select, embed, object").each(function(b){b.style.visibility="visible"})}},destroy:function(){this.element.remove();this.shield.element.remove()},position:function(){var a=Position.viewportSize();var c=this.element.getDimensions();var e=(a.height-c.height)/2;var d=(a.width-c.width)/2;this.element.setStyle({top:e+"px",left:d+"px",position:"fixed"});var b=!!(c.height>a.height);this._positionFix(e,d,b);return this},_positionFix:function(c,b,a){if(a||Prototype.Browser.IE6){var d=document.viewport.getScrollOffsets();this.element.setStyle({top:(c+d.top)+"px",position:"absolute"})}}});Fx.Overlay.visible=null;Fx.Overlay.hide=function(){if(Fx.Overlay.visible){Fx.Overlay.visible.hide()}};Fx.Overlay.destroy=function(){if(Fx.Overlay.visible){Fx.Overlay.visible.destroy()}};Fx.Overlay.BindOverlayAction=function(b,d,c){var a=b||this;d=d||".lbAction";c=c||"rel";$(this.element).select(d).each(function(e){var f=e.readAttribute(c);if(Object.isFunction(a[f])){Event.observe(e,"click",a[f].bindAsEventListener(a))}})};Fx.AjaxOverlay=Class.create(Fx.Overlay,{initialize:function($super,a){this.myOptions=Object.extend(this.myOptions,a);var b=$(this.myOptions.id)||new Element("div",{id:this.myOptions.id}).addClassName(this.myOptions.className);b.update(new Element("img",{src:this.myOptions.progressImage,"class":"spinner"}));$super(b,this.myOptions.overlayOptions)},show:function($super){var b=function(d){return function(f){this.element.update(f.responseText);this.position();var e=d.bind(this,f);e()}};var c=b(this.myOptions.onSuccess);var a=b(this.myOptions.onFailure);if(Fx.Overlay.visible!==this){Fx.AjaxOverlay.hide();$super()}this.load(c,a)},load:function(b,a){new Ajax.Request(this.myOptions.url,{method:this.myOptions.method,parameters:this.myOptions.parameters,onSuccess:b.bind(this),onFailure:a.bind(this)})},element:null,myOptions:{url:null,progressImage:"http://g.fool.com/img/progress_spinner.gif",method:"post",parameters:null,id:"overlayMessage",className:"overlayElement",onSuccess:function(){},onFailure:function(){},overlayOptions:{}}});Fx.AjaxOverlay.hide=function(){Fx.Overlay.hide()};Fx.Transitions={linear:function(e,a,g,f){return g*e/f+a},sineIn:function(e,a,g,f){return -g*Math.cos(e/f*(Math.PI/2))+g+a},sineOut:function(e,a,g,f){return g*Math.sin(e/f*(Math.PI/2))+a},sineInOut:function(e,a,g,f){return -g/2*(Math.cos(Math.PI*e/f)-1)+a},bounceIn:function(e,a,g,f){return g-Fx.Transitions.bounceOut(f-e,0,g,f)+a},bounceOut:function(e,a,g,f){if((e/=f)<(1/2.75)){return g*(7.5625*e*e)+a}else{if(e<(2/2.75)){return g*(7.5625*(e-=(1.5/2.75))*e+0.75)+a}else{if(e<(2.5/2.75)){return g*(7.5625*(e-=(2.25/2.75))*e+0.9375)+a}else{return g*(7.5625*(e-=(2.625/2.75))*e+0.984375)+a}}}},bounceInOut:function(e,a,g,f){if(e<f/2){return Fx.Transitions.bounceIn(e*2,0,g,f)*0.5+a}return Fx.Transitions.bounceOut(e*2-f,0,g,f)*0.5+g*0.5+a}};