/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
*/

var fx=new Object();fx.Base=function(){};fx.Base.prototype={setOptions:function(options){this.options={duration:500,onComplete:'',transition:fx.sinoidal};Object.extend(this.options,options||{})},go:function(){this.startTime=(new Date).getTime();this.timer=setInterval(this.step.bind(this),13)},step:function(){var time=(new Date).getTime();if(time>=this.options.duration+this.startTime){this.now=this.to;clearInterval(this.timer);this.timer=null;if(this.options.onComplete)setTimeout(this.options.onComplete.bind(this),10)}else{var Tpos=(time-this.startTime)/(this.options.duration);this.now=this.options.transition(Tpos)*(this.to-this.from)+this.from}this.increase()},custom:function(from,to){if(this.timer!=null)return;this.from=from;this.to=to;this.go()},hide:function(){this.now=0;this.increase()},clearTimer:function(){clearInterval(this.timer);this.timer=null}};fx.Layout=Class.create();fx.Layout.prototype=Object.extend(new fx.Base(),{initialize:function(el,options){this.el=$(el);this.el.style.overflow="hidden";this.el.iniWidth=this.el.offsetWidth;this.el.iniHeight=this.el.offsetHeight;this.setOptions(options)}});fx.Height=Class.create();Object.extend(Object.extend(fx.Height.prototype,fx.Layout.prototype),{increase:function(){this.el.style.height=this.now+"px"},toggle:function(){if(this.el.offsetHeight>1)this.custom(this.el.offsetHeight,1);else this.custom(1,this.el.scrollHeight)}});fx.Width=Class.create();Object.extend(Object.extend(fx.Width.prototype,fx.Layout.prototype),{increase:function(){this.el.style.width=this.now+"px"},toggle:function(){if(this.el.offsetWidth>0)this.custom(this.el.offsetWidth,0);else this.custom(0,this.el.iniWidth)}});fx.Opacity=Class.create();fx.Opacity.prototype=Object.extend(new fx.Base(),{initialize:function(el,options){this.el=$(el);if(this.el.offsetHeight<=1){this.now=0}else{this.now=1}this.increase();this.setOptions(options)},increase:function(){if(this.now==1&&(/Firefox/.test(navigator.userAgent)))this.now=0.9999;this.setOpacity(this.now)},setOpacity:function(opacity){if(window.ActiveXObject)this.el.style.filter="alpha(opacity="+opacity*100+")";this.el.style.opacity=opacity;if(opacity==0)this.el.style.visibility="hidden";else this.el.style.visibility="visible"},toggle:function(){ if(this.now>0)this.custom(1,0);else this.custom(0,1)}});fx.sinoidal=function(pos){return((-Math.cos(pos*Math.PI)/2)+0.5)};fx.linear=function(pos){return pos};fx.cubic=function(pos){return Math.pow(pos,3)};fx.circ=function(pos){return Math.sqrt(pos)};fx.Combo=Class.create();fx.Combo.prototype={setOptions:function(options){this.options={opacity:true,height:true,width:false};Object.extend(this.options,options||{})},initialize:function(el,options){this.el=$(el);this.setOptions(options);if(this.options.opacity){this.el.o=new fx.Opacity(el,options);options.onComplete=null}if(this.options.height){this.el.h=new fx.Height(el,options);options.onComplete=null}if(this.options.width)his.el.w=new fx.Width(el,options)},toggle:function(){this.checkExec('toggle')},hide:function(){this.checkExec('hide')},clearTimer:function(){this.checkExec('clearTimer')},checkExec:function(func){if(this.el.o)this.el.o[func]();if(this.el.h)this.el.h[func]();if(this.el.w)this.el.w[func]()},resizeTo:function(hto,wto){if(this.el.h&&this.el.w){this.h.custom(this.el.offsetHeight,this.el.offsetHeight+hto);this.w.custom(this.el.offsetWidth,this.el.offsetWidth+wto)}},customSize:function(hto,wto){if(this.el.h&&this.el.w){this.h.custom(this.el.offsetHeight,hto);this.w.custom(this.el.offsetWidth,wto)}}};var blocks=new Object();$blocks=new Array();var toggle_speed=600;blocks.collapse=function(id){var cookie_name=CPREFIX+'blocks_collapse';var blocks_collapsed=Cookie.fetch(cookie_name);var tmp=new Array();var block_collapsed=false;if(blocks_collapsed!=null){blocks_collapsed=blocks_collapsed.split('\n');for(var i in blocks_collapsed){if(blocks_collapsed[i]!=id&&blocks_collapsed[i]!=''&&i!='each'){tmp[tmp.length]=blocks_collapsed[i]}if(blocks_collapsed[i]==id)block_collapsed=true}}if($('block_'+id).offsetHeight>1&&!block_collapsed){tmp[tmp.length]=id}expire=new Date();expire.setTime(expire.getTime()+(86400*365));Cookie.set(cookie_name,tmp.join('\n'),expire)};blocks.toggle=function(id){if(!$blocks[id]){$blocks[id]=new fx.Combo("block_"+id,{duration:toggle_speed,height:true,opacity:true})}$blocks[id].toggle();blocks.collapse(id)};