PageSourceSearch

http://www.limnologia.hu/limno_plugins/cl_widgets/jslib/jslib.php?1348675994

js limnologia.hu collected 2026-09-25 00:00:42 UTC 325,871 bytes, 9,960 lines download raw bytes

1/*  Prototype JavaScript framework, version 1.7
2 *  (c) 2005-2010 Sam Stephenson
3 *
4 *  Prototype is freely distributable under the terms of an MIT-style license.
5 *  For details, see the Prototype web site: http://www.prototypejs.org/
6 *
7 *--------------------------------------------------------------------------*/
8
9var Prototype = {
10  Version: '1.7',
11
12  Browser: (function(){
13    var ua = navigator.userAgent;
14    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
15    return {
16      IE:             !!window.attachEvent && !isOpera,
17      Opera:          isOpera,
18      WebKit:         ua.indexOf('AppleWebKit/') > -1,
19      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
20      MobileSafari:   /Apple.*Mobile/.test(ua)
21    }
22  })(),
23
24  BrowserFeatures: {
25    XPath: !!document.evaluate,
26
27    SelectorsAPI: !!document.querySelector,
28
29    ElementExtensions: (function() {
30      var constructor = window.Element || window.HTMLElement;
31      return !!(constructor && constructor.prototype);
32    })(),
33    SpecificElementExtensions: (function() {
34      if (typeof window.HTMLDivElement !== 'undefined')
35        return true;
36
37      var div = document.createElement('div'),
38          form = document.createElement('form'),
39          isSupported = false;
40
41      if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
42        isSupported = true;
43      }
44
45      div = form = null;
46
47      return isSupported;
48    })()
49  },
50
51  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
52  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
53
54  emptyFunction: function() { },
55
56  K: function(x) { return x }
57};
58
59if (Prototype.Browser.MobileSafari)
60  Prototype.BrowserFeatures.SpecificElementExtensions = false;
61
62
63var Abstract = { };
64
65
66var Try = {
67  these: function() {
68    var returnValue;
69
70    for (var i = 0, length = arguments.length; i < length; i++) {
71      var lambda = arguments[i];
72      try {
73        returnValue = lambda();
74        break;
75      } catch (e) { }
76    }
77
78    return returnValue;
79  }
80};
81
82/* Based on Alex Arnell's inheritance implementation. */
83
84var Class = (function() {
85
86  var IS_DONTENUM_BUGGY = (function(){
87    for (var p in { toString: 1 }) {
88      if (p === 'toString') return false;
89    }
90    return true;
91  })();
92
93  function subclass() {};
94  function create() {
95    var parent = null, properties = $A(arguments);
96    if (Object.isFunction(properties[0]))
97      parent = properties.shift();
98
99    function klass() {
100      this.initialize.apply(this, arguments);
101    }
102
103    Object.extend(klass, Class.Methods);
104    klass.superclass = parent;
105    klass.subclasses = [];
106
107    if (parent) {
108      subclass.prototype = parent.prototype;
109      klass.prototype = new subclass;
110      parent.subclasses.push(klass);
111    }
112
113    for (var i = 0, length = properties.length; i < length; i++)
114      klass.addMethods(properties[i]);
115
116    if (!klass.prototype.initialize)
117      klass.prototype.initialize = Prototype.emptyFunction;
118
119    klass.prototype.constructor = klass;
120    return klass;
121  }
122
123  function addMethods(source) {
124    var ancestor   = this.superclass && this.superclass.prototype,
125        properties = Object.keys(source);
126
127    if (IS_DONTENUM_BUGGY) {
128      if (source.toString != Object.prototype.toString)
129        properties.push("toString");
130      if (source.valueOf != Object.prototype.valueOf)
131        properties.push("valueOf");
132    }
133
134    for (var i = 0, length = properties.length; i < length; i++) {
135      var property = properties[i], value = source[property];
136      if (ancestor && Object.isFunction(value) &&
137          value.argumentNames()[0] == "$super") {
138        var method = value;
139        value = (function(m) {
140          return function() { return ancestor[m].apply(this, arguments); };
141        })(property).wrap(method);
142
143        value.valueOf = method.valueOf.bind(method);
144        value.toString = method.toString.bind(method);
145      }
146      this.prototype[property] = value;
147    }
148
149    return this;
150  }
151
152  return {
153    create: create,
154    Methods: {
155      addMethods: addMethods
156    }
157  };
158})();
159(function() {
160
161  var _toString = Object.prototype.toString,
162      NULL_TYPE = 'Null',
163      UNDEFINED_TYPE = 'Undefined',
164      BOOLEAN_TYPE = 'Boolean',
165      NUMBER_TYPE = 'Number',
166      STRING_TYPE = 'String',
167      OBJECT_TYPE = 'Object',
168      FUNCTION_CLASS = '[object Function]',
169      BOOLEAN_CLASS = '[object Boolean]',
170      NUMBER_CLASS = '[object Number]',
171      STRING_CLASS = '[object String]',
172      ARRAY_CLASS = '[object Array]',
173      DATE_CLASS = '[object Date]',
174      NATIVE_JSON_STRINGIFY_SUPPORT = window.JSON &&
175        typeof JSON.stringify === 'function' &&
176        JSON.stringify(0) === '0' &&
177        typeof JSON.stringify(Prototype.K) === 'undefined';
178
179  function Type(o) {
180    switch(o) {
181      case null: return NULL_TYPE;
182      case (void 0): return UNDEFINED_TYPE;
183    }
184    var type = typeof o;
185    switch(type) {
186      case 'boolean': return BOOLEAN_TYPE;
187      case 'number':  return NUMBER_TYPE;
188      case 'string':  return STRING_TYPE;
189    }
190    return OBJECT_TYPE;
191  }
192
193  function extend(destination, source) {
194    for (var property in source)
195      destination[property] = source[property];
196    return destination;
197  }
198
199  function inspect(object) {
200    try {
201      if (isUndefined(object)) return 'undefined';
202      if (object === null) return 'null';
203      return object.inspect ? object.inspect() : String(object);
204    } catch (e) {
205      if (e instanceof RangeError) return '...';
206      throw e;
207    }
208  }
209
210  function toJSON(value) {
211    return Str('', { '': value }, []);
212  }
213
214  function Str(key, holder, stack) {
215    var value = holder[key],
216        type = typeof value;
217
218    if (Type(value) === OBJECT_TYPE && typeof value.toJSON === 'function') {
219      value = value.toJSON(key);
220    }
221
222    var _class = _toString.call(value);
223
224    switch (_class) {
225      case NUMBER_CLASS:
226      case BOOLEAN_CLASS:
227      case STRING_CLASS:
228        value = value.valueOf();
229    }
230
231    switch (value) {
232      case null: return 'null';
233      case true: return 'true';
234      case false: return 'false';
235    }
236
237    type = typeof value;
238    switch (type) {
239      case 'string':
240        return value.inspect(true);
241      case 'number':
242        return isFinite(value) ? String(value) : 'null';
243      case 'object':
244
245        for (var i = 0, length = stack.length; i < length; i++) {
246          if (stack[i] === value) { throw new TypeError(); }
247        }
248        stack.push(value);
249
250        var partial = [];
251        if (_class === ARRAY_CLASS) {
252          for (var i = 0, length = value.length; i < length; i++) {
253            var str = Str(i, value, stack);
254            partial.push(typeof str === 'undefined' ? 'null' : str);
255          }
256          partial = '[' + partial.join(',') + ']';
257        } else {
258          var keys = Object.keys(value);
259          for (var i = 0, length = keys.length; i < length; i++) {
260            var key = keys[i], str = Str(key, value, stack);
261            if (typeof str !== "undefined") {
262               partial.push(key.inspect(true)+ ':' + str);
263             }
264          }
265          partial = '{' + partial.join(',') + '}';
266        }
267        stack.pop();
268        return partial;
269    }
270  }
271
272  function stringify(object) {
273    return JSON.stringify(object);
274  }
275
276  function toQueryString(object) {
277    return $H(object).toQueryString();
278  }
279
280  function toHTML(object) {
281    return object && object.toHTML ? object.toHTML() : String.interpret(object);
282  }
283
284  function keys(object) {
285    if (Type(object) !== OBJECT_TYPE) { throw new TypeError(); }
286    var results = [];
287    for (var property in object) {
288      if (object.hasOwnProperty(property)) {
289        results.push(property);
290      }
291    }
292    return results;
293  }
294
295  function values(object) {
296    var results = [];
297    for (var property in object)
298      results.push(object[property]);
299    return results;
300  }
301
302  function clone(object) {
303    return extend({ }, object);
304  }
305
306  function isElement(object) {
307    return !!(object && object.nodeType == 1);
308  }
309
310  function isArray(object) {
311    return _toString.call(object) === ARRAY_CLASS;
312  }
313
314  var hasNativeIsArray = (typeof Array.isArray == 'function')
315    && Array.isArray([]) && !Array.isArray({});
316
317  if (hasNativeIsArray) {
318    isArray = Array.isArray;
319  }
320
321  function isHash(object) {
322    return object instanceof Hash;
323  }
324
325  function isFunction(object) {
326    return _toString.call(object) === FUNCTION_CLASS;
327  }
328
329  function isString(object) {
330    return _toString.call(object) === STRING_CLASS;
331  }
332
333  function isNumber(object) {
334    return _toString.call(object) === NUMBER_CLASS;
335  }
336
337  function isDate(object) {
338    return _toString.call(object) === DATE_CLASS;
339  }
340
341  function isUndefined(object) {
342    return typeof object === "undefined";
343  }
344
345  extend(Object, {
346    extend:        extend,
347    inspect:       inspect,
348    toJSON:        NATIVE_JSON_STRINGIFY_SUPPORT ? stringify : toJSON,
349    toQueryString: toQueryString,
350    toHTML:        toHTML,
351    keys:          Object.keys || keys,
352    values:        values,
353    clone:         clone,
354    isElement:     isElement,
355    isArray:       isArray,
356    isHash:        isHash,
357    isFunction:    isFunction,
358    isString:      isString,
359    isNumber:      isNumber,
360    isDate:        isDate,
361    isUndefined:   isUndefined
362  });
363})();
364Object.extend(Function.prototype, (function() {
365  var slice = Array.prototype.slice;
366
367  function update(array, args) {
368    var arrayLength = array.length, length = args.length;
369    while (length--) array[arrayLength + length] = args[length];
370    return array;
371  }
372
373  function merge(array, args) {
374    array = slice.call(array, 0);
375    return update(array, args);
376  }
377
378  function argumentNames() {
379    var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
380      .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
381      .replace(/\s+/g, '').split(',');
382    return names.length == 1 && !names[0] ? [] : names;
383  }
384
385  function bind(context) {
386    if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
387    var __method = this, args = slice.call(arguments, 1);
388    return function() {
389      var a = merge(args, arguments);
390      return __method.apply(context, a);
391    }
392  }
393
394  function bindAsEventListener(context) {
395    var __method = this, args = slice.call(arguments, 1);
396    return function(event) {
397      var a = update([event || window.event], args);
398      return __method.apply(context, a);
399    }
400  }
401
402  function curry() {
403    if (!arguments.length) return this;
404    var __method = this, args = slice.call(arguments, 0);
405    return function() {
406      var a = merge(args, arguments);
407      return __method.apply(this, a);
408    }
409  }
410
411  function delay(timeout) {
412    var __method = this, args = slice.call(arguments, 1);
413    timeout = timeout * 1000;
414    return window.setTimeout(function() {
415      return __method.apply(__method, args);
416    }, timeout);
417  }
418
419  function defer() {
420    var args = update([0.01], arguments);
421    return this.delay.apply(this, args);
422  }
423
424  function wrap(wrapper) {
425    var __method = this;
426    return function() {
427      var a = update([__method.bind(this)], arguments);
428      return wrapper.apply(this, a);
429    }
430  }
431
432  function methodize() {
433    if (this._methodized) return this._methodized;
434    var __method = this;
435    return this._methodized = function() {
436      var a = update([this], arguments);
437      return __method.apply(null, a);
438    };
439  }
440
441  return {
442    argumentNames:       argumentNames,
443    bind:                bind,
444    bindAsEventListener: bindAsEventListener,
445    curry:               curry,
446    delay:               delay,
447    defer:               defer,
448    wrap:                wrap,
449    methodize:           methodize
450  }
451})());
452
453
454
455(function(proto) {
456
457
458  function toISOString() {
459    return this.getUTCFullYear() + '-' +
460      (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
461      this.getUTCDate().toPaddedString(2) + 'T' +
462      this.getUTCHours().toPaddedString(2) + ':' +
463      this.getUTCMinutes().toPaddedString(2) + ':' +
464      this.getUTCSeconds().toPaddedString(2) + 'Z';
465  }
466
467
468  function toJSON() {
469    return this.toISOString();
470  }
471
472  if (!proto.toISOString) proto.toISOString = toISOString;
473  if (!proto.toJSON) proto.toJSON = toJSON;
474
475})(Date.prototype);
476
477
478RegExp.prototype.match = RegExp.prototype.test;
479
480RegExp.escape = function(str) {
481  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
482};
483var PeriodicalExecuter = Class.create({
484  initialize: function(callback, frequency) {
485    this.callback = callback;
486    this.frequency = frequency;
487    this.currentlyExecuting = false;
488
489    this.registerCallback();
490  },
491
492  registerCallback: function() {
493    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
494  },
495
496  execute: function() {
497    this.callback(this);
498  },
499
500  stop: function() {
501    if (!this.timer) return;
502    clearInterval(this.timer);
503    this.timer = null;
504  },
505
506  onTimerEvent: function() {
507    if (!this.currentlyExecuting) {
508      try {
509        this.currentlyExecuting = true;
510        this.execute();
511        this.currentlyExecuting = false;
512      } catch(e) {
513        this.currentlyExecuting = false;
514        throw e;
515      }
516    }
517  }
518});
519Object.extend(String, {
520  interpret: function(value) {
521    return value == null ? '' : String(value);
522  },
523  specialChar: {
524    '\b': '\\b',
525    '\t': '\\t',
526    '\n': '\\n',
527    '\f': '\\f',
528    '\r': '\\r',
529    '\\': '\\\\'
530  }
531});
532
533Object.extend(String.prototype, (function() {
534  var NATIVE_JSON_PARSE_SUPPORT = window.JSON &&
535    typeof JSON.parse === 'function' &&
536    JSON.parse('{"test": true}').test;
537
538  function prepareReplacement(replacement) {
539    if (Object.isFunction(replacement)) return replacement;
540    var template = new Template(replacement);
541    return function(match) { return template.evaluate(match) };
542  }
543
544  function gsub(pattern, replacement) {
545    var result = '', source = this, match;
546    replacement = prepareReplacement(replacement);
547
548    if (Object.isString(pattern))
549      pattern = RegExp.escape(pattern);
550
551    if (!(pattern.length || pattern.source)) {
552      replacement = replacement('');
553      return replacement + source.split('').join(replacement) + replacement;
554    }
555
556    while (source.length > 0) {
557      if (match = source.match(pattern)) {
558        result += source.slice(0, match.index);
559        result += String.interpret(replacement(match));
560        source  = source.slice(match.index + match[0].length);
561      } else {
562        result += source, source = '';
563      }
564    }
565    return result;
566  }
567
568  function sub(pattern, replacement, count) {
569    replacement = prepareReplacement(replacement);
570    count = Object.isUndefined(count) ? 1 : count;
571
572    return this.gsub(pattern, function(match) {
573      if (--count < 0) return match[0];
574      return replacement(match);
575    });
576  }
577
578  function scan(pattern, iterator) {
579    this.gsub(pattern, iterator);
580    return String(this);
581  }
582
583  function truncate(length, truncation) {
584    length = length || 30;
585    truncation = Object.isUndefined(truncation) ? '...' : truncation;
586    return this.length > length ?
587      this.slice(0, length - truncation.length) + truncation : String(this);
588  }
589
590  function strip() {
591    return this.replace(/^\s+/, '').replace(/\s+$/, '');
592  }
593
594  function stripTags() {
595    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
596  }
597
598  function stripScripts() {
599    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
600  }
601
602  function extractScripts() {
603    var matchAll = new RegExp(Prototype.ScriptFragment, 'img'),
604        matchOne = new RegExp(Prototype.ScriptFragment, 'im');
605    return (this.match(matchAll) || []).map(function(scriptTag) {
606      return (scriptTag.match(matchOne) || ['', ''])[1];
607    });
608  }
609
610  function evalScripts() {
611    return this.extractScripts().map(function(script) { return eval(script) });
612  }
613
614  function escapeHTML() {
615    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
616  }
617
618  function unescapeHTML() {
619    return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
620  }
621
622
623  function toQueryParams(separator) {
624    var match = this.strip().match(/([^?#]*)(#.*)?$/);
625    if (!match) return { };
626
627    return match[1].split(separator || '&').inject({ }, function(hash, pair) {
628      if ((pair = pair.split('='))[0]) {
629        var key = decodeURIComponent(pair.shift()),
630            value = pair.length > 1 ? pair.join('=') : pair[0];
631
632        if (value != undefined) value = decodeURIComponent(value);
633
634        if (key in hash) {
635          if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
636          hash[key].push(value);
637        }
638        else hash[key] = value;
639      }
640      return hash;
641    });
642  }
643
644  function toArray() {
645    return this.split('');
646  }
647
648  function succ() {
649    return this.slice(0, this.length - 1) +
650      String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
651  }
652
653  function times(count) {
654    return count < 1 ? '' : new Array(count + 1).join(this);
655  }
656
657  function camelize() {
658    return this.replace(/-+(.)?/g, function(match, chr) {
659      return chr ? chr.toUpperCase() : '';
660    });
661  }
662
663  function capitalize() {
664    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
665  }
666
667  function underscore() {
668    return this.replace(/::/g, '/')
669               .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
670               .replace(/([a-z\d])([A-Z])/g, '$1_$2')
671               .replace(/-/g, '_')
672               .toLowerCase();
673  }
674
675  function dasherize() {
676    return this.replace(/_/g, '-');
677  }
678
679  function inspect(useDoubleQuotes) {
680    var escapedString = this.replace(/[\x00-\x1f\\]/g, function(ch
680aracter) {
681      if (character in String.specialChar) {
682        return String.specialChar[character];
683      }
684      return '\\u00' + character.charCodeAt().toPaddedString(2, 16);
685    });
686    if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
687    return "'" + escapedString.replace(/'/g, '\\\'') + "'";
688  }
689
690  function unfilterJSON(filter) {
691    return this.replace(filter || Prototype.JSONFilter, '$1');
692  }
693
694  function isJSON() {
695    var str = this;
696    if (str.blank()) return false;
697    str = str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@');
698    str = str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');
699    str = str.replace(/(?:^|:|,)(?:\s*\[)+/g, '');
700    return (/^[\],:{}\s]*$/).test(str);
701  }
702
703  function evalJSON(sanitize) {
704    var json = this.unfilterJSON(),
705        cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
706    if (cx.test(json)) {
707      json = json.replace(cx, function (a) {
708        return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
709      });
710    }
711    try {
712      if (!sanitize || json.isJSON()) return eval('(' + json + ')');
713    } catch (e) { }
714    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
715  }
716
717  function parseJSON() {
718    var json = this.unfilterJSON();
719    return JSON.parse(json);
720  }
721
722  function include(pattern) {
723    return this.indexOf(pattern) > -1;
724  }
725
726  function startsWith(pattern) {
727    return this.lastIndexOf(pattern, 0) === 0;
728  }
729
730  function endsWith(pattern) {
731    var d = this.length - pattern.length;
732    return d >= 0 && this.indexOf(pattern, d) === d;
733  }
734
735  function empty() {
736    return this == '';
737  }
738
739  function blank() {
740    return /^\s*$/.test(this);
741  }
742
743  function interpolate(object, pattern) {
744    return new Template(this, pattern).evaluate(object);
745  }
746
747  return {
748    gsub:           gsub,
749    sub:            sub,
750    scan:           scan,
751    truncate:       truncate,
752    strip:          String.prototype.trim || strip,
753    stripTags:      stripTags,
754    stripScripts:   stripScripts,
755    extractScripts: extractScripts,
756    evalScripts:    evalScripts,
757    escapeHTML:     escapeHTML,
758    unescapeHTML:   unescapeHTML,
759    toQueryParams:  toQueryParams,
760    parseQuery:     toQueryParams,
761    toArray:        toArray,
762    succ:           succ,
763    times:          times,
764    camelize:       camelize,
765    capitalize:     capitalize,
766    underscore:     underscore,
767    dasherize:      dasherize,
768    inspect:        inspect,
769    unfilterJSON:   unfilterJSON,
770    isJSON:         isJSON,
771    evalJSON:       NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON,
772    include:        include,
773    startsWith:     startsWith,
774    endsWith:       endsWith,
775    empty:          empty,
776    blank:          blank,
777    interpolate:    interpolate
778  };
779})());
780
781var Template = Class.create({
782  initialize: function(template, pattern) {
783    this.template = template.toString();
784    this.pattern = pattern || Template.Pattern;
785  },
786
787  evaluate: function(object) {
788    if (object && Object.isFunction(object.toTemplateReplacements))
789      object = object.toTemplateReplacements();
790
791    return this.template.gsub(this.pattern, function(match) {
792      if (object == null) return (match[1] + '');
793
794      var before = match[1] || '';
795      if (before == '\\') return match[2];
796
797      var ctx = object, expr = match[3],
798          pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
799
800      match = pattern.exec(expr);
801      if (match == null) return before;
802
803      while (match != null) {
804        var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1];
805        ctx = ctx[comp];
806        if (null == ctx || '' == match[3]) break;
807        expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
808        match = pattern.exec(expr);
809      }
810
811      return before + String.interpret(ctx);
812    });
813  }
814});
815Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
816
817var $break = { };
818
819var Enumerable = (function() {
820  function each(iterator, context) {
821    var index = 0;
822    try {
823      this._each(function(value) {
824        iterator.call(context, value, index++);
825      });
826    } catch (e) {
827      if (e != $break) throw e;
828    }
829    return this;
830  }
831
832  function eachSlice(number, iterator, context) {
833    var index = -number, slices = [], array = this.toArray();
834    if (number < 1) return array;
835    while ((index += number) < array.length)
836      slices.push(array.slice(index, index+number));
837    return slices.collect(iterator, context);
838  }
839
840  function all(iterator, context) {
841    iterator = iterator || Prototype.K;
842    var result = true;
843    this.each(function(value, index) {
844      result = result && !!iterator.call(context, value, index);
845      if (!result) throw $break;
846    });
847    return result;
848  }
849
850  function any(iterator, context) {
851    iterator = iterator || Prototype.K;
852    var result = false;
853    this.each(function(value, index) {
854      if (result = !!iterator.call(context, value, index))
855        throw $break;
856    });
857    return result;
858  }
859
860  function collect(iterator, context) {
861    iterator = iterator || Prototype.K;
862    var results = [];
863    this.each(function(value, index) {
864      results.push(iterator.call(context, value, index));
865    });
866    return results;
867  }
868
869  function detect(iterator, context) {
870    var result;
871    this.each(function(value, index) {
872      if (iterator.call(context, value, index)) {
873        result = value;
874        throw $break;
875      }
876    });
877    return result;
878  }
879
880  function findAll(iterator, context) {
881    var results = [];
882    this.each(function(value, index) {
883      if (iterator.call(context, value, index))
884        results.push(value);
885    });
886    return results;
887  }
888
889  function grep(filter, iterator, context) {
890    iterator = iterator || Prototype.K;
891    var results = [];
892
893    if (Object.isString(filter))
894      filter = new RegExp(RegExp.escape(filter));
895
896    this.each(function(value, index) {
897      if (filter.match(value))
898        results.push(iterator.call(context, value, index));
899    });
900    return results;
901  }
902
903  function include(object) {
904    if (Object.isFunction(this.indexOf))
905      if (this.indexOf(object) != -1) return true;
906
907    var found = false;
908    this.each(function(value) {
909      if (value == object) {
910        found = true;
911        throw $break;
912      }
913    });
914    return found;
915  }
916
917  function inGroupsOf(number, fillWith) {
918    fillWith = Object.isUndefined(fillWith) ? null : fillWith;
919    return this.eachSlice(number, function(slice) {
920      while(slice.length < number) slice.push(fillWith);
921      return slice;
922    });
923  }
924
925  function inject(memo, iterator, context) {
926    this.each(function(value, index) {
927      memo = iterator.call(context, memo, value, index);
928    });
929    return memo;
930  }
931
932  function invoke(method) {
933    var args = $A(arguments).slice(1);
934    return this.map(function(value) {
935      return value[method].apply(value, args);
936    });
937  }
938
939  function max(iterator, context) {
940    iterator = iterator || Prototype.K;
941    var result;
942    this.each(function(value, index) {
943      value = iterator.call(context, value, index);
944      if (result == null || value >= result)
945        result = value;
946    });
947    return result;
948  }
949
950  function min(iterator, context) {
951    iterator = iterator || Prototype.K;
952    var result;
953    this.each(function(value, index) {
954      value = iterator.call(context, value, index);
955      if (result == null || value < result)
956        result = value;
957    });
958    return result;
959  }
960
961  function partition(iterator, context) {
962    iterator = iterator || Prototype.K;
963    var trues = [], falses = [];
964    this.each(function(value, index) {
965      (iterator.call(context, value, index) ?
966        trues : falses).push(value);
967    });
968    return [trues, falses];
969  }
970
971  function pluck(property) {
972    var results = [];
973    this.each(function(value) {
974      results.push(value[property]);
975    });
976    return results;
977  }
978
979  function reject(iterator, context) {
980    var results = [];
981    this.each(function(value, index) {
982      if (!iterator.call(context, value, index))
983        results.push(value);
984    });
985    return results;
986  }
987
988  function sortBy(iterator, context) {
989    return this.map(function(value, index) {
990      return {
991        value: value,
992        criteria: iterator.call(context, value, index)
993      };
994    }).sort(function(left, right) {
995      var a = left.criteria, b = right.criteria;
996      return a < b ? -1 : a > b ? 1 : 0;
997    }).pluck('value');
998  }
999
1000  function toArray() {
1001    return this.map();
1002  }
1003
1004  function zip() {
1005    var iterator = Prototype.K, args = $A(arguments);
1006    if (Object.isFunction(args.last()))
1007      iterator = args.pop();
1008
1009    var collections = [this].concat(args).map($A);
1010    return this.map(function(value, index) {
1011      return iterator(collections.pluck(index));
1012    });
1013  }
1014
1015  function size() {
1016    return this.toArray().length;
1017  }
1018
1019  function inspect() {
1020    return '#<Enumerable:' + this.toArray().inspect() + '>';
1021  }
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031  return {
1032    each:       each,
1033    eachSlice:  eachSlice,
1034    all:        all,
1035    every:      all,
1036    any:        any,
1037    some:       any,
1038    collect:    collect,
1039    map:        collect,
1040    detect:     detect,
1041    findAll:    findAll,
1042    select:     findAll,
1043    filter:     findAll,
1044    grep:       grep,
1045    include:    include,
1046    member:     include,
1047    inGroupsOf: inGroupsOf,
1048    inject:     inject,
1049    invoke:     invoke,
1050    max:        max,
1051    min:        min,
1052    partition:  partition,
1053    pluck:      pluck,
1054    reject:     reject,
1055    sortBy:     sortBy,
1056    toArray:    toArray,
1057    entries:    toArray,
1058    zip:        zip,
1059    size:       size,
1060    inspect:    inspect,
1061    find:       detect
1062  };
1063})();
1064
1065function $A(iterable) {
1066  if (!iterable) return [];
1067  if ('toArray' in Object(iterable)) return iterable.toArray();
1068  var length = iterable.length || 0, results = new Array(length);
1069  while (length--) results[length] = iterable[length];
1070  return results;
1071}
1072
1073
1074function $w(string) {
1075  if (!Object.isString(string)) return [];
1076  string = string.strip();
1077  return string ? string.split(/\s+/) : [];
1078}
1079
1080Array.from = $A;
1081
1082
1083(function() {
1084  var arrayProto = Array.prototype,
1085      slice = arrayProto.slice,
1086      _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available
1087
1088  function each(iterator, context) {
1089    for (var i = 0, length = this.length >>> 0; i < length; i++) {
1090      if (i in this) iterator.call(context, this[i], i, this);
1091    }
1092  }
1093  if (!_each) _each = each;
1094
1095  function clear() {
1096    this.length = 0;
1097    return this;
1098  }
1099
1100  function first() {
1101    return this[0];
1102  }
1103
1104  function last() {
1105    return this[this.length - 1];
1106  }
1107
1108  function compact() {
1109    return this.select(function(value) {
1110      return value != null;
1111    });
1112  }
1113
1114  function flatten() {
1115    return this.inject([], function(array, value) {
1116      if (Object.isArray(value))
1117        return array.concat(value.flatten());
1118      array.push(value);
1119      return array;
1120    });
1121  }
1122
1123  function without() {
1124    var values = slice.call(arguments, 0);
1125    return this.select(function(value) {
1126      return !values.include(value);
1127    });
1128  }
1129
1130  function reverse(inline) {
1131    return (inline === false ? this.toArray() : this)._reverse();
1132  }
1133
1134  function uniq(sorted) {
1135    return this.inject([], function(array, value, index) {
1136      if (0 == index || (sorted ? array.last() != value : !array.include(value)))
1137        array.push(value);
1138      return array;
1139    });
1140  }
1141
1142  function intersect(array) {
1143    return this.uniq().findAll(function(item) {
1144      return array.detect(function(value) { return item === value });
1145    });
1146  }
1147
1148
1149  function clone() {
1150    return slice.call(this, 0);
1151  }
1152
1153  function size() {
1154    return this.length;
1155  }
1156
1157  function inspect() {
1158    return '[' + this.map(Object.inspect).join(', ') + ']';
1159  }
1160
1161  function indexOf(item, i) {
1162    i || (i = 0);
1163    var length = this.length;
1164    if (i < 0) i = length + i;
1165    for (; i < length; i++)
1166      if (this[i] === item) return i;
1167    return -1;
1168  }
1169
1170  function lastIndexOf(item, i) {
1171    i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
1172    var n = this.slice(0, i).reverse().indexOf(item);
1173    return (n < 0) ? n : i - n - 1;
1174  }
1175
1176  function concat() {
1177    var array = slice.call(this, 0), item;
1178    for (var i = 0, length = arguments.length; i < length; i++) {
1179      item = arguments[i];
1180      if (Object.isArray(item) && !('callee' in item)) {
1181        for (var j = 0, arrayLength = item.length; j < arrayLength; j++)
1182          array.push(item[j]);
1183      } else {
1184        array.push(item);
1185      }
1186    }
1187    return array;
1188  }
1189
1190  Object.extend(arrayProto, Enumerable);
1191
1192  if (!arrayProto._reverse)
1193    arrayProto._reverse = arrayProto.reverse;
1194
1195  Object.extend(arrayProto, {
1196    _each:     _each,
1197    clear:     clear,
1198    first:     first,
1199    last:      last,
1200    compact:   compact,
1201    flatten:   flatten,
1202    without:   without,
1203    reverse:   reverse,
1204    uniq:      uniq,
1205    intersect: intersect,
1206    clone:     clone,
1207    toArray:   clone,
1208    size:      size,
1209    inspect:   inspect
1210  });
1211
1212  var CONCAT_ARGUMENTS_BUGGY = (function() {
1213    return [].concat(arguments)[0][0] !== 1;
1214  })(1,2)
1215
1216  if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;
1217
1218  if (!arrayProto.indexOf) arrayProto.indexOf = indexOf;
1219  if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf;
1220})();
1221function $H(object) {
1222  return new Hash(object);
1223};
1224
1225var Hash = Class.create(Enumerable, (function() {
1226  function initialize(object) {
1227    this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
1228  }
1229
1230
1231  function _each(iterator) {
1232    for (var key in this._object) {
1233      var value = this._object[key], pair = [key, value];
1234      pair.key = key;
1235      pair.value = value;
1236      iterator(pair);
1237    }
1238  }
1239
1240  function set(key, value) {
1241    return this._object[key] = value;
1242  }
1243
1244  function get(key) {
1245    if (this._object[key] !== Object.prototype[key])
1246      return this._object[key];
1247  }
1248
1249  function unset(key) {
1250    var value = this._object[key];
1251    delete this._object[key];
1252    return value;
1253  }
1254
1255  function toObject() {
1256    return Object.clone(this._object);
1257  }
1258
1259
1260
1261  function keys() {
1262    return this.pluck('key');
1263  }
1264
1265  function values() {
1266    return this.pluck('value');
1267  }
1268
1269  function index(value) {
1270    var match = this.detect(function(pair) {
1271      return pair.value === value;
1272    });
1273    return match && match.key;
1274  }
1275
1276  function merge(object) {
1277    return this.clone().update(object);
1278  }
1279
1280  function update(object) {
1281    return new Hash(object).inject(this, function(result, pair) {
1282      result.set(pair.key, pair.value);
1283      return result;
1284    });
1285  }
1286
1287  function toQueryPair(key, value) {
1288    if (Object.isUndefined(value)) return key;
1289    return key + '=' + encodeURIComponent(String.interpret(value));
1290  }
1291
1292  function toQueryString() {
1293    return this.inject([], function(results, pair) {
1294      var key = encodeURIComponent(pair.key), values = pair.value;
1295
1296      if (values && typeof values == 'object') {
1297        if (Object.isArray(values)) {
1298          var queryValues = [];
1299          for (var i = 0, len = values.length, value; i < len; i++) {
1300            value = values[i];
1301            queryValues.push(toQueryPair(key, value));
1302          }
1303          return results.concat(queryValues);
1304        }
1305      } else results.push(toQueryPair(key, values));
1306      return results;
1307    }).join('&');
1308  }
1309
1310  function inspect() {
1311    return '#<Hash:{' + this.map(function(pair) {
1312      return pair.map(Object.inspect).join(': ');
1313    }).join(', ') + '}>';
1314  }
1315
1316  function clone() {
1317    return new Hash(this);
1318  }
1319
1320  return {
1321    initialize:             initialize,
1322    _each:                  _each,
1323    set:                    set,
1324    get:                    get,
1325    unset:                  unset,
1326    toObject:               toObject,
1327    toTemplateReplacements: toObject,
1328    keys:                   keys,
1329    values:                 values,
1330    index:                  index,
1331    merge:                  merge,
1332    update:                 update,
1333    toQueryString:          toQueryString,
1334    inspect:                inspect,
1335    toJSON:                 toObject,
1336    clone:                  clone
1337  };
1338})());
1339
1340Hash.from = $H;
1341Object.extend(Number.prototype, (function() {
1342  function toColorPart() {
1343    return this.toPaddedString(2, 16);
1344  }
1345
1346  function succ() {
1347    return this + 1;
1348  }
1349
1350  function times(iterator, context) {
1351    $R(0, this, true).each(iterator, context);
1352    return this;
1353  }
1354
1355  function toPaddedString(length, radix) {
1356    var string = this.toString(radix || 10);
1357    return '0'.times(length - string.length) + string;
1358  }
1359
1360  function abs() {
1361    return Math.abs(this);
1362  }
1363
1364  function round() {
1365    return Math.round(this);
1366  }
1367
1368  function ceil() {
1369    return Math.ceil(this);
1370  }
1371
1372  function floor() {
1373    return Math.floor(this);
1374  }
1375
1376  return {
1377    toColorPart:    toColorPart,
1378    succ:           succ,
1379    times:          times,
1380    toPaddedString: toPaddedString,
1381    abs:            abs,
1382    round:          round,
1383    ceil:           ceil,
1384    floor:          floor
1385  };
1386})());
1387
1388function $R(start, end, exclusive) {
1389  return new ObjectRange(start, end, exclusive);
1390}
1391
1392var ObjectRange = Class.create(Enumerable, (function() {
1393  function initialize(start, end, exclusive) {
1394    this.start = start;
1395    this.end = end;
1396    this.exclusive = exclusive;
1397  }
1398
1399  function _each(iterator) {
1400    var value = this.start;
1401    while (this.include(value)) {
1402      iterator(value);
1403      value = value.succ();
1404    }
1405  }
1406
1407  function include(value) {
1408    if (value < this.start)
1409      return false;
1410    if (this.exclusive)
1411      return value < this.end;
1412    return value <= this.end;
1413  }
1414
1415  return {
1416    initialize: initialize,
1417    _each:      _each,
1418    include:    include
1419  };
1420})());
1421
1422
1423
1424var Ajax = {
1425  getTransport: function() {
1426    return Try.these(
1427      function() {return new XMLHttpRequest()},
1428      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
1429      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
1430    ) || false;
1431  },
1432
1433  activeRequestCount: 0
1434};
1435
1436Ajax.Responders = {
1437  responders: [],
1438
1439  _each: function(iterator) {
1440    this.responders._each(iterator);
1441  },
1442
1443  register: function(responder) {
1444    if (!this.include(responder))
1445      this.responders.push(responder);
1446  },
1447
1448  unregister: function(responder) {
1449    this.responders = this.responders.without(responder);
1450  },
1451
1452  dispatch: function(callback, request, transport, json) {
1453    this.each(function(responder) {
1454      if (Object.isFunction(responder[callback])) {
1455        try {
1456          responder[callback].apply(responder, [request, transport, json]);
1457        } catch (e) { }
1458      }
1459    });
1460  }
1461};
1462
1463Object.extend(Ajax.Responders, Enumerable);
1464
1465Ajax.Responders.register({
1466  onCreate:   function() { Ajax.activeRequestCount++ },
1467  onComplete: function() { Ajax.activeRequestCount-- }
1468});
1469Ajax.Base = Class.create({
1470  initialize: function(options) {
1471    this.options = {
1472      method:       'post',
1473      asynchronous: true,
1474      contentType:  'application/x-www-form-urlencoded',
1475      encoding:     'UTF-8',
1476      parameters:   '',
1477      evalJSON:     true,
1478      evalJS:       true
1479    };
1480    Object.extend(this.options, options || { });
1481
1482    this.options.method = this.options.method.toLowerCase();
1483
1484    if (Object.isHash(this.options.parameters))
1485      this.options.parameters = this.options.parameters.toObject();
1486  }
1487});
1488Ajax.Request = Class.create(Ajax.Base, {
1489  _complete: false,
1490
1491  initialize: function($super, url, options) {
1492    $super(options);
1493    this.transport = Ajax.getTransport();
1494    this.request(url);
1495  },
1496
1497  request: function(url) {
1498    this.url = url;
1499    this.method = this.options.method;
1500    var params = Object.isString(this.options.parameters) ?
1501          this.options.parameters :
1502          Object.toQueryString(this.options.parameters);
1503
1504    if (!['get', 'post'].include(this.method)) {
1505      params += (params ? '&' : '') + "_method=" + this.method;
1506      this.method = 'post';
1507    }
1508
1509    if (params && this.method === 'get') {
1510      this.url += (this.url.include('?') ? '&' : '?') + params;
1511    }
1512
1513    this.parameters = params.toQueryParams();
1514
1515    try {
1516      var response = new Ajax.Response(this);
1517      if (this.options.onCreate) this.options.onCreate(response);
1518      Ajax.Responders.dispatch('onCreate', this, response);
1519
1520      this.transport.open(this.method.toUpperCase(), this.url,
1521        this.options.asynchronous);
1522
1523      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
1524
1525      this.transport.onreadystatechange = this.onStateChange.bind(this);
1526      this.setRequestHeaders();
1527
1528      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
1529      this.transport.send(this.body);
1530
1531      /* Force Firefox to handle ready state 4 for synchronous requests */
1532      if (!this.options.asynchronous && this.transport.overrideMimeType)
1533        this.onStateChange();
1534
1535    }
1536    catch (e) {
1537      this.dispatchException(e);
1538    }
1539  },
1540
1541  onStateChange: function() {
1542    var readyState = this.transport.readyState;
1543    if (readyState > 1 && !((readyState == 4) && this._complete))
1544      this.respondToReadyState(this.transport.readyState);
1545  },
1546
1547  setRequestHeaders: function() {
1548    var headers = {
1549      'X-Requested-With': 'XMLHttpRequest',
1550      'X-Prototype-Version': Prototype.Version,
1551      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
1552    };
1553
1554    if (this.method == 'post') {
1555      headers['Content-type'] = this.options.contentType +
1556        (this.options.encoding ? '; charset=' + this.options.encoding : '');
1557
1558      /* Force "Connection: close" for older Mozilla browsers to work
1559       * around a bug where XMLHttpRequest sends an incorrect
1560       * Content-length header. See Mozilla Bugzilla #246651.
1561       */
1562      if (this.transport.overrideMimeType &&
1563          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
1564            headers['Connection'] = 'close';
1565    }
1566
1567    if (typeof this.options.requestHeaders == 'object') {
1568      var extras = this.options.requestHeaders;
1569
1570      if (Object.isFunction(extras.push))
1571        for (var i = 0, length = extras.length; i < length; i += 2)
1572          headers[extras[i]] = extras[i+1];
1573      else
1574        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
1575    }
1576
1577    for (var name in headers)
1578      this.transport.setRequestHeader(name, headers[name]);
1579  },
1580
1581  success: function() {
1582    var status = this.getStatus();
1583    return !status || (status >= 200 && status < 300) || status == 304;
1584  },
1585
1586  getStatus: function() {
1587    try {
1588      if (this.transport.status === 1223) return 204;
1589      return this.transport.status || 0;
1590    } catch (e) { return 0 }
1591  },
1592
1593  respondToReadyState: function(readyState) {
1594    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
1595
1596    if (state == 'Complete') {
1597      try {
1598        this._complete = true;
1599        (this.options['on' + response.status]
1600         || this.options['on' + (this.success() ? 'Success' : 'Failure')]
1601         || Prototype.emptyFunction)(response, response.headerJSON);
1602      } catch (e) {
1603        this.dispatchException(e);
1604      }
1605
1606      var contentType = response.getHeader('Content-type');
1607      if (this.options.evalJS == 'force'
1608          || (this.options.evalJS && this.isSameOrigin() && contentType
1609          && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
1610        this.evalResponse();
1611    }
1612
1613    try {
1614      (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
1615      Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
1616    } catch (e) {
1617      this.dispatchException(e);
1618    }
1619
1620    if (state == 'Complete') {
1621      this.transport.onreadystatechange = Prototype.emptyFunction;
1622    }
1623  },
1624
1625  isSameOrigin: function() {
1626    var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
1627    return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
1628      protocol: location.protocol,
1629      domain: document.domain,
1630      port: location.port ? ':' + location.port : ''
1631    }));
1632  },
1633
1634  getHeader: function(name) {
1635    try {
1636      return this.transport.getResponseHeader(name) || null;
1637    } catch (e) { return null; }
1638  },
1639
1640  evalResponse: function() {
1641    try {
1642      return eval((this.transport.responseText || '').unfilterJSON());
1643    } catch (e) {
1644      this.dispatchException(e);
1645    }
1646  },
1647
1648  dispatchException: function(exception) {
1649    (this.options.onException || Prototype.emptyFunction)(this, exception);
1650    Ajax.Responders.dispatch('onException', this, exception);
1651  }
1652});
1653
1654Ajax.Request.Events =
1655  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
1656
1657
1658
1659
1660
1661
1662
1663
1664Ajax.Response = Class.create({
1665  initialize: function(request){
1666    this.request = request;
1667    var transport  = this.transport  = request.transport,
1668        readyState = this.readyState = transport.readyState;
1669
1670    if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
1671      this.status       = this.getStatus();
1672      this.statusText   = this.getStatusText();
1673      this.responseText = String.interpret(transport.responseText);
1674      this.headerJSON   = this._getHeaderJSON();
1675    }
1676
1677    if (readyState == 4) {
1678      var xml = transport.responseXML;
1679      this.responseXML  = Object.isUndefined(xml) ? null : xml;
1680      this.responseJSON = this._getResponseJSON();
1681    }
1682  },
1683
1684  status:      0,
1685
1686  statusText: '',
1687
1688  getStatus: Ajax.Request.prototype.getStatus,
1689
1690  getStatusText: function() {
1691    try {
1692      return this.transport.statusText || '';
1693    } catch (e) { return '' }
1694  },
1695
1696  getHeader: Ajax.Request.prototype.getHeader,
1697
1698  getAllHeaders: function() {
1699    try {
1700      return this.getAllResponseHeaders();
1701    } catch (e) { return null }
1702  },
1703
1704  getResponseHeader: function(name) {
1705    return this.transport.getResponseHeader(name);
1706  },
1707
1708  getAllResponseHeaders: function() {
1709    return this.transport.getAllResponseHeaders();
1710  },
1711
1712  _getHeaderJSON: function() {
1713    var json = this.getHeader('X-JSON');
1714    if (!json) return null;
1715    json = decodeURIComponent(escape(json));
1716    try {
1717      return json.evalJSON(this.request.options.sanitizeJSON ||
1718        !this.request.isSameOrigin());
1719    } catch (e) {
1720      this.request.dispatchException(e);
1721    }
1722  },
1723
1724  _getResponseJSON: function() {
1725    var options = this.request.options;
1726    if (!options.evalJSON || (options.evalJSON != 'force' &&
1727      !(this.getHeader('Content-type') || '').include('application/json')) ||
1728        this.responseText.blank())
1729          return null;
1730    try {
1731      return this.responseText.evalJSON(options.sanitizeJSON ||
1732        !this.request.isSameOrigin());
1733    } catch (e) {
1734      this.request.dispatchException(e);
1735    }
1736  }
1737});
1738
1739Ajax.Updater = Class.create(Ajax.Request, {
1740  initialize: function($super, container, url, options) {
1741    this.container = {
1742      success: (container.success || container),
1743      failure: (container.failure || (container.success ? null : container))
1744    };
1745
1746    options = Object.clone(options);
1747    var onComplete = options.onComplete;
1748    options.onComplete = (function(response, json) {
1749      this.updateContent(response.responseText);
1750      if (Object.isFunction(onComplete)) onComplete(response, json);
1751    }).bind(this);
1752
1753    $super(url, options);
1754  },
1755
1756  updateContent: function(responseText) {
1757    var receiver = this.container[this.success() ? 'success' : 'failure'],
1758        options = this.options;
1759
1760    if (!options.evalScripts) responseText = responseText.stripScripts();
1761
1762    if (receiver = $(receiver)) {
1763      if (options.insertion) {
1764        if (Object.isString(options.insertion)) {
1765          var insertion = { }; insertion[options.insertion] = responseText;
1766          receiver.insert(insertion);
1767        }
1768        else options.insertion(receiver, responseText);
1769      }
1770      else receiver.update(responseText);
1771    }
1772  }
1773});
1774
1775Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
1776  initialize: function($super, container, url, options) {
1777    $super(options);
1778    this.onComplete = this.options.onComplete;
1779
1780    this.frequency = (this.options.frequency || 2);
1781    this.decay = (this.options.decay || 1);
1782
1783    this.updater = { };
1784    this.container = container;
1785    this.url = url;
1786
1787    this.start();
1788  },
1789
1790  start: function() {
1791    this.options.onComplete = this.updateComplete.bind(this);
1792    this.onTimerEvent();
1793  },
1794
1795  stop: function() {
1796    this.updater.options.onComplete = undefined;
1797    clearTimeout(this.timer);
1798    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
1799  },
1800
1801  updateComplete: function(response) {
1802    if (this.options.decay) {
1803      this.decay = (response.responseText == this.lastText ?
1804        this.decay * this.options.decay : 1);
1805
1806      this.lastText = response.responseText;
1807    }
1808    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
1809  },
1810
1811  onTimerEvent: function() {
1812    this.updater = new Ajax.Updater(this.container, this.url, this.options);
1813  }
1814});
1815
1816
1817function $(element) {
1818  if (arguments.length > 1) {
1819    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
1820      elements.push($(arguments[i]));
1821    return elements;
1822  }
1823  if (Object.isString(element))
1824    element = document.getElementById(element);
1825  return Element.extend(element);
1826}
1827
1828if (Prototype.BrowserFeatures.XPath) {
1829  document._getElementsByXPath = function(expression, parentElement) {
1830    var results = [];
1831    var query = document.evaluate(expression, $(parentElement) || document,
1832      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
1833    for (var i = 0, length = query.snapshotLength; i < length; i++)
1834      results.push(Element.extend(query.snapshotItem(i)));
1835    return results;
1836  };
1837}
1838
1839/*--------------------------------------------------------------------------*/
1840
1841if (!Node) var Node = { };
1842
1843if (!Node.ELEMENT_NODE) {
1844  Object.extend(Node, {
1845    ELEMENT_NODE: 1,
1846    ATTRIBUTE_NODE: 2,
1847    TEXT_NODE: 3,
1848    CDATA_SECTION_NODE: 4,
1849    ENTITY_REFERENCE_NODE: 5,
1850    ENTITY_NODE: 6,
1851    PROCESSING_INSTRUCTION_NODE: 7,
1852    COMMENT_NODE: 8,
1853    DOCUMENT_NODE: 9,
1854    DOCUMENT_TYPE_NODE: 10,
1855    DOCUMENT_FRAGMENT_NODE: 11,
1856    NOTATION_NODE: 12
1857  });
1858}
1859
1860
1861
1862(function(global) {
1863  function shouldUseCache(tagName, attributes) {
1864    if (tagName === 'select') return false;
1865    if ('type' in attributes) return false;
1866    return true;
1867  }
1868
1869  var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = (function(){
1870    try {
1871      var el = document.createElement('<input name="x">');
1872      return el.tagName.toLowerCase() === 'input' && el.name === 'x';
1873    }
1874    catch(err) {
1875      return false;
1876    }
1877  })();
1878
1879  var element = global.Element;
1880
1881  global.Element = function(tagName, attributes) {
1882    attributes = attributes || { };
1883    tagName = tagName.toLowerCase();
1884    var cache = Element.cache;
1885
1886    if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) {
1887      tagName = '<' + tagName + ' name="' + attributes.name + '">';
1888      delete attributes.name;
1889      return Element.writeAttribute(document.createElement(tagName), attributes);
1890    }
1891
1892    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
1893
1894    var node = shouldUseCache(tagName, attributes) ?
1895     cache[tagName].cloneNode(false) : document.createElement(tagName);
1896
1897    return Element.writeAttribute(node, attributes);
1898  };
1899
1900  Object.extend(global.Element, element || { });
1901  if (element) global.Element.prototype = element.prototype;
1902
1903})(this);
1904
1905Element.idCounter = 1;
1906Element.cache = { };
1907
1908Element._purgeElement = function(element) {
1909  var uid = element._prototypeUID;
1910  if (uid) {
1911    Element.stopObserving(element);
1912    element._prototypeUID = void 0;
1913    delete Element.Storage[uid];
1914  }
1915}
1916
1917Element.Methods = {
1918  visible: function(element) {
1919    return $(element).style.display != 'none';
1920  },
1921
1922  toggle: function(element) {
1923    element = $(element);
1924    Element[Element.visible(element) ? 'hide' : 'show'](element);
1925    return element;
1926  },
1927
1928  hide: function(element) {
1929    element = $(element);
1930    element.style.display = 'none';
1931    return element;
1932  },
1933
1934  show: function(element) {
1935    element = $(element);
1936    element.style.display = '';
1937    return element;
1938  },
1939
1940  remove: function(element) {
1941    element = $(element);
1942    element.parentNode.removeChild(element);
1943    return element;
1944  },
1945
1946  update: (function(){
1947
1948    var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
1949      var el = document.createElement("select"),
1950          isBuggy = true;
1951      el.innerHTML = "<option value=\"test\">test</option>";
1952      if (el.options && el.options[0]) {
1953        isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION";
1954      }
1955      el = null;
1956      return isBuggy;
1957    })();
1958
1959    var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){
1960      try {
1961        var el = document.createElement("table");
1962        if (el && el.tBodies) {
1963          el.innerHTML = "<tbody><tr><td>test</td></tr></tbody>";
1964          var isBuggy = typeof el.tBodies[0] == "undefined";
1965          el = null;
1966          return isBuggy;
1967        }
1968      } catch (e) {
1969        return true;
1970      }
1971    })();
1972
1973    var LINK_ELEMENT_INNERHTML_BUGGY = (function() {
1974      try {
1975        var el = document.createElement('div');
1976        el.innerHTML = "<link>";
1977        var isBuggy = (el.childNodes.length === 0);
1978        el = null;
1979        return isBuggy;
1980      } catch(e) {
1981        return true;
1982      }
1983    })();
1984
1985    var ANY_INNERHTML_BUGGY = SELECT_ELEMENT_INNERHTML_BUGGY ||
1986     TABLE_ELEMENT_INNERHTML_BUGGY || LINK_ELEMENT_INNERHTML_BUGGY;
1987
1988    var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () {
1989      var s = document.createElement("script"),
1990          isBuggy = false;
1991      try {
1992        s.appendChild(document.createTextNode(""));
1993        isBuggy = !s.firstChild ||
1994          s.firstChild && s.firstChild.nodeType !== 3;
1995      } catch (e) {
1996        isBuggy = true;
1997      }
1998      s = null;
1999      return isBuggy;
2000    })();
2001
2002
2003    function update(element, content) {
2004      element = $(element);
2005      var purgeElement = Element._purgeElement;
2006
2007      var descendants = element.getElementsByTagName('*'),
2008       i = descendants.length;
2009      while (i--) purgeElement(descendants[i]);
2010
2011      if (content && content.toElement)
2012        content = content.toElement();
2013
2014      if (Object.isElement(content))
2015        return element.update().insert(content);
2016
2017      content = Object.toHTML(content);
2018
2019      var tagName = element.tagName.toUpperCase();
2020
2021      if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) {
2022        element.text = content;
2023        return element;
2024      }
2025
2026      if (ANY_INNERHTML_BUGGY) {
2027        if (tagName in Element._insertionTranslations.tags) {
2028          while (element.firstChild) {
2029            element.removeChild(element.firstChild);
2030          }
2031          Element._getContentFromAnonymousElement(tagName, content.stripScripts())
2032            .each(function(node) {
2033              element.appendChild(node)
2034            });
2035        } else if (LINK_ELEMENT_INNERHTML_BUGGY && Object.isString(content) && content.indexOf('<link') > -1) {
2036          while (element.firstChild) {
2037            element.removeChild(element.firstChild);
2038          }
2039          var nodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts(), true);
2040          nodes.each(function(node) { element.appendChild(node) });
2041        }
2042        else {
2043          element.innerHTML = content.stripScripts();
2044        }
2045      }
2046      else {
2047        element.innerHTML = content.stripScripts();
2048      }
2049
2050      content.evalScripts.bind(content).defer();
2051      return element;
2052    }
2053
2054    return update;
2055  })(),
2056
2057  replace: function(element, content) {
2058    element = $(element);
2059    if (content && content.toElement) content = content.toElement();
2060    else if (!Object.isElement(content)) {
2061      content = Object.toHTML(content);
2062      var range = element.ownerDocument.createRange();
2063      range.selectNode(element);
2064      content.evalScripts.bind(content).defer();
2065      content = range.createContextualFragment(content.stripScripts());
2066    }
2067    element.parentNode.replaceChild(content, element);
2068    return element;
2069  },
2070
2071  insert: function(element, insertions) {
2072    element = $(element);
2073
2074    if (Object.isString(insertions) || Object.isNumber(insertions) ||
2075        Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
2076          insertions = {bottom:insertions};
2077
2078    var content, insert, tagName, childNodes;
2079
2080    for (var position in insertions) {
2081      content  = insertions[position];
2082      position = position.toLowerCase();
2083      insert = Element._insertionTranslations[position];
2084
2085      if (content && content.toElement) content = content.toElement();
2086      if (Object.isElement(content)) {
2087        insert(element, content);
2088        continue;
2089      }
2090
2091      content = Object.toHTML(content);
2092
2093      tagName = ((position == 'before' || position == 'after')
2094        ? element.parentNode : element).tagName.toUpperCase();
2095
2096      childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
2097
2098      if (position == 'top' || position == 'after') childNodes.reverse();
2099      childNodes.each(insert.curry(element));
2100
2101      content.evalScripts.bind(content).defer();
2102    }
2103
2104    return element;
2105  },
2106
2107  wrap: function(element, wrapper, attributes) {
2108    element = $(element);
2109    if (Object.isElement(wrapper))
2110      $(wrapper).writeAttribute(attributes || { });
2111    else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
2112    else wrapper = new Element('div', wrapper);
2113    if (element.parentNode)
2114      element.parentNode.replaceChild(wrapper, element);
2115    wrapper.appendChild(element);
2116    return wrapper;
2117  },
2118
2119  inspect: function(element) {
2120    element = $(element);
2121    var result = '<' + element.tagName.toLowerCase();
2122    $H({'id': 'id', 'className': 'class'}).each(function(pair) {
2123      var property = pair.first(),
2124          attribute = pair.last(),
2125          value = (element[property] || '').toString();
2126      if (value) result += ' ' + attribute + '=' + value.inspect(true);
2127    });
2128    return result + '>';
2129  },
2130
2131  recursivelyCollect: function(element, property, maximumLength) {
2132    element = $(element);
2133    maximumLength = maximumLength || -1;
2134    var elements = [];
2135
2136    while (element = element[property]) {
2137      if (element.nodeType == 1)
2138        elements.push(Element.extend(element));
2139      if (elements.length == maximumLength)
2140        break;
2141    }
2142
2143    return elements;
2144  },
2145
2146  ancestors: function(element) {
2147    return Element.recursivelyCollect(element, 'parentNode');
2148  },
2149
2150  descendants: function(element) {
2151    return Element.select(element, "*");
2152  },
2153
2154  firstDescendant: function(element) {
2155    element = $(element).firstChild;
2156    while (element && element.nodeType != 1) element = element.nextSibling;
2157    return $(element);
2158  },
2159
2160  immediateDescendants: function(element) {
2161    var results = [], child = $(element).firstChild;
2162    while (child) {
2163      if (child.nodeType === 1) {
2164        results.push(Element.extend(child));
2165      }
2166      child = child.nextSibling;
2167    }
2168    return results;
2169  },
2170
2171  previousSiblings: function(element, maximumLength) {
2172    return Element.recursivelyCollect(element, 'previousSibling');
2173  },
2174
2175  nextSiblings: function(element) {
2176    return Element.recursivelyCollect(element, 'nextSibling');
2177  },
2178
2179  siblings: function(element) {
2180    element = $(element);
2181    return Element.previousSiblings(element).reverse()
2182      .concat(Element.nextSiblings(element));
2183  },
2184
2185  match: function(element, selector) {
2186    element = $(element);
2187    if (Object.isString(selector))
2188      return Prototype.Selector.match(element, selector);
2189    return selector.match(element);
2190  },
2191
2192  up: function(element, expression, index) {
2193    element = $(element);
2194    if (arguments.length == 1) return $(element.parentNode);
2195    var ancestors = Element.ancestors(element);
2196    return Object.isNumber(expression) ? ancestors[expression] :
2197      Prototype.Selector.find(ancestors, expression, index);
2198  },
2199
2200  down: function(element, expression, index) {
2201    element = $(element);
2202    if (arguments.length == 1) return Element.firstDescendant(element);
2203    return Object.isNumber(expression) ? Element.descendants(element)[expression] :
2204      Element.select(element, expression)[index || 0];
2205  },
2206
2207  previous: function(element, expression, index) {
2208    element = $(element);
2209    if (Object.isNumber(expression)) index = expression, expression = false;
2210    if (!Object.isNumber(index)) index = 0;
2211
2212    if (expression) {
2213      return Prototype.Selector.find(element.previousSiblings(), expression, index);
2214    } else {
2215      return element.recursivelyCollect("previousSibling", index + 1)[index];
2216    }
2217  },
2218
2219  next: function(element, expression, index) {
2220    element = $(element);
2221    if (Object.isNumber(expression)) index = expression, expression = false;
2222    if (!Object.isNumber(index)) index = 0;
2223
2224    if (expression) {
2225      return Prototype.Selector.find(element.nextSiblings(), expression, index);
2226    } else {
2227      var maximumLength = Object.isNumber(index) ? index + 1 : 1;
2228      return element.recursivelyCollect("nextSibling", index + 1)[index];
2229    }
2230  },
2231
2232
2233  select: function(element) {
2234    element = $(element);
2235    var expressions = Array.prototype.slice.call(arguments, 1).join(', ');
2236    return Prototype.Selector.select(expressions, element);
2237  },
2238
2239  adjacent: function(element) {
2240    element = $(element);
2241    var expressions = Array.prototype.slice.call(arguments, 1).join(', ');
2242    return Prototype.Selector.select(expressions, element.parentNode).without(element);
2243  },
2244
2245  identify: function(element) {
2246    element = $(element);
2247    var id = Element.readAttribute(element, 'id');
2248    if (id) return id;
2249    do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id));
2250    Element.writeAttribute(element, 'id', id);
2251    return id;
2252  },
2253
2254  readAttribute: function(element, name) {
2255    element = $(element);
2256    if (Prototype.Browser.IE) {
2257      var t = Element._attributeTranslations.read;
2258      if (t.values[name]) return t.values[name](element, name);
2259      if (t.names[name]) name = t.names[name];
2260      if (name.include(':')) {
2261        return (!element.attributes || !element.attributes[name]) ? null :
2262         element.attributes[name].value;
2263      }
2264    }
2265    return element.getAttribute(name);
2266  },
2267
2268  writeAttribute: function(element, name, value) {
2269    element = $(element);
2270    var attributes = { }, t = Element._attributeTranslations.write;
2271
2272    if (typeof name == 'object') attributes = name;
2273    else attributes[name] = Object.isUndefined(value) ? true : value;
2274
2275    for (var attr in attributes) {
2276      name = t.names[attr] || attr;
2277      value = attributes[attr];
2278      if (t.values[attr]) name = t.values[attr](element, value);
2279      if (value === false || value === null)
2280        element.removeAttribute(name);
2281      else if (value === true)
2282        element.setAttribute(name, name);
2283      else element.setAttribute(name, value);
2284    }
2285    return element;
2286  },
2287
2288  getHeight: function(element) {
2289    return Element.getDimensions(element).height;
2290  },
2291
2292  getWidth: function(element) {
2293    return Element.getDimensions(element).width;
2294  },
2295
2296  classNames: function(element) {
2297    return new Element.ClassNames(element);
2298  },
2299
2300  hasClassName: function(element, className) {
2301    if (!(element = $(element))) return;
2302    var elementClassName = element.className;
2303    return (elementClassName.length > 0 && (elementClassName == className ||
2304      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
2305  },
2306
2307  addClassName: function(element, className) {
2308    if (!(element = $(element))) return;
2309    if (!Element.hasClassName(element, className))
2310      element.className += (element.className ? ' ' : '') + className;
2311    return element;
2312  },
2313
2314  removeClassName: function(element, className) {
2315    if (!(element = $(element))) return;
2316    element.className = element.className.replace(
2317      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
2318    return element;
2319  },
2320
2321  toggleClassName: function(element, className) {
2322    if (!(element = $(element))) return;
2323    return Element[Element.hasClassName(element, className) ?
2324      'removeClassName' : 'addClassName'](element, className);
2325  },
2326
2327  cleanWhitespace: function(element) {
2328    element = $(element);
2329    var node = element.firstChild;
2330    while (node) {
2331      var nextNode = node.nextSibling;
2332      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
2333        element.removeChild(node);
2334      node = nextNode;
2335    }
2336    return element;
2337  },
2338
2339  empty: function(element) {
2340    return $(element).innerHTML.blank();
2341  },
2342
2343  descendantOf: function(element, ancestor) {
2344    element = $(element), ancestor = $(ancestor);
2345
2346    if (element.compareDocumentPosition)
2347      return (element.compareDocumentPosition(ancestor) & 8) === 8;
2348
2349    if (ancestor.contains)
2350      return ancestor.contains(element) && ancestor !== element;
2351
2352    while (element = element.parentNode)
2353      if (element == ancestor) return true;
2354
2355    return false;
2356  },
2357
2358  scrollTo: function(element) {
2359    element = $(element);
2360    var pos = Element.cumulativeOffset(element);
2361    window.scrollTo(pos[0], pos[1]);
2362    return element;
2363  },
2364
2365  getStyle: function(element, style) {
2366    element = $(element);
2367    style = style == 'float' ? 'cssFloat' : style.camelize();
2368    var value = element.style[style];
2369    if (!value || value == 'auto') {
2370      var css = document.defaultView.getComputedStyle(element, null);
2371      value = css ? css[style] : null;
2372    }
2373    if (style == 'opacity') return value ? parseFloat(value) : 1.0;
2374    return value == 'auto' ? null : value;
2375  },
2376
2377  getOpacity: function(element) {
2378    return $(element).getStyle('opacity');
2379  },
2380
2381  setStyle: function(element, styles) {
2382    element = $(element);
2383    var elementStyle = element.style, match;
2384    if (Object.isString(styles)) {
2385      element.style.cssText += ';' + styles;
2386      return styles.include('opacity') ?
2387        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
2388    }
2389    for (var property in styles)
2390      if (property == 'opacity') element.setOpacity(styles[property]);
2391      else
2392        elementStyle[(property == 'float' || property == 'cssFloat') ?
2393          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
2394            property] = styles[property];
2395
2396    return element;
2397  },
2398
2399  setOpacity: function(element, value) {
2400    element = $(element);
2401    element.style.opacity = (value == 1 || value === '') ? '' :
2402      (value < 0.00001) ? 0 : value;
2403    return element;
2404  },
2405
2406  makePositioned: function(element) {
2407    element = $(element);
2408    var pos = Element.getStyle(element, 'position');
2409    if (pos == 'static' || !pos) {
2410      element._madePositioned = true;
2411      element.style.position = 'relative';
2412      if (Prototype.Browser.Opera) {
2413        element.style.top = 0;
2414        element.style.left = 0;
2415      }
2416    }
2417    return element;
2418  },
2419
2420  undoPositioned: function(element) {
2421    element = $(element);
2422    if (element._madePositioned) {
2423      element._madePositioned = undefined;
2424      element.style.position =
2425        element.style.top =
2426        element.style.left =
2427        element.style.bottom =
2428        element.style.right = '';
2429    }
2430    return element;
2431  },
2432
2433  makeClipping: function(element) {
2434    element = $(element);
2435    if (element._overflow) return element;
2436    element._overflow = Element.getStyle(element, 'overflow') || 'auto';
2437    if (element._overflow !== 'hidden')
2438      element.style.overflow = 'hidden';
2439    return element;
2440  },
2441
2442  undoClipping: function(element) {
2443    element = $(element);
2444    if (!element._overflow) return element;
2445    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
2446    element._overflow = null;
2447    return element;
2448  },
2449
2450  clonePosition: function(element, source) {
2451    var options = Object.extend({
2452      setLeft:    true,
2453      setTop:     true,
2454      setWidth:   true,
2455      setHeight:  true,
2456      offsetTop:  0,
2457      offsetLeft: 0
2458    }, arguments[2] || { });
2459
2460    source = $(source);
2461    var p = Element.viewportOffset(source), delta = [0, 0], parent = null;
2462
2463    element = $(element);
2464
2465    if (Element.getStyle(element, 'position') == 'absolute') {
2466      parent = Element.getOffsetParent(element);
2467      delta = Element.viewportOffset(parent);
2468    }
2469
2470    if (parent == document.body) {
2471      delta[0] -= document.body.offsetLeft;
2472      delta[1] -= document.body.offsetTop;
2473    }
2474
2475    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
2476    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
2477    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';
2478    if (options.setHeight) element.style.height = source.offsetHeight + 'px';
2479    return element;
2480  }
2481};
2482
2483Object.extend(Element.Methods, {
2484  getElementsBySelector: Element.Methods.select,
2485
2486  childElements: Element.Methods.immediateDescendants
2487});
2488
2489Element._attributeTranslations = {
2490  write: {
2491    names: {
2492      className: 'class',
2493      htmlFor:   'for'
2494    },
2495    values: { }
2496  }
2497};
2498
2499if (Prototype.Browser.Opera) {
2500  Element.Methods.getStyle = Element.Methods.getStyle.wrap(
2501    function(proceed, element, style) {
2502      switch (style) {
2503        case 'height': case 'width':
2504          if (!Element.visible(element)) return null;
2505
2506          var dim = parseInt(proceed(element, style), 10);
2507
2508          if (dim !== element['offset' + style.capitalize()])
2509            return dim + 'px';
2510
2511          var properties;
2512          if (style === 'height') {
2513            properties = ['border-top-width', 'padding-top',
2514             'padding-bottom', 'border-bottom-width'];
2515          }
2516          else {
2517            properties = ['border-left-width', 'padding-left',
2518             'padding-right', 'border-right-width'];
2519          }
2520          return properties.inject(dim, function(memo, property) {
2521            var val = proceed(element, property);
2522            return val === null ? memo : memo - parseInt(val, 10);
2523          }) + 'px';
2524        default: return proceed(element, style);
2525      }
2526    }
2527  );
2528
2529  Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
2530    function(proceed, element, attribute) {
2531      if (attribute === 'title') return element.title;
2532      return proceed(element, attribute);
2533    }
2534  );
2535}
2536
2537else if (Prototype.Browser.IE) {
2538  Element.Methods.getStyle = function(element, style) {
2539    element = $(element);
2540    style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
2541    var value = element.style[style];
2542    if (!value && element.currentStyle) value = element.currentStyle[style];
2543
2544    if (style == 'opacity') {
2545      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
2546        if (value[1]) return parseFloat(value[1]) / 100;
2547      return 1.0;
2548    }
2549
2550    if (value == 'auto') {
2551      if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
2552        return element['offset' + style.capitalize()] + 'px';
2553      return null;
2554    }
2555    return value;
2556  };
2557
2558  Element.Methods.setOpacity = function(element, value) {
2559    function stripAlpha(filter){
2560      return filter.replace(/alpha\([^\)]*\)/gi,'');
2561    }
2562    element = $(element);
2563    var currentStyle = element.currentStyle;
2564    if ((currentStyle && !currentStyle.hasLayout) ||
2565      (!currentStyle && element.style.zoom == 'normal'))
2566        element.style.zoom = 1;
2567
2568    var filter = element.getStyle('filter'), style = element.style;
2569    if (value == 1 || value === '') {
2570      (filter = stripAlpha(filter)) ?
2571        style.filter = filter : style.removeAttribute('filter');
2572      return element;
2573    } else if (value < 0.00001) value = 0;
2574    style.filter = stripAlpha(filter) +
2575      'alpha(opacity=' + (value * 100) + ')';
2576    return element;
2577  };
2578
2579  Element._attributeTranslations = (function(){
2580
2581    var classProp = 'className',
2582        forProp = 'for',
2583        el = document.createElement('div');
2584
2585    el.setAttribute(classProp, 'x');
2586
2587    if (el.className !== 'x') {
2588      el.setAttribute('class', 'x');
2589      if (el.className === 'x') {
2590        classProp = 'class';
2591      }
2592    }
2593    el = null;
2594
2595    el = document.createElement('label');
2596    el.setAttribute(forProp, 'x');
2597    if (el.htmlFor !== 'x') {
2598      el.setAttribute('htmlFor', 'x');
2599      if (el.htmlFor === 'x') {
2600        forProp = 'htmlFor';
2601      }
2602    }
2603    el = null;
2604
2605    return {
2606      read: {
2607        names: {
2608          'class':      classProp,
2609          'className':  classProp,
2610          'for':        forProp,
2611          'htmlFor':    forProp
2612        },
2613        values: {
2614          _getAttr: function(element, attribute) {
2615            return element.getAttribute(attribute);
2616          },
2617          _getAttr2: function(element, attribute) {
2618            return element.getAttribute(attribute, 2);
2619          },
2620          _getAttrNode: function(element, attribute) {
2621            var node = element.getAttributeNode(attribute);
2622            return node ? node.value : "";
2623          },
2624          _getEv: (function(){
2625
2626            var el = document.createElement('div'), f;
2627            el.onclick = Prototype.emptyFunction;
2628            var value = el.getAttribute('onclick');
2629
2630            if (String(value).indexOf('{') > -1) {
2631              f = function(element, attribute) {
2632                attribute = element.getAttribute(attribute);
2633                if (!attribute) return null;
2634                attribute = attribute.toString();
2635                attribute = attribute.split('{')[1];
2636                attribute = attribute.split('}')[0];
2637                return attribute.strip();
2638              };
2639            }
2640            else if (value === '') {
2641              f = function(element, attribute) {
2642                attribute = element.getAttribute(attribute);
2643                if (!attribute) return null;
2644                return attribute.strip();
2645              };
2646            }
2647            el = null;
2648            return f;
2649          })(),
2650          _flag: function(element, attribute) {
2651            return $(element).hasAttribute(attribute) ? attribute : null;
2652          },
2653          style: function(element) {
2654            return element.style.cssText.toLowerCase();
2655          },
2656          title: function(element) {
2657            return element.title;
2658          }
2659        }
2660      }
2661    }
2662  })();
2663
2664  Element._attributeTranslations.write = {
2665    names: Object.extend({
2666      cellpadding: 'cellPadding',
2667      cellspacing: 'cellSpacing'
2668    }, Element._attributeTranslations.read.names),
2669    values: {
2670      checked: function(element, value) {
2671        element.checked = !!value;
2672      },
2673
2674      style: function(element, value) {
2675        element.style.cssText = value ? value : '';
2676      }
2677    }
2678  };
2679
2680  Element._attributeTranslations.has = {};
2681
2682  $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
2683      'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
2684    Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
2685    Element._attributeTranslations.has[attr.toLowerCase()] = attr;
2686  });
2687
2688  (function(v) {
2689    Object.extend(v, {
2690      href:        v._getAttr2,
2691      src:         v._getAttr2,
2692      type:        v._getAttr,
2693      action:      v._getAttrNode,
2694      disabled:    v._flag,
2695      checked:     v._flag,
2696      readonly:    v._flag,
2697      multiple:    v._flag,
2698      onload:      v._getEv,
2699      onunload:    v._getEv,
2700      onclick:     v._getEv,
2701      ondblclick:  v._getEv,
2702      onmousedown: v._getEv,
2703      onmouseup:   v._getEv,
2704      onmouseover: v._getEv,
2705      onmousemove: v._getEv,
2706      onmouseout:  v._getEv,
2707      onfocus:     v._getEv,
2708      onblur:      v._getEv,
2709      onkeypress:  v._getEv,
2710      onkeydown:   v._getEv,
2711      onkeyup:     v._getEv,
2712      onsubmit:    v._getEv,
2713      onreset:     v._getEv,
2714      onselect:    v._getEv,
2715      onchange:    v._getEv
2716    });
2717  })(Element._attributeTranslations.read.values);
2718
2719  if (Prototype.BrowserFeatures.ElementExtensions) {
2720    (function() {
2721      function _descendants(element) {
2722        var nodes = element.getElementsByTagName('*'), results = [];
2723        for (var i = 0, node; node = nodes[i]; i++)
2724          if (node.tagName !== "!") // Filter out comment nodes.
2725            results.push(node);
2726        return results;
2727      }
2728
2729      Element.Methods.down = function(element, expression, index) {
2730        element = $(element);
2731        if (arguments.length == 1) return element.firstDescendant();
2732        return Object.isNumber(expression) ? _descendants(element)[expression] :
2733          Element.select(element, expression)[index || 0];
2734      }
2735    })();
2736  }
2737
2738}
2739
2740else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
2741  Element.Methods.setOpacity = function(element, value) {
2742    element = $(element);
2743    element.style.opacity = (value == 1) ? 0.999999 :
2744      (value === '') ? '' : (value < 0.00001) ? 0 : value;
2745    return element;
2746  };
2747}
2748
2749else if (Prototype.Browser.WebKit) {
2750  Element.Methods.setOpacity = function(element, value) {
2751    element = $(element);
2752    element.style.opacity = (value == 1 || value === '') ? '' :
2753      (value < 0.00001) ? 0 : value;
2754
2755    if (value == 1)
2756      if (element.tagName.toUpperCase() == 'IMG' && element.width) {
2757        element.width++; element.width--;
2758      } else try {
2759        var n = document.createTextNode(' ');
2760        element.appendChild(n);
2761        element.removeChild(n);
2762      } catch (e) { }
2763
2764    return element;
2765  };
2766}
2767
2768if ('outerHTML' in document.documentElement) {
2769  Element.Methods.replace = function(element, content) {
2770    element = $(element);
2771
2772    if (content && content.toElement) content = content.toElement();
2773    if (Object.isElement(content)) {
2774      element.parentNode.replaceChild(content, element);
2775      return element;
2776    }
2777
2778    content = Object.toHTML(content);
2779    var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
2780
2781    if (Element._insertionTranslations.tags[tagName]) {
2782      var nextSibling = element.next(),
2783          fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
2784      parent.removeChild(element);
2785      if (nextSibling)
2786        fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
2787      else
2788        fragments.each(function(node) { parent.appendChild(node) });
2789    }
2790    else element.outerHTML = content.stripScripts();
2791
2792    content.evalScripts.bind(content).defer();
2793    return element;
2794  };
2795}
2796
2797Element._returnOffset = function(l, t) {
2798  var result = [l, t];
2799  result.left = l;
2800  result.top = t;
2801  return result;
2802};
2803
2804Element._getContentFromAnonymousElement = function(tagName, html, force) {
2805  var div = new Element('div'),
2806      t = Element._insertionTranslations.tags[tagName];
2807
2808  var workaround = false;
2809  if (t) workaround = true;
2810  else if (force) {
2811    workaround = true;
2812    t = ['', '', 0];
2813  }
2814
2815  if (workaround) {
2816    div.innerHTML = '&nbsp;' + t[0] + html + t[1];
2817    div.removeChild(div.firstChild);
2818    for (var i = t[2]; i--; ) {
2819      div = div.firstChild;
2820    }
2821  }
2822  else {
2823    div.innerHTML = html;
2824  }
2825  return $A(div.childNodes);
2826};
2827
2828Element._insertionTranslations = {
2829  before: function(element, node) {
2830    element.parentNode.insertBefore(node, element);
2831  },
2832  top: function(element, node) {
2833    element.insertBefore(node, element.firstChild);
2834  },
2835  bottom: function(element, node) {
2836    element.appendChild(node);
2837  },
2838  after: function(element, node) {
2839    element.parentNode.insertBefore(node, element.nextSibling);
2840  },
2841  tags: {
2842    TABLE:  ['<table>',                '</table>',                   1],
2843    TBODY:  ['<table><tbody>',         '</tbody></table>',           2],
2844    TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],
2845    TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
2846    SELECT: ['<select>',               '</select>',                  1]
2847  }
2848};
2849
2850(function() {
2851  var tags = Element._insertionTranslations.tags;
2852  Object.extend(tags, {
2853    THEAD: tags.TBODY,
2854    TFOOT: tags.TBODY,
2855    TH:    tags.TD
2856  });
2857})();
2858
2859Element.Methods.Simulated = {
2860  hasAttribute: function(element, attribute) {
2861    attribute = Element._attributeTranslations.has[attribute] || attribute;
2862    var node = $(element).getAttributeNode(attribute);
2863    return !!(node && node.specified);
2864  }
2865};
2866
2867Element.Methods.ByTag = { };
2868
2869Object.extend(Element, Element.Methods);
2870
2871(function(div) {
2872
2873  if (!Prototype.BrowserFeatures.ElementExtensions && div['__proto__']) {
2874    window.HTMLElement = { };
2875    window.HTMLElement.prototype = div['__proto__'];
2876    Prototype.BrowserFeatures.ElementExtensions = true;
2877  }
2878
2879  div = null;
2880
2881})(document.createElement('div'));
2882
2883Element.extend = (function() {
2884
2885  function checkDeficiency(tagName) {
2886    if (typeof window.Element != 'undefined') {
2887      var proto = window.Element.prototype;
2888      if (proto) {
2889        var id = '_' + (Math.random()+'').slice(2),
2890            el = document.createElement(tagName);
2891        proto[id] = 'x';
2892        var isBuggy = (el[id] !== 'x');
2893        delete proto[id];
2894        el = null;
2895        return isBuggy;
2896      }
2897    }
2898    return false;
2899  }
2900
2901  function extendElementWith(element, methods) {
2902    for (var property in methods) {
2903      var value = methods[property];
2904      if (Object.isFunction(value) && !(property in element))
2905        element[property] = value.methodize();
2906    }
2907  }
2908
2909  var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency('object');
2910
2911  if (Prototype.BrowserFeatures.SpecificElementExtensions) {
2912    if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) {
2913      return function(element) {
2914        if (element && typeof element._extendedByPrototype == 'undefined') {
2915          var t = element.tagName;
2916          if (t && (/^(?:object|applet|embed)$/i.test(t))) {
2917            extendElementWith(element, Element.Methods);
2918            extendElementWith(element, Element.Methods.Simulated);
2919            extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
2920          }
2921        }
2922        return element;
2923      }
2924    }
2925    return Prototype.K;
2926  }
2927
2928  var Methods = { }, ByTag = Element.Methods.ByTag;
2929
2930  var extend = Object.extend(function(element) {
2931    if (!element || typeof element._extendedByPrototype != 'undefined' ||
2932        element.nodeType != 1 || element == window) return element;
2933
2934    var methods = Object.clone(Methods),
2935        tagName = element.tagName.toUpperCase();
2936
2937    if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
2938
2939    extendElementWith(element, methods);
2940
2941    element._extendedByPrototype = Prototype.emptyFunction;
2942    return element;
2943
2944  }, {
2945    refresh: function() {
2946      if (!Prototype.BrowserFeatures.ElementExtensions) {
2947        Object.extend(Methods, Element.Methods);
2948        Object.extend(Methods, Element.Methods.Simulated);
2949      }
2950    }
2951  });
2952
2953  extend.refresh();
2954  return extend;
2955})();
2956
2957if (document.documentElement.hasAttribute) {
2958  Element.hasAttribute = function(element, attribute) {
2959    return element.hasAttribute(attribute);
2960  };
2961}
2962else {
2963  Element.hasAttribute = Element.Methods.Simulated.hasAttribute;
2964}
2965
2966Element.addMethods = function(methods) {
2967  var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
2968
2969  if (!methods) {
2970    Object.extend(Form, Form.Methods);
2971    Object.extend(Form.Element, Form.Element.Methods);
2972    Object.extend(Element.Methods.ByTag, {
2973      "FORM":     Object.clone(Form.Methods),
2974      "INPUT":    Object.clone(Form.Element.Methods),
2975      "SELECT":   Object.clone(Form.Element.Methods),
2976      "TEXTAREA": Object.clone(Form.Element.Methods),
2977      "BUTTON":   Object.clone(Form.Element.Methods)
2978    });
2979  }
2980
2981  if (arguments.length == 2) {
2982    var tagName = methods;
2983    methods = arguments[1];
2984  }
2985
2986  if (!tagName) Object.extend(Element.Methods, methods || { });
2987  else {
2988    if (Object.isArray(tagName)) tagName.each(extend);
2989    else extend(tagName);
2990  }
2991
2992  function extend(tagName) {
2993    tagName = tagName.toUpperCase();
2994    if (!Element.Methods.ByTag[tagName])
2995      Element.Methods.ByTag[tagName] = { };
2996    Object.extend(Element.Methods.ByTag[tagName], methods);
2997  }
2998
2999  function copy(methods, destination, onlyIfAbsent) {
3000    onlyIfAbsent = onlyIfAbsent || false;
3001    for (var property in methods) {
3002      var value = methods[property];
3003      if (!Object.isFunction(value)) continue;
3004      if (!onlyIfAbsent || !(property in destination))
3005        destination[property] = value.methodize();
3006    }
3007  }
3008
3009  function findDOMClass(tagName) {
3010    var klass;
3011    var trans = {
3012      "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
3013      "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
3014      "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
3015      "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
3016      "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
3017      "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
3018      "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
3019      "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
3020      "FrameSet", "IFRAME": "IFrame"
3021    };
3022    if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
3023    if (window[klass]) return window[klass];
3024    klass = 'HTML' + tagName + 'Element';
3025    if (window[klass]) return window[klass];
3026    klass = 'HTML' + tagName.capitalize() + 'Element';
3027    if (window[klass]) return window[klass];
3028
3029    var element = document.createElement(tagName),
3030        proto = element['__proto__'] || element.constructor.prototype;
3031
3032    element = null;
3033    return proto;
3034  }
3035
3036  var elementPrototype = window.HTMLElement ? HTMLElement.prototype :
3037   Element.prototype;
3038
3039  if (F.ElementExtensions) {
3040    copy(Element.Methods, elementPrototype);
3041    copy(Element.Methods.Simulated, elementPrototype, true);
3042  }
3043
3044  if (F.SpecificElementExtensions) {
3045    for (var tag in Element.Methods.ByTag) {
3046      var klass = findDOMClass(tag);
3047      if (Object.isUndefined(klass)) continue;
3048      copy(T[tag], klass.prototype);
3049    }
3050  }
3051
3052  Object.extend(Element, Element.Methods);
3053  delete Element.ByTag;
3054
3055  if (Element.extend.refresh) Element.extend.refresh();
3056  Element.cache = { };
3057};
3058
3059
3060document.viewport = {
3061
3062  getDimensions: function() {
3063    return { width: this.getWidth(), height: this.getHeight() };
3064  },
3065
3066  getScrollOffsets: function() {
3067    return Element._returnOffset(
3068      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
3069      window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop);
3070  }
3071};
3072
3073(function(viewport) {
3074  var B = Prototype.Browser, doc = document, element, property = {};
3075
3076  function getRootElement() {
3077    if (B.WebKit && !doc.evaluate)
3078      return document;
3079
3080    if (B.Opera && window.parseFloat(window.opera.version()) < 9.5)
3081      return document.body;
3082
3083    return document.documentElement;
3084  }
3085
3086  function define(D) {
3087    if (!element) element = getRootElement();
3088
3089    property[D] = 'client' + D;
3090
3091    viewport['get' + D] = function() { return element[property[D]] };
3092    return viewport['get' + D]();
3093  }
3094
3095  viewport.getWidth  = define.curry('Width');
3096
3097  viewport.getHeight = define.curry('Height');
3098})(document.viewport);
3099
3100
3101Element.Storage = {
3102  UID: 1
3103};
3104
3105Element.addMethods({
3106  getStorage: function(element) {
3107    if (!(element = $(element))) return;
3108
3109    var uid;
3110    if (element === window) {
3111      uid = 0;
3112    } else {
3113      if (typeof element._prototypeUID === "undefined")
3114        element._prototypeUID = Element.Storage.UID++;
3115      uid = element._prototypeUID;
3116    }
3117
3118    if (!Element.Storage[uid])
3119      Element.Storage[uid] = $H();
3120
3121    return Element.Storage[uid];
3122  },
3123
3124  store: function(element, key, value) {
3125    if (!(element = $(element))) return;
3126
3127    if (arguments.length === 2) {
3128      Element.getStorage(element).update(key);
3129    } else {
3130      Element.getStorage(element).set(key, value);
3131    }
3132
3133    return element;
3134  },
3135
3136  retrieve: function(element, key, defaultValue) {
3137    if (!(element = $(element))) return;
3138    var hash = Element.getStorage(element), value = hash.get(key);
3139
3140    if (Object.isUndefined(value)) {
3141      hash.set(key, defaultValue);
3142      value = defaultValue;
3143    }
3144
3145    return value;
3146  },
3147
3148  clone: function(element, deep) {
3149    if (!(element = $(element))) return;
3150    var clone = element.cloneNode(deep);
3151    clone._prototypeUID = void 0;
3152    if (deep) {
3153      var descendants = Element.select(clone, '*'),
3154          i = descendants.length;
3155      while (i--) {
3156        descendants[i]._prototypeUID = void 0;
3157      }
3158    }
3159    return Element.extend(clone);
3160  },
3161
3162  purge: function(element) {
3163    if (!(element = $(element))) return;
3164    var purgeElement = Element._purgeElement;
3165
3166    purgeElement(element);
3167
3168    var descendants = element.getElementsByTagName('*'),
3169     i = descendants.length;
3170
3171    while (i--) purgeElement(descendants[i]);
3172
3173    return null;
3174  }
3175});
3176
3177(function() {
3178
3179  function toDecimal(pctString) {
3180    var match = pctString.match(/^(\d+)%?$/i);
3181    if (!match) return null;
3182    return (Number(match[1]) / 100);
3183  }
3184
3185  function getPixelValue(value, property, context) {
3186    var element = null;
3187    if (Object.isElement(value)) {
3188      element = value;
3189      value = element.getStyle(property);
3190    }
3191
3192    if (value === null) {
3193      return null;
3194    }
3195
3196    if ((/^(?:-)?\d+(\.\d+)?(px)?$/i).test(value)) {
3197      return window.parseFloat(value);
3198    }
3199
3200    var isPercentage = value.include('%'), isViewport = (context === document.viewport);
3201
3202    if (/\d/.test(value) && element && element.runtimeStyle && !(isPercentage && isViewport)) {
3203      var style = element.style.left, rStyle = element.runtimeStyle.left;
3204      element.runtimeStyle.left = element.currentStyle.left;
3205      element.style.left = value || 0;
3206      value = element.style.pixelLeft;
3207      element.style.left = style;
3208      element.runtimeStyle.left = rStyle;
3209
3210      return value;
3211    }
3212
3213    if (element && isPercentage) {
3214      context = context || element.parentNode;
3215      var decimal = toDecimal(value);
3216      var whole = null;
3217      var position = element.getStyle('position');
3218
3219      var isHorizontal = property.include('left') || property.include('right') ||
3220       property.include('width');
3221
3222      var isVertical =  property.include('top') || property.include('bottom') ||
3223        property.include('height');
3224
3225      if (context === document.viewport) {
3226        if (isHorizontal) {
3227          whole = document.viewport.getWidth();
3228        } else if (isVertical) {
3229          whole = document.viewport.getHeight();
3230        }
3231      } else {
3232        if (isHorizontal) {
3233          whole = $(context).measure('width');
3234        } else if (isVertical) {
3235          whole = $(context).measure('height');
3236        }
3237      }
3238
3239      return (whole === null) ? 0 : whole * decimal;
3240    }
3241
3242    return 0;
3243  }
3244
3245  function toCSSPixels(number) {
3246    if (Object.isString(number) && number.endsWith('px')) {
3247      return number;
3248    }
3249    return number + 'px';
3250  }
3251
3252  function isDisplayed(element) {
3253    var originalElement = element;
3254    while (element && element.parentNode) {
3255      var display = element.getStyle('display');
3256      if (display === 'none') {
3257        return false;
3258      }
3259      element = $(element.parentNode);
3260    }
3261    return true;
3262  }
3263
3264  var hasLayout = Prototype.K;
3265  if ('currentStyle' in document.documentElement) {
3266    hasLayout = function(element) {
3267      if (!element.currentStyle.hasLayout) {
3268        element.style.zoom = 1;
3269      }
3270      return element;
3271    };
3272  }
3273
3274  function cssNameFor(key) {
3275    if (key.include('border')) key = key + '-width';
3276    return key.camelize();
3277  }
3278
3279  Element.Layout = Class.create(Hash, {
3280    initialize: function($super, element, preCompute) {
3281      $super();
3282      this.element = $(element);
3283
3284      Element.Layout.PROPERTIES.each( function(property) {
3285        this._set(property, null);
3286      }, this);
3287
3288      if (preCompute) {
3289        this._preComputing = true;
3290        this._begin();
3291        Element.Layout.PROPERTIES.each( this._compute, this );
3292        this._end();
3293        this._preComputing = false;
3294      }
3295    },
3296
3297    _set: function(property, value) {
3298      return Hash.prototype.set.call(this, property, value);
3299    },
3300
3301    set: function(property, value) {
3302      throw "Properties of Element.Layout are read-only.";
3303    },
3304
3305    get: function($super, property) {
3306      var value = $super(property);
3307      return value === null ? this._compute(property) : value;
3308    },
3309
3310    _begin: function() {
3311      if (this._prepared) return;
3312
3313      var element = this.element;
3314      if (isDisplayed(element)) {
3315        this._prepared = true;
3316        return;
3317      }
3318
3319      var originalStyles = {
3320        position:   element.style.position   || '',
3321        width:      element.style.width      || '',
3322        visibility: element.style.visibility || '',
3323        display:    element.style.display    || ''
3324      };
3325
3326      element.store('prototype_original_styles', originalStyles);
3327
3328      var position = element.getStyle('position'),
3329       width = element.getStyle('width');
3330
3331      if (width === "0px" || width === null) {
3332        element.style.display = 'block';
3333        width = element.getStyle('width');
3334      }
3335
3336      var context = (position === 'fixed') ? document.viewport :
3337       element.parentNode;
3338
3339      element.setStyle({
3340        position:   'absolute',
3341        visibility: 'hidden',
3342        display:    'block'
3343      });
3344
3345      var positionedWidth = element.getStyle('width');
3346
3347      var newWidth;
3348      if (width && (positionedWidth === width)) {
3349        newWidth = getPixelValue(element, 'width', context);
3350      } else if (position === 'absolute' || position === 'fixed') {
3351        newWidth = getPixelValue(element, 'width', context);
3352      } else {
3353        var parent = element.parentNode, pLayout = $(parent).getLayout();
3354
3355        newWidth = pLayout.get('width') -
3356         this.get('margin-left') -
3357         this.get('border-left') -
3358         this.get('padding-left') -
3359         this.get('padding-right') -
3360         this.get('border-right') -
3361         this.get('margin-right');
3362      }
3363
3364      element.setStyle({ width: newWidth + 'px' });
3365
3366      this._prepared = true;
3367    },
3368
3369    _end: function() {
3370      var element = this.element;
3371      var originalStyles = element.retrieve('prototype_original_styles');
3372      element.store('prototype_original_styles', null);
3373      element.setStyle(originalStyles);
3374      this._prepared = false;
3375    },
3376
3377    _compute: function(property) {
3378      var COMPUTATIONS = Element.Layout.COMPUTATIONS;
3379      if (!(property in COMPUTATIONS)) {
3380        throw "Property not found.";
3381      }
3382
3383      return this._set(property, COMPUTATIONS[property].call(this, this.element));
3384    },
3385
3386    toObject: function() {
3387      var args = $A(arguments);
3388      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
3389       args.join(' ').split(' ');
3390      var obj = {};
3391      keys.each( function(key) {
3392        if (!Element.Layout.PROPERTIES.include(key)) return;
3393        var value = this.get(key);
3394        if (value != null) obj[key] = value;
3395      }, this);
3396      return obj;
3397    },
3398
3399    toHash: function() {
3400      var obj = this.toObject.apply(this, arguments);
3401      return new Hash(obj);
3402    },
3403
3404    toCSS: function() {
3405      var args = $A(arguments);
3406      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
3407       args.join(' ').split(' ');
3408      var css = {};
3409
3410      keys.each( function(key) {
3411        if (!Element.Layout.PROPERTIES.include(key)) return;
3412        if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return;
3413
3414        var value = this.get(key);
3415        if (value != null) css[cssNameFor(key)] = value + 'px';
3416      }, this);
3417      return css;
3418    },
3419
3420    inspect: function() {
3421      return "#<Element.Layout>";
3422    }
3423  });
3424
3425  Object.extend(Element.Layout, {
3426    PROPERTIES: $w('height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height'),
3427
3428    COMPOSITE_PROPERTIES: $w('padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height'),
3429
3430    COMPUTATIONS: {
3431      'height': function(element) {
3432        if (!this._preComputing) this._begin();
3433
3434        var bHeight = this.get('border-box-height');
3435        if (bHeight <= 0) {
3436          if (!this._preComputing) this._end();
3437          return 0;
3438        }
3439
3440        var bTop = this.get('border-top'),
3441         bBottom = this.get('border-bottom');
3442
3443        var pTop = this.get('padding-top'),
3444         pBottom = this.get('padding-bottom');
3445
3446        if (!this._preComputing) this._end();
3447
3448        return bHeight - bTop - bBottom - pTop - pBottom;
3449      },
3450
3451      'width': function(element) {
3452        if (!this._preComputing) this._begin();
3453
3454        var bWidth = this.get('border-box-width');
3455        if (bWidth <= 0) {
3456          if (!this._preComputing) this._end();
3457          return 0;
3458        }
3459
3460        var bLeft = this.get('border-left'),
3461         bRight = this.get('border-right');
3462
3463        var pLeft = this.get('padding-left'),
3464         pRight = this.get('padding-right');
3465
3466        if (!this._preComputing) this._end();
3467
3468        return bWidth - bLeft - bRight - pLeft - pRight;
3469      },
3470
3471      'padding-box-height': function(element) {
3472        var height = this.get('height'),
3473         pTop = this.get('padding-top'),
3474         pBottom = this.get('padding-bottom');
3475
3476        return height + pTop + pBottom;
3477      },
3478
3479      'padding-box-width': function(element) {
3480        var width = this.get('width'),
3481         pLeft = this.get('padding-left'),
3482         pRight = this.get('padding-right');
3483
3484        return width + pLeft + pRight;
3485      },
3486
3487      'border-box-height': function(element) {
3488        if (!this._preComputing) this._begin();
3489        var height = element.offsetHeight;
3490        if (!this._preComputing) this._end();
3491        return height;
3492      },
3493
3494      'border-box-width': function(element) {
3495        if (!this._preComputing) this._begin();
3496        var width = element.offsetWidth;
3497        if (!this._preComputing) this._end();
3498        return width;
3499      },
3500
3501      'margin-box-height': function(element) {
3502        var bHeight = this.get('border-box-height'),
3503         mTop = this.get('margin-top'),
3504         mBottom = this.get('margin-bottom');
3505
3506        if (bHeight <= 0) return 0;
3507
3508        return bHeight + mTop + mBottom;
3509      },
3510
3511      'margin-box-width': function(element) {
3512        var bWidth = this.get('border-box-width'),
3513         mLeft = this.get('margin-left'),
3514         mRight = this.get('margin-right');
3515
3516        if (bWidth <= 0) return 0;
3517
3518        return bWidth + mLeft + mRight;
3519      },
3520
3521      'top': function(element) {
3522        var offset = element.positionedOffset();
3523        return offset.top;
3524      },
3525
3526      'bottom': function(element) {
3527        var offset = element.positionedOffset(),
3528         parent = element.getOffsetParent(),
3529         pHeight = parent.measure('height');
3530
3531        var mHeight = this.get('border-box-height');
3532
3533        return pHeight - mHeight - offset.top;
3534      },
3535
3536      'left': function(element) {
3537        var offset = element.positionedOffset();
3538        return offset.left;
3539      },
3540
3541      'right': function(element) {
3542        var offset = element.positionedOffset(),
3543         parent = element.getOffsetParent(),
3544         pWidth = parent.measure('width');
3545
3546        var mWidth = this.get('border-box-width');
3547
3548        return pWidth - mWidth - offset.left;
3549      },
3550
3551      'padding-top': function(element) {
3552        return getPixelValue(element, 'paddingTop');
3553      },
3554
3555      'padding-bottom': function(element) {
3556        return getPixelValue(element, 'paddingBottom');
3557      },
3558
3559      'padding-left': function(element) {
3560        return getPixelValue(element, 'paddingLeft');
3561      },
3562
3563      'padding-right': function(element) {
3564        return getPixelValue(element, 'paddingRight');
3565      },
3566
3567      'border-top': function(element) {
3568        return getPixelValue(element, 'borderTopWidth');
3569      },
3570
3571      'border-bottom': function(element) {
3572        return getPixelValue(element, 'borderBottomWidth');
3573      },
3574
3575      'border-left': function(element) {
3576        return getPixelValue(element, 'borderLeftWidth');
3577      },
3578
3579      'border-right': function(element) {
3580        return getPixelValue(element, 'borderRightWidth');
3581      },
3582
3583      'margin-top': function(element) {
3584        return getPixelValue(element, 'marginTop');
3585      },
3586
3587      'margin-bottom': function(element) {
3588        return getPixelValue(element, 'marginBottom');
3589      },
3590
3591      'margin-left': function(element) {
3592        return getPixelValue(element, 'marginLeft');
3593      },
3594
3595      'margin-right': function(element) {
3596        return getPixelValue(element, 'marginRight');
3597      }
3598    }
3599  });
3600
3601  if ('getBoundingClientRect' in document.documentElement) {
3602    Object.extend(Element.Layout.COMPUTATIONS, {
3603      'right': function(element) {
3604        var parent = hasLayout(element.getOffsetParent());
3605        var rect = element.getBoundingClientRect(),
3606         pRect = parent.getBoundingClientRect();
3607
3608        return (pRect.right - rect.right).round();
3609      },
3610
3611      'bottom': function(element) {
3612        var parent = hasLayout(element.getOffsetParent());
3613        var rect = element.getBoundingClientRect(),
3614         pRect = parent.getBoundingClientRect();
3615
3616        return (pRect.bottom - rect.bottom).round();
3617      }
3618    });
3619  }
3620
3621  Element.Offset = Class.create({
3622    initialize: function(left, top) {
3623      this.left = left.round();
3624      this.top  = top.round();
3625
3626      this[0] = this.left;
3627      this[1] = this.top;
3628    },
3629
3630    relativeTo: function(offset) {
3631      return new Element.Offset(
3632        this.left - offset.left,
3633        this.top  - offset.top
3634      );
3635    },
3636
3637    inspect: function() {
3638      return "#<Element.Offset left: #{left} top: #{top}>".interpolate(this);
3639    },
3640
3641    toString: function() {
3642      return "[#{left}, #{top}]".interpolate(this);
3643    },
3644
3645    toArray: function() {
3646      return [this.left, this.top];
3647    }
3648  });
3649
3650  function getLayout(element, preCompute) {
3651    return new Element.Layout(element, preCompute);
3652  }
3653
3654  function measure(element, property) {
3655    return $(element).getLayout().get(property);
3656  }
3657
3658  function getDimensions(element) {
3659    element = $(element);
3660    var display = Element.getStyle(element, 'display');
3661
3662    if (display && display !== 'none') {
3663      return { width: element.offsetWidth, height: element.offsetHeight };
3664    }
3665
3666    var style = element.style;
3667    var originalStyles = {
3668      visibility: style.visibility,
3669      position:   style.position,
3670      display:    style.display
3671    };
3672
3673    var newStyles = {
3674      visibility: 'hidden',
3675      display:    'block'
3676    };
3677
3678    if (originalStyles.position !== 'fixed')
3679      newStyles.position = 'absolute';
3680
3681    Element.setStyle(element, newStyles);
3682
3683    var dimensions = {
3684      width:  element.offsetWidth,
3685      height: element.offsetHeight
3686    };
3687
3688    Element.setStyle(element, originalStyles);
3689
3690    return dimensions;
3691  }
3692
3693  function getOffsetParent(element) {
3694    element = $(element);
3695
3696    if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element))
3697      return $(document.body);
3698
3699    var isInline = (Element.getStyle(element, 'display') === 'inline');
3700    if (!isInline && element.offsetParent) return $(element.offsetParent);
3701
3702    while ((element = element.parentNode) && element !== document.body) {
3703      if (Element.getStyle(element, 'position') !== 'static') {
3704        return isHtml(element) ? $(document.body) : $(element);
3705      }
3706    }
3707
3708    return $(document.body);
3709  }
3710
3711
3712  function cumulativeOffset(element) {
3713    element = $(element);
3714    var valueT = 0, valueL = 0;
3715    if (element.parentNode) {
3716      do {
3717        valueT += element.offsetTop  || 0;
3718        valueL += element.offsetLeft || 0;
3719        element = element.offsetParent;
3720      } while (element);
3721    }
3722    return new Element.Offset(valueL, valueT);
3723  }
3724
3725  function positionedOffset(element) {
3726    element = $(element);
3727
3728    var layout = element.getLayout();
3729
3730    var valueT = 0, valueL = 0;
3731    do {
3732      valueT += element.offsetTop  || 0;
3733      valueL += element.offsetLeft || 0;
3734      element = element.offsetParent;
3735      if (element) {
3736        if (isBody(element)) break;
3737        var p = Element.getStyle(element, 'position');
3738        if (p !== 'static') break;
3739      }
3740    } while (element);
3741
3742    valueL -= layout.get('margin-top');
3743    valueT -= layout.get('margin-left');
3744
3745    return new Element.Offset(valueL, valueT);
3746  }
3747
3748  function cumulativeScrollOffset(element) {
3749    var valueT = 0, valueL = 0;
3750    do {
3751      valueT += element.scrollTop  || 0;
3752      valueL += element.scrollLeft || 0;
3753      element = element.parentNode;
3754    } while (element);
3755    return new Element.Offset(valueL, valueT);
3756  }
3757
3758  function viewportOffset(forElement) {
3759    element = $(element);
3760    var valueT = 0, valueL = 0, docBody = document.body;
3761
3762    var element = forElement;
3763    do {
3764      valueT += element.offsetTop  || 0;
3765      valueL += element.offsetLeft || 0;
3766      if (element.offsetParent == docBody &&
3767        Element.getStyle(element, 'position') == 'absolute') break;
3768    } while (element = element.offsetParent);
3769
3770    element = forElement;
3771    do {
3772      if (element != docBody) {
3773        valueT -= element.scrollTop  || 0;
3774        valueL -= element.scrollLeft || 0;
3775      }
3776    } while (element = element.parentNode);
3777    return new Element.Offset(valueL, valueT);
3778  }
3779
3780  function absolutize(element) {
3781    element = $(element);
3782
3783    if (Element.getStyle(element, 'position') === 'absolute') {
3784      return element;
3785    }
3786
3787    var offsetParent = getOffsetParent(element);
3788    var eOffset = element.viewportOffset(),
3789     pOffset = offsetParent.viewportOffset();
3790
3791    var offset = eOffset.relativeTo(pOffset);
3792    var layout = element.getLayout();
3793
3794    element.store('prototype_absolutize_original_styles', {
3795      left:   element.getStyle('left'),
3796      top:    element.getStyle('top'),
3797      width:  element.getStyle('width'),
3798      height: element.getStyle('height')
3799    });
3800
3801    element.setStyle({
3802      position: 'absolute',
3803      top:    offset.top + 'px',
3804      left:   offset.left + 'px',
3805      width:  layout.get('width') + 'px',
3806      height: layout.get('height') + 'px'
3807    });
3808
3809    return element;
3810  }
3811
3812  function relativize(element) {
3813    element = $(element);
3814    if (Element.getStyle(element, 'position') === 'relative') {
3815      return element;
3816    }
3817
3818    var originalStyles =
3819     element.retrieve('prototype_absolutize_original_styles');
3820
3821    if (originalStyles) element.setStyle(originalStyles);
3822    return element;
3823  }
3824
3825  if (Prototype.Browser.IE) {
3826    getOffsetParent = getOffsetParent.wrap(
3827      function(proceed, element) {
3828        element = $(element);
3829
3830        if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element))
3831          return $(document.body);
3832
3833        var position = element.getStyle('position');
3834        if (position !== 'static') return proceed(element);
3835
3836        element.setStyle({ position: 'relative' });
3837        var value = proceed(element);
3838        element.setStyle({ position: position });
3839        return value;
3840      }
3841    );
3842
3843    positionedOffset = positionedOffset.wrap(function(proceed, element) {
3844      element = $(element);
3845      if (!element.parentNode) return new Element.Offset(0, 0);
3846      var position = element.getStyle('position');
3847      if (position !== 'static') return proceed(element);
3848
3849      var offsetParent = element.getOffsetParent();
3850      if (offsetParent && offsetParent.getStyle('position') === 'fixed')
3851        hasLayout(offsetParent);
3852
3853      element.setStyle({ position: 'relative' });
3854      var value = proceed(element);
3855      element.setStyle({ position: position });
3856      return value;
3857    });
3858  } else if (Prototype.Browser.Webkit) {
3859    cumulativeOffset = function(element) {
3860      element = $(element);
3861      var valueT = 0, valueL = 0;
3862      do {
3863        valueT += element.offsetTop  || 0;
3864        valueL += element.offsetLeft || 0;
3865        if (element.offsetParent == document.body)
3866          if (Element.getStyle(element, 'position') == 'absolute') break;
3867
3868        element = element.offsetParent;
3869      } while (element);
3870
3871      return new Element.Offset(valueL, valueT);
3872    };
3873  }
3874
3875
3876  Element.addMethods({
3877    getLayout:              getLayout,
3878    measure:                measure,
3879    getDimensions:          getDimensions,
3880    getOffsetParent:        getOffsetParent,
3881    cumulativeOffset:       cumulativeOffset,
3882    positionedOffset:       positionedOffset,
3883    cumulativeScrollOffset: cumulativeScrollOffset,
3884    viewportOffset:         viewportOffset,
3885    absolutize:             absolutize,
3886    relativize:             relativize
3887  });
3888
3889  function isBody(element) {
3890    return element.nodeName.toUpperCase() === 'BODY';
3891  }
3892
3893  function isHtml(element) {
3894    return element.nodeName.toUpperCase() === 'HTML';
3895  }
3896
3897  function isDocument(element) {
3898    return element.nodeType === Node.DOCUMENT_NODE;
3899  }
3900
3901  function isDetached(element) {
3902    return element !== document.body &&
3903     !Element.descendantOf(element, document.body);
3904  }
3905
3906  if ('getBoundingClientRect' in document.documentElement) {
3907    Element.addMethods({
3908      viewportOffset: function(element) {
3909        element = $(element);
3910        if (isDetached(element)) return new Element.Offset(0, 0);
3911
3912        var rect = element.getBoundingClientRect(),
3913         docEl = document.documentElement;
3914        return new Element.Offset(rect.left - docEl.clientLeft,
3915         rect.top - docEl.clientTop);
3916      }
3917    });
3918  }
3919})();
3920window.$$ = function() {
3921  var expression = $A(arguments).join(', ');
3922  return Prototype.Selector.select(expression, document);
3923};
3924
3925Prototype.Selector = (function() {
3926
3927  function select() {
3928    throw new Error('Method "Prototype.Selector.select" must be defined.');
3929  }
3930
3931  function match() {
3932    throw new Error('Method "Prototype.Selector.match" must be defined.');
3933  }
3934
3935  function find(elements, expression, index) {
3936    index = index || 0;
3937    var match = Prototype.Selector.match, length = elements.length, matchIndex = 0, i;
3938
3939    for (i = 0; i < length; i++) {
3940      if (match(elements[i], expression) && index == matchIndex++) {
3941        return Element.extend(elements[i]);
3942      }
3943    }
3944  }
3945
3946  function extendElements(elements) {
3947    for (var i = 0, length = elements.length; i < length; i++) {
3948      Element.extend(elements[i]);
3949    }
3950    return elements;
3951  }
3952
3953
3954  var K = Prototype.K;
3955
3956  return {
3957    select: select,
3958    match: match,
3959    find: find,
3960    extendElements: (Element.extend === K) ? K : extendElements,
3961    extendElement: Element.extend
3962  };
3963})();
3964Prototype._original_property = window.Sizzle;
3965/*!
3966 * Sizzle CSS Selector Engine - v1.0
3967 *  Copyright 2009, The Dojo Foundation
3968 *  Released under the MIT, BSD, and GPL Licenses.
3969 *  More information: http://sizzlejs.com/
3970 */
3971(function(){
3972
3973var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3974	done = 0,
3975	toString = Object.prototype.toString,
3976	hasDuplicate = false,
3977	baseHasDuplicate = true;
3978
3979[0, 0].sort(function(){
3980	baseHasDuplicate = false;
3981	return 0;
3982});
3983
3984var Sizzle = function(selector, context, results, seed) {
3985	results = results || [];
3986	var origContext = context = context || document;
3987
3988	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3989		return [];
3990	}
3991
3992	if ( !selector || typeof selector !== "string" ) {
3993		return results;
3994	}
3995
3996	var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context),
3997		soFar = selector;
3998
3999	while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
4000		soFar = m[3];
4001
4002		parts.push( m[1] );
4003
4004		if ( m[2] ) {
4005			extra = m[3];
4006			break;
4007		}
4008	}
4009
4010	if ( parts.length > 1 && origPOS.exec( selector ) ) {
4011		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
4012			set = posProcess( parts[0] + parts[1], context );
4013		} else {
4014			set = Expr.relative[ parts[0] ] ?
4015				[ context ] :
4016				Sizzle( parts.shift(), context );
4017
4018			while ( parts.length ) {
4019				selector = parts.shift();
4020
4021				if ( Expr.relative[ selector ] )
4022					selector += parts.shift();
4023
4024				set = posProcess( selector, set );
4025			}
4026		}
4027	} else {
4028		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
4029				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
4030			var ret = Sizzle.find( parts.shift(), context, contextXML );
4031			context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
4032		}
4033
4034		if ( context ) {
4035			var ret = seed ?
4036				{ expr: parts.pop(), set: makeArray(seed) } :
4037				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
4038			set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
4039
4040			if ( parts.length > 0 ) {
4041				checkSet = makeArray(set);
4042			} else {
4043				prune = false;
4044			}
4045
4046			while ( parts.length ) {
4047				var cur = parts.pop(), pop = cur;
4048
4049				if ( !Expr.relative[ cur ] ) {
4050					cur = "";
4051				} else {
4052					pop = parts.pop();
4053				}
4054
4055				if ( pop == null ) {
4056					pop = context;
4057				}
4058
4059				Expr.relative[ cur ]( checkSet, pop, contextXML );
4060			}
4061		} else {
4062			checkSet = parts = [];
4063		}
4064	}
4065
4066	if ( !checkSet ) {
4067		checkSet = set;
4068	}
4069
4070	if ( !checkSet ) {
4071		throw "Syntax error, unrecognized expression: " + (cur || selector);
4072	}
4073
4074	if ( toString.call(checkSet) === "[object Array]" ) {
4075		if ( !prune ) {
4076			results.push.apply( results, checkSet );
4077		} else if ( context && context.nodeType === 1 ) {
4078			for ( var i = 0; checkSet[i] != null; i++ ) {
4079				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
4080					results.push( set[i] );
4081				}
4082			}
4083		} else {
4084			for ( var i = 0; checkSet[i] != null; i++ ) {
4085				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
4086					results.push( set[i] );
4087				}
4088			}
4089		}
4090	} else {
4091		makeArray( checkSet, results );
4092	}
4093
4094	if ( extra ) {
4095		Sizzle( extra, origContext, results, seed );
4096		Sizzle.uniqueSort( results );
4097	}
4098
4099	return results;
4100};
4101
4102Sizzle.uniqueSort = function(results){
4103	if ( sortOrder ) {
4104		hasDuplicate = baseHasDuplicate;
4105		results.sort(sortOrder);
4106
4107		if ( hasDuplicate ) {
4108			for ( var i = 1; i < results.length; i++ ) {
4109				if ( results[i] === results[i-1] ) {
4110					results.splice(i--, 1);
4111				}
4112			}
4113		}
4114	}
4115
4116	return results;
4117};
4118
4119Sizzle.matches = function(expr, set){
4120	return Sizzle(expr, null, null, set);
4121};
4122
4123Sizzle.find = function(expr, context, isXML){
4124	var set, match;
4125
4126	if ( !expr ) {
4127		return [];
4128	}
4129
4130	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
4131		var type = Expr.order[i], match;
4132
4133		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
4134			var left = match[1];
4135			match.splice(1,1);
4136
4137			if ( left.substr( left.length - 1 ) !== "\\" ) {
4138				match[1] = (match[1] || "").replace(/\\/g, "");
4139				set = Expr.find[ type ]( match, context, isXML );
4140				if ( set != null ) {
4141					expr = expr.replace( Expr.match[ type ], "" );
4142					break;
4143				}
4144			}
4145		}
4146	}
4147
4148	if ( !set ) {
4149		set = context.getElementsByTagName("*");
4150	}
4151
4152	return {set: set, expr: expr};
4153};
4154
4155Sizzle.filter = function(expr, set, inplace, not){
4156	var old = expr, result = [], curLoop = set, match, anyFound,
4157		isXMLFilter = set && set[0] && isXML(set[0]);
4158
4159	while ( expr && set.length ) {
4160		for ( var type in Expr.filter ) {
4161			if ( (match = Expr.match[ type ].exec( expr )) != null ) {
4162				var filter = Expr.filter[ type ], found, item;
4163				anyFound = false;
4164
4165				if ( curLoop == result ) {
4166					result = [];
4167				}
4168
4169				if ( Expr.preFilter[ type ] ) {
4170					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4171
4172					if ( !match ) {
4173						anyFound = found = true;
4174					} else if ( match === true ) {
4175						continue;
4176					}
4177				}
4178
4179				if ( match ) {
4180					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
4181						if ( item ) {
4182							found = filter( item, match, i, curLoop );
4183							var pass = not ^ !!found;
4184
4185							if ( inplace && found != null ) {
4186								if ( pass ) {
4187									anyFound = true;
4188								} else {
4189									curLoop[i] = false;
4190								}
4191							} else if ( pass ) {
4192								result.push( item );
4193								anyFound = true;
4194							}
4195						}
4196					}
4197				}
4198
4199				if ( found !== undefined ) {
4200					if ( !inplace ) {
4201						curLoop = result;
4202					}
4203
4204					expr = expr.replace( Expr.match[ type ], "" );
4205
4206					if ( !anyFound ) {
4207						return [];
4208					}
4209
4210					break;
4211				}
4212			}
4213		}
4214
4215		if ( expr == old ) {
4216			if ( anyFound == null ) {
4217				throw "Syntax error, unrecognized expression: " + expr;
4218			} else {
4219				break;
4220			}
4221		}
4222
4223		old = expr;
4224	}
4225
4226	return curLoop;
4227};
4228
4229var Expr = Sizzle.selectors = {
4230	order: [ "ID", "NAME", "TAG" ],
4231	match: {
4232		ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
4233		CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
4234		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
4235		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
4236		TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
4237		CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
4238		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
4239		PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
4240	},
4241	leftMatch: {},
4242	attrMap: {
4243		"class": "className",
4244		"for": "htmlFor"
4245	},
4246	attrHandle: {
4247		href: function(elem){
4248			return elem.getAttribute("href");
4249		}
4250	},
4251	relative: {
4252		"+": function(checkSet, part, isXML){
4253			var isPartStr = typeof part === "string",
4254				isTag = isPartStr && !/\W/.test(part),
4255				isPartStrNotTag = isPartStr && !isTag;
4256
4257			if ( isTag && !isXML ) {
4258				part = part.toUpperCase();
4259			}
4260
4261			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4262				if ( (elem = checkSet[i]) ) {
4263					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4264
4265					checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ?
4266						elem || false :
4267						elem === part;
4268				}
4269			}
4270
4271			if ( isPartStrNotTag ) {
4272				Sizzle.filter( part, checkSet, true );
4273			}
4274		},
4275		">": function(checkSet, part, isXML){
4276			var isPartStr = typeof part === "string";
4277
4278			if ( isPartStr && !/\W/.test(part) ) {
4279				part = isXML ? part : part.toUpperCase();
4280
4281				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4282					var elem = checkSet[i];
4283					if ( elem ) {
4284						var parent = elem.parentNode;
4285						checkSet[i] = parent.nodeName === part ? parent : false;
4286					}
4287				}
4288			} else {
4289				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4290					var elem = checkSet[i];
4291					if ( elem ) {
4292						checkSet[i] = isPartStr ?
4293							elem.parentNode :
4294							elem.parentNode === part;
4295					}
4296				}
4297
4298				if ( isPartStr ) {
4299					Sizzle.filter( part, checkSet, true );
4300				}
4301			}
4302		},
4303		"": function(checkSet, part, isXML){
4304			var doneName = done++, checkFn = dirCheck;
4305
4306			if ( !/\W/.test(part) ) {
4307				var nodeCheck = part = isXML ? part : part.toUpperCase();
4308				checkFn = dirNodeCheck;
4309			}
4310
4311			checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
4312		},
4313		"~": function(checkSet, part, isXML){
4314			var doneName = done++, checkFn = dirCheck;
4315
4316			if ( typeof part === "string" && !/\W/.test(part) ) {
4317				var nodeCheck = part = isXML ? part : part.toUpperCase();
4318				checkFn = dirNodeCheck;
4319			}
4320
4321			checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
4322		}
4323	},
4324	find: {
4325		ID: function(match, context, isXML){
4326			if ( typeof context.getElementById !== "undefined" && !isXML ) {
4327				var m = context.getElementById(match[1]);
4328				return m ? [m] : [];
4329			}
4330		},
4331		NAME: function(match, context, isXML){
4332			if ( typeof context.getElementsByName !== "undefined" ) {
4333				var ret = [], results = context.getElementsByName(match[1]);
4334
4335				for ( var i = 0, l = results.length; i < l; i++ ) {
4336					if ( results[i].getAttribute("name") === match[1] ) {
4337						ret.push( results[i] );
4338					}
4339				}
4340
4341				return ret.length === 0 ? null : ret;
4342			}
4343		},
4344		TAG: function(match, context){
4345			return context.getElementsByTagName(match[1]);
4346		}
4347	},
4348	preFilter: {
4349		CLASS: function(match, curLoop, inplace, result, not, isXML){
4350			match = " " + match[1].replace(/\\/g, "") + " ";
4351
4352			if ( isXML ) {
4353				return match;
4354			}
4355
4356			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4357				if ( elem ) {
4358					if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) {
4359						if ( !inplace )
4360							result.push( elem );
4361					} else if ( inplace ) {
4362						curLoop[i] = false;
4363					}
4364				}
4365			}
4366
4367			return false;
4368		},
4369		ID: function(match){
4370			return match[1].replace(/\\/g, "");
4371		},
4372		TAG: function(match, curLoop){
4373			for ( var i = 0; curLoop[i] === false; i++ ){}
4374			return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
4375		},
4376		CHILD: function(match){
4377			if ( match[1] == "nth" ) {
4378				var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
4379					match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
4380					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4381
4382				match[2] = (test[1] + (test[2] || 1)) - 0;
4383				match[3] = test[3] - 0;
4384			}
4385
4386			match[0] = done++;
4387
4388			return match;
4389		},
4390		ATTR: function(match, curLoop, inplace, result, not, isXML){
4391			var name = match[1].replace(/\\/g, "");
4392
4393			if ( !isXML && Expr.attrMap[name] ) {
4394				match[1] = Expr.attrMap[name];
4395			}
4396
4397			if ( match[2] === "~=" ) {
4398				match[4] = " " + match[4] + " ";
4399			}
4400
4401			return match;
4402		},
4403		PSEUDO: function(match, curLoop, inplace, result, not){
4404			if ( match[1] === "not" ) {
4405				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4406					match[3] = Sizzle(match[3], null, null, curLoop);
4407				} else {
4408					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4409					if ( !inplace ) {
4410						result.push.apply( result, ret );
4411					}
4412					return false;
4413				}
4414			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4415				return true;
4416			}
4417
4418			return match;
4419		},
4420		POS: function(match){
4421			match.unshift( true );
4422			return match;
4423		}
4424	},
4425	filters: {
4426		enabled: function(elem){
4427			return elem.disabled === false && elem.type !== "hidden";
4428		},
4429		disabled: function(elem){
4430			return elem.disabled === true;
4431		},
4432		checked: function(elem){
4433			return elem.checked === true;
4434		},
4435		selected: function(elem){
4436			elem.parentNode.selectedIndex;
4437			return elem.selected === true;
4438		},
4439		parent: function(elem){
4440			return !!elem.firstChild;
4441		},
4442		empty: function(elem){
4443			return !elem.firstChild;
4444		},
4445		has: function(elem, i, match){
4446			return !!Sizzle( match[3], elem ).length;
4447		},
4448		header: function(elem){
4449			return /h\d/i.test( elem.nodeName );
4450		},
4451		text: function(elem){
4452			return "text" === elem.type;
4453		},
4454		radio: function(elem){
4455			return "radio" === elem.type;
4456		},
4457		checkbox: function(elem){
4458			return "checkbox" === elem.type;
4459		},
4460		file: function(elem){
4461			return "file" === elem.type;
4462		},
4463		password: function(elem){
4464			return "password" === elem.type;
4465		},
4466		submit: function(elem){
4467			return "submit" === elem.type;
4468		},
4469		image: function(elem){
4470			return "image" === elem.type;
4471		},
4472		reset: function(elem){
4473			return "reset" === elem.type;
4474		},
4475		button: function(elem){
4476			return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
4477		},
4478		input: function(elem){
4479			return /input|select|textarea|button/i.test(elem.nodeName);
4480		}
4481	},
4482	setFilters: {
4483		first: function(elem, i){
4484			return i === 0;
4485		},
4486		last: function(elem, i, match, array){
4487			return i === array.length - 1;
4488		},
4489		even: function(elem, i){
4490			return i % 2 === 0;
4491		},
4492		odd: function(elem, i){
4493			return i % 2 === 1;
4494		},
4495		lt: function(elem, i, match){
4496			return i < match[3] - 0;
4497		},
4498		gt: function(elem, i, match){
4499			return i > match[3] - 0;
4500		},
4501		nth: function(elem, i, match){
4502			return match[3] - 0 == i;
4503		},
4504		eq: function(elem, i, match){
4505			return match[3] - 0 == i;
4506		}
4507	},
4508	filter: {
4509		PSEUDO: function(elem, match, i, array){
4510			var name = match[1], filter = Expr.filters[ name ];
4511
4512			if ( filter ) {
4513				return filter( elem, i, match, array );
4514			} else if ( name === "contains" ) {
4515				return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
4516			} else if ( name === "not" ) {
4517				var not = match[3];
4518
4519				for ( var i = 0, l = not.length; i < l; i++ ) {
4520					if ( not[i] === elem ) {
4521						return false;
4522					}
4523				}
4524
4525				return true;
4526			}
4527		},
4528		CHILD: function(elem, match){
4529			var type = match[1], node = elem;
4530			switch (type) {
4531				case 'only':
4532				case 'first':
4533					while ( (node = node.previousSibling) )  {
4534						if ( node.nodeType === 1 ) return false;
4535					}
4536					if ( type == 'first') return true;
4537					node = elem;
4538				case 'last':
4539					while ( (node = node.nextSibling) )  {
4540						if ( node.nodeType === 1 ) return false;
4541					}
4542					return true;
4543				case 'nth':
4544					var first = match[2], last = match[3];
4545
4546					if ( first == 1 && last == 0 ) {
4547						return true;
4548					}
4549
4550					var doneName = match[0],
4551						parent = elem.parentNode;
4552
4553					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4554						var count = 0;
4555						for ( node = parent.firstChild; node; node = node.nextSibling ) {
4556							if ( node.nodeType === 1 ) {
4557								node.nodeIndex = ++count;
4558							}
4559						}
4560						parent.sizcache = doneName;
4561					}
4562
4563					var diff = elem.nodeIndex - last;
4564					if ( first == 0 ) {
4565						return diff == 0;
4566					} else {
4567						return ( diff % first == 0 && diff / first >= 0 );
4568					}
4569			}
4570		},
4571		ID: function(elem, match){
4572			return elem.nodeType === 1 && elem.getAttribute("id") === match;
4573		},
4574		TAG: function(elem, match){
4575			return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
4576		},
4577		CLASS: function(elem, match){
4578			return (" " + (elem.className || elem.getAttribute("class")) + " ")
4579				.indexOf( match ) > -1;
4580		},
4581		ATTR: function(elem, match){
4582			var name = match[1],
4583				result = Expr.attrHandle[ name ] ?
4584					Expr.attrHandle[ name ]( elem ) :
4585					elem[ name ] != null ?
4586						elem[ name ] :
4587						elem.getAttribute( name ),
4588				value = result + "",
4589				type = match[2],
4590				check = match[4];
4591
4592			return result == null ?
4593				type === "!=" :
4594				type === "=" ?
4595				value === check :
4596				type === "*=" ?
4597				value.indexOf(check) >= 0 :
4598				type === "~=" ?
4599				(" " + value + " ").indexOf(check) >= 0 :
4600				!check ?
4601				value && result !== false :
4602				type === "!=" ?
4603				value != check :
4604				type === "^=" ?
4605				value.indexOf(check) === 0 :
4606				type === "$=" ?
4607				value.substr(value.length - check.length) === check :
4608				type === "|=" ?
4609				value === check || value.substr(0, check.length + 1) === check + "-" :
4610				false;
4611		},
4612		POS: function(elem, match, i, array){
4613			var name = match[2], filter = Expr.setFilters[ name ];
4614
4615			if ( filter ) {
4616				return filter( elem, i, match, array );
4617			}
4618		}
4619	}
4620};
4621
4622var origPOS = Expr.match.POS;
4623
4624for ( var type in Expr.match ) {
4625	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
4626	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source );
4627}
4628
4629var makeArray = function(array, results) {
4630	array = Array.prototype.slice.call( array, 0 );
4631
4632	if ( results ) {
4633		results.push.apply( results, array );
4634		return results;
4635	}
4636
4637	return array;
4638};
4639
4640try {
4641	Array.prototype.slice.call( document.documentElement.childNodes, 0 );
4642
4643} catch(e){
4644	makeArray = function(array, results) {
4645		var ret = results || [];
4646
4647		if ( toString.call(array) === "[object Array]" ) {
4648			Array.prototype.push.apply( ret, array );
4649		} else {
4650			if ( typeof array.length === "number" ) {
4651				for ( var i = 0, l = array.length; i < l; i++ ) {
4652					ret.push( array[i] );
4653				}
4654			} else {
4655				for ( var i = 0; array[i]; i++ ) {
4656					ret.push( array[i] );
4657				}
4658			}
4659		}
4660
4661		return ret;
4662	};
4663}
4664
4665var sortOrder;
4666
4667if ( document.documentElement.compareDocumentPosition ) {
4668	sortOrder = function( a, b ) {
4669		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4670			if ( a == b ) {
4671				hasDuplicate = true;
4672			}
4673			return 0;
4674		}
4675
4676		var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
4677		if ( ret === 0 ) {
4678			hasDuplicate = true;
4679		}
4680		return ret;
4681	};
4682} else if ( "sourceIndex" in document.documentElement ) {
4683	sortOrder = function( a, b ) {
4684		if ( !a.sourceIndex || !b.sourceIndex ) {
4685			if ( a == b ) {
4686				hasDuplicate = true;
4687			}
4688			return 0;
4689		}
4690
4691		var ret = a.sourceIndex - b.sourceIndex;
4692		if ( ret === 0 ) {
4693			hasDuplicate = true;
4694		}
4695		return ret;
4696	};
4697} else if ( document.createRange ) {
4698	sortOrder = function( a, b ) {
4699		if ( !a.ownerDocument || !b.ownerDocument ) {
4700			if ( a == b ) {
4701				hasDuplicate = true;
4702			}
4703			return 0;
4704		}
4705
4706		var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
4707		aRange.setStart(a, 0);
4708		aRange.setEnd(a, 0);
4709		bRange.setStart(b, 0);
4710		bRange.setEnd(b, 0);
4711		var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
4712		if ( ret === 0 ) {
4713			hasDuplicate = true;
4714		}
4715		return ret;
4716	};
4717}
4718
4719(function(){
4720	var form = document.createElement("div"),
4721		id = "script" + (new Date).getTime();
4722	form.innerHTML = "<a name='" + id + "'/>";
4723
4724	var root = document.documentElement;
4725	root.insertBefore( form, root.firstChild );
4726
4727	if ( !!document.getElementById( id ) ) {
4728		Expr.find.ID = function(match, context, isXML){
4729			if ( typeof context.getElementById !== "undefined" && !isXML ) {
4730				var m = context.getElementById(match[1]);
4731				return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
4732			}
4733		};
4734
4735		Expr.filter.ID = function(elem, match){
4736			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4737			return elem.nodeType === 1 && node && node.nodeValue === match;
4738		};
4739	}
4740
4741	root.removeChild( form );
4742	root = form = null; // release memory in IE
4743})();
4744
4745(function(){
4746
4747	var div = document.createElement("div");
4748	div.appendChild( document.createComment("") );
4749
4750	if ( div.getElementsByTagName("*").length > 0 ) {
4751		Expr.find.TAG = function(match, context){
4752			var results = context.getElementsByTagName(match[1]);
4753
4754			if ( match[1] === "*" ) {
4755				var tmp = [];
4756
4757				for ( var i = 0; results[i]; i++ ) {
4758					if ( results[i].nodeType === 1 ) {
4759						tmp.push( results[i] );
4760					}
4761				}
4762
4763				results = tmp;
4764			}
4765
4766			return results;
4767		};
4768	}
4769
4770	div.innerHTML = "<a href='#'></a>";
4771	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4772			div.firstChild.getAttribute("href") !== "#" ) {
4773		Expr.attrHandle.href = function(elem){
4774			return elem.getAttribute("href", 2);
4775		};
4776	}
4777
4778	div = null; // release memory in IE
4779})();
4780
4781if ( document.querySelectorAll ) (function(){
4782	var oldSizzle = Sizzle, div = document.createElement("div");
4783	div.innerHTML = "<p class='TEST'></p>";
4784
4785	if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4786		return;
4787	}
4788
4789	Sizzle = function(query, context, extra, seed){
4790		context = context || document;
4791
4792		if ( !seed && context.nodeType === 9 && !isXML(context) ) {
4793			try {
4794				return makeArray( context.querySelectorAll(query), extra );
4795			} catch(e){}
4796		}
4797
4798		return oldSizzle(query, context, extra, seed);
4799	};
4800
4801	for ( var prop in oldSizzle ) {
4802		Sizzle[ prop ] = oldSizzle[ prop ];
4803	}
4804
4805	div = null; // release memory in IE
4806})();
4807
4808if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
4809	var div = document.createElement("div");
4810	div.innerHTML = "<div class='test e'></div><div class='test'></div>";
4811
4812	if ( div.getElementsByClassName("e").length === 0 )
4813		return;
4814
4815	div.lastChild.className = "e";
4816
4817	if ( div.getElementsByClassName("e").length === 1 )
4818		return;
4819
4820	Expr.order.splice(1, 0, "CLASS");
4821	Expr.find.CLASS = function(match, context, isXML) {
4822		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
4823			return context.getElementsByClassName(match[1]);
4824		}
4825	};
4826
4827	div = null; // release memory in IE
4828})();
4829
4830function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
4831	var sibDir = dir == "previousSibling" && !isXML;
4832	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4833		var elem = checkSet[i];
4834		if ( elem ) {
4835			if ( sibDir && elem.nodeType === 1 ){
4836				elem.sizcache = doneName;
4837				elem.sizset = i;
4838			}
4839			elem = elem[dir];
4840			var match = false;
4841
4842			while ( elem ) {
4843				if ( elem.sizcache === doneName ) {
4844					match = checkSet[elem.sizset];
4845					break;
4846				}
4847
4848				if ( elem.nodeType === 1 && !isXML ){
4849					elem.sizcache = doneName;
4850					elem.sizset = i;
4851				}
4852
4853				if ( elem.nodeName === cur ) {
4854					match = elem;
4855					break;
4856				}
4857
4858				elem = elem[dir];
4859			}
4860
4861			checkSet[i] = match;
4862		}
4863	}
4864}
4865
4866function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
4867	var sibDir = dir == "previousSibling" && !isXML;
4868	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
4869		var elem = checkSet[i];
4870		if ( elem ) {
4871			if ( sibDir && elem.nodeType === 1 ) {
4872				elem.sizcache = doneName;
4873				elem.sizset = i;
4874			}
4875			elem = elem[dir];
4876			var match = false;
4877
4878			while ( elem ) {
4879				if ( elem.sizcache === doneName ) {
4880					match = checkSet[elem.sizset];
4881					break;
4882				}
4883
4884				if ( elem.nodeType === 1 ) {
4885					if ( !isXML ) {
4886						elem.sizcache = doneName;
4887						elem.sizset = i;
4888					}
4889					if ( typeof cur !== "string" ) {
4890						if ( elem === cur ) {
4891							match = true;
4892							break;
4893						}
4894
4895					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
4896						match = elem;
4897						break;
4898					}
4899				}
4900
4901				elem = elem[dir];
4902			}
4903
4904			checkSet[i] = match;
4905		}
4906	}
4907}
4908
4909var contains = document.compareDocumentPosition ?  function(a, b){
4910	return a.compareDocumentPosition(b) & 16;
4911} : function(a, b){
4912	return a !== b && (a.contains ? a.contains(b) : true);
4913};
4914
4915var isXML = function(elem){
4916	return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
4917		!!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML";
4918};
4919
4920var posProcess = function(selector, context){
4921	var tmpSet = [], later = "", match,
4922		root = context.nodeType ? [context] : context;
4923
4924	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
4925		later += match[0];
4926		selector = selector.replace( Expr.match.PSEUDO, "" );
4927	}
4928
4929	selector = Expr.relative[selector] ? selector + "*" : selector;
4930
4931	for ( var i = 0, l = root.length; i < l; i++ ) {
4932		Sizzle( selector, root[i], tmpSet );
4933	}
4934
4935	return Sizzle.filter( later, tmpSet );
4936};
4937
4938
4939window.Sizzle = Sizzle;
4940
4941})();
4942
4943;(function(engine) {
4944  var extendElements = Prototype.Selector.extendElements;
4945
4946  function select(selector, scope) {
4947    return extendElements(engine(selector, scope || document));
4948  }
4949
4950  function match(element, selector) {
4951    return engine.matches(selector, [element]).length == 1;
4952  }
4953
4954  Prototype.Selector.engine = engine;
4955  Prototype.Selector.select = select;
4956  Prototype.Selector.match = match;
4957})(Sizzle);
4958
4959window.Sizzle = Prototype._original_property;
4960delete Prototype._original_property;
4961
4962var Form = {
4963  reset: function(form) {
4964    form = $(form);
4965    form.reset();
4966    return form;
4967  },
4968
4969  serializeElements: function(elements, options) {
4970    if (typeof options != 'object') options = { hash: !!options };
4971    else if (Object.isUndefined(options.hash)) options.hash = true;
4972    var key, value, submitted = false, submit = options.submit, accumulator, initial;
4973
4974    if (options.hash) {
4975      initial = {};
4976      accumulator = function(result, key, value) {
4977        if (key in result) {
4978          if (!Object.isArray(result[key])) result[key] = [result[key]];
4979          result[key].push(value);
4980        } else result[key] = value;
4981        return result;
4982      };
4983    } else {
4984      initial = '';
4985      accumulator = function(result, key, value) {
4986        return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + encodeURIComponent(value);
4987      }
4988    }
4989
4990    return elements.inject(initial, function(result, element) {
4991      if (!element.disabled && element.name) {
4992        key = element.name; value = $(element).getValue();
4993        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
4994            submit !== false && (!submit || key == submit) && (submitted = true)))) {
4995          result = accumulator(result, key, value);
4996        }
4997      }
4998      return result;
4999    });
5000  }
5001};
5002
5003Form.Methods = {
5004  serialize: function(form, options) {
5005    return Form.serializeElements(Form.getElements(form), options);
5006  },
5007
5008  getElements: function(form) {
5009    var elements = $(form).getElementsByTagName('*'),
5010        element,
5011        arr = [ ],
5012        serializers = Form.Element.Serializers;
5013    for (var i = 0; element = elements[i]; i++) {
5014      arr.push(element);
5015    }
5016    return arr.inject([], function(elements, child) {
5017      if (serializers[child.tagName.toLowerCase()])
5018        elements.push(Element.extend(child));
5019      return elements;
5020    })
5021  },
5022
5023  getInputs: function(form, typeName, name) {
5024    form = $(form);
5025    var inputs = form.getElementsByTagName('input');
5026
5027    if (!typeName && !name) return $A(inputs).map(Element.extend);
5028
5029    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
5030      var input = inputs[i];
5031      if ((typeName && input.type != typeName) || (name && input.name != name))
5032        continue;
5033      matchingInputs.push(Element.extend(input));
5034    }
5035
5036    return matchingInputs;
5037  },
5038
5039  disable: function(form) {
5040    form = $(form);
5041    Form.getElements(form).invoke('disable');
5042    return form;
5043  },
5044
5045  enable: function(form) {
5046    form = $(form);
5047    Form.getElements(form).invoke('enable');
5048    return form;
5049  },
5050
5051  findFirstElement: function(form) {
5052    var elements = $(form).getElements().findAll(function(element) {
5053      return 'hidden' != element.type && !element.disabled;
5054    });
5055    var firstByIndex = elements.findAll(function(element) {
5056      return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
5057    }).sortBy(function(element) { return element.tabIndex }).first();
5058
5059    return firstByIndex ? firstByIndex : elements.find(function(element) {
5060      return /^(?:input|select|textarea)$/i.test(element.tagName);
5061    });
5062  },
5063
5064  focusFirstElement: function(form) {
5065    form = $(form);
5066    var element = form.findFirstElement();
5067    if (element) element.activate();
5068    return form;
5069  },
5070
5071  request: function(form, options) {
5072    form = $(form), options = Object.clone(options || { });
5073
5074    var params = options.parameters, action = form.readAttribute('action') || '';
5075    if (action.blank()) action = window.location.href;
5076    options.parameters = form.serialize(true);
5077
5078    if (params) {
5079      if (Object.isString(params)) params = params.toQueryParams();
5080      Object.extend(options.parameters, params);
5081    }
5082
5083    if (form.hasAttribute('method') && !options.method)
5084      options.method = form.method;
5085
5086    return new Ajax.Request(action, options);
5087  }
5088};
5089
5090/*--------------------------------------------------------------------------*/
5091
5092
5093Form.Element = {
5094  focus: function(element) {
5095    $(element).focus();
5096    return element;
5097  },
5098
5099  select: function(element) {
5100    $(element).select();
5101    return element;
5102  }
5103};
5104
5105Form.Element.Methods = {
5106
5107  serialize: function(element) {
5108    element = $(element);
5109    if (!element.disabled && element.name) {
5110      var value = element.getValue();
5111      if (value != undefined) {
5112        var pair = { };
5113        pair[element.name] = value;
5114        return Object.toQueryString(pair);
5115      }
5116    }
5117    return '';
5118  },
5119
5120  getValue: function(element) {
5121    element = $(element);
5122    var method = element.tagName.toLowerCase();
5123    return Form.Element.Serializers[method](element);
5124  },
5125
5126  setValue: function(element, value) {
5127    element = $(element);
5128    var method = element.tagName.toLowerCase();
5129    Form.Element.Serializers[method](element, value);
5130    return element;
5131  },
5132
5133  clear: function(element) {
5134    $(element).value = '';
5135    return element;
5136  },
5137
5138  present: function(element) {
5139    return $(element).value != '';
5140  },
5141
5142  activate: function(element) {
5143    element = $(element);
5144    try {
5145      element.focus();
5146      if (element.select && (element.tagName.toLowerCase() != 'input' ||
5147          !(/^(?:button|reset|submit)$/i.test(element.type))))
5148        element.select();
5149    } catch (e) { }
5150    return element;
5151  },
5152
5153  disable: function(element) {
5154    element = $(element);
5155    element.disabled = true;
5156    return element;
5157  },
5158
5159  enable: function(element) {
5160    element = $(element);
5161    element.disabled = false;
5162    return element;
5163  }
5164};
5165
5166/*--------------------------------------------------------------------------*/
5167
5168var Field = Form.Element;
5169
5170var $F = Form.Element.Methods.getValue;
5171
5172/*--------------------------------------------------------------------------*/
5173
5174Form.Element.Serializers = (function() {
5175  function input(element, value) {
5176    switch (element.type.toLowerCase()) {
5177      case 'checkbox':
5178      case 'radio':
5179        return inputSelector(element, value);
5180      default:
5181        return valueSelector(element, value);
5182    }
5183  }
5184
5185  function inputSelector(element, value) {
5186    if (Object.isUndefined(value))
5187      return element.checked ? element.value : null;
5188    else element.checked = !!value;
5189  }
5190
5191  function valueSelector(element, value) {
5192    if (Object.isUndefined(value)) return element.value;
5193    else element.value = value;
5194  }
5195
5196  function select(element, value) {
5197    if (Object.isUndefined(value))
5198      return (element.type === 'select-one' ? selectOne : selectMany)(element);
5199
5200    var opt, currentValue, single = !Object.isArray(value);
5201    for (var i = 0, length = element.length; i < length; i++) {
5202      opt = element.options[i];
5203      currentValue = this.optionValue(opt);
5204      if (single) {
5205        if (currentValue == value) {
5206          opt.selected = true;
5207          return;
5208        }
5209      }
5210      else opt.selected = value.include(currentValue);
5211    }
5212  }
5213
5214  function selectOne(element) {
5215    var index = element.selectedIndex;
5216    return index >= 0 ? optionValue(element.options[index]) : null;
5217  }
5218
5219  function selectMany(element) {
5220    var values, length = element.length;
5221    if (!length) return null;
5222
5223    for (var i = 0, values = []; i < length; i++) {
5224      var opt = element.options[i];
5225      if (opt.selected) values.push(optionValue(opt));
5226    }
5227    return values;
5228  }
5229
5230  function optionValue(opt) {
5231    return Element.hasAttribute(opt, 'value') ? opt.value : opt.text;
5232  }
5233
5234  return {
5235    input:         input,
5236    inputSelector: inputSelector,
5237    textarea:      valueSelector,
5238    select:        select,
5239    selectOne:     selectOne,
5240    selectMany:    selectMany,
5241    optionValue:   optionValue,
5242    button:        valueSelector
5243  };
5244})();
5245
5246/*--------------------------------------------------------------------------*/
5247
5248
5249Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
5250  initialize: function($super, element, frequency, callback) {
5251    $super(callback, frequency);
5252    this.element   = $(element);
5253    this.lastValue = this.getValue();
5254  },
5255
5256  execute: function() {
5257    var value = this.getValue();
5258    if (Object.isString(this.lastValue) && Object.isString(value) ?
5259        this.lastValue != value : String(this.lastValue) != String(value)) {
5260      this.callback(this.element, value);
5261      this.lastValue = value;
5262    }
5263  }
5264});
5265
5266Form.Element.Observer = Class.create(Abstract.TimedObserver, {
5267  getValue: function() {
5268    return Form.Element.getValue(this.element);
5269  }
5270});
5271
5272Form.Observer = Class.create(Abstract.TimedObserver, {
5273  getValue: function() {
5274    return Form.serialize(this.element);
5275  }
5276});
5277
5278/*--------------------------------------------------------------------------*/
5279
5280Abstract.EventObserver = Class.create({
5281  initialize: function(element, callback) {
5282    this.element  = $(element);
5283    this.callback = callback;
5284
5285    this.lastValue = this.getValue();
5286    if (this.element.tagName.toLowerCase() == 'form')
5287      this.registerFormCallbacks();
5288    else
5289      this.registerCallback(this.element);
5290  },
5291
5292  onElementEvent: function() {
5293    var value = this.getValue();
5294    if (this.lastValue != value) {
5295      this.callback(this.element, value);
5296      this.lastValue = value;
5297    }
5298  },
5299
5300  registerFormCallbacks: function() {
5301    Form.getElements(this.element).each(this.registerCallback, this);
5302  },
5303
5304  registerCallback: function(element) {
5305    if (element.type) {
5306      switch (element.type.toLowerCase()) {
5307        case 'checkbox':
5308        case 'radio':
5309          Event.observe(element, 'click', this.onElementEvent.bind(this));
5310          break;
5311        default:
5312          Event.observe(element, 'change', this.onElementEvent.bind(this));
5313          break;
5314      }
5315    }
5316  }
5317});
5318
5319Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
5320  getValue: function() {
5321    return Form.Element.getValue(this.element);
5322  }
5323});
5324
5325Form.EventObserver = Class.create(Abstract.EventObserver, {
5326  getValue: function() {
5327    return Form.serialize(this.element);
5328  }
5329});
5330(function() {
5331
5332  var Event = {
5333    KEY_BACKSPACE: 8,
5334    KEY_TAB:       9,
5335    KEY_RETURN:   13,
5336    KEY_ESC:      27,
5337    KEY_LEFT:     37,
5338    KEY_UP:       38,
5339    KEY_RIGHT:    39,
5340    KEY_DOWN:     40,
5341    KEY_DELETE:   46,
5342    KEY_HOME:     36,
5343    KEY_END:      35,
5344    KEY_PAGEUP:   33,
5345    KEY_PAGEDOWN: 34,
5346    KEY_INSERT:   45,
5347
5348    cache: {}
5349  };
5350
5351  var docEl = document.documentElement;
5352  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
5353    && 'onmouseleave' in docEl;
5354
5355
5356
5357  var isIELegacyEvent = function(event) { return false; };
5358
5359  if (window.attachEvent) {
5360    if (window.addEventListener) {
5361      isIELegacyEvent = function(event) {
5362        return !(event instanceof window.Event);
5363      };
5364    } else {
5365      isIELegacyEvent = function(event) { return true; };
5366    }
5367  }
5368
5369  var _isButton;
5370
5371  function _isButtonForDOMEvents(event, code) {
5372    return event.which ? (event.which === code + 1) : (event.button === code);
5373  }
5374
5375  var legacyButtonMap = { 0: 1, 1: 4, 2: 2 };
5376  function _isButtonForLegacyEvents(event, code) {
5377    return event.button === legacyButtonMap[code];
5378  }
5379
5380  function _isButtonForWebKit(event, code) {
5381    switch (code) {
5382      case 0: return event.which == 1 && !event.metaKey;
5383      case 1: return event.which == 2 || (event.which == 1 && event.metaKey);
5384      case 2: return event.which == 3;
5385      default: return false;
5386    }
5387  }
5388
5389  if (window.attachEvent) {
5390    if (!window.addEventListener) {
5391      _isButton = _isButtonForLegacyEvents;
5392    } else {
5393      _isButton = function(event, code) {
5394        return isIELegacyEvent(event) ? _isButtonForLegacyEvents(event, code) :
5395         _isButtonForDOMEvents(event, code);
5396      }
5397    }
5398  } else if (Prototype.Browser.WebKit) {
5399    _isButton = _isButtonForWebKit;
5400  } else {
5401    _isButton = _isButtonForDOMEvents;
5402  }
5403
5404  function isLeftClick(event)   { return _isButton(event, 0) }
5405
5406  function isMiddleClick(event) { return _isButton(event, 1) }
5407
5408  function isRightClick(event)  { return _isButton(event, 2) }
5409
5410  function element(event) {
5411    event = Event.extend(event);
5412
5413    var node = event.target, type = event.type,
5414     currentTarget = event.currentTarget;
5415
5416    if (currentTarget && currentTarget.tagName) {
5417      if (type === 'load' || type === 'error' ||
5418        (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
5419          && currentTarget.type === 'radio'))
5420            node = currentTarget;
5421    }
5422
5423    if (node.nodeType == Node.TEXT_NODE)
5424      node = node.parentNode;
5425
5426    return Element.extend(node);
5427  }
5428
5429  function findElement(event, expression) {
5430    var element = Event.element(event);
5431
5432    if (!expression) return element;
5433    while (element) {
5434      if (Object.isElement(element) && Prototype.Selector.match(element, expression)) {
5435        return Element.extend(element);
5436      }
5437      element = element.parentNode;
5438    }
5439  }
5440
5441  function pointer(event) {
5442    return { x: pointerX(event), y: pointerY(event) };
5443  }
5444
5445  function pointerX(event) {
5446    var docElement = document.documentElement,
5447     body = document.body || { scrollLeft: 0 };
5448
5449    return event.pageX || (event.clientX +
5450      (docElement.scrollLeft || body.scrollLeft) -
5451      (docElement.clientLeft || 0));
5452  }
5453
5454  function pointerY(event) {
5455    var docElement = document.documentElement,
5456     body = document.body || { scrollTop: 0 };
5457
5458    return  event.pageY || (event.clientY +
5459       (docElement.scrollTop || body.scrollTop) -
5460       (docElement.clientTop || 0));
5461  }
5462
5463
5464  function stop(event) {
5465    Event.extend(event);
5466    event.preventDefault();
5467    event.stopPropagation();
5468
5469    event.stopped = true;
5470  }
5471
5472
5473  Event.Methods = {
5474    isLeftClick:   isLeftClick,
5475    isMiddleClick: isMiddleClick,
5476    isRightClick:  isRightClick,
5477
5478    element:     element,
5479    findElement: findElement,
5480
5481    pointer:  pointer,
5482    pointerX: pointerX,
5483    pointerY: pointerY,
5484
5485    stop: stop
5486  };
5487
5488  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
5489    m[name] = Event.Methods[name].methodize();
5490    return m;
5491  });
5492
5493  if (window.attachEvent) {
5494    function _relatedTarget(event) {
5495      var element;
5496      switch (event.type) {
5497        case 'mouseover':
5498        case 'mouseenter':
5499          element = event.fromElement;
5500          break;
5501        case 'mouseout':
5502        case 'mouseleave':
5503          element = event.toElement;
5504          break;
5505        default:
5506          return null;
5507      }
5508      return Element.extend(element);
5509    }
5510
5511    var additionalMethods = {
5512      stopPropagation: function() { this.cancelBubble = true },
5513      preventDefault:  function() { this.returnValue = false },
5514      inspect: function() { return '[object Event]' }
5515    };
5516
5517    Event.extend = function(event, element) {
5518      if (!event) return false;
5519
5520      if (!isIELegacyEvent(event)) return event;
5521
5522      if (event._extendedByPrototype) return event;
5523      event._extendedByPrototype = Prototype.emptyFunction;
5524
5525      var pointer = Event.pointer(event);
5526
5527      Object.extend(event, {
5528        target: event.srcElement || element,
5529        relatedTarget: _relatedTarget(event),
5530        pageX:  pointer.x,
5531        pageY:  pointer.y
5532      });
5533
5534      Object.extend(event, methods);
5535      Object.extend(event, additionalMethods);
5536
5537      return event;
5538    };
5539  } else {
5540    Event.extend = Prototype.K;
5541  }
5542
5543  if (window.addEventListener) {
5544    Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__;
5545    Object.extend(Event.prototype, methods);
5546  }
5547
5548  function _createResponder(element, eventName, handler) {
5549    var registry = Element.retrieve(element, 'prototype_event_registry');
5550
5551    if (Object.isUndefined(registry)) {
5552      CACHE.push(element);
5553      registry = Element.retrieve(element, 'prototype_event_registry', $H());
5554    }
5555
5556    var respondersForEvent = registry.get(eventName);
5557    if (Object.isUndefined(respondersForEvent)) {
5558      respondersForEvent = [];
5559      registry.set(eventName, respondersForEvent);
5560    }
5561
5562    if (respondersForEvent.pluck('handler').include(handler)) return false;
5563
5564    var responder;
5565    if (eventName.include(":")) {
5566      responder = function(event) {
5567        if (Object.isUndefined(event.eventName))
5568          return false;
5569
5570        if (event.eventName !== eventName)
5571          return false;
5572
5573        Event.extend(event, element);
5574        handler.call(element, event);
5575      };
5576    } else {
5577      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED &&
5578       (eventName === "mouseenter" || eventName === "mouseleave")) {
5579        if (eventName === "mouseenter" || eventName === "mouseleave") {
5580          responder = function(event) {
5581            Event.extend(event, element);
5582
5583            var parent = event.relatedTarget;
5584            while (parent && parent !== element) {
5585              try { parent = parent.parentNode; }
5586              catch(e) { parent = element; }
5587            }
5588
5589            if (parent === element) return;
5590
5591            handler.call(element, event);
5592          };
5593        }
5594      } else {
5595        responder = function(event) {
5596          Event.extend(event, element);
5597          handler.call(element, event);
5598        };
5599      }
5600    }
5601
5602    responder.handler = handler;
5603    respondersForEvent.push(responder);
5604    return responder;
5605  }
5606
5607  function _destroyCache() {
5608    for (var i = 0, length = CACHE.length; i < length; i++) {
5609      Event.stopObserving(CACHE[i]);
5610      CACHE[i] = null;
5611    }
5612  }
5613
5614  var CACHE = [];
5615
5616  if (Prototype.Browser.IE)
5617    window.attachEvent('onunload', _destroyCache);
5618
5619  if (Prototype.Browser.WebKit)
5620    window.addEventListener('unload', Prototype.emptyFunction, false);
5621
5622
5623  var _getDOMEventName = Prototype.K,
5624      translations = { mouseenter: "mouseover", mouseleave: "mouseout" };
5625
5626  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {
5627    _getDOMEventName = function(eventName) {
5628      return (translations[eventName] || eventName);
5629    };
5630  }
5631
5632  function observe(element, eventName, handler) {
5633    element = $(element);
5634
5635    var responder = _createResponder(element, eventName, handler);
5636
5637    if (!responder) return element;
5638
5639    if (eventName.include(':')) {
5640      if (element.addEventListener)
5641        element.addEventListener("dataavailable", responder, false);
5642      else {
5643        element.attachEvent("ondataavailable", responder);
5644        element.attachEvent("onlosecapture", responder);
5645      }
5646    } else {
5647      var actualEventName = _getDOMEventName(eventName);
5648
5649      if (element.addEventListener)
5650        element.addEventListener(actualEventName, responder, false);
5651      else
5652        element.attachEvent("on" + actualEventName, responder);
5653    }
5654
5655    return element;
5656  }
5657
5658  function stopObserving(element, eventName, handler) {
5659    element = $(element);
5660
5661    var registry = Element.retrieve(element, 'prototype_event_registry');
5662    if (!registry) return element;
5663
5664    if (!eventName) {
5665      registry.each( function(pair) {
5666        var eventName = pair.key;
5667        stopObserving(element, eventName);
5668      });
5669      return element;
5670    }
5671
5672    var responders = registry.get(eventName);
5673    if (!responders) return element;
5674
5675    if (!handler) {
5676      responders.each(function(r) {
5677        stopObserving(element, eventName, r.handler);
5678      });
5679      return element;
5680    }
5681
5682    var i = responders.length, responder;
5683    while (i--) {
5684      if (responders[i].handler === handler) {
5685        responder = responders[i];
5686        break;
5687      }
5688    }
5689    if (!responder) return element;
5690
5691    if (eventName.include(':')) {
5692      if (element.removeEventListener)
5693        element.removeEventListener("dataavailable", responder, false);
5694      else {
5695        element.detachEvent("ondataavailable", responder);
5696        element.detachEvent("onlosecapture", responder);
5697      }
5698    } else {
5699      var actualEventName = _getDOMEventName(eventName);
5700      if (element.removeEventListener)
5701        element.removeEventListener(actualEventName, responder, false);
5702      else
5703        element.detachEvent('on' + actualEventName, responder);
5704    }
5705
5706    registry.set(eventName, responders.without(responder));
5707
5708    return element;
5709  }
5710
5711  function fire(element, eventName, memo, bubble) {
5712    element = $(element);
5713
5714    if (Object.isUndefined(bubble))
5715      bubble = true;
5716
5717    if (element == document && document.createEvent && !element.dispatchEvent)
5718      element = document.documentElement;
5719
5720    var event;
5721    if (document.createEvent) {
5722      event = document.createEvent('HTMLEvents');
5723      event.initEvent('dataavailable', bubble, true);
5724    } else {
5725      event = document.createEventObject();
5726      event.eventType = bubble ? 'ondataavailable' : 'onlosecapture';
5727    }
5728
5729    event.eventName = eventName;
5730    event.memo = memo || { };
5731
5732    if (document.createEvent)
5733      element.dispatchEvent(event);
5734    else
5735      element.fireEvent(event.eventType, event);
5736
5737    return Event.extend(event);
5738  }
5739
5740  Event.Handler = Class.create({
5741    initialize: function(element, eventName, selector, callback) {
5742      this.element   = $(element);
5743      this.eventName = eventName;
5744      this.selector  = selector;
5745      this.callback  = callback;
5746      this.handler   = this.handleEvent.bind(this);
5747    },
5748
5749    start: function() {
5750      Event.observe(this.element, this.eventName, this.handler);
5751      return this;
5752    },
5753
5754    stop: function() {
5755      Event.stopObserving(this.element, this.eventName, this.handler);
5756      return this;
5757    },
5758
5759    handleEvent: function(event) {
5760      var element = Event.findElement(event, this.selector);
5761      if (element) this.callback.call(this.element, event, element);
5762    }
5763  });
5764
5765  function on(element, eventName, selector, callback) {
5766    element = $(element);
5767    if (Object.isFunction(selector) && Object.isUndefined(callback)) {
5768      callback = selector, selector = null;
5769    }
5770
5771    return new Event.Handler(element, eventName, selector, callback).start();
5772  }
5773
5774  Object.extend(Event, Event.Methods);
5775
5776  Object.extend(Event, {
5777    fire:          fire,
5778    observe:       observe,
5779    stopObserving: stopObserving,
5780    on:            on
5781  });
5782
5783  Element.addMethods({
5784    fire:          fire,
5785
5786    observe:       observe,
5787
5788    stopObserving: stopObserving,
5789
5790    on:            on
5791  });
5792
5793  Object.extend(document, {
5794    fire:          fire.methodize(),
5795
5796    observe:       observe.methodize(),
5797
5798    stopObserving: stopObserving.methodize(),
5799
5800    on:            on.methodize(),
5801
5802    loaded:        false
5803  });
5804
5805  if (window.Event) Object.extend(window.Event, Event);
5806  else window.Event = Event;
5807})();
5808
5809(function() {
5810  /* Support for the DOMContentLoaded event is based on work by Dan Webb,
5811     Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */
5812
5813  var timer;
5814
5815  function fireContentLoadedEvent() {
5816    if (document.loaded) return;
5817    if (timer) window.clearTimeout(timer);
5818    document.loaded = true;
5819    document.fire('dom:loaded');
5820  }
5821
5822  function checkReadyState() {
5823    if (document.readyState === 'complete') {
5824      document.stopObserving('readystatechange', checkReadyState);
5825      fireContentLoadedEvent();
5826    }
5827  }
5828
5829  function pollDoScroll() {
5830    try { document.documentElement.doScroll('left'); }
5831    catch(e) {
5832      timer = pollDoScroll.defer();
5833      return;
5834    }
5835    fireContentLoadedEvent();
5836  }
5837
5838  if (document.addEventListener) {
5839    document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);
5840  } else {
5841    document.observe('readystatechange', checkReadyState);
5842    if (window == top)
5843      timer = pollDoScroll.defer();
5844  }
5845
5846  Event.observe(window, 'load', fireContentLoadedEvent);
5847})();
5848
5849Element.addMethods();
5850
5851/*------------------------------- DEPRECATED -------------------------------*/
5852
5853Hash.toQueryString = Object.toQueryString;
5854
5855var Toggle = { display: Element.toggle };
5856
5857Element.Methods.childOf = Element.Methods.descendantOf;
5858
5859var Insertion = {
5860  Before: function(element, content) {
5861    return Element.insert(element, {before:content});
5862  },
5863
5864  Top: function(element, content) {
5865    return Element.insert(element, {top:content});
5866  },
5867
5868  Bottom: function(element, content) {
5869    return Element.insert(element, {bottom:content});
5870  },
5871
5872  After: function(element, content) {
5873    return Element.insert(element, {after:content});
5874  }
5875};
5876
5877var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
5878
5879var Position = {
5880  includeScrollOffsets: false,
5881
5882  prepare: function() {
5883    this.deltaX =  window.pageXOffset
5884                || document.documentElement.scrollLeft
5885                || document.body.scrollLeft
5886                || 0;
5887    this.deltaY =  window.pageYOffset
5888                || document.documentElement.scrollTop
5889                || document.body.scrollTop
5890                || 0;
5891  },
5892
5893  within: function(element, x, y) {
5894    if (this.includeScrollOffsets)
5895      return this.withinIncludingScrolloffsets(element, x, y);
5896    this.xcomp = x;
5897    this.ycomp = y;
5898    this.offset = Element.cumulativeOffset(element);
5899
5900    return (y >= this.offset[1] &&
5901            y <  this.offset[1] + element.offsetHeight &&
5902            x >= this.offset[0] &&
5903            x <  this.offset[0] + element.offsetWidth);
5904  },
5905
5906  withinIncludingScrolloffsets: function(element, x, y) {
5907    var offsetcache = Element.cumulativeScrollOffset(element);
5908
5909    this.xcomp = x + offsetcache[0] - this.deltaX;
5910    this.ycomp = y + offsetcache[1] - this.deltaY;
5911    this.offset = Element.cumulativeOffset(element);
5912
5913    return (this.ycomp >= this.offset[1] &&
5914            this.ycomp <  this.offset[1] + element.offsetHeight &&
5915            this.xcomp >= this.offset[0] &&
5916            this.xcomp <  this.offset[0] + element.offsetWidth);
5917  },
5918
5919  overlap: function(mode, element) {
5920    if (!mode) return 0;
5921    if (mode == 'vertical')
5922      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
5923        element.offsetHeight;
5924    if (mode == 'horizontal')
5925      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
5926        element.offsetWidth;
5927  },
5928
5929
5930  cumulativeOffset: Element.Methods.cumulativeOffset,
5931
5932  positionedOffset: Element.Methods.positionedOffset,
5933
5934  absolutize: function(element) {
5935    Position.prepare();
5936    return Element.absolutize(element);
5937  },
5938
5939  relativize: function(element) {
5940    Position.prepare();
5941    return Element.relativize(element);
5942  },
5943
5944  realOffset: Element.Methods.cumulativeScrollOffset,
5945
5946  offsetParent: Element.Methods.getOffsetParent,
5947
5948  page: Element.Methods.viewportOffset,
5949
5950  clone: function(source, target, options) {
5951    options = options || { };
5952    return Element.clonePosition(target, source, options);
5953  }
5954};
5955
5956/*--------------------------------------------------------------------------*/
5957
5958if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
5959  function iter(name) {
5960    return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
5961  }
5962
5963  instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
5964  function(element, className) {
5965    className = className.toString().strip();
5966    var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
5967    return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
5968  } : function(element, className) {
5969    className = className.toString().strip();
5970    var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
5971    if (!classNames && !className) return elements;
5972
5973    var nodes = $(element).getElementsByTagName('*');
5974    className = ' ' + className + ' ';
5975
5976    for (var i = 0, child, cn; child = nodes[i]; i++) {
5977      if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
5978          (classNames && classNames.all(function(name) {
5979            return !name.toString().blank() && cn.include(' ' + name + ' ');
5980          }))))
5981        elements.push(Element.extend(child));
5982    }
5983    return elements;
5984  };
5985
5986  return function(className, parentElement) {
5987    return $(parentElement || document.body).getElementsByClassName(className);
5988  };
5989}(Element.Methods);
5990
5991/*--------------------------------------------------------------------------*/
5992
5993Element.ClassNames = Class.create();
5994Element.ClassNames.prototype = {
5995  initialize: function(element) {
5996    this.element = $(element);
5997  },
5998
5999  _each: function(iterator) {
6000    this.element.className.split(/\s+/).select(function(name) {
6001      return name.length > 0;
6002    })._each(iterator);
6003  },
6004
6005  set: function(className) {
6006    this.element.className = className;
6007  },
6008
6009  add: function(classNameToAdd) {
6010    if (this.include(classNameToAdd)) return;
6011    this.set($A(this).concat(classNameToAdd).join(' '));
6012  },
6013
6014  remove: function(classNameToRemove) {
6015    if (!this.include(classNameToRemove)) return;
6016    this.set($A(this).without(classNameToRemove).join(' '));
6017  },
6018
6019  toString: function() {
6020    return $A(this).join(' ');
6021  }
6022};
6023
6024Object.extend(Element.ClassNames.prototype, Enumerable);
6025
6026/*--------------------------------------------------------------------------*/
6027
6028(function() {
6029  window.Selector = Class.create({
6030    initialize: function(expression) {
6031      this.expression = expression.strip();
6032    },
6033
6034    findElements: function(rootElement) {
6035      return Prototype.Selector.select(this.expression, rootElement);
6036    },
6037
6038    match: function(element) {
6039      return Prototype.Selector.match(element, this.expression);
6040    },
6041
6042    toString: function() {
6043      return this.expression;
6044    },
6045
6046    inspect: function() {
6047      return "#<Selector: " + this.expression + ">";
6048    }
6049  });
6050
6051  Object.extend(Selector, {
6052    matchElements: function(elements, expression) {
6053      var match = Prototype.Selector.match,
6054          results = [];
6055
6056      for (var i = 0, length = elements.length; i < length; i++) {
6057        var element = elements[i];
6058        if (match(element, expression)) {
6059          results.push(Element.extend(element));
6060        }
6061      }
6062      return results;
6063    },
6064
6065    findElement: function(elements, expression, index) {
6066      index = index || 0;
6067      var matchIndex = 0, element;
6068      for (var i = 0, length = elements.length; i < length; i++) {
6069        element = elements[i];
6070        if (Prototype.Selector.match(element, expression) && index === matchIndex++) {
6071          return Element.extend(element);
6072        }
6073      }
6074    },
6075
6076    findChildElements: function(element, expressions) {
6077      var selector = expressions.toArray().join(', ');
6078      return Prototype.Selector.select(selector, element || document);
6079    }
6080  });
6081})();
6082
6083
6084// script.aculo.us scriptaculous.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
6085
6086// Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
6087//
6088// Permission is hereby granted, free of charge, to any person obtaining
6089// a copy of this software and associated documentation files (the
6090// "Software"), to deal in the Software without restriction, including
6091// without limitation the rights to use, copy, modify, merge, publish,
6092// distribute, sublicense, and/or sell copies of the Software, and to
6093// permit persons to whom the Software is furnished to do so, subject to
6094// the following conditions:
6095//
6096// The above copyright notice and this permission notice shall be
6097// included in all copies or substantial portions of the Software.
6098//
6099// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6100// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6101// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6102// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
6103// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
6104// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
6105// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6106//
6107// For details, see the script.aculo.us web site: http://script.aculo.us/
6108
6109var Scriptaculous = {
6110  Version: '1.9.0',
6111  require: function(libraryName) {
6112    try{
6113      // inserting via DOM fails in Safari 2.0, so brute force approach
6114      document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
6115    } catch(e) {
6116      // for xhtml+xml served content, fall back to DOM methods
6117      var script = document.createElement('script');
6118      script.type = 'text/javascript';
6119      script.src = libraryName;
6120      document.getElementsByTagName('head')[0].appendChild(script);
6121    }
6122  },
6123  REQUIRED_PROTOTYPE: '1.6.0.3',
6124  load: function() {
6125    function convertVersionString(versionString) {
6126      var v = versionString.replace(/_.*|\./g, '');
6127      v = parseInt(v + '0'.times(4-v.length));
6128      return versionString.indexOf('_') > -1 ? v-1 : v;
6129    }
6130
6131    if((typeof Prototype=='undefined') ||
6132       (typeof Element == 'undefined') ||
6133       (typeof Element.Methods=='undefined') ||
6134       (convertVersionString(Prototype.Version) <
6135        convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
6136       throw("script.aculo.us requires the Prototype JavaScript framework >= " +
6137        Scriptaculous.REQUIRED_PROTOTYPE);
6138
6139    var js = /scriptaculous\.js(\?.*)?$/;
6140    $$('script[src]').findAll(function(s) {
6141      return s.src.match(js);
6142    }).each(function(s) {
6143      var path = s.src.replace(js, ''),
6144      includes = s.src.match(/\?.*load=([a-z,]*)/);
6145      (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
6146       function(include) { Scriptaculous.require(path+include+'.js') });
6147    });
6148  }
6149};
6150
6151Scriptaculous.load();
6152
6153// script.aculo.us effects.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010
6154
6155// Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
6156// Contributors:
6157//  Justin Palmer (http://encytemedia.com/)
6158//  Mark Pilgrim (http://diveintomark.org/)
6159//  Martin Bialasinki
6160//
6161// script.aculo.us is freely distributable under the terms of an MIT-style license.
6162// For details, see the script.aculo.us web site: http://script.aculo.us/
6163
6164// converts rgb() and #xxx to #xxxxxx format,
6165// returns self (or first argument) if not convertable
6166String.prototype.parseColor = function() {
6167  var color = '#';
6168  if (this.slice(0,4) == 'rgb(') {
6169    var cols = this.slice(4,this.length-1).split(',');
6170    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
6171  } else {
6172    if (this.slice(0,1) == '#') {
6173      if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
6174      if (this.length==7) color = this.toLowerCase();
6175    }
6176  }
6177  return (color.length==7 ? color : (arguments[0] || this));
6178};
6179
6180/*--------------------------------------------------------------------------*/
6181
6182Element.collectTextNodes = function(element) {
6183  return $A($(element).childNodes).collect( function(node) {
6184    return (node.nodeType==3 ? node.nodeValue :
6185      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
6186  }).flatten().join('');
6187};
6188
6189Element.collectTextNodesIgnoreClass = function(element, className) {
6190  return $A($(element).childNodes).collect( function(node) {
6191    return (node.nodeType==3 ? node.nodeValue :
6192      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?
6193        Element.collectTextNodesIgnoreClass(node, className) : ''));
6194  }).flatten().join('');
6195};
6196
6197Element.setContentZoom = function(element, percent) {
6198  element = $(element);
6199  element.setStyle({fontSize: (percent/100) + 'em'});
6200  if (Prototype.Browser.WebKit) window.scrollBy(0,0);
6201  return element;
6202};
6203
6204Element.getInlineOpacity = function(element){
6205  return $(element).style.opacity || '';
6206};
6207
6208Element.forceRerendering = function(element) {
6209  try {
6210    element = $(element);
6211    var n = document.createTextNode(' ');
6212    element.appendChild(n);
6213    element.removeChild(n);
6214  } catch(e) { }
6215};
6216
6217/*--------------------------------------------------------------------------*/
6218
6219var Effect = {
6220  _elementDoesNotExistError: {
6221    name: 'ElementDoesNotExistError',
6222    message: 'The specified DOM element does not exist, but is required for this effect to operate'
6223  },
6224  Transitions: {
6225    linear: Prototype.K,
6226    sinoidal: function(pos) {
6227      return (-Math.cos(pos*Math.PI)/2) + .5;
6228    },
6229    reverse: function(pos) {
6230      return 1-pos;
6231    },
6232    flicker: function(pos) {
6233      var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;
6234      return pos > 1 ? 1 : pos;
6235    },
6236    wobble: function(pos) {
6237      return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5;
6238    },
6239    pulse: function(pos, pulses) {
6240      return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5;
6241    },
6242    spring: function(pos) {
6243      return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));
6244    },
6245    none: function(pos) {
6246      return 0;
6247    },
6248    full: function(pos) {
6249      return 1;
6250    }
6251  },
6252  DefaultOptions: {
6253    duration:   1.0,   // seconds
6254    fps:        100,   // 100= assume 66fps max.
6255    sync:       false, // true for combining
6256    from:       0.0,
6257    to:         1.0,
6258    delay:      0.0,
6259    queue:      'parallel'
6260  },
6261  tagifyText: function(element) {
6262    var tagifyStyle = 'position:relative';
6263    if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';
6264
6265    element = $(element);
6266    $A(element.childNodes).each( function(child) {
6267      if (child.nodeType==3) {
6268        child.nodeValue.toArray().each( function(character) {
6269          element.insertBefore(
6270            new Element('span', {style: tagifyStyle}).update(
6271              character == ' ' ? String.fromCharCode(160) : character),
6272              child);
6273        });
6274        Element.remove(child);
6275      }
6276    });
6277  },
6278  multiple: function(element, effect) {
6279    var elements;
6280    if (((typeof element == 'object') ||
6281        Object.isFunction(element)) &&
6282       (element.length))
6283      elements = element;
6284    else
6285      elements = $(element).childNodes;
6286
6287    var options = Object.extend({
6288      speed: 0.1,
6289      delay: 0.0
6290    }, arguments[2] || { });
6291    var masterDelay = options.delay;
6292
6293    $A(elements).each( function(element, index) {
6294      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
6295    });
6296  },
6297  PAIRS: {
6298    'slide':  ['SlideDown','SlideUp'],
6299    'blind':  ['BlindDown','BlindUp'],
6300    'appear': ['Appear','Fade']
6301  },
6302  toggle: function(element, effect, options) {
6303    element = $(element);
6304    effect  = (effect || 'appear').toLowerCase();
6305    
6306    return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
6307      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
6308    }, options || {}));
6309  }
6310};
6311
6312Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
6313
6314/* ------------- core effects ------------- */
6315
6316Effect.ScopedQueue = Class.create(Enumerable, {
6317  initialize: function() {
6318    this.effects  = [];
6319    this.interval = null;
6320  },
6321  _each: function(iterator) {
6322    this.effects._each(iterator);
6323  },
6324  add: function(effect) {
6325    var timestamp = new Date().getTime();
6326
6327    var position = Object.isString(effect.options.queue) ?
6328      effect.options.queue : effect.options.queue.position;
6329
6330    switch(position) {
6331      case 'front':
6332        // move unstarted effects after this effect
6333        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
6334            e.startOn  += effect.finishOn;
6335            e.finishOn += effect.finishOn;
6336          });
6337        break;
6338      case 'with-last':
6339        timestamp = this.effects.pluck('startOn').max() || timestamp;
6340        break;
6341      case 'end':
6342        // start effect after last queued effect has finished
6343        timestamp = this.effects.pluck('finishOn').max() || timestamp;
6344        break;
6345    }
6346
6347    effect.startOn  += timestamp;
6348    effect.finishOn += timestamp;
6349
6350    if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
6351      this.effects.push(effect);
6352
6353    if (!this.interval)
6354      this.interval = setInterval(this.loop.bind(this), 15);
6355  },
6356  remove: function(effect) {
6357    this.effects = this.effects.reject(function(e) { return e==effect });
6358    if (this.effects.length == 0) {
6359      clearInterval(this.interval);
6360      this.interval = null;
6361    }
6362  },
6363  loop: function() {
6364    var timePos = new Date().getTime();
6365    for(var i=0, len=this.effects.length;i<len;i++)
6366      this.effects[i] && this.effects[i].loop(timePos);
6367  }
6368});
6369
6370Effect.Queues = {
6371  instances: $H(),
6372  get: function(queueName) {
6373    if (!Object.isString(queueName)) return queueName;
6374
6375    return this.instances.get(queueName) ||
6376      this.instances.set(queueName, new Effect.ScopedQueue());
6377  }
6378};
6379Effect.Queue = Effect.Queues.get('global');
6380
6381Effect.Base = Class.create({
6382  position: null,
6383  start: function(options) {
6384    if (options && options.transition === false) options.transition = Effect.Transitions.linear;
6385    this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
6386    this.currentFrame = 0;
6387    this.state        = 'idle';
6388    this.startOn      = this.options.delay*1000;
6389    this.finishOn     = this.startOn+(this.options.duration*1000);
6390    this.fromToDelta  = this.options.to-this.options.from;
6391    this.totalTime    = this.finishOn-this.startOn;
6392    this.totalFrames  = this.options.fps*this.options.duration;
6393
6394    this.render = (function() {
6395      function dispatch(effect, eventName) {
6396        if (effect.options[eventName + 'Internal'])
6397          effect.options[eventName + 'Internal'](effect);
6398        if (effect.options[eventName])
6399          effect.options[eventName](effect);
6400      }
6401
6402      return function(pos) {
6403        if (this.state === "idle") {
6404          this.state = "running";
6405          dispatch(this, 'beforeSetup');
6406          if (this.setup) this.setup();
6407          dispatch(this, 'afterSetup');
6408        }
6409        if (this.state === "running") {
6410          pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from;
6411          this.position = pos;
6412          dispatch(this, 'beforeUpdate');
6413          if (this.update) this.update(pos);
6414          dispatch(this, 'afterUpdate');
6415        }
6416      };
6417    })();
6418
6419    this.event('beforeStart');
6420    if (!this.options.sync)
6421      Effect.Queues.get(Object.isString(this.options.queue) ?
6422        'global' : this.options.queue.scope).add(this);
6423  },
6424  loop: function(timePos) {
6425    if (timePos >= this.startOn) {
6426      if (timePos >= this.finishOn) {
6427        this.render(1.0);
6428        this.cancel();
6429        this.event('beforeFinish');
6430        if (this.finish) this.finish();
6431        this.event('afterFinish');
6432        return;
6433      }
6434      var pos   = (timePos - this.startOn) / this.totalTime,
6435          frame = (pos * this.totalFrames).round();
6436      if (frame > this.currentFrame) {
6437        this.render(pos);
6438        this.currentFrame = frame;
6439      }
6440    }
6441  },
6442  cancel: function() {
6443    if (!this.options.sync)
6444      Effect.Queues.get(Object.isString(this.options.queue) ?
6445        'global' : this.options.queue.scope).remove(this);
6446    this.state = 'finished';
6447  },
6448  event: function(eventName) {
6449    if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
6450    if (this.options[eventName]) this.options[eventName](this);
6451  },
6452  inspect: function() {
6453    var data = $H();
6454    for(property in this)
6455      if (!Object.isFunction(this[property])) data.set(property, this[property]);
6456    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';
6457  }
6458});
6459
6460Effect.Parallel = Class.create(Effect.Base, {
6461  initialize: function(effects) {
6462    this.effects = effects || [];
6463    this.start(arguments[1]);
6464  },
6465  update: function(position) {
6466    this.effects.invoke('render', position);
6467  },
6468  finish: function(position) {
6469    this.effects.each( function(effect) {
6470      effect.render(1.0);
6471      effect.cancel();
6472      effect.event('beforeFinish');
6473      if (effect.finish) effect.finish(position);
6474      effect.event('afterFinish');
6475    });
6476  }
6477});
6478
6479Effect.Tween = Class.create(Effect.Base, {
6480  initialize: function(object, from, to) {
6481    object = Object.isString(object) ? $(object) : object;
6482    var args = $A(arguments), method = args.last(),
6483      options = args.length == 5 ? args[3] : null;
6484    this.method = Object.isFunction(method) ? method.bind(object) :
6485      Object.isFunction(object[method]) ? object[method].bind(object) :
6486      function(value) { object[method] = value };
6487    this.start(Object.extend({ from: from, to: to }, options || { }));
6488  },
6489  update: function(position) {
6490    this.method(position);
6491  }
6492});
6493
6494Effect.Event = Class.create(Effect.Base, {
6495  initialize: function() {
6496    this.start(Object.extend({ duration: 0 }, arguments[0] || { }));
6497  },
6498  update: Prototype.emptyFunction
6499});
6500
6501Effect.Opacity = Class.create(Effect.Base, {
6502  initialize: function(element) {
6503    this.element = $(element);
6504    if (!this.element) throw(Effect._elementDoesNotExistError);
6505    // make this work on IE on elements without 'layout'
6506    if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
6507      this.element.setStyle({zoom: 1});
6508    var options = Object.extend({
6509      from: this.element.getOpacity() || 0.0,
6510      to:   1.0
6511    }, arguments[1] || { });
6512    this.start(options);
6513  },
6514  update: function(position) {
6515    this.element.setOpacity(position);
6516  }
6517});
6518
6519Effect.Move = Class.create(Effect.Base, {
6520  initialize: function(element) {
6521    this.element = $(element);
6522    if (!this.element) throw(Effect._elementDoesNotExistError);
6523    var options = Object.extend({
6524      x:    0,
6525      y:    0,
6526      mode: 'relative'
6527    }, arguments[1] || { });
6528    this.start(options);
6529  },
6530  setup: function() {
6531    this.element.makePositioned();
6532    this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
6533    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');
6534    if (this.options.mode == 'absolute') {
6535      this.options.x = this.options.x - this.originalLeft;
6536      this.options.y = this.options.y - this.originalTop;
6537    }
6538  },
6539  update: function(position) {
6540    this.element.setStyle({
6541      left: (this.options.x  * position + this.originalLeft).round() + 'px',
6542      top:  (this.options.y  * position + this.originalTop).round()  + 'px'
6543    });
6544  }
6545});
6546
6547// for backwards compatibility
6548Effect.MoveBy = function(element, toTop, toLeft) {
6549  return new Effect.Move(element,
6550    Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));
6551};
6552
6553Effect.Scale = Class.create(Effect.Base, {
6554  initialize: function(element, percent) {
6555    this.element = $(element);
6556    if (!this.element) throw(Effect._elementDoesNotExistError);
6557    var options = Object.extend({
6558      scaleX: true,
6559      scaleY: true,
6560      scaleContent: true,
6561      scaleFromCenter: false,
6562      scaleMode: 'box',        // 'box' or 'contents' or { } with provided values
6563      scaleFrom: 100.0,
6564      scaleTo:   percent
6565    }, arguments[2] || { });
6566    this.start(options);
6567  },
6568  setup: function() {
6569    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
6570    this.elementPositioning = this.element.getStyle('position');
6571
6572    this.originalStyle = { };
6573    ['top','left','width','height','fontSize'].each( function(k) {
6574      this.originalStyle[k] = this.element.style[k];
6575    }.bind(this));
6576
6577    this.originalTop  = this.element.offsetTop;
6578    this.originalLeft = this.element.offsetLeft;
6579
6580    var fontSize = this.element.getStyle('font-size') || '100%';
6581    ['em','px','%','pt'].each( function(fontSizeType) {
6582      if (fontSize.indexOf(fontSizeType)>0) {
6583        this.fontSize     = parseFloat(fontSize);
6584        this.fontSizeType = fontSizeType;
6585      }
6586    }.bind(this));
6587
6588    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
6589
6590    this.dims = null;
6591    if (this.options.scaleMode=='box')
6592      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
6593    if (/^content/.test(this.options.scaleMode))
6594      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
6595    if (!this.dims)
6596      this.dims = [this.options.scaleMode.originalHeight,
6597                   this.options.scaleMode.originalWidth];
6598  },
6599  update: function(position) {
6600    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
6601    if (this.options.scaleContent && this.fontSize)
6602      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
6603    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
6604  },
6605  finish: function(position) {
6606    if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
6607  },
6608  setDimensions: function(height, width) {
6609    var d = { };
6610    if (this.options.scaleX) d.width = width.round() + 'px';
6611    if (this.options.scaleY) d.height = height.round() + 'px';
6612    if (this.options.scaleFromCenter) {
6613      var topd  = (height - this.dims[0])/2;
6614      var leftd = (width  - this.dims[1])/2;
6615      if (this.elementPositioning == 'absolute') {
6616        if (this.options.scaleY) d.top = this.originalTop-topd + 'px';
6617        if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
6618      } else {
6619        if (this.options.scaleY) d.top = -topd + 'px';
6620        if (this.options.scaleX) d.left = -leftd + 'px';
6621      }
6622    }
6623    this.element.setStyle(d);
6624  }
6625});
6626
6627Effect.Highlight = Class.create(Effect.Base, {
6628  initialize: function(element) {
6629    this.element = $(element);
6630    if (!this.element) throw(Effect._elementDoesNotExistError);
6631    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });
6632    this.start(options);
6633  },
6634  setup: function() {
6635    // Prevent executing on elements not in the layout flow
6636    if (this.element.getStyle('display')=='none') { this.cancel(); return; }
6637    // Disable background image during the effect
6638    this.oldStyle = { };
6639    if (!this.options.keepBackgroundImage) {
6640      this.oldStyle.backgroundImage = this.element.getStyle('background-image');
6641      this.element.setStyle({backgroundImage: 'none'});
6642    }
6643    if (!this.options.endcolor)
6644      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
6645    if (!this.options.restorecolor)
6646      this.options.restorecolor = this.element.getStyle('background-color');
6647    // init color calculations
6648    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
6649    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
6650  },
6651  update: function(position) {
6652    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
6653      return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });
6654  },
6655  finish: function() {
6656    this.element.setStyle(Object.extend(this.oldStyle, {
6657      backgroundColor: this.options.restorecolor
6658    }));
6659  }
6660});
6661
6662Effect.ScrollTo = function(element) {
6663  var options = arguments[1] || { },
6664  scrollOffsets = document.viewport.getScrollOffsets(),
6665  elementOffsets = $(element).cumulativeOffset();
6666
6667  if (options.offset) elementOffsets[1] += options.offset;
6668
6669  return new Effect.Tween(null,
6670    scrollOffsets.top,
6671    elementOffsets[1],
6672    options,
6673    function(p){ scrollTo(scrollOffsets.left, p.round()); }
6674  );
6675};
6676
6677/* ------------- combination effects ------------- */
6678
6679Effect.Fade = function(element) {
6680  element = $(element);
6681  var oldOpacity = element.getInlineOpacity();
6682  var options = Object.extend({
6683    from: element.getOpacity() || 1.0,
6684    to:   0.0,
6685    afterFinishInternal: function(effect) {
6686      if (effect.options.to!=0) return;
6687      effect.element.hide().setStyle({opacity: oldOpacity});
6688    }
6689  }, arguments[1] || { });
6690  return new Effect.Opacity(element,options);
6691};
6692
6693Effect.Appear = function(element) {
6694  element = $(element);
6695  var options = Object.extend({
6696  from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),
6697  to:   1.0,
6698  // force Safari to render floated elements properly
6699  afterFinishInternal: function(effect) {
6700    effect.element.forceRerendering();
6701  },
6702  beforeSetup: function(effect) {
6703    effect.element.setOpacity(effect.options.from).show();
6704  }}, arguments[1] || { });
6705  return new Effect.Opacity(element,options);
6706};
6707
6708Effect.Puff = function(element) {
6709  element = $(element);
6710  var oldStyle = {
6711    opacity: element.getInlineOpacity(),
6712    position: element.getStyle('position'),
6713    top:  element.style.top,
6714    left: element.style.left,
6715    width: element.style.width,
6716    height: element.style.height
6717  };
6718  return new Effect.Parallel(
6719   [ new Effect.Scale(element, 200,
6720      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
6721     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
6722     Object.extend({ duration: 1.0,
6723      beforeSetupInternal: function(effect) {
6724        Position.absolutize(effect.effects[0].element);
6725      },
6726      afterFinishInternal: function(effect) {
6727         effect.effects[0].element.hide().setStyle(oldStyle); }
6728     }, arguments[1] || { })
6729   );
6730};
6731
6732Effect.BlindUp = function(element) {
6733  element = $(element);
6734  element.makeClipping();
6735  return new Effect.Scale(element, 0,
6736    Object.extend({ scaleContent: false,
6737      scaleX: false,
6738      restoreAfterFinish: true,
6739      afterFinishInternal: function(effect) {
6740        effect.element.hide().undoClipping();
6741      }
6742    }, arguments[1] || { })
6743  );
6744};
6745
6746Effect.BlindDown = function(element) {
6747  element = $(element);
6748  var elementDimensions = element.getDimensions();
6749  return new Effect.Scale(element, 100, Object.extend({
6750    scaleContent: false,
6751    scaleX: false,
6752    scaleFrom: 0,
6753    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
6754    restoreAfterFinish: true,
6755    afterSetup: function(effect) {
6756      effect.element.makeClipping().setStyle({height: '0px'}).show();
6757    },
6758    afterFinishInternal: function(effect) {
6759      effect.element.undoClipping();
6760    }
6761  }, arguments[1] || { }));
6762};
6763
6764Effect.SwitchOff = function(element) {
6765  element = $(element);
6766  var oldOpacity = element.getInlineOpacity();
6767  return new Effect.Appear(element, Object.extend({
6768    duration: 0.4,
6769    from: 0,
6770    transition: Effect.Transitions.flicker,
6771    afterFinishInternal: function(effect) {
6772      new Effect.Scale(effect.element, 1, {
6773        duration: 0.3, scaleFromCenter: true,
6774        scaleX: false, scaleContent: false, restoreAfterFinish: true,
6775        beforeSetup: function(effect) {
6776          effect.element.makePositioned().makeClipping();
6777        },
6778        afterFinishInternal: function(effect) {
6779          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});
6780        }
6781      });
6782    }
6783  }, arguments[1] || { }));
6784};
6785
6786Effect.DropOut = function(element) {
6787  element = $(element);
6788  var oldStyle = {
6789    top: element.getStyle('top'),
6790    left: element.getStyle('left'),
6791    opacity: element.getInlineOpacity() };
6792  return new Effect.Parallel(
6793    [ new Effect.Move(element, {x: 0, y: 100, sync: true }),
6794      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
6795    Object.extend(
6796      { duration: 0.5,
6797        beforeSetup: function(effect) {
6798          effect.effects[0].element.makePositioned();
6799        },
6800        afterFinishInternal: function(effect) {
6801          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);
6802        }
6803      }, arguments[1] || { }));
6804};
6805
6806Effect.Shake = function(element) {
6807  element = $(element);
6808  var options = Object.extend({
6809    distance: 20,
6810    duration: 0.5
6811  }, arguments[1] || {});
6812  var distance = parseFloat(options.distance);
6813  var split = parseFloat(options.duration) / 10.0;
6814  var oldStyle = {
6815    top: element.getStyle('top'),
6816    left: element.getStyle('left') };
6817    return new Effect.Move(element,
6818      { x:  distance, y: 0, duration: split, afterFinishInternal: function(effect) {
6819    new Effect.Move(effect.element,
6820      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
6821    new Effect.Move(effect.element,
6822      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
6823    new Effect.Move(effect.element,
6824      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
6825    new Effect.Move(effect.element,
6826      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {
6827    new Effect.Move(effect.element,
6828      { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {
6829        effect.element.undoPositioned().setStyle(oldStyle);
6830  }}); }}); }}); }}); }}); }});
6831};
6832
6833Effect.SlideDown = function(element) {
6834  element = $(element).cleanWhitespace();
6835  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
6836  var oldInnerBottom = element.down().getStyle('bottom');
6837  var elementDimensions = element.getDimensions();
6838  return new Effect.Scale(element, 100, Object.extend({
6839    scaleContent: false,
6840    scaleX: false,
6841    scaleFrom: window.opera ? 0 : 1,
6842    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
6843    restoreAfterFinish: true,
6844    afterSetup: function(effect) {
6845      effect.element.makePositioned();
6846      effect.element.down().makePositioned();
6847      if (window.opera) effect.element.setStyle({top: ''});
6848      effect.element.makeClipping().setStyle({height: '0px'}).show();
6849    },
6850    afterUpdateInternal: function(effect) {
6851      effect.element.down().setStyle({bottom:
6852        (effect.dims[0] - effect.element.clientHeight) + 'px' });
6853    },
6854    afterFinishInternal: function(effect) {
6855      effect.element.undoClipping().undoPositioned();
6856      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
6857    }, arguments[1] || { })
6858  );
6859};
6860
6861Effect.SlideUp = function(element) {
6862  element = $(element).cleanWhitespace();
6863  var oldInnerBottom = element.down().getStyle('bottom');
6864  var elementDimensions = element.getDimensions();
6865  return new Effect.Scale(element, window.opera ? 0 : 1,
6866   Object.extend({ scaleContent: false,
6867    scaleX: false,
6868    scaleMode: 'box',
6869    scaleFrom: 100,
6870    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
6871    restoreAfterFinish: true,
6872    afterSetup: function(effect) {
6873      effect.element.makePositioned();
6874      effect.element.down().makePositioned();
6875      if (window.opera) effect.element.setStyle({top: ''});
6876      effect.element.makeClipping().show();
6877    },
6878    afterUpdateInternal: function(effect) {
6879      effect.element.down().setStyle({bottom:
6880        (effect.dims[0] - effect.element.clientHeight) + 'px' });
6881    },
6882    afterFinishInternal: function(effect) {
6883      effect.element.hide().undoClipping().undoPositioned();
6884      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});
6885    }
6886   }, arguments[1] || { })
6887  );
6888};
6889
6890// Bug in opera makes the TD containing this element expand for a instance after finish
6891Effect.Squish = function(element) {
6892  return new Effect.Scale(element, window.opera ? 1 : 0, {
6893    restoreAfterFinish: true,
6894    beforeSetup: function(effect) {
6895      effect.element.makeClipping();
6896    },
6897    afterFinishInternal: function(effect) {
6898      effect.element.hide().undoClipping();
6899    }
6900  });
6901};
6902
6903Effect.Grow = function(element) {
6904  element = $(element);
6905  var options = Object.extend({
6906    direction: 'center',
6907    moveTransition: Effect.Transitions.sinoidal,
6908    scaleTransition: Effect.Transitions.sinoidal,
6909    opacityTransition: Effect.Transitions.full
6910  }, arguments[1] || { });
6911  var oldStyle = {
6912    top: element.style.top,
6913    left: element.style.left,
6914    height: element.style.height,
6915    width: element.style.width,
6916    opacity: element.getInlineOpacity() };
6917
6918  var dims = element.getDimensions();
6919  var initialMoveX, initialMoveY;
6920  var moveX, moveY;
6921
6922  switch (options.direction) {
6923    case 'top-left':
6924      initialMoveX = initialMoveY = moveX = moveY = 0;
6925      break;
6926    case 'top-right':
6927      initialMoveX = dims.width;
6928      initialMoveY = moveY = 0;
6929      moveX = -dims.width;
6930      break;
6931    case 'bottom-left':
6932      initialMoveX = moveX = 0;
6933      initialMoveY = dims.height;
6934      moveY = -dims.height;
6935      break;
6936    case 'bottom-right':
6937      initialMoveX = dims.width;
6938      initialMoveY = dims.height;
6939      moveX = -dims.width;
6940      moveY = -dims.height;
6941      break;
6942    case 'center':
6943      initialMoveX = dims.width / 2;
6944      initialMoveY = dims.height / 2;
6945      moveX = -dims.width / 2;
6946      moveY = -dims.height / 2;
6947      break;
6948  }
6949
6950  return new Effect.Move(element, {
6951    x: initialMoveX,
6952    y: initialMoveY,
6953    duration: 0.01,
6954    beforeSetup: function(effect) {
6955      effect.element.hide().makeClipping().makePositioned();
6956    },
6957    afterFinishInternal: function(effect) {
6958      new Effect.Parallel(
6959        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),
6960          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),
6961          new Effect.Scale(effect.element, 100, {
6962            scaleMode: { originalHeight: dims.height, originalWidth: dims.width },
6963            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})
6964        ], Object.extend({
6965             beforeSetup: function(effect) {
6966               effect.effects[0].element.setStyle({height: '0px'}).show();
6967             },
6968             afterFinishInternal: function(effect) {
6969               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);
6970             }
6971           }, options)
6972      );
6973    }
6974  });
6975};
6976
6977Effect.Shrink = function(element) {
6978  element = $(element);
6979  var options = Object.extend({
6980    direction: 'center',
6981    moveTransition: Effect.Transitions.sinoidal,
6982    scaleTransition: Effect.Transitions.sinoidal,
6983    opacityTransition: Effect.Transitions.none
6984  }, arguments[1] || { });
6985  var oldStyle = {
6986    top: element.style.top,
6987    left: element.style.left,
6988    height: element.style.height,
6989    width: element.style.width,
6990    opacity: element.getInlineOpacity() };
6991
6992  var dims = element.getDimensions();
6993  var moveX, moveY;
6994
6995  switch (options.direction) {
6996    case 'top-left':
6997      moveX = moveY = 0;
6998      break;
6999    case 'top-right':
7000      moveX = dims.width;
7001      moveY = 0;
7002      break;
7003    case 'bottom-left':
7004      moveX = 0;
7005      moveY = dims.height;
7006      break;
7007    case 'bottom-right':
7008      moveX = dims.width;
7009      moveY = dims.height;
7010      break;
7011    case 'center':
7012      moveX = dims.width / 2;
7013      moveY = dims.height / 2;
7014      break;
7015  }
7016
7017  return new Effect.Parallel(
7018    [ new Effect.Opacity(elemen
7018t, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),
7019      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),
7020      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })
7021    ], Object.extend({
7022         beforeStartInternal: function(effect) {
7023           effect.effects[0].element.makePositioned().makeClipping();
7024         },
7025         afterFinishInternal: function(effect) {
7026           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }
7027       }, options)
7028  );
7029};
7030
7031Effect.Pulsate = function(element) {
7032  element = $(element);
7033  var options    = arguments[1] || { },
7034    oldOpacity = element.getInlineOpacity(),
7035    transition = options.transition || Effect.Transitions.linear,
7036    reverser   = function(pos){
7037      return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5);
7038    };
7039
7040  return new Effect.Opacity(element,
7041    Object.extend(Object.extend({  duration: 2.0, from: 0,
7042      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }
7043    }, options), {transition: reverser}));
7044};
7045
7046Effect.Fold = function(element) {
7047  element = $(element);
7048  var oldStyle = {
7049    top: element.style.top,
7050    left: element.style.left,
7051    width: element.style.width,
7052    height: element.style.height };
7053  element.makeClipping();
7054  return new Effect.Scale(element, 5, Object.extend({
7055    scaleContent: false,
7056    scaleX: false,
7057    afterFinishInternal: function(effect) {
7058    new Effect.Scale(element, 1, {
7059      scaleContent: false,
7060      scaleY: false,
7061      afterFinishInternal: function(effect) {
7062        effect.element.hide().undoClipping().setStyle(oldStyle);
7063      } });
7064  }}, arguments[1] || { }));
7065};
7066
7067Effect.Morph = Class.create(Effect.Base, {
7068  initialize: function(element) {
7069    this.element = $(element);
7070    if (!this.element) throw(Effect._elementDoesNotExistError);
7071    var options = Object.extend({
7072      style: { }
7073    }, arguments[1] || { });
7074
7075    if (!Object.isString(options.style)) this.style = $H(options.style);
7076    else {
7077      if (options.style.include(':'))
7078        this.style = options.style.parseStyle();
7079      else {
7080        this.element.addClassName(options.style);
7081        this.style = $H(this.element.getStyles());
7082        this.element.removeClassName(options.style);
7083        var css = this.element.getStyles();
7084        this.style = this.style.reject(function(style) {
7085          return style.value == css[style.key];
7086        });
7087        options.afterFinishInternal = function(effect) {
7088          effect.element.addClassName(effect.options.style);
7089          effect.transforms.each(function(transform) {
7090            effect.element.style[transform.style] = '';
7091          });
7092        };
7093      }
7094    }
7095    this.start(options);
7096  },
7097
7098  setup: function(){
7099    function parseColor(color){
7100      if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
7101      color = color.parseColor();
7102      return $R(0,2).map(function(i){
7103        return parseInt( color.slice(i*2+1,i*2+3), 16 );
7104      });
7105    }
7106    this.transforms = this.style.map(function(pair){
7107      var property = pair[0], value = pair[1], unit = null;
7108
7109      if (value.parseColor('#zzzzzz') != '#zzzzzz') {
7110        value = value.parseColor();
7111        unit  = 'color';
7112      } else if (property == 'opacity') {
7113        value = parseFloat(value);
7114        if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))
7115          this.element.setStyle({zoom: 1});
7116      } else if (Element.CSS_LENGTH.test(value)) {
7117          var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
7118          value = parseFloat(components[1]);
7119          unit = (components.length == 3) ? components[2] : null;
7120      }
7121
7122      var originalValue = this.element.getStyle(property);
7123      return {
7124        style: property.camelize(),
7125        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),
7126        targetValue: unit=='color' ? parseColor(value) : value,
7127        unit: unit
7128      };
7129    }.bind(this)).reject(function(transform){
7130      return (
7131        (transform.originalValue == transform.targetValue) ||
7132        (
7133          transform.unit != 'color' &&
7134          (isNaN(transform.originalValue) || isNaN(transform.targetValue))
7135        )
7136      );
7137    });
7138  },
7139  update: function(position) {
7140    var style = { }, transform, i = this.transforms.length;
7141    while(i--)
7142      style[(transform = this.transforms[i]).style] =
7143        transform.unit=='color' ? '#'+
7144          (Math.round(transform.originalValue[0]+
7145            (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +
7146          (Math.round(transform.originalValue[1]+
7147            (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +
7148          (Math.round(transform.originalValue[2]+
7149            (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :
7150        (transform.originalValue +
7151          (transform.targetValue - transform.originalValue) * position).toFixed(3) +
7152            (transform.unit === null ? '' : transform.unit);
7153    this.element.setStyle(style, true);
7154  }
7155});
7156
7157Effect.Transform = Class.create({
7158  initialize: function(tracks){
7159    this.tracks  = [];
7160    this.options = arguments[1] || { };
7161    this.addTracks(tracks);
7162  },
7163  addTracks: function(tracks){
7164    tracks.each(function(track){
7165      track = $H(track);
7166      var data = track.values().first();
7167      this.tracks.push($H({
7168        ids:     track.keys().first(),
7169        effect:  Effect.Morph,
7170        options: { style: data }
7171      }));
7172    }.bind(this));
7173    return this;
7174  },
7175  play: function(){
7176    return new Effect.Parallel(
7177      this.tracks.map(function(track){
7178        var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');
7179        var elements = [$(ids) || $$(ids)].flatten();
7180        return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });
7181      }).flatten(),
7182      this.options
7183    );
7184  }
7185});
7186
7187Element.CSS_PROPERTIES = $w(
7188  'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +
7189  'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +
7190  'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +
7191  'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +
7192  'fontSize fontWeight height left letterSpacing lineHeight ' +
7193  'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+
7194  'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +
7195  'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +
7196  'right textIndent top width wordSpacing zIndex');
7197
7198Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
7199
7200String.__parseStyleElement = document.createElement('div');
7201String.prototype.parseStyle = function(){
7202  var style, styleRules = $H();
7203  if (Prototype.Browser.WebKit)
7204    style = new Element('div',{style:this}).style;
7205  else {
7206    String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
7207    style = String.__parseStyleElement.childNodes[0].style;
7208  }
7209
7210  Element.CSS_PROPERTIES.each(function(property){
7211    if (style[property]) styleRules.set(property, style[property]);
7212  });
7213
7214  if (Prototype.Browser.IE && this.include('opacity'))
7215    styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);
7216
7217  return styleRules;
7218};
7219
7220if (document.defaultView && document.defaultView.getComputedStyle) {
7221  Element.getStyles = function(element) {
7222    var css = document.defaultView.getComputedStyle($(element), null);
7223    return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {
7224      styles[property] = css[property];
7225      return styles;
7226    });
7227  };
7228} else {
7229  Element.getStyles = function(element) {
7230    element = $(element);
7231    var css = element.currentStyle, styles;
7232    styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) {
7233      results[property] = css[property];
7234      return results;
7235    });
7236    if (!styles.opacity) styles.opacity = element.getOpacity();
7237    return styles;
7238  };
7239}
7240
7241Effect.Methods = {
7242  morph: function(element, style) {
7243    element = $(element);
7244    new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));
7245    return element;
7246  },
7247  visualEffect: function(element, effect, options) {
7248    element = $(element);
7249    var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);
7250    new Effect[klass](element, options);
7251    return element;
7252  },
7253  highlight: function(element, options) {
7254    element = $(element);
7255    new Effect.Highlight(element, options);
7256    return element;
7257  }
7258};
7259
7260$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+
7261  'pulsate shake puff squish switchOff dropOut').each(
7262  function(effect) {
7263    Effect.Methods[effect] = function(element, options){
7264      element = $(element);
7265      Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);
7266      return element;
7267    };
7268  }
7269);
7270
7271$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(
7272  function(f) { Effect.Methods[f] = Element[f]; }
7273);
7274
7275Element.addMethods(Effect.Methods);
7276
7277/*
7278 * e107 website system
7279 *
7280 * Copyright (C) 2001-2008 e107 Inc (e107.org)
7281 * Released under the terms and conditions of the
7282 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
7283 *
7284 * e107 Javascript API
7285 *
7286 * $Source: /cvsroot/e107/e107_0.8/e107_files/jslib/e107.js.php,v $
7287 * $Revision: 1.23 $
7288 * $Date: 2009/01/16 17:57:57 $
7289 * $Author: secretr $
7290 *
7291*/
7292
7293var e107API = {
7294	Version: '1.0.1',
7295	ServerVersion: '0.8.1'
7296}
7297
7298/*
7299 * Old stuff
7300 * FIXME ASAP
7301 */
7302var nowLocal = new Date();		/* time at very beginning of js execution */
7303var localTime = Math.floor(nowLocal.getTime()/1000);	/* time, in ms -- recorded at top of jscript */
7304/**
7305 * NOTE: if serverDelta is needed for js functions, you must pull it from
7306 * the cookie (as calculated during a previous page load!)
7307 * The value calculated in SyncWithServerTime is not known until after the
7308 * entire page has been processed.
7309 */
7310function SyncWithServerTime(serverTime)
7311{
7312	if (serverTime)
7313	{
7314	  	/* update time difference cookie */
7315		var serverDelta=Math.floor(localTime-serverTime);
7316	  	document.cookie = 'e107_tdOffset='+serverDelta+'; path=/';
7317	  	document.cookie = 'e107_tdSetTime='+(localTime-serverDelta)+'; path=/'; /* server time when set */
7318	}
7319
7320	var tzCookie = 'e107_tzOffset=';
7321//	if (document.cookie.indexOf(tzCookie) < 0) {
7322		/* set if not already set */
7323		var timezoneOffset = nowLocal.getTimezoneOffset(); /* client-to-GMT in minutes */
7324		document.cookie = tzCookie + timezoneOffset+'; path=/';
7325//	}
7326}
7327
7328// -------------------------------------------------------------------
7329
7330/**
7331 * Prototype Xtensions
7332 * @author    Simon Martins
7333 * @copyright (c) 2008 Netatoo SARL <http://www.netatoo.fr>
7334 * @license   MIT License <http://www.prototypextensions.com/#main=license>
7335 *
7336 * @desc Retrieve the browser version
7337 */
7338(function() {
7339    var nav       = navigator;
7340    var userAgent = ua = navigator.userAgent;
7341    var v         = nav.appVersion;
7342    var version   = parseFloat(v);
7343
7344    e107API.Browser = {
7345        IE      : (Prototype.Browser.IE)    ? parseFloat(v.split("MSIE ")[1]) || 0 : 0,
7346        Firefox : (Prototype.Browser.Gecko) ? parseFloat(ua.split("Firefox/")[1]) || 0 : 0,
7347        Camino  : (Prototype.Browser.Gecko) ? parseFloat(ua.split("Camino/")[1]) || 0 : 0,
7348        Flock   : (Prototype.Browser.Gecko) ? parseFloat(ua.split("Flock/")[1]) || 0 : 0,
7349        Opera   : (Prototype.Browser.Opera) ? version : 0,
7350        AIR     : (ua.indexOf("AdobeAIR") >= 0) ? 1 : 0,
7351        Mozilla : (Prototype.Browser.Gecko || !this.Khtml) ? version : 0,
7352        Khtml   : (v.indexOf("Konqueror") >= 0 && this.safari) ? version : 0,
7353        Safari  : (function() {
7354            var safari = Math.max(v.indexOf("WebKit"), v.indexOf("Safari"), 0);
7355            return (safari) ? (
7356                parseFloat(v.split("Version/")[1]) || ( ( parseFloat(v.substr(safari+7)) >= 419.3 ) ? 3 : 2 ) || 2
7357            ) : 0;
7358        })()
7359    };
7360})();
7361
7362// -------------------------------------------------------------------
7363
7364/**
7365 * Main registry object
7366 */
7367var e107Registry = {
7368
7369    //System Path
7370    Path: {
7371        e_IMAGE:    '/limno_images/',
7372        e_COMPAT: '/limno_plugins/cl_widgets/jslib/compat/',
7373        e_COMPAT_IMAGE: '/limno_plugins/cl_widgets/jslib/compat/images/',
7374        e_IMAGE_PACK:    '/limno_images/',
7375        e_PLUGIN:   '/limno_plugins/',
7376        e_FILE:     '/limno_files/',
7377        e_ADMIN: 	'',
7378        e_THEME:    '/limno_themes/',
7379        THEME:      '/limno_themes/human_condition/'
7380    },
7381
7382    //Language Constants
7383    Lan: {},
7384
7385    //Global Templates
7386    Template: {
7387    	Core: {
7388    		//e107Helper#duplicateHTML method
7389	        duplicateHTML:	'<div><div class="clear"><!-- --></div>' +
7390                           		'#{duplicateBody}' +
7391                           		'<a href="#" id="#{removeId}"><img src="#{e_IMAGE_PACK}admin_images/delete_16.png" class="icon action" style="vertical-align: middle" /></a>' +
7392                           	'</div>'
7393    	},
7394
7395    	//e107Helper#LoadingStatus class
7396    	CoreLoading:   {
7397    		template: 		'<div id="loading-mask">' +
7398								'<p id="loading-mask-loader" class="loader">' +
7399									'<img src="#{e_COMPAT_IMAGE}loading_32.gif" alt="#{JSLAN_CORE_LOADING_ALT}" />' +
7400									'<br /> <span class="loading-text">#{JSLAN_CORE_LOADING_TEXT}</span>' +
7401								'<p>' +
7402							'</div>'
7403    	}
7404    },
7405
7406    //Cache
7407    Cache: new Hash,
7408
7409    //Cached vars
7410    CachedVars: new Hash,
7411
7412    //Global Preferences
7413    Pref: {
7414    	Core: {
7415    		zIndex: 5 //base system z-index
7416    	}
7417    }
7418}
7419
7420// -------------------------------------------------------------------
7421
7422/**
7423 * Global helpers - server side clonings
7424 */
7425var isset = function(varname) {
7426    return !Object.isUndefined(varname);
7427}
7428
7429var varset = function(varname) {
7430    if(Object.isUndefined(varname)) {
7431        return (Object.isUndefined(arguments[1]) ? null : arguments[1]);
7432    }
7433    return varname;
7434}
7435
7436var varsettrue = function(varname) {
7437    if(Object.isUndefined(varname) || !varname) {
7438        return (Object.isUndefined(arguments[1]) ? null : arguments[1]);
7439    }
7440    return varname;
7441}
7442
7443var cachevars = function(varname, data) {
7444    e107Registry.CachedVars.set(data)
7445}
7446
7447var getcachedvars = function(varname, destroy) {
7448	if(destroy)
7449		return clearcachedvars(varname);
7450    return e107Registry.CachedVars.get(varname);
7451}
7452
7453var clearcachedvars = function(varname) {
7454    return e107Registry.CachedVars.unset(varname);
7455}
7456
7457var echo = Prototype.emptyFunction, print_a = Prototype.emptyFunction, var_dump = Prototype.emptyFunction;
7458
7459// -------------------------------------------------------------------
7460
7461
7462/**
7463 * e107 custom events
7464 */
7465var e107Event = {
7466
7467    fire: function(eventName, memo, element) {
7468    	if ((!element || element == document) && !document.createEvent)
7469    	{
7470    		element = $(document.documentElement);
7471    	}
7472    	else
7473    		element = $(element) || document;
7474    	memo = memo || {};
7475    	return element.fire('e107:' + eventName, memo);
7476    },
7477
7478    observe: function(eventName, handler, element) {
7479    	element = $(element) || document;
7480    	element.observe('e107:' + eventName, handler);
7481    	return this;
7482    },
7483
7484    stopObserving: function(eventName, handler, element) {
7485    	element = $(element) || document;
7486    	element.stopObserving('e107:' + eventName, handler);
7487    	return this;
7488    },
7489
7490    //Server side - e107_event aliases
7491    trigger: function(eventName, memo, element) {
7492    	this.fire(eventName, memo, element);
7493    },
7494
7495    register: function(eventName, handler, element) {
7496    	this.observe(eventName, handler, element);
7497    },
7498
7499    unregister:  function(eventName, handler, element) {
7500    	this.stopObserving(eventName, handler, element);
7501    }
7502}
7503
7504
7505
7506/**
7507 * EventManager
7508 * Prototype Xtensions http://www.prototypextensions.com
7509 *
7510 * @desc Create custom events on your own class
7511 */
7512var e107EventManager = Class.create({
7513
7514    /**
7515     * Initialize
7516     *
7517     * @desc Set scope and events hash
7518     */
7519    initialize: function(scope) {
7520        this.scope  = scope;
7521        this.events = new Hash();
7522    },
7523
7524    /**
7525     * addListener
7526     *
7527     * @desc Add event observer
7528     */
7529    addObserver: function(name) {
7530        return this.events.set(name, new Hash());
7531    },
7532
7533    /**
7534     * observe
7535     *
7536     * @desc Add a callback for listener 'name'
7537     */
7538    observe: function(name, callback) {
7539        var observers = this.events.get(name);
7540
7541        if(!observers) observers = this.addObserver(name);
7542
7543        if(!Object.isFunction(callback)) {
7544            //throw('e107EventManager.observe : callback must be an js function');
7545            //surpess error
7546            return this;
7547        }
7548
7549        var i = this.events.get(name).keys().length;
7550        observers.set(i, callback.bind(this.scope));
7551
7552        return this;
7553    },
7554
7555    /**
7556     * stopObserving (class improvements)
7557     *
7558     * @desc Remove callback for listener 'name'
7559     */
7560    stopObserving: function(name, callback) {
7561        var observers = this.events.get(name);
7562
7563        if(!observers) return this;
7564        observers.each( function(pair) {
7565        	if(pair.value == callback) {
7566        		observers.unset(pair.key);
7567        		$break;
7568        	}
7569        });
7570        return this;
7571    },
7572
7573    /**
7574     * notify
7575     *
7576     * @desc Launch all callbacks for listener 'name'
7577     */
7578    notify: function(name) {
7579        var observers = this.events.get(name);
7580        //console.log('notifying ' + name);
7581        if(observers) {
7582            var args = $A(arguments).slice(1);
7583            //Fix - preserve order
7584            observers.keys().sort().each( function(key) {
7585            	var callback = observers.get(key);
7586                if(Object.isFunction(callback)) {
7587                    callback.apply(this.scope, args);
7588                }
7589            });
7590        }
7591
7592        return this;
7593    }
7594
7595});
7596
7597// -------------------------------------------------------------------
7598
7599
7600/**
7601 * Base e107 Object - interacts with the registry object
7602 */
7603var e107Base = {
7604
7605    setPath: function(path_object) {
7606        e107Registry.Path = Object.extend( this.getPathVars(), path_object || {});
7607        return this;
7608    },
7609
7610    addPath: function(path_var, path) {
7611    	//don't allow overwrite
7612        if(!e107Registry.Path[path_var]) e107Registry.Path[path_var] = path;
7613        return this;
7614    },
7615
7616    getPathVars: function() {
7617        return e107Registry.Path;
7618    },
7619
7620    getPath: function(path_name) {
7621        return varset(e107Registry.Path[path_name]);
7622    },
7623
7624    _addLan: function(lan_name, lan_value) {
7625        e107Registry.Lan[lan_name] = lan_value;
7626        return this;
7627    },
7628
7629    _getLan: function(lan_name) {
7630        return varsettrue(e107Registry.Lan[lan_name], lan_name);
7631    },
7632
7633    setLan: function(lan_object) {
7634    	if(!arguments[1]) {
7635	        Object.keys(lan_object).each(function(key) {
7636	            this.addLan(key, lan_object[key]);
7637	        }, this);
7638	        return this
7639    	}
7640        Object.extend(e107Registry.Lan, (lan_object || {}));
7641        return this;
7642    },
7643
7644    addLan: function(lan_name, lan_value) {
7645        this._addLan(this.toLanName(lan_name), lan_value);
7646        return this;
7647    },
7648
7649    setModLan: function(mod, lan_object) {
7650    	Object.keys(lan_object).each( function(key) {
7651    		this.addModLan(mod, key, lan_object[key]);
7652    	}, this);
7653    	return this;
7654    },
7655
7656    addModLan: function(mod, lan_name, lan_value) {
7657        return this._addLan(this.toModLanName(mod, lan_name), lan_value);
7658    },
7659
7660    getLan: function(lan_name) {
7661        return this._getLan(this.toLanName(lan_name));
7662    },
7663
7664    getModLan: function(mod, lan_name) {
7665    	return this._getLan(this.toModLanName(mod, lan_name));
7666    },
7667
7668    getLanVars: function() {
7669        return e107Registry.Lan;
7670    },
7671
7672    getModLanVars: function(mod) {
7673    	return this.getLanFilter(this.toModLanName(mod));
7674    },
7675
7676    //Example e107.getLanRange('lan1 lan2 ...'); -- { LAN1: 'lan value1', LAN2: 'lan value2', ... }
7677    getLanRange: function(lan_keys) {
7678        var ret = {};
7679        $w(lan_keys).each( function(key) {
7680            this[key.toUpperCase()] = e107.getLan(key);
7681        }, ret);
7682        return ret;
7683    },
7684
7685    //Example e107.getLanFilter('lan_myplug'); -- { LAN_MYPLUG_1: 'lan value1', LAN_MYPLUG_2: 'lan value2', ... }
7686    getLanFilter: function(filter) {
7687        var ret = {};
7688        filter = filter.toUpperCase();
7689        $H(e107Registry.Lan).keys().each( function(key) {
7690            if(key.startsWith(filter)) {
7691                this[key] = e107Registry.Lan[key];
7692            }
7693        }, ret);
7694
7695        return ret;
7696    },
7697
7698    setTemplate: function(mod, tmpl_object) {
7699        mod = this.toModName(mod);
7700        if(!varset(e107Registry.Template[mod])) {
7701            e107Registry.Template[mod] = {};
7702        }
7703        Object.extend(e107Registry.Template[mod], (tmpl_object || {}));
7704
7705        return this;
7706    },
7707
7708    addTemplate: function(mod, name, tmpl_string) {
7709        mod = this.toModName(mod);
7710        if(!varset(e107Registry.Template[mod])) {
7711            e107Registry.Template[mod] = {};
7712        }
7713        e107Registry.Template[mod][name] = tmpl_string;
7714
7715        return this;
7716    },
7717
7718    getTemplates: function(mod) {
7719        return varsettrue(e107Registry.Template[this.toModName(mod)], {});
7720    },
7721
7722    getTemplate: function(mod, name) {
7723        mod = this.toModName(mod);
7724
7725        if(varset(e107Registry.Template[mod])) {
7726            return varsettrue(e107Registry.Template[mod][name], '');
7727        }
7728
7729        return '';
7730    },
7731
7732    setPrefs: function(mod, pref_object) {
7733        mod = this.toModName(mod);
7734        if(!varset(e107Registry.Pref[mod])) {
7735            e107Registry.Pref[mod] = {};
7736        }
7737        Object.extend(e107Registry.Pref[mod], (pref_object || {}));
7738
7739        return this;
7740    },
7741
7742    addPref: function(mod, pref_name, pref_value) {
7743        mod = this.toModName(mod);
7744        if(!varset(e107Registry.Pref[mod])) {
7745            e107Registry.Pref[mod] = {};
7746        }
7747        e107Registry.Pref[mod][pref_name] = pref_value;
7748
7749        return this;
7750    },
7751
7752    getPrefs: function(mod) {
7753        return varsettrue(e107Registry.Pref[this.toModName(mod)], {});
7754    },
7755
7756    getPref: function(mod, pref_name, def) {
7757        mod = this.toModName(mod);
7758        if(varset(e107Registry.Pref[mod])) {
7759            return varsettrue(e107Registry.Pref[mod][pref_name], varset(def, null));
7760        }
7761        return varset(def, null);
7762    },
7763
7764    setCache: function(cache_str, cache_item) {
7765    	this.clearCache(cache_str);
7766        e107Registry.Cache['cache-' + cache_str] = cache_item;
7767        return this;
7768    },
7769
7770    getCache: function(cache_str, def) {
7771        return varset(e107Registry.Cache['cache-' + cache_str], def);
7772    },
7773
7774    clearCache: function(cache_str, nodestroy) {
7775    	var cached = this.getCache(cache_str);
7776    	if(!nodestroy && cached && Object.isFunction(cached['destroy'])) cached.destroy();
7777    	e107Registry.Cache['cache-' + cache_str] = null;
7778    	delete e107Registry.Cache['cache-' + cache_str];
7779    	return this;
7780    },
7781
7782    parseTemplate: function(mod, name, data) {
7783        var cacheStr = mod + '_' + name;
7784        var cached = this.getCache(cacheStr);
7785        if(null === cached) {
7786            var tmp = this.getTemplate(mod, name);
7787            cached = new Template(tmp);
7788            this.setCache(cacheStr, cached);
7789        }
7790
7791        if(varsettrue(arguments[3])) {
7792            data = this.getParseData(Object.clone(data || {}));
7793        }
7794
7795        try{
7796           return cached.evaluate(data || {});
7797        } catch(e) {
7798            return '';
7799        }
7800    },
7801
7802    getParseData: function (data) {
7803        Object.extend(data || {},
7804          Object.extend(this.getLanVars(), this.getPathVars())
7805        );
7806
7807        return data;
7808    },
7809
7810    parseLan: function(str) {
7811        return String(str).interpolate(this.getLanVars());
7812    },
7813
7814    parsePath: function(str) {
7815        return String(str).interpolate(this.getPathVars());
7816    },
7817
7818    toModName: function(mod, raw) {
7819    	return raw ? mod.dasherize() : mod.dasherize().camelize().ucfirst();
7820    },
7821
7822    toLanName: function(lan) {
7823    	return 'JSLAN_' + lan.underscore().toUpperCase();
7824    },
7825
7826    toModLanName: function(raw_mod, lan) {
7827    	return this.toLanName(raw_mod + '_' + varset(lan, ''));
7828    }
7829};
7830
7831// -------------------------------------------------------------------
7832
7833/**
7834 * String Extensions
7835 *
7836 * Methods used later in the core + e107base shorthands
7837 */
7838Object.extend(String.prototype, {
7839
7840	//php like
7841    ucfirst: function() {
7842        return this.charAt(0).toUpperCase() + this.substring(1);
7843    },
7844
7845	//Create element from string - Prototype UI
7846	createElement: function() {
7847	    var wrapper = new Element('div'); wrapper.innerHTML = this;
7848	    return wrapper.down();
7849	},
7850
7851	parseToElement: function(data) {
7852		return this.parseTemplate(data).createElement();
7853	},
7854
7855	parseTemplate: function(data) {
7856		return this.interpolate(e107Base.getParseData(data || {}));
7857	},
7858
7859	parsePath: function() {
7860		return e107Base.parsePath(this);
7861	},
7862
7863	parseLan: function() {
7864		return e107Base.parseLan(this);
7865	},
7866
7867    addLan: function(lan_name) {
7868    	if(lan_name)
7869        	e107Base.addLan(lan_name, this);
7870        return e107Base.toLanName(lan_name);
7871    },
7872
7873    addModLan: function(mod, lan_name) {
7874    	if(mod && lan_name)
7875        	e107Base.addModLan(mod, lan_name, this);
7876        return e107Base.toModLanName(mod, lan_name);
7877    },
7878
7879    getLan: function() {
7880        return e107Base.getLan(this);
7881    },
7882
7883    getModLan: function(mod) {
7884    	if(mod)
7885    		return e107Base.getModLan(mod, this);
7886    	return this;
7887    }
7888});
7889
7890// -------------------------------------------------------------------
7891
7892/**
7893 * e107WidgetAbstract Class
7894 */
7895var e107WidgetAbstract = Class.create(e107Base);
7896var e107WidgetAbstract = Class.create(e107WidgetAbstract, {
7897
7898    initMod: function(modId, options, inherit) {
7899
7900        this.mod = e107Base.toModName(modId, true);
7901        if(!this.mod) {
7902            throw 'Illegal Mod ID';
7903        }
7904
7905		var methods = 'setTemplate addTemplate getTemplate parseTemplate setPrefs addPref getPref getPrefs getLan getLanVars addLan setLan';
7906		var that = this;
7907
7908		//Some magic
7909		$w(methods).each(function(method){
7910			var mod_method = method.gsub(/^(set|get|add|parse)(.*)$/, function(match){
7911				return match[1] + 'Mod' + match[2];
7912			});
7913			var parent_method = !e107Base[mod_method] ? method : mod_method;
7914			this[mod_method] = e107Base[parent_method].bind(this, this.mod);
7915		}.bind(that));
7916
7917		Object.extend(that, {
7918			getModName: function(raw) {
7919				return raw ? this.mod : e107Base.toModName(this.mod);
7920			},
7921
7922		    parseModLan: function(str) {
7923		        return String(str).interpolate(e107Base.getModLan(this.mod));
7924		    },
7925
7926		    setModCache: function(cache_str, cache_item) {
7927		    	e107Base.setCache(this.getModName(true) + varsettrue(cache_str, ''), cache_item);
7928		    	return this;
7929		    },
7930
7931		    getModCache: function(cache_str) {
7932		    	return e107Base.getCache(this.getModName(true) + varsettrue(cache_str, ''));
7933		    },
7934
7935		    clearModCache: function(cache_str) {
7936		    	e107Base.clearCache(this.getModName(true) + varsettrue(cache_str, ''));
7937		    	return this;
7938		    }
7939		});
7940
7941        //Merge option object (recursive)
7942        this.setOptions(options, inherit);
7943
7944        return this;
7945    },
7946
7947
7948    setOptions: function(options, inherit) {
7949        this.options = {};
7950
7951        var c = this.constructor;
7952
7953        if (c.superclass && inherit) {
7954            var chain = [], klass = c;
7955
7956            while (klass = klass.superclass)
7957                chain.push(klass);
7958
7959            chain = chain.reverse();
7960            for (var i = 0, len = chain.length; i < len; i++) {
7961                if(!chain[i].getModPrefs) chain[i].getModPrefs = Prototype.emptyFunction;
7962                //global options if available
7963                Object.extend(this.options, chain[i].getModPrefs() || {});
7964            }
7965        }
7966
7967        //global options if available
7968        if(!this.getModPrefs) { this.getModPrefs = Prototype.emptyFunction; }
7969
7970        Object.extend(this.options, this.getModPrefs() || {});
7971        return Object.extend(this.options, options || {});
7972    }
7973
7974});
7975
7976// -------------------------------------------------------------------
7977
7978/**
7979 * Core - everything's widget!
7980 */
7981var e107Core = Class.create(e107WidgetAbstract, {
7982    initialize: function() {
7983        this.initMod('core');
7984    },
7985
7986    /**
7987     * e107:loaded Event observer
7988     */
7989    runOnLoad: function(handler, element, reload) {
7990    	e107Event.register('loaded', handler, element || document);
7991    	if(reload)
7992    		this.runOnReload(handler, element);
7993
7994    	return this;
7995    },
7996
7997    /**
7998     * Ajax after update Event observer
7999     */
8000    runOnReload: function(handler, element) {
8001    	e107Event.register('ajax_update_after', handler, element || document);
8002    	return this;
8003    }
8004
8005});
8006
8007//e107Core instance
8008var e107 = new e107Core();
8009
8010// -------------------------------------------------------------------
8011
8012/*
8013 * Widgets namespace
8014 * @descr should contain only high-level classes
8015 */
8016 var e107Widgets = {};
8017
8018/**
8019 * Utils namespace
8020 * @descr contains low-level classes and non-widget high-level classes/objects
8021 */
8022var e107Utils = {}
8023
8024/**
8025 * Helper namespace
8026 * @descr includes all old e107 functions + some new helper methods/classes
8027 */
8028var e107Helper = {
8029    fxToggle: function(el, fx) {
8030    	var opt = Object.extend( { effect: 'blind' , options: {duration: 0.5} }, fx || {});
8031        Effect.toggle(el, opt.effect, opt.options);
8032    }
8033}
8034
8035// -------------------------------------------------------------------
8036
8037/*
8038 * Element extension
8039 */
8040Element.addMethods( {
8041	fxToggle: function(element, options) {
8042	    e107Helper.fxToggle(element, options);
8043	}
8044});
8045
8046// -------------------------------------------------------------------
8047
8048/**
8049 * Backward compatibility
8050 */
8051Object.extend(e107Helper, {
8052
8053	toggle: function(el) {
8054		var eltoggle;
8055		/**
8056		 * (SecretR) Notice
8057		 *
8058		 * Logic mismatch!
8059		 * Passed element/string should be always the target element (which will be toggled)
8060		 *  OR
8061		 * anchor: <a href="#some-id"> where 'some-id' is the id of the target element
8062		 * This method will be rewritten after the core is cleaned up. After this point
8063		 * the target element will be auto-hidden (no need of class="e-hideme")
8064		 */
8065
8066        if(false === Object.isString(el) || (
8067        	($(el) && $(el).nodeName.toLowerCase() == 'a' && $(el).readAttribute('href'))
8068        		||
8069        	($(el) && $(el).readAttribute('type') && $(el).readAttribute('type').toLowerCase() == 'input') /* deprecated */
8070        )) {
8071        	eltoggle = (function(el) {
8072	    		return Try.these(
8073	    		    function() { var ret = $(el.readAttribute('href').substr(1));  if(ret) { return ret; } throw 'Error';}, //This will be the only valid case in the near future
8074                    function() { var ret = el.next('.e-expandme'); if(ret) { return ret; } throw 'Error';},// maybe this too?
8075                    function() { var ret = el.next('div'); if(ret) { return ret; } throw 'Error'; }, //backward compatibality - DEPRECATED
8076                    function() { return null; } //break
8077	    		) || false;
8078        	})($(el));
8079        } else {
8080            var eltoggle = $(el);
8081        }
8082
8083        if(!eltoggle) return false;
8084
8085		var fx = varset(arguments[1], null);
8086
8087		if(false !== fx)
8088		    this.fxToggle(eltoggle, fx || {});
8089		else
8090		    $(eltoggle).toggle();
8091
8092		return true;
8093	},
8094
8095    /**
8096     * added as Element method below
8097     * No toggle effects!
8098     */
8099    downToggle: function(element, selector) {
8100    	$(element).select(varsettrue(selector, '.e-expandme')).invoke('toggle');
8101    	return element;
8102    },
8103
8104	/**
8105	 * Event listener - e107:loaded|e107:ajax_update_after
8106	 * @see e107Core#addOnLoad
8107	 */
8108    toggleObserver: function(event) {
8109    	var element = event.memo['element'] ? $(event.memo.element) : $$('body')[0];
8110        Element.select(element, '.e-expandit').invoke('observe', 'click', function(e) {
8111            var element = e.findElement('a');
8112            if(!element) element = e.element();
8113            if(this.toggle(element, {})) e.stop();
8114        }.bindAsEventListener(e107Helper));
8115    },
8116
8117    /**
8118     * Add fx scroll on click event
8119     * on all <a href='#something" class="scroll-to"> elements
8120     */
8121    scrollToObserver: function(event) {
8122    	var element = event.memo['element'] ? $(event.memo.element) : $$('body')[0];
8123		Element.select(element, 'a[href^=#].scroll-to:not([href=#])').invoke('observe', 'click', function(e) {
8124			new Effect.ScrollTo(e.element().hash.substr(1));
8125			e.stop();
8126		});
8127    },
8128
8129    /**
8130     * added as Element method below
8131     */
8132    downHide: function(element, selector) {
8133    	$(element).select(varsettrue(selector, '.e-hideme')).invoke('hide');
8134    	return element;
8135    },
8136
8137    /**
8138     * added as Element method below
8139     */
8140    downShow: function(element, selector) {
8141    	$(element).select(varsettrue(selector, '.e-hideme')).invoke('show');
8142    	return element;
8143    },
8144
8145    //event listener
8146    autoHide: function(event) {
8147    	var hideunder = event.memo['element'] ? $(event.memo.element) : $$('body')[0];
8148        if(hideunder) hideunder.downHide();
8149    },
8150
8151    /**
8152     * added as Element method below
8153     * autocomplete="off" - all major browsers except Opera(?!)
8154     */
8155    noHistory: function(element) {
8156        $(element).writeAttribute('autocomplete', 'off');
8157        return element;
8158    },
8159
8160    /**
8161     * added as Element method below
8162     */
8163    downNoHistory: function(element, selector) {
8164    	$(element).select(varsettrue(selector, 'input.e-nohistory')).invoke('noHistory');
8165    	return element;
8166    },
8167
8168    //event listener
8169    autoNoHistory: function(event) {
8170    	var down = event.memo['element'] ? $(event.memo.element) : $$('body')[0];
8171        if(down) down.downNoHistory();
8172    },
8173
8174    /**
8175     * added as Element method below
8176     */
8177	externalLink: function (element) {
8178	    $(element).writeAttribute('target', '_blank');
8179	    return element;
8180	},
8181
8182    /**
8183     * added as Element method below
8184     */
8185    downExternalLinks: function(element) {
8186    	$(element).select('a[rel~=external]').invoke('externalLink');
8187    	return element;
8188    },
8189
8190    //event listener
8191	autoExternalLinks: function (event) {
8192		//event.element() works for IE now!
8193		//TODO - remove memo.element references
8194		//event.memo['element'] ? $(event.memo.element) : $$('body')[0];
8195		var down = event.element() != document ? event.element() : $$('body')[0];
8196	    if(down) down.downExternalLinks();
8197	},
8198
8199	urlJump: function(url) {
8200	    top.window.location = url;
8201	},
8202
8203	//TODO Widget - e107Window#confirm;
8204    confirm: function(thetext) {
8205    	return confirm(thetext);
8206    },
8207
8208    autoConfirm: function(event) {
8209
8210    },
8211
8212	imagePreload: function(ejs_path, ejs_imageString) {
8213	    var ejs_imageArray = ejs_imageString.split(',');
8214	    for(var ejs_loadall = 0, len = ejs_imageArray.length; ejs_loadall < len; ejs_loadall++){
8215	        var ejs_LoadedImage = new Image();
8216	        ejs_LoadedImage.src=ejs_path + ejs_imageArray[ejs_loadall];
8217	    }
8218	},
8219
8220	toggleChecked: function(form, state, selector, byId) {
8221		form = $(form); if(!form) { return; }
8222		if(byId) selector = 'id^=' + selector;
8223		$A(form.select('input[type=checkbox][' + selector + ']')).each(function(element) { if(!element.disabled) element.checked=state });
8224	},
8225
8226	//This will be replaced later with upload_ui.php own JS method
8227	//and moved to a separate class
8228    __dupCounter: 1,
8229    __dupTmpTemplate: '',
8230	//FIXME
8231	duplicateHTML: function(copy, paste, baseid) {
8232        if(!$(copy) || !$(paste)) { return; }
8233        this.__dupCounter++;
8234        var source = $($(copy).cloneNode(true)), newentry, newid, containerId, clearB;
8235
8236        source.writeAttribute('id', source.readAttribute('id') + this.__dupCounter);
8237        newid = (baseid || 'duplicated') + '-' + this.__dupCounter;
8238
8239        var tmpl = this.getDuplicateTemplate();
8240        if(tmpl) {
8241        	var sourceInnerHTML = source.innerHTML;
8242        	source = source.update(tmpl.parseToElement({
8243                duplicateBody: sourceInnerHTML,
8244                removeId: 'remove-' + newid,
8245                baseId: baseid || '',
8246                newId: newid,
8247                counter: this.__dupCounter
8248            })).down().hide();
8249        	clearB = $(source.select('#remove-' + newid)[0]);
8250        } else {
8251        	//see clear, clearL and clearR CSS definitions
8252        	clearB = new Element('input', { 'class': 'button', 'value': 'x', 'type': 'button', 'id': 'remove-' + newid }); //backward compat. - subject of removal
8253        	source.insert({
8254        		top: new Element('div', {'class': 'clear'}),
8255        		bottom: clearB
8256        	}).hide();
8257        }
8258        if(baseid) {
8259            source.innerHTML = source.innerHTML.replace(new RegExp(baseid, 'g'), newid);
8260        }
8261        var containerId = source.identify();
8262        $(paste).insert(source);
8263        //Again - the EVIL IE6
8264        if(!clearB) { clearB = $('remove-' + newid); }
8265
8266        clearB.observe('click', function(e) {
8267        	e.stop();
8268        	var el = e.element().up('#'+containerId);
8269	        el.fxToggle({
8270	            effect: 'appear',
8271	            options: {
8272	            	duration: 0.4,
8273	                afterFinish: function(o) { o.element.remove(); }
8274	            }
8275	        });
8276        }.bind(this));
8277
8278        source.fxToggle({
8279        	effect: 'appear',
8280        	options: { duration: 0.5 }
8281        });
8282	},
8283
8284    getDuplicateTemplate: function() {
8285    	if(this.__dupTmpTemplate) {
8286    		var tmpl = this.__dupTmpTemplate;
8287    		this.__dupTmpTemplate = '';
8288    		return tmpl;
8289    	}
8290    	return e107.getModTemplate('duplicateHTML');
8291    },
8292
8293    setDuplicateTemplate: function(tmpl) {
8294        return this.__dupTmpTemplate = tmpl;
8295    },
8296
8297	previewImage: function(src_val, img_path, not_found) {
8298	   $(src_val + '_prev').src = $(src_val).value ? img_path + $(src_val).value : not_found;
8299	    return;
8300	},
8301
8302	insertText: function(str, tagid, display) {
8303	    $(tagid).value = str.escapeHTML();
8304	    if($(display)) {
8305	        $(display).fxToggle();
8306	    }
8307	},
8308
8309	appendText: function(str, tagid, display) {
8310	    $(tagid).focus().value += str.escapeHTML();
8311	    if($(display)) {
8312	        $(display).fxToggle();
8313	    }
8314	},
8315
8316	//by Lokesh Dhakar - http://www.lokeshdhakar.com
8317    getPageSize: function() {
8318
8319	     var xScroll, yScroll;
8320
8321		if (window.innerHeight && window.scrollMaxY) {
8322			xScroll = window.innerWidth + window.scrollMaxX;
8323			yScroll = window.innerHeight + window.scrollMaxY;
8324		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
8325			xScroll = document.body.scrollWidth;
8326			yScroll = document.body.scrollHeight;
8327		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
8328			xScroll = document.body.offsetWidth;
8329			yScroll = document.body.offsetHeight;
8330		}
8331
8332		var windowWidth, windowHeight;
8333
8334		if (self.innerHeight) {	// all except Explorer
8335			if(document.documentElement.clientWidth){
8336				windowWidth = document.documentElement.clientWidth;
8337			} else {
8338				windowWidth = self.innerWidth;
8339			}
8340			windowHeight = self.innerHeight;
8341		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
8342			windowWidth = document.documentElement.clientWidth;
8343			windowHeight = document.documentElement.clientHeight;
8344		} else if (document.body) { // other Explorers
8345			windowWidth = document.body.clientWidth;
8346			windowHeight = document.body.clientHeight;
8347		}
8348
8349		// for small pages with total height less then height of the viewport
8350		if(yScroll < windowHeight){
8351			pageHeight = windowHeight;
8352		} else {
8353			pageHeight = yScroll;
8354		}
8355
8356		// for small pages with total width less then width of the viewport
8357		if(xScroll < windowWidth){
8358			pageWidth = xScroll;
8359		} else {
8360			pageWidth = windowWidth;
8361		}
8362
8363		return [pageWidth,pageHeight];
8364	}
8365});
8366
8367
8368// -------------------------------------------------------------------
8369
8370/*
8371 * Element extensions
8372 */
8373Element.addMethods( {
8374	downNoHistory: e107Helper.downNoHistory,
8375	downHide: e107Helper.downHide,
8376	downShow: e107Helper.downShow,
8377	downToggle: e107Helper.downToggle,
8378	downExternalLinks: e107Helper.downExternalLinks
8379});
8380
8381Element.addMethods('INPUT', {
8382	noHistory: e107Helper.noHistory
8383});
8384
8385Element.addMethods('A', {
8386	externalLink: e107Helper.externalLink
8387});
8388
8389Element.addMethods('FORM', {
8390	toggleChecked: e107Helper.toggleChecked
8391});
8392
8393// -------------------------------------------------------------------
8394
8395/**
8396 * e107BB helper
8397 */
8398e107Helper.BB = {
8399
8400	__selectedInputArea: null,
8401
8402	store: function(textAr){
8403	    this.__selectedInputArea = $(textAr);
8404	},
8405
8406	/**
8407	 * New improved version - fixed scroll to top behaviour when inserting BBcodes
8408	 * @TODO - improve it further
8409	 */
8410	insert: function(text, emote) {
8411	    if (!this.__selectedInputArea) {
8412	    	return; //[SecretR] TODO - alert the user
8413	    }
8414	    var eField = this.__selectedInputArea, tags = this.parse(text, emote);
8415        if(this.insertIE(eField, text, tags)) return;
8416
8417	    var scrollPos = eField.scrollTop, sel = (eField.value).substring(eField.selectionStart, eField.selectionEnd);
8418	    if (eField.selectionEnd <= 2 && typeof(eField.textLength) != 'undefined') {
8419	        eField.selectionEnd = eField.textLength;
8420	    }
8421
8422	    var newStart = eField.selectionStart + tags.start.length + sel.length + tags.end.length;
8423	    eField.value = (eField.value).substring(0, eField.selectionStart) + tags.start + sel + tags.end + (eField.value).substring(eField.selectionEnd, eField.textLength);
8424
8425	    eField.focus(); eField.selectionStart = newStart; eField.selectionEnd = newStart; eField.scrollTop = scrollPos;
8426	    return;
8427
8428	},
8429
8430	insertIE: function(area, text, tags) {
8431        // IE fix
8432        if (!document.selection) return false;
8433        var eSelection = document.selection.createRange().text;
8434        area.focus();
8435        if (eSelection) {
8436            document.selection.createRange().text = tags.start + eSelection + tags.end;
8437        } else {
8438            document.selection.createRange().text = tags.start + tags.end;
8439        }
8440        eSelection = ''; area.blur(); area.focus();
8441        return true;
8442	},
8443
8444	parse: function(text, isEmote) {
8445		var tOpen = text, tClose = '';
8446        if (isEmote != true) {  // Split if its a paired bbcode
8447            var tmp = text.split('][', 2);
8448            tOpen = varset(tmp[1]) ? tmp[0] + ']' : text;
8449            tClose = varset(tmp[1]) ? '[' + tmp[1] : '';
8450        }
8451        return { start: tOpen, end: tClose };
8452	},
8453
8454	//TODO VERY BAD - make it right ASAP!
8455	help_old: function(help, tagid, nohtml){
8456		if(nohtml) { help = help.escapeHTML(); }
8457		if($(tagid)) { $(tagid).value = help; }
8458		else if($('helpb')) {
8459			$('helpb').value = help;
8460		}
8461	},
8462
8463	//FIXME - The new BB help system
8464	help: function(help, tagid, nohtml){
8465		if(nohtml) { help = help.escapeHTML(); }
8466		if(!$(tagid)) return;
8467		if(help) {
8468			var wrapper = new Element('div', {'style': 'position: relative'}).update(help);
8469			$(tagid).update(wrapper).fxToggle();
8470		} else {
8471			$(tagid).update('').fxToggle();
8472		}
8473	}
8474};
8475
8476//Iframe Shim - from PrototypeUI
8477e107Utils.IframeShim = Class.create({
8478	initialize: function() {
8479		this.element = new Element('iframe',{
8480			style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none;',
8481			src: 'javascript:void(0);',
8482			frameborder: 0
8483		});
8484		$(document.body).insert(this.element);
8485	},
8486	hide: function() {
8487		this.element.hide();
8488		return this;
8489	},
8490	show: function() {
8491		this.element.show();
8492		return this;
8493	},
8494	positionUnder: function(element) {
8495		var element = $(element);
8496		var offset = element.cumulativeOffset();
8497		var dimensions = element.getDimensions();
8498
8499		this.element.setStyle({
8500			left: offset[0] + 'px',
8501			top: offset[1] + 'px',
8502			width: dimensions.width + 'px',
8503			height: dimensions.height + 'px',
8504			zIndex: element.getStyle('zIndex') - 1
8505		}).show();
8506
8507		return this;
8508	},
8509	setBounds: function(bounds) {
8510		for(prop in bounds)
8511			bounds[prop] += 'px';
8512		this.element.setStyle(bounds);
8513		return this;
8514	},
8515	destroy: function() {
8516		if(this.element)
8517			this.element.remove();
8518		return this;
8519	}
8520});
8521
8522// -------------------------------------------------------------------
8523
8524/**
8525 * Show Page/Element loading status (during AJAX call)
8526 *
8527 * @class e107Utils.LoadingStatus
8528 * @widget: core-loading
8529 * @version 1.0
8530 * @author SecretR
8531 * @extends e107WidgetAbstract
8532 * @template: 'template'
8533 * @cache_string: 'instance-loading-status'
8534 */
8535
8536
8537('Loading')				   .addModLan('core-loading', 'alt');
8538('Loading, please wait...').addModLan('core-loading', 'text');
8539
8540e107Utils.LoadingStatus = Class.create(e107WidgetAbstract, {
8541
8542	initialize: function(dest_element, options) {
8543		this.initMod('core-loading', options);
8544		this.cacheStr = 'instance-loading-status';
8545
8546		this.loading_mask_loader = false;
8547		this.loading_mask = $('loading-mask');
8548		this.iframeShim = this.getModCache(this.cacheStr + '-iframe');
8549		this.destElement = ($(dest_element) || $$('body')[0]);
8550
8551		//this.addModLan('loading_text', 'Loading, please wait...').addModLan('loading_alt', 'Loading');
8552		this.re_center = this.recenter.bindAsEventListener(this);
8553
8554		this.create();
8555	    if(this.options.show_auto)
8556	    	this.show();
8557	},
8558
8559	startObserving: function() {
8560		Event.observe(window,"resize", this.re_center);
8561    	if(e107API.Browser.IE && e107API.Browser.IE <= 7)
8562    		Event.observe(window,"scroll", this.re_center);
8563    	return this;
8564	},
8565
8566	stopObserving:  function() {
8567		Event.stopObserving(window, "resize", this.re_center);
8568    	if(e107API.Browser.IE && e107API.Browser.IE <= 7)
8569    		Event.stopObserving(window, "scroll", this.re_center);
8570    	return this;
8571	},
8572
8573	set_destination: function(dest_element) {
8574		this.destElement = $(dest_element) || $$('body')[0];
8575		return this;
8576	},
8577
8578	create: function() {
8579		if(!this.loading_mask) {
8580			var objBody = $$('body')[0];
8581			this.loading_mask = this.getModTemplate('template').parseToElement().hide();
8582
8583			objBody.insert({
8584				bottom: this.loading_mask
8585			});
8586			this.loading_mask.setStyle( { 'opacity': 0.8, zIndex: 9000 } );
8587		}
8588
8589		this.loading_mask_loader = this.loading_mask.down('#loading-mask-loader');
8590		this.loading_mask_loader.setStyle( { /*'position': 'fixed', */zIndex: 9100 } );
8591		//Create iframeShim if required
8592		this.createShim();
8593		return this;
8594 	},
8595
8596	show: function () {
8597		if(this.loading_mask.visible()) return;
8598		this.startObserving();
8599		this.center();
8600		this.loading_mask.show();
8601		return this;
8602	},
8603
8604	hide: function () {
8605		this.loading_mask.hide();
8606		this.stopObserving().positionShim(true);
8607		return this;
8608	},
8609
8610	center: function() {
8611		//Evil IE6
8612		if(!this.iecenter()) {
8613			Element.clonePosition(this.loading_mask, this.destElement);
8614			this.fixBody().positionShim(false);
8615		}
8616		return this;
8617
8618	},
8619
8620	recenter: function() {
8621		if(!this.iecenter()) {
8622			Element.clonePosition(this.loading_mask, this.destElement);
8623			this.fixBody().positionShim(false);
8624		}
8625		return this;
8626	},
8627
8628	iecenter: function() {
8629		//TODO - actually ie7 should work without this - investigate
8630		if(e107API.Browser.IE && e107API.Browser.IE <= 7) {
8631			//The 'freezing' problem solved (opacity = 1 ?!)
8632			this.loading_mask.show();
8633			var offset = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
8634			var destdim = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
8635
8636			if(!this.lmh) this.lmh = this.loading_mask_loader.getHeight();
8637			var eldim = this.lmh;
8638			var toph = parseInt(destdim/2 - eldim/2 + offset );
8639			this.loading_mask.setStyle({top: 0, left: 0, 'opacity': 1});
8640			this.fixBody(true);
8641			this.loading_mask_loader.setStyle( {
8642				'position': 'absolute',
8643				'top': toph + 'px',
8644				'opacity': 1
8645			});
8646
8647			this.positionShim(false);
8648			return true;
8649		}
8650		return false;
8651	},
8652
8653	fixBody: function(force) {
8654		if(force || this.destElement.nodeName.toLowerCase() == 'body') {
8655			var ps = e107Helper.getPageSize();
8656			this.loading_mask.setStyle({ 'width': parseInt(ps[0]) + 'px', 'height': parseInt(ps[1]) + 'px' });
8657		}
8658		return this;
8659	},
8660
8661	createShim: function() {
8662		if(e107API.Browser.IE && e107API.Browser.IE <= 7 && !this.iframeShim) {
8663			this.iframeShim = new e107Utils.IframeShim().hide();
8664			this.setModCache(this.cacheStr +'-iframe', this.iframeShim);
8665		}
8666
8667		return this;
8668	},
8669
8670	positionShim: function(hide) {
8671		if(!e107API.Browser.IE || e107API.Browser.IE > 6) return this;
8672		if(hide) {
8673			this.iframeShim.hide(); return this;
8674		}
8675		this.iframeShim.positionUnder(this.loading_mask).show();
8676		return this;
8677	}
8678});
8679
8680/**
8681 * Register page loading core events
8682 */
8683e107Event.register('ajax_loading_start', function(event) {
8684	var loadingObj = e107.getModCache('ajax-loader');
8685	if(!loadingObj) {
8686		loadingObj = new e107Utils.LoadingStatus(false, { show_auto: false });
8687		e107.setModCache('ajax-loader', loadingObj);
8688	}
8689	loadingObj.set_destination(event.memo.overlayPage).show();
8690});
8691
8692e107Event.register('ajax_loading_end', function(event) {
8693	var loadingObj = e107.getModCache('ajax-loader');
8694	if(loadingObj) {
8695		window.setTimeout( function(){ loadingObj.hide() }, 200);
8696	}
8697});
8698
8699/**
8700 * e107Utils.LoadingElement
8701 * based on Protoload by Andreas Kalsch
8702 */
8703e107Base.setPrefs('core-loading-element', {
8704	overlayDelay: 50,
8705	opacity: 0.8,
8706	zIndex: 10,
8707	className: 'element-loading-mask',
8708	backgroundImage: '#{e_COMPAT_IMAGE}loading_32.gif'
8709});
8710
8711e107Utils.LoadingElement = {
8712	startLoading: function(element, options) {
8713		if(!options) options = {};
8714		Object.extend(options, e107Base.getPrefs('core-loading-element') || {});
8715		element = $(element);
8716
8717		var zindex = parseInt(e107.getModPref('zIndex')) + parseInt(options.zIndex);
8718		var cacheStr = 'core-loading-element-' + $(element).identify();
8719		element._waiting = true;
8720		//can't use element._eloading for storing objects because of IE6 memory leak
8721		var _eloading = e107Base.getCache(cacheStr);
8722
8723		if (!_eloading) {
8724			_eloading = new Element('div', { 'class': options.className }).setStyle({
8725				position: 'absolute',
8726				opacity: options.opacity,
8727				zIndex: zindex
8728				//backgroundImage: 'url(' + options.backgroundImage.parsePath() + ')'
8729			});
8730
8731			$$('body')[0].insert({ bottom: _eloading });
8732			var imgcheck = _eloading.getStyle('background-image');
8733			//console.log(options.backgroundImage.parsePath());
8734			if(!imgcheck || imgcheck == 'none') //only if not specified by CSS
8735				_eloading.setStyle( {backgroundImage: 'url(' + options.backgroundImage.parsePath() + ')'});
8736			e107Base.setCache(cacheStr, _eloading);
8737		}
8738		window.setTimeout(( function() {
8739			if (this._waiting) {
8740				Element.clonePosition(_eloading, this);
8741				_eloading.show();
8742			}
8743		}).bind(element), options.overlayDelay);
8744
8745	},
8746
8747	stopLoading: function(element) {
8748		if (element._waiting) {
8749			element._waiting = false;
8750			var cacheStr = 'core-loading-element-' + $(element).identify(), _eloading = e107Base.getCache(cacheStr);
8751			if($(_eloading)) $(_eloading).hide();//remove it or not?
8752			//e107Base.clearCache(cacheStr);
8753		}
8754	}
8755};
8756
8757Element.addMethods(e107Utils.LoadingElement);
8758
8759/**
8760 * Register element loading core events
8761 */
8762e107Event.register('ajax_loading_element_start', function(event) {
8763	var element = $(event.memo.overlayElement);
8764	if(element) element.startLoading();
8765});
8766
8767e107Event.register('ajax_loading_element_end', function(event) {
8768	var element = $(event.memo.overlayElement);
8769	if(element)  window.setTimeout( function(){ element.stopLoading() }.bind(element), 50);
8770});
8771
8772// -------------------------------------------------------------------
8773
8774// ###### START DEPRECATED - subject of removal!!! ######
8775
8776//@see e107Helper#toggle, e107Helper#autoToggle
8777var expandit = function(curobj, hide) {
8778	e107Helper.toggle(curobj, {});
8779
8780    if(hide) { //don't use it - will be removed
8781        hide.replace(/[\s]?,[\s]?/, ' ').strip();
8782        $w(hide).each(function(h) {
8783            if(Object.isElement($(h))) { $(h).hide(); }
8784        });
8785    }
8786}
8787
8788//Use Prototype JS instead: $(id).update(txt);
8789var setInner = function(id, txt) {
8790    $(id).update(txt);
8791}
8792
8793//@see e107Helper#confirm TODO @see e107ModalConfirm#confirm
8794var jsconfirm = function(thetext){
8795        return e107Helper.confirm(thetext);
8796}
8797
8798//Use Prototype JS instead e.g.: $(tagid).value = str; $(display).hide();
8799var insertext = function(str, tagid, display) {
8800    e107Helper.insertText(str, tagid, display);
8801}
8802
8803//Use Prototype JS instead e.g.: $(tagid).focus().value += str; $(display).hide();
8804var appendtext = function(str, tagid, display) {
8805    e107Helper.appendText(str, tagid, display);
8806}
8807
8808//TODO - e107Window class, e107Helper#openWindow proxy
8809var open_window = function(url, wth, hgt) {
8810    if('full' == wth){
8811        pwindow = window.open(url);
8812    } else {
8813    	mywidth = varset(wth, 600);
8814    	myheight = varset(wth, 400);
8815        pwindow = window.open(url,'Name', 'top=100,left=100,resizable=yes,width='+mywidth+',height='+myheight+',scrollbars=yes,menubar=yes')
8816    }
8817    pwindow.focus();
8818}
8819
8820//TODO Window class
8821var closeWindow = function(form){
8822    if((window.opener!=null)&&(!window.opener.closed)){
8823        window.opener.location.reload();
8824    }
8825    if(window.opener!=null) {
8826        window.close();
8827    }else{setWinType(form);
8827form.whatAction.value="Close";form.submit();}
8828}
8829
8830
8831//@see e107Helper#urljump
8832var urljump = function(url) {
8833    e107Helper.urlJump(url);
8834}
8835
8836//@see e107Helper#imagePreload
8837var ejs_preload = function(ejs_path, ejs_imageString){
8838    e107Helper.imagePreload(ejs_path, ejs_imageString)
8839}
8840
8841//Use Prototype JS e.g.: $(cntfield).value = $(field).value.length;
8842var textCounter = function(field,cntfield) {
8843    cntfield.value = field.value.length;
8844}
8845
8846//Not used anymore - seek & remove
8847/*
8848function openwindow() {
8849    opener = window.open("htmlarea/index.php", "popup","top=50,left=100,resizable=no,width=670,height=520,scrollbars=no,menubar=no");
8850    opener.focus();
8851}
8852*/
8853
8854//@see e107Helper#toggleChecked
8855var setCheckboxes = function(the_form, do_check, the_cb) { //backward compatibility
8856    e107Helper.toggleChecked(the_form, do_check, 'name^=' + the_cb.gsub(/[\[\]]/, ''), false);
8857}
8858
8859//@see e107Helper.BB#storeCaret
8860var storeCaret = function(textAr) {
8861	e107Helper.BB.store(textAr); return;
8862}
8863
8864//@see e107Helper.BB#insert
8865var addtext = function(text, emote) {
8866    e107Helper.BB.insert(text, emote); return;
8867}
8868
8869//@see e107Helper.BB#help
8870var help = function(help,tagid) {
8871    e107Helper.BB.help_old(help, tagid, true);
8872}
8873
8874//Use Prototype JS e.g.: $(object).addClassName(over); $(object).removeClassName(over);
8875var eover = function(object, over) {
8876    $(object).writeAttribute('class', over);
8877}
8878
8879//@see e107Helper#duplicateHTML
8880var duplicateHTML = function(copy, paste, baseid) {
8881    e107Helper.duplicateHTML(copy,paste,baseid);
8882}
8883
8884var preview_image = function(src_val,img_path, not_found) {
8885    e107Helper.previewImage(src_val, img_path, not_found)
8886}
8887
8888var externalLinks = function () {
8889    //e107Helper.externalLinks();
8890};
8891// ###### END DEPRECATED ######
8892
8893// -------------------------------------------------------------------
8894
8895/**
8896 * e107History
8897 *
8898 * Prototype Xtensions http://www.prototypextensions.com/
8899 */
8900var e107History = {
8901    __altered: false,
8902    __currentHash: null,
8903    __previousHash: null,
8904    __iframe: false,
8905    __title: false,
8906
8907    /**
8908     * init()
8909     * @desc Initialize the hash. Call this method in first
8910     */
8911    init: function() {
8912        var inst  = this;
8913        var hash  = location.hash.substring(1);
8914        this.hash = $H(hash.toQueryParams());
8915        this.__currentHash  = hash;
8916        this.__previousHash = hash;
8917
8918        this.__title = document.title;
8919
8920        if(e107API.Browser.IE && e107API.Browser.IE < 8) {
8921            document.observe('dom:loaded', function(e) {
8922                if(!$('e107-px-historyframe')) {
8923                    e107History.__iframe = new Element('iframe', {
8924                        name   : 'e107-px-historyframe',
8925                        id     : 'e107-px-historyframe',
8926                        src    : '',
8927                        width  : '0',
8928                        height : '0',
8929                        style  : {
8930                            visibility: 'hidden'
8931                        }
8932                    });
8933
8934                    document.body.appendChild(e107History.__iframe);
8935
8936                    e107History.setHashOnIframe(inst.hash.toQueryString());
8937                }
8938            });
8939        }
8940    },
8941
8942    /**
8943     * set( string name, string value )
8944     *
8945     * @desc Set new value value for parameter name
8946     */
8947    set: function(name, value) {
8948        this.__previousHash = this.hash.toQueryString();
8949        this.hash.set(name, value);
8950        this.apply();
8951    },
8952
8953    /**
8954     * get( string $name )
8955     *
8956     * @desc Get value parameter $name
8957     */
8958    get: function(name) {
8959        return this.hash.get(name);
8960    },
8961
8962    /**
8963     * unset( string $name )
8964     *
8965     * @desc Unset parameter $name
8966     */
8967    unset: function(name) {
8968        this.hash.unset(name);
8969        this.apply();
8970    },
8971
8972    /**
8973     * update()
8974     *
8975     * @desc Updates this.hash with the current hash
8976     */
8977    update: function() {
8978        this.__previousHash = this.hash.toQueryString();
8979        var hash = window.location.hash.substring(1);
8980
8981        // If IE, look in the iframe if the hash is updated
8982        if(e107API.Browser.IE && e107API.Browser.IE < 8 && this.__iframe) {
8983            var hashInFrame = this.getHashOnIframe();
8984
8985            if(hashInFrame != hash) {
8986                hash = hashInFrame;
8987            }
8988        }
8989
8990        this.hash = $H(hash.toQueryParams());
8991        this.__currentHash = hash;
8992    },
8993
8994    /**
8995     * apply()
8996     *
8997     * @desc Apply this.hash to location.hash
8998     */
8999    apply: function() {
9000        var newHash = this.hash.toQueryString();
9001
9002        // set new hash
9003        window.location.hash = newHash;
9004
9005        // If IE, apply new hash to frame for history
9006        if(e107API.Browser.IE && e107API.Browser.IE < 8 && this.__iframe) {
9007            if(this.__currentHash != newHash)
9008            {
9009                this.setHashOnIframe(newHash);
9010            }
9011            else if(newHash != this.getHashOnIframe())
9012            {
9013                this.setHashOnIframe(newHash);
9014            }
9015        }
9016    },
9017
9018    /**
9019     * isAltered()
9020     *
9021     * @desc Return true if current hash is different of previous hash.
9022     * this.__altered allows to force the dispatch.
9023     */
9024    isAltered: function() {
9025        if(this.__altered) {
9026            return true;
9027        }
9028        this.__altered = false;
9029
9030        return (e107History.__currentHash != e107History.__previousHash);
9031    },
9032
9033    /**
9034     * setHashOnIframe()
9035     *
9036     * @use  For IE compatibility
9037     * @desc Set hash value on iframe
9038     */
9039    setHashOnIframe: function(hash) {
9040        try {
9041            var doc = e107History.__iframe.contentWindow.document;
9042            doc.open();
9043            doc.write('<html><body id="history">' + hash + '</body></html>');
9044            doc.close();
9045        } catch(e) {}
9046    },
9047
9048    /**
9049     * getHashOnIframe()
9050     *
9051     * @use  For IE compatibility
9052     * @desc Get hash value on iframe
9053     */
9054    getHashOnIframe: function() {
9055        var doc = this.__iframe.contentWindow.document;
9056        if (doc && doc.body.id == 'history') {
9057            return doc.body.innerText;
9058        } else {
9059            return this.hash.toQueryString();
9060        }
9061    },
9062
9063    /**
9064     * setTitle()
9065     *
9066     * @desc Set a new title for window
9067     */
9068    setTitle: function(title) {
9069        if(document.title) {
9070            document.title = title;
9071        }
9072    },
9073
9074    /**
9075     * getTitle()
9076     *
9077     * @desc Return current window title
9078     */
9079    getTitle: function() {
9080        return this.__title;
9081    }
9082};
9083
9084e107History.init();
9085
9086/**
9087 * History.Registry
9088 * Prototype Xtensions http://www.prototypextensions.com/
9089 *
9090 * @desc Used to register a callback for a parameter
9091 */
9092e107History.Registry =
9093{
9094    /**
9095     * @desc Hash
9096     */
9097    hash : new Hash(),
9098
9099    /**
9100     * set( string $config )
9101     *
9102     * @desc Set new value historyId for parameter config
9103     */
9104    set: function(config) {
9105
9106        if(typeof(config) != 'object') {
9107            throw('e107History.Registry.set : config must be an javascript object');
9108        }
9109
9110        // id
9111        if(!config.id || !Object.isString(config.id)) {
9112            throw('e107History.Registry.set : config.id must be an string');
9113        }
9114
9115        // onChange
9116        if(!config.onStateChange || !Object.isFunction(config.onStateChange)) {
9117            throw('e107History.Registry.set : config.onStateChange '
9118                + 'must be an javascript callback function');
9119        }
9120
9121        // defaultValue
9122        if(!config.defaultValue || !Object.isString(config.defaultValue)) {
9123            config.defaultValue = '';
9124        }
9125
9126        this.hash.set(config.id, config);
9127    },
9128
9129    /**
9130     * flat version of set method
9131     *
9132     * @desc Register callback function for historyId
9133     */
9134    register: function(historyId, callback, defval) {
9135        var config = {
9136        	id: historyId,
9137        	onStateChange: callback,
9138        	defaultValue: defval
9139        };
9140        this.set(config);
9141    },
9142
9143    /**
9144     * get( string $id )
9145     *
9146     * @desc Get value parameter $id
9147     */
9148    get: function(id) {
9149        return this.hash.get(id);
9150    },
9151
9152    /**
9153     * unset( string $id )
9154     *
9155     * @desc Unset parameter $id
9156     */
9157    unset: function(id) {
9158        this.hash.unset(id);
9159    }
9160}
9161
9162/**
9163 * History.Observer
9164 * Prototype Xtensions http://www.prototypextensions.com/
9165 *
9166 * @desc Used to perform actions defined in the registry,
9167 * according to the hash of the url.
9168 */
9169e107History.Observer = {
9170
9171    /**
9172     * @desc Interval delay in seconds
9173     */
9174    delay : 0.4,
9175
9176    /**
9177     * @desc Interval timer instance
9178     */
9179    interval : null,
9180
9181    /**
9182     * @desc If interval is started : true, else false
9183     */
9184    started : false,
9185
9186    /**
9187     * start()
9188     *
9189     * @desc Start a interval timer
9190     */
9191    start: function() {
9192        if(this.started) return;
9193        this.interval = new PeriodicalExecuter(e107History.Observer.dispatch, this.delay);
9194        this.started = true;
9195    },
9196
9197    /**
9198     * stop()
9199     *
9200     * @desc Stop the interval timer
9201     */
9202    stop: function() {
9203        if(!this.started) return;
9204        this.interval.stop();
9205        this.started = false;
9206    },
9207
9208    /**
9209     * dispatch()
9210     *
9211     * @desc This method is called each time interval,
9212     * the dispatch of the registry is implemented only if
9213     * the hash has been amended (optimisiation)
9214     */
9215    dispatch: function() {
9216        // Update the hash
9217        e107History.update();
9218
9219        // Dispatch only if location.hash has been altered
9220        if(e107History.isAltered()) {
9221        	var oldstate = String(e107History.__previousHash).toQueryParams();
9222        	//FIXME - possible bugs/performance issues here - investigate further
9223            e107History.hash.each(function(pair)  {
9224                var registry = e107History.Registry.get(pair.key);
9225                //Bugfix - notify callbacks only when required
9226                if(registry && (e107History.__altered === pair.key || oldstate[pair.key] !== pair.value)) {
9227                   registry.onStateChange.bind(e107History)( pair.value );
9228                }
9229            });
9230        }
9231    }
9232};
9233
9234// -------------------------------------------------------------------
9235
9236/*
9237 * AJAX related
9238 */
9239var e107Ajax = {};
9240
9241/**
9242 * Ajax.History
9243 * Prototype Xtensions http://www.prototypextensions.com/
9244 *
9245 * @desc Provides core methods to easily manage browsing history
9246 * with Ajax.History.Request / Updater.
9247 */
9248e107Ajax.History = {
9249
9250    /**
9251     * @desc Allowed Ajax.History prefix (for validation)
9252     */
9253    types : ['Request', 'Updater'],
9254
9255    cacheString: 'ajax-history-',
9256
9257    /**
9258     * observe( string type, string id, string url, object options )
9259     *
9260     * @desc This method helps manage the browsing history
9261     */
9262    observe: function(type, id, url, options) {
9263
9264        var getter         = e107.getModCache(this.cacheString + id);
9265        var currentVersion = 0;
9266        var output         = false;
9267
9268        // Type validation
9269        if(this.types.indexOf(type) == -1) {
9270            throw('e107Ajax.History.observer: type ' + type + ' is invalid !');
9271        }
9272
9273        // Registry management
9274        if(!getter) {
9275            currentVersion = (options.history.state) ? options.history.state : 0;
9276            var hash = new Hash();
9277            hash.set(currentVersion, options);
9278            e107.setModCache(this.cacheString + id, hash);
9279            //console.log(id,  e107.getModCache(this.cacheString + id));
9280        } else {
9281            currentVersion = (options.history.state)
9282                ? options.history.state : this.getCurrentVersion(id);
9283            getter.set(currentVersion, options);
9284        }
9285
9286        // add handler on registry
9287        this.addCallback(type, id);
9288
9289        return currentVersion;
9290    },
9291
9292    /**
9293     * addCallback( string type, string id )
9294     *
9295     * @desc This method adds a state for request on History.Registry
9296     */
9297    addCallback: function(type, id) {
9298
9299        e107History.Observer.start();
9300        // Set history altered state to true : force dispatch
9301        e107History.__altered = id;
9302
9303        // Return void if registry is already set
9304        if(!Object.isUndefined(e107History.Registry.get(id))) return;
9305
9306        // Add this id to history registry
9307        var cacheS = this.cacheString + id;
9308        e107History.Registry.set({
9309            id: id,
9310            onStateChange: function(state) {
9311                var options = e107.getModCache(cacheS).get(state.toString());
9312                var request = null;
9313
9314                if(Object.isUndefined(options)) return;
9315
9316                if(options.history.cache == true && options.history.__request) {
9317                    new Ajax.Cache(options.history.__request);
9318                } else {
9319
9320                	//make a request
9321                    if(type == 'Request') {
9322                        request = new Ajax.Request(options.history.__url, options);
9323                    } else if(type == 'Updater') {
9324                        request = new Ajax.Updater(options.container, options.history.__url, options);
9325                    }
9326                    options.history.__request = request;
9327                }
9328
9329                e107History.__altered = false;
9330
9331                if (Object.isFunction(options.history.onStateChange)) {
9332                    options.history.onStateChange(state);
9333                }
9334            }
9335        });
9336    },
9337
9338    /**
9339     * getCurrentVersion( string id )
9340     *
9341     * @desc This method returns the current state in history
9342     * (if the state is not defined)
9343     */
9344    getCurrentVersion: function(id) {
9345        var getter = e107.getModCache(this.cacheString + id);
9346        return Object.isUndefined(getter) ? 0 : getter.keys().length;
9347    }
9348};
9349
9350e107Ajax.ObjectMap = {
9351    id              : null,    // set custom history value for this instance
9352    state           : false,   // set custom state value for this instance
9353    cache           : false,   // enable/disable history cache
9354    onStateChange   : null,    // handler called on history change
9355    __url           : null,
9356    __request       : null
9357};
9358
9359/**
9360 * Ajax.Cache
9361 * Prototype Xtensions http://www.prototypextensions.com/
9362 *
9363 * @desc Ajax.Cache can "simulate" an Ajax request from an
9364 * Ajax.Request/Updater made beforehand.
9365 */
9366Ajax.Cache = Class.create(Ajax.Base, {
9367    _complete: false,
9368    initialize: function($super, request) {
9369        $super(request.options);
9370        request._complete = false;
9371        this.transport = request.transport;
9372        this.request(request.url);
9373        return this;
9374    },
9375
9376    request: function(url) {
9377        this.url = url;
9378        this.method = this.options.method;
9379        var params = Object.clone(this.options.parameters);
9380
9381        try {
9382            var response = new Ajax.Response(this);
9383
9384            if (this.options.onCreate) this.options.onCreate(response);
9385            Ajax.Responders.dispatch('onCreate', this, response);
9386
9387            if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
9388
9389            this.onStateChange();
9390        }
9391        catch (e) {
9392            this.dispatchException(e);
9393        }
9394    }
9395});
9396
9397Object.extend(Ajax.Cache.prototype, {
9398    respondToReadyState : Ajax.Request.prototype.respondToReadyState,
9399    onStateChange       : Ajax.Request.prototype.onStateChange,
9400    success             : Ajax.Request.prototype.getStatus,
9401    getStatus           : Ajax.Request.prototype.getStatus,
9402    isSameOrigin        : Ajax.Request.prototype.isSameOrigin,
9403    getHeader           : Ajax.Request.prototype.getHeader,
9404    evalResponse        : Ajax.Request.prototype.evalResponse,
9405    dispatchException   : Ajax.Request.prototype.dispatchException
9406});
9407
9408/**
9409 * Ajax.Request Extended
9410 * Prototype Xtensions http://www.prototypextensions.com/
9411 *
9412 * @desc Just a small change: now Ajax.Request return self scope.
9413 * It is required by Ajax.Cache
9414 */
9415Ajax.Request = Class.create(Ajax.Request, {
9416    initialize: function($super, url, options) {
9417        $super(url, options);
9418        return this;
9419    }
9420});
9421
9422Ajax.Request.Events =
9423  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
9424
9425/**
9426 * Ajax.Updater Extended
9427 * Prototype Xtensions http://www.prototypextensions.com/
9428 *
9429 * @desc Just a small change: now Ajax.Updater return self scope
9430 * It is required by Ajax.Cache
9431 */
9432Ajax.Updater = Class.create(Ajax.Updater, {
9433    initialize: function($super, container, url, options) {
9434        $super(container, url, options);
9435        return this;
9436    }
9437});
9438
9439
9440
9441//Register Ajax Responder
9442(function() {
9443
9444		var e_responder = {
9445				onCreate: function(request) {
9446					if(request.options['updateElement']) {
9447						request.options.element = request.options.updateElement;
9448						e107Event.trigger('ajax_update_before', request.options, request.options.updateElement);
9449					}
9450					if(request.options['overlayPage']){
9451						e107Event.trigger('ajax_loading_start', request.options, request.options.overlayPage);
9452					} else if(request.options['overlayElement']) {
9453						e107Event.trigger('ajax_loading_element_start', request.options, request.options.overlayElement);
9454					}
9455				},
9456
9457				onComplete: function(request) {
9458					/*Ajax.activeRequestCount == 0 && */
9459					if(request.options['overlayPage']) {
9460						e107Event.trigger('ajax_loading_end', request.options, request.options.overlayPage);
9461					} else if(request.options['overlayElement']) {
9462						e107Event.trigger('ajax_loading_element_end', request.options, request.options.overlayElement);
9463					}
9464
9465					if(request.options['updateElement']) {
9466						request.options.element = request.options.updateElement;
9467						e107Event.trigger('ajax_update_after', request.options, request.options.updateElement);
9468					}
9469				},
9470
9471				onException: function(request, e) {
9472					//TODO handle exceptions
9473					alert('e107Ajax Exception: ' + e);
9474				}
9475		}
9476
9477		Ajax.Responders.register(e_responder);
9478})();
9479
9480/**
9481 * e107AjaxAbstract
9482 */
9483var e107AjaxAbstract = Class.create ({
9484	_processResponse: function(transport) {
9485		if(null !== transport.responseXML) {
9486			this._handleXMLResponse(transport.responseXML);
9487		} else if(null !== transport.responseJSON) {
9488			this._handleJSONResponse(transport.responseJSON);
9489		} else {
9490			this._handleTextResponse(transport.responseText);
9491		}
9492
9493	},
9494
9495	_handleXMLResponse: function (response) {
9496		var xfields = $A(response.getElementsByTagName('e107response')[0].childNodes);
9497		var parsed = {};
9498		xfields.each( function(el) {
9499			if (el.nodeType == 1 && el.nodeName == 'e107action' && el.getAttribute('name') && el.childNodes) {
9500
9501				var action = el.getAttribute('name'), items = el.childNodes;
9502				if(!varsettrue(parsed[action])) {
9503					parsed[action] = {};
9504				}
9505
9506				for(var i=0, len=items.length; i<len; i++) {
9507					var field = items[i];
9508
9509					if(field.nodeType!=1)
9510						continue;
9511
9512					if(field.getAttribute('name')) {
9513						var type = field.getAttribute('type'), //not used yet
9514							name = field.getAttribute('name'),
9515							eldata = field.firstChild;
9516						parsed[action][name] = eldata ? eldata.data : '';
9517					}
9518
9519				}
9520			}
9521		}.bind(this));
9522		this._handleResponse(parsed);
9523	},
9524
9525	_handleJSONResponse: function (response) {
9526		this._handleResponse(response);
9527	},
9528
9529	_handleTextResponse: function (response) {
9530		this._handleResponse({ 'auto': response} );
9531	},
9532
9533	_handleResponse: function(parsed) {
9534
9535		Object.keys(parsed).each(function(method) {
9536			try{
9537				this['_processResponse' + ('-' + method).camelize()](parsed[method]);
9538			} catch(e) {
9539				//
9540			}
9541		}.bind(this));
9542
9543	},
9544
9545	_processResponseAuto: function(response) {
9546		//find by keys as IDs & update
9547		Object.keys(response).each(function(key) {
9548			this._updateElement(key, response[key]);
9549		}.bind(this));
9550	},
9551
9552	/**
9553	 * Reset checked property of form elements by selector name attribute (checkbox, radio)
9554	 */
9555	_processResponseResetChecked: function(response) {
9556		Object.keys(response).each(function(key) {
9557			var checked = parseInt(response[key]) ? true : false;
9558			$$('input[name^=' + key + ']').each( function(felement) {
9559				var itype = String(felement.type);
9560				if(itype && 'checkbox radio'.include(itype.toLowerCase()))
9561					felement.checked = checked;
9562			});
9563		}.bind(this));
9564	},
9565
9566	/**
9567	 * Invoke methods on element or element collections by id
9568	 *
9569	 * Examples:
9570	 * {'show': 'id1,id2,id3'} -> show elements with id id1,id2 and id3
9571	 * {'writeAttribute,rel,external': 'id1,id2,id3'} -> invoke writeAttribute('rel', 'external') on elements with id id1,id2 and id3
9572	 */
9573	_processResponseElementInvokeById: function(response) {
9574		//response.key is comma separated list representing method -> args to be invoked on every element
9575		Object.keys(response).each(function(key) {
9576			var tmp = $A(key.split(',')),
9577				method = tmp[0],
9578				args = tmp.slice(1);
9579
9580			//search for boolean type
9581			$A(args).each( function(arg, i) {
9582				switch(arg) {
9583					case 'false': args[i] = false; break;
9584					case 'true': args[i] = true; break;
9585					case 'null': args[i] = null; break;
9586				}
9587			});
9588			//response.value is comma separated element id list
9589			$A(response[key].split(',')).each( function(el) {
9590				el = el ? $(el.strip()) : null;
9591				if(!el) return;
9592
9593				if(Object.isFunction(el[method]))
9594					el[method].apply(el, args);
9595				else if(typeof el[method] !== 'undefined') {
9596					//XXX - should we allow adding values to undefined yet properties? At this time not allowed
9597					el[method] = varset(args[0], null);
9598				}
9599			});
9600		});
9601	},
9602
9603	/**
9604	 * Update element by type
9605	 */
9606	_updateElement: function(el, data) {
9607		el = $(el); if(!el) return;
9608		var type = el.nodeName.toLowerCase(), itype = el.type;
9609        if(type == 'input' || type == 'textarea') {
9610        	if(itype) itype = itype.toLowerCase();
9611        	switch (itype) {
9612        		case 'checkbox':
9613        		case 'radio':
9614        			el.checked = (el.value == data);
9615        			break;
9616        		default:
9617        			el.value = data.unescapeHTML(); //browsers doesn't unescape entities on JS update, why?!
9618        			break;
9619        	}
9620
9621        } else if(type == 'select') {
9622            if(el.options) {
9623                var opt = $A(el.options).find( function(op, ind) {
9624                    return op.value == data;
9625                });
9626                if(opt)
9627                	el.selectedIndex = opt.index;
9628            }
9629        } else if(type == 'img') {
9630        	el.writeAttribute('src', data).show(); //show if hidden
9631        }else if(el.nodeType == 1) {
9632        	el.update(data);
9633        }
9634	}
9635});
9636
9637// -------------------------------------------------------------------
9638
9639/**
9640 * e107Ajax.Request
9641 * Prototype Xtensions http://www.prototypextensions.com/
9642 *
9643 * @desc @desc e107Ajax.Update wrapper, used to execute an Ajax.Request by integrating
9644 * the management of browsing history
9645 */
9646e107Ajax.Request = Class.create({
9647    initialize: function(url, options) {
9648
9649        this.options = {};
9650        Object.extend(this.options, options || {});
9651        if(!this.options['parameters'])
9652        	this.options['parameters'] = { 'ajax_used': 1 }
9653        else if(!this.options.parameters['ajax_used'])
9654        	this.options['parameters']['ajax_used'] = 1;
9655
9656        // only if required
9657        if(this.options['history']) {
9658            var tmpOpt = Object.clone(e107Ajax.ObjectMap);
9659            Object.extend(tmpOpt, this.options.history);
9660            this.options.history = tmpOpt;
9661            this.options.history.__url = url;
9662
9663            // History id
9664            if(Object.isUndefined(options.history.id))
9665                throw('e107Ajax.Request error : you must define historyId');
9666
9667            var id = this.options.history.id;
9668
9669            // Enable history observer
9670            var version = e107Ajax.History.observe('Request', id, url, this.options);
9671
9672            // Set current version value for container
9673            e107History.set(id, version);
9674
9675        } else {
9676            return new Ajax.Request(url, this.options);
9677        }
9678    }
9679});
9680
9681/**
9682 * e107Ajax.Updater
9683 *
9684 * @desc e107Ajax.Updater wrapper, used to execute an Ajax.Updater by integrating
9685 * the management of browsing history
9686 */
9687e107Ajax.Updater = Class.create({
9688    initialize: function(container, url, options) {
9689
9690        this.options = {};
9691
9692        Object.extend(this.options, options || {});
9693        if(!this.options['parameters'])
9694        	this.options['parameters'] = { 'ajax_used': 1 }
9695        else if(!this.options.parameters['ajax_used'])
9696        	this.options['parameters']['ajax_used'] = 1;
9697
9698		//required for ajax_update event trigger
9699		this.options.updateElement = container;
9700
9701        // only if required
9702        if(this.options['history']) {
9703            var tmpOpt = Object.clone(e107Ajax.ObjectMap);
9704            Object.extend(tmpOpt, this.options.history);
9705            this.options.history = tmpOpt;
9706            this.options.history.__url = url;
9707
9708            // History id
9709            if(Object.isUndefined(options.history.id)) {
9710                var id = (Object.isString(container)) ? container : container.identify();
9711                this.options.history.id = id;
9712            } else {
9713                var id = this.options.history.id;
9714            }
9715            // Add container to this.options
9716            this.options.container = container;
9717
9718            // Enable history observer
9719            var version = e107Ajax.History.observe('Updater', id, url, this.options);
9720
9721            // Set current version value for container
9722            e107History.set(id, version);
9723
9724        } else {
9725            return new Ajax.Updater(container, url, this.options);
9726        }
9727    }
9728});
9729
9730Object.extend(e107Ajax, {
9731
9732	/**
9733	 * Ajax Submit Form method
9734	 *
9735	 * @descr e107 analog to Prototpye native Form.request method
9736	 */
9737	submitForm: function(form, container, options, handler) {
9738		var parm = $(form).serialize(true),
9739			opt = Object.clone(options || {}),
9740			url = !handler ? $(form).readAttribute('action') : String(handler).parsePath();
9741
9742		if(!opt.parameters) opt.parameters = {};
9743		Object.extend(opt.parameters, parm || {});
9744		opt.method = 'post';
9745
9746		if ($(form).hasAttribute('method') && !opt.method)
9747		      opt.method = $(form).method;
9748		
9749		if(container)
9750			return new e107Ajax.Updater(container, url, opt);
9751
9752		return new e107Ajax.Request(url, opt);
9753	},
9754
9755	/**
9756	 * Ajax Submit Form method and auto-replace SC method
9757	 */
9758	submitFormSC: function(form, sc, scfile, container) {
9759		var handler = ('#{e_COMPAT}e_ajax.php'), parm = { 'ajax_sc': sc, 'ajax_scfile': scfile };
9760		return this.submitForm(form, varsettrue(container, sc), { parameters: parm, overlayElement: varsettrue(container, sc) }, handler);
9761	},
9762
9763	toggleUpdate: function(toggle, container, url, cacheid, options) {
9764		container = $(container);
9765		toggle = $(toggle);
9766		opt = Object.clone(options || {});
9767		opt.method = 'post';
9768
9769		if(!toggle) return;
9770
9771		if(!toggle.visible())
9772		{
9773
9774			if(cacheid && $(cacheid)) return toggle.fxToggle();
9775			var oldOnComplete = opt['onComplete'];
9776			
9777			opt.onComplete = function(t) { toggle.fxToggle(); if(Object.isFunction(oldOnComplete)) oldOnComplete(t) };
9778			if(url.startsWith('sc:'))
9779			{
9780				return e107Ajax.scUpdate(url.substring(3), container, opt);
9781			}
9782			return new e107Ajax.Updater(container, url, opt);
9783		}
9784
9785		return toggle.fxToggle();
9786	},
9787
9788	scUpdate: function(sc, container, options) {
9789		var handler = ('#{e_COMPAT}e_ajax.php').parsePath(), parm = { 'ajax_sc': sc };
9790		opt = Object.clone(options || {});
9791		opt.method = 'post';
9792		if(!opt.parameters) opt.parameters = {};
9793		Object.extend(opt.parameters, parm || {});
9794		return new e107Ajax.Updater(container, handler, opt);
9795	}
9796});
9797
9798/**
9799 * e107Ajax.fillForm
9800 *
9801 * @desc
9802 */
9803e107Ajax.fillForm = Class.create(e107AjaxAbstract, {
9804
9805	initialize: function(form, overlay_dest, options) {
9806		//TODO - options
9807		this.options = Object.extend({
9808			start: true
9809		}, options || {});
9810
9811		this.form = $(form);
9812		if(!this.form) return;
9813
9814		if(this.options['start'])
9815			this.start(overlay_dest);
9816	},
9817
9818	start: function(overlay_dest) {
9819		e107Event.trigger("ajax_fillForm_start", {form: this.form});
9820		var destEl = $(overlay_dest) || false;
9821		var C = this;
9822
9823		//Ajax history is NOT supported (and shouldn't be)
9824		var options = {
9825			overlayPage: destEl,
9826
9827			history: false,
9828
9829			onSuccess: function(transport) {
9830				try {
9831					this._processResponse(transport);
9832				} catch(e) {
9833					var err_obj = { message: 'Callback Error!', extended: e, code: -1 }
9834					e107Event.trigger("ajax_fillForm_error", {form: this.form, error: err_obj});
9835				}
9836			}.bind(C),
9837
9838			onFailure: function(transport) {
9839				//We don't use transport.statusText only because of Safari!!!
9840				var err = transport.getHeader('e107ErrorMessage') || '';
9841				//TODO - move error messages to the ajax responder object, convert it to an 'error' object (message, extended, code)
9842				//Add Ajax option e.g. printErrors (true|false)
9843				var err_obj = { message: err, extended: transport.responseText, code: transport.status }
9844				e107Event.trigger("ajax_fillForm_error", {form: this.form, error: err_obj });
9845			}.bind(C)
9846		}
9847		Object.extend(options, this.options.request || {}); //update - allow passing request options
9848
9849		this.form.submitForm(null, options, this.options.handler);
9850	},
9851
9852	_processResponseFillForm: function(response) {
9853		if(!response || !this.form) return;
9854		var C = this, left_response = Object.clone(response);
9855		this.form.getElements().each(function(el) {
9856			var elid = el.identify(), elname = el.readAttribute('name'), data, elnameid = String(elname).gsub(/[\[\]\_]/, '-');
9857
9858			if(isset(response[elname])) {
9859				data = response[elname];
9860				if(left_response[elname]) delete left_response[elname];
9861			} else if(isset(response[elnameid])) {
9862				data = response[elnameid];
9863				if(left_response[elnameid]) delete left_response[elnameid];
9864			} else if(isset(response[elid])) {
9865				data = response[elid];
9866				if(left_response[elid]) delete left_response[elid];
9867			} else {
9868				return;
9869			}
9870            this._updateElement(el, data);
9871		}.bind(C));
9872
9873		if(left_response) { //update non-form elements (by id)
9874			Object.keys(left_response).each( function(el) {
9875				this._updateElement(el, left_response[el]);
9876			}.bind(C));
9877		}
9878
9879		e107Event.trigger("ajax_fillForm_success", {form: this.form});
9880	}
9881
9882});
9883
9884Element.addMethods('FORM', {
9885
9886	submitForm: e107Ajax.submitForm.bind(e107Ajax),
9887
9888	submitFormSC: e107Ajax.submitFormSC.bind(e107Ajax),
9889
9890	fillForm: function(form, overlay_element, options) {
9891		new e107Ajax.fillForm(form, overlay_element, options);
9892	}
9893});
9894
9895// -------------------------------------------------------------------
9896
9897//DEPRECATED!!! Use e107Ajax.submitFormSC() || form.submitFormSC() instead
9898function replaceSC(sc, form, container, scfile) {
9899		$(form).submitFormSC(sc, scfile, container);
9900}
9901
9902//DEPRECATED!!! Use e107Ajax.submitForm() || form.submitForm() instead
9903function sendInfo(handler, container, form) {
9904	if(form)
9905		$(form).submitForm(container, null, handler);
9906	else
9907		new e107Ajax.Updater(container, handler);
9908}
9909
9910// -------------------------------------------------------------------
9911
9912/*
9913 * Core Auto-load
9914 */
9915$w('autoExternalLinks autoNoHistory autoHide toggleObserver scrollToObserver').each( function(f) {
9916	e107.runOnLoad(e107Helper[f], null, true);
9917});
9918
9919//shadowbox
9920var Shadowbox=function(){var ua=navigator.userAgent.toLowerCase(),S={version:"3.0b",adapter:null,current:-1,gallery:[],cache:[],content:null,dimensions:null,plugins:null,path:"",options:{adapter:null,animate:true,animateFade:true,autoplayMovies:true,autoDimensions:false,continuous:false,counterLimit:10,counterType:"default",displayCounter:true,displayNav:true,ease:function(x){return 1+Math.pow(x-1,3)},enableKeys:true,errors:{fla:{name:"Flash",url:"http://www.adobe.com/products/flashplayer/"},qt:{name:"QuickTime",url:"http://www.apple.com/quicktime/download/"},wmp:{name:"Windows Media Player",url:"http://www.microsoft.com/windows/windowsmedia/"},f4m:{name:"Flip4Mac",url:"http://www.flip4mac.com/wmv_download.htm"}},ext:{img:["png","jpg","jpeg","gif","bmp"],swf:["swf"],flv:["flv"],qt:["dv","mov","moov","movie","mp4"],wmp:["asf","wm","wmv"],qtwmp:["avi","mpg","mpeg"],iframe:["asp","aspx","cgi","cfm","htm","html","jsp","pl","php","php3","php4","php5","phtml","rb","rhtml","shtml","txt","vbs"]},fadeDuration:0.35,flashParams:{bgcolor:"#000000",allowFullScreen:true},flashVars:{},flashVersion:"9.0.115",handleOversize:"resize",handleUnsupported:"link",initialHeight:160,initialWidth:320,language:"en",modal:false,onChange:null,onClose:null,onFinish:null,onOpen:null,overlayColor:"#000",overlayOpacity:0.8,players:["img"],resizeDuration:0.35,showOverlay:true,showMovieControls:true,skipSetup:false,slideshowDelay:0,useSizzle:true,viewportPadding:20},client:{isIE:ua.indexOf("msie")>-1,isIE6:ua.indexOf("msie 6")>-1,isIE7:ua.indexOf("msie 7")>-1,isGecko:ua.indexOf("gecko")>-1&&ua.indexOf("safari")==-1,isWebkit:ua.indexOf("applewebkit/")>-1,isWindows:ua.indexOf("windows")>-1||ua.indexOf("win32")>-1,isMac:ua.indexOf("macintosh")>-1||ua.indexOf("mac os x")>-1,isLinux:ua.indexOf("linux")>-1},regex:{domain:/:\/\/(.*?)[:\/]/,inline:/#(.+)$/,rel:/^(light|shadow)box/i,gallery:/^(light|shadow)box\[(.*?)\]/i,unsupported:/^unsupported-(\w+)/,param:/\s*([a-z_]*?)\s*=\s*(.+)\s*/},libraries:{Prototype:"prototype",jQuery:"jquery",MooTools:"mootools",YAHOO:"yui",dojo:"dojo",
9920Ext:"ext"},applyOptions:function(opts){if(opts){default_options=apply({},S.options);apply(S.options,opts)}},buildCacheObj:function(link,opts){var href=link.href,obj={el:link,title:link.getAttribute("title"),options:apply({},opts||{}),content:href};each(["player","title","height","width","gallery"],function(o){if(typeof obj.options[o]!="undefined"){obj[o]=obj.options[o];delete obj.options[o]}});if(!obj.player){obj.player=getPlayer(href)}var rel=link.getAttribute("rel");if(rel){var m=rel.match(S.regex.gallery);if(m){obj.gallery=escape(m[2])}each(rel.split(";"),function(p){m=p.match(S.regex.param);if(m){if(m[1]=="options"){eval("apply(obj.options,"+m[2]+")")}else{obj[m[1]]=m[2]}}})}return obj},change:function(n){if(!S.gallery){return}if(!S.gallery[n]){if(!S.options.continuous){return}else{n=n<0?S.gallery.length-1:0}}S.current=n;if(typeof slide_timer=="number"){clearTimeout(slide_timer);slide_timer=null;slide_delay=slide_start=0}if(S.options.onChange){S.options.onChange()}loadContent()},clearCache:function(){each(S.cache,function(obj){if(obj.el){S.lib.removeEvent(obj.el,"click",handleClick)}});S.cache=[]},close:function(){if(!active){return}active=false;listenKeys(false);if(S.content){S.content.remove();S.content=null}if(typeof slide_timer=="number"){clearTimeout(slide_timer)}slide_timer=null;slide_delay=0;if(S.options.onClose){S.options.onClose()}S.skin.onClose();S.revertOptions();each(v_cache,function(c){c[0].style.visibility=c[1]})},contentId:function(){return content_id},getCounter:function(){var len=S.gallery.length;if(S.options.counterType=="skip"){var c=[],i=0,end=len,limit=parseInt(S.options.counterLimit)||0;if(limit<len&&limit>2){var h=Math.floor(limit/2);i=S.current-h;if(i<0){i+=len}end=S.current+(limit-h);if(end>len){end-=len}}while(i!=end){if(i==len){i=0}c.push(i++)}}else{var c=(S.current+1)+" "+S.lang.of+" "+len}return c},getCurrent:function(){return S.current>-1?S.gallery[S.current]:null},hasNext:function(){return S.gallery.length>1&&(S.current!=S.gallery.length-1||S.options.continuous)},init:function(opts){if(initialized){return}initialized=true;opts=opts||{};init_options=opts;if(opts){apply(S.options,opts)}for(var e in S.options.ext){S.regex[e]=new RegExp(".("+S.options.ext[e].join("|")+")s*$","i")}if(!S.path){var path_re=/(.+)shadowbox\.js/i,path;each(document.getElementsByTagName("script"),function(s){if((path=path_re.exec(s.src))!=null){S.path=path[1];return false}})}if(S.options.adapter){S.adapter=S.options.adapter}else{for(var lib in S.libraries){if(typeof window[lib]!="undefined"){S.adapter=S.libraries[lib];break}}if(!S.adapter){S.adapter="base"}}if(S.options.useSizzle&&!window.Sizzle){U.include(S.path+"libraries/sizzle/sizzle.js")}if(!S.lang){U.include(S.path+"languages/shadowbox-"+S.options.language+".js")}each(S.options.players,function(p){if((p=="swf"||p=="flv")&&!window.swfobject){U.include(S.path+"libraries/swfobject/swfobject.js")}if(!S[p]){U.include(S.path+"players/shadowbox-"+p+".js")}});if(!S.lib){U.include(S.path+"adapters/shadowbox-"+S.adapter+".js")}},isActive:function(){return active},isPaused:function(){return slide_timer=="paused"},load:function(){if(S.skin.options){apply(S.options,S.skin.options);apply(S.options,init_options)}var markup=S.skin.markup.replace(/\{(\w+)\}/g,function(m,p){return S.lang[p]});S.lib.append(document.body,markup);if(S.skin.init){S.skin.init()}var id;S.lib.addEvent(window,"resize",function(){if(id){clearTimeout(id);id=null}if(active){id=setTimeout(function(){if(S.skin.onWindowResize){S.skin.onWindowResize()}var c=S.content;if(c&&c.onWindowResize){c.onWindowResize()}},50)}});if(!S.options.skipSetup){S.setup()}},next:function(){S.change(S.current+1)},open:function(obj){if(U.isLink(obj)){obj=S.buildCacheObj(obj)}if(obj.constructor==Array){S.gallery=obj;S.current=0}else{if(!obj.gallery){S.gallery=[obj];S.current=0}else{S.current=null;S.gallery=[];each(S.cache,function(c){if(c.gallery&&c.gallery==obj.gallery){if(S.current==null&&c.content==obj.content&&c.title==obj.title){S.current=S.gallery.length}S.gallery.push(c)}});if(S.current==null){S.gallery.unshift(obj);S.current=0}}}obj=S.getCurrent();if(obj.options){S.revertOptions();S.applyOptions(obj.options)}var g,r,m,s,a,oe=S.options.errors,msg,el;for(var i=0;i<S.gallery.length;++i){g=S.gallery[i]=apply({},S.gallery[i]);r=false;if(g.player=="unsupported"){r=true}else{if(m=S.regex.unsupported.exec(g.player)){if(S.options.handleUnsupported=="link"){g.player="html";switch(m[1]){case"qtwmp":s="either";a=[oe.qt.url,oe.qt.name,oe.wmp.url,oe.wmp.name];break;case"qtf4m":s="shared";a=[oe.qt.url,oe.qt.name,oe.f4m.url,oe.f4m.name];break;default:s="single";if(m[1]=="swf"||m[1]=="flv"){m[1]="fla"}a=[oe[m[1]].url,oe[m[1]].name]}msg=S.lang.errors[s].replace(/\{(\d+)\}/g,function(m,n){return a[n]});g.content='<div class="sb-message">'+msg+"</div>"}else{r=true}}else{if(g.player=="inline"){m=S.regex.inline.exec(g.content);if(m){var el=U.get(m[1]);if(el){g.content=el.innerHTML}else{throw"Cannot find element with id "+m[1]}}else{throw"Cannot find element id for inline content"}}else{if(g.player=="swf"||g.player=="flv"){var version=(g.options&&g.options.flashVersion)||S.options.flashVersion;if(!swfobject.hasFlashPlayerVersion(version)){g.width=310;g.height=177}}}}}if(r){S.gallery.splice(i,1);if(i<S.current){--S.current}else{if(i==S.current){S.current=i>0?i-1:i}}--i}}if(S.gallery.length){if(!active){if(typeof S.options.onOpen=="function"&&S.options.onOpen(obj)===false){return}v_cache=[];each(["select","object","embed","canvas"],function(tag){each(document.getElementsByTagName(tag),function(el){v_cache.push([el,el.style.visibility||"visible"]);el.style.visibility="hidden"})});var h=S.options.autoDimensions&&"height" in obj?obj.height:S.options.initialHeight;var w=S.options.autoDimensions&&"width" in obj?obj.width:S.options.initialWidth;S.skin.onOpen(h,w,loadContent)}else{loadContent()}active=true}},pause:function(){if(typeof slide_timer!="number"){return}var time=new Date().getTime();slide_delay=Math.max(0,slide_delay-(time-slide_start));if(slide_delay){clearTimeout(slide_timer);slide_timer="paused";if(S.skin.onPause){S.skin.onPause()}}},play:function(){if(!S.hasNext()){return}if(!slide_delay){slide_delay=S.options.slideshowDelay*1000}if(slide_delay){slide_start=new Date().getTime();slide_timer=setTimeout(function(){slide_delay=slide_start=0;S.next()},slide_delay);if(S.skin.onPlay){S.skin.onPlay()}}},previous:function(){S.change(S.current-1)},revertOptions:function(){apply(S.options,default_options)},setDimensions:function(height,width,max_h,max_w,tb,lr,resizable){var h=height=parseInt(height),w=width=parseInt(width),pad=parseInt(S.options.viewportPadding)||0;var extra_h=2*pad+tb;if(h+extra_h>=max_h){h=max_h-extra_h}var extra_w=2*pad+lr;if(w+extra_w>
9920=max_w){w=max_w-extra_w}var resize_h=height,resize_w=width,change_h=(height-h)/height,change_w=(width-w)/width,oversized=(change_h>0||change_w>0);if(resizable&&oversized&&S.options.handleOversize=="resize"){if(change_h>change_w){w=Math.round((width/height)*h)}else{if(change_w>change_h){h=Math.round((height/width)*w)}}resize_w=w;resize_h=h}S.dimensions={height:h+tb,width:w+lr,inner_h:h,inner_w:w,top:(max_h-(h+extra_h))/2+pad,left:(max_w-(w+extra_w))/2+pad,oversized:oversized,resize_h:resize_h,resize_w:resize_w};return S.dimensions},setup:function(links,opts){if(!links){var links=[],rel;each(document.getElementsByTagName("a"),function(a){rel=a.getAttribute("rel");if(rel&&S.regex.rel.test(rel)){links.push(a)}})}else{var len=links.length;if(len){if(window.Sizzle){if(typeof links=="string"){links=Sizzle(links)}else{if(len==2&&links.push&&typeof links[0]=="string"&&links[1].nodeType){links=Sizzle(links[0],links[1])}}}}else{links=[links]}}each(links,function(link){if(typeof link.shadowboxCacheKey=="undefined"){link.shadowboxCacheKey=S.cache.length;S.lib.addEvent(link,"click",handleClick)}S.cache[link.shadowboxCacheKey]=S.buildCacheObj(link,opts)})}},U=S.util={animate:function(el,p,to,d,cb){var from=parseFloat(S.lib.getStyle(el,p));if(isNaN(from)){from=0}var delta=to-from;if(delta==0){if(cb){cb()}return}var op=p=="opacity";function fn(ease){var to=from+ease*delta;if(op){U.setOpacity(el,to)}else{el.style[p]=to+"px"}}if(!d||(!op&&!S.options.animate)||(op&&!S.options.animateFade)){fn(1);if(cb){cb()}return}d*=1000;var begin=new Date().getTime(),end=begin+d,time,timer=setInterval(function(){time=new Date().getTime();if(time>=end){clearInterval(timer);fn(1);if(cb){cb()}}else{fn(S.options.ease((time-begin)/d))}},10)},apply:function(o,e){for(var p in e){o[p]=e[p]}return o},clearOpacity:function(el){var s=el.style;if(window.ActiveXObject){if(typeof s.filter=="string"&&(/alpha/i).test(s.filter)){s.filter=s.filter.replace(/[\w\.]*alpha\(.*?\);?/i,"")}}else{s.opacity=""}},each:function(obj,fn,scope){for(var i=0,len=obj.length;i<len;++i){if(fn.call(scope||obj[i],obj[i],i,obj)===false){return}}},get:function(id){return document.getElementById(id)},include:function(){var includes={};return function(file){if(includes[file]){return}includes[file]=true;
9920document.write('<script type="text/javascript" src="'+file+'"><\/script>')}}(),isLink:function(obj){if(!obj||!obj.tagName){return false}var up=obj.tagName.toUpperCase();return up=="A"||up=="AREA"},removeChildren:function(el){while(el.firstChild){el.removeChild(el.firstChild)}},setOpacity:function(el,o){var s=el.style;if(window.ActiveXObject){s.zoom=1;s.filter=(s.filter||"").replace(/\s*alpha\([^\)]*\)/gi,"")+(o==1?"":" alpha(opacity="+(o*100)+")")}else{s.opacity=o}}},apply=U.apply,each=U.each,init_options,initialized=false,default_options={},content_id="sb-content",active=false,slide_timer,slide_start,slide_delay=0,v_cache=[];if(navigator.plugins&&navigator.plugins.length){var names=[];each(navigator.plugins,function(p){names.push(p.name)});names=names.join();var detectPlugin=function(n){return names.indexOf(n)>-1};var f4m=detectPlugin("Flip4Mac");S.plugins={fla:detectPlugin("Shockwave Flash"),qt:detectPlugin("QuickTime"),wmp:!f4m&&detectPlugin("Windows Media"),f4m:f4m}}else{function detectPlugin(n){try{var axo=new ActiveXObject(n)}catch(e){}return !!axo}S.plugins={fla:detectPlugin("ShockwaveFlash.ShockwaveFlash"),qt:detectPlugin("QuickTime.QuickTime"),wmp:detectPlugin("wmplayer.ocx"),f4m:false}}function getPlayer(url){var re=S.regex,p=S.plugins,m=url.match(re.domain),d=m&&document.domain==m[1];if(url.indexOf("#")>-1&&d){return"inline"}var q=url.indexOf("?");if(q>-1){url=url.substring(0,q)}if(re.img.test(url)){return"img"}if(re.swf.test(url)){return p.fla?"swf":"unsupported-swf"}if(re.flv.test(url)){return p.fla?"flv":"unsupported-flv"}if(re.qt.test(url)){return p.qt?"qt":"unsupported-qt"}if(re.wmp.test(url)){if(p.wmp){return"wmp"}if(p.f4m){return"qt"}if(S.client.isMac){return p.qt?"unsupported-f4m":"unsupported-qtf4m"}return"unsupported-wmp"}if(re.qtwmp.test(url)){if(p.qt){return"qt"}if(p.wmp){return"wmp"}return S.client.isMac?"unsupported-qt":"unsupported-qtwmp"}if(!d||re.iframe.test(url)){return"iframe"}return"unsupported"}function handleClick(e){var link;if(U.isLink(this)){link=this}else{link=S.lib.getTarget(e);while(!U.isLink(link)&&link.parentNode){link=link.parentNode}}if(link){var key=link.shadowboxCacheKey;if(typeof key!="undefined"&&typeof S.cache[key]!="undefined"){link=S.cache[key]}S.open(link);if(S.gallery.length){S.lib.preventDefault(e)}}}function listenKeys(on){if(!S.options.enableKeys){return}S.lib[(on?"add":"remove")+"Event"](document,"keydown",handleKey)}function handleKey(e){var code=S.lib.keyCode(e);S.lib.preventDefault(e);switch(code){case 81:case 88:case 27:S.close();break;case 37:S.previous();break;case 39:S.next();break;case 32:S[(typeof slide_timer=="number"?"pause":"play")]()}}function loadContent(){var obj=S.getCurrent();if(!obj){return}var p=obj.player=="inline"?"html":obj.player;if(typeof S[p]!="function"){throw"Unknown player: "+p}var change=false;if(S.content){S.content.remove();change=true;S.revertOptions();if(obj.options){S.applyOptions(obj.options)}}U.removeChildren(S.skin.bodyEl());S.content=new S[p](obj);listenKeys(false);S.skin.onLoad(S.content,change,function(){if(!S.content){return}if(typeof S.content.ready!="undefined"){var id=setInterval(function(){if(S.content){if(S.content.ready){clearInterval(id);id=null;S.skin.onReady(contentReady)}}else{clearInterval(id);id=null}},100)}else{S.skin.onReady(contentReady)}});if(S.gallery.length>1){var next=S.gallery[S.current+1]||S.gallery[0];if(next.player=="img"){var a=new Image();a.src=next.content}var prev=S.gallery[S.current-1]||S.gallery[S.gallery.length-1];if(prev.player=="img"){var b=new Image();b.src=prev.content}}}function contentReady(){if(!S.content){return}S.content.append(S.skin.bodyEl(),content_id,S.dimensions);S.skin.onFinish(finishContent)}function finishContent(){if(!S.content){return}if(S.content.onLoad){S.content.onLoad()}if(S.options.onFinish){S.options.onFinish()}if(!S.isPaused()){S.play()}listenKeys(true)}return S}();Shadowbox.skin=function(){var e=Shadowbox,d=e.util,o=false,k=["sb-nav-close","sb-nav-next","sb-nav-play","sb-nav-pause","sb-nav-previous"];function l(){d.get("sb-container").style.top=document.documentElement.scrollTop+"px"}function g(p){var q=d.get("sb-overlay"),r=d.get("sb-container"),t=d.get("sb-wrapper");if(p){if(e.client.isIE6){l();e.lib.addEvent(window,"scroll",l)}if(e.options.showOverlay){o=true;q.style.backgroundColor=e.options.overlayColor;d.setOpacity(q,0);if(!e.options.modal){e.lib.addEvent(q,"click",e.close)}t.style.display="none"}r.style.visibility="visible";if(o){var s=parseFloat(e.options.overlayOpacity);d.animate(q,"opacity",s,e.options.fadeDuration,p)}else{p()}}else{if(e.client.isIE6){e.lib.removeEvent(window,"scroll",l)}e.lib.removeEvent(q,"click",e.close);if(o){t.style.display="none";d.animate(q,"opacity",0,e.options.fadeDuration,function(){r.style.display="";t.style.display="";d.clearOpacity(q)})}else{r.style.visibility="hidden"}}}function b(r,p){var q=d.get("sb-nav-"+r);if(q){q.style.display=p?"":"none"}}function i(r,q){var t=d.get("sb-loading"),v=e.getCurrent().player,u=(v=="img"||v=="html");if(r){function s(){d.clearOpacity(t);if(q){q()}}d.setOpacity(t,0);t.style.display="";if(u){d.animate(t,"opacity",1,e.options.fadeDuration,s)}else{s()}}else{function s(){t.style.display="none";d.clearOpacity(t);if(q){q()}}if(u){d.animate(t,"opacity",0,e.options.fadeDuration,s)}else{s()}}}function a(s){var u=e.getCurrent();d.get("sb-title-inner").innerHTML=u.title||"";var x,r,t,y,q;if(e.options.displayNav){x=true;var w=e.gallery.length;if(w>1){if(e.options.continuous){r=q=true}else{r=(w-1)>e.current;q=e.current>0}}if(e.options.slideshowDelay>0&&e.hasNext()){y=!e.isPaused();t=!y}}else{x=r=t=y=q=false}b("close",x);b("next",r);b("play",t);b("pause",y);b("previous",q);var x="";if(e.options.displayCounter&&e.gallery.length>1){var v=e.getCounter();if(typeof v=="string"){x=v}else{d.each(v,function(p){x+='<a onclick="Shadowbox.change('+p+');"';if(p==e.current){x+=' class="sb-counter-current"'}x+=">"+(p+1)+"</a>"})}}d.get("sb-counter").innerHTML=x;s()}function h(r,q){var w=d.get("sb-wrapper"),z=d.get("sb-title"),s=d.get("sb-info"),p=d.get("sb-title-inner"),x=d.get("sb-info-inner"),y=parseInt(e.lib.getStyle(p,"height"))||0,v=parseInt(e.lib.getStyle(x,"height"))||0;function u(){p.style.visibility=x.style.visibility="hidden";a(q)}if(r){d.animate(z,"height",0,0.35);d.animate(s,"height",0,0.35);d.animate(w,"paddingTop",y,0.35);d.animate(w,"paddingBottom",v,0.35,u)}else{z.style.height=s.style.height="0px";w.style.paddingTop=y+"px";w.style.paddingBottom=v+"px";u()}}function j(r){var q=d.get("sb-wrapper"),u=d.get("sb-title"),s=d.get("sb-info"),x=d.get("sb-title-inner"),w=d.get("sb-info-inner"),v=parseInt(e.lib.getStyle(x,"height"))||0,p=parseInt(e.lib.getStyle(w,"height"))||0;x.style.visibility=w.style.visibility="";if(x.innerHTML!=""){d.animate(u,"height",v,0.35);d.animate(q,"paddingTop",0,0.35)}d.animate(s,"height",p,0.35);d.animate(q,"paddingBottom",0,0.35,r)}function c(q,x,w,p){var y=d.get("sb-body"),v=d.get("sb-wrapper"),u=parseInt(q),r=parseInt(x);if(w){d.animate(y,"height",u,e.options.resizeDuration);d.animate(v,"top",r,e.options.resizeDuration,p)}else{y.style.height=u+"px";v.style.top=r+"px";if(p){p()}}}function f(u,x,v,p){var t=d.get("sb-wrapper"),r=parseInt(u),q=parseInt(x);if(v){d.animate(t,"width",r,e.options.resizeDuration);d.animate(t,"left",q,e.options.resizeDuration,p)}else{t.style.width=r+"px";t.style.left=q+"px";if(p){p()}}}function n(p){var r=e.content;if(!r){return}var q=m(r.height,r.width,r.resizable);switch(e.options.animSequence){case"hw":c(q.inner_h,q.top,true,function(){f(q.width,q.left,true,p)});break;case"wh":f(q.width,q.left,true,function(){c(q.inner_h,q.top,true,p)});break;default:f(q.width,q.left,true);c(q.inner_h,q.top,true,p)}}function m(p,s,r){var q=d.get("sb-body-inner");sw=d.get("sb-wrapper"),so=d.get("sb-overlay"),tb=sw.offsetHeight-q.offsetHeight,lr=sw.offsetWidth-q.offsetWidth,max_h=so.offsetHeight,max_w=so.offsetWidth;return e.setDimensions(p,s,max_h,max_w,tb,lr,r)}return{markup:'<div id="sb-container"><div id="sb-overlay"></div><div id="sb-wrapper"><div id="sb-title"><div id="sb-title-inner"></div></div><div id="sb-body"><div id="sb-body-inner"></div><div id="sb-loading">
9920<a onclick="Shadowbox.close()">{cancel}</a></div></div><div id="sb-info"><div id="sb-info-inner"><div id="sb-counter"></div><div id="sb-nav"><a id="sb-nav-close" title="{close}" onclick="Shadowbox.close()"></a><a id="sb-nav-next" title="{next}" onclick="Shadowbox.next()"></a><a id="sb-nav-play" title="{play}" onclick="Shadowbox.play()"></a><a id="sb-nav-pause" title="{pause}" onclick="Shadowbox.pause()"></a><a id="sb-nav-previous" title="{previous}" onclick="Shadowbox.previous()"></a></div><div style="clear:both"></div></div></div></div></div>',options:{animSequence:"sync"},init:function(){if(e.client.isIE6){d.get("sb-body").style.zoom=1;var r,p,q=/url\("(.*\.png)"\)/;d.each(k,function(s){r=d.get(s);if(r){p=e.lib.getStyle(r,"backgroundImage").match(q);if(p){r.style.backgroundImage="none";r.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src="+p[1]+",sizingMethod=scale);"}}})}},bodyEl:function(){return d.get("sb-body-inner")},onOpen:function(r,q,p){d.get("sb-container").style.display="block";var s=m(r,q);c(s.inner_h,s.top,false);f(s.width,s.left,false);g(p)},onLoad:function(q,r,p){i(true);h(r,function(){if(!q){return}if(!r){d.get("sb-wrapper").style.display=""}p()})},onReady:function(p){n(function(){j(p)})},onFinish:function(p){i(false,p)},onClose:function(){g(false)},onPlay:function(){b("play",false);b("pause",true)},onPause:function(){b("pause",false);b("play",true)},onWindowResize:function(){var r=e.content;if(!r){return}var q=m(r.height,r.width,r.resizable);f(q.width,q.left,false);c(q.inner_h,q.top,false);var p=d.get(e.contentId());if(p){if(r.resizable&&e.options.handleOversize=="resize"){p.height=q.resize_h;p.width=q.resize_w}}}}}();
9921
9922//shadowbox-extend
9923if(typeof e107_selectedInputArea=="undefined"){var e107_selectedInputArea}
9923Object.extend(Shadowbox,{getSelectedInputArea:function(){return typeof e107Helper==="object"?e107Helper.BB.__selectedInputArea:e107_selectedInputArea||null},e107addText:function(a){if(!this.getSelectedInputArea()){alert(this.options.alertSelected);return}addtext(this.implodeContentFields(a));this.close();return false},implodeContentFields:function(a){return this.runImplodeMod(a)},runImplodeMod:function(b){var a,c=$(b.form);switch(b.mod){case"advanced_sgallery":case"default_sgallery":a=this.runImplodeSgallery(b.mod,c);break;default:a=this.runImplodeDefault(b.mod,c);break}return a},runImplodeDefault:function(e,d){var i="",a="",b="",c="",f="",h="",g="";d.getElements().each(function(j){switch(j.name){case"sb_img":i=j.value;break;case"sb_thimg":f=j.value;break;case"sb_thtext":if(!f&&j.value){f=j.value}break;case"sb_title":a=j.value;break;case"sb_caption":h=j.value;break;case"sb_params":g=j.value;break;case"sb_group":b=j.value;break;case"sb_float":c=j.value;break}});a+="::"+h;if(g){a+="::"+g}return"[shadowbox="+i+"|"+a+"|"+b+"|"+c+"]"+f+"[/shadowbox]"},runImplodeSgallery:function(g,f){var k="",a="",c="",d="",h="",e="",b="",j="",i="";f.getElements().each(function(l){switch(l.name){case"sb_img":k=l.value;break;case"sb_thw":h=l.value;break;case"sb_thh":e=l.value;break;case"sb_thfar":b=l.value;break;case"sb_title":a=l.value;break;case"sb_caption":j=l.value;break;case"sb_params":i=l.value;break;case"sb_group":c=l.value;break;case"sb_float":d=l.value;break}});a+="::"+j;if(i){a+="::"+i}return"[thumb="+h+","+e+","+b+"|"+a+"|"+c+"|"+d+"]"+k+"[/thumb]"}});
9924
9925//adapters/shadowbox-prototype
9926if(typeof Prototype=="undefined"){throw"Unable to load Shadowbox adapter, Prototype not found"}if(typeof Shadowbox=="undefined"){throw"Unable to load Shadowbox adapter, Shadowbox not found"}Shadowbox.lib={getStyle:function(b,a){return Element.getStyle(b,a)},remove:function(a){Element.remove(a)},getTarget:function(a){return Event.element(a)},getPageXY:function(b){var a=Event.pointer(b);return[a.x,a.y]},preventDefault:function(a){Event.stop(a)},keyCode:function(a){return a.keyCode},addEvent:function(c,a,b){Event.observe(c,a,b)},removeEvent:function(c,a,b){Event.stopObserving(c,a,b)},append:function(b,a){Element.insert(b,a)}};document.observe("dom:loaded",Shadowbox.load);
9927
9928//libraries/sizzle/sizzle
9929/*
9930 * Sizzle CSS Selector Engine - v1.0
9931 *  Copyright 2009, The Dojo Foundation
9932 *  Released under the MIT, BSD, and GPL Licenses.
9933 *  More information: http://sizzlejs.com/
9934 */
9935(function(){var p=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,i=0,d=Object.prototype.toString,n=false;var b=function(D,t,A,v){A=A||[];var e=t=t||document;if(t.nodeType!==1&&t.nodeType!==9){return[]}if(!D||typeof D!=="string"){return A}var B=[],C,y,G,F,z,s,r=true,w=o(t);p.lastIndex=0;while((C=p.exec(D))!==null){B.push(C[1]);if(C[2]){s=RegExp.rightContext;break}}if(B.length>1&&j.exec(D)){if(B.length===2&&f.relative[B[0]]){y=g(B[0]+B[1],t)}else{y=f.relative[B[0]]?[t]:b(B.shift(),t);while(B.length){D=B.shift();if(f.relative[D]){D+=B.shift()}y=g(D,y)}}}else{if(!v&&B.length>1&&t.nodeType===9&&!w&&f.match.ID.test(B[0])&&!f.match.ID.test(B[B.length-1])){var H=b.find(B.shift(),t,w);t=H.expr?b.filter(H.expr,H.set)[0]:H.set[0]}if(t){var H=v?{expr:B.pop(),set:a(v)}:b.find(B.pop(),B.length===1&&(B[0]==="~"||B[0]==="+")&&t.parentNode?t.parentNode:t,w);y=H.expr?b.filter(H.expr,H.set):H.set;if(B.length>0){G=a(y)}else{r=false}while(B.length){var u=B.pop(),x=u;if(!f.relative[u]){u=""}else{x=B.pop()}if(x==null){x=t}f.relative[u](G,x,w)}}else{G=B=[]}}if(!G){G=y}if(!G){throw"Syntax error, unrecognized expression: "+(u||D)}if(d.call(G)==="[object Array]"){if(!r){A.push.apply(A,G)}else{if(t&&t.nodeType===1){for(var E=0;G[E]!=null;E++){if(G[E]&&(G[E]===true||G[E].nodeType===1&&h(t,G[E]))){A.push(y[E])}}}else{for(var E=0;G[E]!=null;E++){if(G[E]&&G[E].nodeType===1){A.push(y[E])}}}}}else{a(G,A)}if(s){b(s,e,A,v);b.uniqueSort(A)}return A};b.uniqueSort=function(r){if(c){n=false;r.sort(c);if(n){for(var e=1;e<r.length;e++){if(r[e]===r[e-1]){r.splice(e--,1)}}}}};b.matches=function(e,r){return b(e,null,null,r)};b.find=function(x,e,y){var w,u;if(!x){return[]}for(var t=0,s=f.order.length;t<s;t++){var v=f.order[t],u;if((u=f.match[v].exec(x))){var r=RegExp.leftContext;if(r.substr(r.length-1)!=="\\"){u[1]=(u[1]||"").replace(/\\/g,"");w=f.find[v](u,e,y);if(w!=null){x=x.replace(f.match[v],"");break}}}}if(!w){w=e.getElementsByTagName("*")}return{set:w,expr:x}};b.filter=function(A,z,D,t){var s=A,F=[],x=z,v,e,w=z&&z[0]&&o(z[0]);while(A&&z.length){for(var y in f.filter){if((v=f.match[y].exec(A))!=null){var r=f.filter[y],E,C;e=false;if(x==F){F=[]}if(f.preFilter[y]){v=f.preFilter[y](v,x,D,F,t,w);if(!v){e=E=true}else{if(v===true){continue}}}if(v){for(var u=0;(C=x[u])!=null;u++){if(C){E=r(C,v,u,x);var B=t^!!E;if(D&&E!=null){if(B){e=true}else{x[u]=false}}else{if(B){F.push(C);e=true}}}}}
9935if(E!==undefined){if(!D){x=F}A=A.replace(f.match[y],"");if(!e){return[]}break}}}if(A==s){if(e==null){throw"Syntax error, unrecognized expression: "+A}else{break}}s=A}return x};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(x,e,w){var u=typeof e==="string",y=u&&!/\W/.test(e),v=u&&!y;if(y&&!w){e=e.toUpperCase()}for(var t=0,s=x.length,r;t<s;t++){if((r=x[t])){while((r=r.previousSibling)&&r.nodeType!==1){}x[t]=v||r&&r.nodeName===e?r||false:r===e}}if(v){b.filter(e,x,true)}},">":function(w,r,x){var u=typeof r==="string";if(u&&!/\W/.test(r)){r=x?r:r.toUpperCase();for(var s=0,e=w.length;s<e;s++){var v=w[s];if(v){var t=v.parentNode;w[s]=t.nodeName===r?t:false}}}else{for(var s=0,e=w.length;s<e;s++){var v=w[s];if(v){w[s]=u?v.parentNode:v.parentNode===r}}if(u){b.filter(r,w,true)}}},"":function(t,r,v){var s=i++,e=q;if(!r.match(/\W/)){var u=r=v?r:r.toUpperCase();e=m}e("parentNode",r,s,t,u,v)},"~":function(t,r,v){var s=i++,e=q;if(typeof r==="string"&&!r.match(/\W/)){var u=r=v?r:r.toUpperCase();e=m}e("previousSibling",r,s,t,u,v)}},find:{ID:function(r,s,t){if(typeof s.getElementById!=="undefined"&&!t){var e=s.getElementById(r[1]);return e?[e]:[]}},NAME:function(s,v,w){if(typeof v.getElementsByName!=="undefined"){var r=[],u=v.getElementsByName(s[1]);for(var t=0,e=u.length;t<e;t++){if(u[t].getAttribute("name")===s[1]){r.push(u[t])}}return r.length===0?null:r}},TAG:function(e,r){return r.getElementsByTagName(e[1])}},preFilter:{CLASS:function(t,r,s,e,w,x){t=" "+t[1].replace(/\\/g,"")+" ";if(x){return t}for(var u=0,v;(v=r[u])!=null;u++){if(v){if(w^(v.className&&(" "+v.className+" ").indexOf(t)>=0)){if(!s){e.push(v)}}else{if(s){r[u]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(r,e){for(var s=0;e[s]===false;s++){}return e[s]&&o(e[s])?r[1]:r[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var r=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(r[1]+(r[2]||1))-0;e[3]=r[3]-0}e[0]=i++;return e},ATTR:function(u,r,s,e,v,w){var t=u[1].replace(/\\/g,"");if(!w&&f.attrMap[t]){u[1]=f.attrMap[t]}if(u[2]==="~="){u[4]=" "+u[4]+" "}return u},PSEUDO:function(u,r,s,e,v){if(u[1]==="not"){if(u[3].match(p).length>1||/^\w/.test(u[3])){u[3]=b(u[3],null,null,r)}else{var t=b.filter(u[3],r,s,true^v);if(!s){e.push.apply(e,t)}return false}}else{if(f.match.POS.test(u[0])||f.match.CHILD.test(u[0])){return true}}return u},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(s,r,e){return !!b(e[3],s).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(r,e){return e===0},last:function(s,r,e,t){return r===t.length-1},even:function(r,e){return e%2===0},odd:function(r,e){return e%2===1},lt:function(s,r,e){return r<e[3]-0},gt:function(s,r,e){return r>e[3]-0},nth:function(s,r,e){return e[3]-0==r},eq:function(s,r,e){return e[3]-0==r}},filter:{PSEUDO:function(w,s,t,x){var r=s[1],u=f.filters[r];if(u){return u(w,t,s,x)}else{if(r==="contains"){return(w.textContent||w.innerText||"").indexOf(s[3])>=0}else{if(r==="not"){var v=s[3];for(var t=0,e=v.length;t<e;t++){if(v[t]===w){return false}}return true}}}},CHILD:function(e,t){var w=t[1],r=e;switch(w){case"only":case"first":while(r=r.previousSibling){if(r.nodeType===1){return false}}if(w=="first"){return true}r=e;case"last":while(r=r.nextSibling){if(r.nodeType===1){return false}}return true;case"nth":var s=t[2],z=t[3];if(s==1&&z==0){return true}var v=t[0],y=e.parentNode;if(y&&(y.sizcache!==v||!e.nodeIndex)){var u=0;for(r=y.firstChild;r;r=r.nextSibling){if(r.nodeType===1){r.nodeIndex=++u}}y.sizcache=v}var x=e.nodeIndex-z;if(s==0){return x==0}else{return(x%s==0&&x/s>=0)}}},ID:function(r,e){return r.nodeType===1&&r.getAttribute("id")===e},TAG:function(r,e){return(e==="*"&&r.nodeType===1)||r.nodeName===e},CLASS:function(r,e){return(" "+(r.className||r.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(v,t){var s=t[1],e=f.attrHandle[s]?f.attrHandle[s](v):v[s]!=null?v[s]:v.getAttribute(s),w=e+"",u=t[2],r=t[4];return e==null?u==="!=":u==="="?w===r:u==="*="?w.indexOf(r)>=0:u==="~="?(" "+w+" ").indexOf(r)>=0:!r?w&&e!==false:u==="!="?w!=r:u==="^="?w.indexOf(r)===0:u==="$="?w.substr(w.length-r.length)===r:u==="|="?w===r||w.substr(0,r.length+1)===r+"-":false},POS:function(u,r,s,v){var e=r[2],t=f.setFilters[e];if(t){return t(u,s,r,v)}}}};var j=f.match.POS;for(var l in f.match){f.match[l]=new RegExp(f.match[l].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var a=function(r,e){r=Array.prototype.slice.call(r);if(e){e.push.apply(e,r);return e}return r};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(k){a=function(u,t){var r=t||[];if(d.call(u)==="[object Array]"){Array.prototype.push.apply(r,u)}else{if(typeof u.length==="number"){for(var s=0,e=u.length;s<e;s++){r.push(u[s])}}else{for(var s=0;u[s];s++){r.push(u[s])}}}return r}}var c;if(document.documentElement.compareDocumentPosition){c=function(r,e){var s=r.compareDocumentPosition(e)&4?-1:r===e?0:1;if(s===0){n=true}return s}}else{if("sourceIndex" in document.documentElement){c=function(r,e){var s=r.sourceIndex-e.sourceIndex;if(s===0){n=true}return s}}else{if(document.createRange){c=function(t,r){var s=t.ownerDocument.createRange(),e=r.ownerDocument.createRange();s.selectNode(t);s.collapse(true);
9935e.selectNode(r);e.collapse(true);var u=s.compareBoundaryPoints(Range.START_TO_END,e);if(u===0){n=true}return u}}}}(function(){var r=document.createElement("div"),s="script"+(new Date).getTime();r.innerHTML="<a name='"+s+"'/>";var e=document.documentElement;e.insertBefore(r,e.firstChild);if(!!document.getElementById(s)){f.find.ID=function(u,v,w){if(typeof v.getElementById!=="undefined"&&!w){var t=v.getElementById(u[1]);return t?t.id===u[1]||typeof t.getAttributeNode!=="undefined"&&t.getAttributeNode("id").nodeValue===u[1]?[t]:undefined:[]}};f.filter.ID=function(v,t){var u=typeof v.getAttributeNode!=="undefined"&&v.getAttributeNode("id");return v.nodeType===1&&u&&u.nodeValue===t}}e.removeChild(r)})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(r,v){var u=v.getElementsByTagName(r[1]);if(r[1]==="*"){var t=[];for(var s=0;u[s];s++){if(u[s].nodeType===1){t.push(u[s])}}u=t}return u}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(r){return r.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var e=b,s=document.createElement("div");s.innerHTML="<p class='TEST'></p>";if(s.querySelectorAll&&s.querySelectorAll(".TEST").length===0){return}b=function(w,v,t,u){v=v||document;if(!u&&v.nodeType===9&&!o(v)){try{return a(v.querySelectorAll(w),t)}catch(x){}}return e(w,v,t,u)};for(var r in e){b[r]=e[r]}})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(r,s,t){if(typeof s.getElementsByClassName!=="undefined"&&!t){return s.getElementsByClassName(r[1])}}})()}function m(r,w,v,A,x,z){var y=r=="previousSibling"&&!z;for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){if(y&&e.nodeType===1){e.sizcache=v;e.sizset=t}e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1&&!z){e.sizcache=v;e.sizset=t}if(e.nodeName===w){u=e;break}e=e[r]}A[t]=u}}}function q(r,w,v,A,x,z){var y=r=="previousSibling"&&!z;for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){if(y&&e.nodeType===1){e.sizcache=v;e.sizset=t}e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1){if(!z){e.sizcache=v;e.sizset=t}if(typeof w!=="string"){if(e===w){u=true;break}}else{if(b.filter(w,[e]).length>0){u=e;break}}}e=e[r]}A[t]=u}}}var h=document.compareDocumentPosition?function(r,e){return r.compareDocumentPosition(e)&16}:function(r,e){return r!==e&&(r.contains?r.contains(e):true)};var o=function(e){return e.nodeType===9&&e.documentElement.nodeName!=="HTML"||!!e.ownerDocument&&e.ownerDocument.documentElement.nodeName!=="HTML"};var g=function(e,x){var t=[],u="",v,s=x.nodeType?[x]:x;while((v=f.match.PSEUDO.exec(e))){u+=v[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var w=0,r=s.length;w<r;w++){b(e,s[w],t)}return b.filter(u,t)};window.Sizzle=b})();
9936
9937//players/shadowbox-img
9938(function(h){var e=h.util,i,k,j="sb-drag-layer",d;function b(){i={x:0,y:0,start_x:null,start_y:null}}function c(m,o,l){if(m){b();var n=["position:absolute","height:"+o+"px","width:"+l+"px","cursor:"+(h.client.isGecko?"-moz-grab":"move"),"background-color:"+(h.client.isIE?"#fff;filter:alpha(opacity=0)":"transparent")].join(";");h.lib.append(h.skin.bodyEl(),'<div id="'+j+'" style="'+n+'"></div>');h.lib.addEvent(e.get(j),"mousedown",g)}else{var p=e.get(j);if(p){h.lib.removeEvent(p,"mousedown",g);h.lib.remove(p)}k=null}}function g(m){h.lib.preventDefault(m);var l=h.lib.getPageXY(m);i.start_x=l[0];i.start_y=l[1];k=e.get(h.contentId());h.lib.addEvent(document,"mousemove",f);h.lib.addEvent(document,"mouseup",a);if(h.client.isGecko){e.get(j).style.cursor="-moz-grabbing"}}function a(){h.lib.removeEvent(document,"mousemove",f);h.lib.removeEvent(document,"mouseup",a);if(h.client.isGecko){e.get(j).style.cursor="-moz-grab"}}function f(o){var q=h.content,p=h.dimensions,n=h.lib.getPageXY(o);var m=n[0]-i.start_x;i.start_x+=m;i.x=Math.max(Math.min(0,i.x+m),p.inner_w-q.width);k.style.left=i.x+"px";var l=n[1]-i.start_y;i.start_y+=l;i.y=Math.max(Math.min(0,i.y+l),p.inner_h-q.height);k.style.top=i.y+"px"}h.img=function(m){this.obj=m;this.resizable=true;this.ready=false;var l=this;d=new Image();d.onload=function(){l.height=m.height?parseInt(m.height,10):d.height;
9938l.width=m.width?parseInt(m.width,10):d.width;l.ready=true;d.onload="";d=null};d.src=m.content};h.img.prototype={append:function(l,o,n){this.id=o;var m=document.createElement("img");m.id=o;m.src=this.obj.content;m.style.position="absolute";m.setAttribute("height",n.resize_h);m.setAttribute("width",n.resize_w);l.appendChild(m)},remove:function(){var l=e.get(this.id);if(l){h.lib.remove(l)}c(false);if(d){d.onload="";d=null}},onLoad:function(){var l=h.dimensions;if(l.oversized&&h.options.handleOversize=="drag"){c(true,l.resize_h,l.resize_w)}},onWindowResize:function(){if(k){var p=h.content,o=h.dimensions,n=parseInt(h.lib.getStyle(k,"top")),m=parseInt(h.lib.getStyle(k,"left"));if(n+p.height<o.inner_h){k.style.top=o.inner_h-p.height+"px"}if(m+p.width<o.inner_w){k.style.left=o.inner_w-p.width+"px"}}}}})(Shadowbox);
9939
9940//players/shadowbox-innerhtml
9941(function(a){a.innerhtml=function(b){this.obj=b;this.width=b.width?parseInt(b.width,10):500;this.height=b.height?parseInt(b.height,10):300};a.innerhtml.prototype={append:function(b,f,d){this.id=f;var e=document.createElement("div"),c=this.obj.content.match("#")?a.util.get(this.obj.content.split("#")[1]):a.util.get(this.obj.content);e.id=f;e.className="html";e.innerHTML=c?c.innerHTML:"";b.appendChild(e)},remove:function(){var b=document.getElementById(this.id);if(b){a.lib.remove(b)}}}})(Shadowbox);
9942
9943//players/shadowbox-html
9944(function(a){a.html=function(b){this.obj=b;this.height=b.height?parseInt(b.height,10):300;this.width=b.width?parseInt(b.width,10):500};a.html.prototype={append:function(b,e,c){this.id=e;var d=document.createElement("div");d.id=e;d.className="html";d.innerHTML=this.obj.content;b.appendChild(d)},remove:function(){var b=document.getElementById(this.id);if(b){a.lib.remove(b)}}}})(Shadowbox);
9945
9946//players/shadowbox-ajax
9947(function(b){var a=b.util,c;b.ajax=function(f){this.obj=f;if(b.options.handleOversize=="drag"){b.options.handleOversize="resize"}b.options.enableKeys=false;this.resizable=false;this.ready=false;if(typeof Ajax==="undefined"||!Ajax.Updater){alert("Error! Ajax Player is supported only in Prototype framework environment at this time.");return}this.width=f.width?parseInt(f.width,10):500;this.height=f.height?parseInt(f.height,10):300;var e=this,g={};new Ajax.Request(f.content,{method:"post",onComplete:function(h){wrapper=new Element("div");var d=h.responseText.length?h.responseText:"Empty response";wrapper.innerHTML=d;c=wrapper.down()?wrapper.down():wrapper;if(!f.width||!f.height){$(c).setStyle({display:"none"});document.body.appendChild(c);g=c.getDimensions();b.lib.remove(c);$(c).setStyle({display:""});if(!f.width&&g.width){e.width=parseInt(g.width,10)}if(!f.height&&g.height){e.height=parseInt(g.height,10)}}e.ready=true}})};b.ajax.prototype={append:function(e,g,f){this.id=g;c.id=g;c.className="html";c.setAttribute("height",f.resize_h);c.setAttribute("width",f.resize_w);e.appendChild(c)},remove:function(){var d=a.get(this.id);if(d){b.lib.remove(d)}if(c){c=null}}}})(Shadowbox);
9948
9949//players/shadowbox-swf
9950(function(b){var a=b.util;b.swf=function(c){this.obj=c;this.resizable=true;this.height=c.height?parseInt(c.height,10):300;this.width=c.width?parseInt(c.width,10):300};b.swf.prototype={append:function(k,d,m){this.id=d;var i=document.createElement("div");i.id=d;k.appendChild(i);var j=m.resize_h,n=m.resize_w,e=this.obj.content,l=b.options.flashVersion,c=b.path+"libraries/swfobject/expressInstall.swf",f=b.options.flashVars,g=b.options.flashParams;swfobject.embedSWF(e,d,n,j,l,c,f,g)},remove:function(){swfobject.expressInstallCallback();swfobject.removeSWF(this.id)}}})(Shadowbox);
9951
9952//players/shadowbox-qt
9953(function(a){var b=16;a.qt=function(c){this.obj=c;this.height=c.height?parseInt(c.height,10):300;if(a.options.showMovieControls==true){this.height+=b}this.width=c.width?parseInt(c.width,10):300};a.qt.prototype={append:function(l,e,n){this.id=e;var f=a.options,g=String(f.autoplayMovies),o=String(f.showMovieControls);var k="<object",i={id:e,name:e,height:this.height,width:this.width,kioskmode:"true"};if(a.client.isIE){i.classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
9953i.codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"}else{i.type="video/quicktime";i.data=this.obj.content}for(var h in i){k+=" "+h+'="'+i[h]+'"'}k+=">";var j={src:this.obj.content,scale:"aspect",controller:o,autoplay:g};for(var c in j){k+='<param name="'+c+'" value="'+j[c]+'">'}k+="</object>";l.innerHTML=k},remove:function(){var f=this.id;try{document[f].Stop()}catch(d){}var c=document.getElementById(f);if(c){a.lib.remove(c)}}}})(Shadowbox);
9954
9955//players/shadowbox-wmp
9956(function(a){var b=(a.client.isIE?70:45);a.wmp=function(c){this.obj=c;this.height=c.height?parseInt(c.height,10):300;if(a.options.showMovieControls){this.height+=b}this.width=c.width?parseInt(c.width,10):300};a.wmp.prototype={append:function(c,j,i){this.id=j;var e=a.options,f=e.autoplayMovies?1:0;var d='<object id="'+j+'" name="'+j+'" height="'+this.height+'" width="'+this.width+'"',h={autostart:e.autoplayMovies?1:0};if(a.client.isIE){d+=' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"';h.url=this.obj.content;h.uimode=e.showMovieControls?"full":"none"}else{d+=' type="video/x-ms-wmv"';d+=' data="'+this.obj.content+'"';h.showcontrols=e.showMovieControls?1:0}d+=">";for(var g in h){d+='<param name="'+g+'" value="'+h[g]+'">'}d+="</object>";c.innerHTML=d},remove:function(){var f=this.id;if(a.client.isIE){try{window[f].controls.stop();window[f].URL="non-existent.wmv";window[f]=function(){}}catch(d){}}var c=document.getElementById(f);if(c){setTimeout(function(){a.lib.remove(c)},10)}}}})(Shadowbox);
9957
9958//languages/shadowbox-hu
9959if(typeof Shadowbox=="undefined"){throw"Unable to load Shadowbox language file, Shadowbox not found."}Shadowbox.lang={code:"hu",of:"/",loading:"Betöltés",cancel:"Mégse",next:"Következõ",previous:"Elõzõ",play:"Lejátszás",pause:"Szünet",close:"Bezárás",errors:{single:'A tartalom megjelenítéséhez a következõ bõvítmény szükséges: <a href="{0}">{1}</a>.',shared:'A tartalom megjelenítéséhez a következõ két bõvítmény szükséges: <a href="{0}">{1}</a>, <a href="{2}">{3}</a>.',either:'A tartalom megjelenítéséhez a következõ bõvítmények valamelyikét telepítenie kell: <a href="{0}">{1}</a> vagy <a href="{2}">{3}</a>.'}};
9960

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.