//MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. var MooTools={version:"1.2.1",build:"0d4845aab3d9a4fdee2f0d4a6dd59210e4b697cf"};var Native=function(K){K=K||{};var A=K.name;var I=K.legacy;var B=K.protect; var C=K.implement;var H=K.generics;var F=K.initialize;var G=K.afterImplement||function(){};var D=F||I;H=H!==false;D.constructor=Native;D.$family={name:"native"}; if(I&&F){D.prototype=I.prototype;}D.prototype.constructor=D;if(A){var E=A.toLowerCase();D.prototype.$family={name:E};Native.typize(D,E);}var J=function(N,L,O,M){if(!B||M||!N.prototype[L]){N.prototype[L]=O; }if(H){Native.genericize(N,L,B);}G.call(N,L,O);return N;};D.alias=function(N,L,O){if(typeof N=="string"){if((N=this.prototype[N])){return J(this,L,N,O); }}for(var M in N){this.alias(M,N[M],L);}return this;};D.implement=function(M,L,O){if(typeof M=="string"){return J(this,M,L,O);}for(var N in M){J(this,N,M[N],L); }return this;};if(C){D.implement(C);}return D;};Native.genericize=function(B,C,A){if((!A||!B[C])&&typeof B.prototype[C]=="function"){B[C]=function(){var D=Array.prototype.slice.call(arguments); return B.prototype[C].apply(D.shift(),D);};}};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(){for(var E in this){if($type(this[E])!="function"){this[E]=$unlink(this[E]); }}this.constructor=A;if(Class.prototyping){return this;}var D=(this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize){this.options.initialize.call(this); }return D;};for(var C in Class.Mutators){if(!B[C]){continue;}B=Class.Mutators[C](B,B[C]);delete B[C];}$extend(A,this);A.constructor=Class;A.prototype=B; return A;}});Class.Mutators={Extends:function(C,A){Class.prototyping=A.prototype;var B=new A;delete B.parent;B=Class.inherit(B,C);delete Class.prototyping; return B;},Implements:function(A,B){$splat(B).each(function(C){Class.prototying=C;$extend(A,($type(C)=="class")?new C:C);delete Class.prototyping;});return A; }};Class.extend({inherit:function(B,E){var A=arguments.callee.caller;for(var D in E){var C=E[D];var G=B[D];var F=$type(C);if(G&&F=="function"){if(C!=G){if(A){C.__parent=G; B[D]=C;}else{Class.override(B,D,C);}}}else{if(F=="object"){B[D]=$merge(G,C);}else{B[D]=C;}}}if(A){B.parent=function(){return arguments.callee.caller.__parent.apply(this,arguments); };}return B;},override:function(B,A,E){var D=Class.prototyping;if(D&&B[A]!=D[A]){D=null;}var C=function(){var F=this.parent;this.parent=D?D[A]:B[A];var G=E.apply(this,arguments); this.parent=F;return G;};B[A]=C;}});Class.implement({implement:function(){var A=this.prototype;$each(arguments,function(B){Class.inherit(A,B);});return this; }});var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false; },clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){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[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){if($type(C)=="object"){for(var D in C){this.removeEvent(D,C[D]); }return this;}if(C){C=Events.removeOn(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;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(A,B){var C=Element.Constructors.get(A); if(C){return C(B);}if(typeof A=="string"){return document.newElement(A,B);}return $(A).set(B);},afterImplement:function(A,B){Element.Prototype[A]=B;if(Array[A]){return ; }Elements.implement(A,function(){var C=[],G=true;for(var E=0,D=this.length;E";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); },getDocument:function(){return this;},getWindow:function(){return this.window;}});Window.implement({$:function(B,C){if(B&&B.$family&&B.uid){return B;}var A=$type(B); return($[A])?$[A](B,C,this.document):null;},$$:function(A){if(arguments.length==1&&typeof A=="string"){return this.document.getElements(A);}var F=[];var C=Array.flatten(arguments); for(var D=0,B=C.length;D1);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}); }});(function(){var H={},F={};var I={input:"checked",option:"selected",textarea:(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerHTML":"value"}; var C=function(L){return(F[L]||(F[L]={}));};var G=function(N,L){if(!N){return ;}var M=N.uid;if(Browser.Engine.trident){if(N.clearAttributes){var P=L&&N.cloneNode(false); N.clearAttributes();if(P){N.mergeAttributes(P);}}else{if(N.removeEvents){N.removeEvents();}}if((/object/i).test(N.tagName)){for(var O in N){if(typeof N[O]=="function"){N[O]=$empty; }}Element.dispose(N);}}if(!M){return ;}H[M]=F[M]=null;};var D=function(){Hash.each(H,G);if(Browser.Engine.trident){$A(document.getElementsByTagName("object")).each(G); }if(window.CollectGarbage){CollectGarbage();}H=F=null;};var J=function(N,L,S,M,P,R){var O=N[S||L];var Q=[];while(O){if(O.nodeType==1&&(!M||Element.match(O,M))){if(!P){return $(O,R); }Q.push(O);}O=O[L];}return(P)?new Elements(Q,{ddup:false,cash:!R}):null;};var E={html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident||(Browser.Engine.webkit&&Browser.Engine.version<420))?"innerText":"textContent"}; var B=["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"];var K=["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]; Hash.extend(E,B.associate(B));Hash.extend(E,K.associate(K.map(String.toLowerCase)));var A={before:function(M,L){if(L.parentNode){L.parentNode.insertBefore(M,L); }},after:function(M,L){if(!L.parentNode){return ;}var N=L.nextSibling;(N)?L.parentNode.insertBefore(M,N):L.parentNode.appendChild(M);},bottom:function(M,L){L.appendChild(M); },top:function(M,L){var N=L.firstChild;(N)?L.insertBefore(M,N):L.appendChild(M);}};A.inside=A.bottom;Hash.each(A,function(L,M){M=M.capitalize();Element.implement("inject"+M,function(N){L(this,$(N,true)); return this;});Element.implement("grab"+M,function(N){L($(N,true),this);return this;});});Element.implement({set:function(O,M){switch($type(O)){case"object":for(var N in O){this.set(N,O[N]); }break;case"string":var L=Element.Properties.get(O);(L&&L.set)?L.set.apply(this,Array.slice(arguments,1)):this.setProperty(O,M);}return this;},get:function(M){var L=Element.Properties.get(M); return(L&&L.get)?L.get.apply(this,Array.slice(arguments,1)):this.getProperty(M);},erase:function(M){var L=Element.Properties.get(M);(L&&L.erase)?L.erase.apply(this):this.removeProperty(M); return this;},setProperty:function(M,N){var L=E[M];if(N==undefined){return this.removeProperty(M);}if(L&&B[M]){N=!!N;}(L)?this[L]=N:this.setAttribute(M,""+N); return this;},setProperties:function(L){for(var M in L){this.setProperty(M,L[M]);}return this;},getProperty:function(M){var L=E[M];var N=(L)?this[L]:this.getAttribute(M,2); return(B[M])?!!N:(L)?N:N||null;},getProperties:function(){var L=$A(arguments);return L.map(this.getProperty,this).associate(L);},removeProperty:function(M){var L=E[M]; (L)?this[L]=(L&&B[M])?false:"":this.removeAttribute(M);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this; },hasClass:function(L){return this.className.contains(L," ");},addClass:function(L){if(!this.hasClass(L)){this.className=(this.className+" "+L).clean(); }return this;},removeClass:function(L){this.className=this.className.replace(new RegExp("(^|\\s)"+L+"(?:\\s|$)"),"$1");return this;},toggleClass:function(L){return this.hasClass(L)?this.removeClass(L):this.addClass(L); },adopt:function(){Array.flatten(arguments).each(function(L){L=$(L,true);if(L){this.appendChild(L);}},this);return this;},appendText:function(M,L){return this.grab(this.getDocument().newTextNode(M),L); },grab:function(M,L){A[L||"bottom"]($(M,true),this);return this;},inject:function(M,L){A[L||"bottom"](this,$(M,true));return this;},replaces:function(L){L=$(L,true); L.parentNode.replaceChild(this,L);return this;},wraps:function(M,L){M=$(M,true);return this.replaces(M).grab(M,L);},getPrevious:function(L,M){return J(this,"previousSibling",null,L,false,M); },getAllPrevious:function(L,M){return J(this,"previousSibling",null,L,true,M);},getNext:function(L,M){return J(this,"nextSibling",null,L,false,M);},getAllNext:function(L,M){return J(this,"nextSibling",null,L,true,M); },getFirst:function(L,M){return J(this,"nextSibling","firstChild",L,false,M);},getLast:function(L,M){return J(this,"previousSibling","lastChild",L,false,M); },getParent:function(L,M){return J(this,"parentNode",null,L,false,M);},getParents:function(L,M){return J(this,"parentNode",null,L,true,M);},getChildren:function(L,M){return J(this,"nextSibling","firstChild",L,true,M); },getWindow:function(){return this.ownerDocument.window;},getDocument:function(){return this.ownerDocument;},getElementById:function(O,N){var M=this.ownerDocument.getElementById(O); if(!M){return null;}for(var L=M.parentNode;L!=this;L=L.parentNode){if(!L){return null;}}return $.element(M,N);},getSelected:function(){return new Elements($A(this.options).filter(function(L){return L.selected; }));},getComputedStyle:function(M){if(this.currentStyle){return this.currentStyle[M.camelCase()];}var L=this.getDocument().defaultView.getComputedStyle(this,null); return(L)?L.getPropertyValue([M.hyphenate()]):null;},toQueryString:function(){var L=[];this.getElements("input, select, textarea",true).each(function(M){if(!M.name||M.disabled){return ; }var N=(M.tagName.toLowerCase()=="select")?Element.getSelected(M).map(function(O){return O.value;}):((M.type=="radio"||M.type=="checkbox")&&!M.checked)?null:M.value; $splat(N).each(function(O){if(typeof O!="undefined"){L.push(M.name+"="+encodeURIComponent(O));}});});return L.join("&");},clone:function(O,L){O=O!==false; var R=this.cloneNode(O);var N=function(V,U){if(!L){V.removeAttribute("id");}if(Browser.Engine.trident){V.clearAttributes();V.mergeAttributes(U);V.removeAttribute("uid"); if(V.options){var W=V.options,S=U.options;for(var T=W.length;T--;){W[T].selected=S[T].selected;}}}var X=I[U.tagName.toLowerCase()];if(X&&U[X]){V[X]=U[X]; }};if(O){var P=R.getElementsByTagName("*"),Q=this.getElementsByTagName("*");for(var M=P.length;M--;){N(P[M],Q[M]);}}N(R,this);return $(R);},destroy:function(){Element.empty(this); Element.dispose(this);G(this,true);return null;},empty:function(){$A(this.childNodes).each(function(L){Element.destroy(L);});return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this; },hasChild:function(L){L=$(L,true);if(!L){return false;}if(Browser.Engine.webkit&&Browser.Engine.version<420){return $A(this.getElementsByTagName(L.tagName)).contains(L); }return(this.contains)?(this!=L&&this.contains(L)):!!(this.compareDocumentPosition(L)&16);},match:function(L){return(!L||(L==this)||(Element.get(this,"tag")==L)); }});Native.implement([Element,Window,Document],{addListener:function(O,N){if(O=="unload"){var L=N,M=this;N=function(){M.removeListener("unload",N);L(); };}else{H[this.uid]=this;}if(this.addEventListener){this.addEventListener(O,N,false);}else{this.attachEvent("on"+O,N);}return this;},removeListener:function(M,L){if(this.removeEventListener){this.removeEventListener(M,L,false); }else{this.detachEvent("on"+M,L);}return this;},retrieve:function(M,L){var O=C(this.uid),N=O[M];if(L!=undefined&&N==undefined){N=O[M]=L;}return $pick(N); },store:function(M,L){var N=C(this.uid);N[M]=L;return this;},eliminate:function(L){var M=C(this.uid);delete M[L];return this;}});window.addListener("unload",D); })();Element.Properties=new Hash;Element.Properties.style={set:function(A){this.style.cssText=A;},get:function(){return this.style.cssText;},erase:function(){this.style.cssText=""; }};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.html=(function(){var C=document.createElement("div"); var A={table:[1,"","
"],select:[1,""],tbody:[2,"","
"],tr:[3,"","
"]}; A.thead=A.tfoot=A.tbody;var B={set:function(){var E=Array.flatten(arguments).join("");var F=Browser.Engine.trident&&A[this.get("tag")];if(F){var G=C;G.innerHTML=F[1]+E+F[2]; for(var D=F[0];D--;){G=G.firstChild;}this.empty().adopt(G.childNodes);}else{this.innerHTML=E;}}};B.erase=B.set;return B;})();if(Browser.Engine.webkit&&Browser.Engine.version<420){Element.Properties.text={get:function(){if(this.innerText){return this.innerText; }var A=this.ownerDocument.newElement("div",{html:this.innerHTML}).inject(this.ownerDocument.body);var B=A.innerText;A.destroy();return B;}};}Element.Properties.events={set:function(A){this.addEvents(A); }};Native.implement([Element,Window,Document],{addEvent:function(E,G){var H=this.retrieve("events",{});H[E]=H[E]||{keys:[],values:[]};if(H[E].keys.contains(G)){return this; }H[E].keys.push(G);var F=E,A=Element.Events.get(E),C=G,I=this;if(A){if(A.onAdd){A.onAdd.call(this,G);}if(A.condition){C=function(J){if(A.condition.call(this,J)){return G.call(this,J); }return true;};}F=A.base||F;}var D=function(){return G.call(I);};var B=Element.NativeEvents[F];if(B){if(B==2){D=function(J){J=new Event(J,I.getWindow()); if(C.call(I,J)===false){J.stop();}};}this.addListener(F,D);}H[E].values.push(D);return this;},removeEvent:function(C,B){var A=this.retrieve("events");if(!A||!A[C]){return this; }var F=A[C].keys.indexOf(B);if(F==-1){return this;}A[C].keys.splice(F,1);var E=A[C].values.splice(F,1)[0];var D=Element.Events.get(C);if(D){if(D.onRemove){D.onRemove.call(this,B); }C=D.base||C;}return(Element.NativeEvents[C])?this.removeListener(C,E):this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this; },removeEvents:function(A){if($type(A)=="object"){for(var C in A){this.removeEvent(C,A[C]);}return this;}var B=this.retrieve("events");if(!B){return this; }if(!A){for(var C in B){this.removeEvents(C);}this.eliminate("events");}else{if(B[A]){while(B[A].keys[0]){this.removeEvent(A,B[A].keys[0]);}B[A]=null;}}return this; },fireEvent:function(D,B,A){var C=this.retrieve("events");if(!C||!C[D]){return this;}C[D].keys.each(function(E){E.create({bind:this,delay:A,"arguments":B})(); },this);return this;},cloneEvents:function(D,A){D=$(D);var C=D.retrieve("events");if(!C){return this;}if(!A){for(var B in C){this.cloneEvents(D,B);}}else{if(C[A]){C[A].keys.each(function(E){this.addEvent(A,E); },this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1}; (function(){var A=function(B){var C=B.relatedTarget;if(C==undefined){return true;}if(C===false){return false;}return($type(this)!="document"&&C!=this&&C.prefix!="xul"&&!this.hasChild(C)); };Element.Events=new Hash({mouseenter:{base:"mouseover",condition:A},mouseleave:{base:"mouseout",condition:A},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}}); })();Element.Properties.styles={set:function(A){this.setStyles(A);}};Element.Properties.opacity={set:function(A,B){if(!B){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden"; }}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")"; }this.style.opacity=A;this.store("opacity",A);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(A){return this.set("opacity",A,true); },getOpacity:function(){return this.get("opacity");},setStyle:function(B,A){switch(B){case"opacity":return this.set("opacity",parseFloat(A));case"float":B=(Browser.Engine.trident)?"styleFloat":"cssFloat"; }B=B.camelCase();if($type(A)!="string"){var C=(Element.Styles.get(B)||"@").split(" ");A=$splat(A).map(function(E,D){if(!C[D]){return"";}return($type(E)=="number")?C[D].replace("@",Math.round(E)):E; }).join(" ");}else{if(A==String(Number(A))){A=Math.round(A);}}this.style[B]=A;return this;},getStyle:function(G){switch(G){case"opacity":return this.get("opacity"); case"float":G=(Browser.Engine.trident)?"styleFloat":"cssFloat";}G=G.camelCase();var A=this.style[G];if(!$chk(A)){A=[];for(var F in Element.ShortStyles){if(G!=F){continue; }for(var E in Element.ShortStyles[F]){A.push(this.getStyle(E));}return A.join(" ");}A=this.getComputedStyle(G);}if(A){A=String(A);var C=A.match(/rgba?\([\d\s,]+\)/); if(C){A=A.replace(C[0],C[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(A)))){if(G.test(/^(height|width)$/)){var B=(G=="width")?["left","right"]:["top","bottom"],D=0; B.each(function(H){D+=this.getStyle("border-"+H+"-width").toInt()+this.getStyle("padding-"+H).toInt();},this);return this["offset"+G.capitalize()]-D+"px"; }if((Browser.Engine.presto)&&String(A).test("px")){return A;}if(G.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return A;},setStyles:function(B){for(var A in B){this.setStyle(A,B[A]); }return this;},getStyles:function(){var A={};Array.each(arguments,function(B){A[B]=this.getStyle(B);},this);return A;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"}); Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(G){var F=Element.ShortStyles; var B=Element.Styles;["margin","padding"].each(function(H){var I=H+G;F[H][I]=B[I]="@px";});var E="border"+G;F.border[E]=B[E]="@px @ rgb(@, @, @)";var D=E+"Width",A=E+"Style",C=E+"Color"; F[E]={};F.borderWidth[D]=F[E][D]=B[D]="@px";F.borderStyle[A]=F[E][A]=B[A]="@";F.borderColor[C]=F[E][C]=B[C]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(H,I){if(B(this)){this.getWindow().scrollTo(H,I); }else{this.scrollLeft=H;this.scrollTop=I;}return this;},getSize:function(){if(B(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight}; },getScrollSize:function(){if(B(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(B(this)){return this.getWindow().getScroll(); }return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var I=this,H={x:0,y:0};while(I&&!B(I)){H.x+=I.scrollLeft;H.y+=I.scrollTop;I=I.parentNode; }return H;},getOffsetParent:function(){var H=this;if(B(H)){return null;}if(!Browser.Engine.trident){return H.offsetParent;}while((H=H.parentNode)&&!B(H)){if(D(H,"position")!="static"){return H; }}return null;},getOffsets:function(){if(Browser.Engine.trident){var L=this.getBoundingClientRect(),J=this.getDocument().documentElement;return{x:L.left+J.scrollLeft-J.clientLeft,y:L.top+J.scrollTop-J.clientTop}; }var I=this,H={x:0,y:0};if(B(this)){return H;}while(I&&!B(I)){H.x+=I.offsetLeft;H.y+=I.offsetTop;if(Browser.Engine.gecko){if(!F(I)){H.x+=C(I);H.y+=G(I); }var K=I.parentNode;if(K&&D(K,"overflow")!="visible"){H.x+=C(K);H.y+=G(K);}}else{if(I!=this&&Browser.Engine.webkit){H.x+=C(I);H.y+=G(I);}}I=I.offsetParent; }if(Browser.Engine.gecko&&!F(this)){H.x-=C(this);H.y-=G(this);}return H;},getPosition:function(K){if(B(this)){return{x:0,y:0};}var L=this.getOffsets(),I=this.getScrolls(); var H={x:L.x-I.x,y:L.y-I.y};var J=(K&&(K=$(K)))?K.getPosition():{x:0,y:0};return{x:H.x-J.x,y:H.y-J.y};},getCoordinates:function(J){if(B(this)){return this.getWindow().getCoordinates(); }var H=this.getPosition(J),I=this.getSize();var K={left:H.x,top:H.y,width:I.x,height:I.y};K.right=K.left+K.width;K.bottom=K.top+K.height;return K;},computePosition:function(H){return{left:H.x-E(this,"margin-left"),top:H.y-E(this,"margin-top")}; },position:function(H){return this.setStyles(this.computePosition(H));}});Native.implement([Document,Window],{getSize:function(){var I=this.getWindow(); if(Browser.Engine.presto||Browser.Engine.webkit){return{x:I.innerWidth,y:I.innerHeight};}var H=A(this);return{x:H.clientWidth,y:H.clientHeight};},getScroll:function(){var I=this.getWindow(); var H=A(this);return{x:I.pageXOffset||H.scrollLeft,y:I.pageYOffset||H.scrollTop};},getScrollSize:function(){var I=A(this);var H=this.getSize();return{x:Math.max(I.scrollWidth,H.x),y:Math.max(I.scrollHeight,H.y)}; },getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var H=this.getSize();return{top:0,left:0,bottom:H.y,right:H.x,height:H.y,width:H.x}; }});var D=Element.getComputedStyle;function E(H,I){return D(H,I).toInt()||0;}function F(H){return D(H,"-moz-box-sizing")=="border-box";}function G(H){return E(H,"border-top-width"); }function C(H){return E(H,"border-left-width");}function B(H){return(/^(?:body|html)$/i).test(H.tagName);}function A(H){var I=H.getDocument();return(!I.compatMode||I.compatMode=="CSS1Compat")?I.html:I.body; }})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y; },getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x; },getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(H,G){H=H.split(","); var C,E={};for(var D=0,B=H.length;D1),cash:!G});}});Element.implement({match:function(B){if(!B||(B==this)){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+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\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[5],C=D[6],J=D[7];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(I,H,N){var B=[];var C=H.trim().replace(Selectors.RegExps.splitter,function(Y,X,W){B.push(X); return":)"+W;}).split(":)");var J,E,U;for(var T=0,P=C.length;T":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");};if(Browser.Engine.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);})(); }else{if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); })();}else{window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}}})();var JSON=new Hash({$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); },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;},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"},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"; }},getTransition:function(){return function(A){return -(Math.cos(Math.PI*A)-1)/2;};},step:function(){var A=$time();if(A=(7-4*B)/11){C=A*A-Math.pow((11-6*B-11*D)/4,2); 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){try{this.xhr.setRequestHeader(J,K);}catch(L){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. /* Script: Fx.Slide.js Effect to slide an element in and out of view. License: 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; } }); /* Script: Fx.Elements.js Effect to change any number of CSS properties of any number of Elements. License: MIT-style license. */ 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); } }); /* Script: Accordion.js An Fx.Elements extension which allows you to easily create accordion type controls. License: MIT-style license. */ var Accordion = new Class({ Extends: Fx.Elements, options: {/* onActive: $empty, onBackground: $empty,*/ 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; i < l; i++) this.addSection(this.togglers[i], this.elements[i]); this.elements.each(function(el, i){ if (this.options.show === i){ this.fireEvent('active', [this.togglers[i], el]); } else { for (var fx in this.effects) el.setStyle(fx, 0); } }, this); if ($chk(this.options.display)) this.display(this.options.display); }, addSection: function(toggler, element, pos){ toggler = $(toggler); element = $(element); var test = this.togglers.contains(toggler); var len = this.togglers.length; this.togglers.include(toggler); this.elements.include(element); if (len && (!test || pos)){ pos = $pick(pos, len - 1); toggler.inject(this.togglers[pos], 'before'); element.inject(toggler, 'after'); } else if (this.container && !test){ toggler.inject(this.container); element.inject(this.container); } var idx = this.togglers.indexOf(toggler); toggler.addEvent('click', this.display.bind(this, idx)); if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'}); if (this.options.width) element.setStyles({'padding-left': 0, 'border-left': 'none', 'padding-right': 0, 'border-right': 'none'}); element.fullOpacity = 1; if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth; if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight; element.setStyle('overflow', 'hidden'); if (!test){ for (var fx in this.effects) element.setStyle(fx, 0); } return this; }, display: function(index){ index = ($type(index) == 'element') ? this.elements.indexOf(index) : index; if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this; this.previous = index; var obj = {}; this.elements.each(function(el, i){ obj[i] = {}; var hide = (i != index) || (this.options.alwaysHide && (el.offsetHeight > 0)); 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); } }); /************************************************************** Script : MultiBox Version : 1.3.1 Authors : Samuel Birch Desc : Supports jpg, gif, png, flash, flv, mov, wmv, mp3, html, iframe Licence : Open Source MIT Licence **************************************************************/ var MultiBox = new Class({ getOptions: function(){ return { initialWidth: 250, initialHeight: 250, container: document.body, useOverlay: false, contentColor: '#FFF', showNumbers: true, showControls: true, //showThumbnails: false, //autoPlay: false, waitDuration: 2000, descClassName: false, descMinWidth: 400, descMaxWidth: 600, movieWidth: 400, movieHeight: 300, offset: {x:0, y:0}, fixedTop: false, path: '', onOpen: $empty, onClose: $empty, openFromLink: true, relativeToWindow: true }; }, initialize: function(className, options){ this.setOptions(this.getOptions(), options); if (options.onClose) this.options.onClose = options.onClose; if (options.onOpen) this.options.onOpen = options.onOpen; this.openClosePos = {}; this.timer = 0; this.contentToLoad = {}; this.index = 0; this.opened = false; this.contentObj = {}; this.containerDefaults = {}; if(this.options.useOverlay){ this.overlay = new Overlay({container: this.options.container, onClick:this.close.bind(this)}); } this.content = $$('.'+className); if(this.options.descClassName){ this.descriptions = $$('.'+this.options.descClassName); this.descriptions.each(function(el){ el.setStyle('display', 'none'); }); } this.container = new Element('div').addClass('MultiBoxContainer').injectInside(this.options.container); this.iframe = new Element('iframe').setProperties({ 'id': 'multiBoxIframe', 'name': 'mulitBoxIframe', 'src': 'javascript:void(0);', 'frameborder': 1, 'scrolling': 'no' }).setStyles({ 'position': 'absolute', 'top': -20, 'left': -20, 'width': '115%', 'height': '115%', 'filter': 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)', 'opacity': 0 }).injectInside(this.container); this.box = new Element('div').addClass('MultiBoxContent').injectInside(this.container); this.closeButton = new Element('div').addClass('MultiBoxClose').injectInside(this.container).addEvent('click', this.close.bind(this)); this.controlsContainer = new Element('div').addClass('MultiBoxControlsContainer').injectInside(this.container); this.controls = new Element('div').addClass('MultiBoxControls').injectInside(this.controlsContainer); this.previousButton = new Element('div').addClass('MultiBoxPrevious').injectInside(this.controls).addEvent('click', this.previous.bind(this)); this.nextButton = new Element('div').addClass('MultiBoxNext').injectInside(this.controls).addEvent('click', this.next.bind(this)); this.title = new Element('div').addClass('MultiBoxTitle').injectInside(this.controls); this.number = new Element('div').addClass('MultiBoxNumber').injectInside(this.controls); this.description = new Element('div').addClass('MultiBoxDescription').injectInside(this.controls); if(this.content.length == 1){ this.title.setStyles({ 'margin-left': 0 }); this.description.setStyles({ 'margin-left': 0 }); this.previousButton.setStyle('display', 'none'); this.nextButton.setStyle('display', 'none'); this.number.setStyle('display', 'none'); } new Element('div').setStyle('clear', 'both').injectInside(this.controls); this.content.each(function(el,i){ el.index = i; el.addEvent('click', function(e){ new Event(e).stop(); this.open(el); }.bind(this)); if(el.href.indexOf('#') > -1){ el.content = $(el.href.substr(el.href.indexOf('#')+1)); if(el.content){el.content.setStyle('display','none');} } }, this); this.containerEffects = new Fx.Morph(this.container, {duration: 400, transition: Fx.Transitions.Sine.easeInOut}); this.controlEffects = new Fx.Morph(this.controlsContainer, {duration: 300, transition: Fx.Transitions.Sine.easeInOut}); this.reset(); }, setContentType: function(link){ var str = link.href.substr(link.href.lastIndexOf('.')+1).toLowerCase(); var contentOptions = {}; if($chk(link.rel)){ var optArr = link.rel.split(','); optArr.each(function(el){ var ta = el.split(':'); contentOptions[ta[0]] = ta[1]; }); } if(contentOptions.type != undefined){ str = contentOptions.type; } this.contentObj = {}; this.contentObj.url = link.href; this.contentObj.xH = 0; if(contentOptions.width){ this.contentObj.width = contentOptions.width; }else{ this.contentObj.width = this.options.movieWidth; } if(contentOptions.height){ this.contentObj.height = contentOptions.height; }else{ this.contentObj.height = this.options.movieHeight; } if(contentOptions.panel){ this.panelPosition = contentOptions.panel; }else{ this.panelPosition = this.options.panel; } switch(str) { case 'jpg': case 'gif': case 'png': this.type = 'image'; break; case 'swf': this.type = 'flash'; break; case 'flv': this.type = 'flashVideo'; this.contentObj.xH = 70; break; case 'mov': this.type = 'quicktime'; break; case 'wmv': this.type = 'windowsMedia'; break; case 'rv': case 'rm': case 'rmvb': this.type = 'real'; break; case 'mp3': this.type = 'flashMp3'; this.contentObj.width = 320; this.contentObj.height = 70; break; case 'element': this.type = 'htmlelement'; this.elementContent = link.content; this.elementContent.setStyles({ display: 'block', opacity: 0 }) if(this.elementContent.getStyle('width') != 'auto'){ this.contentObj.width = this.elementContent.getStyle('width'); } this.contentObj.height = this.elementContent.getSize().y; this.elementContent.setStyles({ display: 'none', opacity: 1 }) break; default: this.type = 'iframe'; if(contentOptions.ajax){ this.type = 'ajax'; } break; } }, reset: function(){ this.container.setStyles({ 'opacity': 0, 'display': 'none' }); this.controlsContainer.setStyles({ 'height': 0 }); this.removeContent(); this.previousButton.removeClass('MultiBoxButtonDisabled'); this.nextButton.removeClass('MultiBoxButtonDisabled'); this.opened = false; }, getOpenClosePos: function(el){ if (this.options.openFromLink) { if (el.getFirst()) { var w = el.getFirst().getCoordinates().width - (this.container.getStyle('border').toInt() * 2); if (w < 0) { w = 0 } var h = el.getFirst().getCoordinates().height - (this.container.getStyle('border').toInt() * 2); if (h < 0) { h = 0 } this.openClosePos = { width: w, height: h, top: el.getFirst().getCoordinates().top, left: el.getFirst().getCoordinates().left }; } else { var w = el.getCoordinates().width - (this.container.getStyle('border').toInt() * 2); if (w < 0) { w = 0 } var h = el.getCoordinates().height - (this.container.getStyle('border').toInt() * 2); if (h < 0) { h = 0 } this.openClosePos = { width: w, height: h, top: el.getCoordinates().top, left: el.getCoordinates().left }; } }else{ if(this.options.fixedTop){ var top = this.options.fixedTop; }else{ var top = ((window.getHeight()/2)-(this.options.initialHeight/2)-this.container.getStyle('border').toInt())+this.options.offset.y; } this.openClosePos = { width: this.options.initialWidth, height: this.options.initialHeight, top: top, left: ((window.getWidth()/2)-(this.options.initialWidth/2)-this.container.getStyle('border').toInt())+this.options.offset.x }; } return this.openClosePos; }, open: function(el){ if (this.options.onOpen) this.options.onOpen(); this.index = this.content.indexOf(el); this.openId = el.getProperty('id'); if(!this.opened){ this.opened = true; if(this.options.useOverlay){ this.overlay.show(); } this.container.setStyles(this.getOpenClosePos(el)); this.container.setStyles({ opacity: 0, display: 'block' }); if(this.options.fixedTop){ var top = this.options.fixedTop; }else{ var top = ((window.getHeight()/2)-(this.options.initialHeight/2)-this.container.getStyle('border').toInt())+this.options.offset.y; } this.containerEffects.start({ width: this.options.initialWidth, height: this.options.initialHeight, top: top, left: ((window.getWidth()/2)-(this.options.initialWidth/2)-this.container.getStyle('border').toInt())+this.options.offset.x, opacity: [0, 1] }); this.load(this.index); }else{ if (this.options.showControls) { this.hideControls(); } this.getOpenClosePos(this.content[this.index]); this.timer = this.hideContent.bind(this).delay(500); this.timer = this.load.pass(this.index, this).delay(1100); } }, getContent: function(index){ this.setContentType(this.content[index]); var desc = {}; if(this.options.descClassName){ this.descriptions.each(function(el,i){ if(el.hasClass(this.openId)){ desc = el.clone(); } },this); } //var title = this.content[index].title; this.contentToLoad = { title: this.content[index].title || ' ', //desc: $(this.options.descClassName+this.content[index].id).clone(), desc: desc, number: index+1 }; }, close: function(){ if(this.options.useOverlay){ this.overlay.hide(); } if (this.options.showControls) { this.hideControls(); } this.hideContent(); this.containerEffects.cancel(); this.zoomOut.bind(this).delay(500); if (this.options.onClose) { this.options.onClose(); } }, zoomOut: function(){ this.containerEffects.start({ width: this.openClosePos.width, height: this.openClosePos.height, top: this.openClosePos.top, left: this.openClosePos.left, opacity: 0 }); this.reset.bind(this).delay(500); }, load: function(index){ this.box.addClass('MultiBoxLoading'); this.getContent(index); if ( this.type == 'image' ) { var xH = this.contentObj.xH; this.contentObj = new Asset.image(this.content[index].href, {onload: this.resize.bind(this)}); //this.contentObj = new Image(); this.contentObj.onload = this.resize.bind(this); this.contentObj.xH = xH; this.contentObj.src = this.content[index].href; } else { this.resize(); } }, resize: function(){ if (this.options.fixedTop) { var top = this.options.fixedTop; } else { var top = ((window.getHeight() / 2) - ((Number(this.contentObj.height) + this.contentObj.xH) / 2) - this.container.getStyle('border').toInt() + window.getScrollTop()) + this.options.offset.y; } var left = ((window.getWidth() / 2) - (this.contentObj.width.toInt() / 2) - this.container.getStyle('border').toInt()) + this.options.offset.x; if (top < 0) { top = 0 } if (left < 0) { left = 0 } this.containerEffects.cancel(); this.containerEffects.start({ width: this.contentObj.width, height: Number(this.contentObj.height) + this.contentObj.xH, top: top, left: left, opacity: 1 }); this.timer = this.showContent.bind(this).delay(500); }, showContent: function(){ this.box.removeClass('MultiBoxLoading'); this.removeContent(); this.contentContainer = new Element('div').setProperties({id: 'MultiBoxContentContainer'}).setStyles({opacity: 0, width: this.contentObj.width+'px', height: (Number(this.contentObj.height)+this.contentObj.xH)+'px'}).injectInside(this.box); if(this.type == 'image'){ this.contentObj.injectInside(this.contentContainer); }else if(this.type == 'iframe'){ new Element('iframe').setProperties({ id: 'iFrame'+new Date().getTime(), width: this.contentObj.width, height: this.contentObj.height, src: this.contentObj.url, frameborder: 0, scrolling: 'auto' }).injectInside(this.contentContainer); }else if(this.type == 'htmlelement'){ this.elementContent.clone().setStyle('display','block').injectInside(this.contentContainer); }else if(this.type == 'ajax'){ new Request.HTML ({ url: this.contentObj.url, method: 'get', update: 'MultiBoxContentContainer', evalScripts: true, autoCancel: true }).send(); }else{ var obj = this.createEmbedObject().injectInside(this.contentContainer); if(this.str != ''){ $('MultiBoxMediaObject').innerHTML = this.str; } } this.contentEffects = new Fx.Tween(this.contentContainer, {duration: 500}); this.contentEffects.start('opacity', 1); this.title.set('text', this.contentToLoad.title); this.number.set('text', this.contentToLoad.number+' of '+this.content.length); if (this.options.descClassName) { if (this.description.getFirst()) { this.description.getFirst().dispose(); } this.contentToLoad.desc.inject(this.description).setStyles({ 'display': 'block' }); } //this.removeContent.bind(this).delay(500); if (this.options.showControls) { this.timer = this.showControls.bind(this).delay(800); } }, hideContent: function(){ this.box.addClass('MultiBoxLoading'); this.contentEffects.start('opacity', 0); this.removeContent.bind(this).delay(500); }, removeContent: function(){ if($('MultiBoxMediaObject')){ $('MultiBoxMediaObject').empty(); $('MultiBoxMediaObject').dispose(); } if($('MultiBoxContentContainer')){ //$('MultiBoxContentContainer').empty(); $('MultiBoxContentContainer').dispose(); } }, showControls: function(){ this.clicked = false; if(this.container.getStyle('height') != 'auto'){ this.containerDefaults.height = this.container.getStyle('height') this.containerDefaults.backgroundColor = this.options.contentColor; } this.container.setStyles({ //'backgroundColor': this.controls.getStyle('backgroundColor'), 'height': 'auto' }); if(this.contentToLoad.number == 1){ this.previousButton.addClass('MultiBoxPreviousDisabled'); }else{ this.previousButton.removeClass('MultiBoxPreviousDisabled'); } if(this.contentToLoad.number == this.content.length){ this.nextButton.addClass('MultiBoxNextDisabled'); }else{ this.nextButton.removeClass('MultiBoxNextDisabled'); } this.controlEffects.start({'height': this.controls.getStyle('height')}); }, hideControls: function(num){ this.controlEffects.start({'height': 0}).chain(function(){ this.container.setStyles(this.containerDefaults); }.bind(this)); }, showThumbnails: function(){ }, next: function(){ if(this.index < this.content.length-1){ this.index++; this.openId = this.content[this.index].getProperty('id'); if (this.options.showControls) { this.hideControls(); } this.getOpenClosePos(this.content[this.index]); //this.getContent(this.index); this.timer = this.hideContent.bind(this).delay(500); this.timer = this.load.pass(this.index, this).delay(1100); } }, previous: function(){ if(this.index > 0){ this.index--; this.openId = this.content[this.index].getProperty('id'); if (this.options.showControls) { this.hideControls(); } this.getOpenClosePos(this.content[this.index]); //this.getContent(this.index); this.timer = this.hideContent.bind(this).delay(500); this.timer = this.load.pass(this.index, this).delay(1000); } }, createEmbedObject: function(){ if(this.type == 'flash'){ var url = this.contentObj.url; var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'}); this.str = '' this.str += ''; this.str += ''; this.str += ''; } if(this.type == 'flashVideo'){ //var url = this.contentObj.url.substring(0, this.contentObj.url.lastIndexOf('.')); var url = this.contentObj.url; var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'}); this.str = '' this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += '' this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; } if(this.type == 'windowsMedia'){ var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'}); this.str = ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; } if(this.type == 'real'){ var obj = new Element('div').setProperties({id: 'MultiBoxMediaObject'}); this.str = ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; this.str += ''; } return obj; } }); MultiBox.implement(new Options, new Events); /*************************************************************/ /************************************************************** Script : Overlay Version : 1.2 Authors : Samuel birch Desc : Covers the window with a semi-transparent layer. Licence : Open Source MIT Licence **************************************************************/ var Overlay = new Class({ getOptions: function(){ return { colour: '#000', opacity: 0.7, zIndex: 1, container: document.body, onClick: Class.empty }; }, initialize: function(options){ this.setOptions(this.getOptions(), options); this.options.container = $(this.options.container); this.container = new Element('div').setProperty('id', 'OverlayContainer').setStyles({ position: 'absolute', left: '0px', top: '0px', width: '100%', zIndex: this.options.zIndex }).injectInside(this.options.container); this.iframe = new Element('iframe').setProperties({ 'id': 'OverlayIframe', 'name': 'OverlayIframe', 'src': 'javascript:void(0);', 'frameborder': 1, 'scrolling': 'no' }).setStyles({ 'position': 'absolute', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%', 'filter': 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)', 'opacity': 0, 'zIndex': 1 }).injectInside(this.container); this.overlay = new Element('div').setProperty('id', 'Overlay').setStyles({ position: 'absolute', left: '0px', top: '0px', width: '100%', height: '100%', zIndex: 2, backgroundColor: this.options.colour }).injectInside(this.container); this.container.addEvent('click', function(){ this.options.onClick(); }.bind(this)); this.fade = new Fx.Tween(this.container); this.fade.set('opacity','0'); this.position(); window.addEvent('resize', this.position.bind(this)); }, position: function(){ if(this.options.container == document.body){ var h = window.getScrollHeight()+'px'; this.container.setStyles({top: '0px', height: h}); }else{ var myCoords = this.options.container.getCoordinates(); this.container.setStyles({ top: myCoords.top+'px', height: myCoords.height+'px', left: myCoords.left+'px', width: myCoords.width+'px' }); } }, show: function(){ this.fade.start('opacity', 0,this.options.opacity); }, hide: function(){ this.fade.start('opacity', this.options.opacity,0); } }); Overlay.implement(new Options); /*************************************************************/ Utils = {}; Utils.defaultWindow = {}; Utils.defaultWindow.popup = null; Utils.defaultWindow.width = 400; Utils.defaultWindow.height = 600; Utils.defaultWindow.properties = "location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0"; /** * Will open up the URL in our default window settings **/ Utils.popUpWindow = function(url, width, height) { if (Utils.defaultWindow.popup && !Utils.defaultWindow.popup.closed) { Utils.defaultWindow.popup.location = url; } else { if (width != null) { Utils.defaultWindow.popup = window.open(url, '_blank', 'width=' + width + ',height=' + height + ',' + Utils.defaultWindow.properties); } else { Utils.defaultWindow.popup = window.open(url, '_blank', 'width=' + Utils.defaultWindow.width + ',height=' + Utils.defaultWindow.height + ',' + Utils.defaultWindow.properties); } } Utils.defaultWindow.popup.focus(); } function toggleCheckAll(id, name) { var elms = document.getElementsByName(name); var ch = document.getElementById(id).checked; for (var i = 0; i < elms.length; i++) { elms[i].checked = ch; } } var confirmPopup = function (url,text) { var answer = confirm (text); if (answer) { window.location = url; } } // does the same as the above but submits a form instead of going to a url var confirmPopupForm = function (form,text) { var answer = confirm (text); if (answer) { form.submit(); } } // Enable dropdowns with 'class' if 'element' has a value of 'value' var enableDropdowns = function (element, value) { var dropDowns = document.getElements('.' + element.getAttribute('id')); // Enable dropdowns if (element.value == value) { for (var y = 0; y < dropDowns.length; y++) { if (dropDowns[y] != null) { dropDowns[y].removeAttribute('disabled'); dropDowns[y].setAttribute('class', 'var ' + element.getAttribute('id')); } } } else { // Disable for (var z = 0; z < dropDowns.length; z++) { // remove var class if (dropDowns[z] != null) { dropDowns[z].setAttribute('disabled','disabled'); dropDowns[z].setAttribute('class', element.getAttribute('id')); } } } } // id = the tab to display // tabs = array with all the tabs var showHideTabs = function (id, tabs) { //Make all the tabs nonactive for (var i = 0; i < tabs.length; i++) { if ($(tabs[i] + "Tab") != null) { $(tabs[i] + "Tab").className = "none"; $(tabs[i] + "Bttn").className = ""; } } $(id + 'Tab').className = "block"; $(id + 'Bttn').className = "greenGradientheader"; if ($(id + 'Tab').getAttribute('id') == 'toolsTab') { $('toolsTabInstructions').className = "whiteBox"; } else { $('toolsTabInstructions').className = "none" } } var assignXstandardValues = function (isTask) { setRequirements(); if(isTask == 'true'){ setDownloadInstructions(); } } var setRequirements = function () { try { if(typeof(document.getElementById('id_requirementsField').EscapeUnicode) == 'undefined') { throw "Error" } else { document.getElementById('requirementsValue').value = document.getElementById('id_requirementsField').value; } } catch(er) { } } var setDownloadInstructions = function () { try{ if(typeof(document.getElementById('id_downloadInstructions').EscapeUnicode) == 'undefined'){ throw "Error"; } else { document.getElementById('downloadValue').value = document.getElementById('id_downloadInstructions').value; } } catch(er){ } } var disableLink = function (element) { if (element.getAttribute('name') == "clicked") { element.removeAttribute('href'); } else { element.setAttribute('name','clicked'); } } // Used for multibox var reloadPage = function (url) { if (url != null && url != "") { window.location = url; } } function tabSwitch (key, tabContentUrl) { $('itemTabsNav').getElements('a').each(function(i) { i.removeClass('greenGradientheader'); }) $(key).addClass('greenGradientheader'); var req = new Request.HTML({ url: tabContentUrl, method: 'get', evalScripts: false, onRequest: function() { $('tabsContent').set("html","

loading ...

"); }, onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript) { $('tabsContent').empty(); $('tabsContent').adopt(responseTree); $exec(responseJavaScript); } }).send(); } var showSubtype = function () { $$('.subtypes').each(function (el, i) { if (el.get('id').match($('type').value)) { el.setStyle('display','block'); el.set('disabled',''); } else { el.setStyle('display','none'); el.set('disabled','true'); } }); } /********************************************************************************************************************** PIPELINE TOOLS - NUKE TOOLS ***********************************************************************************************************************/ var threeCharVersion = function(version) { switch(version.length) { case 1: version = "00" + version; break; case 2: version = "0" + version; break; } return version; } // Returns true if is an integer var isInt = function(value) { var reg = /^[-]{0,1}[0-9]{1,}$/; return reg.test(value); } // Returns true if the element has one of the classesToIgnore value as a class var hasClassesToIgnore = function (element, classesToIgnore) { if (classesToIgnore.length > 0) { // Go through all the classes to ignore for (var z = 0; z < classesToIgnore.length; z++) { if ((element.className).match(classesToIgnore[z])) { //console.log(element.getAttribute('title') + " is ignored coz it has the class " + classesToIgnore[z]); return true; } } } return false; } // Check the variables passed in are well formated an returns the command line string var checkVars = function(vars) { var commandLineVars = ""; var classesToIgnore = new Array(); var defaultValuePath = "1"; var defaultValueFrame = "0"; // Getting all the variables and add them to the final command line for (var x = 0; x < vars.length; x++) { // If var has the null class, then add it to command line using default value // = CAN BE NULL if ((vars[x].className).match("null") && vars[x].value == "") { commandLineVars += " " + defaultValuePath; classesToIgnore.push(vars[x].getAttribute('id')); // else add var to command line if not null or empty } else if ((vars[x].className != "var null" && vars[x].value != "" && vars[x].value != null) || (vars[x].className == "var null" && vars[x].value != "")) { // put default value for var if has one of the classes to ignore if (hasClassesToIgnore(vars[x], classesToIgnore)) { commandLineVars += " " + defaultValueFrame; } else { // class = dblBSlash and Windows --> double slashes if ((vars[x].className).match("dblBSlash") && $('os').value == "windows") { commandLineVars += " " + (vars[x].value).replace(/\\/g,"\\\\"); // class = sglBSlash and Windows --> single slash } else if ((vars[x].className).match("sglBSlash") && $('os').value == "windows") { commandLineVars += " " + (vars[x].value).replace(/\\/g,"\\"); // checks var is an int } else if ((vars[x].className).match("int") && !isInt(vars[x].value)) { $('commandErrors').innerHTML += "

" + vars[x].getAttribute('title') + " needs to be an integer.

"; // checks var is a string and not an int } else if ((vars[x].className).match("string") && isInt(vars[x].value)) { $('commandErrors').innerHTML += "

" + vars[x].getAttribute('title') + " needs to be a filepath.

"; // class = quote --> add \\" around var } else if ((vars[x].className).match("quote") && isInt(vars[x].value)) { commandLineVars += " \\\"" + vars[x].value + "\\\""; // Add to command line } else { commandLineVars += " " + vars[x].value; } } } else { // one var is null = no command line --> display errors if (hasClassesToIgnore(vars[x], classesToIgnore)) { commandLineVars += " " + defaultValueFrame; } else { $('commandErrors').innerHTML += "

" + vars[x].getAttribute('title') + " must be filled in to generate the command line.

"; } } } return commandLineVars; } var burnIn = function () { // last var in command $('burnInFirstFrameLastFrameOutput').value = $('burnInFirstFrameImgSeq').value + "," + $('burnInLastFrameImgSeq').value; // output needs to have / even if input in windows has \ as nuke is Linux based $('burnInOutputPathFinal').value = $('burnInOutputPath').value + "/" + $('burnInItemName').value + threeCharVersion($('burnInVersion').value) + ".%04d.jpg"; /*$('burnInFinalPath').value = $('burnInPath').value;*/ if ($('os').value == "windows") { $('burnInOutputPathFinal').value = $('burnInOutputPathFinal').value.replace(/\\/g,"/"); /*$('burnInFinalPath').value = $('burnInPath').value.replace(/\\/g,"/");*/ } } var exrConverter = function () { } var qcTool = function () { $('qcToolFirstFrameLastFrameOutput').value = $('qcToolFirstFrameImgSeq').value + "," + $('qcToolLastFrameImgSeq').value; $('qcToolOutputPathFinal').value = $('qcToolOutputPath').value + "/" + $('qcToolItemName').value; /*$('qcToolFinalPath').value = $('qcToolPath').value;*/ if ($('os').value == "windows") { $('qcToolOutputPathFinal').value = $('qcToolOutputPathFinal').value.replace(/\\/g,"/"); /*$('qcToolFinalPath').value = $('qcToolPath').value.replace(/\\/g,"/");*/ } } var rotoChecker = function() { // put all that in an array and send to function -> returns lowest / highest var lowestFirst = parseInt($('rotoCheckerFirstFrameFirstRoto').value); var highestLast = parseInt($('rotoCheckerLastFrameFirstRoto').value); if (parseInt($('rotoCheckerFirstFrameSecondRoto').value) < lowestFirst) { lowestFirst = $('rotoCheckerFirstFrameSecondRoto').value; } if (parseInt($('rotoCheckerFirstFrameThirdRoto').value) < lowestFirst) { lowestFirst = parseInt($('rotoCheckerFirstFrameThirdRoto').value); } if (parseInt($('rotoCheckerFirstFrameForeground').value) < lowestFirst) { lowestFirst = parseInt($('rotoCheckerFirstFrameForeground').value); } if (parseInt($('rotoCheckerFirstFrameBackground').value) < lowestFirst) { lowestFirst = parseInt($('rotoCheckerFirstFrameBackground').value); } if (parseInt($('rotoCheckerLastFrameSecondRoto').value) > highestLast) { highestLast = parseInt($('rotoCheckerLastFrameSecondRoto').value); } if (parseInt($('rotoCheckerLastFrameThirdRoto').value) > highestLast) { highestLast = parseInt($('rotoCheckerLastFrameThirdRoto').value); } if (parseInt($('rotoCheckerLastFrameForeground').value) > highestLast) { highestLast = parseInt($('rotoCheckerLastFrameForeground').value); } if (parseInt($('rotoCheckerLastFrameBackground').value) > highestLast) { highestLast = parseInt($('rotoCheckerLastFrameBackground').value); } $('rotoCheckerFirstFrameLastFrameOutput').value = lowestFirst + "," + highestLast; $('rotoCheckerOutputPathFinal').value = $('rotoCheckerOutputPath').value + "/" + $('rotoCheckerItemName').value + "_reviewcomp_mb_v" + threeCharVersion($('rotoCheckerOutputVersion').value) + ".%04d.exr"; if ($('os').value == "windows") { $('rotoCheckerOutputPathFinal').value = $('rotoCheckerOutputPathFinal').value.replace(/\\/g,"/"); } } // Generate a nuke command line with multiple variables // - nukeCommandType // 1 = burnIn // 2 = exrConverter // 3 = QcTool // 4 = reviewcomp (aka rotoChecker) // - form = id of the submitted form // - scriptType = "nk" or "py" // - scriptFileName: filename of the script to use var generateCommandLine = function (nukeCommandType, form, scriptFileName, scriptType) { var commandVars = $(form).getElements('.var'); var commandLineVars = ""; var scriptFilePath = ""; $('commandErrors').innerHTML = ""; $('commandResult').value = ""; switch (nukeCommandType) { case '1': burnIn(); commandLineVars = checkVars(commandVars); break; case '2': exrConverter(); commandLineVars = checkVars(commandVars); break; case '3': qcTool(); commandLineVars = checkVars(commandVars); break; case '4': rotoChecker(); commandLineVars = checkVars(commandVars); break; } //console.log(commandLineVars); // If there are error messages, display them if ($('commandErrors').innerHTML != "") { //console.log(classesToIgnore.length); $('commandErrors').get('slide').slideIn(); return; // else no error show the command result } else if (commandLineVars != "") { if ($('os').value == "linux" || $('os').value == "mac") { scriptFilePath = "$NUKE_SCRIPTS"; } else if ($('os').value == "windows") { scriptFilePath = "%NUKE_SCRIPTS%"; scriptFileName = scriptFileName.replace(/\//g,'\\'); // backslashes for win not forward slashes } // Hide errors if they were some if ($('commandErrors').innerHTML != null) { $('commandErrors').get('slide').slideOut(); $('commandErrors').innerHTML = ""; } if ((nukeCommandType == '1' || nukeCommandType == '3' || nukeCommandType == '4') && $('os').value == "windows") { commandLineVars = commandLineVars.replace(/\\/g,"/"); } $('commandResult').value = "nuke " + scriptType + " " + scriptFilePath + scriptFileName + commandLineVars; $('commandResult').select(); } } // Check version number var removeLetters = function (version) { var integerVersionNumber = ""; for (var i = 0; i < version.length; i++) { if(isInt(version.charAt(i))){ integerVersionNumber += version.charAt(i); } } return parseInt(integerVersionNumber); } // notNull = cannot be null var checkForm = function (f,e) { var form = $(f); var errorDiv = $(e); errorDiv.innerHTML = ""; $$('#' + form.get('id') + ' .var').each(function(elmt) { if ((elmt.get('class')).match("notNull") && (elmt.value).replace(/ /g,"") == "") { errorDiv.innerHTML = errorDiv.innerHTML + "

" + elmt.get('title') + " must not be empty.

"; } }); // new version number must be greater than latest version ie // if latest version is 2, new version must be 3 or 2a /*if ($('versionInput')!= null) { if ($('versionInput').value != "") { if (removeLetters($('versionInput').value) < removeLetters($('latestVersionNumber').value) || $('versionInput').value == $('latestVersionNumber').value) { errorDiv.innerHTML = errorDiv.innerHTML + "

" + $('versionInput').get('title') + " must be greater than " + $('latestVersionNumber').value + ".

"; } } }*/ errorDiv.set('class','error'); return (errorDiv.innerHTML == ""); } // Getting the descriptions from a multiple select // -- returns a string with comma separated values var getMultipleSelectDescriptions = function (el) { var descriptions = ""; var count = 0; el.getSelected().each(function(e) { descriptions += "\"" + e.get('html') + "\"" + (count == el.getSelected().length-1 ? "" : ", "); count++; }); return descriptions; }; /** * Fx.ProgressBar * * @version 1.1 * * @license MIT License * * @author Harald Kirschner * @copyright Authors */ Fx.ProgressBar = new Class({ Extends: Fx, options: { text: null, url: null, transition: Fx.Transitions.Circ.easeOut, fit: true, link: 'cancel' }, initialize: function(element, options) { this.element = $(element); this.parent(options); var url = this.options.url; if (url) { this.element.setStyles({ 'background-image': 'url(' + url + ')', 'background-repeat': 'no-repeat' }); } if (this.options.fit) { url = url || this.element.getStyle('background-image').replace(/^url\(["']?|["']?\)$/g, ''); if (url) { var fill = new Image(); fill.onload = function() { this.fill = fill.width; fill = fill.onload = null; this.set(this.now || 0); }.bind(this); fill.src = url; if (!this.fill && fill.width) fill.onload(); } } else { this.set(0); } }, start: function(to, total) { return this.parent(this.now, (arguments.length == 1) ? to.limit(0, 100) : to / total * 100); }, set: function(to) { this.now = to; var css = (this.fill) ? (((this.fill / -2) + (to / 100) * (this.element.width || 1) || 0).round() + 'px') : ((100 - to) + '%'); this.element.setStyle('backgroundPosition', css + ' 0px').title = Math.round(to) + '%'; var text = $(this.options.text); if (text) text.set('text', Math.round(to) + '%'); return this; } }); /** * Swiff.Uploader - Flash FileReference Control * * @version 3.0 * * @license MIT License * * @author Harald Kirschner * @author Valerio Proietti, * @copyright Authors */ Swiff.Uploader = new Class({ Extends: Swiff, Implements: Events, options: { path: 'Swiff.Uploader.swf', target: null, zIndex: 9999, height: 30, width: 100, callBacks: null, params: { wMode: 'opaque', menu: 'false', allowScriptAccess: 'always' }, typeFilter: null, multiple: true, queued: true, verbose: false, url: null, method: null, data: null, mergeData: true, fieldName: null, fileSizeMin: 1, fileSizeMax: null, // Official limit is 100 MB for FileReference, but I tested up to 2Gb! allowDuplicates: false, timeLimit: (Browser.Platform.linux) ? 0 : 30, buttonImage: null, policyFile: null, fileListMax: 0, fileListSizeMax: 0, instantStart: false, appendCookieData: false, fileClass: null /* onLoad: $empty, onFail: $empty, onStart: $empty, onQueue: $empty, onComplete: $empty, onBrowse: $empty, onDisabledBrowse: $empty, onCancel: $empty, onSelect: $empty, onSelectSuccess: $empty, onSelectFail: $empty, onButtonEnter: $empty, onButtonLeave: $empty, onButtonDown: $empty, onButtonDisable: $empty, onFileStart: $empty, onFileStop: $empty, onFileRequeue: $empty, onFileOpen: $empty, onFileProgress: $empty, onFileComplete: $empty, onFileRemove: $empty, onBeforeStart: $empty, onBeforeStop: $empty, onBeforeRemove: $empty */ }, initialize: function(options) { // protected events to control the class, added // before setting options (which adds own events) this.addEvent('load', this.initializeSwiff, true) .addEvent('select', this.processFiles, true) .addEvent('complete', this.update, true) .addEvent('fileRemove', function(file) { this.fileList.erase(file); }.bind(this), true); this.setOptions(options); // callbacks are no longer in the options, every callback // is fired as event, this is just compat if (this.options.callBacks) { Hash.each(this.options.callBacks, function(fn, name) { this.addEvent(name, fn); }, this); } this.options.callBacks = { fireCallback: this.fireCallback.bind(this) }; var path = this.options.path; if (!path.contains('?')) path += '?noCache=' + $time(); // cache in IE // container options for Swiff class this.options.container = this.box = new Element('span', {'class': 'swiff-uploader-box'}).inject($(this.options.container) || document.body); // target this.target = $(this.options.target); if (this.target) { var scroll = window.getScroll(); this.box.setStyles({ position: 'absolute', visibility: 'visible', zIndex: this.options.zIndex, overflow: 'hidden', height: 1, width: 1, top: scroll.y, left: scroll.x }); // we force wMode to transparent for the overlay effect this.parent(path, { params: { wMode: 'transparent' }, height: '100%', width: '100%' }); this.target.addEvent('mouseenter', this.reposition.bind(this, [])); // button interactions, relayed to to the target this.addEvents({ buttonEnter: this.targetRelay.bind(this, ['mouseenter']), buttonLeave: this.targetRelay.bind(this, ['mouseleave']), buttonDown: this.targetRelay.bind(this, ['mousedown']), buttonDisable: this.targetRelay.bind(this, ['disable']) }); this.reposition(); window.addEvent('resize', this.reposition.bind(this, [])); } else { this.parent(path); } this.inject(this.box); this.fileList = []; this.size = this.uploading = this.bytesLoaded = this.percentLoaded = 0; if (Browser.Plugins.Flash.version < 9) { this.fireEvent('fail', ['flash']); } else { this.verifyLoad.delay(1000, this); } }, verifyLoad: function() { if (this.loaded) return; if (!this.object.parentNode) { this.fireEvent('fail', ['disabled']); } else if (this.object.style.display == 'none') { this.fireEvent('fail', ['hidden']); } else if (!this.object.offsetWidth) { this.fireEvent('fail', ['empty']); } }, fireCallback: function(name, args) { // file* callbacks are relayed to the specific file if (name.substr(0, 4) == 'file') { // updated queue data is the second argument if (args.length > 1) this.update(args[1]); var data = args[0]; var file = this.findFile(data.id); this.fireEvent(name, file || data, 5); if (file) { var fire = name.replace(/^file([A-Z])/, function($0, $1) { return $1.toLowerCase(); }); file.update(data).fireEvent(fire, [data], 10); } } else { this.fireEvent(name, args, 5); } }, update: function(data) { // the data is saved right to the instance $extend(this, data); this.fireEvent('queue', [this], 10); return this; }, findFile: function(id) { for (var i = 0; i < this.fileList.length; i++) { if (this.fileList[i].id == id) return this.fileList[i]; } return null; }, initializeSwiff: function() { // extracted options for the swf this.remote('initialize', { width: this.options.width, height: this.options.height, typeFilter: this.options.typeFilter, multiple: this.options.multiple, queued: this.options.queued, url: this.options.url, method: this.options.method, data: this.options.data, mergeData: this.options.mergeData, fieldName: this.options.fieldName, verbose: this.options.verbose, fileSizeMin: this.options.fileSizeMin, fileSizeMax: this.options.fileSizeMax, allowDuplicates: this.options.allowDuplicates, timeLimit: this.options.timeLimit, buttonImage: this.options.buttonImage, policyFile: this.options.policyFile }); this.loaded = true; this.appendCookieData(); }, targetRelay: function(name) { if (this.target) this.target.fireEvent(name); }, reposition: function(coords) { // update coordinates, manual or automatically coords = coords || (this.target && this.target.offsetHeight) ? this.target.getCoordinates(this.box.getOffsetParent()) : {top: window.getScrollTop(), left: 0, width: 40, height: 40} this.box.setStyles(coords); this.fireEvent('reposition', [coords, this.box, this.target]); }, setOptions: function(options) { if (options) { if (options.url) options.url = Swiff.Uploader.qualifyPath(options.url); if (options.buttonImage) options.buttonImage = Swiff.Uploader.qualifyPath(options.buttonImage); this.parent(options); if (this.loaded) this.remote('setOptions', options); } return this; }, setEnabled: function(status) { this.remote('setEnabled', status); }, start: function() { this.fireEvent('beforeStart'); this.remote('start'); }, stop: function() { this.fireEvent('beforeStop'); this.remote('stop'); }, remove: function() { this.fireEvent('beforeRemove'); this.remote('remove'); }, fileStart: function(file) { this.remote('fileStart', file.id); }, fileStop: function(file) { this.remote('fileStop', file.id); }, fileRemove: function(file) { this.remote('fileRemove', file.id); }, fileRequeue: function(file) { this.remote('fileRequeue', file.id); }, appendCookieData: function() { var append = this.options.appendCookieData; if (!append) return; var hash = {}; document.cookie.split(/;\s*/).each(function(cookie) { cookie = cookie.split('='); if (cookie.length == 2) { hash[decodeURIComponent(cookie[0])] = decodeURIComponent(cookie[1]); } }); var data = this.options.data || {}; if ($type(append) == 'string') data[append] = hash; else $extend(data, hash); this.setOptions({data: data}); }, processFiles: function(successraw, failraw, queue) { var cls = this.options.fileClass || Swiff.Uploader.File; var fail = [], success = []; if (successraw) { successraw.each(function(data) { var ret = new cls(this, data); if (!ret.validate()) { ret.remove.delay(10, ret); fail.push(ret); } else { this.size += data.size; this.fileList.push(ret); success.push(ret); ret.render(); } }, this); this.fireEvent('selectSuccess', [success], 10); } if (failraw || fail.length) { fail.extend((failraw) ? failraw.map(function(data) { return new cls(this, data); }, this) : []).each(function(file) { file.invalidate().render(); }); this.fireEvent('selectFail', [fail], 10); } this.update(queue); if (this.options.instantStart && success.length) this.start(); } }); $extend(Swiff.Uploader, { STATUS_QUEUED: 0, STATUS_RUNNING: 1, STATUS_ERROR: 2, STATUS_COMPLETE: 3, STATUS_STOPPED: 4, log: function() { if (window.console && console.info) console.info.apply(console, arguments); }, unitLabels: { b: [{min: 1, unit: 'B'}, {min: 1024, unit: 'kB'}, {min: 1048576, unit: 'MB'}, {min: 1073741824, unit: 'GB'}], s: [{min: 1, unit: 's'}, {min: 60, unit: 'm'}, {min: 3600, unit: 'h'}, {min: 86400, unit: 'd'}] }, formatUnit: function(base, type, join) { var labels = Swiff.Uploader.unitLabels[(type == 'bps') ? 'b' : type]; var append = (type == 'bps') ? '/s' : ''; var i, l = labels.length, value; if (base < 1) return '0 ' + labels[0].unit + append; if (type == 's') { var units = []; for (i = l - 1; i >= 0; i--) { value = Math.floor(base / labels[i].min); if (value) { units.push(value + ' ' + labels[i].unit); base -= value * labels[i].min; if (!base) break; } } return (join === false) ? units : units.join(join || ', '); } for (i = l - 1; i >= 0; i--) { value = labels[i].min; if (base >= value) break; } return (base / value).toFixed(1) + ' ' + labels[i].unit + append; } }); Swiff.Uploader.qualifyPath = (function() { var anchor; return function(path) { (anchor || (anchor = new Element('a'))).href = path; return anchor.href; }; })(); Swiff.Uploader.File = new Class({ Implements: Events, initialize: function(base, data) { this.base = base; this.update(data); }, update: function(data) { return $extend(this, data); }, validate: function() { var options = this.base.options; if (options.fileListMax && this.base.fileList.length >= options.fileListMax) { this.validationError = 'fileListMax'; return false; } if (options.fileListSizeMax && (this.base.size + this.size) > options.fileListSizeMax) { this.validationError = 'fileListSizeMax'; return false; } return true; }, invalidate: function() { this.invalid = true; this.base.fireEvent('fileInvalid', this, 10); return this.fireEvent('invalid', this, 10); }, render: function() { return this; }, setOptions: function(options) { if (options) { if (options.url) options.url = Swiff.Uploader.qualifyPath(options.url); this.base.remote('fileSetOptions', this.id, options); this.options = $merge(this.options, options); } return this; }, start: function() { this.base.fileStart(this); return this; }, stop: function() { this.base.fileStop(this); return this; }, remove: function() { this.base.fileRemove(this); return this; }, requeue: function() { this.base.fileRequeue(this); } }); /** * FancyUpload - Flash meets Ajax for powerful and elegant uploads. * * Updated to latest 3.0 API. Hopefully 100% compat! * * @version 3.0 * * @license MIT License * * @author Harald Kirschner * @copyright Authors */ var FancyUpload2 = new Class({ Extends: Swiff.Uploader, options: { queued: 1, // compat limitSize: 0, limitFiles: 0, validateFile: $lambda(true) }, initialize: function(status, list, options) { this.status = $(status); this.list = $(list); // compat options.fileClass = options.fileClass || FancyUpload2.File; options.fileSizeMax = options.limitSize || options.fileSizeMax; options.fileListMax = options.limitFiles || options.fileListMax; this.parent(options); this.addEvents({ 'load': this.render, 'select': this.onSelect, 'cancel': this.onCancel, 'start': this.onStart, 'queue': this.onQueue, 'complete': this.onComplete }); }, render: function() { this.overallTitle = this.status.getElement('.overall-title'); this.currentTitle = this.status.getElement('.current-title'); this.currentText = this.status.getElement('.current-text'); var progress = this.status.getElement('.overall-progress'); this.overallProgress = new Fx.ProgressBar(progress, { text: new Element('span', {'class': 'progress-text'}).inject(progress, 'after') }); progress = this.status.getElement('.current-progress') this.currentProgress = new Fx.ProgressBar(progress, { text: new Element('span', {'class': 'progress-text'}).inject(progress, 'after') }); this.updateOverall(); }, onSelect: function() { this.status.removeClass('status-browsing'); }, onCancel: function() { this.status.removeClass('file-browsing'); }, onStart: function() { this.status.addClass('file-uploading'); this.overallProgress.set(0); }, onQueue: function() { this.updateOverall(); }, onComplete: function() { this.status.removeClass('file-uploading'); if (this.size) { this.overallProgress.start(100); } else { this.overallProgress.set(0); this.currentProgress.set(0); } }, updateOverall: function() { this.overallTitle.set('html', MooTools.lang.get('FancyUpload', 'progressOverall').substitute({ total: Swiff.Uploader.formatUnit(this.size, 'b') })); if (!this.size) { this.currentTitle.set('html', MooTools.lang.get('FancyUpload', 'currentTitle')); this.currentText.set('html', ''); } }, /** * compat */ upload: function() { this.start(); }, removeFile: function() { return this.remove(); } }); FancyUpload2.File = new Class({ Extends: Swiff.Uploader.File, render: function() { if (this.invalid) { if (this.validationError) { var msg = MooTools.lang.get('FancyUpload', 'validationErrors')[this.validationError] || this.validationError; this.validationErrorMessage = msg.substitute({ name: this.name, size: Swiff.Uploader.formatUnit(this.size, 'b'), fileSizeMin: Swiff.Uploader.formatUnit(this.base.options.fileSizeMin || 0, 'b'), fileSizeMax: Swiff.Uploader.formatUnit(this.base.options.fileSizeMax || 0, 'b'), fileListMax: this.base.options.fileListMax || 0, fileListSizeMax: Swiff.Uploader.formatUnit(this.base.options.fileListSizeMax || 0, 'b') }); } this.remove(); return; } this.addEvents({ 'start': this.onStart, 'progress': this.onProgress, 'complete': this.onComplete, 'error': this.onError, 'remove': this.onRemove }); this.info = new Element('span', {'class': 'file-info'}); this.element = new Element('li', {'class': 'file'}).adopt( new Element('span', {'class': 'file-size', 'html': Swiff.Uploader.formatUnit(this.size, 'b')}), new Element('a', { 'class': 'file-remove', href: '#', html: MooTools.lang.get('FancyUpload', 'remove'), title: MooTools.lang.get('FancyUpload', 'removeTitle'), events: { click: function() { this.remove(); return false; }.bind(this) } }), new Element('span', {'class': 'file-name', 'html': MooTools.lang.get('FancyUpload', 'fileName').substitute(this)}), this.info ).inject(this.base.list); }, validate: function() { return (this.parent() && this.base.options.validateFile(this)); }, onStart: function() { this.element.addClass('file-uploading'); this.base.currentProgress.cancel().set(0); this.base.currentTitle.set('html', MooTools.lang.get('FancyUpload', 'currentFile').substitute(this)); }, onProgress: function() { this.base.overallProgress.start(this.base.percentLoaded); this.base.currentText.set('html', MooTools.lang.get('FancyUpload', 'currentProgress').substitute({ rate: (this.progress.rate) ? Swiff.Uploader.formatUnit(this.progress.rate, 'bps') : '- B', bytesLoaded: Swiff.Uploader.formatUnit(this.progress.bytesLoaded, 'b'), timeRemaining: (this.progress.timeRemaining) ? Swiff.Uploader.formatUnit(this.progress.timeRemaining, 's') : '-' })); this.base.currentProgress.start(this.progress.percentLoaded); }, onComplete: function() { this.element.removeClass('file-uploading'); this.base.currentText.set('html', 'Upload completed'); this.base.currentProgress.start(100); if (this.response.error) { var msg = MooTools.lang.get('FancyUpload', 'errors')[this.response.error] || '{error} #{code}'; this.errorMessage = msg.substitute($extend({ name: this.name, size: Swiff.Uploader.formatUnit(this.size, 'b') }, this.response)); var args = [this, this.errorMessage, this.response]; this.fireEvent('error', args).base.fireEvent('fileError', args); } else { this.base.fireEvent('fileSuccess', [this, this.response.text || '']); } }, onError: function() { this.element.addClass('file-failed'); var error = MooTools.lang.get('FancyUpload', 'fileError').substitute(this); this.info.set('html', '' + error + ': ' + this.errorMessage); }, onRemove: function() { this.element.getElements('a').setStyle('visibility', 'hidden'); this.element.fade('out').retrieve('tween').chain(Element.destroy.bind(Element, this.element)); } }); // Avoiding MooTools.lang dependency (function() { var phrases = { 'progressOverall': 'Overall Progress ({total})', 'currentTitle': 'File Progress', 'currentFile': 'Uploading "{name}"', 'currentProgress': 'Upload: {bytesLoaded} with {rate}, {timeRemaining} remaining.', 'fileName': '{name}', 'remove': 'Remove', 'removeTitle': 'Click to remove this entry.', 'fileError': 'Upload failed', 'validationErrors': { 'duplicate': 'File {name} is already added, duplicates are not allowed.', 'sizeLimitMin': 'File {name} ({size}) is too small, the minimal file size is {fileSizeMin}.', 'sizeLimitMax': 'File {name} ({size}) is too big, the maximal file size is {fileSizeMax}.', 'fileListMax': 'File {name} could not be added, amount of {fileListMax} files exceeded.', 'fileListSizeMax': 'File {name} ({size}) is too big, overall filesize of {fileListSizeMax} exceeded.' }, 'errors': { 'httpStatus': 'Server returned HTTP-Status #{code}', 'securityError': 'Security error occured ({text})', 'ioError': 'Error caused a send or load operation to fail ({text})' } }; if (MooTools.lang) { MooTools.lang.set('en-US', 'FancyUpload', phrases); } else { MooTools.lang = { get: function(from, key) { return phrases[key]; } }; } })();