Fx.Slide=new Class({Extends:Fx,options:{mode:'vertical'},initialize:function(a,b){this.addEvent('complete',function(){this.open=(this.wrapper['offset'+this.layout.capitalize()]!=0);if(this.open&&Browser.Engine.webkit419)this.element.dispose().inject(this.wrapper)},true);this.element=this.subject=$(a);this.parent(b);var c=this.element.retrieve('wrapper');this.wrapper=c||new Element('div',{styles:$extend(this.element.getStyles('margin','position'),{'overflow':'hidden'})}).wraps(this.element);this.element.store('wrapper',this.wrapper).setStyle('margin',0);this.now=[];this.open=true},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},set:function(a){this.element.setStyle(this.margin,a[0]);this.wrapper.setStyle(this.layout,a[1]);return this},compute:function(a,b,c){var d=[];var x=2;x.times(function(i){d[i]=Fx.compute(a[i],b[i],c)});return d},start:function(a,b){if(!this.check(arguments.callee,a,b))return this;this[b||this.options.mode]();var c=this.element.getStyle(this.margin).toInt();var d=this.wrapper.getStyle(this.layout).toInt();var e=[[c,d],[0,this.offset]];var f=[[c,d],[-this.offset,0]];var g;switch(a){case'in':g=e;break;case'out':g=f;break;case'toggle':g=(this.wrapper['offset'+this.layout.capitalize()]==0)?e:f}return this.parent(g[0],g[1])},slideIn:function(a){return this.start('in',a)},slideOut:function(a){return this.start('out',a)},hide:function(a){this[a||this.options.mode]();this.open=false;return this.set([-this.offset,0])},show:function(a){this[a||this.options.mode]();this.open=true;return this.set([0,this.offset])},toggle:function(a){return this.start('toggle',a)}});Element.Properties.slide={set:function(a){var b=this.retrieve('slide');if(b)b.cancel();return this.eliminate('slide').store('slide:options',$extend({link:'cancel'},a))},get:function(a){if(a||!this.retrieve('slide')){if(a||!this.retrieve('slide:options'))this.set('slide',a);this.store('slide',new Fx.Slide(this,this.retrieve('slide:options')))}return this.retrieve('slide')}};Element.implement({slide:function(a,b){a=a||'toggle';var c=this.get('slide'),toggle;switch(a){case'hide':c.hide(b);break;case'show':c.show(b);break;case'toggle':var d=this.retrieve('slide:flag',c.open);c[(d)?'slideOut':'slideIn'](b);this.store('slide:flag',!d);toggle=true;break;default:c.start(a,b)}if(!toggle)this.eliminate('slide:flag');return this}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{'x':0,'y':0},wheelStops:true},initialize:function(a,b){this.element=this.subject=$(a);this.parent(b);var c=this.cancel.bind(this,false);if($type(this.element)!='element')this.element=$(this.element.getDocument().body);var d=this.element;if(this.options.wheelStops){this.addEvent('start',function(){d.addEvent('mousewheel',c)},true);this.addEvent('complete',function(){d.removeEvent('mousewheel',c)},true)}},set:function(){var a=Array.flatten(arguments);this.element.scrollTo(a[0],a[1])},compute:function(a,b,c){var d=[];var x=2;x.times(function(i){d.push(Fx.compute(a[i],b[i],c))});return d},start:function(x,y){if(!this.check(arguments.callee,x,y))return this;var a=this.element.getSize(),scrollSize=this.element.getScrollSize();var b=this.element.getScroll(),values={x:x,y:y};for(var z in values){var c=scrollSize[z]-a[z];if($chk(values[z]))values[z]=($type(values[z])=='number')?values[z].limit(0,c):c;else values[z]=b[z];values[z]+=this.options.offset[z]}return this.parent([b.x,b.y],[values.x,values.y])},toTop:function(){return this.start(false,0)},toLeft:function(){return this.start(0,false)},toRight:function(){return this.start('right',false)},toBottom:function(){return this.start(false,'bottom')},toElement:function(a){var b=$(a).getPosition(this.element);return this.start(b.x,b.y)}});Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(a,b){this.elements=this.subject=$$(a);this.parent(b)},compute:function(a,b,c){var d={};for(var i in a){var e=a[i],iTo=b[i],iNow=d[i]={};for(var p in e)iNow[p]=this.parent(e[p],iTo[p],c)}return d},set:function(a){for(var i in a){var b=a[i];for(var p in b)this.render(this.elements[i],p,b[p],this.options.unit)}return this},start:function(a){if(!this.check(arguments.callee,a))return this;var b={},to={};for(var i in a){var c=a[i],iFrom=b[i]={},iTo=to[i]={};for(var p in c){var d=this.prepare(this.elements[i],p,c[p]);iFrom[p]=d.from;iTo[p]=d.to}}return this.parent(b,to)}});var Drag=new Class({Implements:[Events,Options],options:{snap:6,unit:'px',grid:false,style:true,limit:false,handle:false,invert:false,preventDefault:false,modifiers:{x:'left',y:'top'}},initialize:function(){var a=Array.link(arguments,{'options':Object.type,'element':$defined});this.element=$(a.element);this.document=this.element.getDocument();this.setOptions(a.options||{});var b=$type(this.options.handle);this.handles=(b=='array'||b=='collection')?$$(this.options.handle):$(this.options.handle)||this.element;this.mouse={'now':{},'pos':{}};this.value={'start':{},'now':{}};this.selection=(Browser.Engine.trident)?'selectstart':'mousedown';this.bound={start:this.start.bind(this),check:this.check.bind(this),drag:this.drag.bind(this),stop:this.stop.bind(this),cancel:this.cancel.bind(this),eventStop:$lambda(false)};this.attach()},attach:function(){this.handles.addEvent('mousedown',this.bound.start);return this},detach:function(){this.handles.removeEvent('mousedown',this.bound.start);return this},start:function(a){if(this.options.preventDefault)a.preventDefault();this.fireEvent('beforeStart',this.element);this.mouse.start=a.page;var b=this.options.limit;this.limit={'x':[],'y':[]};for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;if(this.options.style)this.value.now[z]=this.element.getStyle(this.options.modifiers[z]).toInt();else this.value.now[z]=this.element[this.options.modifiers[z]];if(this.options.invert)this.value.now[z]*=-1;this.mouse.pos[z]=a.page[z]-this.value.now[z];if(b&&b[z]){for(var i=2;i--;i){if($chk(b[z][i]))this.limit[z][i]=$lambda(b[z][i])()}}}if($type(this.options.grid)=='number')this.options.grid={'x':this.options.grid,'y':this.options.grid};this.document.addEvents({mousemove:this.bound.check,mouseup:this.bound.cancel});this.document.addEvent(this.selection,this.bound.eventStop)},check:function(a){if(this.options.preventDefault)a.preventDefault();var b=Math.round(Math.sqrt(Math.pow(a.page.x-this.mouse.start.x,2)+Math.pow(a.page.y-this.mouse.start.y,2)));if(b>this.options.snap){this.cancel();this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop});this.fireEvent('start',this.element).fireEvent('snap',this.element)}},drag:function(a){if(this.options.preventDefault)a.preventDefault();this.mouse.now=a.page;for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.mouse.now[z]-this.mouse.pos[z];if(this.options.invert)this.value.now[z]*=-1;if(this.options.limit&&this.limit[z]){if($chk(this.limit[z][1])&&(this.value.now[z]>this.limit[z][1])){this.value.now[z]=this.limit[z][1]}else if($chk(this.limit[z][0])&&(this.value.now[z]<this.limit[z][0])){this.value.now[z]=this.limit[z][0]}}if(this.options.grid[z])this.value.now[z]-=(this.value.now[z]%this.options.grid[z]);if(this.options.style)this.element.setStyle(this.options.modifiers[z],this.value.now[z]+this.options.unit);else this.element[this.options.modifiers[z]]=this.value.now[z]}this.fireEvent('drag',this.element)},cancel:function(a){this.document.removeEvent('mousemove',this.bound.check);this.document.removeEvent('mouseup',this.bound.cancel);if(a){this.document.removeEvent(this.selection,this.bound.eventStop);this.fireEvent('cancel',this.element)}},stop:function(a){this.document.removeEvent(this.selection,this.bound.eventStop);this.document.removeEvent('mousemove',this.bound.drag);this.document.removeEvent('mouseup',this.bound.stop);if(a)this.fireEvent('complete',this.element)}});Element.implement({makeResizable:function(a){return new Drag(this,$merge({modifiers:{'x':'width','y':'height'}},a))}});Drag.Move=new Class({Extends:Drag,options:{droppables:[],container:false},initialize:function(a,b){this.parent(a,b);this.droppables=$$(this.options.droppables);this.container=$(this.options.container);if(this.container&&$type(this.container)!='element')this.container=$(this.container.getDocument().body);a=this.element;var c=a.getStyle('position');var d=(c!='static')?c:'absolute';if(a.getStyle('left')=='auto'||a.getStyle('top')=='auto')a.position(a.getPosition(a.offsetParent));a.setStyle('position',d);this.addEvent('start',function(){this.checkDroppables()},true)},start:function(b){if(this.container){var c=this.element,cont=this.container,ccoo=cont.getCoordinates(c.offsetParent),cps={},ems={};['top','right','bottom','left'].each(function(a){cps[a]=cont.getStyle('padding-'+a).toInt();ems[a]=c.getStyle('margin-'+a).toInt()},this);var d=c.offsetWidth+ems.left+ems.right,height=c.offsetHeight+ems.top+ems.bottom;var x=[ccoo.left+cps.left,ccoo.right-cps.right-d];var y=[ccoo.top+cps.top,ccoo.bottom-cps.bottom-height];this.options.limit={x:x,y:y}}this.parent(b)},checkAgainst:function(a){a=a.getCoordinates();var b=this.mouse.now;return(b.x>a.left&&b.x<a.right&&b.y<a.bottom&&b.y>a.top)},checkDroppables:function(){var a=this.droppables.filter(this.checkAgainst,this).getLast();if(this.overed!=a){if(this.overed)this.fireEvent('leave',[this.element,this.overed]);if(a){this.overed=a;this.fireEvent('enter',[this.element,a])}else{this.overed=null}}},drag:function(a){this.parent(a);if(this.droppables.length)this.checkDroppables()},stop:function(a){this.checkDroppables();this.fireEvent('drop',[this.element,this.overed]);this.overed=null;return this.parent(a)}});Element.implement({makeDraggable:function(a){return new Drag.Move(this,a)}});Hash.Cookie=new Class({Extends:Cookie,options:{autoSave:true},initialize:function(a,b){this.parent(a,b);this.load()},save:function(){var a=JSON.encode(this.hash);if(!a||a.length>4096)return false;if(a=='{}')this.dispose();else this.write(a);return true},load:function(){this.hash=new Hash(JSON.decode(this.read(),true));return this}});Hash.Cookie.implement((function(){var d={};Hash.each(Hash.prototype,function(b,c){d[c]=function(){var a=b.apply(this.hash,arguments);if(this.options.autoSave)this.save();return a}});return d})());var Color=new Native({initialize:function(a,b){if(arguments.length>=3){b="rgb";a=Array.slice(arguments,0,3)}else if(typeof a=='string'){if(a.match(/rgb/))a=a.rgbToHex().hexToRgb(true);else if(a.match(/hsb/))a=a.hsbToRgb();else a=a.hexToRgb(true)}b=b||'rgb';switch(b){case'hsb':var c=a;a=a.hsbToRgb();a.hsb=c;break;case'hex':a=a.hexToRgb(true);break}a.rgb=a.slice(0,3);a.hsb=a.hsb||a.rgbToHsb();a.hex=a.rgbToHex();return $extend(a,this)}});Color.implement({mix:function(){var b=Array.slice(arguments);var c=($type(b.getLast())=='number')?b.pop():50;var d=this.slice();b.each(function(a){a=new Color(a);for(var i=0;i<3;i++)d[i]=Math.round((d[i]/100*(100-c))+(a[i]/100*c))});return new Color(d,'rgb')},invert:function(){return new Color(this.map(function(a){return 255-a}))},setHue:function(a){return new Color([a,this.hsb[1],this.hsb[2]],'hsb')},setSaturation:function(a){return new Color([this.hsb[0],a,this.hsb[2]],'hsb')},setBrightness:function(a){return new Color([this.hsb[0],this.hsb[1],a],'hsb')}});function $RGB(r,g,b){return new Color([r,g,b],'rgb')};function $HSB(h,s,b){return new Color([h,s,b],'hsb')};function $HEX(a){return new Color(a,'hex')};Array.implement({rgbToHsb:function(){var a=this[0],green=this[1],blue=this[2];var b,saturation,brightness;var c=Math.max(a,green,blue),min=Math.min(a,green,blue);var d=c-min;brightness=c/255;saturation=(c!=0)?d/c:0;if(saturation==0){b=0}else{var e=(c-a)/d;var f=(c-green)/d;var g=(c-blue)/d;if(a==c)b=g-f;else if(green==c)b=2+e-g;else b=4+f-e;b/=6;if(b<0)b++}return[Math.round(b*360),Math.round(saturation*100),Math.round(brightness*100)]},hsbToRgb:function(){var a=Math.round(this[2]/100*255);if(this[1]==0){return[a,a,a]}else{var b=this[0]%360;var f=b%60;var p=Math.round((this[2]*(100-this[1]))/10000*255);var q=Math.round((this[2]*(6000-this[1]*f))/600000*255);var t=Math.round((this[2]*(6000-this[1]*(60-f)))/600000*255);switch(Math.floor(b/60)){case 0:return[a,t,p];case 1:return[q,a,p];case 2:return[p,a,t];case 3:return[p,q,a];case 4:return[t,p,a];case 5:return[a,p,q]}}return false}});String.implement({rgbToHsb:function(){var a=this.match(/\d{1,3}/g);return(a)?hsb.rgbToHsb():null},hsbToRgb:function(){var a=this.match(/\d{1,3}/g);return(a)?a.hsbToRgb():null}});var Group=new Class({initialize:function(){this.instances=Array.flatten(arguments);this.events={};this.checker={}},addEvent:function(b,c){this.checker[b]=this.checker[b]||{};this.events[b]=this.events[b]||[];if(this.events[b].contains(c))return false;else this.events[b].push(c);this.instances.each(function(a,i){a.addEvent(b,this.check.bind(this,[b,a,i]))},this);return this},check:function(b,c,i){this.checker[b][i]=true;var d=this.instances.every(function(a,j){return this.checker[b][j]||false},this);if(!d)return;this.checker[b]={};this.events[b].each(function(a){a.call(this,this.instances,c)},this)}});var Asset=new Hash({javascript:function(a,b){b=$extend({onload:$empty,document:document,check:$lambda(true)},b);var c=new Element('script',{'src':a,'type':'text/javascript'});var d=b.onload.bind(c),check=b.check,doc=b.document;delete b.onload;delete b.check;delete b.document;c.addEvents({load:d,readystatechange:function(){if(['loaded','complete'].contains(this.readyState))d()}}).setProperties(b);if(Browser.Engine.webkit419)var e=(function(){if(!$try(check))return;$clear(e);d()}).periodical(50);return c.inject(doc.head)},css:function(a,b){return new Element('link',$merge({'rel':'stylesheet','media':'screen','type':'text/css','href':a},b)).inject(document.head)},image:function(d,e){e=$merge({'onload':$empty,'onabort':$empty,'onerror':$empty},e);var f=new Image();var g=$(f)||new Element('img');['load','abort','error'].each(function(a){var b='on'+a;var c=e[b];delete e[b];f[b]=function(){if(!f)return;if(!g.parentNode){g.width=f.width;g.height=f.height}f=f.onload=f.onabort=f.onerror=null;c.delay(1,g,g);g.fireEvent(a,g,1)}});f.src=g.src=d;if(f&&f.complete)f.onload.delay(1);return g.setProperties(e)},images:function(c,d){d=$merge({onComplete:$empty,onProgress:$empty},d);if(!c.push)c=[c];var e=[];var f=0;c.each(function(a){var b=new Asset.image(a,{'onload':function(){d.onProgress.call(this,f,c.indexOf(a));f++;if(f==c.length)d.onComplete()}});e.push(b)});return new Elements(e)}});var Sortables=new Class({Implements:[Events,Options],options:{snap:4,opacity:1,clone:false,revert:false,handle:false,constrain:false},initialize:function(a,b){this.setOptions(b);this.elements=[];this.lists=[];this.idle=true;this.addLists($$($(a)||a));if(!this.options.clone)this.options.revert=false;if(this.options.revert)this.effect=new Fx.Morph(null,$merge({duration:250,link:'cancel'},this.options.revert))},attach:function(){this.addLists(this.lists);return this},detach:function(){this.lists=this.removeLists(this.lists);return this},addItems:function(){Array.flatten(arguments).each(function(a){this.elements.push(a);var b=a.retrieve('sortables:start',this.start.bindWithEvent(this,a));(this.options.handle?a.getElement(this.options.handle)||a:a).addEvent('mousedown',b)},this);return this},addLists:function(){Array.flatten(arguments).each(function(a){this.lists.push(a);this.addItems(a.getChildren())},this);return this},removeItems:function(){var c=[];Array.flatten(arguments).each(function(a){c.push(a);this.elements.erase(a);var b=a.retrieve('sortables:start');(this.options.handle?a.getElement(this.options.handle)||a:a).removeEvent('mousedown',b)},this);return $$(c)},removeLists:function(){var b=[];Array.flatten(arguments).each(function(a){b.push(a);this.lists.erase(a);this.removeItems(a.getChildren())},this);return $$(b)},getClone:function(a,b){if(!this.options.clone)return new Element('div').inject(document.body);if($type(this.options.clone)=='function')return this.options.clone.call(this,a,b,this.list);return b.clone(true).setStyles({'margin':'0px','position':'absolute','visibility':'hidden','width':b.getStyle('width')}).inject(this.list).position(b.getPosition(b.getOffsetParent()))},getDroppables:function(){var a=this.list.getChildren();if(!this.options.constrain)a=this.lists.concat(a).erase(this.list);return a.erase(this.clone).erase(this.element)},insert:function(a,b){var c='inside';if(this.lists.contains(b)){this.list=b;this.drag.droppables=this.getDroppables()}else{c=this.element.getAllPrevious().contains(b)?'before':'after'}this.element.inject(b,c);this.fireEvent('sort',[this.element,this.clone])},start:function(a,b){if(!this.idle)return;this.idle=false;this.element=b;this.opacity=b.get('opacity');this.list=b.getParent();this.clone=this.getClone(a,b);this.drag=new Drag.Move(this.clone,{snap:this.options.snap,container:this.options.constrain&&this.element.getParent(),droppables:this.getDroppables(),onSnap:function(){a.stop();this.clone.setStyle('visibility','visible');this.element.set('opacity',this.options.opacity||0);this.fireEvent('start',[this.element,this.clone])}.bind(this),onEnter:this.insert.bind(this),onCancel:this.reset.bind(this),onComplete:this.end.bind(this)});this.clone.inject(this.element,'before');this.drag.start(a)},end:function(){this.drag.detach();this.element.set('opacity',this.opacity);if(this.effect){var a=this.element.getStyles('width','height');var b=this.clone.computePosition(this.element.getPosition(this.clone.offsetParent));this.effect.element=this.clone;this.effect.start({top:b.top,left:b.left,width:a.width,height:a.height,opacity:0.25}).chain(this.reset.bind(this))}else{this.reset()}},reset:function(){this.idle=true;this.clone.destroy();this.fireEvent('complete',this.element)},serialize:function(){var c=Array.link(arguments,{modifier:Function.type,index:$defined});var d=this.lists.map(function(b){return b.getChildren().map(c.modifier||function(a){return a.get('id')},this)},this);var e=c.index;if(this.lists.length==1)e=0;return $chk(e)&&e>=0&&e<this.lists.length?d[e]:d}});var Tips=new Class({Implements:[Events,Options],options:{onShow:function(a){a.setStyle('visibility','visible')},onHide:function(a){a.setStyle('visibility','hidden')},showDelay:100,hideDelay:100,className:null,offsets:{x:16,y:16},fixed:false},initialize:function(){var a=Array.link(arguments,{options:Object.type,elements:$defined});this.setOptions(a.options||null);this.tip=new Element('div').inject(document.body);if(this.options.className)this.tip.addClass(this.options.className);var b=new Element('div',{'class':'tip-top'}).inject(this.tip);this.container=new Element('div',{'class':'tip'}).inject(this.tip);var c=new Element('div',{'class':'tip-bottom'}).inject(this.tip);this.tip.setStyles({position:'absolute',top:0,left:0,visibility:'hidden'});if(a.elements)this.attach(a.elements)},attach:function(g){$$(g).each(function(a){var b=a.retrieve('tip:title',a.get('title'));var c=a.retrieve('tip:text',a.get('rel')||a.get('href'));var d=a.retrieve('tip:enter',this.elementEnter.bindWithEvent(this,a));var e=a.retrieve('tip:leave',this.elementLeave.bindWithEvent(this,a));a.addEvents({mouseenter:d,mouseleave:e});if(!this.options.fixed){var f=a.retrieve('tip:move',this.elementMove.bindWithEvent(this,a));a.addEvent('mousemove',f)}a.store('tip:native',a.get('title'));a.erase('title')},this);return this},detach:function(c){$$(c).each(function(a){a.removeEvent('mouseenter',a.retrieve('tip:enter')||$empty);a.removeEvent('mouseleave',a.retrieve('tip:leave')||$empty);a.removeEvent('mousemove',a.retrieve('tip:move')||$empty);a.eliminate('tip:enter').eliminate('tip:leave').eliminate('tip:move');var b=a.retrieve('tip:native');if(b)a.set('title',b)});return this},elementEnter:function(a,b){$A(this.container.childNodes).each(Element.dispose);var c=b.retrieve('tip:title');if(c){this.titleElement=new Element('div',{'class':'tip-title'}).inject(this.container);this.fill(this.titleElement,c)}var d=b.retrieve('tip:text');if(d){this.textElement=new Element('div',{'class':'tip-text'}).inject(this.container);this.fill(this.textElement,d)}this.timer=$clear(this.timer);this.timer=this.show.delay(this.options.showDelay,this);this.position((!this.options.fixed)?a:{page:b.getPosition()})},elementLeave:function(a){$clear(this.timer);this.timer=this.hide.delay(this.options.hideDelay,this)},elementMove:function(a){this.position(a)},position:function(a){var b=window.getSize(),scroll=window.getScroll();var c={x:this.tip.offsetWidth,y:this.tip.offsetHeight};var d={x:'left',y:'top'};for(var z in d){var e=a.page[z]+this.options.offsets[z];if((e+c[z]-scroll[z])>b[z])e=a.page[z]-this.options.offsets[z]-c[z];this.tip.setStyle(d[z],e)}},fill:function(a,b){(typeof b=='string')?a.set('html',b):a.adopt(b)},show:function(){this.fireEvent('show',this.tip)},hide:function(){this.fireEvent('hide',this.tip)}});var SmoothScroll=new Class({Extends:Fx.Scroll,initialize:function(c,d){d=d||document;var e=d.getDocument(),win=d.getWindow();this.parent(e,c);this.links=(this.options.links)?$$(this.options.links):$$(e.links);var f=win.location.href.match(/^[^#]*/)[0]+'#';this.links.each(function(a){if(a.href.indexOf(f)!=0)return;var b=a.href.substr(f.length);if(b&&$(b))this.useLink(a,b)},this);if(!Browser.Engine.webkit419)this.addEvent('complete',function(){win.location.hash=this.anchor},true)},useLink:function(b,c){b.addEvent('click',function(a){this.anchor=c;this.toElement(c);a.stop()}.bind(this))}});var Slider=new Class({Implements:[Events,Options],options:{onTick:function(a){if(this.options.snap)a=this.toPosition(this.step);this.knob.setStyle(this.property,a)},snap:false,offset:0,range:false,wheel:false,steps:100,mode:'horizontal'},initialize:function(a,b,c){this.setOptions(c);this.element=$(a);this.knob=$(b);this.previousChange=this.previousEnd=this.step=-1;this.element.addEvent('mousedown',this.clickedElement.bind(this));if(this.options.wheel)this.element.addEvent('mousewheel',this.scrolledElement.bindWithEvent(this));var d,limit={},modifiers={'x':false,'y':false};switch(this.options.mode){case'vertical':this.axis='y';this.property='top';d='offsetHeight';break;case'horizontal':this.axis='x';this.property='left';d='offsetWidth'}this.half=this.knob[d]/2;this.full=this.element[d]-this.knob[d]+(this.options.offset*2);this.min=$chk(this.options.range[0])?this.options.range[0]:0;this.max=$chk(this.options.range[1])?this.options.range[1]:this.options.steps;this.range=this.max-this.min;this.steps=this.options.steps||this.full;this.stepSize=Math.abs(this.range)/this.steps;this.stepWidth=this.stepSize*this.full/Math.abs(this.range);this.knob.setStyle('position','relative').setStyle(this.property,-this.options.offset);modifiers[this.axis]=this.property;limit[this.axis]=[-this.options.offset,this.full-this.options.offset];this.drag=new Drag(this.knob,{snap:0,limit:limit,modifiers:modifiers,onDrag:this.draggedKnob.bind(this),onStart:this.draggedKnob.bind(this),onComplete:function(){this.draggedKnob();this.end()}.bind(this)});if(this.options.snap){this.drag.options.grid=Math.ceil(this.stepWidth);this.drag.options.limit[this.axis][1]=this.full}},set:function(a){if(!((this.range>0)^(a<this.min)))a=this.min;if(!((this.range>0)^(a>this.max)))a=this.max;this.step=Math.round(a);this.checkStep();this.end();this.fireEvent('tick',this.toPosition(this.step));return this},clickedElement:function(a){var b=this.range<0?-1:1;var c=a.page[this.axis]-this.element.getPosition()[this.axis]-this.half;c=c.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+b*this.toStep(c));this.checkStep();this.end();this.fireEvent('tick',c)},scrolledElement:function(a){var b=(this.options.mode=='horizontal')?(a.wheel<0):(a.wheel>0);this.set(b?this.step-this.stepSize:this.step+this.stepSize);a.stop()},draggedKnob:function(){var a=this.range<0?-1:1;var b=this.drag.value.now[this.axis];b=b.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+a*this.toStep(b));this.checkStep()},checkStep:function(){if(this.previousChange!=this.step){this.previousChange=this.step;this.fireEvent('change',this.step)}},end:function(){if(this.previousEnd!==this.step){this.previousEnd=this.step;this.fireEvent('complete',this.step+'')}},toStep:function(a){var b=(a+this.options.offset)*this.stepSize/this.full*this.steps;return this.options.steps?Math.round(b-=b%this.stepSize):b},toPosition:function(a){return(this.full*Math.abs(this.min-a))/(this.steps*this.stepSize)-this.options.offset}});var Scroller=new Class({Implements:[Events,Options],options:{area:20,velocity:1,onChange:function(x,y){this.element.scrollTo(x,y)}},initialize:function(a,b){this.setOptions(b);this.element=$(a);this.listener=($type(this.element)!='element')?$(this.element.getDocument().body):this.element;this.timer=null;this.coord=this.getCoords.bind(this)},start:function(){this.listener.addEvent('mousemove',this.coord)},stop:function(){this.listener.removeEvent('mousemove',this.coord);this.timer=$clear(this.timer)},getCoords:function(a){this.page=(this.listener.get('tag')=='body')?a.client:a.page;if(!this.timer)this.timer=this.scroll.periodical(50,this)},scroll:function(){var a=this.element.getSize(),scroll=this.element.getScroll(),pos=this.element.getPosition(),change={'x':0,'y':0};for(var z in this.page){if(this.page[z]<(this.options.area+pos[z])&&scroll[z]!=0)change[z]=(this.page[z]-this.options.area-pos[z])*this.options.velocity;else if(this.page[z]+this.options.area>(a[z]+pos[z])&&a[z]+a[z]!=scroll[z])change[z]=(this.page[z]-a[z]+this.options.area-pos[z])*this.options.velocity}if(change.y||change.x)this.fireEvent('change',[scroll.x+change.x,scroll.y+change.y])}});var Accordion=new Class({Extends:Fx.Elements,options:{display:0,show:false,height:true,width:false,opacity:true,fixedHeight:false,fixedWidth:false,wait:false,alwaysHide:false},initialize:function(){var c=Array.link(arguments,{'container':Element.type,'options':Object.type,'togglers':$defined,'elements':$defined});this.parent(c.elements,c.options);this.togglers=$$(c.togglers);this.container=$(c.container);this.previous=-1;if(this.options.alwaysHide)this.options.wait=true;if($chk(this.options.show)){this.options.display=false;this.previous=this.options.show}if(this.options.start){this.options.display=false;this.options.show=false}this.effects={};if(this.options.opacity)this.effects.opacity='fullOpacity';if(this.options.width)this.effects.width=this.options.fixedWidth?'fullWidth':'offsetWidth';if(this.options.height)this.effects.height=this.options.fixedHeight?'fullHeight':'scrollHeight';for(var i=0,l=this.togglers.length;i<l;i++)this.addSection(this.togglers[i],this.elements[i]);this.elements.each(function(a,i){if(this.options.show===i){this.fireEvent('active',[this.togglers[i],a])}else{for(var b in this.effects)a.setStyle(b,0)}},this);if($chk(this.options.display))this.display(this.options.display)},addSection:function(a,b,c){a=$(a);b=$(b);var d=this.togglers.contains(a);var e=this.togglers.length;this.togglers.include(a);this.elements.include(b);if(e&&(!d||c)){c=$pick(c,e-1);a.inject(this.togglers[c],'before');b.inject(a,'after')}else if(this.container&&!d){a.inject(this.container);b.inject(this.container)}var f=this.togglers.indexOf(a);a.addEvent('click',this.display.bind(this,f));if(this.options.height)b.setStyles({'padding-top':0,'border-top':'none','padding-bottom':0,'border-bottom':'none'});if(this.options.width)b.setStyles({'padding-left':0,'border-left':'none','padding-right':0,'border-right':'none'});b.fullOpacity=1;if(this.options.fixedWidth)b.fullWidth=this.options.fixedWidth;if(this.options.fixedHeight)b.fullHeight=this.options.fixedHeight;b.setStyle('overflow','hidden');if(!d){for(var g in this.effects)b.setStyle(g,0)}return this},display:function(d){d=($type(d)=='element')?this.elements.indexOf(d):d;if((this.timer&&this.options.wait)||(d===this.previous&&!this.options.alwaysHide))return this;this.previous=d;var e={};this.elements.each(function(a,i){e[i]={};var b=(i!=d)||(this.options.alwaysHide&&(a.offsetHeight>0));this.fireEvent(b?'background':'active',[this.togglers[i],a]);for(var c in this.effects)e[i][c]=b?0:a[this.effects[c]]},this);return this.start(e)}});