Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(a,c){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(c);var b=this.element.retrieve("wrapper");this.wrapper=b||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,e){var c=[];var d=2;d.times(function(f){c[f]=Fx.compute(a[f],b[f],e);});return c;},start:function(g,b){if(!this.check(arguments.callee,g,b)){return this;}this[b||this.options.mode]();var f=this.element.getStyle(this.margin).toInt();var c=this.wrapper.getStyle(this.layout).toInt();var e=[[f,c],[0,this.offset]];var d=[[f,c],[-this.offset,0]];var a;switch(g){case"in":a=e;break;case"out":a=d;break;case"toggle":a=(this.wrapper["offset"+this.layout.capitalize()]==0)?e:d;}return this.parent(a[0],a[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(c,b){c=c||"toggle";var d=this.get("slide"),e;switch(c){case"hide":d.hide(b);break;case"show":d.show(b);break;case"toggle":var a=this.retrieve("slide:flag",d.open);d[(a)?"slideOut":"slideIn"](b);this.store("slide:flag",!a);e=true;break;default:d.start(c,b);}if(!e){this.eliminate("slide:flag");}return this;}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(a,c){this.element=this.subject=$(a);this.parent(c);var d=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=$(this.element.getDocument().body);}var b=this.element;if(this.options.wheelStops){this.addEvent("start",function(){b.addEvent("mousewheel",d);},true);this.addEvent("complete",function(){b.removeEvent("mousewheel",d);},true);}},set:function(){var a=Array.flatten(arguments);this.element.scrollTo(a[0],a[1]);},compute:function(a,b,e){var c=[];var d=2;d.times(function(f){c.push(Fx.compute(a[f],b[f],e));});return c;},start:function(g,h){if(!this.check(arguments.callee,g,h)){return this;}var c=this.element.getSize(),b=this.element.getScrollSize();var a=this.element.getScroll(),e={x:g,y:h};for(var f in e){var d=b[f]-c[f];if($chk(e[f])){e[f]=($type(e[f])=="number")?e[f].limit(0,d):d;}else{e[f]=a[f];}e[f]+=this.options.offset[f];}return this.parent([a.x,a.y],[e.x,e.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(b){var a=$(b).getPosition(this.element);return this.start(a.x,a.y);}});Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(a,b){this.elements=this.subject=$$(a);this.parent(b);},compute:function(j,a,c){var h={};for(var f in j){var e=j[f],g=a[f],d=h[f]={};for(var b in e){d[b]=this.parent(e[b],g[b],c);}}return h;},set:function(a){for(var c in a){var b=a[c];for(var d in b){this.render(this.elements[c],d,b[d],this.options.unit);}}return this;},start:function(h){if(!this.check(arguments.callee,h)){return this;}var d={},a={};for(var f in h){var j=h[f],e=d[f]={},g=a[f]={};for(var b in j){var c=this.prepare(this.elements[f],b,j[b]);e[b]=c.from;g[b]=c.to;}}return this.parent(d,a);}});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(b){if(this.options.preventDefault){b.preventDefault();}this.fireEvent("beforeStart",this.element);this.mouse.start=b.page;var d=this.options.limit;this.limit={x:[],y:[]};for(var c in this.options.modifiers){if(!this.options.modifiers[c]){continue;}if(this.options.style){this.value.now[c]=this.element.getStyle(this.options.modifiers[c]).toInt();}else{this.value.now[c]=this.element[this.options.modifiers[c]];}if(this.options.invert){this.value.now[c]*=-1;}this.mouse.pos[c]=b.page[c]-this.value.now[c];if(d&&d[c]){for(var a=2;a--;a){if($chk(d[c][a])){this.limit[c][a]=$lambda(d[c][a])();}}}}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 b in this.options.modifiers){if(!this.options.modifiers[b]){continue;}this.value.now[b]=this.mouse.now[b]-this.mouse.pos[b];if(this.options.invert){this.value.now[b]*=-1;}if(this.options.limit&&this.limit[b]){if($chk(this.limit[b][1])&&(this.value.now[b]>this.limit[b][1])){this.value.now[b]=this.limit[b][1];}else{if($chk(this.limit[b][0])&&(this.value.now[b]<this.limit[b][0])){this.value.now[b]=this.limit[b][0];}}}if(this.options.grid[b]){this.value.now[b]-=(this.value.now[b]%this.options.grid[b]);}if(this.options.style){this.element.setStyle(this.options.modifiers[b],this.value.now[b]+this.options.unit);}else{this.element[this.options.modifiers[b]]=this.value.now[b];}}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,d){this.parent(a,d);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 b=(c!="static")?c:"absolute";if(a.getStyle("left")=="auto"||a.getStyle("top")=="auto"){a.position(a.getPosition(a.offsetParent));}a.setStyle("position",b);this.addEvent("start",function(){this.checkDroppables();},true);},start:function(a){if(this.container){var b=this.element,d=this.container,e=d.getCoordinates(b.offsetParent),g={},i={};["top","right","bottom","left"].each(function(k){g[k]=d.getStyle("padding-"+k).toInt();i[k]=b.getStyle("margin-"+k).toInt();},this);var f=b.offsetWidth+i.left+i.right,c=b.offsetHeight+i.top+i.bottom;var h=[e.left+g.left,e.right-g.right-f];var j=[e.top+g.top,e.bottom-g.bottom-c];this.options.limit={x:h,y:j};}this.parent(a);},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(b,a){this.parent(b,a);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 a={};Hash.each(Hash.prototype,function(b,c){a[c]=function(){var d=b.apply(this.hash,arguments);if(this.options.autoSave){this.save();}return d;};});return a;})());var Color=new Native({initialize:function(c,b){if(arguments.length>=3){b="rgb";c=Array.slice(arguments,0,3);}else{if(typeof c=="string"){if(c.match(/rgb/)){c=c.rgbToHex().hexToRgb(true);}else{if(c.match(/hsb/)){c=c.hsbToRgb();}else{c=c.hexToRgb(true);}}}}b=b||"rgb";switch(b){case"hsb":var a=c;c=c.hsbToRgb();c.hsb=a;break;case"hex":c=c.hexToRgb(true);break;}c.rgb=c.slice(0,3);c.hsb=c.hsb||c.rgbToHsb();c.hex=c.rgbToHex();return $extend(c,this);}});Color.implement({mix:function(){var a=Array.slice(arguments);var b=($type(a.getLast())=="number")?a.pop():50;var c=this.slice();a.each(function(e){e=new Color(e);for(var d=0;d<3;d++){c[d]=Math.round((c[d]/100*(100-b))+(e[d]/100*b));}});return new Color(c,"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(d,c,a){return new Color([d,c,a],"rgb");}function $HSB(d,a,c){return new Color([d,a,c],"hsb");}function $HEX(a){return new Color(a,"hex");}Array.implement({rgbToHsb:function(){var i=this[0],f=this[1],h=this[2];var k,g,b;var e=Math.max(i,f,h),l=Math.min(i,f,h);var c=e-l;b=e/255;g=(e!=0)?c/e:0;if(g==0){k=0;}else{var a=(e-i)/c;var d=(e-f)/c;var j=(e-h)/c;if(i==e){k=j-d;}else{if(f==e){k=2+a-j;}else{k=4+d-a;}}k/=6;if(k<0){k++;}}return[Math.round(k*360),Math.round(g*100),Math.round(b*100)];},hsbToRgb:function(){var g=Math.round(this[2]/100*255);if(this[1]==0){return[g,g,g];}else{var e=this[0]%360;var b=e%60;var a=Math.round((this[2]*(100-this[1]))/10000*255);var c=Math.round((this[2]*(6000-this[1]*b))/600000*255);var d=Math.round((this[2]*(6000-this[1]*(60-b)))/600000*255);switch(Math.floor(e/60)){case 0:return[g,d,a];case 1:return[c,g,a];case 2:return[a,g,d];case 3:return[a,c,g];case 4:return[d,a,g];case 5:return[g,a,c];}}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,a){this.checker[b]=this.checker[b]||{};this.events[b]=this.events[b]||[];if(this.events[b].contains(a)){return false;}else{this.events[b].push(a);}this.instances.each(function(d,c){d.addEvent(b,this.check.bind(this,[b,d,c]));},this);return this;},check:function(c,a,b){this.checker[c][b]=true;var d=this.instances.every(function(f,e){return this.checker[c][e]||false;},this);if(!d){return;}this.checker[c]={};this.events[c].each(function(e){e.call(this,this.instances,a);},this);}});var Asset=new Hash({javascript:function(e,c){c=$extend({onload:$empty,document:document,check:$lambda(true)},c);var d=new Element("script",{src:e,type:"text/javascript"});var g=c.onload.bind(d),a=c.check,f=c.document;delete c.onload;delete c.check;delete c.document;d.addEvents({load:g,readystatechange:function(){if(["loaded","complete"].contains(this.readyState)){g();}}}).setProperties(c);if(Browser.Engine.webkit419){var b=(function(){if(!$try(a)){return;}$clear(b);g();}).periodical(50);}return d.inject(f.head);},css:function(b,a){return new Element("link",$merge({rel:"stylesheet",media:"screen",type:"text/css",href:b},a)).inject(document.head);},image:function(a,b){b=$merge({onload:$empty,onabort:$empty,onerror:$empty},b);var d=new Image();var c=$(d)||new Element("img");["load","abort","error"].each(function(e){var f="on"+e;var g=b[f];delete b[f];d[f]=function(){if(!d){return;}if(!c.parentNode){c.width=d.width;c.height=d.height;}d=d.onload=d.onabort=d.onerror=null;g.delay(1,c,c);c.fireEvent(e,c,1);};});d.src=c.src=a;if(d&&d.complete){d.onload.delay(1);}return c.setProperties(b);},images:function(a,c){c=$merge({onComplete:$empty,onProgress:$empty},c);if(!a.push){a=[a];}var d=[];var b=0;a.each(function(f){var e=new Asset.image(f,{onload:function(){c.onProgress.call(this,b,a.indexOf(f));b++;if(b==a.length){c.onComplete();}}});d.push(e);});return new Elements(d);}});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(b){this.elements.push(b);var a=b.retrieve("sortables:start",this.start.bindWithEvent(this,b));(this.options.handle?b.getElement(this.options.handle)||b:b).addEvent("mousedown",a);},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 a=[];Array.flatten(arguments).each(function(c){a.push(c);this.elements.erase(c);var b=c.retrieve("sortables:start");(this.options.handle?c.getElement(this.options.handle)||c:c).removeEvent("mousedown",b);},this);return $$(a);},removeLists:function(){var a=[];Array.flatten(arguments).each(function(b){a.push(b);this.lists.erase(b);this.removeItems(b.getChildren());},this);return $$(a);},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(b,a){var c="inside";if(this.lists.contains(a)){this.list=a;this.drag.droppables=this.getDroppables();}else{c=this.element.getAllPrevious().contains(a)?"before":"after";}this.element.inject(a,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 b=this.element.getStyles("width","height");var a=this.clone.computePosition(this.element.getPosition(this.clone.offsetParent));this.effect.element=this.clone;this.effect.start({top:a.top,left:a.left,width:b.width,height:b.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 a=Array.link(arguments,{modifier:Function.type,index:$defined});var c=this.lists.map(function(d){return d.getChildren().map(a.modifier||function(e){return e.get("id");},this);},this);var b=a.index;if(this.lists.length==1){b=0;}return $chk(b)&&b>=0&&b<this.lists.length?c[b]:c;}});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 c=new Element("div",{"class":"tip-top"}).inject(this.tip);this.container=new Element("div",{"class":"tip"}).inject(this.tip);var b=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(a){$$(a).each(function(c){var g=c.retrieve("tip:title",c.get("title"));var d=c.retrieve("tip:text",c.get("rel")||c.get("href"));var b=c.retrieve("tip:enter",this.elementEnter.bindWithEvent(this,c));var e=c.retrieve("tip:leave",this.elementLeave.bindWithEvent(this,c));c.addEvents({mouseenter:b,mouseleave:e});if(!this.options.fixed){var f=c.retrieve("tip:move",this.elementMove.bindWithEvent(this,c));c.addEvent("mousemove",f);}c.store("tip:native",c.get("title"));c.erase("title");},this);return this;},detach:function(a){$$(a).each(function(c){c.removeEvent("mouseenter",c.retrieve("tip:enter")||$empty);c.removeEvent("mouseleave",c.retrieve("tip:leave")||$empty);c.removeEvent("mousemove",c.retrieve("tip:move")||$empty);c.eliminate("tip:enter").eliminate("tip:leave").eliminate("tip:move");var b=c.retrieve("tip:native");if(b){c.set("title",b);}});return this;},elementEnter:function(c,a){$A(this.container.childNodes).each(Element.dispose);var b=a.retrieve("tip:title");if(b){this.titleElement=new Element("div",{"class":"tip-title"}).inject(this.container);this.fill(this.titleElement,b);}var d=a.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)?c:{page:a.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 f=window.getSize(),b=window.getScroll();var c={x:this.tip.offsetWidth,y:this.tip.offsetHeight};var d={x:"left",y:"top"};for(var e in d){var g=a.page[e]+this.options.offsets[e];if((g+c[e]-b[e])>f[e]){g=a.page[e]-this.options.offsets[e]-c[e];}this.tip.setStyle(d[e],g);}},fill:function(b,a){(typeof a=="string")?b.set("html",a):b.adopt(a);},show:function(){this.fireEvent("show",this.tip);},hide:function(){this.fireEvent("hide",this.tip);}});var SmoothScroll=new Class({Extends:Fx.Scroll,initialize:function(d,b){b=b||document;var e=b.getDocument(),c=b.getWindow();this.parent(e,d);this.links=(this.options.links)?$$(this.options.links):$$(e.links);var a=c.location.href.match(/^[^#]*/)[0]+"#";this.links.each(function(f){if(f.href.indexOf(a)!=0){return;}var g=f.href.substr(a.length);if(g&&$(g)){this.useLink(f,g);}},this);if(!Browser.Engine.webkit419){this.addEvent("complete",function(){c.location.hash=this.anchor;},true);}},useLink:function(a,b){a.addEvent("click",function(c){this.anchor=b;this.toElement(b);c.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(b,f,d){this.setOptions(d);this.element=$(b);this.knob=$(f);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 a,e={},c={x:false,y:false};switch(this.options.mode){case"vertical":this.axis="y";this.property="top";a="offsetHeight";break;case"horizontal":this.axis="x";this.property="left";a="offsetWidth";}this.half=this.knob[a]/2;this.full=this.element[a]-this.knob[a]+(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);c[this.axis]=this.property;e[this.axis]=[-this.options.offset,this.full-this.options.offset];this.drag=new Drag(this.knob,{snap:0,limit:e,modifiers:c,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(c){var a=this.range<0?-1:1;var b=c.page[this.axis]-this.element.getPosition()[this.axis]-this.half;b=b.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+a*this.toStep(b));this.checkStep();this.end();this.fireEvent("tick",b);},scrolledElement:function(b){var a=(this.options.mode=="horizontal")?(b.wheel<0):(b.wheel>0);this.set(a?this.step-this.stepSize:this.step+this.stepSize);b.stop();},draggedKnob:function(){var b=this.range<0?-1:1;var a=this.drag.value.now[this.axis];a=a.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+b*this.toStep(a));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(a,b){this.element.scrollTo(a,b);}},initialize:function(b,a){this.setOptions(a);this.element=$(b);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 c=this.element.getSize(),d=this.element.getScroll(),e=this.element.getPosition(),b={x:0,y:0};for(var a in this.page){if(this.page[a]<(this.options.area+e[a])&&d[a]!=0){b[a]=(this.page[a]-this.options.area-e[a])*this.options.velocity;}else{if(this.page[a]+this.options.area>(c[a]+e[a])&&c[a]+c[a]!=d[a]){b[a]=(this.page[a]-c[a]+this.options.area-e[a])*this.options.velocity;}}}if(b.y||b.x){this.fireEvent("change",[d.x+b.x,d.y+b.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 a=Array.link(arguments,{container:Element.type,options:Object.type,togglers:$defined,elements:$defined});this.parent(a.elements,a.options);this.togglers=$$(a.togglers);this.container=$(a.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 b=0,c=this.togglers.length;b<c;b++){this.addSection(this.togglers[b],this.elements[b]);}this.elements.each(function(e,d){if(this.options.show===d){this.fireEvent("active",[this.togglers[d],e]);}else{for(var f in this.effects){e.setStyle(f,0);}}},this);if($chk(this.options.display)){this.display(this.options.display);}},addSection:function(a,b,f){a=$(a);b=$(b);var e=this.togglers.contains(a);var c=this.togglers.length;this.togglers.include(a);this.elements.include(b);if(c&&(!e||f)){f=$pick(f,c-1);a.inject(this.togglers[f],"before");b.inject(a,"after");}else{if(this.container&&!e){a.inject(this.container);b.inject(this.container);}}var g=this.togglers.indexOf(a);a.addEvent("click",this.display.bind(this,g));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(!e){for(var d in this.effects){b.setStyle(d,0);}}return this;},display:function(b){b=($type(b)=="element")?this.elements.indexOf(b):b;if((this.timer&&this.options.wait)||(b===this.previous&&!this.options.alwaysHide)){return this;}this.previous=b;var a={};this.elements.each(function(e,d){a[d]={};var c=(d!=b)||(this.options.alwaysHide&&(e.offsetHeight>0));this.fireEvent(c?"background":"active",[this.togglers[d],e]);for(var f in this.effects){a[d][f]=c?0:e[this.effects[f]];}},this);return this.start(a);}});
