//// JavaScript Document //MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. var MooTools={version:"1.2.0",build:""};var Native=function(J){J=J||{};var F=J.afterImplement||function(){};var G=J.generics;G=(G!==false);var H=J.legacy; var E=J.initialize;var B=J.protect;var A=J.name;var C=E||H;C.constructor=Native;C.$family={name:"native"};if(H&&E){C.prototype=H.prototype;}C.prototype.constructor=C; if(A){var D=A.toLowerCase();C.prototype.$family={name:D};Native.typize(C,D);}var I=function(M,K,N,L){if(!B||L||!M.prototype[K]){M.prototype[K]=N;}if(G){Native.genericize(M,K,B); }F.call(M,K,N);return M;};C.implement=function(L,K,N){if(typeof L=="string"){return I(this,L,K,N);}for(var M in L){I(this,M,L[M],K);}return this;};C.alias=function(M,K,N){if(typeof M=="string"){M=this.prototype[M]; if(M){I(this,K,M,N);}}else{for(var L in M){this.alias(L,M[L],K);}}return this;};return C;};Native.implement=function(D,C){for(var B=0,A=D.length;B-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); },camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase()); });},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); },toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A=""; var C=this.replace(/]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C); }}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:""; });}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null; },hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C); },this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null; },set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this); return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this)); },this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false; }}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[]; Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[]; Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H; });D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type; var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111; if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body; var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY}; if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement; break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false; }}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey}); }});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); },stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); }else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(E){for(var D in this){this[D]=$unlink(this[D]); }for(var F in Class.Mutators){if(!this[F]){continue;}Class.Mutators[F](this,this[F]);delete this[F];}this.constructor=A;if(E===$empty){return this;}var C=(this.initialize)?this.initialize.apply(this,arguments):this; if(this.options&&this.options.initialize){this.options.initialize.call(this);}return C;};$extend(A,this);A.constructor=Class;A.prototype=B;return A;}}); Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Mutators={Implements:function(A,B){$splat(B).each(function(C){$extend(A,($type(C)=="class")?new C($empty):C); });},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key]; if(current==undefined){self[key]=previous;continue;}var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype){continue;}switch(ctype){case"function":if(!arguments.callee.caller){self[key]=eval("("+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return"arguments.callee._parent_.call(this"+(close||", "); })+")");}self[key]._parent_=previous;break;case"object":self[key]=$merge(previous,current);}}self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments); };self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1));};}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments); return this;},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){if(this.$chain){this.$chain.empty(); }return this;}});var Events=new Class({addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events=this.$events||{};this.$events[C]=this.$events[C]||[]; this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C); if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B); if(!this.$events||!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){for(var D in this.$events){if(C&&C!=D){continue; }var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);}}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase(); });};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue; }this.addEvent(A,this.options[A]);delete this.options[A];}return this;}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ; }A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); },getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;},purge:function(){var C=this.getElementsByTagName("*"); for(var B=0,A=C.length;B1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D}); }});Element.Storage={get:function(A){return(this[A]||(this[A]={}));}};Element.Inserters=new Hash({before:function(B,A){if(A.parentNode){A.parentNode.insertBefore(B,A); }},after:function(B,A){if(!A.parentNode){return ;}var C=A.nextSibling;(C)?A.parentNode.insertBefore(B,C):A.parentNode.appendChild(B);},bottom:function(B,A){A.appendChild(B); },top:function(B,A){var C=A.firstChild;(C)?A.insertBefore(B,C):A.appendChild(B);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(C,B){var A=B.capitalize(); Element.implement("inject"+A,function(D){C(this,$(D,true));return this;});Element.implement("grab"+A,function(D){C($(D,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument; },getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(D,C){var B=this.ownerDocument.getElementById(D);if(!B){return null; }for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return null;}}return $.element(B,C);},set:function(D,B){switch($type(D)){case"object":for(var C in D){this.set(C,D[C]); }break;case"string":var A=Element.Properties.get(D);(A&&A.set)?A.set.apply(this,Array.slice(arguments,1)):this.setProperty(D,B);}return this;},get:function(B){var A=Element.Properties.get(B); return(A&&A.get)?A.get.apply(this,Array.slice(arguments,1)):this.getProperty(B);},erase:function(B){var A=Element.Properties.get(B);(A&&A.erase)?A.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(B); return this;},match:function(A){return(!A||Element.get(this,"tag")==A);},inject:function(B,A){Element.Inserters.get(A||"bottom")(this,$(B,true));return this; },wraps:function(B,A){B=$(B,true);return this.replaces(B).grab(B,A);},grab:function(B,A){Element.Inserters.get(A||"bottom")($(B,true),this);return this; },appendText:function(B,A){return this.grab(this.getDocument().newTextNode(B),A);},adopt:function(){Array.flatten(arguments).each(function(A){A=$(A,true); if(A){this.appendChild(A);}},this);return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},clone:function(D,C){switch($type(this)){case"element":var H={}; for(var G=0,E=this.attributes.length;G1),cash:!G});}});Element.implement({match:function(B){if(!B){return true;}var D=Selectors.Utils.parseTagAndID(B); var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B);return(C)?Selectors.Utils.filter(this,C,{}):true; }});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F]; }var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0; if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"}; break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"}; break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E]; }var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[4],C=D[5],J=D[6];if(I){H.classes.push(I); }else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B}); }}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null; }return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false]; },filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length; D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D]; if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true); return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(J,I,O){var B=[];var C=I.trim().replace(Selectors.RegExps.splitter,function(Z,Y,X){B.push(Y); return":)"+X;}).split(":)");var K,F,E,V;for(var U=0,Q=C.length;U":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;EA){return false; }}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A);},odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A); }});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this);}}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true; window.fireEvent("domready");document.fireEvent("domready");};switch(Browser.Engine.name){case"webkit":(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); })();break;case"trident":var A=document.createElement("div");(function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose(); }))?B():arguments.callee.delay(50);})();break;default:window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}})();var JSON=new Hash({encode:function(B){switch($type(B)){case"string":return'"'+B.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"'; case"array":return"["+String(B.map(JSON.encode).filter($defined))+"]";case"object":case"hash":var A=[];Hash.each(B,function(E,D){var C=JSON.encode(E);if(C){A.push(JSON.encode(D)+":"+C); }});return"{"+A+"}";case"number":case"boolean":return String(B);case false:return"null";}return null;},$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(A){return JSON.$specialChars[A]||"\\u00"+Math.floor(A.charCodeAt()/16).toString(16)+(A.charCodeAt()%16).toString(16); },decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; }return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B; this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path; }if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure"; }this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C); };Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:"high",allowScriptAccess:"always",wMode:"transparent",swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object; },initialize:function(L,M){this.instance="Swiff_"+$time();this.setOptions(M);M=this.options;var B=this.id=M.id||this.instance;var A=$(M.container);Swiff.CallBacks[this.instance]={}; var E=M.params,G=M.vars,F=M.callBacks;var H=$extend({height:M.height,width:M.width},M.properties);var K=this;for(var D in F){Swiff.CallBacks[this.instance][D]=(function(N){return function(){return N.apply(K.object,arguments); };})(F[D]);G[D]="Swiff.CallBacks."+this.instance+"."+D;}E.flashVars=Hash.toQueryString(G);if(Browser.Engine.trident){H.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; E.movie=L;}else{H.type="application/x-shockwave-flash";H.data=L;}var J=''; }}J+="";this.object=((A)?A.empty():new Element("div")).set("html",J).firstChild;},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this.toElement(),A); return this;},inject:function(A){$(A,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments)); }});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction(''+__flash__argumentsToXML(arguments,2)+""); return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore",transition:function(A){return -(Math.cos(Math.PI*A)-1)/2; }},initialize:function(A){this.subject=this.subject||this;this.setOptions(A);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt(); var B=this.options.wait;if(B===false){this.options.link="cancel";}},step:function(){var A=$time();if(A=(7-4*B)/11){C=-Math.pow((11-6*B-11*D)/4,2)+A*A; break;}}return C;},Elastic:function(B,A){return Math.pow(2,10*--B)*Math.cos(20*B*Math.PI*(A[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(B,A){Fx.Transitions[B]=new Fx.Transition(function(C){return Math.pow(C,[A+2]); });});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request(); this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ; }this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); },processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts); },success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); },failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B); return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true; }switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false; },send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options; I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E); }if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A; E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C); }if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); this.headers.each(function(K,J){if(!$try(function(){this.xhr.setRequestHeader(J,K);return true;}.bind(this))){this.fireEvent("exception",[J,K]);}},this); this.fireEvent("request");this.xhr.send(E);if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this; }this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={}; ["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined}); return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send"); if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A)); },get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options"))); }return this.retrieve("send");}};Element.implement({send:function(A){var B=this.get("send");B.send({data:this,url:A||B.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(C){var B=C.match(/]*>([\s\S]*?)<\/body>/i); C=(B)?B[1]:C;var A=new Element("div");return $try(function(){var D=""+C+"",G;if(Browser.Engine.trident){G=new ActiveXObject("Microsoft.XMLDOM"); G.async=false;G.loadXML(D);}else{G=new DOMParser().parseFromString(D,"text/xml");}D=G.getElementsByTagName("root")[0];for(var F=0,E=D.childNodes.length; F. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. Fx.Slide=new Class({Extends:Fx,options:{mode:'vertical'},initialize:function(element,options){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=$(element);this.parent(options);var wrapper=this.element.retrieve('wrapper');this.wrapper=wrapper||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(now){this.element.setStyle(this.margin,now[0]);this.wrapper.setStyle(this.layout,now[1]);return this;},compute:function(from,to,delta){var now=[];var x=2;x.times(function(i){now[i]=Fx.compute(from[i],to[i],delta);});return now;},start:function(how,mode){if(!this.check(arguments.callee,how,mode))return this;this[mode||this.options.mode]();var margin=this.element.getStyle(this.margin).toInt();var layout=this.wrapper.getStyle(this.layout).toInt();var caseIn=[[margin,layout],[0,this.offset]];var caseOut=[[margin,layout],[-this.offset,0]];var start;switch(how){case'in':start=caseIn;break;case'out':start=caseOut;break;case'toggle':start=(this.wrapper['offset'+this.layout.capitalize()]==0)?caseIn:caseOut;} return this.parent(start[0],start[1]);},slideIn:function(mode){return this.start('in',mode);},slideOut:function(mode){return this.start('out',mode);},hide:function(mode){this[mode||this.options.mode]();this.open=false;return this.set([-this.offset,0]);},show:function(mode){this[mode||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(mode){return this.start('toggle',mode);}});Element.Properties.slide={set:function(options){var slide=this.retrieve('slide');if(slide)slide.cancel();return this.eliminate('slide').store('slide:options',$extend({link:'cancel'},options));},get:function(options){if(options||!this.retrieve('slide')){if(options||!this.retrieve('slide:options'))this.set('slide',options);this.store('slide',new Fx.Slide(this,this.retrieve('slide:options')));} return this.retrieve('slide');}};Element.implement({slide:function(how,mode){how=how||'toggle';var slide=this.get('slide'),toggle;switch(how){case'hide':slide.hide(mode);break;case'show':slide.show(mode);break;case'toggle':var flag=this.retrieve('slide:flag',slide.open);slide[(flag)?'slideOut':'slideIn'](mode);this.store('slide:flag',!flag);toggle=true;break;default:slide.start(how,mode);} if(!toggle)this.eliminate('slide:flag');return this;}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{'x':0,'y':0},wheelStops:true},initialize:function(element,options){this.element=this.subject=$(element);this.parent(options);var cancel=this.cancel.bind(this,false);if($type(this.element)!='element')this.element=$(this.element.getDocument().body);var stopper=this.element;if(this.options.wheelStops){this.addEvent('start',function(){stopper.addEvent('mousewheel',cancel);},true);this.addEvent('complete',function(){stopper.removeEvent('mousewheel',cancel);},true);}},set:function(){var now=Array.flatten(arguments);this.element.scrollTo(now[0],now[1]);},compute:function(from,to,delta){var now=[];var x=2;x.times(function(i){now.push(Fx.compute(from[i],to[i],delta));});return now;},start:function(x,y){if(!this.check(arguments.callee,x,y))return this;var offsetSize=this.element.getSize(),scrollSize=this.element.getScrollSize();var scroll=this.element.getScroll(),values={x:x,y:y};for(var z in values){var max=scrollSize[z]-offsetSize[z];if($chk(values[z]))values[z]=($type(values[z])=='number')?values[z].limit(0,max):max;else values[z]=scroll[z];values[z]+=this.options.offset[z];} return this.parent([scroll.x,scroll.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(el){var position=$(el).getPosition(this.element);return this.start(position.x,position.y);}});Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(elements,options){this.elements=this.subject=$$(elements);this.parent(options);},compute:function(from,to,delta){var now={};for(var i in from){var iFrom=from[i],iTo=to[i],iNow=now[i]={};for(var p in iFrom)iNow[p]=this.parent(iFrom[p],iTo[p],delta);} return now;},set:function(now){for(var i in now){var iNow=now[i];for(var p in iNow)this.render(this.elements[i],p,iNow[p],this.options.unit);} return this;},start:function(obj){if(!this.check(arguments.callee,obj))return this;var from={},to={};for(var i in obj){var iProps=obj[i],iFrom=from[i]={},iTo=to[i]={};for(var p in iProps){var parsed=this.prepare(this.elements[i],p,iProps[p]);iFrom[p]=parsed.from;iTo[p]=parsed.to;}} return this.parent(from,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 params=Array.link(arguments,{'options':Object.type,'element':$defined});this.element=$(params.element);this.document=this.element.getDocument();this.setOptions(params.options||{});var htype=$type(this.options.handle);this.handles=(htype=='array'||htype=='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(event){if(this.options.preventDefault)event.preventDefault();this.fireEvent('beforeStart',this.element);this.mouse.start=event.page;var limit=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]=event.page[z]-this.value.now[z];if(limit&&limit[z]){for(var i=2;i--;i){if($chk(limit[z][i]))this.limit[z][i]=$lambda(limit[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(event){if(this.options.preventDefault)event.preventDefault();var distance=Math.round(Math.sqrt(Math.pow(event.page.x-this.mouse.start.x,2)+Math.pow(event.page.y-this.mouse.start.y,2)));if(distance>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(event){if(this.options.preventDefault)event.preventDefault();this.mouse.now=event.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]el.left&&now.xel.top);},checkDroppables:function(){var overed=this.droppables.filter(this.checkAgainst,this).getLast();if(this.overed!=overed){if(this.overed)this.fireEvent('leave',[this.element,this.overed]);if(overed){this.overed=overed;this.fireEvent('enter',[this.element,overed]);}else{this.overed=null;}}},drag:function(event){this.parent(event);if(this.droppables.length)this.checkDroppables();},stop:function(event){this.checkDroppables();this.fireEvent('drop',[this.element,this.overed]);this.overed=null;return this.parent(event);}});Element.implement({makeDraggable:function(options){return new Drag.Move(this,options);}});Hash.Cookie=new Class({Extends:Cookie,options:{autoSave:true},initialize:function(name,options){this.parent(name,options);this.load();},save:function(){var value=JSON.encode(this.hash);if(!value||value.length>4096)return false;if(value=='{}')this.dispose();else this.write(value);return true;},load:function(){this.hash=new Hash(JSON.decode(this.read(),true));return this;}});Hash.Cookie.implement((function(){var methods={};Hash.each(Hash.prototype,function(method,name){methods[name]=function(){var value=method.apply(this.hash,arguments);if(this.options.autoSave)this.save();return value;};});return methods;})());var Color=new Native({initialize:function(color,type){if(arguments.length>=3){type="rgb";color=Array.slice(arguments,0,3);}else if(typeof color=='string'){if(color.match(/rgb/))color=color.rgbToHex().hexToRgb(true);else if(color.match(/hsb/))color=color.hsbToRgb();else color=color.hexToRgb(true);} type=type||'rgb';switch(type){case'hsb':var old=color;color=color.hsbToRgb();color.hsb=old;break;case'hex':color=color.hexToRgb(true);break;} color.rgb=color.slice(0,3);color.hsb=color.hsb||color.rgbToHsb();color.hex=color.rgbToHex();return $extend(color,this);}});Color.implement({mix:function(){var colors=Array.slice(arguments);var alpha=($type(colors.getLast())=='number')?colors.pop():50;var rgb=this.slice();colors.each(function(color){color=new Color(color);for(var i=0;i<3;i++)rgb[i]=Math.round((rgb[i]/100*(100-alpha))+(color[i]/100*alpha));});return new Color(rgb,'rgb');},invert:function(){return new Color(this.map(function(value){return 255-value;}));},setHue:function(value){return new Color([value,this.hsb[1],this.hsb[2]],'hsb');},setSaturation:function(percent){return new Color([this.hsb[0],percent,this.hsb[2]],'hsb');},setBrightness:function(percent){return new Color([this.hsb[0],this.hsb[1],percent],'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(hex){return new Color(hex,'hex');};Array.implement({rgbToHsb:function(){var red=this[0],green=this[1],blue=this[2];var hue,saturation,brightness;var max=Math.max(red,green,blue),min=Math.min(red,green,blue);var delta=max-min;brightness=max/255;saturation=(max!=0)?delta/max:0;if(saturation==0){hue=0;}else{var rr=(max-red)/delta;var gr=(max-green)/delta;var br=(max-blue)/delta;if(red==max)hue=br-gr;else if(green==max)hue=2+rr-br;else hue=4+gr-rr;hue/=6;if(hue<0)hue++;} return[Math.round(hue*360),Math.round(saturation*100),Math.round(brightness*100)];},hsbToRgb:function(){var br=Math.round(this[2]/100*255);if(this[1]==0){return[br,br,br];}else{var hue=this[0]%360;var f=hue%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(hue/60)){case 0:return[br,t,p];case 1:return[q,br,p];case 2:return[p,br,t];case 3:return[p,q,br];case 4:return[t,p,br];case 5:return[br,p,q];}} return false;}});String.implement({rgbToHsb:function(){var rgb=this.match(/\d{1,3}/g);return(rgb)?hsb.rgbToHsb():null;},hsbToRgb:function(){var hsb=this.match(/\d{1,3}/g);return(hsb)?hsb.hsbToRgb():null;}});var Group=new Class({initialize:function(){this.instances=Array.flatten(arguments);this.events={};this.checker={};},addEvent:function(type,fn){this.checker[type]=this.checker[type]||{};this.events[type]=this.events[type]||[];if(this.events[type].contains(fn))return false;else this.events[type].push(fn);this.instances.each(function(instance,i){instance.addEvent(type,this.check.bind(this,[type,instance,i]));},this);return this;},check:function(type,instance,i){this.checker[type][i]=true;var every=this.instances.every(function(current,j){return this.checker[type][j]||false;},this);if(!every)return;this.checker[type]={};this.events[type].each(function(event){event.call(this,this.instances,instance);},this);}});var Asset=new Hash({javascript:function(source,properties){properties=$extend({onload:$empty,document:document,check:$lambda(true)},properties);var script=new Element('script',{'src':source,'type':'text/javascript'});var load=properties.onload.bind(script),check=properties.check,doc=properties.document;delete properties.onload;delete properties.check;delete properties.document;script.addEvents({load:load,readystatechange:function(){if(['loaded','complete'].contains(this.readyState))load();}}).setProperties(properties);if(Browser.Engine.webkit419)var checker=(function(){if(!$try(check))return;$clear(checker);load();}).periodical(50);return script.inject(doc.head);},css:function(source,properties){return new Element('link',$merge({'rel':'stylesheet','media':'screen','type':'text/css','href':source},properties)).inject(document.head);},image:function(source,properties){properties=$merge({'onload':$empty,'onabort':$empty,'onerror':$empty},properties);var image=new Image();var element=$(image)||new Element('img');['load','abort','error'].each(function(name){var type='on'+name;var event=properties[type];delete properties[type];image[type]=function(){if(!image)return;if(!element.parentNode){element.width=image.width;element.height=image.height;} image=image.onload=image.onabort=image.onerror=null;event.delay(1,element,element);element.fireEvent(name,element,1);};});image.src=element.src=source;if(image&&image.complete)image.onload.delay(1);return element.setProperties(properties);},images:function(sources,options){options=$merge({onComplete:$empty,onProgress:$empty},options);if(!sources.push)sources=[sources];var images=[];var counter=0;sources.each(function(source){var img=new Asset.image(source,{'onload':function(){options.onProgress.call(this,counter,sources.indexOf(source));counter++;if(counter==sources.length)options.onComplete();}});images.push(img);});return new Elements(images);}});var Sortables=new Class({Implements:[Events,Options],options:{snap:4,opacity:1,clone:false,revert:false,handle:false,constrain:false},initialize:function(lists,options){this.setOptions(options);this.elements=[];this.lists=[];this.idle=true;this.addLists($$($(lists)||lists));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(element){this.elements.push(element);var start=element.retrieve('sortables:start',this.start.bindWithEvent(this,element));(this.options.handle?element.getElement(this.options.handle)||element:element).addEvent('mousedown',start);},this);return this;},addLists:function(){Array.flatten(arguments).each(function(list){this.lists.push(list);this.addItems(list.getChildren());},this);return this;},removeItems:function(){var elements=[];Array.flatten(arguments).each(function(element){elements.push(element);this.elements.erase(element);var start=element.retrieve('sortables:start');(this.options.handle?element.getElement(this.options.handle)||element:element).removeEvent('mousedown',start);},this);return $$(elements);},removeLists:function(){var lists=[];Array.flatten(arguments).each(function(list){lists.push(list);this.lists.erase(list);this.removeItems(list.getChildren());},this);return $$(lists);},getClone:function(event,element){if(!this.options.clone)return new Element('div').inject(document.body);if($type(this.options.clone)=='function')return this.options.clone.call(this,event,element,this.list);return element.clone(true).setStyles({'margin':'0px','position':'absolute','visibility':'hidden','width':element.getStyle('width')}).inject(this.list).position(element.getPosition(element.getOffsetParent()));},getDroppables:function(){var droppables=this.list.getChildren();if(!this.options.constrain)droppables=this.lists.concat(droppables).erase(this.list);return droppables.erase(this.clone).erase(this.element);},insert:function(dragging,element){var where='inside';if(this.lists.contains(element)){this.list=element;this.drag.droppables=this.getDroppables();}else{where=this.element.getAllPrevious().contains(element)?'before':'after';} this.element.inject(element,where);this.fireEvent('sort',[this.element,this.clone]);},start:function(event,element){if(!this.idle)return;this.idle=false;this.element=element;this.opacity=element.get('opacity');this.list=element.getParent();this.clone=this.getClone(event,element);this.drag=new Drag.Move(this.clone,{snap:this.options.snap,container:this.options.constrain&&this.element.getParent(),droppables:this.getDroppables(),onSnap:function(){event.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(event);},end:function(){this.drag.detach();this.element.set('opacity',this.opacity);if(this.effect){var dim=this.element.getStyles('width','height');var pos=this.clone.computePosition(this.element.getPosition(this.clone.offsetParent));this.effect.element=this.clone;this.effect.start({top:pos.top,left:pos.left,width:dim.width,height:dim.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 params=Array.link(arguments,{modifier:Function.type,index:$defined});var serial=this.lists.map(function(list){return list.getChildren().map(params.modifier||function(element){return element.get('id');},this);},this);var index=params.index;if(this.lists.length==1)index=0;return $chk(index)&&index>=0&&indexsize[z])pos=event.page[z]-this.options.offsets[z]-tip[z];this.tip.setStyle(props[z],pos);}},fill:function(element,contents){(typeof contents=='string')?element.set('html',contents):element.adopt(contents);},show:function(){this.fireEvent('show',this.tip);},hide:function(){this.fireEvent('hide',this.tip);}});var SmoothScroll=new Class({Extends:Fx.Scroll,initialize:function(options,context){context=context||document;var doc=context.getDocument(),win=context.getWindow();this.parent(doc,options);this.links=(this.options.links)?$$(this.options.links):$$(doc.links);var location=win.location.href.match(/^[^#]*/)[0]+'#';this.links.each(function(link){if(link.href.indexOf(location)!=0)return;var anchor=link.href.substr(location.length);if(anchor&&$(anchor))this.useLink(link,anchor);},this);if(!Browser.Engine.webkit419)this.addEvent('complete',function(){win.location.hash=this.anchor;},true);},useLink:function(link,anchor){link.addEvent('click',function(event){this.anchor=anchor;this.toElement(anchor);event.stop();}.bind(this));}});var Slider=new Class({Implements:[Events,Options],options:{onTick:function(position){if(this.options.snap)position=this.toPosition(this.step);this.knob.setStyle(this.property,position);},snap:false,offset:0,range:false,wheel:false,steps:100,mode:'horizontal'},initialize:function(element,knob,options){this.setOptions(options);this.element=$(element);this.knob=$(knob);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 offset,limit={},modifiers={'x':false,'y':false};switch(this.options.mode){case'vertical':this.axis='y';this.property='top';offset='offsetHeight';break;case'horizontal':this.axis='x';this.property='left';offset='offsetWidth';} this.half=this.knob[offset]/2;this.full=this.element[offset]-this.knob[offset]+(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(step){if(!((this.range>0)^(step0)^(step>this.max)))step=this.max;this.step=Math.round(step);this.checkStep();this.end();this.fireEvent('tick',this.toPosition(this.step));return this;},clickedElement:function(event){var dir=this.range<0?-1:1;var position=event.page[this.axis]-this.element.getPosition()[this.axis]-this.half;position=position.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+dir*this.toStep(position));this.checkStep();this.end();this.fireEvent('tick',position);},scrolledElement:function(event){var mode=(this.options.mode=='horizontal')?(event.wheel<0):(event.wheel>0);this.set(mode?this.step-this.stepSize:this.step+this.stepSize);event.stop();},draggedKnob:function(){var dir=this.range<0?-1:1;var position=this.drag.value.now[this.axis];position=position.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+dir*this.toStep(position));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(position){var step=(position+this.options.offset)*this.stepSize/this.full*this.steps;return this.options.steps?Math.round(step-=step%this.stepSize):step;},toPosition:function(step){return(this.full*Math.abs(this.min-step))/(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(element,options){this.setOptions(options);this.element=$(element);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(event){this.page=(this.listener.get('tag')=='body')?event.client:event.page;if(!this.timer)this.timer=this.scroll.periodical(50,this);},scroll:function(){var size=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>(size[z]+pos[z])&&size[z]+size[z]!=scroll[z]) change[z]=(this.page[z]-size[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 params=Array.link(arguments,{'container':Element.type,'options':Object.type,'togglers':$defined,'elements':$defined});this.parent(params.elements,params.options);this.togglers=$$(params.togglers);this.container=$(params.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;i0));this.fireEvent(hide?'background':'active',[this.togglers[i],el]);for(var fx in this.effects)obj[i][fx]=hide?0:el[this.effects[fx]];},this);return this.start(obj);}}); /*========== NEXT ==========*/ /* Milkbox - required: mootools.js v1.2 core + more: Assets v1.3.1 - feature: hide milkbox links hover default firefox tooltips - feature: hide select and textarea tags while playing - fix: you can use milkbox with image links that contains url variables (ex. image.jpg?id=77&lang=ita) - fix: a little preload problem when using 2-image galleries by Luca Reghellin (http://www.reghellin.com) July 2008, MIT-style license. Inspiration from Slimbox by Christophe Beyls (http://www.digitalia.be) and from THE VERY FIRST MAN ON THE MOON: Lokesh Dhakar (http://www.lokeshdhakar.com/projects/lightbox2/) AND OF COURSE, SPECIAL THANKS TO THE MOOTOOLS DEVELOPERS */ var Milkbox = new Class({ Implements:Options, options:{//set all the options here overlayOpacity:0.7, topPosition:80, initialWidth:250, initialHeight:250, resizeDuration:500, resizeTransition:'sine:in:out',/*function (ex. Transitions.Sine.easeIn) or string (ex. 'quint:out')*/ hoverBackgroundPosition:'0 -23px', autoPlay:false, autoPlayDelay:7, removeTitle:true }, initialize: function(options){ this.setOptions(options); this.galleries = []; this.currentImage = null; this.currentIndex = null; this.currentGallery = null; this.specialDescription = null;//for showThisImage this.activated = false;//used in showThisImage this.mode = null;//'singleImage','imageGallery','showThisImage' this.closed = true; this.busy = true;//to control keyboard and autoplay events this.intObj = null; this.formtags = null; this.loadedImages = [];//to check the preloaded images this.prepareGalleries(); //if no galleries, stop here and prevent extra memory usage. //so you can keep milkbox in every page of a site. if(this.galleries.length == 0){ return; }; this.initMilkbox(); },//end init initMilkbox:function(){ this.prepareHTML(); this.prepareEffects(); this.prepareEvents(); this.activated = true; this.formtags = $$('select','textarea'); }, //runs only 1 time per gallery openMilkbox:function(gallery,index){ if(this.formtags.length != 0){ this.formtags.setStyle('display','none') }; this.overlay.setStyles({ 'top': -$(window).getScroll().y,'height':$(window).getScrollSize().y+$(window).getScroll().y }); this.center.addClass('mbLoading'); this.center.setStyle('top',$(window).getScroll().y+this.options.topPosition); this.currentGallery = gallery; this.currentIndex = index; this.overlay.tween('opacity',this.options.overlayOpacity);//onComplete: center.tween opacity if(gallery.length == 1){ this.mode = 'singleImage'; this.loadImages(gallery[index].href); } else { this.mode = 'imageGallery'; var images = gallery.map(function(item){ return item.href; }); $$(this.prev, this.next, this.count).setStyles({'display':'block'}); var border = this.center.getStyle('border-right-width').toInt();//border-right is just ok for design purposes.. var navWidth = this.prev.getSize().x+this.next.getSize().x+this.close.getSize().x+border; this.navigation.setStyle('width',navWidth); this.description.setStyle('margin-right',navWidth); var next = (index != images.length-1) ? images[index+1] : images[0]; var prev = (index != 0) ? images[index-1] : images[images.length-1]; var preloads = (prev == next) ? [prev] : [prev,next]; //if gallery.length == 2, then prev == next this.loadImages(images[index],preloads); } this.closed = false; }, //call with js showThisImage:function(image,description){ //if init was not done because of the absence of galleries, do it now. if(!this.activated){ this.initMilkbox(); } this.mode = 'showThisImage'; this.specialDescription = description; this.overlay.setStyles({ 'top': -$(window).getScroll().y,'height':$(window).getScrollSize().y+$(window).getScroll().y }); this.center.addClass('mbLoading'); this.center.setStyle('top',$(window).getScroll().y+this.options.topPosition); this.overlay.tween('opacity',this.options.overlayOpacity);//onComplete: center.tween opacity this.loadImages(image); this.closed = false; }, //see loadImages() showImage:function(image){ if(this.closed){ return; };//if you close the Milkbox and an onload event is still running var imageBoxSize = this.image.getSize(); this.image.setStyles({'opacity':0, 'width':'', 'height':''}); var imageSize = new Hash(image.getProperties('width','height')).map(function(item, index){ return item.toInt(); }); var centerSize = new Hash(this.center.getStyles('width','height')).map(function(item, index){ return item.toInt(); }); var targetSize = {}; if(imageSize.width != centerSize.width){ targetSize.width = imageSize.width; targetSize.marginLeft = -(imageSize.width/2).round(); }; var gap = (imageBoxSize.y > 0) ? centerSize.height - imageBoxSize.y : 0; var targetHeight = imageSize.height + gap; targetSize.height = targetHeight; //so nav doesn't move when you click next/prev this.image.setStyles({'width':imageSize.width, 'height':imageSize.height}) this.center.removeClass('mbLoading'); this.center.morph(targetSize);//onComplete: show all items }, loadImages:function(currentImage,preloads){ var loadImage = new Asset.image(currentImage, { onload:function(img){ this.currentImage = img; if(!this.loadedImages.contains(currentImage)){ this.loadedImages.push(currentImage); };//see next/prev events $$(this.description,this.navigation).setStyle('visibility','hidden'); this.navigation.setStyle('height','');//reset the height setted in center.morph.onComplete $$(this.next,this.prev,this.close).setStyle('backgroundPosition','0 0'); this.showImage(this.currentImage); }.bindWithEvent(this)}); if(preloads && !this.loadedImages.contains(preloads)){ var preloadImages = new Asset.images(preloads, { onComplete:function(img){ preloads.each(function(item){ if(!(this.loadedImages.contains(item))){ this.loadedImages.push(item); } }.bind(this)); }.bindWithEvent(this)}); }; }, //all the main events prepareEvents:function(){ //galleries this.galleries.each(function(gallery){ $$(gallery).addEvent('click',function(e){ var button=($(e.target).match('a')) ? $(e.target) : $(e.target).getParent('a'); e.preventDefault(); if(this.options.autoPlay){ this.autoPlay({ gallery:gallery, index:gallery.indexOf(button) }); } else{ this.openMilkbox(gallery, gallery.indexOf(button)); } }.bindWithEvent(this)); },this); //next, prev, see next_prev_aux() this.next.addEvent('click',this.next_prev_aux.bindWithEvent(this,'next')); this.prev.addEvent('click',this.next_prev_aux.bindWithEvent(this,'prev')); //keyboard next/prev/close $(window.document).addEvent('keydown',function(e){ if(this.mode != 'imageGallery' || this.busy == true){ return; }; if(e.key == 'right' || e.key == 'space'){ this.next_prev_aux(e,'next'); } else if(e.key == 'left'){ this.next_prev_aux(e,'prev'); } else if(e.key == 'esc'){ this.closeMilkbox(); }; }.bindWithEvent(this)); //css hover doesn't work in ie6, so I must do it via js... $$(this.next,this.prev,this.close).addEvents({ 'mouseover':function(e){ var button=($(e.target).match('a')) ? $(e.target) : $(e.target).getParent('a'); button.setStyle('backgroundPosition',this.options.hoverBackgroundPosition); }.bindWithEvent(this), 'mouseout':function(){ this.setStyle('backgroundPosition','0 0'); } }); //overlay this.overlay.get('tween').addEvent('onComplete',function(){ if(this.overlay.getStyle('opacity') == this.options.overlayOpacity){ this.center.tween('opacity',1); } else if(this.overlay.getStyle('opacity') == 0) { this.overlay.setStyles({'height':'','top':''}); }; }.bindWithEvent(this)); //center this.center.get('morph').addEvent('onComplete',function(){ this.image.grab(this.currentImage); this.image.tween('opacity',1); var d = (!(this.mode == 'showThisImage')) ? this.currentGallery[this.currentIndex].retrieve('title') : this.specialDescription; if($chk(d)){ this.description.innerHTML = d; }; if(this.mode == 'imageGallery'){ this.count.appendText((this.currentIndex+1)+' z '+this.currentGallery.length); } var currentCenterHeight = this.center.getStyle('height').toInt(); this.navigation.setStyle('height',this.bottom.getStyle('height').toInt());//to have the right-border height == total bottom height var bottomSize = this.bottom.getSize().y; //after the 1st time, currentCenterHeight is always > this.image.getSize().y var targetOffset = (currentCenterHeight > this.image.getSize().y) ? (this.bottom.getSize().y+this.image.getSize().y)-currentCenterHeight : bottomSize; this.bottom.setStyle('display','none');//to avoid rendering problems during setFinalHeight this.center.retrieve('setFinalHeight').start(currentCenterHeight,currentCenterHeight+targetOffset); /**/ }.bindWithEvent(this)); this.center.retrieve('setFinalHeight').addEvent('onComplete',function(){ this.bottom.setStyles({'visibility':'visible','display':'block'}); $$(this.description,this.navigation).setStyle('visibility','visible'); //reset overlay height based on position and height var scrollSize = $(window).getScrollSize().y; var scrollTop = $(window).getScroll().y; this.overlay.setStyle('height',scrollSize+scrollTop); this.busy = false; }.bindWithEvent(this)); //reset overlay height and position onResize window.addEvent('resize',function(){ if(this.overlay.getStyle('opacity') == 0){ return; };//resize only if visible var scrollSize = $(window).getScrollSize().y; var scrollTop = $(window).getScroll().y; this.overlay.setStyles({ 'height':scrollSize+scrollTop,'top':-scrollTop }); }.bindWithEvent(this)) //close $$(this.overlay,this.image,this.close).addEvent('click',function(){ this.closeMilkbox(); }.bindWithEvent(this)); }, next_prev_aux:function(e,direction){ if(e){ e.preventDefault(); if(this.intObj){ $clear(this.intObj); this.intObj = null; }; } //if there's no event obj, than this is called by autoPlay() else{ if(this.busy){ return; } }//stop autoplay() this.busy = true; //for keyboard and autoplay var backupIndex = this.currentIndex; if(direction == "next"){ var i= (this.currentIndex != this.currentGallery.length-1) ? this.currentIndex += 1 : this.currentIndex = 0; var _i= (this.currentIndex != this.currentGallery.length-1) ? this.currentIndex + 1 : 0; } else { var i= (this.currentIndex != 0) ? this.currentIndex -= 1 : this.currentIndex = this.currentGallery.length-1; var _i= (this.currentIndex != 0) ? this.currentIndex - 1 : this.currentGallery.length-1; }; this.image.empty(); this.description.empty(); this.count.empty(); if(!this.loadedImages.contains(this.currentGallery[i].href)){ this.center.addClass('mbLoading'); }; this.loadImages(this.currentGallery[i].href,[this.currentGallery[_i].href]); }, autoPlay:function(obj){//obj: gallery, index, delay (in seconds) var g = (obj && obj.gallery && ($type(obj.gallery) == 'array')) ? obj.gallery : Milkbox.galleries[0]; var i = (obj && obj.index && ($type(obj.index) == 'number')) ? obj.index : 0; var d = (obj && obj.delay && ($type(obj.delay) == 'number')) ? obj.delay*1000 : this.options.autoPlayDelay*1000; if(d < this.options.resizeDuration*2){ d = this.options.resizeDuration*2 }; Milkbox.openMilkbox(g,i); if(this.mode != 'imageGallery'){ return; }; this.intObj = this.next_prev_aux.periodical(d,this,[null,'next']); }, closeMilkbox:function(){ this.cancelAllEffects(); if(this.intObj){ $clear(this.intObj); }; this.currentImage = null; this.currentIndex = null; this.currentGallery = null; $$(this.prev, this.next, this.count).setStyle('display','none'); var border = this.center.getStyle('border-right-width').toInt(); var navWidth = this.close.getSize().x+border; this.navigation.setStyles({'width':navWidth,'height':'','visibility':'hidden'}); this.description.setStyle('margin-right',navWidth); this.description.empty(); this.bottom.setStyles({'visibility':'hidden','display':''}); this.image.setStyles({'opacity':0, 'width':'', 'height':''}); this.image.empty(); this.count.empty(); this.center.setStyles({'opacity':0,'width':this.options.initialWidth,'height':this.options.initialHeight,'marginLeft':-(this.options.initialWidth/2)}); this.overlay.tween('opacity',0);//see onComplete in prepareEvents() if(this.formtags.length != 0){ this.formtags.setStyle('display','inline') }; this.mode = null; this.closed = true; }, cancelAllEffects:function(){ this.overlay.get('tween').cancel(); this.center.get('morph').cancel(); this.center.get('tween').cancel(); this.center.retrieve('setFinalHeight').cancel(); this.image.get('tween').cancel(); }, prepareEffects:function(){ this.overlay.set('tween',{ duration:'short',link:'cancel' }); this.center.set('tween',{ duration:'short',link:'chain' }); this.center.set('morph',{ duration:this.options.resizeDuration,link:'chain',transition:this.options.resizeTransition }); this.center.store('setFinalHeight',new Fx.Tween(this.center,{property:'height',duration:'short'})); this.image.set('tween',{ link:'chain' }); }, prepareGalleries:function(){ var families = []; var milkbox_a = []; $$('a').each(function(a){ //test 'milkbox' and link extension, and collect all milkbox links if(a.rel && a.rel.test(/^milkbox/i) && a.href.split('?')[0].test(/\.(gif|jpg|png)$/i)){ if(a.rel.length>7 && !families.contains(a.rel)){ families.push(a.rel); }; milkbox_a.push(a); } },this); //console.log(milkbox_a) //create an array of arrays with all galleries milkbox_a.each(function(a){ $(a).store('href',a.href); $(a).store('rel',a.rel); $(a).store('title',a.title); if(this.options.removeTitle){ $(a).removeProperty('title'); } if(a.rel.length > 7){ families.each(function(f,i){ if(a.rel == f){ if(!this.galleries[i]){ this.galleries[i] = [] }; this.galleries[i].push($(a)); }; },this); } else { this.galleries.push([$(a)]); }; },this); //console.log(this.galleries) }, prepareHTML:function(){ this.overlay = new Element('div', { 'id':'mbOverlay','styles':{ 'opacity':'0','visibility':'visible' }}).inject($(document.body)); this.center = new Element('div', {'id':'mbCenter', 'styles':{'width':this.options.initialWidth,'height':this.options.initialHeight,'marginLeft':-(this.options.initialWidth/2),'opacity':0}}).inject($(document.body)); this.image = new Element('div', {'id':'mbImage'}).inject(this.center); this.bottom = new Element('div',{'id':'mbBottom'}).inject(this.center).setStyle('visibility','hidden'); this.navigation = new Element('div',{'id':'mbNavigation'}).setStyle('visibility','hidden'); this.description = new Element('div',{'id':'mbDescription'}).setStyle('visibility','hidden'); this.bottom.adopt(this.navigation, this.description, new Element('div',{'class':'clear'})); this.close = new Element('a',{'id':'mbCloseLink'}); this.next = new Element('a',{'id':'mbNextLink'}); this.prev = new Element('a',{'id':'mbPrevLink'}); this.count = new Element('span',{'id':'mbCount'}); $$(this.next, this.prev, this.count).setStyle('display','none'); this.navigation.adopt(this.close, this.next, this.prev,new Element('div',{'class':'clear'}), this.count); } });//END MILKBOX; /*========== NEXT ==========*/ window.addEvent('domready', function() { });