function $RGB(a,b,c){return new Color([a,b,c],"rgb")}function $HSB(a,b,c){return new Color([a,b,c],"hsb")}function $HEX(a){return new Color(a,"hex")}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 e=2;e.times(function(e){d[e]=Fx.compute(a[e],b[e],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"),d;switch(a){case"hide":c.hide(b);break;case"show":c.show(b);break;case"toggle":var e=this.retrieve("slide:flag",c.open);c[e?"slideOut":"slideIn"](b);this.store("slide:flag",!e);d=true;break;default:c.start(a,b)}if(!d){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 e=2;e.times(function(e){d.push(Fx.compute(a[e],b[e],c))});return d},start:function(a,b){if(!this.check(arguments.callee,a,b)){return this}var c=this.element.getSize(),d=this.element.getScrollSize();var e=this.element.getScroll(),f={x:a,y:b};for(var g in f){var h=d[g]-c[g];if($chk(f[g])){f[g]=$type(f[g])=="number"?f[g].limit(0,h):h}else{f[g]=e[g]}f[g]+=this.options.offset[g]}return this.parent([e.x,e.y],[f.x,f.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 e in a){var f=a[e],g=b[e],h=d[e]={};for(var i in f){h[i]=this.parent(f[i],g[i],c)}}return d},set:function(a){for(var b in a){var c=a[b];for(var d in c){this.render(this.elements[b],d,c[d],this.options.unit)}}return this},start:function(a){if(!this.check(arguments.callee,a)){return this}var b={},c={};for(var d in a){var e=a[d],f=b[d]={},g=c[d]={};for(var h in e){var i=this.prepare(this.elements[d],h,e[h]);f[h]=i.from;g[h]=i.to}}return this.parent(b,c)}});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 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]=a.page[c]-this.value.now[c];if(b&&b[c]){for(var d=2;d--;d){if($chk(b[c][d])){this.limit[c][d]=$lambda(b[c][d])()}}}}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]a.left&&b.xa.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)}});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 a=Array.slice(arguments);var b=$type(a.getLast())=="number"?a.pop():50;var c=this.slice();a.each(function(a){a=new Color(a);for(var d=0;d<3;d++){c[d]=Math.round(c[d]/100*(100-b)+a[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")}});Array.implement({rgbToHsb:function(){var a=this[0],b=this[1],c=this[2];var d,e,f;var g=Math.max(a,b,c),h=Math.min(a,b,c);var i=g-h;f=g/255;e=g!=0?i/g:0;if(e==0){d=0}else{var j=(g-a)/i;var k=(g-b)/i;var l=(g-c)/i;if(a==g){d=l-k}else{if(b==g){d=2+j-l}else{d=4+k-j}}d/=6;if(d<0){d++}}return[Math.round(d*360),Math.round(e*100),Math.round(f*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 c=b%60;var d=Math.round(this[2]*(100-this[1])/1e4*255);var e=Math.round(this[2]*(6e3-this[1]*c)/6e5*255);var f=Math.round(this[2]*(6e3-this[1]*(60-c))/6e5*255);switch(Math.floor(b/60)){case 0:return[a,f,d];case 1:return[e,a,d];case 2:return[d,a,f];case 3:return[d,e,a];case 4:return[f,d,a];case 5:return[a,d,e]}}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 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(a){$$(a).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(a){$$(a).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(),c=window.getScroll();var d={x:this.tip.offsetWidth,y:this.tip.offsetHeight};var e={x:"left",y:"top"};for(var f in e){var g=a.page[f]+this.options.offsets[f];if(g+d[f]-c[f]>b[f]){g=a.page[f]-this.options.offsets[f]-d[f]}this.tip.setStyle(e[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)}})