view e2gallerypro/js/mootools-1.2-more.js @ 17:46fdf059b154 judyates

preparing to add google analytics
author Robert McIntyre <rlm@mit.edu>
date Mon, 11 Jul 2011 02:43:59 -0400
parents 3f6b44aa6b35
children
line wrap: on
line source
1 Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(b,a){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=$(b);this.parent(a);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(e,d,c){var b=[];var a=2;a.times(function(f){b[f]=Fx.compute(e[f],d[f],c)});return b},start:function(b,e){if(!this.check(arguments.callee,b,e)){return this}this[e||this.options.mode]();var d=this.element.getStyle(this.margin).toInt();var c=this.wrapper.getStyle(this.layout).toInt();var a=[[d,c],[0,this.offset]];var g=[[d,c],[-this.offset,0]];var f;switch(b){case"in":f=a;break;case"out":f=g;break;case"toggle":f=(this.wrapper["offset"+this.layout.capitalize()]==0)?a:g}return this.parent(f[0],f[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(b){var a=this.retrieve("slide");if(a){a.cancel()}return this.eliminate("slide").store("slide:options",$extend({link:"cancel"},b))},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(d,e){d=d||"toggle";var b=this.get("slide"),a;switch(d){case"hide":b.hide(e);break;case"show":b.show(e);break;case"toggle":var c=this.retrieve("slide:flag",b.open);b[(c)?"slideOut":"slideIn"](e);this.store("slide:flag",!c);a=true;break;default:b.start(d,e)}if(!a){this.eliminate("slide:flag")}return this}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(b,a){this.element=this.subject=$(b);this.parent(a);var d=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=$(this.element.getDocument().body)}var c=this.element;if(this.options.wheelStops){this.addEvent("start",function(){c.addEvent("mousewheel",d)},true);this.addEvent("complete",function(){c.removeEvent("mousewheel",d)},true)}},set:function(){var a=Array.flatten(arguments);this.element.scrollTo(a[0],a[1])},compute:function(e,d,c){var b=[];var a=2;a.times(function(f){b.push(Fx.compute(e[f],d[f],c))});return b},start:function(c,h){if(!this.check(arguments.callee,c,h)){return this}var e=this.element.getSize(),f=this.element.getScrollSize();var b=this.element.getScroll(),d={x:c,y:h};for(var g in d){var a=f[g]-e[g];if($chk(d[g])){d[g]=($type(d[g])=="number")?d[g].limit(0,a):a}else{d[g]=b[g]}d[g]+=this.options.offset[g]}return this.parent([b.x,b.y],[d.x,d.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(b,a){this.elements=this.subject=$$(b);this.parent(a)},compute:function(g,h,j){var c={};for(var d in g){var a=g[d],e=h[d],f=c[d]={};for(var b in a){f[b]=this.parent(a[b],e[b],j)}}return c},set:function(b){for(var c in b){var a=b[c];for(var d in a){this.render(this.elements[c],d,a[d],this.options.unit)}}return this},start:function(c){if(!this.check(arguments.callee,c)){return this}var h={},j={};for(var d in c){var f=c[d],a=h[d]={},g=j[d]={};for(var b in f){var e=this.prepare(this.elements[d],b,f[b]);a[b]=e.from;g[b]=e.to}}return this.parent(h,j)}});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 b=Array.link(arguments,{options:Object.type,element:$defined});this.element=$(b.element);this.document=this.element.getDocument();this.setOptions(b.options||{});var a=$type(this.options.handle);this.handles=(a=="array"||a=="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(c){if(this.options.preventDefault){c.preventDefault()}this.fireEvent("beforeStart",this.element);this.mouse.start=c.page;var a=this.options.limit;this.limit={x:[],y:[]};for(var d in this.options.modifiers){if(!this.options.modifiers[d]){continue}if(this.options.style){this.value.now[d]=this.element.getStyle(this.options.modifiers[d]).toInt()}else{this.value.now[d]=this.element[this.options.modifiers[d]]}if(this.options.invert){this.value.now[d]*=-1}this.mouse.pos[d]=c.page[d]-this.value.now[d];if(a&&a[d]){for(var b=2;b--;b){if($chk(a[d][b])){this.limit[d][b]=$lambda(a[d][b])()}}}}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(c,b){this.parent(c,b);this.droppables=$$(this.options.droppables);this.container=$(this.options.container);if(this.container&&$type(this.container)!="element"){this.container=$(this.container.getDocument().body)}c=this.element;var d=c.getStyle("position");var a=(d!="static")?d:"absolute";if(c.getStyle("left")=="auto"||c.getStyle("top")=="auto"){c.position(c.getPosition(c.offsetParent))}c.setStyle("position",a);this.addEvent("start",function(){this.checkDroppables()},true)},start:function(b){if(this.container){var d=this.element,j=this.container,e=j.getCoordinates(d.offsetParent),f={},a={};["top","right","bottom","left"].each(function(k){f[k]=j.getStyle("padding-"+k).toInt();a[k]=d.getStyle("margin-"+k).toInt()},this);var c=d.offsetWidth+a.left+a.right,i=d.offsetHeight+a.top+a.bottom;var h=[e.left+f.left,e.right-f.right-c];var g=[e.top+f.top,e.bottom-f.bottom-i];this.options.limit={x:h,y:g}}this.parent(b)},checkAgainst:function(b){b=b.getCoordinates();var a=this.mouse.now;return(a.x>b.left&&a.x<b.right&&a.y<b.bottom&&a.y>b.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(c,b){a[b]=function(){var d=c.apply(this.hash,arguments);if(this.options.autoSave){this.save()}return d}});return a})());var Color=new Native({initialize:function(b,c){if(arguments.length>=3){c="rgb";b=Array.slice(arguments,0,3)}else{if(typeof b=="string"){if(b.match(/rgb/)){b=b.rgbToHex().hexToRgb(true)}else{if(b.match(/hsb/)){b=b.hsbToRgb()}else{b=b.hexToRgb(true)}}}}c=c||"rgb";switch(c){case"hsb":var a=b;b=b.hsbToRgb();b.hsb=a;break;case"hex":b=b.hexToRgb(true);break}b.rgb=b.slice(0,3);b.hsb=b.hsb||b.rgbToHsb();b.hex=b.rgbToHex();return $extend(b,this)}});Color.implement({mix:function(){var a=Array.slice(arguments);var c=($type(a.getLast())=="number")?a.pop():50;var b=this.slice();a.each(function(d){d=new Color(d);for(var e=0;e<3;e++){b[e]=Math.round((b[e]/100*(100-c))+(d[e]/100*c))}});return new Color(b,"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,c,a){return new Color([d,c,a],"hsb")}function $HEX(a){return new Color(a,"hex")}Array.implement({rgbToHsb:function(){var b=this[0],c=this[1],j=this[2];var g,f,h;var i=Math.max(b,c,j),e=Math.min(b,c,j);var k=i-e;h=i/255;f=(i!=0)?k/i:0;if(f==0){g=0}else{var d=(i-b)/k;var a=(i-c)/k;var l=(i-j)/k;if(b==i){g=l-a}else{if(c==i){g=2+d-l}else{g=4+a-d}}g/=6;if(g<0){g++}}return[Math.round(g*360),Math.round(f*100),Math.round(h*100)]},hsbToRgb:function(){var c=Math.round(this[2]/100*255);if(this[1]==0){return[c,c,c]}else{var a=this[0]%360;var e=a%60;var g=Math.round((this[2]*(100-this[1]))/10000*255);var d=Math.round((this[2]*(6000-this[1]*e))/600000*255);var b=Math.round((this[2]*(6000-this[1]*(60-e)))/600000*255);switch(Math.floor(a/60)){case 0:return[c,b,g];case 1:return[d,c,g];case 2:return[g,c,b];case 3:return[g,d,c];case 4:return[b,g,c];case 5:return[c,g,d]}}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(c,d){c.addEvent(b,this.check.bind(this,[b,c,d]))},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(f,d){d=$extend({onload:$empty,document:document,check:$lambda(true)},d);var b=new Element("script",{src:f,type:"text/javascript"});var e=d.onload.bind(b),a=d.check,g=d.document;delete d.onload;delete d.check;delete d.document;b.addEvents({load:e,readystatechange:function(){if(["loaded","complete"].contains(this.readyState)){e()}}}).setProperties(d);if(Browser.Engine.webkit419){var c=(function(){if(!$try(a)){return}$clear(c);e()}).periodical(50)}return b.inject(g.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(c,b){b=$merge({onload:$empty,onabort:$empty,onerror:$empty},b);var d=new Image();var a=$(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(!a.parentNode){a.width=d.width;a.height=d.height}d=d.onload=d.onabort=d.onerror=null;g.delay(1,a,a);a.fireEvent(e,a,1)}});d.src=a.src=c;if(d&&d.complete){d.onload.delay(1)}return a.setProperties(b)},images:function(d,c){c=$merge({onComplete:$empty,onProgress:$empty},c);if(!d.push){d=[d]}var a=[];var b=0;d.each(function(f){var e=new Asset.image(f,{onload:function(){c.onProgress.call(this,b,d.indexOf(f));b++;if(b==d.length){c.onComplete()}}});a.push(e)});return new Elements(a)}});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 a=[];Array.flatten(arguments).each(function(b){a.push(b);this.elements.erase(b);var c=b.retrieve("sortables:start");(this.options.handle?b.getElement(this.options.handle)||b:b).removeEvent("mousedown",c)},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(b,a){if(!this.options.clone){return new Element("div").inject(document.body)}if($type(this.options.clone)=="function"){return this.options.clone.call(this,b,a,this.list)}return a.clone(true).setStyles({margin:"0px",position:"absolute",visibility:"hidden",width:a.getStyle("width")}).inject(this.list).position(a.getPosition(a.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(c,b){var a="inside";if(this.lists.contains(b)){this.list=b;this.drag.droppables=this.getDroppables()}else{a=this.element.getAllPrevious().contains(b)?"before":"after"}this.element.inject(b,a);this.fireEvent("sort",[this.element,this.clone])},start:function(b,a){if(!this.idle){return}this.idle=false;this.element=a;this.opacity=a.get("opacity");this.list=a.getParent();this.clone=this.getClone(b,a);this.drag=new Drag.Move(this.clone,{snap:this.options.snap,container:this.options.constrain&&this.element.getParent(),droppables:this.getDroppables(),onSnap:function(){b.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(b)},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 b=this.lists.map(function(d){return d.getChildren().map(c.modifier||function(e){return e.get("id")},this)},this);var a=c.index;if(this.lists.length==1){a=0}return $chk(a)&&a>=0&&a<this.lists.length?b[a]:b}});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 c=Array.link(arguments,{options:Object.type,elements:$defined});this.setOptions(c.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 a=new Element("div",{"class":"tip-bottom"}).inject(this.tip);this.tip.setStyles({position:"absolute",top:0,left:0,visibility:"hidden"});if(c.elements){this.attach(c.elements)}},attach:function(a){$$(a).each(function(d){var g=d.retrieve("tip:title",d.get("title"));var f=d.retrieve("tip:text",d.get("rel")||d.get("href"));var e=d.retrieve("tip:enter",this.elementEnter.bindWithEvent(this,d));var c=d.retrieve("tip:leave",this.elementLeave.bindWithEvent(this,d));d.addEvents({mouseenter:e,mouseleave:c});if(!this.options.fixed){var b=d.retrieve("tip:move",this.elementMove.bindWithEvent(this,d));d.addEvent("mousemove",b)}d.store("tip:native",d.get("title"));d.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(b,a){$A(this.container.childNodes).each(Element.dispose);var d=a.retrieve("tip:title");if(d){this.titleElement=new Element("div",{"class":"tip-title"}).inject(this.container);this.fill(this.titleElement,d)}var c=a.retrieve("tip:text");if(c){this.textElement=new Element("div",{"class":"tip-text"}).inject(this.container);this.fill(this.textElement,c)}this.timer=$clear(this.timer);this.timer=this.show.delay(this.options.showDelay,this);this.position((!this.options.fixed)?b:{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(d){var b=window.getSize(),a=window.getScroll();var e={x:this.tip.offsetWidth,y:this.tip.offsetHeight};var c={x:"left",y:"top"};for(var f in c){var g=d.page[f]+this.options.offsets[f];if((g+e[f]-a[f])>b[f]){g=d.page[f]-this.options.offsets[f]-e[f]}this.tip.setStyle(c[f],g)}},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(b,c){c=c||document;var e=c.getDocument(),d=c.getWindow();this.parent(e,b);this.links=(this.options.links)?$$(this.options.links):$$(e.links);var a=d.location.href.match(/^[^#]*/)[0]+"#";this.links.each(function(g){if(g.href.indexOf(a)!=0){return}var f=g.href.substr(a.length);if(f&&$(f)){this.useLink(g,f)}},this);if(!Browser.Engine.webkit419){this.addEvent("complete",function(){d.location.hash=this.anchor},true)}},useLink:function(b,a){b.addEvent("click",function(c){this.anchor=a;this.toElement(a);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(e,a,d){this.setOptions(d);this.element=$(e);this.knob=$(a);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 f,b={},c={x:false,y:false};switch(this.options.mode){case"vertical":this.axis="y";this.property="top";f="offsetHeight";break;case"horizontal":this.axis="x";this.property="left";f="offsetWidth"}this.half=this.knob[f]/2;this.full=this.element[f]-this.knob[f]+(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;b[this.axis]=[-this.options.offset,this.full-this.options.offset];this.drag=new Drag(this.knob,{snap:0,limit:b,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 b=this.range<0?-1:1;var a=c.page[this.axis]-this.element.getPosition()[this.axis]-this.half;a=a.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+b*this.toStep(a));this.checkStep();this.end();this.fireEvent("tick",a)},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 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 b=this.element.getSize(),a=this.element.getScroll(),e=this.element.getPosition(),d={x:0,y:0};for(var c in this.page){if(this.page[c]<(this.options.area+e[c])&&a[c]!=0){d[c]=(this.page[c]-this.options.area-e[c])*this.options.velocity}else{if(this.page[c]+this.options.area>(b[c]+e[c])&&b[c]+b[c]!=a[c]){d[c]=(this.page[c]-b[c]+this.options.area-e[c])*this.options.velocity}}}if(d.y||d.x){this.fireEvent("change",[a.x+d.x,a.y+d.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 b=0,a=this.togglers.length;b<a;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(e,c,g){e=$(e);c=$(c);var f=this.togglers.contains(e);var b=this.togglers.length;this.togglers.include(e);this.elements.include(c);if(b&&(!f||g)){g=$pick(g,b-1);e.inject(this.togglers[g],"before");c.inject(e,"after")}else{if(this.container&&!f){e.inject(this.container);c.inject(this.container)}}var a=this.togglers.indexOf(e);e.addEvent("click",this.display.bind(this,a));if(this.options.height){c.setStyles({"padding-top":0,"border-top":"none","padding-bottom":0,"border-bottom":"none"})}if(this.options.width){c.setStyles({"padding-left":0,"border-left":"none","padding-right":0,"border-right":"none"})}c.fullOpacity=1;if(this.options.fixedWidth){c.fullWidth=this.options.fixedWidth}if(this.options.fixedHeight){c.fullHeight=this.options.fixedHeight}c.setStyle("overflow","hidden");if(!f){for(var d in this.effects){c.setStyle(d,0)}}return this},display:function(a){a=($type(a)=="element")?this.elements.indexOf(a):a;if((this.timer&&this.options.wait)||(a===this.previous&&!this.options.alwaysHide)){return this}this.previous=a;var b={};this.elements.each(function(e,d){b[d]={};var c=(d!=a)||(this.options.alwaysHide&&(e.offsetHeight>0));this.fireEvent(c?"background":"active",[this.togglers[d],e]);for(var f in this.effects){b[d][f]=c?0:e[this.effects[f]]}},this);return this.start(b)}});