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()},setNow:function(){this.now=this.compute(this.from,this.to)},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 }setTimeout(this.options.onStart.bind(this,this.element),10);this.from=B;this.to=A;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"}else{if(C.style.visibility!="visible"){C.style.visibility="visible"}}if(window.ActiveXObject){C.style.filter="alpha(opacity="+A*100+")"}C.style.opacity=A}else{C.style[B]=A+this.options.unit}}};Fx.Style=Class.create();Fx.Style.prototype=Object.extend(new Fx.Base(),{initialize:function(C,A,B){this.element=$(C);this.setOptions(B);this.property=A.camelize()},increase:function(){this.setStyle(this.element,this.property,this.now)}});Fx.Styles=Class.create();Fx.Styles.prototype=Object.extend(new Fx.Base(),{initialize:function(B,A){this.element=$(B);this.setOptions(A);this.now={}},setNow:function(){for(p in this.from){this.now[p]=this.compute(this.from[p],this.to[p])}},custom:function(A){if(this.timer&&this.options.wait){return }var C={};var B={};for(p in A){C[p]=A[p][0];B[p]=A[p][1]}return this._start(C,B)},increase:function(){for(var A in this.now){this.setStyle(this.element,A,this.now[A])}}});Fx.Transitions={linear:function(B,A,D,C){return D*B/C+A},sineInOut:function(B,A,D,C){return -D/2*(Math.cos(Math.PI*B/C)-1)+A}};Fx.Height=Class.create();Fx.Height.prototype=Object.extend(new Fx.Base(),{initialize:function(B,A){this.element=$(B);this.setOptions(A);this.element.style.overflow="hidden"},toggle:function(){if(this.element.offsetHeight>0){return this.custom(this.element.offsetHeight,0)}else{return this.custom(0,this.element.scrollHeight)}},show:function(){return this.set(this.element.scrollHeight)},increase:function(){this.setStyle(this.element,"height",this.now)}});Fx.Width=Class.create();Fx.Width.prototype=Object.extend(new Fx.Base(),{initialize:function(B,A){this.element=$(B);this.setOptions(A);this.element.style.overflow="hidden";this.iniWidth=this.element.offsetWidth},toggle:function(){if(this.element.offsetWidth>0){return this.custom(this.element.offsetWidth,0)}else{return this.custom(0,this.iniWidth)}},show:function(){return this.set(this.iniWidth)},increase:function(){this.setStyle(this.element,"width",this.now)}});Fx.Opacity=Class.create();Fx.Opacity.prototype=Object.extend(new Fx.Base(),{initialize:function(B,A){this.element=$(B);this.setOptions(A);this.now=1},toggle:function(){if(this.now>0){return this.custom(1,0)}else{return this.custom(0,1)}},show:function(){return this.set(1)},increase:function(){this.setStyle(this.element,"opacity",this.now)}});Jamendo.classes.Spy=Class.create();Jamendo.classes.Spy.prototype={initialize:function(A){this.first=true;this.lastid=0;this.items=[];this.o=Object.extend({"langs":"all","nfakestart":2,"decay":1,"fx":true,"itemobject":Jamendo.classes.SpyItem},A);Jamendo.onReady(function(){this.pj=new PeriodicalExecuter(function(){Jamendo.writeApi("spy",[this.o.types,this.o.langs,this.lastid,this.o.n+this.o.nfakestart],this.parseData.bind(this))}.bind(this),this.o.frequency);this.pj.onTimerEvent()}.bind(this))},parseData:function(B){if(B.length<1){return }this.lastid=B[0]["id"];for(var A=B.length-1;A>=0;A--){var C=this.items.length;this.items[C]=new this.o.itemobject(B[A],this);if(!this.o.fx||A>=this.o.nfakestart){this.items[C].show()}else{this.items[C].appearDelayed((Math.random()/2+1/2)*(B.length-A-1)*1000*this.o.frequency/B.length)}}},itemAdded:function(){if(this.items.length>this.o.n){this.items.shift().remove()}}};Jamendo.classes.SpyItem=Class.create();Jamendo.classes.SpyItem.prototype={initialize:function(B,A){this.data=B;this.spy=A;this.insert()},getId:function(){return this.spy.o.container+"__"+this.data.id},getHTML:function(){return"<div class='spy_item' id='"+this.getId()+"' style='display:none'>"+this.getInnerHTML()+"</div>"},appearDelayed:function(A){setTimeout(this.appear.bind(this),A)},appear:function(){if(this.a){this.spy.itemAdded();var A=new fx.Opacity(this.a,{duration:1500});A.hide();this.a.show();A.toggle()}},show:function(){this.spy.itemAdded();if(this.a){this.a.show()}},insert:function(){new Insertion.Top(this.spy.o.container,this.getHTML());this.a=$(this.getId())},remove:function(){this.data=undefined;this.spy=undefined;if(this.a){this.a.remove();delete this.a}},getInnerHTML:function(){return"spy item #"+this.data.id}}