Added Donns Fix for gain mill and bakery
[travianx.git] / uncrypt.js
blob289a842860037849946ae11854be8c76e5bf0853
1 var MooTools = {
2 version: "1.2.5",
3 build: "008d8f0f2fcc2044e54fdd3635341aaab274e757"
4 };
5 var Native = function (l) {
6 l = l || {};
7 var a = l.name;
8 var j = l.legacy;
9 var b = l.protect;
10 var c = l.implement;
11 var i = l.generics;
12 var g = l.initialize;
13 var h = l.afterImplement ||
14 function () {};
15 var d = g || j;
16 i = i !== false;
17 d.constructor = Native;
18 d.$family = {
19 name: "native"
21 if (j && g) {
22 d.prototype = j.prototype
24 d.prototype.constructor = d;
25 if (a) {
26 var f = a.toLowerCase();
27 d.prototype.$family = {
28 name: f
30 Native.typize(d, f)
32 var k = function (o, m, p, n) {
33 if (!b || n || !o.prototype[m]) {
34 o.prototype[m] = p
36 if (i) {
37 Native.genericize(o, m, b)
39 h.call(o, m, p);
40 return o
42 d.alias = function (o, m, q) {
43 if (typeof o == "string") {
44 var p = this.prototype[o];
45 if ((o = p)) {
46 return k(this, m, o, q)
49 for (var n in o) {
50 this.alias(n, o[n], m)
52 return this
54 d.implement = function (n, m, q) {
55 if (typeof n == "string") {
56 return k(this, n, m, q)
58 for (var o in n) {
59 k(this, o, n[o], m)
61 return this
63 if (c) {
64 d.implement(c)
66 return d
68 Native.genericize = function (b, c, a) {
69 if ((!a || !b[c]) && typeof b.prototype[c] == "function") {
70 b[c] = function () {
71 var d = Array.prototype.slice.call(arguments);
72 return b.prototype[c].apply(d.shift(), d)
76 Native.implement = function (d, c) {
77 for (var b = 0, a = d.length; b < a; b++) {
78 d[b].implement(c)
81 Native.typize = function (a, b) {
82 if (!a.type) {
83 a.type = function (c) {
84 return ($type(c) === b)
88 (function () {
89 var a = {
90 Array: Array,
91 Date: Date,
92 Function: Function,
93 Number: Number,
94 RegExp: RegExp,
95 String: String
97 for (var j in a) {
98 new Native({
99 name: j,
100 initialize: a[j],
101 protect: true
104 var d = {
105 "boolean": Boolean,
106 "native": Native,
107 object: Object
109 for (var c in d) {
110 Native.typize(d[c], c)
112 var h = {
113 Array: ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"],
114 String: ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"]
116 for (var f in h) {
117 for (var b = h[f].length; b--;) {
118 Native.genericize(a[f], h[f][b], true)
121 })();
122 var Hash = new Native({
123 name: "Hash",
124 initialize: function (a) {
125 if ($type(a) == "hash") {
126 a = $unlink(a.getClean())
128 for (var b in a) {
129 this[b] = a[b]
131 return this
134 Hash.implement({
135 forEach: function (b, c) {
136 for (var a in this) {
137 if (this.hasOwnProperty(a)) {
138 b.call(c, this[a], a, this)
142 getClean: function () {
143 var b = {};
144 for (var a in this) {
145 if (this.hasOwnProperty(a)) {
146 b[a] = this[a]
149 return b
151 getLength: function () {
152 var b = 0;
153 for (var a in this) {
154 if (this.hasOwnProperty(a)) {
158 return b
161 Hash.alias("forEach", "each");
162 Array.implement({
163 forEach: function (c, d) {
164 for (var b = 0, a = this.length; b < a; b++) {
165 c.call(d, this[b], b, this)
169 Array.alias("forEach", "each");
171 function $A(b) {
172 if (b.item) {
173 var a = b.length,
174 c = new Array(a);
175 while (a--) {
176 c[a] = b[a]
178 return c
180 return Array.prototype.slice.call(b)
182 function $arguments(a) {
183 return function () {
184 return arguments[a]
187 function $chk(a) {
188 return !!(a || a === 0)
190 function $clear(a) {
191 clearTimeout(a);
192 clearInterval(a);
193 return null
195 function $defined(a) {
196 return (a != undefined)
198 function $each(c, b, d) {
199 var a = $type(c);
200 ((a == "arguments" || a == "collection" || a == "array") ? Array : Hash).each(c, b, d)
202 function $empty() {}
203 function $extend(c, a) {
204 for (var b in (a || {})) {
205 c[b] = a[b]
207 return c
209 function $H(a) {
210 return new Hash(a)
212 function $lambda(a) {
213 return ($type(a) == "function") ? a : function () {
214 return a
217 function $merge() {
218 var a = Array.slice(arguments);
219 a.unshift({});
220 return $mixin.apply(null, a)
222 function $mixin(f) {
223 for (var d = 1, a = arguments.length; d < a; d++) {
224 var b = arguments[d];
225 if ($type(b) != "object") {
226 continue
228 for (var c in b) {
229 var h = b[c],
230 g = f[c];
231 f[c] = (g && $type(h) == "object" && $type(g) == "object") ? $mixin(g, h) : $unlink(h)
234 return f
236 function $pick() {
237 for (var b = 0, a = arguments.length; b < a; b++) {
238 if (arguments[b] != undefined) {
239 return arguments[b]
242 return null
244 function $random(b, a) {
245 return Math.floor(Math.random() * (a - b + 1) + b)
247 function $splat(b) {
248 var a = $type(b);
249 return (a) ? ((a != "array" && a != "arguments") ? [b] : b) : []
251 var $time = Date.now ||
252 function () {
253 return +new Date
256 function $try() {
257 for (var b = 0, a = arguments.length; b < a; b++) {
258 try {
259 return arguments[b]()
260 } catch (c) {}
262 return null
264 function $type(a) {
265 if (a == undefined) {
266 return false
268 if (a.$family) {
269 return (a.$family.name == "number" && !isFinite(a)) ? false : a.$family.name
271 if (a.nodeName) {
272 switch (a.nodeType) {
273 case 1:
274 return "element";
275 case 3:
276 return (/\S/).test(a.nodeValue) ? "textnode" : "whitespace"
278 } else {
279 if (typeof a.length == "number") {
280 if (a.callee) {
281 return "arguments"
282 } else {
283 if (a.item) {
284 return "collection"
289 return typeof a
291 function $unlink(c) {
292 var b;
293 switch ($type(c)) {
294 case "object":
295 b = {};
296 for (var f in c) {
297 b[f] = $unlink(c[f])
299 break;
300 case "hash":
301 b = new Hash(c);
302 break;
303 case "array":
304 b = [];
305 for (var d = 0, a = c.length; d < a; d++) {
306 b[d] = $unlink(c[d])
308 break;
309 default:
310 return c
312 return b
314 Array.implement({
315 every: function (c, d) {
316 for (var b = 0, a = this.length; b < a; b++) {
317 if (!c.call(d, this[b], b, this)) {
318 return false
321 return true
323 filter: function (d, f) {
324 var c = [];
325 for (var b = 0, a = this.length; b < a; b++) {
326 if (d.call(f, this[b], b, this)) {
327 c.push(this[b])
330 return c
332 clean: function () {
333 return this.filter($defined)
335 indexOf: function (c, d) {
336 var a = this.length;
337 for (var b = (d < 0) ? Math.max(0, a + d) : d || 0; b < a; b++) {
338 if (this[b] === c) {
339 return b
342 return -1
344 map: function (d, f) {
345 var c = [];
346 for (var b = 0, a = this.length; b < a; b++) {
347 c[b] = d.call(f, this[b], b, this)
349 return c
351 some: function (c, d) {
352 for (var b = 0, a = this.length; b < a; b++) {
353 if (c.call(d, this[b], b, this)) {
354 return true
357 return false
359 associate: function (c) {
360 var d = {},
361 b = Math.min(this.length, c.length);
362 for (var a = 0; a < b; a++) {
363 d[c[a]] = this[a]
365 return d
367 link: function (c) {
368 var a = {};
369 for (var f = 0, b = this.length; f < b; f++) {
370 for (var d in c) {
371 if (c[d](this[f])) {
372 a[d] = this[f];
373 delete c[d];
374 break
378 return a
380 contains: function (a, b) {
381 return this.indexOf(a, b) != -1
383 extend: function (c) {
384 for (var b = 0, a = c.length; b < a; b++) {
385 this.push(c[b])
387 return this
389 getLast: function () {
390 return (this.length) ? this[this.length - 1] : null
392 getRandom: function () {
393 return (this.length) ? this[$random(0, this.length - 1)] : null
395 include: function (a) {
396 if (!this.contains(a)) {
397 this.push(a)
399 return this
401 combine: function (c) {
402 for (var b = 0, a = c.length; b < a; b++) {
403 this.include(c[b])
405 return this
407 erase: function (b) {
408 for (var a = this.length; a--; a) {
409 if (this[a] === b) {
410 this.splice(a, 1)
413 return this
415 empty: function () {
416 this.length = 0;
417 return this
419 flatten: function () {
420 var d = [];
421 for (var b = 0, a = this.length; b < a; b++) {
422 var c = $type(this[b]);
423 if (!c) {
424 continue
426 d = d.concat((c == "array" || c == "collection" || c == "arguments") ? Array.flatten(this[b]) : this[b])
428 return d
430 hexToRgb: function (b) {
431 if (this.length != 3) {
432 return null
434 var a = this.map(function (c) {
435 if (c.length == 1) {
436 c += c
438 return c.toInt(16)
440 return (b) ? a : "rgb(" + a + ")"
442 rgbToHex: function (d) {
443 if (this.length < 3) {
444 return null
446 if (this.length == 4 && this[3] == 0 && !d) {
447 return "transparent"
449 var b = [];
450 for (var a = 0; a < 3; a++) {
451 var c = (this[a] - 0).toString(16);
452 b.push((c.length == 1) ? "0" + c : c)
454 return (d) ? b : "#" + b.join("")
457 String.implement({
458 test: function (a, b) {
459 return ((typeof a == "string") ? new RegExp(a, b) : a).test(this)
461 contains: function (a, b) {
462 return (b) ? (b + this + b).indexOf(b + a + b) > -1 : this.indexOf(a) > -1
464 trim: function () {
465 return this.replace(/^\s+|\s+$/g, "")
467 clean: function () {
468 return this.replace(/\s+/g, " ").trim()
470 camelCase: function () {
471 return this.replace(/-\D/g, function (a) {
472 return a.charAt(1).toUpperCase()
475 hyphenate: function () {
476 return this.replace(/[A-Z]/g, function (a) {
477 return ("-" + a.charAt(0).toLowerCase())
480 capitalize: function () {
481 return this.replace(/\b[a-z]/g, function (a) {
482 return a.toUpperCase()
485 escapeRegExp: function () {
486 return this.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1")
488 toInt: function (a) {
489 return parseInt(this, a || 10)
491 toFloat: function () {
492 return parseFloat(this)
494 hexToRgb: function (b) {
495 var a = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
496 return (a) ? a.slice(1).hexToRgb(b) : null
498 rgbToHex: function (b) {
499 var a = this.match(/\d{1,3}/g);
500 return (a) ? a.rgbToHex(b) : null
502 stripScripts: function (b) {
503 var a = "";
504 var c = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function () {
505 a += arguments[1] + "\n";
506 return ""
508 if (b === true) {
509 $exec(a)
510 } else {
511 if ($type(b) == "function") {
512 b(a, c)
515 return c
517 substitute: function (a, b) {
518 return this.replace(b || (/\\?\{([^{}]+)\}/g), function (d, c) {
519 if (d.charAt(0) == "\\") {
520 return d.slice(1)
522 return (a[c] != undefined) ? a[c] : ""
526 try {
527 delete Function.prototype.bind
528 } catch (e) {}
529 Function.implement({
530 extend: function (a) {
531 for (var b in a) {
532 this[b] = a[b]
534 return this
536 create: function (b) {
537 var a = this;
538 b = b || {};
539 return function (d) {
540 var c = b.arguments;
541 c = (c != undefined) ? $splat(c) : Array.slice(arguments, (b.event) ? 1 : 0);
542 if (b.event) {
543 c = [d || window.event].extend(c)
545 var f = function () {
546 return a.apply(b.bind || null, c)
548 if (b.delay) {
549 return setTimeout(f, b.delay)
551 if (b.periodical) {
552 return setInterval(f, b.periodical)
554 if (b.attempt) {
555 return $try(f)
557 return f()
560 run: function (a, b) {
561 return this.apply(b, $splat(a))
563 pass: function (a, b) {
564 return this.create({
565 bind: b,
566 arguments: a
569 bind: function (b, a) {
570 return this.create({
571 bind: b,
572 arguments: a
575 bindWithEvent: function (b, a) {
576 return this.create({
577 bind: b,
578 arguments: a,
579 event: true
582 attempt: function (a, b) {
583 return this.create({
584 bind: b,
585 arguments: a,
586 attempt: true
587 })()
589 delay: function (b, c, a) {
590 return this.create({
591 bind: c,
592 arguments: a,
593 delay: b
594 })()
596 periodical: function (c, b, a) {
597 return this.create({
598 bind: b,
599 arguments: a,
600 periodical: c
601 })()
604 Number.implement({
605 limit: function (b, a) {
606 return Math.min(a, Math.max(b, this))
608 round: function (a) {
609 a = Math.pow(10, a || 0);
610 return Math.round(this * a) / a
612 times: function (b, c) {
613 for (var a = 0; a < this; a++) {
614 b.call(c, a, this)
617 toFloat: function () {
618 return parseFloat(this)
620 toInt: function (a) {
621 return parseInt(this, a || 10)
624 Number.alias("times", "each");
625 (function (b) {
626 var a = {};
627 b.each(function (c) {
628 if (!Number[c]) {
629 a[c] = function () {
630 return Math[c].apply(null, [this].concat($A(arguments)))
634 Number.implement(a)
635 })(["abs", "acos", "asin", "atan", "atan2", "ceil", "cos", "exp", "floor", "log", "max", "min", "pow", "sin", "sqrt", "tan"]);
636 Hash.implement({
637 has: Object.prototype.hasOwnProperty,
638 keyOf: function (b) {
639 for (var a in this) {
640 if (this.hasOwnProperty(a) && this[a] === b) {
641 return a
644 return null
646 hasValue: function (a) {
647 return (Hash.keyOf(this, a) !== null)
649 extend: function (a) {
650 Hash.each(a || {}, function (c, b) {
651 Hash.set(this, b, c)
652 }, this);
653 return this
655 combine: function (a) {
656 Hash.each(a || {}, function (c, b) {
657 Hash.include(this, b, c)
658 }, this);
659 return this
661 erase: function (a) {
662 if (this.hasOwnProperty(a)) {
663 delete this[a]
665 return this
667 get: function (a) {
668 return (this.hasOwnProperty(a)) ? this[a] : null
670 set: function (a, b) {
671 if (!this[a] || this.hasOwnProperty(a)) {
672 this[a] = b
674 return this
676 empty: function () {
677 Hash.each(this, function (b, a) {
678 delete this[a]
679 }, this);
680 return this
682 include: function (a, b) {
683 if (this[a] == undefined) {
684 this[a] = b
686 return this
688 map: function (b, c) {
689 var a = new Hash;
690 Hash.each(this, function (f, d) {
691 a.set(d, b.call(c, f, d, this))
692 }, this);
693 return a
695 filter: function (b, c) {
696 var a = new Hash;
697 Hash.each(this, function (f, d) {
698 if (b.call(c, f, d, this)) {
699 a.set(d, f)
701 }, this);
702 return a
704 every: function (b, c) {
705 for (var a in this) {
706 if (this.hasOwnProperty(a) && !b.call(c, this[a], a)) {
707 return false
710 return true
712 some: function (b, c) {
713 for (var a in this) {
714 if (this.hasOwnProperty(a) && b.call(c, this[a], a)) {
715 return true
718 return false
720 getKeys: function () {
721 var a = [];
722 Hash.each(this, function (c, b) {
723 a.push(b)
725 return a
727 getValues: function () {
728 var a = [];
729 Hash.each(this, function (b) {
730 a.push(b)
732 return a
734 toQueryString: function (a) {
735 var b = [];
736 Hash.each(this, function (g, f) {
737 if (a) {
738 f = a + "[" + f + "]"
740 var d;
741 switch ($type(g)) {
742 case "object":
743 d = Hash.toQueryString(g, f);
744 break;
745 case "array":
746 var c = {};
747 g.each(function (j, h) {
748 c[h] = j
750 d = Hash.toQueryString(c, f);
751 break;
752 default:
753 d = f + "=" + encodeURIComponent(g)
755 if (g != undefined) {
756 b.push(d)
759 return b.join("&")
762 Hash.alias({
763 keyOf: "indexOf",
764 hasValue: "contains"
767 function Class(b) {
768 if (b instanceof Function) {
769 b = {
770 initialize: b
773 var a = function () {
774 Object.reset(this);
775 if (a._prototyping) {
776 return this
778 this._current = $empty;
779 var c = (this.initialize) ? this.initialize.apply(this, arguments) : this;
780 delete this._current;
781 delete this.caller;
782 return c
783 }.extend(this);
784 a.implement(b);
785 a.constructor = Class;
786 a.prototype.constructor = a;
787 return a
789 Function.prototype.protect = function () {
790 this._protected = true;
791 return this
793 Object.reset = function (a, c) {
794 if (c == null) {
795 for (var f in a) {
796 Object.reset(a, f)
798 return a
800 delete a[c];
801 switch ($type(a[c])) {
802 case "object":
803 var d = function () {};
804 d.prototype = a[c];
805 var b = new d;
806 a[c] = Object.reset(b);
807 break;
808 case "array":
809 a[c] = $unlink(a[c]);
810 break
812 return a
814 new Native({
815 name: "Class",
816 initialize: Class
817 }).extend({
818 instantiate: function (b) {
819 b._prototyping = true;
820 var a = new b;
821 delete b._prototyping;
822 return a
824 wrap: function (a, b, c) {
825 if (c._origin) {
826 c = c._origin
828 return function () {
829 if (c._protected && this._current == null) {
830 throw new Error('The method "' + b + '" cannot be called.')
832 var f = this.caller,
833 g = this._current;
834 this.caller = g;
835 this._current = arguments.callee;
836 var d = c.apply(this, arguments);
837 this._current = g;
838 this.caller = f;
839 return d
840 }.extend({
841 _owner: a,
842 _origin: c,
843 _name: b
847 Class.implement({
848 implement: function (a, d) {
849 if ($type(a) == "object") {
850 for (var f in a) {
851 this.implement(f, a[f])
853 return this
855 var g = Class.Mutators[a];
856 if (g) {
857 d = g.call(this, d);
858 if (d == null) {
859 return this
862 var c = this.prototype;
863 switch ($type(d)) {
864 case "function":
865 if (d._hidden) {
866 return this
868 c[a] = Class.wrap(this, a, d);
869 break;
870 case "object":
871 var b = c[a];
872 if ($type(b) == "object") {
873 $mixin(b, d)
874 } else {
875 c[a] = $unlink(d)
877 break;
878 case "array":
879 c[a] = $unlink(d);
880 break;
881 default:
882 c[a] = d
884 return this
887 Class.Mutators = {
888 Extends: function (a) {
889 this.parent = a;
890 this.prototype = Class.instantiate(a);
891 this.implement("parent", function () {
892 var b = this.caller._name,
893 c = this.caller._owner.parent.prototype[b];
894 if (!c) {
895 throw new Error('The method "' + b + '" has no parent.')
897 return c.apply(this, arguments)
898 }.protect())
900 Implements: function (a) {
901 $splat(a).each(function (b) {
902 if (b instanceof Function) {
903 b = Class.instantiate(b)
905 this.implement(b)
906 }, this)
909 var Chain = new Class({
910 $chain: [],
911 chain: function () {
912 this.$chain.extend(Array.flatten(arguments));
913 return this
915 callChain: function () {
916 return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false
918 clearChain: function () {
919 this.$chain.empty();
920 return this
923 var Events = new Class({
924 $events: {},
925 addEvent: function (c, b, a) {
926 c = Events.removeOn(c);
927 if (b != $empty) {
928 this.$events[c] = this.$events[c] || [];
929 this.$events[c].include(b);
930 if (a) {
931 b.internal = true
934 return this
936 addEvents: function (a) {
937 for (var b in a) {
938 this.addEvent(b, a[b])
940 return this
942 fireEvent: function (c, b, a) {
943 c = Events.removeOn(c);
944 if (!this.$events || !this.$events[c]) {
945 return this
947 this.$events[c].each(function (d) {
948 d.create({
949 bind: this,
950 delay: a,
951 "arguments": b
952 })()
953 }, this);
954 return this
956 removeEvent: function (b, a) {
957 b = Events.removeOn(b);
958 if (!this.$events[b]) {
959 return this
961 if (!a.internal) {
962 this.$events[b].erase(a)
964 return this
966 removeEvents: function (c) {
967 var d;
968 if ($type(c) == "object") {
969 for (d in c) {
970 this.removeEvent(d, c[d])
972 return this
974 if (c) {
975 c = Events.removeOn(c)
977 for (d in this.$events) {
978 if (c && c != d) {
979 continue
981 var b = this.$events[d];
982 for (var a = b.length; a--; a) {
983 this.removeEvent(d, b[a])
986 return this
989 Events.removeOn = function (a) {
990 return a.replace(/^on([A-Z])/, function (b, c) {
991 return c.toLowerCase()
994 var Options = new Class({
995 setOptions: function () {
996 this.options = $merge.run([this.options].extend(arguments));
997 if (!this.addEvent) {
998 return this
1000 for (var a in this.options) {
1001 if ($type(this.options[a]) != "function" || !(/^on[A-Z]/).test(a)) {
1002 continue
1004 this.addEvent(a, this.options[a]);
1005 delete this.options[a]
1007 return this
1010 var Browser = $merge({
1011 Engine: {
1012 name: "unknown",
1013 version: 0
1015 Platform: {
1016 name: (window.orientation != undefined) ? "ipod" : (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase()
1018 Features: {
1019 xpath: !! (document.evaluate),
1020 air: !! (window.runtime),
1021 query: !! (document.querySelector)
1023 Plugins: {},
1024 Engines: {
1025 presto: function () {
1026 return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925))
1028 trident: function () {
1029 return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4)
1031 webkit: function () {
1032 return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419)
1034 gecko: function () {
1035 return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18)
1038 }, Browser || {});
1039 Browser.Platform[Browser.Platform.name] = true;
1040 Browser.detect = function () {
1041 for (var b in this.Engines) {
1042 var a = this.Engines[b]();
1043 if (a) {
1044 this.Engine = {
1045 name: b,
1046 version: a
1048 this.Engine[b] = this.Engine[b + a] = true;
1049 break
1052 return {
1053 name: b,
1054 version: a
1057 Browser.detect();
1058 Browser.Request = function () {
1059 return $try(function () {
1060 return new XMLHttpRequest()
1061 }, function () {
1062 return new ActiveXObject("MSXML2.XMLHTTP")
1063 }, function () {
1064 return new ActiveXObject("Microsoft.XMLHTTP")
1067 Browser.Features.xhr = !! (Browser.Request());
1068 Browser.Plugins.Flash = (function () {
1069 var a = ($try(function () {
1070 return navigator.plugins["Shockwave Flash"].description
1071 }, function () {
1072 return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")
1073 }) || "0 r0").match(/\d+/g);
1074 return {
1075 version: parseInt(a[0] || 0 + "." + a[1], 10) || 0,
1076 build: parseInt(a[2], 10) || 0
1078 })();
1080 function $exec(b) {
1081 if (!b) {
1082 return b
1084 if (window.execScript) {
1085 window.execScript(b)
1086 } else {
1087 var a = document.createElement("script");
1088 a.setAttribute("type", "text/javascript");
1089 a[(Browser.Engine.webkit && Browser.Engine.version < 420) ? "innerText" : "text"] = b;
1090 document.head.appendChild(a);
1091 document.head.removeChild(a)
1093 return b
1095 Native.UID = 1;
1096 var $uid = (Browser.Engine.trident) ?
1097 function (a) {
1098 return (a.uid || (a.uid = [Native.UID++]))[0]
1099 } : function (a) {
1100 return a.uid || (a.uid = Native.UID++)
1102 var Window = new Native({
1103 name: "Window",
1104 legacy: (Browser.Engine.trident) ? null : window.Window,
1105 initialize: function (a) {
1106 $uid(a);
1107 if (!a.Element) {
1108 a.Element = $empty;
1109 if (Browser.Engine.webkit) {
1110 a.document.createElement("iframe")
1112 a.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {}
1114 a.document.window = a;
1115 return $extend(a, Window.Prototype)
1117 afterImplement: function (b, a) {
1118 window[b] = Window.Prototype[b] = a
1121 Window.Prototype = {
1122 $family: {
1123 name: "window"
1126 new Window(window);
1127 var Document = new Native({
1128 name: "Document",
1129 legacy: (Browser.Engine.trident) ? null : window.Document,
1130 initialize: function (a) {
1131 $uid(a);
1132 a.head = a.getElementsByTagName("head")[0];
1133 a.html = a.getElementsByTagName("html")[0];
1134 if (Browser.Engine.trident && Browser.Engine.version <= 4) {
1135 $try(function () {
1136 a.execCommand("BackgroundImageCache", false, true)
1139 if (Browser.Engine.trident) {
1140 a.window.attachEvent("onunload", function () {
1141 a.window.detachEvent("onunload", arguments.callee);
1142 a.head = a.html = a.window = null
1145 return $extend(a, Document.Prototype)
1147 afterImplement: function (b, a) {
1148 document[b] = Document.Prototype[b] = a
1151 Document.Prototype = {
1152 $family: {
1153 name: "document"
1156 new Document(document);
1157 var Element = new Native({
1158 name: "Element",
1159 legacy: window.Element,
1160 initialize: function (a, b) {
1161 var c = Element.Constructors.get(a);
1162 if (c) {
1163 return c(b)
1165 if (typeof a == "string") {
1166 return document.newElement(a, b)
1168 return document.id(a).set(b)
1170 afterImplement: function (a, b) {
1171 Element.Prototype[a] = b;
1172 if (Array[a]) {
1173 return
1175 Elements.implement(a, function () {
1176 var c = [],
1177 h = true;
1178 for (var f = 0, d = this.length; f < d; f++) {
1179 var g = this[f][a].apply(this[f], arguments);
1180 c.push(g);
1181 if (h) {
1182 h = ($type(g) == "element")
1185 return (h) ? new Elements(c) : c
1189 Element.Prototype = {
1190 $family: {
1191 name: "element"
1194 Element.Constructors = new Hash;
1195 var IFrame = new Native({
1196 name: "IFrame",
1197 generics: false,
1198 initialize: function () {
1199 var g = Array.link(arguments, {
1200 properties: Object.type,
1201 iframe: $defined
1203 var d = g.properties || {};
1204 var c = document.id(g.iframe);
1205 var f = d.onload || $empty;
1206 delete d.onload;
1207 d.id = d.name = $pick(d.id, d.name, c ? (c.id || c.name) : "IFrame_" + $time());
1208 c = new Element(c || "iframe", d);
1209 var b = function () {
1210 var h = $try(function () {
1211 return c.contentWindow.location.host
1213 if (!h || h == window.location.host) {
1214 var i = new Window(c.contentWindow);
1215 new Document(c.contentWindow.document);
1216 $extend(i.Element.prototype, Element.Prototype)
1218 f.call(c.contentWindow, c.contentWindow.document)
1220 var a = $try(function () {
1221 return c.contentWindow
1223 ((a && a.document.body) || window.frames[d.id]) ? b() : c.addListener("load", b);
1224 return c
1227 var Elements = new Native({
1228 initialize: function (g, b) {
1229 b = $extend({
1230 ddup: true,
1231 cash: true
1232 }, b);
1233 g = g || [];
1234 if (b.ddup || b.cash) {
1235 var h = {},
1236 f = [];
1237 for (var c = 0, a = g.length; c < a; c++) {
1238 var d = document.id(g[c], !b.cash);
1239 if (b.ddup) {
1240 if (h[d.uid]) {
1241 continue
1243 h[d.uid] = true
1245 if (d) {
1246 f.push(d)
1249 g = f
1251 return (b.cash) ? $extend(g, this) : g
1254 Elements.implement({
1255 filter: function (a, b) {
1256 if (!a) {
1257 return this
1259 return new Elements(Array.filter(this, (typeof a == "string") ?
1260 function (c) {
1261 return c.match(a)
1262 } : a, b))
1265 (function () {
1266 var d;
1267 try {
1268 var a = document.createElement("<input name=x>");
1269 d = (a.name == "x")
1270 } catch (b) {}
1271 var c = function (f) {
1272 return ("" + f).replace(/&/g, "&amp;").replace(/"/g, "&quot;")
1274 Document.implement({
1275 newElement: function (f, g) {
1276 if (g && g.checked != null) {
1277 g.defaultChecked = g.checked
1279 if (d && g) {
1280 f = "<" + f;
1281 if (g.name) {
1282 f += ' name="' + c(g.name) + '"'
1284 if (g.type) {
1285 f += ' type="' + c(g.type) + '"'
1287 f += ">";
1288 delete g.name;
1289 delete g.type
1291 return this.id(this.createElement(f)).set(g)
1293 newTextNode: function (f) {
1294 return this.createTextNode(f)
1296 getDocument: function () {
1297 return this
1299 getWindow: function () {
1300 return this.window
1302 id: (function () {
1303 var f = {
1304 string: function (i, h, g) {
1305 i = g.getElementById(i);
1306 return (i) ? f.element(i, h) : null
1308 element: function (g, j) {
1309 $uid(g);
1310 if (!j && !g.$family && !(/^object|embed$/i).test(g.tagName)) {
1311 var h = Element.Prototype;
1312 for (var i in h) {
1313 g[i] = h[i]
1316 return g
1318 object: function (h, i, g) {
1319 if (h.toElement) {
1320 return f.element(h.toElement(g), i)
1322 return null
1325 f.textnode = f.whitespace = f.window = f.document = $arguments(0);
1326 return function (h, j, i) {
1327 if (h && h.$family && h.uid) {
1328 return h
1330 var g = $type(h);
1331 return (f[g]) ? f[g](h, j, i || document) : null
1333 })()
1335 })();
1336 if (window.$ == null) {
1337 Window.implement({
1338 $: function (a, b) {
1339 return document.id(a, b, this.document)
1343 Window.implement({
1344 $$: function (a) {
1345 if (arguments.length == 1 && typeof a == "string") {
1346 return this.document.getElements(a)
1348 var g = [];
1349 var c = Array.flatten(arguments);
1350 for (var d = 0, b = c.length; d < b; d++) {
1351 var f = c[d];
1352 switch ($type(f)) {
1353 case "element":
1354 g.push(f);
1355 break;
1356 case "string":
1357 g.extend(this.document.getElements(f, true))
1360 return new Elements(g)
1362 getDocument: function () {
1363 return this.document
1365 getWindow: function () {
1366 return this
1369 Native.implement([Element, Document], {
1370 getElement: function (a, b) {
1371 return document.id(this.getElements(a, true)[0] || null, b)
1373 getElements: function (a, d) {
1374 a = a.split(",");
1375 var c = [];
1376 var b = (a.length > 1);
1377 a.each(function (f) {
1378 var g = this.getElementsByTagName(f.trim());
1379 (b) ? c.extend(g) : c = g
1380 }, this);
1381 return new Elements(c, {
1382 ddup: b,
1383 cash: !d
1387 (function () {
1388 var i = {},
1389 g = {};
1390 var j = {
1391 input: "checked",
1392 option: "selected",
1393 textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? "innerHTML" : "value"
1395 var c = function (m) {
1396 return (g[m] || (g[m] = {}))
1398 var h = function (o, m) {
1399 if (!o) {
1400 return
1402 var n = o.uid;
1403 if (m !== true) {
1404 m = false
1406 if (Browser.Engine.trident) {
1407 if (o.clearAttributes) {
1408 var r = m && o.cloneNode(false);
1409 o.clearAttributes();
1410 if (r) {
1411 o.mergeAttributes(r)
1413 } else {
1414 if (o.removeEvents) {
1415 o.removeEvents()
1418 if ((/object/i).test(o.tagName)) {
1419 for (var q in o) {
1420 if (typeof o[q] == "function") {
1421 o[q] = $empty
1424 Element.dispose(o)
1427 if (!n) {
1428 return
1430 i[n] = g[n] = null
1432 var d = function () {
1433 Hash.each(i, h);
1434 if (Browser.Engine.trident) {
1435 $A(document.getElementsByTagName("object")).each(h)
1437 if (window.CollectGarbage) {
1438 CollectGarbage()
1440 i = g = null
1442 var k = function (o, m, t, n, q, s) {
1443 var p = o[t || m];
1444 var r = [];
1445 while (p) {
1446 if (p.nodeType == 1 && (!n || Element.match(p, n))) {
1447 if (!q) {
1448 return document.id(p, s)
1450 r.push(p)
1452 p = p[m]
1454 return (q) ? new Elements(r, {
1455 ddup: false,
1456 cash: !s
1457 }) : null
1459 var f = {
1460 html: "innerHTML",
1461 "class": "className",
1462 "for": "htmlFor",
1463 defaultValue: "defaultValue",
1464 text: (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? "innerText" : "textContent"
1466 var b = ["compact", "nowrap", "ismap", "declare", "noshade", "checked", "disabled", "readonly", "multiple", "selected", "noresize", "defer"];
1467 var l = ["value", "type", "defaultValue", "accessKey", "cellPadding", "cellSpacing", "colSpan", "frameBorder", "maxLength", "readOnly", "rowSpan", "tabIndex", "useMap"];
1468 b = b.associate(b);
1469 Hash.extend(f, b);
1470 Hash.extend(f, l.associate(l.map(String.toLowerCase)));
1471 var a = {
1472 before: function (n, m) {
1473 if (m.parentNode) {
1474 m.parentNode.insertBefore(n, m)
1477 after: function (n, m) {
1478 if (!m.parentNode) {
1479 return
1481 var o = m.nextSibling;
1482 (o) ? m.parentNode.insertBefore(n, o) : m.parentNode.appendChild(n)
1484 bottom: function (n, m) {
1485 m.appendChild(n)
1487 top: function (n, m) {
1488 var o = m.firstChild;
1489 (o) ? m.insertBefore(n, o) : m.appendChild(n)
1492 a.inside = a.bottom;
1493 Hash.each(a, function (m, n) {
1494 n = n.capitalize();
1495 Element.implement("inject" + n, function (o) {
1496 m(this, document.id(o, true));
1497 return this
1499 Element.implement("grab" + n, function (o) {
1500 m(document.id(o, true), this);
1501 return this
1504 Element.implement({
1505 set: function (q, n) {
1506 switch ($type(q)) {
1507 case "object":
1508 for (var o in q) {
1509 this.set(o, q[o])
1511 break;
1512 case "string":
1513 var m = Element.Properties.get(q);
1514 (m && m.set) ? m.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(q, n)
1516 return this
1518 get: function (n) {
1519 var m = Element.Properties.get(n);
1520 return (m && m.get) ? m.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(n)
1522 erase: function (n) {
1523 var m = Element.Properties.get(n);
1524 (m && m.erase) ? m.erase.apply(this) : this.removeProperty(n);
1525 return this
1527 setProperty: function (n, o) {
1528 var m = f[n];
1529 if (o == undefined) {
1530 return this.removeProperty(n)
1532 if (m && b[n]) {
1533 o = !! o
1534 }(m) ? this[m] = o : this.setAttribute(n, "" + o);
1535 return this
1537 setProperties: function (m) {
1538 for (var n in m) {
1539 this.setProperty(n, m[n])
1541 return this
1543 getProperty: function (n) {
1544 var m = f[n];
1545 var o = (m) ? this[m] : this.getAttribute(n, 2);
1546 return (b[n]) ? !! o : (m) ? o : o || null
1548 getProperties: function () {
1549 var m = $A(arguments);
1550 return m.map(this.getProperty, this).associate(m)
1552 removeProperty: function (n) {
1553 var m = f[n];
1554 (m) ? this[m] = (m && b[n]) ? false : "" : this.removeAttribute(n);
1555 return this
1557 removeProperties: function () {
1558 Array.each(arguments, this.removeProperty, this);
1559 return this
1561 hasClass: function (m) {
1562 return this.className.contains(m, " ")
1564 addClass: function (m) {
1565 if (!this.hasClass(m)) {
1566 this.className = (this.className + " " + m).clean()
1568 return this
1570 removeClass: function (m) {
1571 this.className = this.className.replace(new RegExp("(^|\\s)" + m + "(?:\\s|$)"), "$1");
1572 return this
1574 toggleClass: function (m) {
1575 return this.hasClass(m) ? this.removeClass(m) : this.addClass(m)
1577 adopt: function () {
1578 Array.flatten(arguments).each(function (m) {
1579 m = document.id(m, true);
1580 if (m) {
1581 this.appendChild(m)
1583 }, this);
1584 return this
1586 appendText: function (n, m) {
1587 return this.grab(this.getDocument().newTextNode(n), m)
1589 grab: function (n, m) {
1590 a[m || "bottom"](document.id(n, true), this);
1591 return this
1593 inject: function (n, m) {
1594 a[m || "bottom"](this, document.id(n, true));
1595 return this
1597 replaces: function (m) {
1598 m = document.id(m, true);
1599 m.parentNode.replaceChild(this, m);
1600 return this
1602 wraps: function (n, m) {
1603 n = document.id(n, true);
1604 return this.replaces(n).grab(n, m)
1606 getPrevious: function (m, n) {
1607 return k(this, "previousSibling", null, m, false, n)
1609 getAllPrevious: function (m, n) {
1610 return k(this, "previousSibling", null, m, true, n)
1612 getNext: function (m, n) {
1613 return k(this, "nextSibling", null, m, false, n)
1615 getAllNext: function (m, n) {
1616 return k(this, "nextSibling", null, m, true, n)
1618 getFirst: function (m, n) {
1619 return k(this, "nextSibling", "firstChild", m, false, n)
1621 getLast: function (m, n) {
1622 return k(this, "previousSibling", "lastChild", m, false, n)
1624 getParent: function (m, n) {
1625 return k(this, "parentNode", null, m, false, n)
1627 getParents: function (m, n) {
1628 return k(this, "parentNode", null, m, true, n)
1630 getSiblings: function (m, n) {
1631 return this.getParent().getChildren(m, n).erase(this)
1633 getChildren: function (m, n) {
1634 return k(this, "nextSibling", "firstChild", m, true, n)
1636 getWindow: function () {
1637 return this.ownerDocument.window
1639 getDocument: function () {
1640 return this.ownerDocument
1642 getElementById: function (p, o) {
1643 var n = this.ownerDocument.getElementById(p);
1644 if (!n) {
1645 return null
1647 for (var m = n.parentNode; m != this; m = m.parentNode) {
1648 if (!m) {
1649 return null
1652 return document.id(n, o)
1654 getSelected: function () {
1655 return new Elements($A(this.options).filter(function (m) {
1656 return m.selected
1659 getComputedStyle: function (n) {
1660 if (this.currentStyle) {
1661 return this.currentStyle[n.camelCase()]
1663 var m = this.getDocument().defaultView.getComputedStyle(this, null);
1664 return (m) ? m.getPropertyValue([n.hyphenate()]) : null
1666 toQueryString: function () {
1667 var m = [];
1668 this.getElements("input, select, textarea", true).each(function (n) {
1669 if (!n.name || n.disabled || n.type == "submit" || n.type == "reset" || n.type == "file") {
1670 return
1672 var o = (n.tagName.toLowerCase() == "select") ? Element.getSelected(n).map(function (p) {
1673 return p.value
1674 }) : ((n.type == "radio" || n.type == "checkbox") && !n.checked) ? null : n.value;
1675 $splat(o).each(function (p) {
1676 if (typeof p != "undefined") {
1677 m.push(n.name + "=" + encodeURIComponent(p))
1681 return m.join("&")
1683 clone: function (p, m) {
1684 p = p !== false;
1685 var s = this.cloneNode(p);
1686 var o = function (w, v) {
1687 if (!m) {
1688 w.removeAttribute("id")
1690 if (Browser.Engine.trident) {
1691 w.clearAttributes();
1692 w.mergeAttributes(v);
1693 w.removeAttribute("uid");
1694 if (w.options) {
1695 var x = w.options,
1696 t = v.options;
1697 for (var u = x.length; u--;) {
1698 x[u].selected = t[u].selected
1702 var y = j[v.tagName.toLowerCase()];
1703 if (y && v[y]) {
1704 w[y] = v[y]
1707 if (p) {
1708 var q = s.getElementsByTagName("*"),
1709 r = this.getElementsByTagName("*");
1710 for (var n = q.length; n--;) {
1711 o(q[n], r[n])
1714 o(s, this);
1715 return document.id(s)
1717 destroy: function () {
1718 Element.empty(this);
1719 Element.dispose(this);
1720 h(this, true);
1721 return null
1723 empty: function () {
1724 $A(this.childNodes).each(function (m) {
1725 Element.destroy(m)
1727 return this
1729 dispose: function () {
1730 return (this.parentNode) ? this.parentNode.removeChild(this) : this
1732 hasChild: function (m) {
1733 m = document.id(m, true);
1734 if (!m) {
1735 return false
1737 if (Browser.Engine.webkit && Browser.Engine.version < 420) {
1738 return $A(this.getElementsByTagName(m.tagName)).contains(m)
1740 return (this.contains) ? (this != m && this.contains(m)) : !! (this.compareDocumentPosition(m) & 16)
1742 match: function (m) {
1743 return (!m || (m == this) || (Element.get(this, "tag") == m))
1746 Native.implement([Element, Window, Document], {
1747 addListener: function (p, o) {
1748 if (p == "unload") {
1749 var m = o,
1750 n = this;
1751 o = function () {
1752 n.removeListener("unload", o);
1755 } else {
1756 i[this.uid] = this
1758 if (this.addEventListener) {
1759 this.addEventListener(p, o, false)
1760 } else {
1761 this.attachEvent("on" + p, o)
1763 return this
1765 removeListener: function (n, m) {
1766 if (this.removeEventListener) {
1767 this.removeEventListener(n, m, false)
1768 } else {
1769 this.detachEvent("on" + n, m)
1771 return this
1773 retrieve: function (n, m) {
1774 var p = c(this.uid),
1775 o = p[n];
1776 if (m != undefined && o == undefined) {
1777 o = p[n] = m
1779 return $pick(o)
1781 store: function (n, m) {
1782 var o = c(this.uid);
1783 o[n] = m;
1784 return this
1786 eliminate: function (m) {
1787 var n = c(this.uid);
1788 delete n[m];
1789 return this
1792 window.addListener("unload", d)
1793 })();
1794 Element.Properties = new Hash;
1795 Element.Properties.style = {
1796 set: function (a) {
1797 this.style.cssText = a
1799 get: function () {
1800 return this.style.cssText
1802 erase: function () {
1803 this.style.cssText = ""
1806 Element.Properties.tag = {
1807 get: function () {
1808 return this.tagName.toLowerCase()
1811 Element.Properties.html = (function () {
1812 var c = document.createElement("div");
1813 var a = {
1814 table: [1, "<table>", "</table>"],
1815 select: [1, "<select>", "</select>"],
1816 tbody: [2, "<table><tbody>", "</tbody></table>"],
1817 tr: [3, "<table><tbody><tr>", "</tr></tbody></table>"]
1819 a.thead = a.tfoot = a.tbody;
1820 var b = {
1821 set: function () {
1822 var f = Array.flatten(arguments).join("");
1823 var g = Browser.Engine.trident && a[this.get("tag")];
1824 if (g) {
1825 var h = c;
1826 h.innerHTML = g[1] + f + g[2];
1827 for (var d = g[0]; d--;) {
1828 h = h.firstChild
1830 this.empty().adopt(h.childNodes)
1831 } else {
1832 this.innerHTML = f
1836 b.erase = b.set;
1837 return b
1838 })();
1839 if (Browser.Engine.webkit && Browser.Engine.version < 420) {
1840 Element.Properties.text = {
1841 get: function () {
1842 if (this.innerText) {
1843 return this.innerText
1845 var a = this.ownerDocument.newElement("div", {
1846 html: this.innerHTML
1847 }).inject(this.ownerDocument.body);
1848 var b = a.innerText;
1849 a.destroy();
1850 return b
1853 }(function () {
1854 Element.implement({
1855 scrollTo: function (i, j) {
1856 if (b(this)) {
1857 this.getWindow().scrollTo(i, j)
1858 } else {
1859 this.scrollLeft = i;
1860 this.scrollTop = j
1862 return this
1864 getSize: function () {
1865 if (b(this)) {
1866 return this.getWindow().getSize()
1868 return {
1869 x: this.offsetWidth,
1870 y: this.offsetHeight
1873 getScrollSize: function () {
1874 if (b(this)) {
1875 return this.getWindow().getScrollSize()
1877 return {
1878 x: this.scrollWidth,
1879 y: this.scrollHeight
1882 getScroll: function () {
1883 if (b(this)) {
1884 return this.getWindow().getScroll()
1886 return {
1887 x: this.scrollLeft,
1888 y: this.scrollTop
1891 getScrolls: function () {
1892 var j = this,
1893 i = {
1894 x: 0,
1895 y: 0
1897 while (j && !b(j)) {
1898 i.x += j.scrollLeft;
1899 i.y += j.scrollTop;
1900 j = j.parentNode
1902 return i
1904 getOffsetParent: function () {
1905 var i = this;
1906 if (b(i)) {
1907 return null
1909 if (!Browser.Engine.trident) {
1910 return i.offsetParent
1912 while ((i = i.parentNode) && !b(i)) {
1913 if (d(i, "position") != "static") {
1914 return i
1917 return null
1919 getOffsets: function () {
1920 if (this.getBoundingClientRect) {
1921 var k = this.getBoundingClientRect(),
1922 n = document.id(this.getDocument().documentElement),
1923 q = n.getScroll(),
1924 l = this.getScrolls(),
1925 j = this.getScroll(),
1926 i = (d(this, "position") == "fixed");
1927 return {
1928 x: k.left.toInt() + l.x - j.x + ((i) ? 0 : q.x) - n.clientLeft,
1929 y: k.top.toInt() + l.y - j.y + ((i) ? 0 : q.y) - n.clientTop
1932 var m = this,
1933 o = {
1934 x: 0,
1935 y: 0
1937 if (b(this)) {
1938 return o
1940 while (m && !b(m)) {
1941 o.x += m.offsetLeft;
1942 o.y += m.offsetTop;
1943 if (Browser.Engine.gecko) {
1944 if (!g(m)) {
1945 o.x += c(m);
1946 o.y += h(m)
1948 var p = m.parentNode;
1949 if (p && d(p, "overflow") != "visible") {
1950 o.x += c(p);
1951 o.y += h(p)
1953 } else {
1954 if (m != this && Browser.Engine.webkit) {
1955 o.x += c(m);
1956 o.y += h(m)
1959 m = m.offsetParent
1961 if (Browser.Engine.gecko && !g(this)) {
1962 o.x -= c(this);
1963 o.y -= h(this)
1965 return o
1967 getPosition: function (l) {
1968 if (b(this)) {
1969 return {
1970 x: 0,
1971 y: 0
1974 var m = this.getOffsets(),
1975 j = this.getScrolls();
1976 var i = {
1977 x: m.x - j.x,
1978 y: m.y - j.y
1980 var k = (l && (l = document.id(l))) ? l.getPosition() : {
1981 x: 0,
1982 y: 0
1984 return {
1985 x: i.x - k.x,
1986 y: i.y - k.y
1989 getCoordinates: function (k) {
1990 if (b(this)) {
1991 return this.getWindow().getCoordinates()
1993 var i = this.getPosition(k),
1994 j = this.getSize();
1995 var l = {
1996 left: i.x,
1997 top: i.y,
1998 width: j.x,
1999 height: j.y
2001 l.right = l.left + l.width;
2002 l.bottom = l.top + l.height;
2003 return l
2005 computePosition: function (i) {
2006 return {
2007 left: i.x - f(this, "margin-left"),
2008 top: i.y - f(this, "margin-top")
2011 setPosition: function (i) {
2012 return this.setStyles(this.computePosition(i))
2015 Native.implement([Document, Window], {
2016 getSize: function () {
2017 if (Browser.Engine.presto || Browser.Engine.webkit) {
2018 var j = this.getWindow();
2019 return {
2020 x: j.innerWidth,
2021 y: j.innerHeight
2024 var i = a(this);
2025 return {
2026 x: i.clientWidth,
2027 y: i.clientHeight
2030 getScroll: function () {
2031 var j = this.getWindow(),
2032 i = a(this);
2033 return {
2034 x: j.pageXOffset || i.scrollLeft,
2035 y: j.pageYOffset || i.scrollTop
2038 getScrollSize: function () {
2039 var j = a(this),
2040 i = this.getSize();
2041 return {
2042 x: Math.max(j.scrollWidth, i.x),
2043 y: Math.max(j.scrollHeight, i.y)
2046 getPosition: function () {
2047 return {
2048 x: 0,
2049 y: 0
2052 getCoordinates: function () {
2053 var i = this.getSize();
2054 return {
2055 top: 0,
2056 left: 0,
2057 bottom: i.y,
2058 right: i.x,
2059 height: i.y,
2060 width: i.x
2064 var d = Element.getComputedStyle;
2066 function f(i, j) {
2067 return d(i, j).toInt() || 0
2069 function g(i) {
2070 return d(i, "-moz-box-sizing") == "border-box"
2072 function h(i) {
2073 return f(i, "border-top-width")
2075 function c(i) {
2076 return f(i, "border-left-width")
2078 function b(i) {
2079 return (/^(?:body|html)$/i).test(i.tagName)
2081 function a(i) {
2082 var j = i.getDocument();
2083 return (!j.compatMode || j.compatMode == "CSS1Compat") ? j.html : j.body
2085 })();
2086 Element.alias("setPosition", "position");
2087 Native.implement([Window, Document, Element], {
2088 getHeight: function () {
2089 return this.getSize().y
2091 getWidth: function () {
2092 return this.getSize().x
2094 getScrollTop: function () {
2095 return this.getScroll().y
2097 getScrollLeft: function () {
2098 return this.getScroll().x
2100 getScrollHeight: function () {
2101 return this.getScrollSize().y
2103 getScrollWidth: function () {
2104 return this.getScrollSize().x
2106 getTop: function () {
2107 return this.getPosition().y
2109 getLeft: function () {
2110 return this.getPosition().x
2113 var Event = new Native({
2114 name: "Event",
2115 initialize: function (a, g) {
2116 g = g || window;
2117 var l = g.document;
2118 a = a || g.event;
2119 if (a.$extended) {
2120 return a
2122 this.$extended = true;
2123 var k = a.type;
2124 var h = a.target || a.srcElement;
2125 while (h && h.nodeType == 3) {
2126 h = h.parentNode
2128 if (k.test(/key/)) {
2129 var b = a.which || a.keyCode;
2130 var n = Event.Keys.keyOf(b);
2131 if (k == "keydown") {
2132 var d = b - 111;
2133 if (d > 0 && d < 13) {
2134 n = "f" + d
2137 n = n || String.fromCharCode(b).toLowerCase()
2138 } else {
2139 if (k.match(/(click|mouse|menu)/i)) {
2140 l = (!l.compatMode || l.compatMode == "CSS1Compat") ? l.html : l.body;
2141 var j = {
2142 x: a.pageX || a.clientX + l.scrollLeft,
2143 y: a.pageY || a.clientY + l.scrollTop
2145 var c = {
2146 x: (a.pageX) ? a.pageX - g.pageXOffset : a.clientX,
2147 y: (a.pageY) ? a.pageY - g.pageYOffset : a.clientY
2149 if (k.match(/DOMMouseScroll|mousewheel/)) {
2150 var i = (a.wheelDelta) ? a.wheelDelta / 120 : -(a.detail || 0) / 3
2152 var f = (a.which == 3) || (a.button == 2);
2153 var m = null;
2154 if (k.match(/over|out/)) {
2155 switch (k) {
2156 case "mouseover":
2157 m = a.relatedTarget || a.fromElement;
2158 break;
2159 case "mouseout":
2160 m = a.relatedTarget || a.toElement
2162 if (!(function () {
2163 while (m && m.nodeType == 3) {
2164 m = m.parentNode
2166 return true
2167 }).create({
2168 attempt: Browser.Engine.gecko
2169 })()) {
2170 m = false
2175 return $extend(this, {
2176 event: a,
2177 type: k,
2178 page: j,
2179 client: c,
2180 rightClick: f,
2181 wheel: i,
2182 relatedTarget: m,
2183 target: h,
2184 code: b,
2185 key: n,
2186 shift: a.shiftKey,
2187 control: a.ctrlKey,
2188 alt: a.altKey,
2189 meta: a.metaKey
2193 Event.Keys = new Hash({
2194 enter: 13,
2195 up: 38,
2196 down: 40,
2197 left: 37,
2198 right: 39,
2199 esc: 27,
2200 space: 32,
2201 backspace: 8,
2202 tab: 9,
2203 "delete": 46
2205 Event.implement({
2206 stop: function () {
2207 return this.stopPropagation().preventDefault()
2209 stopPropagation: function () {
2210 if (this.event.stopPropagation) {
2211 this.event.stopPropagation()
2212 } else {
2213 this.event.cancelBubble = true
2215 return this
2217 preventDefault: function () {
2218 if (this.event.preventDefault) {
2219 this.event.preventDefault()
2220 } else {
2221 this.event.returnValue = false
2223 return this
2226 Element.Properties.events = {
2227 set: function (a) {
2228 this.addEvents(a)
2231 Native.implement([Element, Window, Document], {
2232 addEvent: function (f, h) {
2233 var i = this.retrieve("events", {});
2234 i[f] = i[f] || {
2235 keys: [],
2236 values: []
2238 if (i[f].keys.contains(h)) {
2239 return this
2241 i[f].keys.push(h);
2242 var g = f,
2243 a = Element.Events.get(f),
2244 c = h,
2245 j = this;
2246 if (a) {
2247 if (a.onAdd) {
2248 a.onAdd.call(this, h)
2250 if (a.condition) {
2251 c = function (k) {
2252 if (a.condition.call(this, k)) {
2253 return h.call(this, k)
2255 return true
2258 g = a.base || g
2260 var d = function () {
2261 return h.call(j)
2263 var b = Element.NativeEvents[g];
2264 if (b) {
2265 if (b == 2) {
2266 d = function (k) {
2267 k = new Event(k, j.getWindow());
2268 if (c.call(j, k) === false) {
2269 k.stop()
2273 this.addListener(g, d)
2275 i[f].values.push(d);
2276 return this
2278 removeEvent: function (c, b) {
2279 var a = this.retrieve("events");
2280 if (!a || !a[c]) {
2281 return this
2283 var g = a[c].keys.indexOf(b);
2284 if (g == -1) {
2285 return this
2287 a[c].keys.splice(g, 1);
2288 var f = a[c].values.splice(g, 1)[0];
2289 var d = Element.Events.get(c);
2290 if (d) {
2291 if (d.onRemove) {
2292 d.onRemove.call(this, b)
2294 c = d.base || c
2296 return (Element.NativeEvents[c]) ? this.removeListener(c, f) : this
2298 addEvents: function (a) {
2299 for (var b in a) {
2300 this.addEvent(b, a[b])
2302 return this
2304 removeEvents: function (a) {
2305 var c;
2306 if ($type(a) == "object") {
2307 for (c in a) {
2308 this.removeEvent(c, a[c])
2310 return this
2312 var b = this.retrieve("events");
2313 if (!b) {
2314 return this
2316 if (!a) {
2317 for (c in b) {
2318 this.removeEvents(c)
2320 this.eliminate("events")
2321 } else {
2322 if (b[a]) {
2323 while (b[a].keys[0]) {
2324 this.removeEvent(a, b[a].keys[0])
2326 b[a] = null
2329 return this
2331 fireEvent: function (d, b, a) {
2332 var c = this.retrieve("events");
2333 if (!c || !c[d]) {
2334 return this
2336 c[d].keys.each(function (f) {
2337 f.create({
2338 bind: this,
2339 delay: a,
2340 "arguments": b
2341 })()
2342 }, this);
2343 return this
2345 cloneEvents: function (d, a) {
2346 d = document.id(d);
2347 var c = d.retrieve("events");
2348 if (!c) {
2349 return this
2351 if (!a) {
2352 for (var b in c) {
2353 this.cloneEvents(d, b)
2355 } else {
2356 if (c[a]) {
2357 c[a].keys.each(function (f) {
2358 this.addEvent(a, f)
2359 }, this)
2362 return this
2365 try {
2366 if (typeof HTMLElement != "undefined") {
2367 HTMLElement.prototype.fireEvent = Element.prototype.fireEvent
2369 } catch (e) {}
2370 Element.NativeEvents = {
2371 click: 2,
2372 dblclick: 2,
2373 mouseup: 2,
2374 mousedown: 2,
2375 contextmenu: 2,
2376 mousewheel: 2,
2377 DOMMouseScroll: 2,
2378 mouseover: 2,
2379 mouseout: 2,
2380 mousemove: 2,
2381 selectstart: 2,
2382 selectend: 2,
2383 keydown: 2,
2384 keypress: 2,
2385 keyup: 2,
2386 focus: 2,
2387 blur: 2,
2388 change: 2,
2389 reset: 2,
2390 select: 2,
2391 submit: 2,
2392 load: 1,
2393 unload: 1,
2394 beforeunload: 2,
2395 resize: 1,
2396 move: 1,
2397 DOMContentLoaded: 1,
2398 readystatechange: 1,
2399 error: 1,
2400 abort: 1,
2401 scroll: 1
2403 (function () {
2404 var a = function (b) {
2405 var c = b.relatedTarget;
2406 if (c == undefined) {
2407 return true
2409 if (c === false) {
2410 return false
2412 return ($type(this) != "document" && c != this && c.prefix != "xul" && !this.hasChild(c))
2414 Element.Events = new Hash({
2415 mouseenter: {
2416 base: "mouseover",
2417 condition: a
2419 mouseleave: {
2420 base: "mouseout",
2421 condition: a
2423 mousewheel: {
2424 base: (Browser.Engine.gecko) ? "DOMMouseScroll" : "mousewheel"
2427 })();
2428 Element.Properties.styles = {
2429 set: function (a) {
2430 this.setStyles(a)
2433 Element.Properties.opacity = {
2434 set: function (a, b) {
2435 if (!b) {
2436 if (a == 0) {
2437 if (this.style.visibility != "hidden") {
2438 this.style.visibility = "hidden"
2440 } else {
2441 if (this.style.visibility != "visible") {
2442 this.style.visibility = "visible"
2446 if (!this.currentStyle || !this.currentStyle.hasLayout) {
2447 this.style.zoom = 1
2449 if (Browser.Engine.trident) {
2450 this.style.filter = (a == 1) ? "" : "alpha(opacity=" + a * 100 + ")"
2452 this.style.opacity = a;
2453 this.store("opacity", a)
2455 get: function () {
2456 return this.retrieve("opacity", 1)
2459 Element.implement({
2460 setOpacity: function (a) {
2461 return this.set("opacity", a, true)
2463 getOpacity: function () {
2464 return this.get("opacity")
2466 setStyle: function (b, a) {
2467 switch (b) {
2468 case "opacity":
2469 return this.set("opacity", parseFloat(a));
2470 case "float":
2471 b = (Browser.Engine.trident) ? "styleFloat" : "cssFloat"
2473 b = b.camelCase();
2474 if ($type(a) != "string") {
2475 var c = (Element.Styles.get(b) || "@").split(" ");
2476 a = $splat(a).map(function (f, d) {
2477 if (!c[d]) {
2478 return ""
2480 return ($type(f) == "number") ? c[d].replace("@", Math.round(f)) : f
2481 }).join(" ")
2482 } else {
2483 if (a == String(Number(a))) {
2484 a = Math.round(a)
2487 this.style[b] = a;
2488 return this
2490 getStyle: function (h) {
2491 switch (h) {
2492 case "opacity":
2493 return this.get("opacity");
2494 case "float":
2495 h = (Browser.Engine.trident) ? "styleFloat" : "cssFloat"
2497 h = h.camelCase();
2498 var a = this.style[h];
2499 if (!$chk(a)) {
2500 a = [];
2501 for (var g in Element.ShortStyles) {
2502 if (h != g) {
2503 continue
2505 for (var f in Element.ShortStyles[g]) {
2506 a.push(this.getStyle(f))
2508 return a.join(" ")
2510 a = this.getComputedStyle(h)
2512 if (a) {
2513 a = String(a);
2514 var c = a.match(/rgba?\([\d\s,]+\)/);
2515 if (c) {
2516 a = a.replace(c[0], c[0].rgbToHex())
2519 if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(a, 10)))) {
2520 if (h.test(/^(height|width)$/)) {
2521 var b = (h == "width") ? ["left", "right"] : ["top", "bottom"],
2522 d = 0;
2523 b.each(function (i) {
2524 d += this.getStyle("border-" + i + "-width").toInt() + this.getStyle("padding-" + i).toInt()
2525 }, this);
2526 return this["offset" + h.capitalize()] - d + "px"
2528 if ((Browser.Engine.presto) && String(a).test("px")) {
2529 return a
2531 if (h.test(/(border(.+)Width|margin|padding)/)) {
2532 return "0px"
2535 return a
2537 setStyles: function (b) {
2538 for (var a in b) {
2539 this.setStyle(a, b[a])
2541 return this
2543 getStyles: function () {
2544 var a = {};
2545 Array.flatten(arguments).each(function (b) {
2546 a[b] = this.getStyle(b)
2547 }, this);
2548 return a
2551 Element.Styles = new Hash({
2552 left: "@px",
2553 top: "@px",
2554 bottom: "@px",
2555 right: "@px",
2556 width: "@px",
2557 height: "@px",
2558 maxWidth: "@px",
2559 maxHeight: "@px",
2560 minWidth: "@px",
2561 minHeight: "@px",
2562 backgroundColor: "rgb(@, @, @)",
2563 backgroundPosition: "@px @px",
2564 color: "rgb(@, @, @)",
2565 fontSize: "@px",
2566 letterSpacing: "@px",
2567 lineHeight: "@px",
2568 clip: "rect(@px @px @px @px)",
2569 margin: "@px @px @px @px",
2570 padding: "@px @px @px @px",
2571 border: "@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",
2572 borderWidth: "@px @px @px @px",
2573 borderStyle: "@ @ @ @",
2574 borderColor: "rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",
2575 zIndex: "@",
2576 zoom: "@",
2577 fontWeight: "@",
2578 textIndent: "@px",
2579 opacity: "@"
2581 Element.ShortStyles = {
2582 margin: {},
2583 padding: {},
2584 border: {},
2585 borderWidth: {},
2586 borderStyle: {},
2587 borderColor: {}
2589 ["Top", "Right", "Bottom", "Left"].each(function (h) {
2590 var g = Element.ShortStyles;
2591 var b = Element.Styles;
2592 ["margin", "padding"].each(function (i) {
2593 var j = i + h;
2594 g[i][j] = b[j] = "@px"
2596 var f = "border" + h;
2597 g.border[f] = b[f] = "@px @ rgb(@, @, @)";
2598 var d = f + "Width",
2599 a = f + "Style",
2600 c = f + "Color";
2601 g[f] = {};
2602 g.borderWidth[d] = g[f][d] = b[d] = "@px";
2603 g.borderStyle[a] = g[f][a] = b[a] = "@";
2604 g.borderColor[c] = g[f][c] = b[c] = "rgb(@, @, @)"
2606 var Fx = new Class({
2607 Implements: [Chain, Events, Options],
2608 options: {
2609 fps: 50,
2610 unit: false,
2611 duration: 500,
2612 link: "ignore"
2614 initialize: function (a) {
2615 this.subject = this.subject || this;
2616 this.setOptions(a);
2617 this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt();
2618 var b = this.options.wait;
2619 if (b === false) {
2620 this.options.link = "cancel"
2623 getTransition: function () {
2624 return function (a) {
2625 return -(Math.cos(Math.PI * a) - 1) / 2
2628 step: function () {
2629 var a = $time();
2630 if (a < this.time + this.options.duration) {
2631 var b = this.transition((a - this.time) / this.options.duration);
2632 this.set(this.compute(this.from, this.to, b))
2633 } else {
2634 this.set(this.compute(this.from, this.to, 1));
2635 this.complete()
2638 set: function (a) {
2639 return a
2641 compute: function (c, b, a) {
2642 return Fx.compute(c, b, a)
2644 check: function () {
2645 if (!this.timer) {
2646 return true
2648 switch (this.options.link) {
2649 case "cancel":
2650 this.cancel();
2651 return true;
2652 case "chain":
2653 this.chain(this.caller.bind(this, arguments));
2654 return false
2656 return false
2658 start: function (b, a) {
2659 if (!this.check(b, a)) {
2660 return this
2662 this.from = b;
2663 this.to = a;
2664 this.time = 0;
2665 this.transition = this.getTransition();
2666 this.startTimer();
2667 this.onStart();
2668 return this
2670 complete: function () {
2671 if (this.stopTimer()) {
2672 this.onComplete()
2674 return this
2676 cancel: function () {
2677 if (this.stopTimer()) {
2678 this.onCancel()
2680 return this
2682 onStart: function () {
2683 this.fireEvent("start", this.subject)
2685 onComplete: function () {
2686 this.fireEvent("complete", this.subject);
2687 if (!this.callChain()) {
2688 this.fireEvent("chainComplete", this.subject)
2691 onCancel: function () {
2692 this.fireEvent("cancel", this.subject).clearChain()
2694 pause: function () {
2695 this.stopTimer();
2696 return this
2698 resume: function () {
2699 this.startTimer();
2700 return this
2702 stopTimer: function () {
2703 if (!this.timer) {
2704 return false
2706 this.time = $time() - this.time;
2707 this.timer = $clear(this.timer);
2708 return true
2710 startTimer: function () {
2711 if (this.timer) {
2712 return false
2714 this.time = $time() - this.time;
2715 this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
2716 return true
2719 Fx.compute = function (c, b, a) {
2720 return (b - c) * a + c
2722 Fx.Durations = {
2723 "short": 250,
2724 normal: 500,
2725 "long": 1000
2727 Fx.CSS = new Class({
2728 Extends: Fx,
2729 prepare: function (d, f, b) {
2730 b = $splat(b);
2731 var c = b[1];
2732 if (!$chk(c)) {
2733 b[1] = b[0];
2734 b[0] = d.getStyle(f)
2736 var a = b.map(this.parse);
2737 return {
2738 from: a[0],
2739 to: a[1]
2742 parse: function (a) {
2743 a = $lambda(a)();
2744 a = (typeof a == "string") ? a.split(" ") : $splat(a);
2745 return a.map(function (c) {
2746 c = String(c);
2747 var b = false;
2748 Fx.CSS.Parsers.each(function (g, f) {
2749 if (b) {
2750 return
2752 var d = g.parse(c);
2753 if ($chk(d)) {
2754 b = {
2755 value: d,
2756 parser: g
2760 b = b || {
2761 value: c,
2762 parser: Fx.CSS.Parsers.String
2764 return b
2767 compute: function (d, c, b) {
2768 var a = [];
2769 (Math.min(d.length, c.length)).times(function (f) {
2770 a.push({
2771 value: d[f].parser.compute(d[f].value, c[f].value, b),
2772 parser: d[f].parser
2775 a.$family = {
2776 name: "fx:css:value"
2778 return a
2780 serve: function (c, b) {
2781 if ($type(c) != "fx:css:value") {
2782 c = this.parse(c)
2784 var a = [];
2785 c.each(function (d) {
2786 a = a.concat(d.parser.serve(d.value, b))
2788 return a
2790 render: function (a, d, c, b) {
2791 a.setStyle(d, this.serve(c, b))
2793 search: function (a) {
2794 if (Fx.CSS.Cache[a]) {
2795 return Fx.CSS.Cache[a]
2797 var b = {};
2798 Array.each(document.styleSheets, function (f, d) {
2799 var c = f.href;
2800 if (c && c.contains("://") && !c.contains(document.domain)) {
2801 return
2803 var g = f.rules || f.cssRules;
2804 Array.each(g, function (k, h) {
2805 if (!k.style) {
2806 return
2808 var j = (k.selectorText) ? k.selectorText.replace(/^\w+/, function (i) {
2809 return i.toLowerCase()
2810 }) : null;
2811 if (!j || !j.test("^" + a + "$")) {
2812 return
2814 Element.Styles.each(function (l, i) {
2815 if (!k.style[i] || Element.ShortStyles[i]) {
2816 return
2818 l = String(k.style[i]);
2819 b[i] = (l.test(/^rgb/)) ? l.rgbToHex() : l
2823 return Fx.CSS.Cache[a] = b
2826 Fx.CSS.Cache = {};
2827 Fx.CSS.Parsers = new Hash({
2828 Color: {
2829 parse: function (a) {
2830 if (a.match(/^#[0-9a-f]{3,6}$/i)) {
2831 return a.hexToRgb(true)
2833 return ((a = a.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [a[1], a[2], a[3]] : false
2835 compute: function (c, b, a) {
2836 return c.map(function (f, d) {
2837 return Math.round(Fx.compute(c[d], b[d], a))
2840 serve: function (a) {
2841 return a.map(Number)
2844 Number: {
2845 parse: parseFloat,
2846 compute: Fx.compute,
2847 serve: function (b, a) {
2848 return (a) ? b + a : b
2851 String: {
2852 parse: $lambda(false),
2853 compute: $arguments(1),
2854 serve: $arguments(0)
2857 Fx.Morph = new Class({
2858 Extends: Fx.CSS,
2859 initialize: function (b, a) {
2860 this.element = this.subject = document.id(b);
2861 this.parent(a)
2863 set: function (a) {
2864 if (typeof a == "string") {
2865 a = this.search(a)
2867 for (var b in a) {
2868 this.render(this.element, b, a[b], this.options.unit)
2870 return this
2872 compute: function (f, d, c) {
2873 var a = {};
2874 for (var b in f) {
2875 a[b] = this.parent(f[b], d[b], c)
2877 return a
2879 start: function (b) {
2880 if (!this.check(b)) {
2881 return this
2883 if (typeof b == "string") {
2884 b = this.search(b)
2886 var f = {},
2887 d = {};
2888 for (var c in b) {
2889 var a = this.prepare(this.element, c, b[c]);
2890 f[c] = a.from;
2891 d[c] = a.to
2893 return this.parent(f, d)
2896 Element.Properties.morph = {
2897 set: function (a) {
2898 var b = this.retrieve("morph");
2899 if (b) {
2900 b.cancel()
2902 return this.eliminate("morph").store("morph:options", $extend({
2903 link: "cancel"
2904 }, a))
2906 get: function (a) {
2907 if (a || !this.retrieve("morph")) {
2908 if (a || !this.retrieve("morph:options")) {
2909 this.set("morph", a)
2911 this.store("morph", new Fx.Morph(this, this.retrieve("morph:options")))
2913 return this.retrieve("morph")
2916 Element.implement({
2917 morph: function (a) {
2918 this.get("morph").start(a);
2919 return this
2922 Fx.implement({
2923 getTransition: function () {
2924 var a = this.options.transition || Fx.Transitions.Sine.easeInOut;
2925 if (typeof a == "string") {
2926 var b = a.split(":");
2927 a = Fx.Transitions;
2928 a = a[b[0]] || a[b[0].capitalize()];
2929 if (b[1]) {
2930 a = a["ease" + b[1].capitalize() + (b[2] ? b[2].capitalize() : "")]
2933 return a
2936 Fx.Transition = function (b, a) {
2937 a = $splat(a);
2938 return $extend(b, {
2939 easeIn: function (c) {
2940 return b(c, a)
2942 easeOut: function (c) {
2943 return 1 - b(1 - c, a)
2945 easeInOut: function (c) {
2946 return (c <= 0.5) ? b(2 * c, a) / 2 : (2 - b(2 * (1 - c), a)) / 2
2950 Fx.Transitions = new Hash({
2951 linear: $arguments(0)
2953 Fx.Transitions.extend = function (a) {
2954 for (var b in a) {
2955 Fx.Transitions[b] = new Fx.Transition(a[b])
2958 Fx.Transitions.extend({
2959 Pow: function (b, a) {
2960 return Math.pow(b, a[0] || 6)
2962 Expo: function (a) {
2963 return Math.pow(2, 8 * (a - 1))
2965 Circ: function (a) {
2966 return 1 - Math.sin(Math.acos(a))
2968 Sine: function (a) {
2969 return 1 - Math.sin((1 - a) * Math.PI / 2)
2971 Back: function (b, a) {
2972 a = a[0] || 1.618;
2973 return Math.pow(b, 2) * ((a + 1) * b - a)
2975 Bounce: function (g) {
2976 var f;
2977 for (var d = 0, c = 1; 1; d += c, c /= 2) {
2978 if (g >= (7 - 4 * d) / 11) {
2979 f = c * c - Math.pow((11 - 6 * d - 11 * g) / 4, 2);
2980 break
2983 return f
2985 Elastic: function (b, a) {
2986 return Math.pow(2, 10 * --b) * Math.cos(20 * b * Math.PI * (a[0] || 1) / 3)
2989 ["Quad", "Cubic", "Quart", "Quint"].each(function (b, a) {
2990 Fx.Transitions[b] = new Fx.Transition(function (c) {
2991 return Math.pow(c, [a + 2])
2994 Fx.Tween = new Class({
2995 Extends: Fx.CSS,
2996 initialize: function (b, a) {
2997 this.element = this.subject = document.id(b);
2998 this.parent(a)
3000 set: function (b, a) {
3001 if (arguments.length == 1) {
3002 a = b;
3003 b = this.property || this.options.property
3005 this.render(this.element, b, a, this.options.unit);
3006 return this
3008 start: function (c, f, d) {
3009 if (!this.check(c, f, d)) {
3010 return this
3012 var b = Array.flatten(arguments);
3013 this.property = this.options.property || b.shift();
3014 var a = this.prepare(this.element, this.property, b);
3015 return this.parent(a.from, a.to)
3018 Element.Properties.tween = {
3019 set: function (a) {
3020 var b = this.retrieve("tween");
3021 if (b) {
3022 b.cancel()
3024 return this.eliminate("tween").store("tween:options", $extend({
3025 link: "cancel"
3026 }, a))
3028 get: function (a) {
3029 if (a || !this.retrieve("tween")) {
3030 if (a || !this.retrieve("tween:options")) {
3031 this.set("tween", a)
3033 this.store("tween", new Fx.Tween(this, this.retrieve("tween:options")))
3035 return this.retrieve("tween")
3038 Element.implement({
3039 tween: function (a, c, b) {
3040 this.get("tween").start(arguments);
3041 return this
3043 fade: function (c) {
3044 var f = this.get("tween"),
3045 d = "opacity",
3047 c = $pick(c, "toggle");
3048 switch (c) {
3049 case "in":
3050 f.start(d, 1);
3051 break;
3052 case "out":
3053 f.start(d, 0);
3054 break;
3055 case "show":
3056 f.set(d, 1);
3057 break;
3058 case "hide":
3059 f.set(d, 0);
3060 break;
3061 case "toggle":
3062 var b = this.retrieve("fade:flag", this.get("opacity") == 1);
3063 f.start(d, (b) ? 0 : 1);
3064 this.store("fade:flag", !b);
3065 a = true;
3066 break;
3067 default:
3068 f.start(d, arguments)
3070 if (!a) {
3071 this.eliminate("fade:flag")
3073 return this
3075 highlight: function (c, a) {
3076 if (!a) {
3077 a = this.retrieve("highlight:original", this.getStyle("background-color"));
3078 a = (a == "transparent") ? "#fff" : a
3080 var b = this.get("tween");
3081 b.start("background-color", c || "#ffff88", a).chain(function () {
3082 this.setStyle("background-color", this.retrieve("highlight:original"));
3083 b.callChain()
3084 }.bind(this));
3085 return this
3088 var Request = new Class({
3089 Implements: [Chain, Events, Options],
3090 options: {
3091 url: "",
3092 data: "",
3093 headers: {
3094 "X-Requested-With": "XMLHttpRequest",
3095 Accept: "text/javascript, text/html, application/xml, text/xml, */*"
3097 async: true,
3098 format: false,
3099 method: "post",
3100 link: "ignore",
3101 isSuccess: null,
3102 emulation: true,
3103 urlEncoded: true,
3104 encoding: "utf-8",
3105 evalScripts: false,
3106 evalResponse: false,
3107 noCache: false
3109 initialize: function (a) {
3110 this.xhr = new Browser.Request();
3111 this.setOptions(a);
3112 this.options.isSuccess = this.options.isSuccess || this.isSuccess;
3113 this.headers = new Hash(this.options.headers)
3115 onStateChange: function () {
3116 if (this.xhr.readyState != 4 || !this.running) {
3117 return
3119 this.running = false;
3120 this.status = 0;
3121 $try(function () {
3122 this.status = this.xhr.status
3123 }.bind(this));
3124 this.xhr.onreadystatechange = $empty;
3125 if (this.options.isSuccess.call(this, this.status)) {
3126 this.response = {
3127 text: this.xhr.responseText,
3128 xml: this.xhr.responseXML
3130 this.success(this.response.text, this.response.xml)
3131 } else {
3132 this.response = {
3133 text: null,
3134 xml: null
3136 this.failure()
3139 isSuccess: function () {
3140 return ((this.status >= 200) && (this.status < 300))
3142 processScripts: function (a) {
3143 if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader("Content-type"))) {
3144 return $exec(a)
3146 return a.stripScripts(this.options.evalScripts)
3148 success: function (b, a) {
3149 this.onSuccess(this.processScripts(b), a)
3151 onSuccess: function () {
3152 this.fireEvent("complete", arguments).fireEvent("success", arguments).callChain()
3154 failure: function () {
3155 this.onFailure()
3157 onFailure: function () {
3158 this.fireEvent("complete").fireEvent("failure", this.xhr)
3160 setHeader: function (a, b) {
3161 this.headers.set(a, b);
3162 return this
3164 getHeader: function (a) {
3165 return $try(function () {
3166 return this.xhr.getResponseHeader(a)
3167 }.bind(this))
3169 check: function () {
3170 if (!this.running) {
3171 return true
3173 switch (this.options.link) {
3174 case "cancel":
3175 this.cancel();
3176 return true;
3177 case "chain":
3178 this.chain(this.caller.bind(this, arguments));
3179 return false
3181 return false
3183 send: function (l) {
3184 if (!this.check(l)) {
3185 return this
3187 this.running = true;
3188 var j = $type(l);
3189 if (j == "string" || j == "element") {
3190 l = {
3191 data: l
3194 var d = this.options;
3195 l = $extend({
3196 data: d.data,
3197 url: d.url,
3198 method: d.method
3199 }, l);
3200 var h = l.data,
3201 b = String(l.url),
3202 a = l.method.toLowerCase();
3203 switch ($type(h)) {
3204 case "element":
3205 h = document.id(h).toQueryString();
3206 break;
3207 case "object":
3208 case "hash":
3209 h = Hash.toQueryString(h)
3211 if (this.options.format) {
3212 var k = "format=" + this.options.format;
3213 h = (h) ? k + "&" + h : k
3215 if (this.options.emulation && !["get", "post"].contains(a)) {
3216 var i = "_method=" + a;
3217 h = (h) ? i + "&" + h : i;
3218 a = "post"
3220 if (this.options.urlEncoded && a == "post") {
3221 var c = (this.options.encoding) ? "; charset=" + this.options.encoding : "";
3222 this.headers.set("Content-type", "application/x-www-form-urlencoded" + c)
3224 if (this.options.noCache) {
3225 var g = "noCache=" + new Date().getTime();
3226 h = (h) ? g + "&" + h : g
3228 var f = b.lastIndexOf("/");
3229 if (f > -1 && (f = b.indexOf("#")) > -1) {
3230 b = b.substr(0, f)
3232 if (h && a == "get") {
3233 b = b + (b.contains("?") ? "&" : "?") + h;
3234 h = null
3236 this.xhr.open(a.toUpperCase(), b, this.options.async);
3237 this.xhr.onreadystatechange = this.onStateChange.bind(this);
3238 this.headers.each(function (n, m) {
3239 try {
3240 this.xhr.setRequestHeader(m, n)
3241 } catch (o) {
3242 this.fireEvent("exception", [m, n])
3244 }, this);
3245 this.fireEvent("request");
3246 this.xhr.send(h);
3247 if (!this.options.async) {
3248 this.onStateChange()
3250 return this
3252 cancel: function () {
3253 if (!this.running) {
3254 return this
3256 this.running = false;
3257 this.xhr.abort();
3258 this.xhr.onreadystatechange = $empty;
3259 this.xhr = new Browser.Request();
3260 this.fireEvent("cancel");
3261 return this
3264 (function () {
3265 var a = {};
3266 ["get", "post", "put", "delete", "GET", "POST", "PUT", "DELETE"].each(function (b) {
3267 a[b] = function () {
3268 var c = Array.link(arguments, {
3269 url: String.type,
3270 data: $defined
3272 return this.send($extend(c, {
3273 method: b
3277 Request.implement(a)
3278 })();
3279 Element.Properties.send = {
3280 set: function (a) {
3281 var b = this.retrieve("send");
3282 if (b) {
3283 b.cancel()
3285 return this.eliminate("send").store("send:options", $extend({
3286 data: this,
3287 link: "cancel",
3288 method: this.get("method") || "post",
3289 url: this.get("action")
3290 }, a))
3292 get: function (a) {
3293 if (a || !this.retrieve("send")) {
3294 if (a || !this.retrieve("send:options")) {
3295 this.set("send", a)
3297 this.store("send", new Request(this.retrieve("send:options")))
3299 return this.retrieve("send")
3302 Element.implement({
3303 send: function (a) {
3304 var b = this.get("send");
3305 b.send({
3306 data: this,
3307 url: a || b.options.url
3309 return this
3312 Request.HTML = new Class({
3313 Extends: Request,
3314 options: {
3315 update: false,
3316 append: false,
3317 evalScripts: true,
3318 filter: false
3320 processHTML: function (c) {
3321 var b = c.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
3322 c = (b) ? b[1] : c;
3323 var a = new Element("div");
3324 return $try(function () {
3325 var d = "<root>" + c + "</root>",
3327 if (Browser.Engine.trident) {
3328 h = new ActiveXObject("Microsoft.XMLDOM");
3329 h.async = false;
3330 h.loadXML(d)
3331 } else {
3332 h = new DOMParser().parseFromString(d, "text/xml")
3334 d = h.getElementsByTagName("root")[0];
3335 if (!d) {
3336 return null
3338 for (var g = 0, f = d.childNodes.length; g < f; g++) {
3339 var j = Element.clone(d.childNodes[g], true, true);
3340 if (j) {
3341 a.grab(j)
3344 return a
3345 }) || a.set("html", c)
3347 success: function (d) {
3348 var c = this.options,
3349 b = this.response;
3350 b.html = d.stripScripts(function (f) {
3351 b.javascript = f
3353 var a = this.processHTML(b.html);
3354 b.tree = a.childNodes;
3355 b.elements = a.getElements("*");
3356 if (c.filter) {
3357 b.tree = b.elements.filter(c.filter)
3359 if (c.update) {
3360 document.id(c.update).empty().set("html", b.html)
3361 } else {
3362 if (c.append) {
3363 document.id(c.append).adopt(a.getChildren())
3366 if (c.evalScripts) {
3367 $exec(b.javascript)
3369 this.onSuccess(b.tree, b.elements, b.html, b.javascript)
3372 Element.Properties.load = {
3373 set: function (a) {
3374 var b = this.retrieve("load");
3375 if (b) {
3376 b.cancel()
3378 return this.eliminate("load").store("load:options", $extend({
3379 data: this,
3380 link: "cancel",
3381 update: this,
3382 method: "get"
3383 }, a))
3385 get: function (a) {
3386 if (a || !this.retrieve("load")) {
3387 if (a || !this.retrieve("load:options")) {
3388 this.set("load", a)
3390 this.store("load", new Request.HTML(this.retrieve("load:options")))
3392 return this.retrieve("load")
3395 Element.implement({
3396 load: function () {
3397 this.get("load").send(Array.link(arguments, {
3398 data: Object.type,
3399 url: String.type
3400 }));
3401 return this
3404 var JSON = new Hash(this.JSON && {
3405 stringify: JSON.stringify,
3406 parse: JSON.parse
3407 }).extend({
3408 $specialChars: {
3409 "\b": "\\b",
3410 "\t": "\\t",
3411 "\n": "\\n",
3412 "\f": "\\f",
3413 "\r": "\\r",
3414 '"': '\\"',
3415 "\\": "\\\\"
3417 $replaceChars: function (a) {
3418 return JSON.$specialChars[a] || "\\u00" + Math.floor(a.charCodeAt() / 16).toString(16) + (a.charCodeAt() % 16).toString(16)
3420 encode: function (b) {
3421 switch ($type(b)) {
3422 case "string":
3423 return '"' + b.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"';
3424 case "array":
3425 return "[" + String(b.map(JSON.encode).clean()) + "]";
3426 case "object":
3427 case "hash":
3428 var a = [];
3429 Hash.each(b, function (f, d) {
3430 var c = JSON.encode(f);
3431 if (c) {
3432 a.push(JSON.encode(d) + ":" + c)
3435 return "{" + a + "}";
3436 case "number":
3437 case "boolean":
3438 return String(b);
3439 case false:
3440 return "null"
3442 return null
3444 decode: function (string, secure) {
3445 if ($type(string) != "string" || !string.length) {
3446 return null
3448 if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, "@").replace(/"[^"\\\n\r]*"/g, ""))) {
3449 return null
3451 return eval("(" + string + ")")
3454 Request.JSON = new Class({
3455 Extends: Request,
3456 options: {
3457 secure: true
3459 initialize: function (a) {
3460 this.parent(a);
3461 this.headers.extend({
3462 Accept: "application/json",
3463 "X-Request": "JSON"
3466 success: function (a) {
3467 this.response.json = JSON.decode(a, this.options.secure);
3468 this.onSuccess(this.response.json, a)
3471 var Cookie = new Class({
3472 Implements: Options,
3473 options: {
3474 path: false,
3475 domain: false,
3476 duration: false,
3477 secure: false,
3478 document: document
3480 initialize: function (b, a) {
3481 this.key = b;
3482 this.setOptions(a)
3484 write: function (b) {
3485 b = encodeURIComponent(b);
3486 if (this.options.domain) {
3487 b += "; domain=" + this.options.domain
3489 if (this.options.path) {
3490 b += "; path=" + this.options.path
3492 if (this.options.duration) {
3493 var a = new Date();
3494 a.setTime(a.getTime() + this.options.duration * 24 * 60 * 60 * 1000);
3495 b += "; expires=" + a.toGMTString()
3497 if (this.options.secure) {
3498 b += "; secure"
3500 this.options.document.cookie = this.key + "=" + b;
3501 return this
3503 read: function () {
3504 var a = this.options.document.cookie.match("(?:^|;)\\s*" + this.key.escapeRegExp() + "=([^;]*)");
3505 return (a) ? decodeURIComponent(a[1]) : null
3507 dispose: function () {
3508 new Cookie(this.key, $merge(this.options, {
3509 duration: -1
3510 })).write("");
3511 return this
3514 Cookie.write = function (b, c, a) {
3515 return new Cookie(b, a).write(c)
3517 Cookie.read = function (a) {
3518 return new Cookie(a).read()
3520 Cookie.dispose = function (b, a) {
3521 return new Cookie(b, a).dispose()
3523 Element.Events.domready = {
3524 onAdd: function (a) {
3525 if (Browser.loaded) {
3526 a.call(this)
3530 (function () {
3531 var b = function () {
3532 if (Browser.loaded) {
3533 return
3535 Browser.loaded = true;
3536 window.fireEvent("domready");
3537 document.fireEvent("domready")
3539 window.addEvent("load", b);
3540 if (Browser.Engine.trident) {
3541 var a = document.createElement("div");
3542 (function () {
3543 ($try(function () {
3544 a.doScroll();
3545 return document.id(a).inject(document.body).set("html", "temp").dispose()
3546 })) ? b() : arguments.callee.delay(50)
3547 })()
3548 } else {
3549 if (Browser.Engine.webkit && Browser.Engine.version < 525) {
3550 (function () {
3551 (["loaded", "complete"].contains(document.readyState)) ? b() : arguments.callee.delay(50)
3552 })()
3553 } else {
3554 document.addEvent("DOMContentLoaded", b)
3557 })();
3558 Native.implement([Document, Element], {
3559 getElements: function (j, h) {
3560 j = j.split(",");
3561 var c, f = {};
3562 for (var d = 0, b = j.length; d < b; d++) {
3563 var a = j[d],
3564 g = Selectors.Utils.search(this, a, f);
3565 if (d != 0 && g.item) {
3566 g = $A(g)
3568 c = (d == 0) ? g : (c.item) ? $A(c).concat(g) : c.concat(g)
3570 return new Elements(c, {
3571 ddup: (j.length > 1),
3572 cash: !h
3576 Element.implement({
3577 match: function (b) {
3578 if (!b || (b == this)) {
3579 return true
3581 var d = Selectors.Utils.parseTagAndID(b);
3582 var a = d[0],
3583 f = d[1];
3584 if (!Selectors.Filters.byID(this, f) || !Selectors.Filters.byTag(this, a)) {
3585 return false
3587 var c = Selectors.Utils.parseSelector(b);
3588 return (c) ? Selectors.Utils.filter(this, c, {}) : true
3591 var Selectors = {
3592 Cache: {
3593 nth: {},
3594 parsed: {}
3597 Selectors.RegExps = {
3598 id: (/#([\w-]+)/),
3599 tag: (/^(\w+|\*)/),
3600 quick: (/^(\w+|\*)$/),
3601 splitter: (/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),
3602 combined: (/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)
3604 Selectors.Utils = {
3605 chk: function (b, c) {
3606 if (!c) {
3607 return true
3609 var a = $uid(b);
3610 if (!c[a]) {
3611 return c[a] = true
3613 return false
3615 parseNthArgument: function (i) {
3616 if (Selectors.Cache.nth[i]) {
3617 return Selectors.Cache.nth[i]
3619 var f = i.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);
3620 if (!f) {
3621 return false
3623 var h = parseInt(f[1], 10);
3624 var d = (h || h === 0) ? h : 1;
3625 var g = f[2] || false;
3626 var c = parseInt(f[3], 10) || 0;
3627 if (d != 0) {
3628 c--;
3629 while (c < 1) {
3630 c += d
3632 while (c >= d) {
3633 c -= d
3635 } else {
3636 d = c;
3637 g = "index"
3639 switch (g) {
3640 case "n":
3641 f = {
3642 a: d,
3643 b: c,
3644 special: "n"
3646 break;
3647 case "odd":
3648 f = {
3649 a: 2,
3650 b: 0,
3651 special: "n"
3653 break;
3654 case "even":
3655 f = {
3656 a: 2,
3657 b: 1,
3658 special: "n"
3660 break;
3661 case "first":
3662 f = {
3663 a: 0,
3664 special: "index"
3666 break;
3667 case "last":
3668 f = {
3669 special: "last-child"
3671 break;
3672 case "only":
3673 f = {
3674 special: "only-child"
3676 break;
3677 default:
3678 f = {
3679 a: (d - 1),
3680 special: "index"
3683 return Selectors.Cache.nth[i] = f
3685 parseSelector: function (f) {
3686 if (Selectors.Cache.parsed[f]) {
3687 return Selectors.Cache.parsed[f]
3689 var d, i = {
3690 classes: [],
3691 pseudos: [],
3692 attributes: []
3694 while ((d = Selectors.RegExps.combined.exec(f))) {
3695 var j = d[1],
3696 h = d[2],
3697 g = d[3],
3698 b = d[5],
3699 c = d[6],
3700 k = d[7];
3701 if (j) {
3702 i.classes.push(j)
3703 } else {
3704 if (c) {
3705 var a = Selectors.Pseudo.get(c);
3706 if (a) {
3707 i.pseudos.push({
3708 parser: a,
3709 argument: k
3711 } else {
3712 i.attributes.push({
3713 name: c,
3714 operator: "=",
3715 value: k
3718 } else {
3719 if (h) {
3720 i.attributes.push({
3721 name: h,
3722 operator: g,
3723 value: b
3729 if (!i.classes.length) {
3730 delete i.classes
3732 if (!i.attributes.length) {
3733 delete i.attributes
3735 if (!i.pseudos.length) {
3736 delete i.pseudos
3738 if (!i.classes && !i.attributes && !i.pseudos) {
3739 i = null
3741 return Selectors.Cache.parsed[f] = i
3743 parseTagAndID: function (b) {
3744 var a = b.match(Selectors.RegExps.tag);
3745 var c = b.match(Selectors.RegExps.id);
3746 return [(a) ? a[1] : "*", (c) ? c[1] : false]
3748 filter: function (g, c, f) {
3749 var d;
3750 if (c.classes) {
3751 for (d = c.classes.length; d--; d) {
3752 var h = c.classes[d];
3753 if (!Selectors.Filters.byClass(g, h)) {
3754 return false
3758 if (c.attributes) {
3759 for (d = c.attributes.length; d--; d) {
3760 var b = c.attributes[d];
3761 if (!Selectors.Filters.byAttribute(g, b.name, b.operator, b.value)) {
3762 return false
3766 if (c.pseudos) {
3767 for (d = c.pseudos.length; d--; d) {
3768 var a = c.pseudos[d];
3769 if (!Selectors.Filters.byPseudo(g, a.parser, a.argument, f)) {
3770 return false
3774 return true
3776 getByTagAndID: function (b, a, d) {
3777 if (d) {
3778 var c = (b.getElementById) ? b.getElementById(d, true) : Element.getElementById(b, d, true);
3779 return (c && Selectors.Filters.byTag(c, a)) ? [c] : []
3780 } else {
3781 return b.getElementsByTagName(a)
3784 search: function (p, o, u) {
3785 var b = [];
3786 var c = o.trim().replace(Selectors.RegExps.splitter, function (k, j, i) {
3787 b.push(j);
3788 return ":)" + i
3789 }).split(":)");
3790 var q, f, B;
3791 for (var A = 0, w = c.length; A < w; A++) {
3792 var z = c[A];
3793 if (A == 0 && Selectors.RegExps.quick.test(z)) {
3794 q = p.getElementsByTagName(z);
3795 continue
3797 var a = b[A - 1];
3798 var r = Selectors.Utils.parseTagAndID(z);
3799 var C = r[0],
3800 s = r[1];
3801 if (A == 0) {
3802 q = Selectors.Utils.getByTagAndID(p, C, s)
3803 } else {
3804 var d = {},
3805 h = [];
3806 for (var y = 0, x = q.length; y < x; y++) {
3807 h = Selectors.Getters[a](h, q[y], C, s, d)
3809 q = h
3811 var g = Selectors.Utils.parseSelector(z);
3812 if (g) {
3813 f = [];
3814 for (var v = 0, t = q.length; v < t; v++) {
3815 B = q[v];
3816 if (Selectors.Utils.filter(B, g, u)) {
3817 f.push(B)
3820 q = f
3823 return q
3826 Selectors.Getters = {
3827 " ": function (j, h, k, a, f) {
3828 var d = Selectors.Utils.getByTagAndID(h, k, a);
3829 for (var c = 0, b = d.length; c < b; c++) {
3830 var g = d[c];
3831 if (Selectors.Utils.chk(g, f)) {
3832 j.push(g)
3835 return j
3837 ">": function (j, h, k, a, g) {
3838 var c = Selectors.Utils.getByTagAndID(h, k, a);
3839 for (var f = 0, d = c.length; f < d; f++) {
3840 var b = c[f];
3841 if (b.parentNode == h && Selectors.Utils.chk(b, g)) {
3842 j.push(b)
3845 return j
3847 "+": function (c, b, a, f, d) {
3848 while ((b = b.nextSibling)) {
3849 if (b.nodeType == 1) {
3850 if (Selectors.Utils.chk(b, d) && Selectors.Filters.byTag(b, a) && Selectors.Filters.byID(b, f)) {
3851 c.push(b)
3853 break
3856 return c
3858 "~": function (c, b, a, f, d) {
3859 while ((b = b.nextSibling)) {
3860 if (b.nodeType == 1) {
3861 if (!Selectors.Utils.chk(b, d)) {
3862 break
3864 if (Selectors.Filters.byTag(b, a) && Selectors.Filters.byID(b, f)) {
3865 c.push(b)
3869 return c
3872 Selectors.Filters = {
3873 byTag: function (b, a) {
3874 return (a == "*" || (b.tagName && b.tagName.toLowerCase() == a))
3876 byID: function (a, b) {
3877 return (!b || (a.id && a.id == b))
3879 byClass: function (b, a) {
3880 return (b.className && b.className.contains && b.className.contains(a, " "))
3882 byPseudo: function (a, d, c, b) {
3883 return d.call(a, c, b)
3885 byAttribute: function (c, d, b, f) {
3886 var a = Element.prototype.getProperty.call(c, d);
3887 if (!a) {
3888 return (b == "!=")
3890 if (!b || f == undefined) {
3891 return true
3893 switch (b) {
3894 case "=":
3895 return (a == f);
3896 case "*=":
3897 return (a.contains(f));
3898 case "^=":
3899 return (a.substr(0, f.length) == f);
3900 case "$=":
3901 return (a.substr(a.length - f.length) == f);
3902 case "!=":
3903 return (a != f);
3904 case "~=":
3905 return a.contains(f, " ");
3906 case "|=":
3907 return a.contains(f, "-")
3909 return false
3912 Selectors.Pseudo = new Hash({
3913 checked: function () {
3914 return this.checked
3916 empty: function () {
3917 return !(this.innerText || this.textContent || "").length
3919 not: function (a) {
3920 return !Element.match(this, a)
3922 contains: function (a) {
3923 return (this.innerText || this.textContent || "").contains(a)
3925 "first-child": function () {
3926 return Selectors.Pseudo.index.call(this, 0)
3928 "last-child": function () {
3929 var a = this;
3930 while ((a = a.nextSibling)) {
3931 if (a.nodeType == 1) {
3932 return false
3935 return true
3937 "only-child": function () {
3938 var b = this;
3939 while ((b = b.previousSibling)) {
3940 if (b.nodeType == 1) {
3941 return false
3944 var a = this;
3945 while ((a = a.nextSibling)) {
3946 if (a.nodeType == 1) {
3947 return false
3950 return true
3952 "nth-child": function (h, f) {
3953 h = (h == undefined) ? "n" : h;
3954 var c = Selectors.Utils.parseNthArgument(h);
3955 if (c.special != "n") {
3956 return Selectors.Pseudo[c.special].call(this, c.a, f)
3958 var g = 0;
3959 f.positions = f.positions || {};
3960 var d = $uid(this);
3961 if (!f.positions[d]) {
3962 var b = this;
3963 while ((b = b.previousSibling)) {
3964 if (b.nodeType != 1) {
3965 continue
3967 g++;
3968 var a = f.positions[$uid(b)];
3969 if (a != undefined) {
3970 g = a + g;
3971 break
3974 f.positions[d] = g
3976 return (f.positions[d] % c.a == c.b)
3978 index: function (a) {
3979 var b = this,
3980 c = 0;
3981 while ((b = b.previousSibling)) {
3982 if (b.nodeType == 1 && ++c > a) {
3983 return false
3986 return (c == a)
3988 even: function (b, a) {
3989 return Selectors.Pseudo["nth-child"].call(this, "2n+1", a)
3991 odd: function (b, a) {
3992 return Selectors.Pseudo["nth-child"].call(this, "2n", a)
3994 selected: function () {
3995 return this.selected
3997 enabled: function () {
3998 return (this.disabled === false)
4001 var Swiff = new Class({
4002 Implements: [Options],
4003 options: {
4004 id: null,
4005 height: 1,
4006 width: 1,
4007 container: null,
4008 properties: {},
4009 params: {
4010 quality: "high",
4011 allowScriptAccess: "always",
4012 wMode: "transparent",
4013 swLiveConnect: true
4015 callBacks: {},
4016 vars: {}
4018 toElement: function () {
4019 return this.object
4021 initialize: function (m, n) {
4022 this.instance = "Swiff_" + $time();
4023 this.setOptions(n);
4024 n = this.options;
4025 var b = this.id = n.id || this.instance;
4026 var a = document.id(n.container);
4027 Swiff.CallBacks[this.instance] = {};
4028 var f = n.params,
4029 h = n.vars,
4030 g = n.callBacks;
4031 var i = $extend({
4032 height: n.height,
4033 width: n.width
4034 }, n.properties);
4035 var l = this;
4036 for (var d in g) {
4037 Swiff.CallBacks[this.instance][d] = (function (o) {
4038 return function () {
4039 return o.apply(l.object, arguments)
4041 })(g[d]);
4042 h[d] = "Swiff.CallBacks." + this.instance + "." + d
4044 f.flashVars = Hash.toQueryString(h);
4045 if (Browser.Engine.trident) {
4046 i.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
4047 f.movie = m
4048 } else {
4049 i.type = "application/x-shockwave-flash";
4050 i.data = m
4052 var k = '<object id="' + b + '"';
4053 for (var j in i) {
4054 k += " " + j + '="' + i[j] + '"'
4056 k += ">";
4057 for (var c in f) {
4058 if (f[c]) {
4059 k += '<param name="' + c + '" value="' + f[c] + '" />'
4062 k += "</object>";
4063 this.object = ((a) ? a.empty() : new Element("div")).set("html", k).firstChild
4065 replaces: function (a) {
4066 a = document.id(a, true);
4067 a.parentNode.replaceChild(this.toElement(), a);
4068 return this
4070 inject: function (a) {
4071 document.id(a, true).appendChild(this.toElement());
4072 return this
4074 remote: function () {
4075 return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments))
4078 Swiff.CallBacks = {};
4079 Swiff.remote = function (obj, fn) {
4080 var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + "</invoke>");
4081 return eval(rs)
4083 MooTools.More = {
4084 version: "1.2.4.4",
4085 build: "6f6057dc645fdb7547689183b2311063bd653ddf"
4087 (function () {
4088 var a = {
4089 language: "en-US",
4090 languages: {
4091 "en-US": {}
4093 cascades: ["en-US"]
4095 var b;
4096 MooTools.lang = new Events();
4097 $extend(MooTools.lang, {
4098 setLanguage: function (c) {
4099 if (!a.languages[c]) {
4100 return this
4102 a.language = c;
4103 this.load();
4104 this.fireEvent("langChange", c);
4105 return this
4107 load: function () {
4108 var c = this.cascade(this.getCurrentLanguage());
4109 b = {};
4110 $each(c, function (f, d) {
4111 b[d] = this.lambda(f)
4112 }, this)
4114 getCurrentLanguage: function () {
4115 return a.language
4117 addLanguage: function (c) {
4118 a.languages[c] = a.languages[c] || {};
4119 return this
4121 cascade: function (f) {
4122 var c = (a.languages[f] || {}).cascades || [];
4123 c.combine(a.cascades);
4124 c.erase(f).push(f);
4125 var d = c.map(function (g) {
4126 return a.languages[g]
4127 }, this);
4128 return $merge.apply(this, d)
4130 lambda: function (c) {
4131 (c || {}).get = function (f, d) {
4132 return $lambda(c[f]).apply(this, $splat(d))
4134 return c
4136 get: function (f, d, c) {
4137 if (b && b[f]) {
4138 return (d ? b[f].get(d, c) : b[f])
4141 set: function (d, f, c) {
4142 this.addLanguage(d);
4143 langData = a.languages[d];
4144 if (!langData[f]) {
4145 langData[f] = {}
4147 $extend(langData[f], c);
4148 if (d == this.getCurrentLanguage()) {
4149 this.load();
4150 this.fireEvent("langChange", d)
4152 return this
4154 list: function () {
4155 return Hash.getKeys(a.languages)
4158 })();
4159 Class.refactor = function (b, a) {
4160 $each(a, function (f, d) {
4161 var c = b.prototype[d];
4162 if (c && (c = c._origin) && typeof f == "function") {
4163 b.implement(d, function () {
4164 var g = this.previous;
4165 this.previous = c;
4166 var h = f.apply(this, arguments);
4167 this.previous = g;
4168 return h
4170 } else {
4171 b.implement(d, f)
4174 return b
4176 Class.Mutators.Binds = function (a) {
4177 return a
4179 Class.Mutators.initialize = function (a) {
4180 return function () {
4181 $splat(this.Binds).each(function (b) {
4182 var c = this[b];
4183 if (c) {
4184 this[b] = c.bind(this)
4186 }, this);
4187 return a.apply(this, arguments)
4190 Class.Occlude = new Class({
4191 occlude: function (c, b) {
4192 b = document.id(b || this.element);
4193 var a = b.retrieve(c || this.property);
4194 if (a && !$defined(this.occluded)) {
4195 return this.occluded = a
4197 this.occluded = false;
4198 b.store(c || this.property, this);
4199 return this.occluded
4202 Array.implement({
4203 min: function () {
4204 return Math.min.apply(null, this)
4206 max: function () {
4207 return Math.max.apply(null, this)
4209 average: function () {
4210 return this.length ? this.sum() / this.length : 0
4212 sum: function () {
4213 var a = 0,
4214 b = this.length;
4215 if (b) {
4216 do {
4217 a += this[--b]
4218 } while (b)
4220 return a
4222 unique: function () {
4223 return [].combine(this)
4225 shuffle: function () {
4226 for (var b = this.length; b && --b;) {
4227 var a = this[b],
4228 c = Math.floor(Math.random() * (b + 1));
4229 this[b] = this[c];
4230 this[c] = a
4232 return this
4235 Hash.implement({
4236 getFromPath: function (a) {
4237 var b = this.getClean();
4238 a.replace(/\[([^\]]+)\]|\.([^.[]+)|[^[.]+/g, function (c) {
4239 if (!b) {
4240 return null
4242 var d = arguments[2] || arguments[1] || arguments[0];
4243 b = (d in b) ? b[d] : null;
4244 return c
4246 return b
4248 cleanValues: function (a) {
4249 a = a || $defined;
4250 this.each(function (c, b) {
4251 if (!a(c)) {
4252 this.erase(b)
4254 }, this);
4255 return this
4257 run: function () {
4258 var a = arguments;
4259 this.each(function (c, b) {
4260 if ($type(c) == "function") {
4261 c.run(a)
4266 (function () {
4267 var b = ["À", "à", "Á", "á", "Â", "â", "Ã", "ã", "Ä", "ä", "Å", "å", "Ă", "ă", "Ą", "ą", "Ć", "ć", "Č", "č", "Ç", "ç", "Ď", "ď", "Đ", "đ", "È", "è", "É", "é", "Ê", "ê", "Ë", "ë", "Ě", "ě", "Ę", "ę", "Ğ", "ğ", "Ì", "ì", "Í", "í", "Î", "î", "Ï", "ï", "Ĺ", "ĺ", "Ľ", "ľ", "Ł", "ł", "Ñ", "ñ", "Ň", "ň", "Ń", "ń", "Ò", "ò", "Ó", "ó", "Ô", "ô", "Õ", "õ", "Ö", "ö", "Ø", "ø", "ő", "Ř", "ř", "Ŕ", "ŕ", "Š", "š", "Ş", "ş", "Ś", "ś", "Ť", "ť", "Ť", "ť", "Ţ", "ţ", "Ù", "ù", "Ú", "ú", "Û", "û", "Ü", "ü", "Ů", "ů", "Ÿ", "ÿ", "ý", "Ý", "Ž", "ž", "Ź", "ź", "Ż", "ż", "Þ", "þ", "Ð", "ð", "ß", "Œ", "œ", "Æ", "æ", "µ"];
4268 var a = ["A", "a", "A", "a", "A", "a", "A", "a", "Ae", "ae", "A", "a", "A", "a", "A", "a", "C", "c", "C", "c", "C", "c", "D", "d", "D", "d", "E", "e", "E", "e", "E", "e", "E", "e", "E", "e", "E", "e", "G", "g", "I", "i", "I", "i", "I", "i", "I", "i", "L", "l", "L", "l", "L", "l", "N", "n", "N", "n", "N", "n", "O", "o", "O", "o", "O", "o", "O", "o", "Oe", "oe", "O", "o", "o", "R", "r", "R", "r", "S", "s", "S", "s", "S", "s", "T", "t", "T", "t", "T", "t", "U", "u", "U", "u", "U", "u", "Ue", "ue", "U", "u", "Y", "y", "Y", "y", "Z", "z", "Z", "z", "Z", "z", "TH", "th", "DH", "dh", "ss", "OE", "oe", "AE", "ae", "u"];
4269 var d = {
4270 "[\xa0\u2002\u2003\u2009]": " ",
4271 "\xb7": "*",
4272 "[\u2018\u2019]": "'",
4273 "[\u201c\u201d]": '"',
4274 "\u2026": "...",
4275 "\u2013": "-",
4276 "\u2014": "--",
4277 "\uFFFD": "&raquo;"
4279 var c = function (f, g) {
4280 f = f || "";
4281 var h = g ? "<" + f + "[^>]*>([\\s\\S]*?)</" + f + ">" : "</?" + f + "([^>]+)?>";
4282 reg = new RegExp(h, "gi");
4283 return reg
4285 String.implement({
4286 standardize: function () {
4287 var f = this;
4288 b.each(function (h, g) {
4289 f = f.replace(new RegExp(h, "g"), a[g])
4291 return f
4293 repeat: function (f) {
4294 return new Array(f + 1).join(this)
4296 pad: function (g, i, f) {
4297 if (this.length >= g) {
4298 return this
4300 var h = (i == null ? " " : "" + i).repeat(g - this.length).substr(0, g - this.length);
4301 if (!f || f == "right") {
4302 return this + h
4304 if (f == "left") {
4305 return h + this
4307 return h.substr(0, (h.length / 2).floor()) + this + h.substr(0, (h.length / 2).ceil())
4309 getTags: function (f, g) {
4310 return this.match(c(f, g)) || []
4312 stripTags: function (f, g) {
4313 return this.replace(c(f, g), "")
4315 tidy: function () {
4316 var f = this.toString();
4317 $each(d, function (h, g) {
4318 f = f.replace(new RegExp(g, "g"), h)
4320 return f
4323 })();
4324 String.implement({
4325 parseQueryString: function () {
4326 var b = this.split(/[&;]/),
4327 a = {};
4328 if (b.length) {
4329 b.each(function (h) {
4330 var c = h.indexOf("="),
4331 d = c < 0 ? [""] : h.substr(0, c).match(/[^\]\[]+/g),
4332 f = decodeURIComponent(h.substr(c + 1)),
4333 g = a;
4334 d.each(function (k, j) {
4335 var l = g[k];
4336 if (j < d.length - 1) {
4337 g = g[k] = l || {}
4338 } else {
4339 if ($type(l) == "array") {
4340 l.push(f)
4341 } else {
4342 g[k] = $defined(l) ? [l, f] : f
4348 return a
4350 cleanQueryString: function (a) {
4351 return this.split("&").filter(function (f) {
4352 var b = f.indexOf("="),
4353 c = b < 0 ? "" : f.substr(0, b),
4354 d = f.substr(b + 1);
4355 return a ? a.run([c, d]) : $chk(d)
4356 }).join("&")
4359 var URI = new Class({
4360 Implements: Options,
4361 options: {},
4362 regex: /^(?:(\w+):)?(?:\/\/(?:(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)?(\.\.?$|(?:[^?#\/]*\/)*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/,
4363 parts: ["scheme", "user", "password", "host", "port", "directory", "file", "query", "fragment"],
4364 schemes: {
4365 http: 80,
4366 https: 443,
4367 ftp: 21,
4368 rtsp: 554,
4369 mms: 1755,
4370 file: 0
4372 initialize: function (b, a) {
4373 this.setOptions(a);
4374 var c = this.options.base || URI.base;
4375 if (!b) {
4376 b = c
4378 if (b && b.parsed) {
4379 this.parsed = $unlink(b.parsed)
4380 } else {
4381 this.set("value", b.href || b.toString(), c ? new URI(c) : false)
4384 parse: function (c, b) {
4385 var a = c.match(this.regex);
4386 if (!a) {
4387 return false
4389 a.shift();
4390 return this.merge(a.associate(this.parts), b)
4392 merge: function (b, a) {
4393 if ((!b || !b.scheme) && (!a || !a.scheme)) {
4394 return false
4396 if (a) {
4397 this.parts.every(function (c) {
4398 if (b[c]) {
4399 return false
4401 b[c] = a[c] || "";
4402 return true
4405 b.port = b.port || this.schemes[b.scheme.toLowerCase()];
4406 b.directory = b.directory ? this.parseDirectory(b.directory, a ? a.directory : "") : "/";
4407 return b
4409 parseDirectory: function (b, c) {
4410 b = (b.substr(0, 1) == "/" ? "" : (c || "/")) + b;
4411 if (!b.test(URI.regs.directoryDot)) {
4412 return b
4414 var a = [];
4415 b.replace(URI.regs.endSlash, "").split("/").each(function (d) {
4416 if (d == ".." && a.length > 0) {
4417 a.pop()
4418 } else {
4419 if (d != ".") {
4420 a.push(d)
4424 return a.join("/") + "/"
4426 combine: function (a) {
4427 return a.value || a.scheme + "://" + (a.user ? a.user + (a.password ? ":" + a.password : "") + "@" : "") + (a.host || "") + (a.port && a.port != this.schemes[a.scheme] ? ":" + a.port : "") + (a.directory || "/") + (a.file || "") + (a.query ? "?" + a.query : "") + (a.fragment ? "#" + a.fragment : "")
4429 set: function (b, d, c) {
4430 if (b == "value") {
4431 var a = d.match(URI.regs.scheme);
4432 if (a) {
4433 a = a[1]
4435 if (a && !$defined(this.schemes[a.toLowerCase()])) {
4436 this.parsed = {
4437 scheme: a,
4438 value: d
4440 } else {
4441 this.parsed = this.parse(d, (c || this).parsed) || (a ? {
4442 scheme: a,
4443 value: d
4444 } : {
4445 value: d
4448 } else {
4449 if (b == "data") {
4450 this.setData(d)
4451 } else {
4452 this.parsed[b] = d
4455 return this
4457 get: function (a, b) {
4458 switch (a) {
4459 case "value":
4460 return this.combine(this.parsed, b ? b.parsed : false);
4461 case "data":
4462 return this.getData()
4464 return this.parsed[a] || ""
4466 go: function () {
4467 document.location.href = this.toString()
4469 toURI: function () {
4470 return this
4472 getData: function (c, b) {
4473 var a = this.get(b || "query");
4474 if (!$chk(a)) {
4475 return c ? null : {}
4477 var d = a.parseQueryString();
4478 return c ? d[c] : d
4480 setData: function (a, c, b) {
4481 if (typeof a == "string") {
4482 data = this.getData();
4483 data[arguments[0]] = arguments[1];
4484 a = data
4485 } else {
4486 if (c) {
4487 a = $merge(this.getData(), a)
4490 return this.set(b || "query", Hash.toQueryString(a))
4492 clearData: function (a) {
4493 return this.set(a || "query", "")
4496 URI.prototype.toString = URI.prototype.valueOf = function () {
4497 return this.get("value")
4499 URI.regs = {
4500 endSlash: /\/$/,
4501 scheme: /^(\w+):/,
4502 directoryDot: /\.\/|\.$/
4504 URI.base = new URI(document.getElements("base[href]", true).getLast(), {
4505 base: document.location
4507 String.implement({
4508 toURI: function (a) {
4509 return new URI(this, a)
4512 Element.implement({
4513 tidy: function () {
4514 this.set("value", this.get("value").tidy())
4516 getTextInRange: function (b, a) {
4517 return this.get("value").substring(b, a)
4519 getSelectedText: function () {
4520 if (this.setSelectionRange) {
4521 return this.getTextInRange(this.getSelectionStart(), this.getSelectionEnd())
4523 return document.selection.createRange().text
4525 getSelectedRange: function () {
4526 if ($defined(this.selectionStart)) {
4527 return {
4528 start: this.selectionStart,
4529 end: this.selectionEnd
4532 var f = {
4533 start: 0,
4534 end: 0
4536 var a = this.getDocument().selection.createRange();
4537 if (!a || a.parentElement() != this) {
4538 return f
4540 var c = a.duplicate();
4541 if (this.type == "text") {
4542 f.start = 0 - c.moveStart("character", -100000);
4543 f.end = f.start + a.text.length
4544 } else {
4545 var b = this.get("value");
4546 var d = b.length;
4547 c.moveToElementText(this);
4548 c.setEndPoint("StartToEnd", a);
4549 if (c.text.length) {
4550 d -= b.match(/[\n\r]*$/)[0].length
4552 f.end = d - c.text.length;
4553 c.setEndPoint("StartToStart", a);
4554 f.start = d - c.text.length
4556 return f
4558 getSelectionStart: function () {
4559 return this.getSelectedRange().start
4561 getSelectionEnd: function () {
4562 return this.getSelectedRange().end
4564 setCaretPosition: function (a) {
4565 if (a == "end") {
4566 a = this.get("value").length
4568 this.selectRange(a, a);
4569 return this
4571 getCaretPosition: function () {
4572 return this.getSelectedRange().start
4574 selectRange: function (f, a) {
4575 if (this.setSelectionRange) {
4576 this.focus();
4577 this.setSelectionRange(f, a)
4578 } else {
4579 var c = this.get("value");
4580 var d = c.substr(f, a - f).replace(/\r/g, "").length;
4581 f = c.substr(0, f).replace(/\r/g, "").length;
4582 var b = this.createTextRange();
4583 b.collapse(true);
4584 b.moveEnd("character", f + d);
4585 b.moveStart("character", f);
4586 b.select()
4588 return this
4590 insertAtCursor: function (b, a) {
4591 var d = this.getSelectedRange();
4592 var c = this.get("value");
4593 this.set("value", c.substring(0, d.start) + b + c.substring(d.end, c.length));
4594 if ($pick(a, true)) {
4595 this.selectRange(d.start, d.start + b.length)
4596 } else {
4597 this.setCaretPosition(d.start + b.length)
4599 return this
4601 insertAroundCursor: function (b, a) {
4602 b = $extend({
4603 before: "",
4604 defaultMiddle: "",
4605 after: ""
4606 }, b);
4607 var c = this.getSelectedText() || b.defaultMiddle;
4608 var h = this.getSelectedRange();
4609 var g = this.get("value");
4610 if (h.start == h.end) {
4611 this.set("value", g.substring(0, h.start) + b.before + c + b.after + g.substring(h.end, g.length));
4612 this.selectRange(h.start + b.before.length, h.end + b.before.length + c.length)
4613 } else {
4614 var d = g.substring(h.start, h.end);
4615 this.set("value", g.substring(0, h.start) + b.before + d + b.after + g.substring(h.end, g.length));
4616 var f = h.start + b.before.length;
4617 if ($pick(a, true)) {
4618 this.selectRange(f, f + d.length)
4619 } else {
4620 this.setCaretPosition(f + g.length)
4623 return this
4626 Elements.from = function (f, d) {
4627 if ($pick(d, true)) {
4628 f = f.stripScripts()
4630 var b, c = f.match(/^\s*<(t[dhr]|tbody|tfoot|thead)/i);
4631 if (c) {
4632 b = new Element("table");
4633 var a = c[1].toLowerCase();
4634 if (["td", "th", "tr"].contains(a)) {
4635 b = new Element("tbody").inject(b);
4636 if (a != "tr") {
4637 b = new Element("tr").inject(b)
4641 return (b || new Element("div")).set("html", f).getChildren()
4643 Element.implement({
4644 measure: function (f) {
4645 var h = function (i) {
4646 return !!(!i || i.offsetHeight || i.offsetWidth)
4648 if (h(this)) {
4649 return f.apply(this)
4651 var d = this.getParent(),
4652 g = [],
4653 b = [];
4654 while (!h(d) && d != document.body) {
4655 b.push(d.expose());
4656 d = d.getParent()
4658 var c = this.expose();
4659 var a = f.apply(this);
4660 c();
4661 b.each(function (i) {
4664 return a
4666 expose: function () {
4667 if (this.getStyle("display") != "none") {
4668 return $empty
4670 var a = this.style.cssText;
4671 this.setStyles({
4672 display: "block",
4673 position: "absolute",
4674 visibility: "hidden"
4676 return function () {
4677 this.style.cssText = a
4678 }.bind(this)
4680 getDimensions: function (a) {
4681 a = $merge({
4682 computeSize: false
4683 }, a);
4684 var f = {};
4685 var d = function (h, g) {
4686 return (g.computeSize) ? h.getComputedSize(g) : h.getSize()
4688 var b = this.getParent("body");
4689 if (b && this.getStyle("display") == "none") {
4690 f = this.measure(function () {
4691 return d(this, a)
4693 } else {
4694 if (b) {
4695 try {
4696 f = d(this, a)
4697 } catch (c) {}
4698 } else {
4699 f = {
4700 x: 0,
4701 y: 0
4705 return $chk(f.x) ? $extend(f, {
4706 width: f.x,
4707 height: f.y
4708 }) : $extend(f, {
4709 x: f.width,
4710 y: f.height
4713 getComputedSize: function (a) {
4714 a = $merge({
4715 styles: ["padding", "border"],
4716 plains: {
4717 height: ["top", "bottom"],
4718 width: ["left", "right"]
4720 mode: "both"
4721 }, a);
4722 var c = {
4723 width: 0,
4724 height: 0
4726 switch (a.mode) {
4727 case "vertical":
4728 delete c.width;
4729 delete a.plains.width;
4730 break;
4731 case "horizontal":
4732 delete c.height;
4733 delete a.plains.height;
4734 break
4736 var b = [];
4737 $each(a.plains, function (h, g) {
4738 h.each(function (i) {
4739 a.styles.each(function (j) {
4740 b.push((j == "border") ? j + "-" + i + "-width" : j + "-" + i)
4744 var f = {};
4745 b.each(function (g) {
4746 f[g] = this.getComputedStyle(g)
4747 }, this);
4748 var d = [];
4749 $each(a.plains, function (h, g) {
4750 var i = g.capitalize();
4751 c["total" + i] = c["computed" + i] = 0;
4752 h.each(function (j) {
4753 c["computed" + j.capitalize()] = 0;
4754 b.each(function (l, k) {
4755 if (l.test(j)) {
4756 f[l] = f[l].toInt() || 0;
4757 c["total" + i] = c["total" + i] + f[l];
4758 c["computed" + j.capitalize()] = c["computed" + j.capitalize()] + f[l]
4760 if (l.test(j) && g != l && (l.test("border") || l.test("padding")) && !d.contains(l)) {
4761 d.push(l);
4762 c["computed" + i] = c["computed" + i] - f[l]
4767 ["Width", "Height"].each(function (h) {
4768 var g = h.toLowerCase();
4769 if (!$chk(c[g])) {
4770 return
4772 c[g] = c[g] + this["offset" + h] + c["computed" + h];
4773 c["total" + h] = c[g] + c["total" + h];
4774 delete c["computed" + h]
4775 }, this);
4776 return $extend(f, c)
4779 (function () {
4780 var a = Element.prototype.position;
4781 Element.implement({
4782 position: function (h) {
4783 if (h && ($defined(h.x) || $defined(h.y))) {
4784 return a ? a.apply(this, arguments) : this
4786 $each(h || {}, function (w, u) {
4787 if (!$defined(w)) {
4788 delete h[u]
4791 h = $merge({
4792 relativeTo: document.body,
4793 position: {
4794 x: "center",
4795 y: "center"
4797 edge: false,
4798 offset: {
4799 x: 0,
4800 y: 0
4802 returnPos: false,
4803 relFixedPosition: false,
4804 ignoreMargins: false,
4805 ignoreScroll: false,
4806 allowNegative: false
4807 }, h);
4808 var s = {
4809 x: 0,
4810 y: 0
4812 f = false;
4813 var c = this.measure(function () {
4814 return document.id(this.getOffsetParent())
4816 if (c && c != this.getDocument().body) {
4817 s = c.measure(function () {
4818 return this.getPosition()
4820 f = c != document.id(h.relativeTo);
4821 h.offset.x = h.offset.x - s.x;
4822 h.offset.y = h.offset.y - s.y
4824 var t = function (u) {
4825 if ($type(u) != "string") {
4826 return u
4828 u = u.toLowerCase();
4829 var v = {};
4830 if (u.test("left")) {
4831 v.x = "left"
4832 } else {
4833 if (u.test("right")) {
4834 v.x = "right"
4835 } else {
4836 v.x = "center"
4839 if (u.test("upper") || u.test("top")) {
4840 v.y = "top"
4841 } else {
4842 if (u.test("bottom")) {
4843 v.y = "bottom"
4844 } else {
4845 v.y = "center"
4848 return v
4850 h.edge = t(h.edge);
4851 h.position = t(h.position);
4852 if (!h.edge) {
4853 if (h.position.x == "center" && h.position.y == "center") {
4854 h.edge = {
4855 x: "center",
4856 y: "center"
4858 } else {
4859 h.edge = {
4860 x: "left",
4861 y: "top"
4865 this.setStyle("position", "absolute");
4866 var g = document.id(h.relativeTo) || document.body,
4867 d = g == document.body ? window.getScroll() : g.getPosition(),
4868 m = d.y,
4869 i = d.x;
4870 var o = this.getDimensions({
4871 computeSize: true,
4872 styles: ["padding", "border", "margin"]
4874 var k = {},
4875 p = h.offset.y,
4876 r = h.offset.x,
4877 l = window.getSize();
4878 switch (h.position.x) {
4879 case "left":
4880 k.x = i + r;
4881 break;
4882 case "right":
4883 k.x = i + r + g.offsetWidth;
4884 break;
4885 default:
4886 k.x = i + ((g == document.body ? l.x : g.offsetWidth) / 2) + r;
4887 break
4889 switch (h.position.y) {
4890 case "top":
4891 k.y = m + p;
4892 break;
4893 case "bottom":
4894 k.y = m + p + g.offsetHeight;
4895 break;
4896 default:
4897 k.y = m + ((g == document.body ? l.y : g.offsetHeight) / 2) + p;
4898 break
4900 if (h.edge) {
4901 var b = {};
4902 switch (h.edge.x) {
4903 case "left":
4904 b.x = 0;
4905 break;
4906 case "right":
4907 b.x = -o.x - o.computedRight - o.computedLeft;
4908 break;
4909 default:
4910 b.x = -(o.totalWidth / 2);
4911 break
4913 switch (h.edge.y) {
4914 case "top":
4915 b.y = 0;
4916 break;
4917 case "bottom":
4918 b.y = -o.y - o.computedTop - o.computedBottom;
4919 break;
4920 default:
4921 b.y = -(o.totalHeight / 2);
4922 break
4924 k.x += b.x;
4925 k.y += b.y
4927 k = {
4928 left: ((k.x >= 0 || f || h.allowNegative) ? k.x : 0).toInt(),
4929 top: ((k.y >= 0 || f || h.allowNegative) ? k.y : 0).toInt()
4931 var j = {
4932 left: "x",
4933 top: "y"
4935 ["minimum", "maximum"].each(function (u) {
4936 ["left", "top"].each(function (v) {
4937 var w = h[u] ? h[u][j[v]] : null;
4938 if (w != null && k[v] < w) {
4939 k[v] = w
4943 if (g.getStyle("position") == "fixed" || h.relFixedPosition) {
4944 var n = window.getScroll();
4945 k.top += n.y;
4946 k.left += n.x
4948 if (h.ignoreScroll) {
4949 var q = g.getScroll();
4950 k.top -= q.y;
4951 k.left -= q.x
4953 if (h.ignoreMargins) {
4954 k.left += (h.edge.x == "right" ? o["margin-right"] : h.edge.x == "center" ? -o["margin-left"] + ((o["margin-right"] + o["margin-left"]) / 2) : -o["margin-left"]);
4955 k.top += (h.edge.y == "bottom" ? o["margin-bottom"] : h.edge.y == "center" ? -o["margin-top"] + ((o["margin-bottom"] + o["margin-top"]) / 2) : -o["margin-top"])
4957 k.left = Math.ceil(k.left);
4958 k.top = Math.ceil(k.top);
4959 if (h.returnPos) {
4960 return k
4961 } else {
4962 this.setStyles(k)
4964 return this
4967 })();
4968 Element.implement({
4969 isDisplayed: function () {
4970 return this.getStyle("display") != "none"
4972 isVisible: function () {
4973 var a = this.offsetWidth,
4974 b = this.offsetHeight;
4975 return (a == 0 && b == 0) ? false : (a > 0 && b > 0) ? true : this.isDisplayed()
4977 toggle: function () {
4978 return this[this.isDisplayed() ? "hide" : "show"]()
4980 hide: function () {
4981 var b;
4982 try {
4983 b = this.getStyle("display")
4984 } catch (a) {}
4985 return this.store("originalDisplay", b || "").setStyle("display", "none")
4987 show: function (a) {
4988 a = a || this.retrieve("originalDisplay") || "block";
4989 return this.setStyle("display", (a == "none") ? "block" : a)
4991 swapClass: function (a, b) {
4992 return this.removeClass(a).addClass(b)
4995 var OverText = new Class({
4996 Implements: [Options, Events, Class.Occlude],
4997 Binds: ["reposition", "assert", "focus", "hide"],
4998 options: {
4999 element: "label",
5000 positionOptions: {
5001 position: "upperLeft",
5002 edge: "upperLeft",
5003 offset: {
5004 x: 4,
5005 y: 2
5008 poll: false,
5009 pollInterval: 250,
5010 wrap: false
5012 property: "OverText",
5013 initialize: function (b, a) {
5014 this.element = document.id(b);
5015 if (this.occlude()) {
5016 return this.occluded
5018 this.setOptions(a);
5019 this.attach(this.element);
5020 OverText.instances.push(this);
5021 if (this.options.poll) {
5022 this.poll()
5024 return this
5026 toElement: function () {
5027 return this.element
5029 attach: function () {
5030 var a = this.options.textOverride || this.element.get("alt") || this.element.get("title");
5031 if (!a) {
5032 return
5034 this.text = new Element(this.options.element, {
5035 "class": "overTxtLabel",
5036 styles: {
5037 lineHeight: "normal",
5038 position: "absolute",
5039 cursor: "text"
5041 html: a,
5042 events: {
5043 click: this.hide.pass(this.options.element == "label", this)
5045 }).inject(this.element, "after");
5046 if (this.options.element == "label") {
5047 if (!this.element.get("id")) {
5048 this.element.set("id", "input_" + new Date().getTime())
5050 this.text.set("for", this.element.get("id"))
5052 if (this.options.wrap) {
5053 this.textHolder = new Element("div", {
5054 styles: {
5055 lineHeight: "normal",
5056 position: "relative"
5058 "class": "overTxtWrapper"
5059 }).adopt(this.text).inject(this.element, "before")
5061 this.element.addEvents({
5062 focus: this.focus,
5063 blur: this.assert,
5064 change: this.assert
5065 }).store("OverTextDiv", this.text);
5066 window.addEvent("resize", this.reposition.bind(this));
5067 this.assert(true);
5068 this.reposition()
5070 wrap: function () {
5071 if (this.options.element == "label") {
5072 if (!this.element.get("id")) {
5073 this.element.set("id", "input_" + new Date().getTime())
5075 this.text.set("for", this.element.get("id"))
5078 startPolling: function () {
5079 this.pollingPaused = false;
5080 return this.poll()
5082 poll: function (a) {
5083 if (this.poller && !a) {
5084 return this
5086 var b = function () {
5087 if (!this.pollingPaused) {
5088 this.assert(true)
5090 }.bind(this);
5091 if (a) {
5092 $clear(this.poller)
5093 } else {
5094 this.poller = b.periodical(this.options.pollInterval, this)
5096 return this
5098 stopPolling: function () {
5099 this.pollingPaused = true;
5100 return this.poll(true)
5102 focus: function () {
5103 if (this.text && (!this.text.isDisplayed() || this.element.get("disabled"))) {
5104 return
5106 this.hide()
5108 hide: function (c, a) {
5109 if (this.text && (this.text.isDisplayed() && (!this.element.get("disabled") || a))) {
5110 this.text.hide();
5111 this.fireEvent("textHide", [this.text, this.element]);
5112 this.pollingPaused = true;
5113 if (!c) {
5114 try {
5115 this.element.fireEvent("focus");
5116 this.element.focus()
5117 } catch (b) {}
5120 return this
5122 show: function () {
5123 if (this.text && !this.text.isDisplayed()) {
5124 this.text.show();
5125 this.reposition();
5126 this.fireEvent("textShow", [this.text, this.element]);
5127 this.pollingPaused = false
5129 return this
5131 assert: function (a) {
5132 this[this.test() ? "show" : "hide"](a)
5134 test: function () {
5135 var a = this.element.get("value");
5136 return !a
5138 reposition: function () {
5139 this.assert(true);
5140 if (!this.element.isVisible()) {
5141 return this.stopPolling().hide()
5143 if (this.text && this.test()) {
5144 this.text.position($merge(this.options.positionOptions, {
5145 relativeTo: this.element
5148 return this
5151 OverText.instances = [];
5152 $extend(OverText, {
5153 each: function (a) {
5154 return OverText.instances.map(function (c, b) {
5155 if (c.element && c.text) {
5156 return a.apply(OverText, [c, b])
5158 return null
5161 update: function () {
5162 return OverText.each(function (a) {
5163 return a.reposition()
5166 hideAll: function () {
5167 return OverText.each(function (a) {
5168 return a.hide(true, true)
5171 showAll: function () {
5172 return OverText.each(function (a) {
5173 return a.show()
5177 if (window.Fx && Fx.Reveal) {
5178 Fx.Reveal.implement({
5179 hideInputs: Browser.Engine.trident ? "select, input, textarea, object, embed, .overTxtLabel" : false
5182 Fx.Elements = new Class({
5183 Extends: Fx.CSS,
5184 initialize: function (b, a) {
5185 this.elements = this.subject = $$(b);
5186 this.parent(a)
5188 compute: function (h, j, k) {
5189 var c = {};
5190 for (var d in h) {
5191 var a = h[d],
5192 f = j[d],
5193 g = c[d] = {};
5194 for (var b in a) {
5195 g[b] = this.parent(a[b], f[b], k)
5198 return c
5200 set: function (b) {
5201 for (var c in b) {
5202 var a = b[c];
5203 for (var d in a) {
5204 this.render(this.elements[c], d, a[d], this.options.unit)
5207 return this
5209 start: function (c) {
5210 if (!this.check(c)) {
5211 return this
5213 var j = {},
5214 k = {};
5215 for (var d in c) {
5216 var g = c[d],
5217 a = j[d] = {},
5218 h = k[d] = {};
5219 for (var b in g) {
5220 var f = this.prepare(this.elements[d], b, g[b]);
5221 a[b] = f.from;
5222 h[b] = f.to
5225 return this.parent(j, k)
5228 Fx.Accordion = new Class({
5229 Extends: Fx.Elements,
5230 options: {
5231 display: 0,
5232 show: false,
5233 height: true,
5234 width: false,
5235 opacity: true,
5236 alwaysHide: false,
5237 trigger: "click",
5238 initialDisplayFx: true,
5239 returnHeightToAuto: true
5241 initialize: function () {
5242 var c = Array.link(arguments, {
5243 container: Element.type,
5244 options: Object.type,
5245 togglers: $defined,
5246 elements: $defined
5248 this.parent(c.elements, c.options);
5249 this.togglers = $$(c.togglers);
5250 this.previous = -1;
5251 this.internalChain = new Chain();
5252 if (this.options.alwaysHide) {
5253 this.options.wait = true
5255 if ($chk(this.options.show)) {
5256 this.options.display = false;
5257 this.previous = this.options.show
5259 if (this.options.start) {
5260 this.options.display = false;
5261 this.options.show = false
5263 this.effects = {};
5264 if (this.options.opacity) {
5265 this.effects.opacity = "fullOpacity"
5267 if (this.options.width) {
5268 this.effects.width = this.options.fixedWidth ? "fullWidth" : "offsetWidth"
5270 if (this.options.height) {
5271 this.effects.height = this.options.fixedHeight ? "fullHeight" : "scrollHeight"
5273 for (var b = 0, a = this.togglers.length; b < a; b++) {
5274 this.addSection(this.togglers[b], this.elements[b])
5276 this.elements.each(function (f, d) {
5277 if (this.options.show === d) {
5278 this.fireEvent("active", [this.togglers[d], f])
5279 } else {
5280 for (var g in this.effects) {
5281 f.setStyle(g, 0)
5284 }, this);
5285 if ($chk(this.options.display) || this.options.initialDisplayFx === false) {
5286 this.display(this.options.display, this.options.initialDisplayFx)
5288 if (this.options.fixedHeight !== false) {
5289 this.options.returnHeightToAuto = false
5291 this.addEvent("complete", this.internalChain.callChain.bind(this.internalChain))
5293 addSection: function (f, c) {
5294 f = document.id(f);
5295 c = document.id(c);
5296 var g = this.togglers.contains(f);
5297 this.togglers.include(f);
5298 this.elements.include(c);
5299 var a = this.togglers.indexOf(f);
5300 var b = this.display.bind(this, a);
5301 f.store("accordion:display", b);
5302 f.addEvent(this.options.trigger, b);
5303 if (this.options.height) {
5304 c.setStyles({
5305 "padding-top": 0,
5306 "border-top": "none",
5307 "padding-bottom": 0,
5308 "border-bottom": "none"
5311 if (this.options.width) {
5312 c.setStyles({
5313 "padding-left": 0,
5314 "border-left": "none",
5315 "padding-right": 0,
5316 "border-right": "none"
5319 c.fullOpacity = 1;
5320 if (this.options.fixedWidth) {
5321 c.fullWidth = this.options.fixedWidth
5323 if (this.options.fixedHeight) {
5324 c.fullHeight = this.options.fixedHeight
5326 c.setStyle("overflow", "hidden");
5327 if (!g) {
5328 for (var d in this.effects) {
5329 c.setStyle(d, 0)
5332 return this
5334 detach: function () {
5335 this.togglers.each(function (a) {
5336 a.removeEvent(this.options.trigger, a.retrieve("accordion:display"))
5337 }, this)
5339 display: function (a, b) {
5340 if (!this.check(a, b)) {
5341 return this
5343 b = $pick(b, true);
5344 if (this.options.returnHeightToAuto) {
5345 var d = this.elements[this.previous];
5346 if (d && !this.selfHidden) {
5347 for (var c in this.effects) {
5348 d.setStyle(c, d[this.effects[c]])
5352 a = ($type(a) == "element") ? this.elements.indexOf(a) : a;
5353 if ((this.timer && this.options.wait) || (a === this.previous && !this.options.alwaysHide)) {
5354 return this
5356 this.previous = a;
5357 var f = {};
5358 this.elements.each(function (j, h) {
5359 f[h] = {};
5360 var g;
5361 if (h != a) {
5362 g = true
5363 } else {
5364 if (this.options.alwaysHide && ((j.offsetHeight > 0 && this.options.height) || j.offsetWidth > 0 && this.options.width)) {
5365 g = true;
5366 this.selfHidden = true
5369 this.fireEvent(g ? "background" : "active", [this.togglers[h], j]);
5370 for (var k in this.effects) {
5371 f[h][k] = g ? 0 : j[this.effects[k]]
5373 }, this);
5374 this.internalChain.chain(function () {
5375 if (this.options.returnHeightToAuto && !this.selfHidden) {
5376 var g = this.elements[a];
5377 if (g) {
5378 g.setStyle("height", "auto")
5381 }.bind(this));
5382 return b ? this.start(f) : this.set(f)
5385 var Accordion = new Class({
5386 Extends: Fx.Accordion,
5387 initialize: function () {
5388 this.parent.apply(this, arguments);
5389 var a = Array.link(arguments, {
5390 container: Element.type
5392 this.container = a.container
5394 addSection: function (c, b, f) {
5395 c = document.id(c);
5396 b = document.id(b);
5397 var d = this.togglers.contains(c);
5398 var a = this.togglers.length;
5399 if (a && (!d || f)) {
5400 f = $pick(f, a - 1);
5401 c.inject(this.togglers[f], "before");
5402 b.inject(c, "after")
5403 } else {
5404 if (this.container && !d) {
5405 c.inject(this.container);
5406 b.inject(this.container)
5409 return this.parent.apply(this, arguments)
5412 Fx.Move = new Class({
5413 Extends: Fx.Morph,
5414 options: {
5415 relativeTo: document.body,
5416 position: "center",
5417 edge: false,
5418 offset: {
5419 x: 0,
5420 y: 0
5423 start: function (a) {
5424 return this.parent(this.element.position($merge(this.options, a, {
5425 returnPos: true
5426 })))
5429 Element.Properties.move = {
5430 set: function (a) {
5431 var b = this.retrieve("move");
5432 if (b) {
5433 b.cancel()
5435 return this.eliminate("move").store("move:options", $extend({
5436 link: "cancel"
5437 }, a))
5439 get: function (a) {
5440 if (a || !this.retrieve("move")) {
5441 if (a || !this.retrieve("move:options")) {
5442 this.set("move", a)
5444 this.store("move", new Fx.Move(this, this.retrieve("move:options")))
5446 return this.retrieve("move")
5449 Element.implement({
5450 move: function (a) {
5451 this.get("move").start(a);
5452 return this
5455 Fx.Reveal = new Class({
5456 Extends: Fx.Morph,
5457 options: {
5458 link: "cancel",
5459 styles: ["padding", "border", "margin"],
5460 transitionOpacity: !Browser.Engine.trident4,
5461 mode: "vertical",
5462 display: "block",
5463 hideInputs: Browser.Engine.trident ? "select, input, textarea, object, embed" : false
5465 dissolve: function () {
5466 try {
5467 if (!this.hiding && !this.showing) {
5468 if (this.element.getStyle("display") != "none") {
5469 this.hiding = true;
5470 this.showing = false;
5471 this.hidden = true;
5472 this.cssText = this.element.style.cssText;
5473 var d = this.element.getComputedSize({
5474 styles: this.options.styles,
5475 mode: this.options.mode
5477 this.element.setStyle("display", this.options.display);
5478 if (this.options.transitionOpacity) {
5479 d.opacity = 1
5481 var b = {};
5482 $each(d, function (g, f) {
5483 b[f] = [g, 0]
5484 }, this);
5485 this.element.setStyle("overflow", "hidden");
5486 var a = this.options.hideInputs ? this.element.getElements(this.options.hideInputs) : null;
5487 this.$chain.unshift(function () {
5488 if (this.hidden) {
5489 this.hiding = false;
5490 $each(d, function (g, f) {
5491 d[f] = g
5492 }, this);
5493 this.element.style.cssText = this.cssText;
5494 this.element.setStyle("display", "none");
5495 if (a) {
5496 a.setStyle("visibility", "visible")
5499 this.fireEvent("hide", this.element);
5500 this.callChain()
5501 }.bind(this));
5502 if (a) {
5503 a.setStyle("visibility", "hidden")
5505 this.start(b)
5506 } else {
5507 this.callChain.delay(10, this);
5508 this.fireEvent("complete", this.element);
5509 this.fireEvent("hide", this.element)
5511 } else {
5512 if (this.options.link == "chain") {
5513 this.chain(this.dissolve.bind(this))
5514 } else {
5515 if (this.options.link == "cancel" && !this.hiding) {
5516 this.cancel();
5517 this.dissolve()
5521 } catch (c) {
5522 this.hiding = false;
5523 this.element.setStyle("display", "none");
5524 this.callChain.delay(10, this);
5525 this.fireEvent("complete", this.element);
5526 this.fireEvent("hide", this.element)
5528 return this
5530 reveal: function () {
5531 try {
5532 if (!this.showing && !this.hiding) {
5533 if (this.element.getStyle("display") == "none" || this.element.getStyle("visiblity") == "hidden" || this.element.getStyle("opacity") == 0) {
5534 this.showing = true;
5535 this.hiding = this.hidden = false;
5536 var d;
5537 this.cssText = this.element.style.cssText;
5538 this.element.measure(function () {
5539 d = this.element.getComputedSize({
5540 styles: this.options.styles,
5541 mode: this.options.mode
5543 }.bind(this));
5544 $each(d, function (g, f) {
5545 d[f] = g
5547 if ($chk(this.options.heightOverride)) {
5548 d.height = this.options.heightOverride.toInt()
5550 if ($chk(this.options.widthOverride)) {
5551 d.width = this.options.widthOverride.toInt()
5553 if (this.options.transitionOpacity) {
5554 this.element.setStyle("opacity", 0);
5555 d.opacity = 1
5557 var b = {
5558 height: 0,
5559 display: this.options.display
5561 $each(d, function (g, f) {
5562 b[f] = 0
5564 this.element.setStyles($merge(b, {
5565 overflow: "hidden"
5566 }));
5567 var a = this.options.hideInputs ? this.element.getElements(this.options.hideInputs) : null;
5568 if (a) {
5569 a.setStyle("visibility", "hidden")
5571 this.start(d);
5572 this.$chain.unshift(function () {
5573 this.element.style.cssText = this.cssText;
5574 this.element.setStyle("display", this.options.display);
5575 if (!this.hidden) {
5576 this.showing = false
5578 if (a) {
5579 a.setStyle("visibility", "visible")
5581 this.callChain();
5582 this.fireEvent("show", this.element)
5583 }.bind(this))
5584 } else {
5585 this.callChain();
5586 this.fireEvent("complete", this.element);
5587 this.fireEvent("show", this.element)
5589 } else {
5590 if (this.options.link == "chain") {
5591 this.chain(this.reveal.bind(this))
5592 } else {
5593 if (this.options.link == "cancel" && !this.showing) {
5594 this.cancel();
5595 this.reveal()
5599 } catch (c) {
5600 this.element.setStyles({
5601 display: this.options.display,
5602 visiblity: "visible",
5603 opacity: 1
5605 this.showing = false;
5606 this.callChain.delay(10, this);
5607 this.fireEvent("complete", this.element);
5608 this.fireEvent("show", this.element)
5610 return this
5612 toggle: function () {
5613 if (this.element.getStyle("display") == "none" || this.element.getStyle("visiblity") == "hidden" || this.element.getStyle("opacity") == 0) {
5614 this.reveal()
5615 } else {
5616 this.dissolve()
5618 return this
5620 cancel: function () {
5621 this.parent.apply(this, arguments);
5622 this.element.style.cssText = this.cssText;
5623 this.hidding = false;
5624 this.showing = false
5627 Element.Properties.reveal = {
5628 set: function (a) {
5629 var b = this.retrieve("reveal");
5630 if (b) {
5631 b.cancel()
5633 return this.eliminate("reveal").store("reveal:options", a)
5635 get: function (a) {
5636 if (a || !this.retrieve("reveal")) {
5637 if (a || !this.retrieve("reveal:options")) {
5638 this.set("reveal", a)
5640 this.store("reveal", new Fx.Reveal(this, this.retrieve("reveal:options")))
5642 return this.retrieve("reveal")
5645 Element.Properties.dissolve = Element.Properties.reveal;
5646 Element.implement({
5647 reveal: function (a) {
5648 this.get("reveal", a).reveal();
5649 return this
5651 dissolve: function (a) {
5652 this.get("reveal", a).dissolve();
5653 return this
5655 nix: function () {
5656 var a = Array.link(arguments, {
5657 destroy: Boolean.type,
5658 options: Object.type
5660 this.get("reveal", a.options).dissolve().chain(function () {
5661 this[a.destroy ? "destroy" : "dispose"]()
5662 }.bind(this));
5663 return this
5665 wink: function () {
5666 var b = Array.link(arguments, {
5667 duration: Number.type,
5668 options: Object.type
5670 var a = this.get("reveal", b.options);
5671 a.reveal().chain(function () {
5672 (function () {
5673 a.dissolve()
5674 }).delay(b.duration || 2000)
5678 Fx.Scroll = new Class({
5679 Extends: Fx,
5680 options: {
5681 offset: {
5682 x: 0,
5683 y: 0
5685 wheelStops: true
5687 initialize: function (b, a) {
5688 this.element = this.subject = document.id(b);
5689 this.parent(a);
5690 var d = this.cancel.bind(this, false);
5691 if ($type(this.element) != "element") {
5692 this.element = document.id(this.element.getDocument().body)
5694 var c = this.element;
5695 if (this.options.wheelStops) {
5696 this.addEvent("start", function () {
5697 c.addEvent("mousewheel", d)
5698 }, true);
5699 this.addEvent("complete", function () {
5700 c.removeEvent("mousewheel", d)
5701 }, true)
5704 set: function () {
5705 var a = Array.flatten(arguments);
5706 if (Browser.Engine.gecko) {
5707 a = [Math.round(a[0]), Math.round(a[1])]
5709 this.element.scrollTo(a[0], a[1])
5711 compute: function (c, b, a) {
5712 return [0, 1].map(function (d) {
5713 return Fx.compute(c[d], b[d], a)
5716 start: function (c, h) {
5717 if (!this.check(c, h)) {
5718 return this
5720 var f = this.element.getScrollSize(),
5721 b = this.element.getScroll(),
5722 d = {
5723 x: c,
5724 y: h
5726 for (var g in d) {
5727 var a = f[g];
5728 if ($chk(d[g])) {
5729 d[g] = ($type(d[g]) == "number") ? d[g] : a
5730 } else {
5731 d[g] = b[g]
5733 d[g] += this.options.offset[g]
5735 return this.parent([b.x, b.y], [d.x, d.y])
5737 toTop: function () {
5738 return this.start(false, 0)
5740 toLeft: function () {
5741 return this.start(0, false)
5743 toRight: function () {
5744 return this.start("right", false)
5746 toBottom: function () {
5747 return this.start(false, "bottom")
5749 toElement: function (b) {
5750 var a = document.id(b).getPosition(this.element);
5751 return this.start(a.x, a.y)
5753 scrollIntoView: function (c, f, d) {
5754 f = f ? $splat(f) : ["x", "y"];
5755 var i = {};
5756 c = document.id(c);
5757 var g = c.getPosition(this.element);
5758 var j = c.getSize();
5759 var h = this.element.getScroll();
5760 var a = this.element.getSize();
5761 var b = {
5762 x: g.x + j.x,
5763 y: g.y + j.y
5765 ["x", "y"].each(function (k) {
5766 if (f.contains(k)) {
5767 if (b[k] > h[k] + a[k]) {
5768 i[k] = b[k] - a[k]
5770 if (g[k] < h[k]) {
5771 i[k] = g[k]
5774 if (i[k] == null) {
5775 i[k] = h[k]
5777 if (d && d[k]) {
5778 i[k] = i[k] + d[k]
5780 }, this);
5781 if (i.x != h.x || i.y != h.y) {
5782 this.start(i.x, i.y)
5784 return this
5786 scrollToCenter: function (c, f, d) {
5787 f = f ? $splat(f) : ["x", "y"];
5788 c = $(c);
5789 var i = {},
5790 g = c.getPosition(this.element),
5791 j = c.getSize(),
5792 h = this.element.getScroll(),
5793 a = this.element.getSize(),
5794 b = {
5795 x: g.x + j.x,
5796 y: g.y + j.y
5798 ["x", "y"].each(function (k) {
5799 if (f.contains(k)) {
5800 i[k] = g[k] - (a[k] - j[k]) / 2
5802 if (i[k] == null) {
5803 i[k] = h[k]
5805 if (d && d[k]) {
5806 i[k] = i[k] + d[k]
5808 }, this);
5809 if (i.x != h.x || i.y != h.y) {
5810 this.start(i.x, i.y)
5812 return this
5815 Fx.Slide = new Class({
5816 Extends: Fx,
5817 options: {
5818 mode: "vertical",
5819 wrapper: false,
5820 hideOverflow: true
5822 initialize: function (b, a) {
5823 this.addEvent("complete", function () {
5824 this.open = (this.wrapper["offset" + this.layout.capitalize()] != 0);
5825 if (this.open) {
5826 this.wrapper.setStyle("height", "")
5828 if (this.open && Browser.Engine.webkit419) {
5829 this.element.dispose().inject(this.wrapper)
5831 }, true);
5832 this.element = this.subject = document.id(b);
5833 this.parent(a);
5834 var d = this.element.retrieve("wrapper");
5835 var c = this.element.getStyles("margin", "position", "overflow");
5836 if (this.options.hideOverflow) {
5837 c = $extend(c, {
5838 overflow: "hidden"
5841 if (this.options.wrapper) {
5842 d = document.id(this.options.wrapper).setStyles(c)
5844 this.wrapper = d || new Element("div", {
5845 styles: c
5846 }).wraps(this.element);
5847 this.element.store("wrapper", this.wrapper).setStyle("margin", 0);
5848 this.now = [];
5849 this.open = true
5851 vertical: function () {
5852 this.margin = "margin-top";
5853 this.layout = "height";
5854 this.offset = this.element.offsetHeight
5856 horizontal: function () {
5857 this.margin = "margin-left";
5858 this.layout = "width";
5859 this.offset = this.element.offsetWidth
5861 set: function (a) {
5862 this.element.setStyle(this.margin, a[0]);
5863 this.wrapper.setStyle(this.layout, a[1]);
5864 return this
5866 compute: function (c, b, a) {
5867 return [0, 1].map(function (d) {
5868 return Fx.compute(c[d], b[d], a)
5871 start: function (b, f) {
5872 if (!this.check(b, f)) {
5873 return this
5875 this[f || this.options.mode]();
5876 var d = this.element.getStyle(this.margin).toInt();
5877 var c = this.wrapper.getStyle(this.layout).toInt();
5878 var a = [
5879 [d, c],
5880 [0, this.offset]
5882 var h = [
5883 [d, c],
5884 [-this.offset, 0]
5886 var g;
5887 switch (b) {
5888 case "in":
5889 g = a;
5890 break;
5891 case "out":
5892 g = h;
5893 break;
5894 case "toggle":
5895 g = (c == 0) ? a : h
5897 return this.parent(g[0], g[1])
5899 slideIn: function (a) {
5900 return this.start("in", a)
5902 slideOut: function (a) {
5903 return this.start("out", a)
5905 hide: function (a) {
5906 this[a || this.options.mode]();
5907 this.open = false;
5908 return this.set([-this.offset, 0])
5910 show: function (a) {
5911 this[a || this.options.mode]();
5912 this.open = true;
5913 return this.set([0, this.offset])
5915 toggle: function (a) {
5916 return this.start("toggle", a)
5919 Element.Properties.slide = {
5920 set: function (b) {
5921 var a = this.retrieve("slide");
5922 if (a) {
5923 a.cancel()
5925 return this.eliminate("slide").store("slide:options", $extend({
5926 link: "cancel"
5927 }, b))
5929 get: function (a) {
5930 if (a || !this.retrieve("slide")) {
5931 if (a || !this.retrieve("slide:options")) {
5932 this.set("slide", a)
5934 this.store("slide", new Fx.Slide(this, this.retrieve("slide:options")))
5936 return this.retrieve("slide")
5939 Element.implement({
5940 slide: function (d, f) {
5941 d = d || "toggle";
5942 var b = this.get("slide"),
5944 switch (d) {
5945 case "hide":
5946 b.hide(f);
5947 break;
5948 case "show":
5949 b.show(f);
5950 break;
5951 case "toggle":
5952 var c = this.retrieve("slide:flag", b.open);
5953 b[c ? "slideOut" : "slideIn"](f);
5954 this.store("slide:flag", !c);
5955 a = true;
5956 break;
5957 default:
5958 b.start(d, f)
5960 if (!a) {
5961 this.eliminate("slide:flag")
5963 return this
5966 var SmoothScroll = Fx.SmoothScroll = new Class({
5967 Extends: Fx.Scroll,
5968 initialize: function (b, c) {
5969 c = c || document;
5970 this.doc = c.getDocument();
5971 var d = c.getWindow();
5972 this.parent(this.doc, b);
5973 this.links = $$(this.options.links || this.doc.links);
5974 var a = d.location.href.match(/^[^#]*/)[0] + "#";
5975 this.links.each(function (g) {
5976 if (g.href.indexOf(a) != 0) {
5977 return
5979 var f = g.href.substr(a.length);
5980 if (f) {
5981 this.useLink(g, f)
5983 }, this);
5984 if (!Browser.Engine.webkit419) {
5985 this.addEvent("complete", function () {
5986 d.location.hash = this.anchor
5987 }, true)
5990 useLink: function (c, a) {
5991 var b;
5992 c.addEvent("click", function (d) {
5993 if (b !== false && !b) {
5994 b = document.id(a) || this.doc.getElement("a[name=" + a + "]")
5996 if (b) {
5997 d.preventDefault();
5998 this.anchor = a;
5999 this.toElement(b).chain(function () {
6000 this.fireEvent("scrolledTo", [c, b])
6001 }.bind(this));
6002 c.blur()
6004 }.bind(this))
6007 var Drag = new Class({
6008 Implements: [Events, Options],
6009 options: {
6010 snap: 6,
6011 unit: "px",
6012 grid: false,
6013 style: true,
6014 limit: false,
6015 handle: false,
6016 invert: false,
6017 preventDefault: false,
6018 stopPropagation: false,
6019 modifiers: {
6020 x: "left",
6021 y: "top"
6024 initialize: function () {
6025 var b = Array.link(arguments, {
6026 options: Object.type,
6027 element: $defined
6029 this.element = document.id(b.element);
6030 this.document = this.element.getDocument();
6031 this.setOptions(b.options || {});
6032 var a = $type(this.options.handle);
6033 this.handles = ((a == "array" || a == "collection") ? $$(this.options.handle) : document.id(this.options.handle)) || this.element;
6034 this.mouse = {
6035 now: {},
6036 pos: {}
6038 this.value = {
6039 start: {},
6040 now: {}
6042 this.selection = (Browser.Engine.trident) ? "selectstart" : "mousedown";
6043 this.bound = {
6044 start: this.start.bind(this),
6045 check: this.check.bind(this),
6046 drag: this.drag.bind(this),
6047 stop: this.stop.bind(this),
6048 cancel: this.cancel.bind(this),
6049 eventStop: $lambda(false)
6051 this.attach()
6053 attach: function () {
6054 this.handles.addEvent("mousedown", this.bound.start);
6055 return this
6057 detach: function () {
6058 this.handles.removeEvent("mousedown", this.bound.start);
6059 return this
6061 start: function (c) {
6062 if (c.rightClick) {
6063 return
6065 if (this.options.preventDefault) {
6066 c.preventDefault()
6068 if (this.options.stopPropagation) {
6069 c.stopPropagation()
6071 this.mouse.start = c.page;
6072 this.fireEvent("beforeStart", this.element);
6073 var a = this.options.limit;
6074 this.limit = {
6075 x: [],
6076 y: []
6078 for (var d in this.options.modifiers) {
6079 if (!this.options.modifiers[d]) {
6080 continue
6082 if (this.options.style) {
6083 this.value.now[d] = this.element.getStyle(this.options.modifiers[d]).toInt()
6084 } else {
6085 this.value.now[d] = this.element[this.options.modifiers[d]]
6087 if (this.options.invert) {
6088 this.value.now[d] *= -1
6090 this.mouse.pos[d] = c.page[d] - this.value.now[d];
6091 if (a && a[d]) {
6092 for (var b = 2; b--; b) {
6093 if ($chk(a[d][b])) {
6094 this.limit[d][b] = $lambda(a[d][b])()
6099 if ($type(this.options.grid) == "number") {
6100 this.options.grid = {
6101 x: this.options.grid,
6102 y: this.options.grid
6105 this.document.addEvents({
6106 mousemove: this.bound.check,
6107 mouseup: this.bound.cancel
6109 this.document.addEvent(this.selection, this.bound.eventStop)
6111 check: function (a) {
6112 if (this.options.preventDefault) {
6113 a.preventDefault()
6115 var b = Math.round(Math.sqrt(Math.pow(a.page.x - this.mouse.start.x, 2) + Math.pow(a.page.y - this.mouse.start.y, 2)));
6116 if (b > this.options.snap) {
6117 this.cancel();
6118 this.document.addEvents({
6119 mousemove: this.bound.drag,
6120 mouseup: this.bound.stop
6122 this.fireEvent("start", [this.element, a]).fireEvent("snap", this.element)
6125 drag: function (a) {
6126 if (this.options.preventDefault) {
6127 a.preventDefault()
6129 this.mouse.now = a.page;
6130 for (var b in this.options.modifiers) {
6131 if (!this.options.modifiers[b]) {
6132 continue
6134 this.value.now[b] = this.mouse.now[b] - this.mouse.pos[b];
6135 if (this.options.invert) {
6136 this.value.now[b] *= -1
6138 if (this.options.limit && this.limit[b]) {
6139 if ($chk(this.limit[b][1]) && (this.value.now[b] > this.limit[b][1])) {
6140 this.value.now[b] = this.limit[b][1]
6141 } else {
6142 if ($chk(this.limit[b][0]) && (this.value.now[b] < this.limit[b][0])) {
6143 this.value.now[b] = this.limit[b][0]
6147 if (this.options.grid[b]) {
6148 this.value.now[b] -= ((this.value.now[b] - (this.limit[b][0] || 0)) % this.options.grid[b])
6150 if (this.options.style) {
6151 this.element.setStyle(this.options.modifiers[b], this.value.now[b] + this.options.unit)
6152 } else {
6153 this.element[this.options.modifiers[b]] = this.value.now[b]
6156 this.fireEvent("drag", [this.element, a])
6158 cancel: function (a) {
6159 this.document.removeEvent("mousemove", this.bound.check);
6160 this.document.removeEvent("mouseup", this.bound.cancel);
6161 if (a) {
6162 this.document.removeEvent(this.selection, this.bound.eventStop);
6163 this.fireEvent("cancel", this.element)
6166 stop: function (a) {
6167 this.document.removeEvent(this.selection, this.bound.eventStop);
6168 this.document.removeEvent("mousemove", this.bound.drag);
6169 this.document.removeEvent("mouseup", this.bound.stop);
6170 if (a) {
6171 this.fireEvent("complete", [this.element, a])
6175 Element.implement({
6176 makeResizable: function (a) {
6177 var b = new Drag(this, $merge({
6178 modifiers: {
6179 x: "width",
6180 y: "height"
6182 }, a));
6183 this.store("resizer", b);
6184 return b.addEvent("drag", function () {
6185 this.fireEvent("resize", b)
6186 }.bind(this))
6189 Drag.Move = new Class({
6190 Extends: Drag,
6191 options: {
6192 droppables: [],
6193 container: false,
6194 precalculate: false,
6195 includeMargins: true,
6196 checkDroppables: true
6198 initialize: function (b, a) {
6199 this.parent(b, a);
6200 b = this.element;
6201 this.droppables = $$(this.options.droppables);
6202 this.container = document.id(this.options.container);
6203 if (this.container && $type(this.container) != "element") {
6204 this.container = document.id(this.container.getDocument().body)
6206 var c = b.getStyles("left", "top", "position");
6207 if (c.left == "auto" || c.top == "auto") {
6208 b.setPosition(b.getPosition(b.getOffsetParent()))
6210 if (c.position == "static") {
6211 b.setStyle("position", "absolute")
6213 this.addEvent("start", this.checkDroppables, true);
6214 this.overed = null
6216 start: function (a) {
6217 if (this.container) {
6218 this.options.limit = this.calculateLimit()
6220 if (this.options.precalculate) {
6221 this.positions = this.droppables.map(function (b) {
6222 return b.getCoordinates()
6225 this.parent(a)
6227 calculateLimit: function () {
6228 var d = this.element.getOffsetParent(),
6229 h = this.container.getCoordinates(d),
6230 g = {},
6231 c = {},
6232 b = {},
6233 j = {},
6234 l = {};
6235 ["top", "right", "bottom", "left"].each(function (p) {
6236 g[p] = this.container.getStyle("border-" + p).toInt();
6237 b[p] = this.element.getStyle("border-" + p).toInt();
6238 c[p] = this.element.getStyle("margin-" + p).toInt();
6239 j[p] = this.container.getStyle("margin-" + p).toInt();
6240 l[p] = d.getStyle("padding-" + p).toInt()
6241 }, this);
6242 var f = this.element.offsetWidth + c.left + c.right,
6243 o = this.element.offsetHeight + c.top + c.bottom,
6244 i = 0,
6245 k = 0,
6246 n = h.right - g.right - f,
6247 a = h.bottom - g.bottom - o;
6248 if (this.options.includeMargins) {
6249 i += c.left;
6250 k += c.top
6251 } else {
6252 n += c.right;
6253 a += c.bottom
6255 if (this.element.getStyle("position") == "relative") {
6256 var m = this.element.getCoordinates(d);
6257 m.left -= this.element.getStyle("left").toInt();
6258 m.top -= this.element.getStyle("top").toInt();
6259 i += g.left - m.left;
6260 k += g.top - m.top;
6261 n += c.left - m.left;
6262 a += c.top - m.top;
6263 if (this.container != d) {
6264 i += j.left + l.left;
6265 k += (Browser.Engine.trident4 ? 0 : j.top) + l.top
6267 } else {
6268 i -= c.left;
6269 k -= c.top;
6270 if (this.container == d) {
6271 n -= g.left;
6272 a -= g.top
6273 } else {
6274 i += h.left + g.left;
6275 k += h.top + g.top
6278 return {
6279 x: [i, n],
6280 y: [k, a]
6283 checkAgainst: function (c, b) {
6284 c = (this.positions) ? this.positions[b] : c.getCoordinates();
6285 var a = this.mouse.now;
6286 return (a.x > c.left && a.x < c.right && a.y < c.bottom && a.y > c.top)
6288 checkDroppables: function () {
6289 var a = this.droppables.filter(this.checkAgainst, this).getLast();
6290 if (this.overed != a) {
6291 if (this.overed) {
6292 this.fireEvent("leave", [this.element, this.overed])
6294 if (a) {
6295 this.fireEvent("enter", [this.element, a])
6297 this.overed = a
6300 drag: function (a) {
6301 this.parent(a);
6302 if (this.options.checkDroppables && this.droppables.length) {
6303 this.checkDroppables()
6306 stop: function (a) {
6307 this.checkDroppables();
6308 this.fireEvent("drop", [this.element, this.overed, a]);
6309 this.overed = null;
6310 return this.parent(a)
6313 Element.implement({
6314 makeDraggable: function (a) {
6315 var b = new Drag.Move(this, a);
6316 this.store("dragger", b);
6317 return b
6320 var Slider = new Class({
6321 Implements: [Events, Options],
6322 Binds: ["clickedElement", "draggedKnob", "scrolledElement"],
6323 options: {
6324 onTick: function (a) {
6325 if (this.options.snap) {
6326 a = this.toPosition(this.step)
6328 this.knob.setStyle(this.property, a)
6330 initialStep: 0,
6331 snap: false,
6332 offset: 0,
6333 range: false,
6334 wheel: false,
6335 steps: 100,
6336 mode: "horizontal"
6338 initialize: function (g, a, f) {
6339 this.setOptions(f);
6340 this.element = document.id(g);
6341 this.knob = document.id(a);
6342 this.previousChange = this.previousEnd = this.step = -1;
6343 var h, b = {},
6344 d = {
6345 x: false,
6346 y: false
6348 switch (this.options.mode) {
6349 case "vertical":
6350 this.axis = "y";
6351 this.property = "top";
6352 h = "offsetHeight";
6353 break;
6354 case "horizontal":
6355 this.axis = "x";
6356 this.property = "left";
6357 h = "offsetWidth"
6359 this.full = this.element.measure(function () {
6360 this.half = this.knob[h] / 2;
6361 return this.element[h] - this.knob[h] + (this.options.offset * 2)
6362 }.bind(this));
6363 this.min = $chk(this.options.range[0]) ? this.options.range[0] : 0;
6364 this.max = $chk(this.options.range[1]) ? this.options.range[1] : this.options.steps;
6365 this.range = this.max - this.min;
6366 this.steps = this.options.steps || this.full;
6367 this.stepSize = Math.abs(this.range) / this.steps;
6368 this.stepWidth = this.stepSize * this.full / Math.abs(this.range);
6369 this.knob.setStyle("position", "relative").setStyle(this.property, this.options.initialStep ? this.toPosition(this.options.initialStep) : -this.options.offset);
6370 d[this.axis] = this.property;
6371 b[this.axis] = [-this.options.offset, this.full - this.options.offset];
6372 var c = {
6373 snap: 0,
6374 limit: b,
6375 modifiers: d,
6376 onDrag: this.draggedKnob,
6377 onStart: this.draggedKnob,
6378 onBeforeStart: (function () {
6379 this.isDragging = true
6380 }).bind(this),
6381 onCancel: function () {
6382 this.isDragging = false
6383 }.bind(this),
6384 onComplete: function () {
6385 this.isDragging = false;
6386 this.draggedKnob();
6387 this.end()
6388 }.bind(this)
6390 if (this.options.snap) {
6391 c.grid = Math.ceil(this.stepWidth);
6392 c.limit[this.axis][1] = this.full
6394 this.drag = new Drag(this.knob, c);
6395 this.attach()
6397 attach: function () {
6398 this.element.addEvent("mousedown", this.clickedElement);
6399 if (this.options.wheel) {
6400 this.element.addEvent("mousewheel", this.scrolledElement)
6402 this.drag.attach();
6403 return this
6405 detach: function () {
6406 this.element.removeEvent("mousedown", this.clickedElement);
6407 this.element.removeEvent("mousewheel", this.scrolledElement);
6408 this.drag.detach();
6409 return this
6411 set: function (a) {
6412 if (!((this.range > 0) ^ (a < this.min))) {
6413 a = this.min
6415 if (!((this.range > 0) ^ (a > this.max))) {
6416 a = this.max
6418 this.step = Math.round(a);
6419 this.checkStep();
6420 this.fireEvent("tick", this.toPosition(this.step));
6421 this.end();
6422 return this
6424 clickedElement: function (c) {
6425 if (this.isDragging || c.target == this.knob) {
6426 return
6428 var b = this.range < 0 ? -1 : 1;
6429 var a = c.page[this.axis] - this.element.getPosition()[this.axis] - this.half;
6430 a = a.limit(-this.options.offset, this.full - this.options.offset);
6431 this.step = Math.round(this.min + b * this.toStep(a));
6432 this.checkStep();
6433 this.fireEvent("tick", a);
6434 this.end()
6436 scrolledElement: function (a) {
6437 var b = (this.options.mode == "horizontal") ? (a.wheel < 0) : (a.wheel > 0);
6438 this.set(b ? this.step - this.stepSize : this.step + this.stepSize);
6439 a.stop()
6441 draggedKnob: function () {
6442 var b = this.range < 0 ? -1 : 1;
6443 var a = this.drag.value.now[this.axis];
6444 a = a.limit(-this.options.offset, this.full - this.options.offset);
6445 this.step = Math.round(this.min + b * this.toStep(a));
6446 this.checkStep()
6448 checkStep: function () {
6449 if (this.previousChange != this.step) {
6450 this.previousChange = this.step;
6451 this.fireEvent("change", this.step)
6454 end: function () {
6455 if (this.previousEnd !== this.step) {
6456 this.previousEnd = this.step;
6457 this.fireEvent("complete", this.step + "")
6460 toStep: function (a) {
6461 var b = (a + this.options.offset) * this.stepSize / this.full * this.steps;
6462 return this.options.steps ? Math.round(b -= b % this.stepSize) : b
6464 toPosition: function (a) {
6465 return (this.full * Math.abs(this.min - a)) / (this.steps * this.stepSize) - this.options.offset
6468 var Sortables = new Class({
6469 Implements: [Events, Options],
6470 options: {
6471 snap: 4,
6472 opacity: 1,
6473 clone: false,
6474 revert: false,
6475 handle: false,
6476 constrain: false
6478 initialize: function (a, b) {
6479 this.setOptions(b);
6480 this.elements = [];
6481 this.lists = [];
6482 this.idle = true;
6483 this.addLists($$(document.id(a) || a));
6484 if (!this.options.clone) {
6485 this.options.revert = false
6487 if (this.options.revert) {
6488 this.effect = new Fx.Morph(null, $merge({
6489 duration: 250,
6490 link: "cancel"
6491 }, this.options.revert))
6494 attach: function () {
6495 this.addLists(this.lists);
6496 return this
6498 detach: function () {
6499 this.lists = this.removeLists(this.lists);
6500 return this
6502 addItems: function () {
6503 Array.flatten(arguments).each(function (a) {
6504 this.elements.push(a);
6505 var b = a.retrieve("sortables:start", this.start.bindWithEvent(this, a));
6506 (this.options.handle ? a.getElement(this.options.handle) || a : a).addEvent("mousedown", b)
6507 }, this);
6508 return this
6510 addLists: function () {
6511 Array.flatten(arguments).each(function (a) {
6512 this.lists.push(a);
6513 this.addItems(a.getChildren())
6514 }, this);
6515 return this
6517 removeItems: function () {
6518 return $$(Array.flatten(arguments).map(function (a) {
6519 this.elements.erase(a);
6520 var b = a.retrieve("sortables:start");
6521 (this.options.handle ? a.getElement(this.options.handle) || a : a).removeEvent("mousedown", b);
6522 return a
6523 }, this))
6525 removeLists: function () {
6526 return $$(Array.flatten(arguments).map(function (a) {
6527 this.lists.erase(a);
6528 this.removeItems(a.getChildren());
6529 return a
6530 }, this))
6532 getClone: function (b, a) {
6533 if (!this.options.clone) {
6534 return new Element("div").inject(document.body)
6536 if ($type(this.options.clone) == "function") {
6537 return this.options.clone.call(this, b, a, this.list)
6539 var c = a.clone(true).setStyles({
6540 margin: "0px",
6541 position: "absolute",
6542 visibility: "hidden",
6543 width: a.getStyle("width")
6545 if (c.get("html").test("radio")) {
6546 c.getElements("input[type=radio]").each(function (d, f) {
6547 d.set("name", "clone_" + f)
6550 return c.inject(this.list).setPosition(a.getPosition(a.getOffsetParent()))
6552 getDroppables: function () {
6553 var a = this.list.getChildren();
6554 if (!this.options.constrain) {
6555 a = this.lists.concat(a).erase(this.list)
6557 return a.erase(this.clone).erase(this.element)
6559 insert: function (c, b) {
6560 var a = "inside";
6561 if (this.lists.contains(b)) {
6562 this.list = b;
6563 this.drag.droppables = this.getDroppables()
6564 } else {
6565 a = this.element.getAllPrevious().contains(b) ? "before" : "after"
6567 this.element.inject(b, a);
6568 this.fireEvent("sort", [this.element, this.clone])
6570 start: function (b, a) {
6571 if (!this.idle) {
6572 return
6574 this.idle = false;
6575 this.element = a;
6576 this.opacity = a.get("opacity");
6577 this.list = a.getParent();
6578 this.clone = this.getClone(b, a);
6579 this.drag = new Drag.Move(this.clone, {
6580 snap: this.options.snap,
6581 container: this.options.constrain && this.element.getParent(),
6582 droppables: this.getDroppables(),
6583 onSnap: function () {
6584 b.stop();
6585 this.clone.setStyle("visibility", "visible");
6586 this.element.set("opacity", this.options.opacity || 0);
6587 this.fireEvent("start", [this.element, this.clone])
6588 }.bind(this),
6589 onEnter: this.insert.bind(this),
6590 onCancel: this.reset.bind(this),
6591 onComplete: this.end.bind(this)
6593 this.clone.inject(this.element, "before");
6594 this.drag.start(b)
6596 end: function () {
6597 this.drag.detach();
6598 this.element.set("opacity", this.opacity);
6599 if (this.effect) {
6600 var a = this.element.getStyles("width", "height");
6601 var b = this.clone.computePosition(this.element.getPosition(this.clone.offsetParent));
6602 this.effect.element = this.clone;
6603 this.effect.start({
6604 top: b.top,
6605 left: b.left,
6606 width: a.width,
6607 height: a.height,
6608 opacity: 0.25
6609 }).chain(this.reset.bind(this))
6610 } else {
6611 this.reset()
6614 reset: function () {
6615 this.idle = true;
6616 this.clone.destroy();
6617 this.fireEvent("complete", this.element)
6619 serialize: function () {
6620 var c = Array.link(arguments, {
6621 modifier: Function.type,
6622 index: $defined
6624 var b = this.lists.map(function (d) {
6625 return d.getChildren().map(c.modifier ||
6626 function (f) {
6627 return f.get("id")
6628 }, this)
6629 }, this);
6630 var a = c.index;
6631 if (this.lists.length == 1) {
6632 a = 0
6634 return $chk(a) && a >= 0 && a < this.lists.length ? b[a] : b
6637 Request.implement({
6638 options: {
6639 initialDelay: 5000,
6640 delay: 5000,
6641 limit: 60000
6643 startTimer: function (b) {
6644 var a = function () {
6645 if (!this.running) {
6646 this.send({
6647 data: b
6651 this.timer = a.delay(this.options.initialDelay, this);
6652 this.lastDelay = this.options.initialDelay;
6653 this.completeCheck = function (c) {
6654 $clear(this.timer);
6655 this.lastDelay = (c) ? this.options.delay : (this.lastDelay + this.options.delay).min(this.options.limit);
6656 this.timer = a.delay(this.lastDelay, this)
6658 return this.addEvent("complete", this.completeCheck)
6660 stopTimer: function () {
6661 $clear(this.timer);
6662 return this.removeEvent("complete", this.completeCheck)
6665 Hash.Cookie = new Class({
6666 Extends: Cookie,
6667 options: {
6668 autoSave: true
6670 initialize: function (b, a) {
6671 this.parent(b, a);
6672 this.load()
6674 save: function () {
6675 var a = JSON.encode(this.hash);
6676 if (!a || a.length > 4096) {
6677 return false
6679 if (a == "{}") {
6680 this.dispose()
6681 } else {
6682 this.write(a)
6684 return true
6686 load: function () {
6687 this.hash = new Hash(JSON.decode(this.read(), true));
6688 return this
6691 Hash.each(Hash.prototype, function (b, a) {
6692 if (typeof b == "function") {
6693 Hash.Cookie.implement(a, function () {
6694 var c = b.apply(this.hash, arguments);
6695 if (this.options.autoSave) {
6696 this.save()
6698 return c
6702 var Scroller = new Class({
6703 Implements: [Events, Options],
6704 options: {
6705 area: 20,
6706 velocity: 1,
6707 onChange: function (a, b) {
6708 this.element.scrollTo(a, b)
6710 fps: 50
6712 initialize: function (b, a) {
6713 this.setOptions(a);
6714 this.element = document.id(b);
6715 this.docBody = document.id(this.element.getDocument().body);
6716 this.listener = ($type(this.element) != "element") ? this.docBody : this.element;
6717 this.timer = null;
6718 this.bound = {
6719 attach: this.attach.bind(this),
6720 detach: this.detach.bind(this),
6721 getCoords: this.getCoords.bind(this)
6724 start: function () {
6725 this.listener.addEvents({
6726 mouseover: this.bound.attach,
6727 mouseout: this.bound.detach
6730 stop: function () {
6731 this.listener.removeEvents({
6732 mouseover: this.bound.attach,
6733 mouseout: this.bound.detach
6735 this.detach();
6736 this.timer = $clear(this.timer)
6738 attach: function () {
6739 this.listener.addEvent("mousemove", this.bound.getCoords)
6741 detach: function () {
6742 this.listener.removeEvent("mousemove", this.bound.getCoords);
6743 this.timer = $clear(this.timer)
6745 getCoords: function (a) {
6746 this.page = (this.listener.get("tag") == "body") ? a.client : a.page;
6747 if (!this.timer) {
6748 this.timer = this.scroll.periodical(Math.round(1000 / this.options.fps), this)
6751 scroll: function () {
6752 var b = this.element.getSize(),
6753 a = this.element.getScroll(),
6754 g = this.element != this.docBody ? this.element.getOffsets() : {
6755 x: 0,
6756 y: 0
6758 c = this.element.getScrollSize(),
6759 f = {
6760 x: 0,
6761 y: 0
6763 for (var d in this.page) {
6764 if (this.page[d] < (this.options.area + g[d]) && a[d] != 0) {
6765 f[d] = (this.page[d] - this.options.area - g[d]) * this.options.velocity
6766 } else {
6767 if (this.page[d] + this.options.area > (b[d] + g[d]) && a[d] + b[d] != c[d]) {
6768 f[d] = (this.page[d] - b[d] + this.options.area - g[d]) * this.options.velocity
6772 if (f.y || f.x) {
6773 this.fireEvent("change", [a.x + f.x, a.y + f.y])
6777 (function () {
6778 var a = function (c, b) {
6779 return (c) ? ($type(c) == "function" ? c(b) : b.get(c)) : ""
6781 this.Tips = new Class({
6782 Implements: [Events, Options],
6783 options: {
6784 onShow: function () {
6785 this.tip.setStyle("display", "block")
6787 onHide: function () {
6788 this.tip.setStyle("display", "none")
6790 title: "title",
6791 text: function (b) {
6792 return b.get("rel") || b.get("href")
6794 showDelay: 100,
6795 hideDelay: 100,
6796 className: "tip-wrap",
6797 offset: {
6798 x: 16,
6799 y: 16
6801 windowPadding: {
6802 x: 0,
6803 y: 0
6805 fixed: false
6807 initialize: function () {
6808 var b = Array.link(arguments, {
6809 options: Object.type,
6810 elements: $defined
6812 this.setOptions(b.options);
6813 if (b.elements) {
6814 this.attach(b.elements)
6816 this.container = new Element("div", {
6817 "class": "tip"
6820 toElement: function () {
6821 if (this.tip) {
6822 return this.tip
6824 return this.tip = new Element("div", {
6825 "class": this.options.className,
6826 styles: {
6827 position: "absolute",
6828 top: 0,
6829 left: 0
6831 }).adopt(new Element("div", {
6832 "class": "tip-top"
6833 }), this.container, new Element("div", {
6834 "class": "tip-bottom"
6835 })).inject(document.body)
6837 attach: function (b) {
6838 $$(b).each(function (d) {
6839 var g = a(this.options.title, d),
6840 f = a(this.options.text, d);
6841 d.erase("title").store("tip:native", g).retrieve("tip:title", g);
6842 d.retrieve("tip:text", f);
6843 this.fireEvent("attach", [d]);
6844 var c = ["enter", "leave"];
6845 if (!this.options.fixed) {
6846 c.push("move")
6848 c.each(function (i) {
6849 var h = d.retrieve("tip:" + i);
6850 if (!h) {
6851 h = this["element" + i.capitalize()].bindWithEvent(this, d)
6853 d.store("tip:" + i, h).addEvent("mouse" + i, h)
6854 }, this)
6855 }, this);
6856 return this
6858 detach: function (b) {
6859 $$(b).each(function (d) {
6860 ["enter", "leave", "move"].each(function (f) {
6861 d.removeEvent("mouse" + f, d.retrieve("tip:" + f)).eliminate("tip:" + f)
6863 this.fireEvent("detach", [d]);
6864 if (this.options.title == "title") {
6865 var c = d.retrieve("tip:native");
6866 if (c) {
6867 d.set("title", c)
6870 }, this);
6871 return this
6873 elementEnter: function (c, b) {
6874 this.container.empty();
6875 ["title", "text"].each(function (f) {
6876 var d = b.retrieve("tip:" + f);
6877 if (d) {
6878 this.fill(new Element("div", {
6879 "class": "tip-" + f
6880 }).inject(this.container), d)
6882 }, this);
6883 $clear(this.timer);
6884 this.timer = (function () {
6885 this.show(this, b);
6886 this.position((this.options.fixed) ? {
6887 page: b.getPosition()
6888 } : c)
6889 }).delay(this.options.showDelay, this)
6891 elementLeave: function (c, b) {
6892 $clear(this.timer);
6893 this.timer = this.hide.delay(this.options.hideDelay, this, b);
6894 this.fireForParent(c, b)
6896 fireForParent: function (c, b) {
6897 b = b.getParent();
6898 if (!b || b == document.body) {
6899 return
6901 if (b.retrieve("tip:enter")) {
6902 b.fireEvent("mouseenter", c)
6903 } else {
6904 this.fireForParent(c, b)
6907 elementMove: function (c, b) {
6908 this.position(c)
6910 position: function (f) {
6911 if (!this.tip) {
6912 document.id(this)
6914 var c = window.getSize(),
6915 b = window.getScroll(),
6916 g = {
6917 x: this.tip.offsetWidth,
6918 y: this.tip.offsetHeight
6920 d = {
6921 x: "left",
6922 y: "top"
6924 h = {};
6925 for (var i in d) {
6926 h[d[i]] = f.page[i] + this.options.offset[i];
6927 if ((h[d[i]] + g[i] - b[i]) > c[i] - this.options.windowPadding[i]) {
6928 h[d[i]] = f.page[i] - this.options.offset[i] - g[i]
6931 this.tip.setStyles(h)
6933 fill: function (b, c) {
6934 if (typeof c == "string") {
6935 b.set("html", c)
6936 } else {
6937 b.adopt(c)
6940 show: function (b) {
6941 if (!this.tip) {
6942 document.id(this)
6944 this.fireEvent("show", [this.tip, b])
6946 hide: function (b) {
6947 if (!this.tip) {
6948 document.id(this)
6950 this.fireEvent("hide", [this.tip, b])
6953 })();
6954 window.$w = function (a) {
6955 return $A(String(a).split(" "))
6958 function $clone(a) {
6959 if (a && a.$family && a.$family.name == "array") {
6960 return a
6962 return $merge(a, {})
6964 Function.implement({
6965 wrap: function (b) {
6966 var a = this;
6967 return function () {
6968 return b.apply(this, [a.bind(this)].concat($A(arguments)))
6972 if (JSON.stringify) {
6973 JSON.encode = JSON.encode.wrap(function (b, c) {
6974 if (typeof c == "undefined") {
6975 c = null
6977 var a = JSON.stringify(c);
6978 return a
6980 delete(Hash.prototype.toJSON);
6981 delete(Array.prototype.toJSON);
6982 delete(String.prototype.toJSON);
6983 delete(Number.prototype.toJSON)
6985 if (JSON.parse) {
6986 JSON.decode = JSON.decode.wrap(function (b, a, c) {
6987 if (typeof a == "undefined" || a === null) {
6988 return null
6990 return JSON.parse(a)
6993 $extend(Object, {
6994 toHTML: function (a) {
6995 return a && a.toHTML ? a.toHTML() : String.interpret(a)
6998 $extend(String, {
6999 interpret: function (a) {
7000 return a == null ? "" : String(a)
7003 Element._getContentFromAnonymousElement = function (c, b) {
7004 var d = new Element("div"),
7005 a = Element._insertionTranslations.tags[c];
7006 if (a) {
7007 d.innerHTML = a[0] + b + a[1];
7008 a[2].times(function () {
7009 d = d.firstChild
7011 } else {
7012 d.innerHTML = b
7014 return $A(d.childNodes)
7016 Array.implement({
7017 find: function (d, c) {
7018 var a;
7019 var b = d;
7020 if (c) {
7021 b = b.bind(c)
7023 this.some(function (g, f, h) {
7024 if (b(g, f, h)) {
7025 a = g;
7026 return true
7028 return false
7030 return a
7032 inject: function (b, a) {
7033 this.each(function (d, c, f) {
7034 b = a(b, d, c, f)
7036 return b
7038 invoke: function (a) {
7039 this.each(function (b) {
7040 if (b && b[a]) {
7041 b[a]()
7044 return this
7047 Element.addClass = Element.addClass.wrap(function (c, b, a) {
7048 if ($type(a) != "array") {
7049 a = $w(a)
7051 if ($type(a) == "array") {
7052 $each(a, function (d) {
7053 c(d)
7055 } else {
7056 c(a)
7058 return b
7060 Element.prototype.addClass = Element.prototype.addClass.wrap(function (b, a) {
7061 if ($type(a) != "array") {
7062 a = $w(a)
7064 if ($type(a) == "array") {
7065 $each(a, function (c) {
7066 b(c)
7068 } else {
7069 b(a)
7071 return this
7073 Element.removeClass = Element.removeClass.wrap(function (c, b, a) {
7074 if ($type(a) != "array") {
7075 a = $w(a)
7077 if ($type(a) == "array") {
7078 $each(a, function (d) {
7079 c(d)
7081 } else {
7082 c(a)
7084 return b
7086 Element.prototype.removeClass = Element.prototype.removeClass.wrap(function (b, a) {
7087 if ($type(a) != "array") {
7088 a = $w(a)
7090 if ($type(a) == "array") {
7091 $each(a, function (c) {
7092 b(c)
7094 } else {
7095 b(a)
7097 return this
7099 Element.implement({
7100 disableSelection: function () {
7101 return this.setStyles({
7102 MozUserSelect: "none",
7103 KhtmlUserSelect: "none"
7104 }).setProperty("unselectable", "on")
7106 down: function (a) {
7107 return this.getElement(a)
7109 getSelectionEnd: function () {
7110 if (this.createTextRange) {
7111 var a = document.selection.createRange().duplicate();
7112 a.moveStart("character", -this.value.length);
7113 return a.text.length
7115 return this.selectionEnd
7117 getSelectionStart: function () {
7118 if (this.createTextRange) {
7119 var a = document.selection.createRange().duplicate();
7120 a.moveEnd("character", this.value.length);
7121 if (a.text == "") {
7122 return this.value.length
7124 return this.value.lastIndexOf(a.text)
7126 return this.selectionStart
7128 insert: function (f) {
7129 var c = $(this);
7130 if (typeof f == "string" || typeof f == "number" || (f.nodeName && f.nodeType == 1) || (f && (f.toElement || f.toHTML))) {
7131 f = {
7132 bottom: f
7135 var d, g, b, h;
7136 for (var a in f) {
7137 d = f[a];
7138 a = a.toLowerCase();
7139 g = Element._insertionTranslations[a];
7140 if (d && d.toElement) {
7141 d = d.toElement()
7143 if (d.nodeName && d.nodeType == 1) {
7144 g(c, d);
7145 continue
7147 d = Object.toHTML(d);
7148 b = ((a == "before" || a == "after") ? c.parentNode : c).tagName.toUpperCase();
7149 h = Element._getContentFromAnonymousElement(b, d);
7150 if (a == "top" || a == "after") {
7151 h.reverse()
7153 h.each(function (i) {
7154 g(c, i)
7157 return c
7159 next: function (a) {
7160 return this.getNext(a)
7162 prev: function (a) {
7163 return this.getPrevious(a)
7165 select: function (b) {
7166 var c = this;
7167 var a = [];
7168 $A(arguments).each(function (d) {
7169 var f = c.getElements(d);
7170 if ($type(f) == "array") {
7171 a = a.concat(f)
7174 return a
7176 setSize: function (b, a) {
7177 if (b && b.$family && b.$family.name == "array") {
7178 a = b[1];
7179 b = b[0]
7180 } else {
7181 if (typeof b == "object") {
7182 if (typeof b.x == "number") {
7183 a = b.y;
7184 b = b.x
7185 } else {
7186 a = b.height;
7187 b = b.width
7191 return this.setStyles({
7192 width: b,
7193 height: a
7196 up: function (a) {
7197 return this.getParent(a)
7200 Element._insertionTranslations = {
7201 before: function (a, b) {
7202 a.parentNode.insertBefore(b, a)
7204 top: function (a, b) {
7205 a.insertBefore(b, a.firstChild)
7207 bottom: function (a, b) {
7208 a.appendChild(b)
7210 after: function (a, b) {
7211 a.parentNode.insertBefore(b, a.nextSibling)
7213 tags: {
7214 TABLE: ["<table>", "</table>", 1],
7215 TBODY: ["<table><tbody>", "</tbody></table>", 2],
7216 TR: ["<table><tbody><tr>", "</tr></tbody></table>", 3],
7217 TD: ["<table><tbody><tr><td>", "</td></tr></tbody></table>", 4],
7218 SELECT: ["<select>", "</select>", 1]
7221 Hash.implement({
7222 find: function (d, c) {
7223 var a;
7224 var b = d;
7225 if (c) {
7226 b = b.bind(c)
7228 this.some(function (g, f, h) {
7229 if (b(g, f, h)) {
7230 a = g;
7231 return true
7233 return false
7235 return a
7237 inject: function (b, a) {
7238 this.each(function (d, c, f) {
7239 b = a(b, d, c, f)
7241 return b
7243 invoke: function (a) {
7244 this.each(function (b) {
7245 if (b[a]) {
7246 b[a]()
7249 return this
7251 ksort: function (c) {
7252 var b = this;
7253 var a = $H({});
7254 this.getKeys().sort(c).each(function (d) {
7255 a[d] = b[d]
7257 return a
7259 merge: function (a) {
7260 return $H($merge(this.toObject(), a || {}))
7262 sort: function (a) {
7263 return this.toArray().sort(a)
7265 toArray: function () {
7266 var a = [];
7267 this.each(function (b) {
7268 a.push(b)
7270 return a
7272 toObject: function () {
7273 var a = {};
7274 this.each(function (c, b) {
7275 a[b] = c
7277 return a
7280 Number.implement({
7281 isNaN: function () {
7282 return isNaN(this)
7284 sgn: function () {
7285 if (this < 0) {
7286 return -1
7287 } else {
7288 if (this > 0) {
7289 return 1
7292 return 0
7295 String.implement({
7296 fromQueryString: function (b) {
7297 var c = this;
7298 var a = {};
7299 if (c.indexOf("?") != -1) {
7300 c = c.substr(c.indexOf("?") + 1)
7302 a = $H($A(c.split("&")).inject({}, function (d, f) {
7303 f = f.split("=");
7304 if (f.length == 2) {
7305 d[f[0]] = f[1]
7307 return d
7308 }));
7309 if (a && a.toObject && b) {
7310 a = a.toObject()
7312 return a
7314 leftPad: function (b, c) {
7315 var a = new String(this);
7316 if (!c) {
7317 c = " "
7319 while (a.length < b) {
7320 a = c + a
7322 return a.toString()
7324 stripTags: function () {
7325 return this.replace(/<\/?[^>]+>/gi, "")
7327 substituteWithoutReplacingUndefinedKeys: function (a, b) {
7328 return this.replace(b || (/\\?\{([^{}]+)\}/g), function (d, c) {
7329 if (d.charAt(0) == "\\") {
7330 return d.slice(1)
7332 return (a[c] != undefined) ? a[c] : "{" + c + "}"
7335 unescapeHtml: function () {
7336 var b = new Element("div");
7337 b.innerHTML = this.stripTags();
7338 if (!b.childNodes[0]) {
7339 return ""
7341 if (b.childNodes.length > 1) {
7342 var a = "";
7343 $A(b.childNodes).each(function (c) {
7344 return a + c.nodeValue
7346 return a
7347 } else {
7348 return b.childNodes[0].nodeValue
7352 Element.NativeEvents = $extend(Element.NativeEvents, {
7353 touchstart: 2,
7354 touchend: 2,
7355 touchmove: 2,
7356 touchcancel: 2,
7357 gesturechange: 2,
7358 gestureend: 2
7360 Browser.Engines.isChrome = function () {
7361 return Browser.Engine.webkit && navigator.userAgent.toLowerCase().indexOf("chrome") != -1
7363 if (Browser.Engine.trident) {
7364 Element.implement({
7365 insertAtCursor: function (b, a) {
7366 var d = this.getSelectedRange();
7367 if (d.start == 0 && d.end == 0) {
7368 this.focus();
7369 sel = document.selection.createRange();
7370 sel.text = b;
7371 this.focus();
7372 return this
7374 var c = this.get("value");
7375 this.set("value", c.substring(0, d.start) + b + c.substring(d.end, c.length));
7376 if ($pick(a, true)) {
7377 this.selectRange(d.start, d.start + b.length)
7378 } else {
7379 this.setCaretPosition(d.start + b.length)
7381 return this
7383 insertAroundCursor: function (b, a) {
7384 b = $extend({
7385 before: "",
7386 defaultMiddle: "",
7387 after: ""
7388 }, b);
7389 var c = this.getSelectedText() || b.defaultMiddle;
7390 var h = this.getSelectedRange();
7391 if (h.start == 0 && h.end == 0) {
7392 this.focus();
7393 sel = document.selection.createRange();
7394 sel.text = b.before + b.after;
7395 this.focus();
7396 return this
7398 var g = this.get("value");
7399 if (h.start == h.end) {
7400 this.set("value", g.substring(0, h.start) + b.before + c + b.after + g.substring(h.end, g.length));
7401 this.selectRange(h.start + b.before.length, h.end + b.before.length + c.length)
7402 } else {
7403 var d = g.substring(h.start, h.end);
7404 this.set("value", g.substring(0, h.start) + b.before + d + b.after + g.substring(h.end, g.length));
7405 var f = h.start + b.before.length;
7406 if ($pick(a, true)) {
7407 this.selectRange(f, f + d.length)
7408 } else {
7409 this.setCaretPosition(f + g.length)
7412 return this
7416 window.Travian = {
7417 applicationId: "travian",
7418 emptyFunction: function () {},
7419 $d: function (b) {
7420 if (Browser.Engine.gecko) {
7421 console.info(b)
7422 } else {
7423 if (Browser.Engine.webkit) {
7424 console.log(b)
7425 } else {
7426 if (Browser.Engine.presto) {
7427 opera.postError(b)
7428 } else {
7429 if (Browser.Engine.trident && window.console) {
7430 if (typeof b == "object") {
7431 console.log(JSON.encode(b))
7432 } else {
7433 console.log(b)
7435 } else {
7436 if (!$("travian_console")) {
7437 var a = new Element("div", {
7438 id: "travian_console",
7439 styles: {
7440 position: "absolute",
7441 left: 0,
7442 height: 150,
7443 width: "100%",
7444 bottom: 0,
7445 zIndex: 10000,
7446 overflow: "auto",
7447 overflowX: "hidden",
7448 overflowY: "auto",
7449 borderTop: "1px solid #A06060",
7450 backgroundColor: "#FFD0D0",
7451 fontSize: "10px",
7452 fontFamily: "tahoma,arial,helvetica,sans-serif"
7455 (new Element("div", {
7456 html: "Console",
7457 styles: {
7458 fontWeight: "bold",
7459 padding: 1,
7460 marginBottom: 2,
7461 borderBottom: "1px solid #858484"
7463 })).inject(a, "bottom");
7464 a.inject(document.body, "bottom")
7465 }(new Element("span", {
7466 html: b + "<br />"
7467 })).inject($("travian_console"), "bottom")
7473 ajax: function (a) {
7474 a = a || {};
7475 var b = {
7476 onRequest: a.onRequest || Travian.emptyFunction,
7477 onComplete: a.onComplete || Travian.emptyFunction,
7478 onCancel: a.onCancel || Travian.emptyFunction,
7479 onSuccess: a.onSuccess || Travian.emptyFunction,
7480 onFailure: a.onFailure || Travian.emptyFunction,
7481 onException: a.onException || Travian.emptyFunction
7483 if (!a.url) {
7484 a.url = "ajax.php"
7486 if (a.data && a.data.cmd) {
7487 a.url = a.url + (a.url.indexOf("?") == -1 ? "?" : "&") + "cmd=" + a.data.cmd
7489 return new Request($merge(a, {
7490 method: "post",
7491 encoding: "utf-8",
7492 evalResponse: false,
7493 evalScripts: false,
7494 headers: {
7495 "X-Request": "JSON"
7497 onRequest: function () {
7498 b.onRequest(this)
7500 onComplete: function () {
7501 if (!this.response.json) {
7502 this.response.json = JSON.decode(this.response.text)
7504 b.onComplete(this.response.json.data)
7506 onCancel: function () {
7507 b.onCancel(this)
7509 onSuccess: function () {
7510 if (!this.response.json) {
7511 this.response.json = JSON.decode(this.response.text)
7513 if (this.response.json.error) {
7514 if (b.onFailure(this.response.json.data, this.response.json.error) !== false) {
7515 if (this.response.json.errorMsg == null) {
7516 this.response.json.errorMsg = "Ajax Request error and no text. That is not so good."
7518 this.response.json.errorMsg.dialog()
7520 return
7521 } else {
7522 if (this.response.json.reload) {
7523 window.location.reload()
7526 b.onSuccess(this.response.json.data)
7528 onFailure: function () {
7529 if (!this.response.json) {
7530 this.response.json = JSON.decode(this.response.text)
7532 if (this.response.json.error) {
7533 if (b.onFailure(this.response.json.data, this.response.json.error) !== false) {
7534 if (this.response.json.errorMsg == null) {
7535 this.response.json.errorMsg = "Ajax Request error and no text. That is not so good."
7537 this.response.json.errorMsg.dialog()
7539 return
7541 b.onFailure(this.response.json.data)
7543 onException: function () {
7544 b.onException(this)
7546 })).send()
7548 getDirection: function () {
7549 if (!this.direction) {
7550 this.direction = $(document.body).getStyle("direction").toLowerCase()
7552 return this.direction
7554 insertScript: (function () {
7555 var a = $A([]);
7556 var b = function (c) {
7557 if (a.length == 0) {
7558 $$("script[src]").each(function (d) {
7559 a.push({
7560 src: d.src,
7561 id: d.id,
7562 defer: d.defer,
7563 defaultURL: false
7567 return a.find(function (d) {
7568 return d.src == c.src
7571 return function (c) {
7572 var f = this;
7573 if (!c) {
7574 return
7576 if (c && c.$family && c.$family.name == "array") {
7577 return $A(c).each(function (g) {
7578 f.insertScript(g)
7581 if (typeof c == "string") {
7582 c = {
7583 src: c
7586 c.onLoad = c.onLoad || this.emptyFunction;
7587 if (b(c)) {
7588 c.onLoad(false);
7589 return true
7591 a.push(c);
7592 var d = new Element("script", {
7593 id: (c.id ? c.id : undefined),
7594 src: c.src,
7595 type: "text/javascript",
7596 defer: (c.defer ? true : false)
7598 if (Browser.Engine.trident) {
7599 d.onreadystatechange = function () {
7600 if (d.readyState == "loaded" || d.readyState == "complete" || d.readyState == 4) {
7601 c.onLoad(true)
7604 } else {
7605 d.onload = c.onLoad.pass(true)
7607 $(document.html).getElement("head").appendChild(d);
7608 return d
7610 })(),
7611 popup: function (b, a) {
7612 return window.open(b, a.id || "_blank", $H(a).getKeys().inject([], function (d, c) {
7613 if (c != "id") {
7614 if ($type(a[c]) == "boolean") {
7615 a[c] = a[c] ? "yes" : "no"
7617 d.push(c + "=" + a[c])
7619 return d
7620 }).join(","), true)
7622 toggleSwitch: function (b, a) {
7623 b.toggleClass("hide");
7624 a.toggleClass("switchClosed");
7625 a.toggleClass("switchOpened");
7626 return this
7629 Travian.ajax = Travian.ajax.wrap(function (b, a) {
7630 if (!a.url) {
7631 a.url = "ajax.php"
7633 return b(a)
7635 Travian.Main = {};
7636 Travian.Main.Flags = new Class({
7637 Implements: [Options],
7638 currentRegion: null,
7639 elements: {
7640 container: null,
7641 flagContainer: null,
7642 flags: null,
7643 regionContainer: null
7645 options: {
7646 adCode: null,
7647 container: null,
7648 currentTld: null,
7649 flags: null,
7650 regions: null
7652 initialize: function (a) {
7653 this.setOptions(a);
7654 this.render()
7656 render: function () {
7657 var a = this;
7658 this.elements.container = $(this.options.container);
7659 this.elements.flagContainer = (new Element("div", {
7660 "class": "region_flag",
7661 id: "flag_box"
7662 })).inject(this.elements.container);
7663 this.elements.regionContainer = (new Element("select", {
7664 id: "region_select",
7665 name: "region",
7666 events: {
7667 change: function (b) {
7668 b.stop();
7669 a.selectRegion(a.elements.regionContainer.value)
7672 })).inject(this.elements.container);
7673 $each(this.options.flags, function (b, c) {
7674 $each(b, function (f, d) {
7675 var g = (new Element("a", {
7676 href: f + (a.options.adCode != "" ? "?ad=" + a.options.adCode : ""),
7677 title: d,
7678 "class": "flagEntry " + c
7679 })).hide().inject(a.elements.flagContainer);
7680 (new Element("img", {
7681 alt: d,
7682 "class": "flag_" + d,
7683 src: "img/x.gif"
7684 })).inject(g);
7685 if (a.options.currentTld == d) {
7686 a.currentRegion = c
7690 this.elements.flags = this.elements.flagContainer.getElements(".flagEntry");
7691 $each(this.options.regions, function (c, b) {
7692 if (!a.currentRegion) {
7693 a.currentRegion = b
7694 }(new Element("option", {
7695 value: b,
7696 html: c
7697 })).inject(a.elements.regionContainer)
7699 this.selectRegion(this.currentRegion);
7700 return this
7702 selectRegion: function (a) {
7703 if (!this.options.regions[a]) {
7704 return this
7706 this.currentRegion = a;
7707 this.elements.regionContainer.value = a;
7708 this.elements.flags.each(function (b) {
7709 b.setStyles({
7710 display: b.hasClass(a) ? "inline" : "none"
7713 return this
7716 var popupWidget = new Class({
7717 Implements: [Options, Events],
7718 options: {
7719 url: "",
7720 pop_bg: $("overlaybg"),
7721 pop_container: $$("popup"),
7722 close: $("pclose"),
7723 tour: false,
7724 insupport: false,
7725 anchorcheck: false
7727 allowedAnchors: new Array("tutorial", "moregames", "impressum", "spielregeln", "links", "agb", "help", "spielregeln", "serverLogin", "serverRegister"),
7728 initialize: function (a) {
7729 this.setOptions(a);
7730 this.showPopup()
7732 popcontent: function () {
7733 return $$(this.options.pop_container)[0].getChildren()[1]
7735 showPopup: function () {
7736 var url = new URI(this.options.url);
7737 var anchor = url.get("fragment");
7738 var target = anchor + ".php";
7739 if (url.get("query").length > 0) {
7740 target += "?" + url.get("query")
7742 if (this.allowedAnchors.indexOf(anchor) == -1) {
7743 if (this.options.anchorcheck == false) {
7744 target = this.options.url
7745 } else {
7746 return
7749 var self = this;
7750 var prevwindow = $$(this.options.pop_bg);
7751 var prevcontainer = $$(this.options.pop_container);
7752 var windowWidth = document.documentElement.clientWidth;
7753 prevcontainer[0].setStyles({
7754 display: "block",
7755 visibility: "hidden"
7757 prevcontainer[0].className = anchor;
7758 var popupWidth = prevcontainer[0].getStyle("width").toInt();
7759 var left = windowWidth / 2 - popupWidth / 2;
7760 prevwindow[0].setStyles({
7761 opacity: "0.7",
7762 display: "block",
7763 height: $(document).getScrollSize().y
7765 var scroll = $(document.body).getScroll();
7766 prevcontainer[0].setStyles({
7767 left: windowWidth / 2 - popupWidth / 2,
7768 top: scroll.y + 100,
7769 visibility: "visible",
7770 display: "block"
7772 self.popcontent().set("html", '<div class="loading"></div>');
7773 var req = new Request.HTML({
7774 url: target,
7775 evalScripts: false,
7776 onSuccess: function (html, responseElements, responseHTML, responseJavaScript) {
7777 self.popcontent().set("text", "");
7778 self.popcontent().adopt(html);
7779 if (anchor == "tutorial") {
7780 self.startTour()
7782 if (self.options.insupport) {
7783 self.startSupport()
7785 if (responseJavaScript) {
7786 eval(responseJavaScript)
7789 onFailure: function () {
7790 self.popcontent().set("text", "The request failed.")
7793 req.send();
7794 var close = $$(this.options.close);
7795 close.addEvent("click", function () {
7796 self.options.pop_container[0].setStyle("display", "none");
7797 self.options.pop_bg.setStyle("display", "none");
7798 this.removeEvents()
7800 var bg = $$(this.options.pop_bg);
7801 bg.addEvent("click", function () {
7802 self.options.pop_container[0].setStyle("display", "none");
7803 self.options.pop_bg.setStyle("display", "none");
7804 this.removeEvents()
7807 startSupport: function () {
7808 $$(".spopcon").addEvent("click", function (a) {
7809 a.stop();
7810 new popupWidget({
7811 pop_bg: $("overlaybg"),
7812 pop_container: $$("#popup"),
7813 close: $$(".pclose"),
7814 url: this.get("href"),
7815 tour: false,
7816 insupport: false
7820 startTour: function () {
7821 var f = $$(this.popcontent())[0].getChildren()[1].getChildren("a.prev");
7822 var d = $$(this.popcontent())[0].getChildren()[1].getChildren("a.next");
7823 var c = $$(this.popcontent())[0].getChildren()[1].getChildren("a.prevtxt");
7824 var a = $$(this.popcontent())[0].getChildren()[1].getChildren("a.nexttxt");
7825 var b = this;
7826 if (d.get("href")[0].indexOf("tutorial.php") != -1) {
7827 d.addEvent("click", function (g) {
7828 g.stop();
7829 b.getTour(d.get("href"))
7831 a.addEvent("click", function (g) {
7832 g.stop();
7833 b.getTour(a.get("href"))
7836 f.addEvent("click", function (g) {
7837 g.stop();
7838 b.getTour(f.get("href"))
7840 c.addEvent("click", function (g) {
7841 g.stop();
7842 b.getTour(c.get("href"))
7845 getTour: function (b) {
7846 var a = this;
7847 a.popcontent().set("html", '<div class="loading"></div>');
7848 var c = new Request.HTML({
7849 url: b,
7850 evalScripts: false,
7851 onSuccess: function (d) {
7852 a.popcontent().set("text", "");
7853 a.popcontent().adopt(d);
7854 a.startTour()
7856 onFailure: function () {
7857 a.popcontent().set("text", "The request failed.")
7860 c.send()
7863 var sliderWidget = new Class({
7864 Implements: [Options, Events],
7865 options: {
7866 container: "",
7867 preview: true,
7868 inpreview: false,
7869 start: 0,
7870 head: "",
7871 desc: "",
7872 prev_bg: "",
7873 prev_container: "",
7874 prev_stage_container: "",
7875 prev_items: "",
7876 close: "",
7877 pimgwidth: "",
7878 directcall: false
7880 initialize: function (a) {
7881 this.setOptions(a);
7882 if (!this.options.directcall) {
7883 this.slideshow()
7884 } else {
7885 this.previewstart(0)
7888 stage: function () {
7889 return $$(this.options.container[0].getChildren(":nth-child(2)"))
7891 belt: function () {
7892 return $$(this.stage()[0].getChildren(":nth-child(1)"))
7894 items: function () {
7895 return $$(this.belt().getChildren())
7897 item: function () {
7898 return this.items()[0]
7900 itemlength: function () {
7901 var b = this.item().getAttribute("width");
7902 if (b == null) {
7903 b = this.item().getStyle("width").toInt()
7905 if (b == 0) {
7906 b = 520
7908 b = parseInt(b);
7909 var c = this.item().getStyle("margin-left").toInt();
7910 var a = this.item().getStyle("margin-right").toInt();
7911 return b + c + a
7913 beltlength: function () {
7914 var a = this.items().length * this.itemlength();
7915 this.belt().setStyle("width", a);
7916 return a
7918 viewport: function () {
7919 return this.stage()[0].getStyle("width").toInt()
7921 prevslide: function () {
7922 return $$(this.options.container[0].getChildren("a.prev"))
7924 nextslide: function () {
7925 return $$(this.options.container[0].getChildren("a.next"))
7927 index: function () {
7928 return this.options.start
7930 slideshow: function () {
7931 var g = this.beltlength();
7932 var b = this.itemlength();
7933 var f = 0;
7934 var a = this;
7935 var c = a.index();
7936 if (c == "0") {
7937 this.prevslide().removeClass("disabled");
7938 this.nextslide().addClass("disabled")
7939 } else {
7940 if (c == this.items().length - 1) {
7941 this.prevslide().addClass("disabled");
7942 this.nextslide().removeClass("disabled")
7943 } else {
7944 this.prevslide().removeClass("disabled");
7945 this.nextslide().removeClass("disabled")
7948 if (this.options.inpreview) {
7949 this.addHeader(c);
7950 this.adddescription(c);
7951 if (c != "0") {
7952 g = g - this.itemlength() * (c + 1);
7953 b = b + this.itemlength() * (c - 1);
7954 f = b - this.itemlength();
7955 var d = new Fx.Morph(a.belt()[0], {
7956 duration: "normal",
7957 transition: "sine:in:out"
7959 d.start({
7960 left: "-" + b + "px"
7962 } else {
7963 a.belt()[0].setStyle("left", 0)
7966 this.prevslide().addEvent("click", function () {
7967 if (a.options.inpreview) {
7968 c = c + 1;
7969 a.addHeader(c);
7970 a.adddescription(c)
7972 if (a.nextslide().hasClass("disabled")) {
7973 a.nextslide().removeClass("disabled")
7975 if (g == a.beltlength()) {
7976 b = b;
7977 g = g - a.itemlength()
7978 } else {
7979 b = a.beltlength() - g
7981 if (g > a.viewport()) {
7982 var h = new Fx.Morph(a.belt()[0], {
7983 duration: "normal",
7984 transition: "sine:in:out"
7986 var i = {};
7987 if (Travian.getDirection() == "ltr") {
7988 i.left = "-" + b + "px"
7989 } else {
7990 i.right = "-" + b + "px"
7992 h.start(i);
7993 g = g - a.itemlength();
7994 f = b - a.itemlength();
7995 if (g < a.viewport()) {
7996 this.addClass("disabled")
8000 this.nextslide().addEvent("click", function () {
8001 c = c - 1;
8002 if (a.options.inpreview) {
8003 a.addHeader(c);
8004 a.adddescription(c)
8006 if (a.prevslide().hasClass("disabled")) {
8007 a.prevslide().removeClass("disabled")
8009 if (f != "-" + a.itemlength()) {
8010 var h = new Fx.Morph(a.belt()[0], {
8011 duration: "normal",
8012 transition: "sine:in:out"
8014 var i = {};
8015 if (Travian.getDirection() == "ltr") {
8016 i.left = "-" + f + "px"
8017 } else {
8018 i.right = "-" + f + "px"
8020 h.start(i);
8021 f = f - a.itemlength();
8022 g = g + a.itemlength();
8023 if (f == "-" + a.itemlength()) {
8024 this.addClass("disabled")
8028 if (this.options.preview) {
8029 this.items().each(function (i, h) {
8030 i.addEvent("click", function () {
8031 a.previewstart(h)
8036 previewstart: function (b) {
8037 var a = this;
8038 this.options.prev_items.empty();
8039 $each(screenshots, function (d) {
8040 a.addImg(d.img)
8042 var c = new sliderWidget({
8043 container: this.options.prev_stage_container,
8044 preview: false,
8045 inpreview: true,
8046 start: b,
8047 head: this.options.head,
8048 desc: this.options.desc,
8049 prev_bg: this.options.prev_bg,
8050 prev_container: this.options.prev_container,
8051 close: this.options.close,
8052 pimgwidth: this.options.pimgwidth
8054 this.showPreview(c)
8056 addImg: function (b) {
8057 var a = new Element("img", {
8058 src: "img/x.gif",
8059 "class": b,
8060 width: this.options.pimgwidth,
8061 height: 397
8062 }).inject(this.options.prev_items)
8064 addHeader: function (a) {
8065 this.options.head.getElement("h3").empty().appendText(screenshots[a].hl)
8067 adddescription: function (a) {
8068 this.options.desc.empty().appendText(screenshots[a].desc)
8070 showPreview: function (g) {
8071 var f = $$(g.options.prev_bg);
8072 var d = $$(g.options.prev_container);
8073 var b = document.documentElement.clientWidth;
8074 d[0].setStyles({
8075 display: "block",
8076 visibility: "hidden"
8078 var c = d[0].getStyle("width").toInt();
8079 f[0].setStyles({
8080 opacity: "0.7",
8081 display: "block"
8083 var a = $(document.body).getScroll();
8084 d[0].setStyles({
8085 left: b / 2 - c / 2,
8086 top: a.y + 100,
8087 visibility: "visible",
8088 display: "block"
8090 var h = $(d[0]).getElement(".close");
8091 h.addEvent("click", function () {
8092 f[0].setStyle("display", "none");
8093 d[0].setStyle("display", "none");
8094 g.prevslide().removeEvents();
8095 g.nextslide().removeEvents()
8097 f[0].addEvent("click", function () {
8098 f[0].setStyle("display", "none");
8099 d[0].setStyle("display", "none");
8100 g.prevslide().removeEvents();
8101 g.nextslide().removeEvents()
8105 var stageWidget = new Class({
8106 Implements: [Options, Events],
8107 options: {
8108 stagebg: "",
8109 stagecon: [],
8110 stagenav: [],
8111 stagelink: [],
8112 stageduration: [],
8113 periodical: "",
8114 currentCounter: 0,
8115 nextCounter: 1,
8116 numberOfStages: 3
8118 initialize: function (a) {
8119 this.setOptions(a);
8120 this.stageshow();
8121 this.autoshow()
8123 stageshow: function () {
8124 var a = this;
8125 this.options.stagenav.each(function (c, b) {
8126 c.addEvents({
8127 mouseenter: function () {
8128 a.pauseshow();
8129 if (!this.hasClass("act" + b)) {
8130 a.animateStage(b)
8133 mouseleave: function (d) {
8134 if (d.relatedTarget != null && d.relatedTarget.className.substring() != "stage-content") {
8135 a.autoshow()
8141 autoAnimateState: function () {
8142 this.animateStage();
8143 clearTimeout(this.options.timeout);
8144 var a = this.options.stageduration[this.options.currentCounter];
8145 this.options.timeout = this.autoAnimateState.delay(a, this)
8147 animateStage: function (a) {
8148 $each(this.options.stagenav, function (d, c) {
8149 d.removeClass("act" + c)
8151 $each(this.options.stagecon, function (c) {
8152 c.removeClass("shown")
8154 $each(this.options.stagelink, function (c) {
8155 c.removeClass("shown")
8157 if (typeof a === "undefined") {
8158 this.options.currentCounter = this.options.nextCounter;
8159 var b = this.options.nextCounter;
8160 this.options.nextCounter = (this.options.nextCounter + 1) % this.options.numberOfStages
8161 } else {
8162 b = a;
8163 this.options.currentCounter = b;
8164 this.options.nextCounter = (b + 1) % this.options.numberOfStages
8166 this.options.stagecon[b].setStyles({
8167 visibility: "hidden",
8168 opacity: 0
8170 this.options.stagebg.setStyles({
8171 visibility: "hidden",
8172 opacity: 0
8174 this.options.stagenav[b].addClass("act" + b).fade("in");
8175 this.options.stagecon[b].addClass("shown").fade("in");
8176 this.options.stagelink[b].addClass("shown").fade("in")
8178 autoshow: function () {
8179 var a = this.options.stageduration[this.options.currentCounter];
8180 this.options.timeout = this.autoAnimateState.delay(a, this)
8182 pauseshow: function () {
8183 clearTimeout(this.options.timeout)
8186 var tooltipWidget = new Class({
8187 Implements: [Options, Events],
8188 options: {
8189 tips: [],
8190 details: []
8192 initialize: function (a) {
8193 this.setOptions(a);
8194 this.tooltip()
8196 tooltip: function () {
8197 var a = this;
8198 this.options.tips.each(function (c, b) {
8199 c.addEvents({
8200 mouseenter: function () {
8201 if (Travian.getDirection() == "ltr") {
8202 var g = this.offsetLeft + 85
8203 } else {
8204 var g = this.offsetLeft - 275
8206 a.options.details[b].addClass("shown");
8207 var f = a.options.details[b].getSize();
8208 a.options.details[b].removeClass("shown");
8209 var d = this.offsetTop - f.y;
8210 a.options.details[b].setStyles({
8211 position: "absolute",
8212 left: g,
8213 top: d,
8214 visibility: "hidden",
8215 opacity: 0
8217 if (!this.hasClass("shown")) {
8218 a.options.details[b].addClass("shown").fade("in");
8219 this.addClass("act" + b)
8222 mouseleave: function (d) {
8223 if (d.relatedTarget.className.substring(0, 7) != "details") {
8224 a.options.details[b].removeClass("shown");
8225 this.removeClass("act" + b)
8230 this.options.details.each(function (c, b) {
8231 c.addEvents({
8232 mouseleave: function () {
8233 this.removeClass("shown")
8239 window.addEvent("domready", function () {
8240 $$(".popcon").addEvent("click", function (c) {
8241 c.stop();
8242 new popupWidget({
8243 pop_bg: $("overlaybg"),
8244 pop_container: $$("#popup"),
8245 close: $$(".pclose"),
8246 url: this.get("href"),
8247 tour: this.get("href") == "#tutorial" ? true : false,
8248 insupport: this.get("href") == "#help" ? true : false
8251 var b = new URI();
8252 var a = b.get("fragment");
8253 if (a && a == "screenshots") {} else {
8254 if (a) {
8255 new popupWidget({
8256 pop_bg: $("overlaybg"),
8257 pop_container: $$("#popup"),
8258 close: $$(".pclose"),
8259 url: b.toString(),
8260 tour: a == "#tutorial" ? true : false,
8261 insupport: a == "#help" ? true : false,
8262 anchorcheck: true