diff js-lib/prototype.js @ 79:343dc947f999 laserkard

read JavaSctipt: the good parts
author Robert McIntyre <rlm@mit.edu>
date Sun, 25 Jul 2010 01:33:22 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js-lib/prototype.js	Sun Jul 25 01:33:22 2010 -0400
     1.3 @@ -0,0 +1,4874 @@
     1.4 +/*  Prototype JavaScript framework, version 1.6.1
     1.5 + *  (c) 2005-2009 Sam Stephenson
     1.6 + *
     1.7 + *  Prototype is freely distributable under the terms of an MIT-style license.
     1.8 + *  For details, see the Prototype web site: http://www.prototypejs.org/
     1.9 + *
    1.10 + *--------------------------------------------------------------------------*/
    1.11 +
    1.12 +var Prototype = {
    1.13 +  Version: '1.6.1',
    1.14 +
    1.15 +  Browser: (function(){
    1.16 +    var ua = navigator.userAgent;
    1.17 +    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    1.18 +    return {
    1.19 +      IE:             !!window.attachEvent && !isOpera,
    1.20 +      Opera:          isOpera,
    1.21 +      WebKit:         ua.indexOf('AppleWebKit/') > -1,
    1.22 +      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
    1.23 +      MobileSafari:   /Apple.*Mobile.*Safari/.test(ua)
    1.24 +    }
    1.25 +  })(),
    1.26 +
    1.27 +  BrowserFeatures: {
    1.28 +    XPath: !!document.evaluate,
    1.29 +    SelectorsAPI: !!document.querySelector,
    1.30 +    ElementExtensions: (function() {
    1.31 +      var constructor = window.Element || window.HTMLElement;
    1.32 +      return !!(constructor && constructor.prototype);
    1.33 +    })(),
    1.34 +    SpecificElementExtensions: (function() {
    1.35 +      if (typeof window.HTMLDivElement !== 'undefined')
    1.36 +        return true;
    1.37 +
    1.38 +      var div = document.createElement('div');
    1.39 +      var form = document.createElement('form');
    1.40 +      var isSupported = false;
    1.41 +
    1.42 +      if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
    1.43 +        isSupported = true;
    1.44 +      }
    1.45 +
    1.46 +      div = form = null;
    1.47 +
    1.48 +      return isSupported;
    1.49 +    })()
    1.50 +  },
    1.51 +
    1.52 +  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
    1.53 +  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
    1.54 +
    1.55 +  emptyFunction: function() { },
    1.56 +  K: function(x) { return x }
    1.57 +};
    1.58 +
    1.59 +if (Prototype.Browser.MobileSafari)
    1.60 +  Prototype.BrowserFeatures.SpecificElementExtensions = false;
    1.61 +
    1.62 +
    1.63 +var Abstract = { };
    1.64 +
    1.65 +
    1.66 +var Try = {
    1.67 +  these: function() {
    1.68 +    var returnValue;
    1.69 +
    1.70 +    for (var i = 0, length = arguments.length; i < length; i++) {
    1.71 +      var lambda = arguments[i];
    1.72 +      try {
    1.73 +        returnValue = lambda();
    1.74 +        break;
    1.75 +      } catch (e) { }
    1.76 +    }
    1.77 +
    1.78 +    return returnValue;
    1.79 +  }
    1.80 +};
    1.81 +
    1.82 +/* Based on Alex Arnell's inheritance implementation. */
    1.83 +
    1.84 +var Class = (function() {
    1.85 +  function subclass() {};
    1.86 +  function create() {
    1.87 +    var parent = null, properties = $A(arguments);
    1.88 +    if (Object.isFunction(properties[0]))
    1.89 +      parent = properties.shift();
    1.90 +
    1.91 +    function klass() {
    1.92 +      this.initialize.apply(this, arguments);
    1.93 +    }
    1.94 +
    1.95 +    Object.extend(klass, Class.Methods);
    1.96 +    klass.superclass = parent;
    1.97 +    klass.subclasses = [];
    1.98 +
    1.99 +    if (parent) {
   1.100 +      subclass.prototype = parent.prototype;
   1.101 +      klass.prototype = new subclass;
   1.102 +      parent.subclasses.push(klass);
   1.103 +    }
   1.104 +
   1.105 +    for (var i = 0; i < properties.length; i++)
   1.106 +      klass.addMethods(properties[i]);
   1.107 +
   1.108 +    if (!klass.prototype.initialize)
   1.109 +      klass.prototype.initialize = Prototype.emptyFunction;
   1.110 +
   1.111 +    klass.prototype.constructor = klass;
   1.112 +    return klass;
   1.113 +  }
   1.114 +
   1.115 +  function addMethods(source) {
   1.116 +    var ancestor   = this.superclass && this.superclass.prototype;
   1.117 +    var properties = Object.keys(source);
   1.118 +
   1.119 +    if (!Object.keys({ toString: true }).length) {
   1.120 +      if (source.toString != Object.prototype.toString)
   1.121 +        properties.push("toString");
   1.122 +      if (source.valueOf != Object.prototype.valueOf)
   1.123 +        properties.push("valueOf");
   1.124 +    }
   1.125 +
   1.126 +    for (var i = 0, length = properties.length; i < length; i++) {
   1.127 +      var property = properties[i], value = source[property];
   1.128 +      if (ancestor && Object.isFunction(value) &&
   1.129 +          value.argumentNames().first() == "$super") {
   1.130 +        var method = value;
   1.131 +        value = (function(m) {
   1.132 +          return function() { return ancestor[m].apply(this, arguments); };
   1.133 +        })(property).wrap(method);
   1.134 +
   1.135 +        value.valueOf = method.valueOf.bind(method);
   1.136 +        value.toString = method.toString.bind(method);
   1.137 +      }
   1.138 +      this.prototype[property] = value;
   1.139 +    }
   1.140 +
   1.141 +    return this;
   1.142 +  }
   1.143 +
   1.144 +  return {
   1.145 +    create: create,
   1.146 +    Methods: {
   1.147 +      addMethods: addMethods
   1.148 +    }
   1.149 +  };
   1.150 +})();
   1.151 +(function() {
   1.152 +
   1.153 +  var _toString = Object.prototype.toString;
   1.154 +
   1.155 +  function extend(destination, source) {
   1.156 +    for (var property in source)
   1.157 +      destination[property] = source[property];
   1.158 +    return destination;
   1.159 +  }
   1.160 +
   1.161 +  function inspect(object) {
   1.162 +    try {
   1.163 +      if (isUndefined(object)) return 'undefined';
   1.164 +      if (object === null) return 'null';
   1.165 +      return object.inspect ? object.inspect() : String(object);
   1.166 +    } catch (e) {
   1.167 +      if (e instanceof RangeError) return '...';
   1.168 +      throw e;
   1.169 +    }
   1.170 +  }
   1.171 +
   1.172 +  function toJSON(object) {
   1.173 +    var type = typeof object;
   1.174 +    switch (type) {
   1.175 +      case 'undefined':
   1.176 +      case 'function':
   1.177 +      case 'unknown': return;
   1.178 +      case 'boolean': return object.toString();
   1.179 +    }
   1.180 +
   1.181 +    if (object === null) return 'null';
   1.182 +    if (object.toJSON) return object.toJSON();
   1.183 +    if (isElement(object)) return;
   1.184 +
   1.185 +    var results = [];
   1.186 +    for (var property in object) {
   1.187 +      var value = toJSON(object[property]);
   1.188 +      if (!isUndefined(value))
   1.189 +        results.push(property.toJSON() + ': ' + value);
   1.190 +    }
   1.191 +
   1.192 +    return '{' + results.join(', ') + '}';
   1.193 +  }
   1.194 +
   1.195 +  function toQueryString(object) {
   1.196 +    return $H(object).toQueryString();
   1.197 +  }
   1.198 +
   1.199 +  function toHTML(object) {
   1.200 +    return object && object.toHTML ? object.toHTML() : String.interpret(object);
   1.201 +  }
   1.202 +
   1.203 +  function keys(object) {
   1.204 +    var results = [];
   1.205 +    for (var property in object)
   1.206 +      results.push(property);
   1.207 +    return results;
   1.208 +  }
   1.209 +
   1.210 +  function values(object) {
   1.211 +    var results = [];
   1.212 +    for (var property in object)
   1.213 +      results.push(object[property]);
   1.214 +    return results;
   1.215 +  }
   1.216 +
   1.217 +  function clone(object) {
   1.218 +    return extend({ }, object);
   1.219 +  }
   1.220 +
   1.221 +  function isElement(object) {
   1.222 +    return !!(object && object.nodeType == 1);
   1.223 +  }
   1.224 +
   1.225 +  function isArray(object) {
   1.226 +    return _toString.call(object) == "[object Array]";
   1.227 +  }
   1.228 +
   1.229 +
   1.230 +  function isHash(object) {
   1.231 +    return object instanceof Hash;
   1.232 +  }
   1.233 +
   1.234 +  function isFunction(object) {
   1.235 +    return typeof object === "function";
   1.236 +  }
   1.237 +
   1.238 +  function isString(object) {
   1.239 +    return _toString.call(object) == "[object String]";
   1.240 +  }
   1.241 +
   1.242 +  function isNumber(object) {
   1.243 +    return _toString.call(object) == "[object Number]";
   1.244 +  }
   1.245 +
   1.246 +  function isUndefined(object) {
   1.247 +    return typeof object === "undefined";
   1.248 +  }
   1.249 +
   1.250 +  extend(Object, {
   1.251 +    extend:        extend,
   1.252 +    inspect:       inspect,
   1.253 +    toJSON:        toJSON,
   1.254 +    toQueryString: toQueryString,
   1.255 +    toHTML:        toHTML,
   1.256 +    keys:          keys,
   1.257 +    values:        values,
   1.258 +    clone:         clone,
   1.259 +    isElement:     isElement,
   1.260 +    isArray:       isArray,
   1.261 +    isHash:        isHash,
   1.262 +    isFunction:    isFunction,
   1.263 +    isString:      isString,
   1.264 +    isNumber:      isNumber,
   1.265 +    isUndefined:   isUndefined
   1.266 +  });
   1.267 +})();
   1.268 +Object.extend(Function.prototype, (function() {
   1.269 +  var slice = Array.prototype.slice;
   1.270 +
   1.271 +  function update(array, args) {
   1.272 +    var arrayLength = array.length, length = args.length;
   1.273 +    while (length--) array[arrayLength + length] = args[length];
   1.274 +    return array;
   1.275 +  }
   1.276 +
   1.277 +  function merge(array, args) {
   1.278 +    array = slice.call(array, 0);
   1.279 +    return update(array, args);
   1.280 +  }
   1.281 +
   1.282 +  function argumentNames() {
   1.283 +    var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
   1.284 +      .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
   1.285 +      .replace(/\s+/g, '').split(',');
   1.286 +    return names.length == 1 && !names[0] ? [] : names;
   1.287 +  }
   1.288 +
   1.289 +  function bind(context) {
   1.290 +    if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
   1.291 +    var __method = this, args = slice.call(arguments, 1);
   1.292 +    return function() {
   1.293 +      var a = merge(args, arguments);
   1.294 +      return __method.apply(context, a);
   1.295 +    }
   1.296 +  }
   1.297 +
   1.298 +  function bindAsEventListener(context) {
   1.299 +    var __method = this, args = slice.call(arguments, 1);
   1.300 +    return function(event) {
   1.301 +      var a = update([event || window.event], args);
   1.302 +      return __method.apply(context, a);
   1.303 +    }
   1.304 +  }
   1.305 +
   1.306 +  function curry() {
   1.307 +    if (!arguments.length) return this;
   1.308 +    var __method = this, args = slice.call(arguments, 0);
   1.309 +    return function() {
   1.310 +      var a = merge(args, arguments);
   1.311 +      return __method.apply(this, a);
   1.312 +    }
   1.313 +  }
   1.314 +
   1.315 +  function delay(timeout) {
   1.316 +    var __method = this, args = slice.call(arguments, 1);
   1.317 +    timeout = timeout * 1000
   1.318 +    return window.setTimeout(function() {
   1.319 +      return __method.apply(__method, args);
   1.320 +    }, timeout);
   1.321 +  }
   1.322 +
   1.323 +  function defer() {
   1.324 +    var args = update([0.01], arguments);
   1.325 +    return this.delay.apply(this, args);
   1.326 +  }
   1.327 +
   1.328 +  function wrap(wrapper) {
   1.329 +    var __method = this;
   1.330 +    return function() {
   1.331 +      var a = update([__method.bind(this)], arguments);
   1.332 +      return wrapper.apply(this, a);
   1.333 +    }
   1.334 +  }
   1.335 +
   1.336 +  function methodize() {
   1.337 +    if (this._methodized) return this._methodized;
   1.338 +    var __method = this;
   1.339 +    return this._methodized = function() {
   1.340 +      var a = update([this], arguments);
   1.341 +      return __method.apply(null, a);
   1.342 +    };
   1.343 +  }
   1.344 +
   1.345 +  return {
   1.346 +    argumentNames:       argumentNames,
   1.347 +    bind:                bind,
   1.348 +    bindAsEventListener: bindAsEventListener,
   1.349 +    curry:               curry,
   1.350 +    delay:               delay,
   1.351 +    defer:               defer,
   1.352 +    wrap:                wrap,
   1.353 +    methodize:           methodize
   1.354 +  }
   1.355 +})());
   1.356 +
   1.357 +
   1.358 +Date.prototype.toJSON = function() {
   1.359 +  return '"' + this.getUTCFullYear() + '-' +
   1.360 +    (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
   1.361 +    this.getUTCDate().toPaddedString(2) + 'T' +
   1.362 +    this.getUTCHours().toPaddedString(2) + ':' +
   1.363 +    this.getUTCMinutes().toPaddedString(2) + ':' +
   1.364 +    this.getUTCSeconds().toPaddedString(2) + 'Z"';
   1.365 +};
   1.366 +
   1.367 +
   1.368 +RegExp.prototype.match = RegExp.prototype.test;
   1.369 +
   1.370 +RegExp.escape = function(str) {
   1.371 +  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
   1.372 +};
   1.373 +var PeriodicalExecuter = Class.create({
   1.374 +  initialize: function(callback, frequency) {
   1.375 +    this.callback = callback;
   1.376 +    this.frequency = frequency;
   1.377 +    this.currentlyExecuting = false;
   1.378 +
   1.379 +    this.registerCallback();
   1.380 +  },
   1.381 +
   1.382 +  registerCallback: function() {
   1.383 +    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
   1.384 +  },
   1.385 +
   1.386 +  execute: function() {
   1.387 +    this.callback(this);
   1.388 +  },
   1.389 +
   1.390 +  stop: function() {
   1.391 +    if (!this.timer) return;
   1.392 +    clearInterval(this.timer);
   1.393 +    this.timer = null;
   1.394 +  },
   1.395 +
   1.396 +  onTimerEvent: function() {
   1.397 +    if (!this.currentlyExecuting) {
   1.398 +      try {
   1.399 +        this.currentlyExecuting = true;
   1.400 +        this.execute();
   1.401 +        this.currentlyExecuting = false;
   1.402 +      } catch(e) {
   1.403 +        this.currentlyExecuting = false;
   1.404 +        throw e;
   1.405 +      }
   1.406 +    }
   1.407 +  }
   1.408 +});
   1.409 +Object.extend(String, {
   1.410 +  interpret: function(value) {
   1.411 +    return value == null ? '' : String(value);
   1.412 +  },
   1.413 +  specialChar: {
   1.414 +    '\b': '\\b',
   1.415 +    '\t': '\\t',
   1.416 +    '\n': '\\n',
   1.417 +    '\f': '\\f',
   1.418 +    '\r': '\\r',
   1.419 +    '\\': '\\\\'
   1.420 +  }
   1.421 +});
   1.422 +
   1.423 +Object.extend(String.prototype, (function() {
   1.424 +
   1.425 +  function prepareReplacement(replacement) {
   1.426 +    if (Object.isFunction(replacement)) return replacement;
   1.427 +    var template = new Template(replacement);
   1.428 +    return function(match) { return template.evaluate(match) };
   1.429 +  }
   1.430 +
   1.431 +  function gsub(pattern, replacement) {
   1.432 +    var result = '', source = this, match;
   1.433 +    replacement = prepareReplacement(replacement);
   1.434 +
   1.435 +    if (Object.isString(pattern))
   1.436 +      pattern = RegExp.escape(pattern);
   1.437 +
   1.438 +    if (!(pattern.length || pattern.source)) {
   1.439 +      replacement = replacement('');
   1.440 +      return replacement + source.split('').join(replacement) + replacement;
   1.441 +    }
   1.442 +
   1.443 +    while (source.length > 0) {
   1.444 +      if (match = source.match(pattern)) {
   1.445 +        result += source.slice(0, match.index);
   1.446 +        result += String.interpret(replacement(match));
   1.447 +        source  = source.slice(match.index + match[0].length);
   1.448 +      } else {
   1.449 +        result += source, source = '';
   1.450 +      }
   1.451 +    }
   1.452 +    return result;
   1.453 +  }
   1.454 +
   1.455 +  function sub(pattern, replacement, count) {
   1.456 +    replacement = prepareReplacement(replacement);
   1.457 +    count = Object.isUndefined(count) ? 1 : count;
   1.458 +
   1.459 +    return this.gsub(pattern, function(match) {
   1.460 +      if (--count < 0) return match[0];
   1.461 +      return replacement(match);
   1.462 +    });
   1.463 +  }
   1.464 +
   1.465 +  function scan(pattern, iterator) {
   1.466 +    this.gsub(pattern, iterator);
   1.467 +    return String(this);
   1.468 +  }
   1.469 +
   1.470 +  function truncate(length, truncation) {
   1.471 +    length = length || 30;
   1.472 +    truncation = Object.isUndefined(truncation) ? '...' : truncation;
   1.473 +    return this.length > length ?
   1.474 +      this.slice(0, length - truncation.length) + truncation : String(this);
   1.475 +  }
   1.476 +
   1.477 +  function strip() {
   1.478 +    return this.replace(/^\s+/, '').replace(/\s+$/, '');
   1.479 +  }
   1.480 +
   1.481 +  function stripTags() {
   1.482 +    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
   1.483 +  }
   1.484 +
   1.485 +  function stripScripts() {
   1.486 +    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
   1.487 +  }
   1.488 +
   1.489 +  function extractScripts() {
   1.490 +    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
   1.491 +    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
   1.492 +    return (this.match(matchAll) || []).map(function(scriptTag) {
   1.493 +      return (scriptTag.match(matchOne) || ['', ''])[1];
   1.494 +    });
   1.495 +  }
   1.496 +
   1.497 +  function evalScripts() {
   1.498 +    return this.extractScripts().map(function(script) { return eval(script) });
   1.499 +  }
   1.500 +
   1.501 +  function escapeHTML() {
   1.502 +    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
   1.503 +  }
   1.504 +
   1.505 +  function unescapeHTML() {
   1.506 +    return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
   1.507 +  }
   1.508 +
   1.509 +
   1.510 +  function toQueryParams(separator) {
   1.511 +    var match = this.strip().match(/([^?#]*)(#.*)?$/);
   1.512 +    if (!match) return { };
   1.513 +
   1.514 +    return match[1].split(separator || '&').inject({ }, function(hash, pair) {
   1.515 +      if ((pair = pair.split('='))[0]) {
   1.516 +        var key = decodeURIComponent(pair.shift());
   1.517 +        var value = pair.length > 1 ? pair.join('=') : pair[0];
   1.518 +        if (value != undefined) value = decodeURIComponent(value);
   1.519 +
   1.520 +        if (key in hash) {
   1.521 +          if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
   1.522 +          hash[key].push(value);
   1.523 +        }
   1.524 +        else hash[key] = value;
   1.525 +      }
   1.526 +      return hash;
   1.527 +    });
   1.528 +  }
   1.529 +
   1.530 +  function toArray() {
   1.531 +    return this.split('');
   1.532 +  }
   1.533 +
   1.534 +  function succ() {
   1.535 +    return this.slice(0, this.length - 1) +
   1.536 +      String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
   1.537 +  }
   1.538 +
   1.539 +  function times(count) {
   1.540 +    return count < 1 ? '' : new Array(count + 1).join(this);
   1.541 +  }
   1.542 +
   1.543 +  function camelize() {
   1.544 +    var parts = this.split('-'), len = parts.length;
   1.545 +    if (len == 1) return parts[0];
   1.546 +
   1.547 +    var camelized = this.charAt(0) == '-'
   1.548 +      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
   1.549 +      : parts[0];
   1.550 +
   1.551 +    for (var i = 1; i < len; i++)
   1.552 +      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
   1.553 +
   1.554 +    return camelized;
   1.555 +  }
   1.556 +
   1.557 +  function capitalize() {
   1.558 +    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
   1.559 +  }
   1.560 +
   1.561 +  function underscore() {
   1.562 +    return this.replace(/::/g, '/')
   1.563 +               .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
   1.564 +               .replace(/([a-z\d])([A-Z])/g, '$1_$2')
   1.565 +               .replace(/-/g, '_')
   1.566 +               .toLowerCase();
   1.567 +  }
   1.568 +
   1.569 +  function dasherize() {
   1.570 +    return this.replace(/_/g, '-');
   1.571 +  }
   1.572 +
   1.573 +  function inspect(useDoubleQuotes) {
   1.574 +    var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) {
   1.575 +      if (character in String.specialChar) {
   1.576 +        return String.specialChar[character];
   1.577 +      }
   1.578 +      return '\\u00' + character.charCodeAt().toPaddedString(2, 16);
   1.579 +    });
   1.580 +    if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
   1.581 +    return "'" + escapedString.replace(/'/g, '\\\'') + "'";
   1.582 +  }
   1.583 +
   1.584 +  function toJSON() {
   1.585 +    return this.inspect(true);
   1.586 +  }
   1.587 +
   1.588 +  function unfilterJSON(filter) {
   1.589 +    return this.replace(filter || Prototype.JSONFilter, '$1');
   1.590 +  }
   1.591 +
   1.592 +  function isJSON() {
   1.593 +    var str = this;
   1.594 +    if (str.blank()) return false;
   1.595 +    str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
   1.596 +    return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
   1.597 +  }
   1.598 +
   1.599 +  function evalJSON(sanitize) {
   1.600 +    var json = this.unfilterJSON();
   1.601 +    try {
   1.602 +      if (!sanitize || json.isJSON()) return eval('(' + json + ')');
   1.603 +    } catch (e) { }
   1.604 +    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
   1.605 +  }
   1.606 +
   1.607 +  function include(pattern) {
   1.608 +    return this.indexOf(pattern) > -1;
   1.609 +  }
   1.610 +
   1.611 +  function startsWith(pattern) {
   1.612 +    return this.indexOf(pattern) === 0;
   1.613 +  }
   1.614 +
   1.615 +  function endsWith(pattern) {
   1.616 +    var d = this.length - pattern.length;
   1.617 +    return d >= 0 && this.lastIndexOf(pattern) === d;
   1.618 +  }
   1.619 +
   1.620 +  function empty() {
   1.621 +    return this == '';
   1.622 +  }
   1.623 +
   1.624 +  function blank() {
   1.625 +    return /^\s*$/.test(this);
   1.626 +  }
   1.627 +
   1.628 +  function interpolate(object, pattern) {
   1.629 +    return new Template(this, pattern).evaluate(object);
   1.630 +  }
   1.631 +
   1.632 +  return {
   1.633 +    gsub:           gsub,
   1.634 +    sub:            sub,
   1.635 +    scan:           scan,
   1.636 +    truncate:       truncate,
   1.637 +    strip:          String.prototype.trim ? String.prototype.trim : strip,
   1.638 +    stripTags:      stripTags,
   1.639 +    stripScripts:   stripScripts,
   1.640 +    extractScripts: extractScripts,
   1.641 +    evalScripts:    evalScripts,
   1.642 +    escapeHTML:     escapeHTML,
   1.643 +    unescapeHTML:   unescapeHTML,
   1.644 +    toQueryParams:  toQueryParams,
   1.645 +    parseQuery:     toQueryParams,
   1.646 +    toArray:        toArray,
   1.647 +    succ:           succ,
   1.648 +    times:          times,
   1.649 +    camelize:       camelize,
   1.650 +    capitalize:     capitalize,
   1.651 +    underscore:     underscore,
   1.652 +    dasherize:      dasherize,
   1.653 +    inspect:        inspect,
   1.654 +    toJSON:         toJSON,
   1.655 +    unfilterJSON:   unfilterJSON,
   1.656 +    isJSON:         isJSON,
   1.657 +    evalJSON:       evalJSON,
   1.658 +    include:        include,
   1.659 +    startsWith:     startsWith,
   1.660 +    endsWith:       endsWith,
   1.661 +    empty:          empty,
   1.662 +    blank:          blank,
   1.663 +    interpolate:    interpolate
   1.664 +  };
   1.665 +})());
   1.666 +
   1.667 +var Template = Class.create({
   1.668 +  initialize: function(template, pattern) {
   1.669 +    this.template = template.toString();
   1.670 +    this.pattern = pattern || Template.Pattern;
   1.671 +  },
   1.672 +
   1.673 +  evaluate: function(object) {
   1.674 +    if (object && Object.isFunction(object.toTemplateReplacements))
   1.675 +      object = object.toTemplateReplacements();
   1.676 +
   1.677 +    return this.template.gsub(this.pattern, function(match) {
   1.678 +      if (object == null) return (match[1] + '');
   1.679 +
   1.680 +      var before = match[1] || '';
   1.681 +      if (before == '\\') return match[2];
   1.682 +
   1.683 +      var ctx = object, expr = match[3];
   1.684 +      var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
   1.685 +      match = pattern.exec(expr);
   1.686 +      if (match == null) return before;
   1.687 +
   1.688 +      while (match != null) {
   1.689 +        var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1];
   1.690 +        ctx = ctx[comp];
   1.691 +        if (null == ctx || '' == match[3]) break;
   1.692 +        expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
   1.693 +        match = pattern.exec(expr);
   1.694 +      }
   1.695 +
   1.696 +      return before + String.interpret(ctx);
   1.697 +    });
   1.698 +  }
   1.699 +});
   1.700 +Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
   1.701 +
   1.702 +var $break = { };
   1.703 +
   1.704 +var Enumerable = (function() {
   1.705 +  function each(iterator, context) {
   1.706 +    var index = 0;
   1.707 +    try {
   1.708 +      this._each(function(value) {
   1.709 +        iterator.call(context, value, index++);
   1.710 +      });
   1.711 +    } catch (e) {
   1.712 +      if (e != $break) throw e;
   1.713 +    }
   1.714 +    return this;
   1.715 +  }
   1.716 +
   1.717 +  function eachSlice(number, iterator, context) {
   1.718 +    var index = -number, slices = [], array = this.toArray();
   1.719 +    if (number < 1) return array;
   1.720 +    while ((index += number) < array.length)
   1.721 +      slices.push(array.slice(index, index+number));
   1.722 +    return slices.collect(iterator, context);
   1.723 +  }
   1.724 +
   1.725 +  function all(iterator, context) {
   1.726 +    iterator = iterator || Prototype.K;
   1.727 +    var result = true;
   1.728 +    this.each(function(value, index) {
   1.729 +      result = result && !!iterator.call(context, value, index);
   1.730 +      if (!result) throw $break;
   1.731 +    });
   1.732 +    return result;
   1.733 +  }
   1.734 +
   1.735 +  function any(iterator, context) {
   1.736 +    iterator = iterator || Prototype.K;
   1.737 +    var result = false;
   1.738 +    this.each(function(value, index) {
   1.739 +      if (result = !!iterator.call(context, value, index))
   1.740 +        throw $break;
   1.741 +    });
   1.742 +    return result;
   1.743 +  }
   1.744 +
   1.745 +  function collect(iterator, context) {
   1.746 +    iterator = iterator || Prototype.K;
   1.747 +    var results = [];
   1.748 +    this.each(function(value, index) {
   1.749 +      results.push(iterator.call(context, value, index));
   1.750 +    });
   1.751 +    return results;
   1.752 +  }
   1.753 +
   1.754 +  function detect(iterator, context) {
   1.755 +    var result;
   1.756 +    this.each(function(value, index) {
   1.757 +      if (iterator.call(context, value, index)) {
   1.758 +        result = value;
   1.759 +        throw $break;
   1.760 +      }
   1.761 +    });
   1.762 +    return result;
   1.763 +  }
   1.764 +
   1.765 +  function findAll(iterator, context) {
   1.766 +    var results = [];
   1.767 +    this.each(function(value, index) {
   1.768 +      if (iterator.call(context, value, index))
   1.769 +        results.push(value);
   1.770 +    });
   1.771 +    return results;
   1.772 +  }
   1.773 +
   1.774 +  function grep(filter, iterator, context) {
   1.775 +    iterator = iterator || Prototype.K;
   1.776 +    var results = [];
   1.777 +
   1.778 +    if (Object.isString(filter))
   1.779 +      filter = new RegExp(RegExp.escape(filter));
   1.780 +
   1.781 +    this.each(function(value, index) {
   1.782 +      if (filter.match(value))
   1.783 +        results.push(iterator.call(context, value, index));
   1.784 +    });
   1.785 +    return results;
   1.786 +  }
   1.787 +
   1.788 +  function include(object) {
   1.789 +    if (Object.isFunction(this.indexOf))
   1.790 +      if (this.indexOf(object) != -1) return true;
   1.791 +
   1.792 +    var found = false;
   1.793 +    this.each(function(value) {
   1.794 +      if (value == object) {
   1.795 +        found = true;
   1.796 +        throw $break;
   1.797 +      }
   1.798 +    });
   1.799 +    return found;
   1.800 +  }
   1.801 +
   1.802 +  function inGroupsOf(number, fillWith) {
   1.803 +    fillWith = Object.isUndefined(fillWith) ? null : fillWith;
   1.804 +    return this.eachSlice(number, function(slice) {
   1.805 +      while(slice.length < number) slice.push(fillWith);
   1.806 +      return slice;
   1.807 +    });
   1.808 +  }
   1.809 +
   1.810 +  function inject(memo, iterator, context) {
   1.811 +    this.each(function(value, index) {
   1.812 +      memo = iterator.call(context, memo, value, index);
   1.813 +    });
   1.814 +    return memo;
   1.815 +  }
   1.816 +
   1.817 +  function invoke(method) {
   1.818 +    var args = $A(arguments).slice(1);
   1.819 +    return this.map(function(value) {
   1.820 +      return value[method].apply(value, args);
   1.821 +    });
   1.822 +  }
   1.823 +
   1.824 +  function max(iterator, context) {
   1.825 +    iterator = iterator || Prototype.K;
   1.826 +    var result;
   1.827 +    this.each(function(value, index) {
   1.828 +      value = iterator.call(context, value, index);
   1.829 +      if (result == null || value >= result)
   1.830 +        result = value;
   1.831 +    });
   1.832 +    return result;
   1.833 +  }
   1.834 +
   1.835 +  function min(iterator, context) {
   1.836 +    iterator = iterator || Prototype.K;
   1.837 +    var result;
   1.838 +    this.each(function(value, index) {
   1.839 +      value = iterator.call(context, value, index);
   1.840 +      if (result == null || value < result)
   1.841 +        result = value;
   1.842 +    });
   1.843 +    return result;
   1.844 +  }
   1.845 +
   1.846 +  function partition(iterator, context) {
   1.847 +    iterator = iterator || Prototype.K;
   1.848 +    var trues = [], falses = [];
   1.849 +    this.each(function(value, index) {
   1.850 +      (iterator.call(context, value, index) ?
   1.851 +        trues : falses).push(value);
   1.852 +    });
   1.853 +    return [trues, falses];
   1.854 +  }
   1.855 +
   1.856 +  function pluck(property) {
   1.857 +    var results = [];
   1.858 +    this.each(function(value) {
   1.859 +      results.push(value[property]);
   1.860 +    });
   1.861 +    return results;
   1.862 +  }
   1.863 +
   1.864 +  function reject(iterator, context) {
   1.865 +    var results = [];
   1.866 +    this.each(function(value, index) {
   1.867 +      if (!iterator.call(context, value, index))
   1.868 +        results.push(value);
   1.869 +    });
   1.870 +    return results;
   1.871 +  }
   1.872 +
   1.873 +  function sortBy(iterator, context) {
   1.874 +    return this.map(function(value, index) {
   1.875 +      return {
   1.876 +        value: value,
   1.877 +        criteria: iterator.call(context, value, index)
   1.878 +      };
   1.879 +    }).sort(function(left, right) {
   1.880 +      var a = left.criteria, b = right.criteria;
   1.881 +      return a < b ? -1 : a > b ? 1 : 0;
   1.882 +    }).pluck('value');
   1.883 +  }
   1.884 +
   1.885 +  function toArray() {
   1.886 +    return this.map();
   1.887 +  }
   1.888 +
   1.889 +  function zip() {
   1.890 +    var iterator = Prototype.K, args = $A(arguments);
   1.891 +    if (Object.isFunction(args.last()))
   1.892 +      iterator = args.pop();
   1.893 +
   1.894 +    var collections = [this].concat(args).map($A);
   1.895 +    return this.map(function(value, index) {
   1.896 +      return iterator(collections.pluck(index));
   1.897 +    });
   1.898 +  }
   1.899 +
   1.900 +  function size() {
   1.901 +    return this.toArray().length;
   1.902 +  }
   1.903 +
   1.904 +  function inspect() {
   1.905 +    return '#<Enumerable:' + this.toArray().inspect() + '>';
   1.906 +  }
   1.907 +
   1.908 +
   1.909 +
   1.910 +
   1.911 +
   1.912 +
   1.913 +
   1.914 +
   1.915 +
   1.916 +  return {
   1.917 +    each:       each,
   1.918 +    eachSlice:  eachSlice,
   1.919 +    all:        all,
   1.920 +    every:      all,
   1.921 +    any:        any,
   1.922 +    some:       any,
   1.923 +    collect:    collect,
   1.924 +    map:        collect,
   1.925 +    detect:     detect,
   1.926 +    findAll:    findAll,
   1.927 +    select:     findAll,
   1.928 +    filter:     findAll,
   1.929 +    grep:       grep,
   1.930 +    include:    include,
   1.931 +    member:     include,
   1.932 +    inGroupsOf: inGroupsOf,
   1.933 +    inject:     inject,
   1.934 +    invoke:     invoke,
   1.935 +    max:        max,
   1.936 +    min:        min,
   1.937 +    partition:  partition,
   1.938 +    pluck:      pluck,
   1.939 +    reject:     reject,
   1.940 +    sortBy:     sortBy,
   1.941 +    toArray:    toArray,
   1.942 +    entries:    toArray,
   1.943 +    zip:        zip,
   1.944 +    size:       size,
   1.945 +    inspect:    inspect,
   1.946 +    find:       detect
   1.947 +  };
   1.948 +})();
   1.949 +function $A(iterable) {
   1.950 +  if (!iterable) return [];
   1.951 +  if ('toArray' in Object(iterable)) return iterable.toArray();
   1.952 +  var length = iterable.length || 0, results = new Array(length);
   1.953 +  while (length--) results[length] = iterable[length];
   1.954 +  return results;
   1.955 +}
   1.956 +
   1.957 +function $w(string) {
   1.958 +  if (!Object.isString(string)) return [];
   1.959 +  string = string.strip();
   1.960 +  return string ? string.split(/\s+/) : [];
   1.961 +}
   1.962 +
   1.963 +Array.from = $A;
   1.964 +
   1.965 +
   1.966 +(function() {
   1.967 +  var arrayProto = Array.prototype,
   1.968 +      slice = arrayProto.slice,
   1.969 +      _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available
   1.970 +
   1.971 +  function each(iterator) {
   1.972 +    for (var i = 0, length = this.length; i < length; i++)
   1.973 +      iterator(this[i]);
   1.974 +  }
   1.975 +  if (!_each) _each = each;
   1.976 +
   1.977 +  function clear() {
   1.978 +    this.length = 0;
   1.979 +    return this;
   1.980 +  }
   1.981 +
   1.982 +  function first() {
   1.983 +    return this[0];
   1.984 +  }
   1.985 +
   1.986 +  function last() {
   1.987 +    return this[this.length - 1];
   1.988 +  }
   1.989 +
   1.990 +  function compact() {
   1.991 +    return this.select(function(value) {
   1.992 +      return value != null;
   1.993 +    });
   1.994 +  }
   1.995 +
   1.996 +  function flatten() {
   1.997 +    return this.inject([], function(array, value) {
   1.998 +      if (Object.isArray(value))
   1.999 +        return array.concat(value.flatten());
  1.1000 +      array.push(value);
  1.1001 +      return array;
  1.1002 +    });
  1.1003 +  }
  1.1004 +
  1.1005 +  function without() {
  1.1006 +    var values = slice.call(arguments, 0);
  1.1007 +    return this.select(function(value) {
  1.1008 +      return !values.include(value);
  1.1009 +    });
  1.1010 +  }
  1.1011 +
  1.1012 +  function reverse(inline) {
  1.1013 +    return (inline !== false ? this : this.toArray())._reverse();
  1.1014 +  }
  1.1015 +
  1.1016 +  function uniq(sorted) {
  1.1017 +    return this.inject([], function(array, value, index) {
  1.1018 +      if (0 == index || (sorted ? array.last() != value : !array.include(value)))
  1.1019 +        array.push(value);
  1.1020 +      return array;
  1.1021 +    });
  1.1022 +  }
  1.1023 +
  1.1024 +  function intersect(array) {
  1.1025 +    return this.uniq().findAll(function(item) {
  1.1026 +      return array.detect(function(value) { return item === value });
  1.1027 +    });
  1.1028 +  }
  1.1029 +
  1.1030 +
  1.1031 +  function clone() {
  1.1032 +    return slice.call(this, 0);
  1.1033 +  }
  1.1034 +
  1.1035 +  function size() {
  1.1036 +    return this.length;
  1.1037 +  }
  1.1038 +
  1.1039 +  function inspect() {
  1.1040 +    return '[' + this.map(Object.inspect).join(', ') + ']';
  1.1041 +  }
  1.1042 +
  1.1043 +  function toJSON() {
  1.1044 +    var results = [];
  1.1045 +    this.each(function(object) {
  1.1046 +      var value = Object.toJSON(object);
  1.1047 +      if (!Object.isUndefined(value)) results.push(value);
  1.1048 +    });
  1.1049 +    return '[' + results.join(', ') + ']';
  1.1050 +  }
  1.1051 +
  1.1052 +  function indexOf(item, i) {
  1.1053 +    i || (i = 0);
  1.1054 +    var length = this.length;
  1.1055 +    if (i < 0) i = length + i;
  1.1056 +    for (; i < length; i++)
  1.1057 +      if (this[i] === item) return i;
  1.1058 +    return -1;
  1.1059 +  }
  1.1060 +
  1.1061 +  function lastIndexOf(item, i) {
  1.1062 +    i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
  1.1063 +    var n = this.slice(0, i).reverse().indexOf(item);
  1.1064 +    return (n < 0) ? n : i - n - 1;
  1.1065 +  }
  1.1066 +
  1.1067 +  function concat() {
  1.1068 +    var array = slice.call(this, 0), item;
  1.1069 +    for (var i = 0, length = arguments.length; i < length; i++) {
  1.1070 +      item = arguments[i];
  1.1071 +      if (Object.isArray(item) && !('callee' in item)) {
  1.1072 +        for (var j = 0, arrayLength = item.length; j < arrayLength; j++)
  1.1073 +          array.push(item[j]);
  1.1074 +      } else {
  1.1075 +        array.push(item);
  1.1076 +      }
  1.1077 +    }
  1.1078 +    return array;
  1.1079 +  }
  1.1080 +
  1.1081 +  Object.extend(arrayProto, Enumerable);
  1.1082 +
  1.1083 +  if (!arrayProto._reverse)
  1.1084 +    arrayProto._reverse = arrayProto.reverse;
  1.1085 +
  1.1086 +  Object.extend(arrayProto, {
  1.1087 +    _each:     _each,
  1.1088 +    clear:     clear,
  1.1089 +    first:     first,
  1.1090 +    last:      last,
  1.1091 +    compact:   compact,
  1.1092 +    flatten:   flatten,
  1.1093 +    without:   without,
  1.1094 +    reverse:   reverse,
  1.1095 +    uniq:      uniq,
  1.1096 +    intersect: intersect,
  1.1097 +    clone:     clone,
  1.1098 +    toArray:   clone,
  1.1099 +    size:      size,
  1.1100 +    inspect:   inspect,
  1.1101 +    toJSON:    toJSON
  1.1102 +  });
  1.1103 +
  1.1104 +  var CONCAT_ARGUMENTS_BUGGY = (function() {
  1.1105 +    return [].concat(arguments)[0][0] !== 1;
  1.1106 +  })(1,2)
  1.1107 +
  1.1108 +  if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;
  1.1109 +
  1.1110 +  if (!arrayProto.indexOf) arrayProto.indexOf = indexOf;
  1.1111 +  if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf;
  1.1112 +})();
  1.1113 +function $H(object) {
  1.1114 +  return new Hash(object);
  1.1115 +};
  1.1116 +
  1.1117 +var Hash = Class.create(Enumerable, (function() {
  1.1118 +  function initialize(object) {
  1.1119 +    this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
  1.1120 +  }
  1.1121 +
  1.1122 +  function _each(iterator) {
  1.1123 +    for (var key in this._object) {
  1.1124 +      var value = this._object[key], pair = [key, value];
  1.1125 +      pair.key = key;
  1.1126 +      pair.value = value;
  1.1127 +      iterator(pair);
  1.1128 +    }
  1.1129 +  }
  1.1130 +
  1.1131 +  function set(key, value) {
  1.1132 +    return this._object[key] = value;
  1.1133 +  }
  1.1134 +
  1.1135 +  function get(key) {
  1.1136 +    if (this._object[key] !== Object.prototype[key])
  1.1137 +      return this._object[key];
  1.1138 +  }
  1.1139 +
  1.1140 +  function unset(key) {
  1.1141 +    var value = this._object[key];
  1.1142 +    delete this._object[key];
  1.1143 +    return value;
  1.1144 +  }
  1.1145 +
  1.1146 +  function toObject() {
  1.1147 +    return Object.clone(this._object);
  1.1148 +  }
  1.1149 +
  1.1150 +  function keys() {
  1.1151 +    return this.pluck('key');
  1.1152 +  }
  1.1153 +
  1.1154 +  function values() {
  1.1155 +    return this.pluck('value');
  1.1156 +  }
  1.1157 +
  1.1158 +  function index(value) {
  1.1159 +    var match = this.detect(function(pair) {
  1.1160 +      return pair.value === value;
  1.1161 +    });
  1.1162 +    return match && match.key;
  1.1163 +  }
  1.1164 +
  1.1165 +  function merge(object) {
  1.1166 +    return this.clone().update(object);
  1.1167 +  }
  1.1168 +
  1.1169 +  function update(object) {
  1.1170 +    return new Hash(object).inject(this, function(result, pair) {
  1.1171 +      result.set(pair.key, pair.value);
  1.1172 +      return result;
  1.1173 +    });
  1.1174 +  }
  1.1175 +
  1.1176 +  function toQueryPair(key, value) {
  1.1177 +    if (Object.isUndefined(value)) return key;
  1.1178 +    return key + '=' + encodeURIComponent(String.interpret(value));
  1.1179 +  }
  1.1180 +
  1.1181 +  function toQueryString() {
  1.1182 +    return this.inject([], function(results, pair) {
  1.1183 +      var key = encodeURIComponent(pair.key), values = pair.value;
  1.1184 +
  1.1185 +      if (values && typeof values == 'object') {
  1.1186 +        if (Object.isArray(values))
  1.1187 +          return results.concat(values.map(toQueryPair.curry(key)));
  1.1188 +      } else results.push(toQueryPair(key, values));
  1.1189 +      return results;
  1.1190 +    }).join('&');
  1.1191 +  }
  1.1192 +
  1.1193 +  function inspect() {
  1.1194 +    return '#<Hash:{' + this.map(function(pair) {
  1.1195 +      return pair.map(Object.inspect).join(': ');
  1.1196 +    }).join(', ') + '}>';
  1.1197 +  }
  1.1198 +
  1.1199 +  function toJSON() {
  1.1200 +    return Object.toJSON(this.toObject());
  1.1201 +  }
  1.1202 +
  1.1203 +  function clone() {
  1.1204 +    return new Hash(this);
  1.1205 +  }
  1.1206 +
  1.1207 +  return {
  1.1208 +    initialize:             initialize,
  1.1209 +    _each:                  _each,
  1.1210 +    set:                    set,
  1.1211 +    get:                    get,
  1.1212 +    unset:                  unset,
  1.1213 +    toObject:               toObject,
  1.1214 +    toTemplateReplacements: toObject,
  1.1215 +    keys:                   keys,
  1.1216 +    values:                 values,
  1.1217 +    index:                  index,
  1.1218 +    merge:                  merge,
  1.1219 +    update:                 update,
  1.1220 +    toQueryString:          toQueryString,
  1.1221 +    inspect:                inspect,
  1.1222 +    toJSON:                 toJSON,
  1.1223 +    clone:                  clone
  1.1224 +  };
  1.1225 +})());
  1.1226 +
  1.1227 +Hash.from = $H;
  1.1228 +Object.extend(Number.prototype, (function() {
  1.1229 +  function toColorPart() {
  1.1230 +    return this.toPaddedString(2, 16);
  1.1231 +  }
  1.1232 +
  1.1233 +  function succ() {
  1.1234 +    return this + 1;
  1.1235 +  }
  1.1236 +
  1.1237 +  function times(iterator, context) {
  1.1238 +    $R(0, this, true).each(iterator, context);
  1.1239 +    return this;
  1.1240 +  }
  1.1241 +
  1.1242 +  function toPaddedString(length, radix) {
  1.1243 +    var string = this.toString(radix || 10);
  1.1244 +    return '0'.times(length - string.length) + string;
  1.1245 +  }
  1.1246 +
  1.1247 +  function toJSON() {
  1.1248 +    return isFinite(this) ? this.toString() : 'null';
  1.1249 +  }
  1.1250 +
  1.1251 +  function abs() {
  1.1252 +    return Math.abs(this);
  1.1253 +  }
  1.1254 +
  1.1255 +  function round() {
  1.1256 +    return Math.round(this);
  1.1257 +  }
  1.1258 +
  1.1259 +  function ceil() {
  1.1260 +    return Math.ceil(this);
  1.1261 +  }
  1.1262 +
  1.1263 +  function floor() {
  1.1264 +    return Math.floor(this);
  1.1265 +  }
  1.1266 +
  1.1267 +  return {
  1.1268 +    toColorPart:    toColorPart,
  1.1269 +    succ:           succ,
  1.1270 +    times:          times,
  1.1271 +    toPaddedString: toPaddedString,
  1.1272 +    toJSON:         toJSON,
  1.1273 +    abs:            abs,
  1.1274 +    round:          round,
  1.1275 +    ceil:           ceil,
  1.1276 +    floor:          floor
  1.1277 +  };
  1.1278 +})());
  1.1279 +
  1.1280 +function $R(start, end, exclusive) {
  1.1281 +  return new ObjectRange(start, end, exclusive);
  1.1282 +}
  1.1283 +
  1.1284 +var ObjectRange = Class.create(Enumerable, (function() {
  1.1285 +  function initialize(start, end, exclusive) {
  1.1286 +    this.start = start;
  1.1287 +    this.end = end;
  1.1288 +    this.exclusive = exclusive;
  1.1289 +  }
  1.1290 +
  1.1291 +  function _each(iterator) {
  1.1292 +    var value = this.start;
  1.1293 +    while (this.include(value)) {
  1.1294 +      iterator(value);
  1.1295 +      value = value.succ();
  1.1296 +    }
  1.1297 +  }
  1.1298 +
  1.1299 +  function include(value) {
  1.1300 +    if (value < this.start)
  1.1301 +      return false;
  1.1302 +    if (this.exclusive)
  1.1303 +      return value < this.end;
  1.1304 +    return value <= this.end;
  1.1305 +  }
  1.1306 +
  1.1307 +  return {
  1.1308 +    initialize: initialize,
  1.1309 +    _each:      _each,
  1.1310 +    include:    include
  1.1311 +  };
  1.1312 +})());
  1.1313 +
  1.1314 +
  1.1315 +
  1.1316 +var Ajax = {
  1.1317 +  getTransport: function() {
  1.1318 +    return Try.these(
  1.1319 +      function() {return new XMLHttpRequest()},
  1.1320 +      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
  1.1321 +      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
  1.1322 +    ) || false;
  1.1323 +  },
  1.1324 +
  1.1325 +  activeRequestCount: 0
  1.1326 +};
  1.1327 +
  1.1328 +Ajax.Responders = {
  1.1329 +  responders: [],
  1.1330 +
  1.1331 +  _each: function(iterator) {
  1.1332 +    this.responders._each(iterator);
  1.1333 +  },
  1.1334 +
  1.1335 +  register: function(responder) {
  1.1336 +    if (!this.include(responder))
  1.1337 +      this.responders.push(responder);
  1.1338 +  },
  1.1339 +
  1.1340 +  unregister: function(responder) {
  1.1341 +    this.responders = this.responders.without(responder);
  1.1342 +  },
  1.1343 +
  1.1344 +  dispatch: function(callback, request, transport, json) {
  1.1345 +    this.each(function(responder) {
  1.1346 +      if (Object.isFunction(responder[callback])) {
  1.1347 +        try {
  1.1348 +          responder[callback].apply(responder, [request, transport, json]);
  1.1349 +        } catch (e) { }
  1.1350 +      }
  1.1351 +    });
  1.1352 +  }
  1.1353 +};
  1.1354 +
  1.1355 +Object.extend(Ajax.Responders, Enumerable);
  1.1356 +
  1.1357 +Ajax.Responders.register({
  1.1358 +  onCreate:   function() { Ajax.activeRequestCount++ },
  1.1359 +  onComplete: function() { Ajax.activeRequestCount-- }
  1.1360 +});
  1.1361 +Ajax.Base = Class.create({
  1.1362 +  initialize: function(options) {
  1.1363 +    this.options = {
  1.1364 +      method:       'post',
  1.1365 +      asynchronous: true,
  1.1366 +      contentType:  'application/x-www-form-urlencoded',
  1.1367 +      encoding:     'UTF-8',
  1.1368 +      parameters:   '',
  1.1369 +      evalJSON:     true,
  1.1370 +      evalJS:       true
  1.1371 +    };
  1.1372 +    Object.extend(this.options, options || { });
  1.1373 +
  1.1374 +    this.options.method = this.options.method.toLowerCase();
  1.1375 +
  1.1376 +    if (Object.isString(this.options.parameters))
  1.1377 +      this.options.parameters = this.options.parameters.toQueryParams();
  1.1378 +    else if (Object.isHash(this.options.parameters))
  1.1379 +      this.options.parameters = this.options.parameters.toObject();
  1.1380 +  }
  1.1381 +});
  1.1382 +Ajax.Request = Class.create(Ajax.Base, {
  1.1383 +  _complete: false,
  1.1384 +
  1.1385 +  initialize: function($super, url, options) {
  1.1386 +    $super(options);
  1.1387 +    this.transport = Ajax.getTransport();
  1.1388 +    this.request(url);
  1.1389 +  },
  1.1390 +
  1.1391 +  request: function(url) {
  1.1392 +    this.url = url;
  1.1393 +    this.method = this.options.method;
  1.1394 +    var params = Object.clone(this.options.parameters);
  1.1395 +
  1.1396 +    if (!['get', 'post'].include(this.method)) {
  1.1397 +      params['_method'] = this.method;
  1.1398 +      this.method = 'post';
  1.1399 +    }
  1.1400 +
  1.1401 +    this.parameters = params;
  1.1402 +
  1.1403 +    if (params = Object.toQueryString(params)) {
  1.1404 +      if (this.method == 'get')
  1.1405 +        this.url += (this.url.include('?') ? '&' : '?') + params;
  1.1406 +      else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
  1.1407 +        params += '&_=';
  1.1408 +    }
  1.1409 +
  1.1410 +    try {
  1.1411 +      var response = new Ajax.Response(this);
  1.1412 +      if (this.options.onCreate) this.options.onCreate(response);
  1.1413 +      Ajax.Responders.dispatch('onCreate', this, response);
  1.1414 +
  1.1415 +      this.transport.open(this.method.toUpperCase(), this.url,
  1.1416 +        this.options.asynchronous);
  1.1417 +
  1.1418 +      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
  1.1419 +
  1.1420 +      this.transport.onreadystatechange = this.onStateChange.bind(this);
  1.1421 +      this.setRequestHeaders();
  1.1422 +
  1.1423 +      this.body = this.method == 'post' ? (this.options.postBody || params) : null;
  1.1424 +      this.transport.send(this.body);
  1.1425 +
  1.1426 +      /* Force Firefox to handle ready state 4 for synchronous requests */
  1.1427 +      if (!this.options.asynchronous && this.transport.overrideMimeType)
  1.1428 +        this.onStateChange();
  1.1429 +
  1.1430 +    }
  1.1431 +    catch (e) {
  1.1432 +      this.dispatchException(e);
  1.1433 +    }
  1.1434 +  },
  1.1435 +
  1.1436 +  onStateChange: function() {
  1.1437 +    var readyState = this.transport.readyState;
  1.1438 +    if (readyState > 1 && !((readyState == 4) && this._complete))
  1.1439 +      this.respondToReadyState(this.transport.readyState);
  1.1440 +  },
  1.1441 +
  1.1442 +  setRequestHeaders: function() {
  1.1443 +    var headers = {
  1.1444 +      'X-Requested-With': 'XMLHttpRequest',
  1.1445 +      'X-Prototype-Version': Prototype.Version,
  1.1446 +      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
  1.1447 +    };
  1.1448 +
  1.1449 +    if (this.method == 'post') {
  1.1450 +      headers['Content-type'] = this.options.contentType +
  1.1451 +        (this.options.encoding ? '; charset=' + this.options.encoding : '');
  1.1452 +
  1.1453 +      /* Force "Connection: close" for older Mozilla browsers to work
  1.1454 +       * around a bug where XMLHttpRequest sends an incorrect
  1.1455 +       * Content-length header. See Mozilla Bugzilla #246651.
  1.1456 +       */
  1.1457 +      if (this.transport.overrideMimeType &&
  1.1458 +          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
  1.1459 +            headers['Connection'] = 'close';
  1.1460 +    }
  1.1461 +
  1.1462 +    if (typeof this.options.requestHeaders == 'object') {
  1.1463 +      var extras = this.options.requestHeaders;
  1.1464 +
  1.1465 +      if (Object.isFunction(extras.push))
  1.1466 +        for (var i = 0, length = extras.length; i < length; i += 2)
  1.1467 +          headers[extras[i]] = extras[i+1];
  1.1468 +      else
  1.1469 +        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
  1.1470 +    }
  1.1471 +
  1.1472 +    for (var name in headers)
  1.1473 +      this.transport.setRequestHeader(name, headers[name]);
  1.1474 +  },
  1.1475 +
  1.1476 +  success: function() {
  1.1477 +    var status = this.getStatus();
  1.1478 +    return !status || (status >= 200 && status < 300);
  1.1479 +  },
  1.1480 +
  1.1481 +  getStatus: function() {
  1.1482 +    try {
  1.1483 +      return this.transport.status || 0;
  1.1484 +    } catch (e) { return 0 }
  1.1485 +  },
  1.1486 +
  1.1487 +  respondToReadyState: function(readyState) {
  1.1488 +    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
  1.1489 +
  1.1490 +    if (state == 'Complete') {
  1.1491 +      try {
  1.1492 +        this._complete = true;
  1.1493 +        (this.options['on' + response.status]
  1.1494 +         || this.options['on' + (this.success() ? 'Success' : 'Failure')]
  1.1495 +         || Prototype.emptyFunction)(response, response.headerJSON);
  1.1496 +      } catch (e) {
  1.1497 +        this.dispatchException(e);
  1.1498 +      }
  1.1499 +
  1.1500 +      var contentType = response.getHeader('Content-type');
  1.1501 +      if (this.options.evalJS == 'force'
  1.1502 +          || (this.options.evalJS && this.isSameOrigin() && contentType
  1.1503 +          && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
  1.1504 +        this.evalResponse();
  1.1505 +    }
  1.1506 +
  1.1507 +    try {
  1.1508 +      (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
  1.1509 +      Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
  1.1510 +    } catch (e) {
  1.1511 +      this.dispatchException(e);
  1.1512 +    }
  1.1513 +
  1.1514 +    if (state == 'Complete') {
  1.1515 +      this.transport.onreadystatechange = Prototype.emptyFunction;
  1.1516 +    }
  1.1517 +  },
  1.1518 +
  1.1519 +  isSameOrigin: function() {
  1.1520 +    var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
  1.1521 +    return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
  1.1522 +      protocol: location.protocol,
  1.1523 +      domain: document.domain,
  1.1524 +      port: location.port ? ':' + location.port : ''
  1.1525 +    }));
  1.1526 +  },
  1.1527 +
  1.1528 +  getHeader: function(name) {
  1.1529 +    try {
  1.1530 +      return this.transport.getResponseHeader(name) || null;
  1.1531 +    } catch (e) { return null; }
  1.1532 +  },
  1.1533 +
  1.1534 +  evalResponse: function() {
  1.1535 +    try {
  1.1536 +      return eval((this.transport.responseText || '').unfilterJSON());
  1.1537 +    } catch (e) {
  1.1538 +      this.dispatchException(e);
  1.1539 +    }
  1.1540 +  },
  1.1541 +
  1.1542 +  dispatchException: function(exception) {
  1.1543 +    (this.options.onException || Prototype.emptyFunction)(this, exception);
  1.1544 +    Ajax.Responders.dispatch('onException', this, exception);
  1.1545 +  }
  1.1546 +});
  1.1547 +
  1.1548 +Ajax.Request.Events =
  1.1549 +  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
  1.1550 +
  1.1551 +
  1.1552 +
  1.1553 +
  1.1554 +
  1.1555 +
  1.1556 +
  1.1557 +
  1.1558 +Ajax.Response = Class.create({
  1.1559 +  initialize: function(request){
  1.1560 +    this.request = request;
  1.1561 +    var transport  = this.transport  = request.transport,
  1.1562 +        readyState = this.readyState = transport.readyState;
  1.1563 +
  1.1564 +    if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
  1.1565 +      this.status       = this.getStatus();
  1.1566 +      this.statusText   = this.getStatusText();
  1.1567 +      this.responseText = String.interpret(transport.responseText);
  1.1568 +      this.headerJSON   = this._getHeaderJSON();
  1.1569 +    }
  1.1570 +
  1.1571 +    if(readyState == 4) {
  1.1572 +      var xml = transport.responseXML;
  1.1573 +      this.responseXML  = Object.isUndefined(xml) ? null : xml;
  1.1574 +      this.responseJSON = this._getResponseJSON();
  1.1575 +    }
  1.1576 +  },
  1.1577 +
  1.1578 +  status:      0,
  1.1579 +
  1.1580 +  statusText: '',
  1.1581 +
  1.1582 +  getStatus: Ajax.Request.prototype.getStatus,
  1.1583 +
  1.1584 +  getStatusText: function() {
  1.1585 +    try {
  1.1586 +      return this.transport.statusText || '';
  1.1587 +    } catch (e) { return '' }
  1.1588 +  },
  1.1589 +
  1.1590 +  getHeader: Ajax.Request.prototype.getHeader,
  1.1591 +
  1.1592 +  getAllHeaders: function() {
  1.1593 +    try {
  1.1594 +      return this.getAllResponseHeaders();
  1.1595 +    } catch (e) { return null }
  1.1596 +  },
  1.1597 +
  1.1598 +  getResponseHeader: function(name) {
  1.1599 +    return this.transport.getResponseHeader(name);
  1.1600 +  },
  1.1601 +
  1.1602 +  getAllResponseHeaders: function() {
  1.1603 +    return this.transport.getAllResponseHeaders();
  1.1604 +  },
  1.1605 +
  1.1606 +  _getHeaderJSON: function() {
  1.1607 +    var json = this.getHeader('X-JSON');
  1.1608 +    if (!json) return null;
  1.1609 +    json = decodeURIComponent(escape(json));
  1.1610 +    try {
  1.1611 +      return json.evalJSON(this.request.options.sanitizeJSON ||
  1.1612 +        !this.request.isSameOrigin());
  1.1613 +    } catch (e) {
  1.1614 +      this.request.dispatchException(e);
  1.1615 +    }
  1.1616 +  },
  1.1617 +
  1.1618 +  _getResponseJSON: function() {
  1.1619 +    var options = this.request.options;
  1.1620 +    if (!options.evalJSON || (options.evalJSON != 'force' &&
  1.1621 +      !(this.getHeader('Content-type') || '').include('application/json')) ||
  1.1622 +        this.responseText.blank())
  1.1623 +          return null;
  1.1624 +    try {
  1.1625 +      return this.responseText.evalJSON(options.sanitizeJSON ||
  1.1626 +        !this.request.isSameOrigin());
  1.1627 +    } catch (e) {
  1.1628 +      this.request.dispatchException(e);
  1.1629 +    }
  1.1630 +  }
  1.1631 +});
  1.1632 +
  1.1633 +Ajax.Updater = Class.create(Ajax.Request, {
  1.1634 +  initialize: function($super, container, url, options) {
  1.1635 +    this.container = {
  1.1636 +      success: (container.success || container),
  1.1637 +      failure: (container.failure || (container.success ? null : container))
  1.1638 +    };
  1.1639 +
  1.1640 +    options = Object.clone(options);
  1.1641 +    var onComplete = options.onComplete;
  1.1642 +    options.onComplete = (function(response, json) {
  1.1643 +      this.updateContent(response.responseText);
  1.1644 +      if (Object.isFunction(onComplete)) onComplete(response, json);
  1.1645 +    }).bind(this);
  1.1646 +
  1.1647 +    $super(url, options);
  1.1648 +  },
  1.1649 +
  1.1650 +  updateContent: function(responseText) {
  1.1651 +    var receiver = this.container[this.success() ? 'success' : 'failure'],
  1.1652 +        options = this.options;
  1.1653 +
  1.1654 +    if (!options.evalScripts) responseText = responseText.stripScripts();
  1.1655 +
  1.1656 +    if (receiver = $(receiver)) {
  1.1657 +      if (options.insertion) {
  1.1658 +        if (Object.isString(options.insertion)) {
  1.1659 +          var insertion = { }; insertion[options.insertion] = responseText;
  1.1660 +          receiver.insert(insertion);
  1.1661 +        }
  1.1662 +        else options.insertion(receiver, responseText);
  1.1663 +      }
  1.1664 +      else receiver.update(responseText);
  1.1665 +    }
  1.1666 +  }
  1.1667 +});
  1.1668 +
  1.1669 +Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
  1.1670 +  initialize: function($super, container, url, options) {
  1.1671 +    $super(options);
  1.1672 +    this.onComplete = this.options.onComplete;
  1.1673 +
  1.1674 +    this.frequency = (this.options.frequency || 2);
  1.1675 +    this.decay = (this.options.decay || 1);
  1.1676 +
  1.1677 +    this.updater = { };
  1.1678 +    this.container = container;
  1.1679 +    this.url = url;
  1.1680 +
  1.1681 +    this.start();
  1.1682 +  },
  1.1683 +
  1.1684 +  start: function() {
  1.1685 +    this.options.onComplete = this.updateComplete.bind(this);
  1.1686 +    this.onTimerEvent();
  1.1687 +  },
  1.1688 +
  1.1689 +  stop: function() {
  1.1690 +    this.updater.options.onComplete = undefined;
  1.1691 +    clearTimeout(this.timer);
  1.1692 +    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  1.1693 +  },
  1.1694 +
  1.1695 +  updateComplete: function(response) {
  1.1696 +    if (this.options.decay) {
  1.1697 +      this.decay = (response.responseText == this.lastText ?
  1.1698 +        this.decay * this.options.decay : 1);
  1.1699 +
  1.1700 +      this.lastText = response.responseText;
  1.1701 +    }
  1.1702 +    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
  1.1703 +  },
  1.1704 +
  1.1705 +  onTimerEvent: function() {
  1.1706 +    this.updater = new Ajax.Updater(this.container, this.url, this.options);
  1.1707 +  }
  1.1708 +});
  1.1709 +
  1.1710 +
  1.1711 +
  1.1712 +function $(element) {
  1.1713 +  if (arguments.length > 1) {
  1.1714 +    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
  1.1715 +      elements.push($(arguments[i]));
  1.1716 +    return elements;
  1.1717 +  }
  1.1718 +  if (Object.isString(element))
  1.1719 +    element = document.getElementById(element);
  1.1720 +  return Element.extend(element);
  1.1721 +}
  1.1722 +
  1.1723 +if (Prototype.BrowserFeatures.XPath) {
  1.1724 +  document._getElementsByXPath = function(expression, parentElement) {
  1.1725 +    var results = [];
  1.1726 +    var query = document.evaluate(expression, $(parentElement) || document,
  1.1727 +      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1.1728 +    for (var i = 0, length = query.snapshotLength; i < length; i++)
  1.1729 +      results.push(Element.extend(query.snapshotItem(i)));
  1.1730 +    return results;
  1.1731 +  };
  1.1732 +}
  1.1733 +
  1.1734 +/*--------------------------------------------------------------------------*/
  1.1735 +
  1.1736 +if (!window.Node) var Node = { };
  1.1737 +
  1.1738 +if (!Node.ELEMENT_NODE) {
  1.1739 +  Object.extend(Node, {
  1.1740 +    ELEMENT_NODE: 1,
  1.1741 +    ATTRIBUTE_NODE: 2,
  1.1742 +    TEXT_NODE: 3,
  1.1743 +    CDATA_SECTION_NODE: 4,
  1.1744 +    ENTITY_REFERENCE_NODE: 5,
  1.1745 +    ENTITY_NODE: 6,
  1.1746 +    PROCESSING_INSTRUCTION_NODE: 7,
  1.1747 +    COMMENT_NODE: 8,
  1.1748 +    DOCUMENT_NODE: 9,
  1.1749 +    DOCUMENT_TYPE_NODE: 10,
  1.1750 +    DOCUMENT_FRAGMENT_NODE: 11,
  1.1751 +    NOTATION_NODE: 12
  1.1752 +  });
  1.1753 +}
  1.1754 +
  1.1755 +
  1.1756 +(function(global) {
  1.1757 +
  1.1758 +  var SETATTRIBUTE_IGNORES_NAME = (function(){
  1.1759 +    var elForm = document.createElement("form");
  1.1760 +    var elInput = document.createElement("input");
  1.1761 +    var root = document.documentElement;
  1.1762 +    elInput.setAttribute("name", "test");
  1.1763 +    elForm.appendChild(elInput);
  1.1764 +    root.appendChild(elForm);
  1.1765 +    var isBuggy = elForm.elements
  1.1766 +      ? (typeof elForm.elements.test == "undefined")
  1.1767 +      : null;
  1.1768 +    root.removeChild(elForm);
  1.1769 +    elForm = elInput = null;
  1.1770 +    return isBuggy;
  1.1771 +  })();
  1.1772 +
  1.1773 +  var element = global.Element;
  1.1774 +  global.Element = function(tagName, attributes) {
  1.1775 +    attributes = attributes || { };
  1.1776 +    tagName = tagName.toLowerCase();
  1.1777 +    var cache = Element.cache;
  1.1778 +    if (SETATTRIBUTE_IGNORES_NAME && attributes.name) {
  1.1779 +      tagName = '<' + tagName + ' name="' + attributes.name + '">';
  1.1780 +      delete attributes.name;
  1.1781 +      return Element.writeAttribute(document.createElement(tagName), attributes);
  1.1782 +    }
  1.1783 +    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
  1.1784 +    return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
  1.1785 +  };
  1.1786 +  Object.extend(global.Element, element || { });
  1.1787 +  if (element) global.Element.prototype = element.prototype;
  1.1788 +})(this);
  1.1789 +
  1.1790 +Element.cache = { };
  1.1791 +Element.idCounter = 1;
  1.1792 +
  1.1793 +Element.Methods = {
  1.1794 +  visible: function(element) {
  1.1795 +    return $(element).style.display != 'none';
  1.1796 +  },
  1.1797 +
  1.1798 +  toggle: function(element) {
  1.1799 +    element = $(element);
  1.1800 +    Element[Element.visible(element) ? 'hide' : 'show'](element);
  1.1801 +    return element;
  1.1802 +  },
  1.1803 +
  1.1804 +
  1.1805 +  hide: function(element) {
  1.1806 +    element = $(element);
  1.1807 +    element.style.display = 'none';
  1.1808 +    return element;
  1.1809 +  },
  1.1810 +
  1.1811 +  show: function(element) {
  1.1812 +    element = $(element);
  1.1813 +    element.style.display = '';
  1.1814 +    return element;
  1.1815 +  },
  1.1816 +
  1.1817 +  remove: function(element) {
  1.1818 +    element = $(element);
  1.1819 +    element.parentNode.removeChild(element);
  1.1820 +    return element;
  1.1821 +  },
  1.1822 +
  1.1823 +  update: (function(){
  1.1824 +
  1.1825 +    var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
  1.1826 +      var el = document.createElement("select"),
  1.1827 +          isBuggy = true;
  1.1828 +      el.innerHTML = "<option value=\"test\">test</option>";
  1.1829 +      if (el.options && el.options[0]) {
  1.1830 +        isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION";
  1.1831 +      }
  1.1832 +      el = null;
  1.1833 +      return isBuggy;
  1.1834 +    })();
  1.1835 +
  1.1836 +    var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){
  1.1837 +      try {
  1.1838 +        var el = document.createElement("table");
  1.1839 +        if (el && el.tBodies) {
  1.1840 +          el.innerHTML = "<tbody><tr><td>test</td></tr></tbody>";
  1.1841 +          var isBuggy = typeof el.tBodies[0] == "undefined";
  1.1842 +          el = null;
  1.1843 +          return isBuggy;
  1.1844 +        }
  1.1845 +      } catch (e) {
  1.1846 +        return true;
  1.1847 +      }
  1.1848 +    })();
  1.1849 +
  1.1850 +    var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () {
  1.1851 +      var s = document.createElement("script"),
  1.1852 +          isBuggy = false;
  1.1853 +      try {
  1.1854 +        s.appendChild(document.createTextNode(""));
  1.1855 +        isBuggy = !s.firstChild ||
  1.1856 +          s.firstChild && s.firstChild.nodeType !== 3;
  1.1857 +      } catch (e) {
  1.1858 +        isBuggy = true;
  1.1859 +      }
  1.1860 +      s = null;
  1.1861 +      return isBuggy;
  1.1862 +    })();
  1.1863 +
  1.1864 +    function update(element, content) {
  1.1865 +      element = $(element);
  1.1866 +
  1.1867 +      if (content && content.toElement)
  1.1868 +        content = content.toElement();
  1.1869 +
  1.1870 +      if (Object.isElement(content))
  1.1871 +        return element.update().insert(content);
  1.1872 +
  1.1873 +      content = Object.toHTML(content);
  1.1874 +
  1.1875 +      var tagName = element.tagName.toUpperCase();
  1.1876 +
  1.1877 +      if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) {
  1.1878 +        element.text = content;
  1.1879 +        return element;
  1.1880 +      }
  1.1881 +
  1.1882 +      if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) {
  1.1883 +        if (tagName in Element._insertionTranslations.tags) {
  1.1884 +          while (element.firstChild) {
  1.1885 +            element.removeChild(element.firstChild);
  1.1886 +          }
  1.1887 +          Element._getContentFromAnonymousElement(tagName, content.stripScripts())
  1.1888 +            .each(function(node) {
  1.1889 +              element.appendChild(node)
  1.1890 +            });
  1.1891 +        }
  1.1892 +        else {
  1.1893 +          element.innerHTML = content.stripScripts();
  1.1894 +        }
  1.1895 +      }
  1.1896 +      else {
  1.1897 +        element.innerHTML = content.stripScripts();
  1.1898 +      }
  1.1899 +
  1.1900 +      content.evalScripts.bind(content).defer();
  1.1901 +      return element;
  1.1902 +    }
  1.1903 +
  1.1904 +    return update;
  1.1905 +  })(),
  1.1906 +
  1.1907 +  replace: function(element, content) {
  1.1908 +    element = $(element);
  1.1909 +    if (content && content.toElement) content = content.toElement();
  1.1910 +    else if (!Object.isElement(content)) {
  1.1911 +      content = Object.toHTML(content);
  1.1912 +      var range = element.ownerDocument.createRange();
  1.1913 +      range.selectNode(element);
  1.1914 +      content.evalScripts.bind(content).defer();
  1.1915 +      content = range.createContextualFragment(content.stripScripts());
  1.1916 +    }
  1.1917 +    element.parentNode.replaceChild(content, element);
  1.1918 +    return element;
  1.1919 +  },
  1.1920 +
  1.1921 +  insert: function(element, insertions) {
  1.1922 +    element = $(element);
  1.1923 +
  1.1924 +    if (Object.isString(insertions) || Object.isNumber(insertions) ||
  1.1925 +        Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
  1.1926 +          insertions = {bottom:insertions};
  1.1927 +
  1.1928 +    var content, insert, tagName, childNodes;
  1.1929 +
  1.1930 +    for (var position in insertions) {
  1.1931 +      content  = insertions[position];
  1.1932 +      position = position.toLowerCase();
  1.1933 +      insert = Element._insertionTranslations[position];
  1.1934 +
  1.1935 +      if (content && content.toElement) content = content.toElement();
  1.1936 +      if (Object.isElement(content)) {
  1.1937 +        insert(element, content);
  1.1938 +        continue;
  1.1939 +      }
  1.1940 +
  1.1941 +      content = Object.toHTML(content);
  1.1942 +
  1.1943 +      tagName = ((position == 'before' || position == 'after')
  1.1944 +        ? element.parentNode : element).tagName.toUpperCase();
  1.1945 +
  1.1946 +      childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
  1.1947 +
  1.1948 +      if (position == 'top' || position == 'after') childNodes.reverse();
  1.1949 +      childNodes.each(insert.curry(element));
  1.1950 +
  1.1951 +      content.evalScripts.bind(content).defer();
  1.1952 +    }
  1.1953 +
  1.1954 +    return element;
  1.1955 +  },
  1.1956 +
  1.1957 +  wrap: function(element, wrapper, attributes) {
  1.1958 +    element = $(element);
  1.1959 +    if (Object.isElement(wrapper))
  1.1960 +      $(wrapper).writeAttribute(attributes || { });
  1.1961 +    else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
  1.1962 +    else wrapper = new Element('div', wrapper);
  1.1963 +    if (element.parentNode)
  1.1964 +      element.parentNode.replaceChild(wrapper, element);
  1.1965 +    wrapper.appendChild(element);
  1.1966 +    return wrapper;
  1.1967 +  },
  1.1968 +
  1.1969 +  inspect: function(element) {
  1.1970 +    element = $(element);
  1.1971 +    var result = '<' + element.tagName.toLowerCase();
  1.1972 +    $H({'id': 'id', 'className': 'class'}).each(function(pair) {
  1.1973 +      var property = pair.first(), attribute = pair.last();
  1.1974 +      var value = (element[property] || '').toString();
  1.1975 +      if (value) result += ' ' + attribute + '=' + value.inspect(true);
  1.1976 +    });
  1.1977 +    return result + '>';
  1.1978 +  },
  1.1979 +
  1.1980 +  recursivelyCollect: function(element, property) {
  1.1981 +    element = $(element);
  1.1982 +    var elements = [];
  1.1983 +    while (element = element[property])
  1.1984 +      if (element.nodeType == 1)
  1.1985 +        elements.push(Element.extend(element));
  1.1986 +    return elements;
  1.1987 +  },
  1.1988 +
  1.1989 +  ancestors: function(element) {
  1.1990 +    return Element.recursivelyCollect(element, 'parentNode');
  1.1991 +  },
  1.1992 +
  1.1993 +  descendants: function(element) {
  1.1994 +    return Element.select(element, "*");
  1.1995 +  },
  1.1996 +
  1.1997 +  firstDescendant: function(element) {
  1.1998 +    element = $(element).firstChild;
  1.1999 +    while (element && element.nodeType != 1) element = element.nextSibling;
  1.2000 +    return $(element);
  1.2001 +  },
  1.2002 +
  1.2003 +  immediateDescendants: function(element) {
  1.2004 +    if (!(element = $(element).firstChild)) return [];
  1.2005 +    while (element && element.nodeType != 1) element = element.nextSibling;
  1.2006 +    if (element) return [element].concat($(element).nextSiblings());
  1.2007 +    return [];
  1.2008 +  },
  1.2009 +
  1.2010 +  previousSiblings: function(element) {
  1.2011 +    return Element.recursivelyCollect(element, 'previousSibling');
  1.2012 +  },
  1.2013 +
  1.2014 +  nextSiblings: function(element) {
  1.2015 +    return Element.recursivelyCollect(element, 'nextSibling');
  1.2016 +  },
  1.2017 +
  1.2018 +  siblings: function(element) {
  1.2019 +    element = $(element);
  1.2020 +    return Element.previousSiblings(element).reverse()
  1.2021 +      .concat(Element.nextSiblings(element));
  1.2022 +  },
  1.2023 +
  1.2024 +  match: function(element, selector) {
  1.2025 +    if (Object.isString(selector))
  1.2026 +      selector = new Selector(selector);
  1.2027 +    return selector.match($(element));
  1.2028 +  },
  1.2029 +
  1.2030 +  up: function(element, expression, index) {
  1.2031 +    element = $(element);
  1.2032 +    if (arguments.length == 1) return $(element.parentNode);
  1.2033 +    var ancestors = Element.ancestors(element);
  1.2034 +    return Object.isNumber(expression) ? ancestors[expression] :
  1.2035 +      Selector.findElement(ancestors, expression, index);
  1.2036 +  },
  1.2037 +
  1.2038 +  down: function(element, expression, index) {
  1.2039 +    element = $(element);
  1.2040 +    if (arguments.length == 1) return Element.firstDescendant(element);
  1.2041 +    return Object.isNumber(expression) ? Element.descendants(element)[expression] :
  1.2042 +      Element.select(element, expression)[index || 0];
  1.2043 +  },
  1.2044 +
  1.2045 +  previous: function(element, expression, index) {
  1.2046 +    element = $(element);
  1.2047 +    if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
  1.2048 +    var previousSiblings = Element.previousSiblings(element);
  1.2049 +    return Object.isNumber(expression) ? previousSiblings[expression] :
  1.2050 +      Selector.findElement(previousSiblings, expression, index);
  1.2051 +  },
  1.2052 +
  1.2053 +  next: function(element, expression, index) {
  1.2054 +    element = $(element);
  1.2055 +    if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
  1.2056 +    var nextSiblings = Element.nextSiblings(element);
  1.2057 +    return Object.isNumber(expression) ? nextSiblings[expression] :
  1.2058 +      Selector.findElement(nextSiblings, expression, index);
  1.2059 +  },
  1.2060 +
  1.2061 +
  1.2062 +  select: function(element) {
  1.2063 +    var args = Array.prototype.slice.call(arguments, 1);
  1.2064 +    return Selector.findChildElements(element, args);
  1.2065 +  },
  1.2066 +
  1.2067 +  adjacent: function(element) {
  1.2068 +    var args = Array.prototype.slice.call(arguments, 1);
  1.2069 +    return Selector.findChildElements(element.parentNode, args).without(element);
  1.2070 +  },
  1.2071 +
  1.2072 +  identify: function(element) {
  1.2073 +    element = $(element);
  1.2074 +    var id = Element.readAttribute(element, 'id');
  1.2075 +    if (id) return id;
  1.2076 +    do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id));
  1.2077 +    Element.writeAttribute(element, 'id', id);
  1.2078 +    return id;
  1.2079 +  },
  1.2080 +
  1.2081 +  readAttribute: function(element, name) {
  1.2082 +    element = $(element);
  1.2083 +    if (Prototype.Browser.IE) {
  1.2084 +      var t = Element._attributeTranslations.read;
  1.2085 +      if (t.values[name]) return t.values[name](element, name);
  1.2086 +      if (t.names[name]) name = t.names[name];
  1.2087 +      if (name.include(':')) {
  1.2088 +        return (!element.attributes || !element.attributes[name]) ? null :
  1.2089 +         element.attributes[name].value;
  1.2090 +      }
  1.2091 +    }
  1.2092 +    return element.getAttribute(name);
  1.2093 +  },
  1.2094 +
  1.2095 +  writeAttribute: function(element, name, value) {
  1.2096 +    element = $(element);
  1.2097 +    var attributes = { }, t = Element._attributeTranslations.write;
  1.2098 +
  1.2099 +    if (typeof name == 'object') attributes = name;
  1.2100 +    else attributes[name] = Object.isUndefined(value) ? true : value;
  1.2101 +
  1.2102 +    for (var attr in attributes) {
  1.2103 +      name = t.names[attr] || attr;
  1.2104 +      value = attributes[attr];
  1.2105 +      if (t.values[attr]) name = t.values[attr](element, value);
  1.2106 +      if (value === false || value === null)
  1.2107 +        element.removeAttribute(name);
  1.2108 +      else if (value === true)
  1.2109 +        element.setAttribute(name, name);
  1.2110 +      else element.setAttribute(name, value);
  1.2111 +    }
  1.2112 +    return element;
  1.2113 +  },
  1.2114 +
  1.2115 +  getHeight: function(element) {
  1.2116 +    return Element.getDimensions(element).height;
  1.2117 +  },
  1.2118 +
  1.2119 +  getWidth: function(element) {
  1.2120 +    return Element.getDimensions(element).width;
  1.2121 +  },
  1.2122 +
  1.2123 +  classNames: function(element) {
  1.2124 +    return new Element.ClassNames(element);
  1.2125 +  },
  1.2126 +
  1.2127 +  hasClassName: function(element, className) {
  1.2128 +    if (!(element = $(element))) return;
  1.2129 +    var elementClassName = element.className;
  1.2130 +    return (elementClassName.length > 0 && (elementClassName == className ||
  1.2131 +      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
  1.2132 +  },
  1.2133 +
  1.2134 +  addClassName: function(element, className) {
  1.2135 +    if (!(element = $(element))) return;
  1.2136 +    if (!Element.hasClassName(element, className))
  1.2137 +      element.className += (element.className ? ' ' : '') + className;
  1.2138 +    return element;
  1.2139 +  },
  1.2140 +
  1.2141 +  removeClassName: function(element, className) {
  1.2142 +    if (!(element = $(element))) return;
  1.2143 +    element.className = element.className.replace(
  1.2144 +      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
  1.2145 +    return element;
  1.2146 +  },
  1.2147 +
  1.2148 +  toggleClassName: function(element, className) {
  1.2149 +    if (!(element = $(element))) return;
  1.2150 +    return Element[Element.hasClassName(element, className) ?
  1.2151 +      'removeClassName' : 'addClassName'](element, className);
  1.2152 +  },
  1.2153 +
  1.2154 +  cleanWhitespace: function(element) {
  1.2155 +    element = $(element);
  1.2156 +    var node = element.firstChild;
  1.2157 +    while (node) {
  1.2158 +      var nextNode = node.nextSibling;
  1.2159 +      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
  1.2160 +        element.removeChild(node);
  1.2161 +      node = nextNode;
  1.2162 +    }
  1.2163 +    return element;
  1.2164 +  },
  1.2165 +
  1.2166 +  empty: function(element) {
  1.2167 +    return $(element).innerHTML.blank();
  1.2168 +  },
  1.2169 +
  1.2170 +  descendantOf: function(element, ancestor) {
  1.2171 +    element = $(element), ancestor = $(ancestor);
  1.2172 +
  1.2173 +    if (element.compareDocumentPosition)
  1.2174 +      return (element.compareDocumentPosition(ancestor) & 8) === 8;
  1.2175 +
  1.2176 +    if (ancestor.contains)
  1.2177 +      return ancestor.contains(element) && ancestor !== element;
  1.2178 +
  1.2179 +    while (element = element.parentNode)
  1.2180 +      if (element == ancestor) return true;
  1.2181 +
  1.2182 +    return false;
  1.2183 +  },
  1.2184 +
  1.2185 +  scrollTo: function(element) {
  1.2186 +    element = $(element);
  1.2187 +    var pos = Element.cumulativeOffset(element);
  1.2188 +    window.scrollTo(pos[0], pos[1]);
  1.2189 +    return element;
  1.2190 +  },
  1.2191 +
  1.2192 +  getStyle: function(element, style) {
  1.2193 +    element = $(element);
  1.2194 +    style = style == 'float' ? 'cssFloat' : style.camelize();
  1.2195 +    var value = element.style[style];
  1.2196 +    if (!value || value == 'auto') {
  1.2197 +      var css = document.defaultView.getComputedStyle(element, null);
  1.2198 +      value = css ? css[style] : null;
  1.2199 +    }
  1.2200 +    if (style == 'opacity') return value ? parseFloat(value) : 1.0;
  1.2201 +    return value == 'auto' ? null : value;
  1.2202 +  },
  1.2203 +
  1.2204 +  getOpacity: function(element) {
  1.2205 +    return $(element).getStyle('opacity');
  1.2206 +  },
  1.2207 +
  1.2208 +  setStyle: function(element, styles) {
  1.2209 +    element = $(element);
  1.2210 +    var elementStyle = element.style, match;
  1.2211 +    if (Object.isString(styles)) {
  1.2212 +      element.style.cssText += ';' + styles;
  1.2213 +      return styles.include('opacity') ?
  1.2214 +        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
  1.2215 +    }
  1.2216 +    for (var property in styles)
  1.2217 +      if (property == 'opacity') element.setOpacity(styles[property]);
  1.2218 +      else
  1.2219 +        elementStyle[(property == 'float' || property == 'cssFloat') ?
  1.2220 +          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
  1.2221 +            property] = styles[property];
  1.2222 +
  1.2223 +    return element;
  1.2224 +  },
  1.2225 +
  1.2226 +  setOpacity: function(element, value) {
  1.2227 +    element = $(element);
  1.2228 +    element.style.opacity = (value == 1 || value === '') ? '' :
  1.2229 +      (value < 0.00001) ? 0 : value;
  1.2230 +    return element;
  1.2231 +  },
  1.2232 +
  1.2233 +  getDimensions: function(element) {
  1.2234 +    element = $(element);
  1.2235 +    var display = Element.getStyle(element, 'display');
  1.2236 +    if (display != 'none' && display != null) // Safari bug
  1.2237 +      return {width: element.offsetWidth, height: element.offsetHeight};
  1.2238 +
  1.2239 +    var els = element.style;
  1.2240 +    var originalVisibility = els.visibility;
  1.2241 +    var originalPosition = els.position;
  1.2242 +    var originalDisplay = els.display;
  1.2243 +    els.visibility = 'hidden';
  1.2244 +    if (originalPosition != 'fixed') // Switching fixed to absolute causes issues in Safari
  1.2245 +      els.position = 'absolute';
  1.2246 +    els.display = 'block';
  1.2247 +    var originalWidth = element.clientWidth;
  1.2248 +    var originalHeight = element.clientHeight;
  1.2249 +    els.display = originalDisplay;
  1.2250 +    els.position = originalPosition;
  1.2251 +    els.visibility = originalVisibility;
  1.2252 +    return {width: originalWidth, height: originalHeight};
  1.2253 +  },
  1.2254 +
  1.2255 +  makePositioned: function(element) {
  1.2256 +    element = $(element);
  1.2257 +    var pos = Element.getStyle(element, 'position');
  1.2258 +    if (pos == 'static' || !pos) {
  1.2259 +      element._madePositioned = true;
  1.2260 +      element.style.position = 'relative';
  1.2261 +      if (Prototype.Browser.Opera) {
  1.2262 +        element.style.top = 0;
  1.2263 +        element.style.left = 0;
  1.2264 +      }
  1.2265 +    }
  1.2266 +    return element;
  1.2267 +  },
  1.2268 +
  1.2269 +  undoPositioned: function(element) {
  1.2270 +    element = $(element);
  1.2271 +    if (element._madePositioned) {
  1.2272 +      element._madePositioned = undefined;
  1.2273 +      element.style.position =
  1.2274 +        element.style.top =
  1.2275 +        element.style.left =
  1.2276 +        element.style.bottom =
  1.2277 +        element.style.right = '';
  1.2278 +    }
  1.2279 +    return element;
  1.2280 +  },
  1.2281 +
  1.2282 +  makeClipping: function(element) {
  1.2283 +    element = $(element);
  1.2284 +    if (element._overflow) return element;
  1.2285 +    element._overflow = Element.getStyle(element, 'overflow') || 'auto';
  1.2286 +    if (element._overflow !== 'hidden')
  1.2287 +      element.style.overflow = 'hidden';
  1.2288 +    return element;
  1.2289 +  },
  1.2290 +
  1.2291 +  undoClipping: function(element) {
  1.2292 +    element = $(element);
  1.2293 +    if (!element._overflow) return element;
  1.2294 +    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
  1.2295 +    element._overflow = null;
  1.2296 +    return element;
  1.2297 +  },
  1.2298 +
  1.2299 +  cumulativeOffset: function(element) {
  1.2300 +    var valueT = 0, valueL = 0;
  1.2301 +    do {
  1.2302 +      valueT += element.offsetTop  || 0;
  1.2303 +      valueL += element.offsetLeft || 0;
  1.2304 +      element = element.offsetParent;
  1.2305 +    } while (element);
  1.2306 +    return Element._returnOffset(valueL, valueT);
  1.2307 +  },
  1.2308 +
  1.2309 +  positionedOffset: function(element) {
  1.2310 +    var valueT = 0, valueL = 0;
  1.2311 +    do {
  1.2312 +      valueT += element.offsetTop  || 0;
  1.2313 +      valueL += element.offsetLeft || 0;
  1.2314 +      element = element.offsetParent;
  1.2315 +      if (element) {
  1.2316 +        if (element.tagName.toUpperCase() == 'BODY') break;
  1.2317 +        var p = Element.getStyle(element, 'position');
  1.2318 +        if (p !== 'static') break;
  1.2319 +      }
  1.2320 +    } while (element);
  1.2321 +    return Element._returnOffset(valueL, valueT);
  1.2322 +  },
  1.2323 +
  1.2324 +  absolutize: function(element) {
  1.2325 +    element = $(element);
  1.2326 +    if (Element.getStyle(element, 'position') == 'absolute') return element;
  1.2327 +
  1.2328 +    var offsets = Element.positionedOffset(element);
  1.2329 +    var top     = offsets[1];
  1.2330 +    var left    = offsets[0];
  1.2331 +    var width   = element.clientWidth;
  1.2332 +    var height  = element.clientHeight;
  1.2333 +
  1.2334 +    element._originalLeft   = left - parseFloat(element.style.left  || 0);
  1.2335 +    element._originalTop    = top  - parseFloat(element.style.top || 0);
  1.2336 +    element._originalWidth  = element.style.width;
  1.2337 +    element._originalHeight = element.style.height;
  1.2338 +
  1.2339 +    element.style.position = 'absolute';
  1.2340 +    element.style.top    = top + 'px';
  1.2341 +    element.style.left   = left + 'px';
  1.2342 +    element.style.width  = width + 'px';
  1.2343 +    element.style.height = height + 'px';
  1.2344 +    return element;
  1.2345 +  },
  1.2346 +
  1.2347 +  relativize: function(element) {
  1.2348 +    element = $(element);
  1.2349 +    if (Element.getStyle(element, 'position') == 'relative') return element;
  1.2350 +
  1.2351 +    element.style.position = 'relative';
  1.2352 +    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
  1.2353 +    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
  1.2354 +
  1.2355 +    element.style.top    = top + 'px';
  1.2356 +    element.style.left   = left + 'px';
  1.2357 +    element.style.height = element._originalHeight;
  1.2358 +    element.style.width  = element._originalWidth;
  1.2359 +    return element;
  1.2360 +  },
  1.2361 +
  1.2362 +  cumulativeScrollOffset: function(element) {
  1.2363 +    var valueT = 0, valueL = 0;
  1.2364 +    do {
  1.2365 +      valueT += element.scrollTop  || 0;
  1.2366 +      valueL += element.scrollLeft || 0;
  1.2367 +      element = element.parentNode;
  1.2368 +    } while (element);
  1.2369 +    return Element._returnOffset(valueL, valueT);
  1.2370 +  },
  1.2371 +
  1.2372 +  getOffsetParent: function(element) {
  1.2373 +    if (element.offsetParent) return $(element.offsetParent);
  1.2374 +    if (element == document.body) return $(element);
  1.2375 +
  1.2376 +    while ((element = element.parentNode) && element != document.body)
  1.2377 +      if (Element.getStyle(element, 'position') != 'static')
  1.2378 +        return $(element);
  1.2379 +
  1.2380 +    return $(document.body);
  1.2381 +  },
  1.2382 +
  1.2383 +  viewportOffset: function(forElement) {
  1.2384 +    var valueT = 0, valueL = 0;
  1.2385 +
  1.2386 +    var element = forElement;
  1.2387 +    do {
  1.2388 +      valueT += element.offsetTop  || 0;
  1.2389 +      valueL += element.offsetLeft || 0;
  1.2390 +
  1.2391 +      if (element.offsetParent == document.body &&
  1.2392 +        Element.getStyle(element, 'position') == 'absolute') break;
  1.2393 +
  1.2394 +    } while (element = element.offsetParent);
  1.2395 +
  1.2396 +    element = forElement;
  1.2397 +    do {
  1.2398 +      if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
  1.2399 +        valueT -= element.scrollTop  || 0;
  1.2400 +        valueL -= element.scrollLeft || 0;
  1.2401 +      }
  1.2402 +    } while (element = element.parentNode);
  1.2403 +
  1.2404 +    return Element._returnOffset(valueL, valueT);
  1.2405 +  },
  1.2406 +
  1.2407 +  clonePosition: function(element, source) {
  1.2408 +    var options = Object.extend({
  1.2409 +      setLeft:    true,
  1.2410 +      setTop:     true,
  1.2411 +      setWidth:   true,
  1.2412 +      setHeight:  true,
  1.2413 +      offsetTop:  0,
  1.2414 +      offsetLeft: 0
  1.2415 +    }, arguments[2] || { });
  1.2416 +
  1.2417 +    source = $(source);
  1.2418 +    var p = Element.viewportOffset(source);
  1.2419 +
  1.2420 +    element = $(element);
  1.2421 +    var delta = [0, 0];
  1.2422 +    var parent = null;
  1.2423 +    if (Element.getStyle(element, 'position') == 'absolute') {
  1.2424 +      parent = Element.getOffsetParent(element);
  1.2425 +      delta = Element.viewportOffset(parent);
  1.2426 +    }
  1.2427 +
  1.2428 +    if (parent == document.body) {
  1.2429 +      delta[0] -= document.body.offsetLeft;
  1.2430 +      delta[1] -= document.body.offsetTop;
  1.2431 +    }
  1.2432 +
  1.2433 +    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
  1.2434 +    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
  1.2435 +    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';
  1.2436 +    if (options.setHeight) element.style.height = source.offsetHeight + 'px';
  1.2437 +    return element;
  1.2438 +  }
  1.2439 +};
  1.2440 +
  1.2441 +Object.extend(Element.Methods, {
  1.2442 +  getElementsBySelector: Element.Methods.select,
  1.2443 +
  1.2444 +  childElements: Element.Methods.immediateDescendants
  1.2445 +});
  1.2446 +
  1.2447 +Element._attributeTranslations = {
  1.2448 +  write: {
  1.2449 +    names: {
  1.2450 +      className: 'class',
  1.2451 +      htmlFor:   'for'
  1.2452 +    },
  1.2453 +    values: { }
  1.2454 +  }
  1.2455 +};
  1.2456 +
  1.2457 +if (Prototype.Browser.Opera) {
  1.2458 +  Element.Methods.getStyle = Element.Methods.getStyle.wrap(
  1.2459 +    function(proceed, element, style) {
  1.2460 +      switch (style) {
  1.2461 +        case 'left': case 'top': case 'right': case 'bottom':
  1.2462 +          if (proceed(element, 'position') === 'static') return null;
  1.2463 +        case 'height': case 'width':
  1.2464 +          if (!Element.visible(element)) return null;
  1.2465 +
  1.2466 +          var dim = parseInt(proceed(element, style), 10);
  1.2467 +
  1.2468 +          if (dim !== element['offset' + style.capitalize()])
  1.2469 +            return dim + 'px';
  1.2470 +
  1.2471 +          var properties;
  1.2472 +          if (style === 'height') {
  1.2473 +            properties = ['border-top-width', 'padding-top',
  1.2474 +             'padding-bottom', 'border-bottom-width'];
  1.2475 +          }
  1.2476 +          else {
  1.2477 +            properties = ['border-left-width', 'padding-left',
  1.2478 +             'padding-right', 'border-right-width'];
  1.2479 +          }
  1.2480 +          return properties.inject(dim, function(memo, property) {
  1.2481 +            var val = proceed(element, property);
  1.2482 +            return val === null ? memo : memo - parseInt(val, 10);
  1.2483 +          }) + 'px';
  1.2484 +        default: return proceed(element, style);
  1.2485 +      }
  1.2486 +    }
  1.2487 +  );
  1.2488 +
  1.2489 +  Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
  1.2490 +    function(proceed, element, attribute) {
  1.2491 +      if (attribute === 'title') return element.title;
  1.2492 +      return proceed(element, attribute);
  1.2493 +    }
  1.2494 +  );
  1.2495 +}
  1.2496 +
  1.2497 +else if (Prototype.Browser.IE) {
  1.2498 +  Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
  1.2499 +    function(proceed, element) {
  1.2500 +      element = $(element);
  1.2501 +      try { element.offsetParent }
  1.2502 +      catch(e) { return $(document.body) }
  1.2503 +      var position = element.getStyle('position');
  1.2504 +      if (position !== 'static') return proceed(element);
  1.2505 +      element.setStyle({ position: 'relative' });
  1.2506 +      var value = proceed(element);
  1.2507 +      element.setStyle({ position: position });
  1.2508 +      return value;
  1.2509 +    }
  1.2510 +  );
  1.2511 +
  1.2512 +  $w('positionedOffset viewportOffset').each(function(method) {
  1.2513 +    Element.Methods[method] = Element.Methods[method].wrap(
  1.2514 +      function(proceed, element) {
  1.2515 +        element = $(element);
  1.2516 +        try { element.offsetParent }
  1.2517 +        catch(e) { return Element._returnOffset(0,0) }
  1.2518 +        var position = element.getStyle('position');
  1.2519 +        if (position !== 'static') return proceed(element);
  1.2520 +        var offsetParent = element.getOffsetParent();
  1.2521 +        if (offsetParent && offsetParent.getStyle('position') === 'fixed')
  1.2522 +          offsetParent.setStyle({ zoom: 1 });
  1.2523 +        element.setStyle({ position: 'relative' });
  1.2524 +        var value = proceed(element);
  1.2525 +        element.setStyle({ position: position });
  1.2526 +        return value;
  1.2527 +      }
  1.2528 +    );
  1.2529 +  });
  1.2530 +
  1.2531 +  Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
  1.2532 +    function(proceed, element) {
  1.2533 +      try { element.offsetParent }
  1.2534 +      catch(e) { return Element._returnOffset(0,0) }
  1.2535 +      return proceed(element);
  1.2536 +    }
  1.2537 +  );
  1.2538 +
  1.2539 +  Element.Methods.getStyle = function(element, style) {
  1.2540 +    element = $(element);
  1.2541 +    style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
  1.2542 +    var value = element.style[style];
  1.2543 +    if (!value && element.currentStyle) value = element.currentStyle[style];
  1.2544 +
  1.2545 +    if (style == 'opacity') {
  1.2546 +      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
  1.2547 +        if (value[1]) return parseFloat(value[1]) / 100;
  1.2548 +      return 1.0;
  1.2549 +    }
  1.2550 +
  1.2551 +    if (value == 'auto') {
  1.2552 +      if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
  1.2553 +        return element['offset' + style.capitalize()] + 'px';
  1.2554 +      return null;
  1.2555 +    }
  1.2556 +    return value;
  1.2557 +  };
  1.2558 +
  1.2559 +  Element.Methods.setOpacity = function(element, value) {
  1.2560 +    function stripAlpha(filter){
  1.2561 +      return filter.replace(/alpha\([^\)]*\)/gi,'');
  1.2562 +    }
  1.2563 +    element = $(element);
  1.2564 +    var currentStyle = element.currentStyle;
  1.2565 +    if ((currentStyle && !currentStyle.hasLayout) ||
  1.2566 +      (!currentStyle && element.style.zoom == 'normal'))
  1.2567 +        element.style.zoom = 1;
  1.2568 +
  1.2569 +    var filter = element.getStyle('filter'), style = element.style;
  1.2570 +    if (value == 1 || value === '') {
  1.2571 +      (filter = stripAlpha(filter)) ?
  1.2572 +        style.filter = filter : style.removeAttribute('filter');
  1.2573 +      return element;
  1.2574 +    } else if (value < 0.00001) value = 0;
  1.2575 +    style.filter = stripAlpha(filter) +
  1.2576 +      'alpha(opacity=' + (value * 100) + ')';
  1.2577 +    return element;
  1.2578 +  };
  1.2579 +
  1.2580 +  Element._attributeTranslations = (function(){
  1.2581 +
  1.2582 +    var classProp = 'className';
  1.2583 +    var forProp = 'for';
  1.2584 +
  1.2585 +    var el = document.createElement('div');
  1.2586 +
  1.2587 +    el.setAttribute(classProp, 'x');
  1.2588 +
  1.2589 +    if (el.className !== 'x') {
  1.2590 +      el.setAttribute('class', 'x');
  1.2591 +      if (el.className === 'x') {
  1.2592 +        classProp = 'class';
  1.2593 +      }
  1.2594 +    }
  1.2595 +    el = null;
  1.2596 +
  1.2597 +    el = document.createElement('label');
  1.2598 +    el.setAttribute(forProp, 'x');
  1.2599 +    if (el.htmlFor !== 'x') {
  1.2600 +      el.setAttribute('htmlFor', 'x');
  1.2601 +      if (el.htmlFor === 'x') {
  1.2602 +        forProp = 'htmlFor';
  1.2603 +      }
  1.2604 +    }
  1.2605 +    el = null;
  1.2606 +
  1.2607 +    return {
  1.2608 +      read: {
  1.2609 +        names: {
  1.2610 +          'class':      classProp,
  1.2611 +          'className':  classProp,
  1.2612 +          'for':        forProp,
  1.2613 +          'htmlFor':    forProp
  1.2614 +        },
  1.2615 +        values: {
  1.2616 +          _getAttr: function(element, attribute) {
  1.2617 +            return element.getAttribute(attribute);
  1.2618 +          },
  1.2619 +          _getAttr2: function(element, attribute) {
  1.2620 +            return element.getAttribute(attribute, 2);
  1.2621 +          },
  1.2622 +          _getAttrNode: function(element, attribute) {
  1.2623 +            var node = element.getAttributeNode(attribute);
  1.2624 +            return node ? node.value : "";
  1.2625 +          },
  1.2626 +          _getEv: (function(){
  1.2627 +
  1.2628 +            var el = document.createElement('div');
  1.2629 +            el.onclick = Prototype.emptyFunction;
  1.2630 +            var value = el.getAttribute('onclick');
  1.2631 +            var f;
  1.2632 +
  1.2633 +            if (String(value).indexOf('{') > -1) {
  1.2634 +              f = function(element, attribute) {
  1.2635 +                attribute = element.getAttribute(attribute);
  1.2636 +                if (!attribute) return null;
  1.2637 +                attribute = attribute.toString();
  1.2638 +                attribute = attribute.split('{')[1];
  1.2639 +                attribute = attribute.split('}')[0];
  1.2640 +                return attribute.strip();
  1.2641 +              };
  1.2642 +            }
  1.2643 +            else if (value === '') {
  1.2644 +              f = function(element, attribute) {
  1.2645 +                attribute = element.getAttribute(attribute);
  1.2646 +                if (!attribute) return null;
  1.2647 +                return attribute.strip();
  1.2648 +              };
  1.2649 +            }
  1.2650 +            el = null;
  1.2651 +            return f;
  1.2652 +          })(),
  1.2653 +          _flag: function(element, attribute) {
  1.2654 +            return $(element).hasAttribute(attribute) ? attribute : null;
  1.2655 +          },
  1.2656 +          style: function(element) {
  1.2657 +            return element.style.cssText.toLowerCase();
  1.2658 +          },
  1.2659 +          title: function(element) {
  1.2660 +            return element.title;
  1.2661 +          }
  1.2662 +        }
  1.2663 +      }
  1.2664 +    }
  1.2665 +  })();
  1.2666 +
  1.2667 +  Element._attributeTranslations.write = {
  1.2668 +    names: Object.extend({
  1.2669 +      cellpadding: 'cellPadding',
  1.2670 +      cellspacing: 'cellSpacing'
  1.2671 +    }, Element._attributeTranslations.read.names),
  1.2672 +    values: {
  1.2673 +      checked: function(element, value) {
  1.2674 +        element.checked = !!value;
  1.2675 +      },
  1.2676 +
  1.2677 +      style: function(element, value) {
  1.2678 +        element.style.cssText = value ? value : '';
  1.2679 +      }
  1.2680 +    }
  1.2681 +  };
  1.2682 +
  1.2683 +  Element._attributeTranslations.has = {};
  1.2684 +
  1.2685 +  $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
  1.2686 +      'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
  1.2687 +    Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
  1.2688 +    Element._attributeTranslations.has[attr.toLowerCase()] = attr;
  1.2689 +  });
  1.2690 +
  1.2691 +  (function(v) {
  1.2692 +    Object.extend(v, {
  1.2693 +      href:        v._getAttr2,
  1.2694 +      src:         v._getAttr2,
  1.2695 +      type:        v._getAttr,
  1.2696 +      action:      v._getAttrNode,
  1.2697 +      disabled:    v._flag,
  1.2698 +      checked:     v._flag,
  1.2699 +      readonly:    v._flag,
  1.2700 +      multiple:    v._flag,
  1.2701 +      onload:      v._getEv,
  1.2702 +      onunload:    v._getEv,
  1.2703 +      onclick:     v._getEv,
  1.2704 +      ondblclick:  v._getEv,
  1.2705 +      onmousedown: v._getEv,
  1.2706 +      onmouseup:   v._getEv,
  1.2707 +      onmouseover: v._getEv,
  1.2708 +      onmousemove: v._getEv,
  1.2709 +      onmouseout:  v._getEv,
  1.2710 +      onfocus:     v._getEv,
  1.2711 +      onblur:      v._getEv,
  1.2712 +      onkeypress:  v._getEv,
  1.2713 +      onkeydown:   v._getEv,
  1.2714 +      onkeyup:     v._getEv,
  1.2715 +      onsubmit:    v._getEv,
  1.2716 +      onreset:     v._getEv,
  1.2717 +      onselect:    v._getEv,
  1.2718 +      onchange:    v._getEv
  1.2719 +    });
  1.2720 +  })(Element._attributeTranslations.read.values);
  1.2721 +
  1.2722 +  if (Prototype.BrowserFeatures.ElementExtensions) {
  1.2723 +    (function() {
  1.2724 +      function _descendants(element) {
  1.2725 +        var nodes = element.getElementsByTagName('*'), results = [];
  1.2726 +        for (var i = 0, node; node = nodes[i]; i++)
  1.2727 +          if (node.tagName !== "!") // Filter out comment nodes.
  1.2728 +            results.push(node);
  1.2729 +        return results;
  1.2730 +      }
  1.2731 +
  1.2732 +      Element.Methods.down = function(element, expression, index) {
  1.2733 +        element = $(element);
  1.2734 +        if (arguments.length == 1) return element.firstDescendant();
  1.2735 +        return Object.isNumber(expression) ? _descendants(element)[expression] :
  1.2736 +          Element.select(element, expression)[index || 0];
  1.2737 +      }
  1.2738 +    })();
  1.2739 +  }
  1.2740 +
  1.2741 +}
  1.2742 +
  1.2743 +else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
  1.2744 +  Element.Methods.setOpacity = function(element, value) {
  1.2745 +    element = $(element);
  1.2746 +    element.style.opacity = (value == 1) ? 0.999999 :
  1.2747 +      (value === '') ? '' : (value < 0.00001) ? 0 : value;
  1.2748 +    return element;
  1.2749 +  };
  1.2750 +}
  1.2751 +
  1.2752 +else if (Prototype.Browser.WebKit) {
  1.2753 +  Element.Methods.setOpacity = function(element, value) {
  1.2754 +    element = $(element);
  1.2755 +    element.style.opacity = (value == 1 || value === '') ? '' :
  1.2756 +      (value < 0.00001) ? 0 : value;
  1.2757 +
  1.2758 +    if (value == 1)
  1.2759 +      if(element.tagName.toUpperCase() == 'IMG' && element.width) {
  1.2760 +        element.width++; element.width--;
  1.2761 +      } else try {
  1.2762 +        var n = document.createTextNode(' ');
  1.2763 +        element.appendChild(n);
  1.2764 +        element.removeChild(n);
  1.2765 +      } catch (e) { }
  1.2766 +
  1.2767 +    return element;
  1.2768 +  };
  1.2769 +
  1.2770 +  Element.Methods.cumulativeOffset = function(element) {
  1.2771 +    var valueT = 0, valueL = 0;
  1.2772 +    do {
  1.2773 +      valueT += element.offsetTop  || 0;
  1.2774 +      valueL += element.offsetLeft || 0;
  1.2775 +      if (element.offsetParent == document.body)
  1.2776 +        if (Element.getStyle(element, 'position') == 'absolute') break;
  1.2777 +
  1.2778 +      element = element.offsetParent;
  1.2779 +    } while (element);
  1.2780 +
  1.2781 +    return Element._returnOffset(valueL, valueT);
  1.2782 +  };
  1.2783 +}
  1.2784 +
  1.2785 +if ('outerHTML' in document.documentElement) {
  1.2786 +  Element.Methods.replace = function(element, content) {
  1.2787 +    element = $(element);
  1.2788 +
  1.2789 +    if (content && content.toElement) content = content.toElement();
  1.2790 +    if (Object.isElement(content)) {
  1.2791 +      element.parentNode.replaceChild(content, element);
  1.2792 +      return element;
  1.2793 +    }
  1.2794 +
  1.2795 +    content = Object.toHTML(content);
  1.2796 +    var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
  1.2797 +
  1.2798 +    if (Element._insertionTranslations.tags[tagName]) {
  1.2799 +      var nextSibling = element.next();
  1.2800 +      var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
  1.2801 +      parent.removeChild(element);
  1.2802 +      if (nextSibling)
  1.2803 +        fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
  1.2804 +      else
  1.2805 +        fragments.each(function(node) { parent.appendChild(node) });
  1.2806 +    }
  1.2807 +    else element.outerHTML = content.stripScripts();
  1.2808 +
  1.2809 +    content.evalScripts.bind(content).defer();
  1.2810 +    return element;
  1.2811 +  };
  1.2812 +}
  1.2813 +
  1.2814 +Element._returnOffset = function(l, t) {
  1.2815 +  var result = [l, t];
  1.2816 +  result.left = l;
  1.2817 +  result.top = t;
  1.2818 +  return result;
  1.2819 +};
  1.2820 +
  1.2821 +Element._getContentFromAnonymousElement = function(tagName, html) {
  1.2822 +  var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
  1.2823 +  if (t) {
  1.2824 +    div.innerHTML = t[0] + html + t[1];
  1.2825 +    t[2].times(function() { div = div.firstChild });
  1.2826 +  } else div.innerHTML = html;
  1.2827 +  return $A(div.childNodes);
  1.2828 +};
  1.2829 +
  1.2830 +Element._insertionTranslations = {
  1.2831 +  before: function(element, node) {
  1.2832 +    element.parentNode.insertBefore(node, element);
  1.2833 +  },
  1.2834 +  top: function(element, node) {
  1.2835 +    element.insertBefore(node, element.firstChild);
  1.2836 +  },
  1.2837 +  bottom: function(element, node) {
  1.2838 +    element.appendChild(node);
  1.2839 +  },
  1.2840 +  after: function(element, node) {
  1.2841 +    element.parentNode.insertBefore(node, element.nextSibling);
  1.2842 +  },
  1.2843 +  tags: {
  1.2844 +    TABLE:  ['<table>',                '</table>',                   1],
  1.2845 +    TBODY:  ['<table><tbody>',         '</tbody></table>',           2],
  1.2846 +    TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],
  1.2847 +    TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
  1.2848 +    SELECT: ['<select>',               '</select>',                  1]
  1.2849 +  }
  1.2850 +};
  1.2851 +
  1.2852 +(function() {
  1.2853 +  var tags = Element._insertionTranslations.tags;
  1.2854 +  Object.extend(tags, {
  1.2855 +    THEAD: tags.TBODY,
  1.2856 +    TFOOT: tags.TBODY,
  1.2857 +    TH:    tags.TD
  1.2858 +  });
  1.2859 +})();
  1.2860 +
  1.2861 +Element.Methods.Simulated = {
  1.2862 +  hasAttribute: function(element, attribute) {
  1.2863 +    attribute = Element._attributeTranslations.has[attribute] || attribute;
  1.2864 +    var node = $(element).getAttributeNode(attribute);
  1.2865 +    return !!(node && node.specified);
  1.2866 +  }
  1.2867 +};
  1.2868 +
  1.2869 +Element.Methods.ByTag = { };
  1.2870 +
  1.2871 +Object.extend(Element, Element.Methods);
  1.2872 +
  1.2873 +(function(div) {
  1.2874 +
  1.2875 +  if (!Prototype.BrowserFeatures.ElementExtensions && div['__proto__']) {
  1.2876 +    window.HTMLElement = { };
  1.2877 +    window.HTMLElement.prototype = div['__proto__'];
  1.2878 +    Prototype.BrowserFeatures.ElementExtensions = true;
  1.2879 +  }
  1.2880 +
  1.2881 +  div = null;
  1.2882 +
  1.2883 +})(document.createElement('div'))
  1.2884 +
  1.2885 +Element.extend = (function() {
  1.2886 +
  1.2887 +  function checkDeficiency(tagName) {
  1.2888 +    if (typeof window.Element != 'undefined') {
  1.2889 +      var proto = window.Element.prototype;
  1.2890 +      if (proto) {
  1.2891 +        var id = '_' + (Math.random()+'').slice(2);
  1.2892 +        var el = document.createElement(tagName);
  1.2893 +        proto[id] = 'x';
  1.2894 +        var isBuggy = (el[id] !== 'x');
  1.2895 +        delete proto[id];
  1.2896 +        el = null;
  1.2897 +        return isBuggy;
  1.2898 +      }
  1.2899 +    }
  1.2900 +    return false;
  1.2901 +  }
  1.2902 +
  1.2903 +  function extendElementWith(element, methods) {
  1.2904 +    for (var property in methods) {
  1.2905 +      var value = methods[property];
  1.2906 +      if (Object.isFunction(value) && !(property in element))
  1.2907 +        element[property] = value.methodize();
  1.2908 +    }
  1.2909 +  }
  1.2910 +
  1.2911 +  var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency('object');
  1.2912 +
  1.2913 +  if (Prototype.BrowserFeatures.SpecificElementExtensions) {
  1.2914 +    if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) {
  1.2915 +      return function(element) {
  1.2916 +        if (element && typeof element._extendedByPrototype == 'undefined') {
  1.2917 +          var t = element.tagName;
  1.2918 +          if (t && (/^(?:object|applet|embed)$/i.test(t))) {
  1.2919 +            extendElementWith(element, Element.Methods);
  1.2920 +            extendElementWith(element, Element.Methods.Simulated);
  1.2921 +            extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
  1.2922 +          }
  1.2923 +        }
  1.2924 +        return element;
  1.2925 +      }
  1.2926 +    }
  1.2927 +    return Prototype.K;
  1.2928 +  }
  1.2929 +
  1.2930 +  var Methods = { }, ByTag = Element.Methods.ByTag;
  1.2931 +
  1.2932 +  var extend = Object.extend(function(element) {
  1.2933 +    if (!element || typeof element._extendedByPrototype != 'undefined' ||
  1.2934 +        element.nodeType != 1 || element == window) return element;
  1.2935 +
  1.2936 +    var methods = Object.clone(Methods),
  1.2937 +        tagName = element.tagName.toUpperCase();
  1.2938 +
  1.2939 +    if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
  1.2940 +
  1.2941 +    extendElementWith(element, methods);
  1.2942 +
  1.2943 +    element._extendedByPrototype = Prototype.emptyFunction;
  1.2944 +    return element;
  1.2945 +
  1.2946 +  }, {
  1.2947 +    refresh: function() {
  1.2948 +      if (!Prototype.BrowserFeatures.ElementExtensions) {
  1.2949 +        Object.extend(Methods, Element.Methods);
  1.2950 +        Object.extend(Methods, Element.Methods.Simulated);
  1.2951 +      }
  1.2952 +    }
  1.2953 +  });
  1.2954 +
  1.2955 +  extend.refresh();
  1.2956 +  return extend;
  1.2957 +})();
  1.2958 +
  1.2959 +Element.hasAttribute = function(element, attribute) {
  1.2960 +  if (element.hasAttribute) return element.hasAttribute(attribute);
  1.2961 +  return Element.Methods.Simulated.hasAttribute(element, attribute);
  1.2962 +};
  1.2963 +
  1.2964 +Element.addMethods = function(methods) {
  1.2965 +  var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
  1.2966 +
  1.2967 +  if (!methods) {
  1.2968 +    Object.extend(Form, Form.Methods);
  1.2969 +    Object.extend(Form.Element, Form.Element.Methods);
  1.2970 +    Object.extend(Element.Methods.ByTag, {
  1.2971 +      "FORM":     Object.clone(Form.Methods),
  1.2972 +      "INPUT":    Object.clone(Form.Element.Methods),
  1.2973 +      "SELECT":   Object.clone(Form.Element.Methods),
  1.2974 +      "TEXTAREA": Object.clone(Form.Element.Methods)
  1.2975 +    });
  1.2976 +  }
  1.2977 +
  1.2978 +  if (arguments.length == 2) {
  1.2979 +    var tagName = methods;
  1.2980 +    methods = arguments[1];
  1.2981 +  }
  1.2982 +
  1.2983 +  if (!tagName) Object.extend(Element.Methods, methods || { });
  1.2984 +  else {
  1.2985 +    if (Object.isArray(tagName)) tagName.each(extend);
  1.2986 +    else extend(tagName);
  1.2987 +  }
  1.2988 +
  1.2989 +  function extend(tagName) {
  1.2990 +    tagName = tagName.toUpperCase();
  1.2991 +    if (!Element.Methods.ByTag[tagName])
  1.2992 +      Element.Methods.ByTag[tagName] = { };
  1.2993 +    Object.extend(Element.Methods.ByTag[tagName], methods);
  1.2994 +  }
  1.2995 +
  1.2996 +  function copy(methods, destination, onlyIfAbsent) {
  1.2997 +    onlyIfAbsent = onlyIfAbsent || false;
  1.2998 +    for (var property in methods) {
  1.2999 +      var value = methods[property];
  1.3000 +      if (!Object.isFunction(value)) continue;
  1.3001 +      if (!onlyIfAbsent || !(property in destination))
  1.3002 +        destination[property] = value.methodize();
  1.3003 +    }
  1.3004 +  }
  1.3005 +
  1.3006 +  function findDOMClass(tagName) {
  1.3007 +    var klass;
  1.3008 +    var trans = {
  1.3009 +      "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
  1.3010 +      "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
  1.3011 +      "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
  1.3012 +      "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
  1.3013 +      "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
  1.3014 +      "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
  1.3015 +      "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
  1.3016 +      "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
  1.3017 +      "FrameSet", "IFRAME": "IFrame"
  1.3018 +    };
  1.3019 +    if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
  1.3020 +    if (window[klass]) return window[klass];
  1.3021 +    klass = 'HTML' + tagName + 'Element';
  1.3022 +    if (window[klass]) return window[klass];
  1.3023 +    klass = 'HTML' + tagName.capitalize() + 'Element';
  1.3024 +    if (window[klass]) return window[klass];
  1.3025 +
  1.3026 +    var element = document.createElement(tagName);
  1.3027 +    var proto = element['__proto__'] || element.constructor.prototype;
  1.3028 +    element = null;
  1.3029 +    return proto;
  1.3030 +  }
  1.3031 +
  1.3032 +  var elementPrototype = window.HTMLElement ? HTMLElement.prototype :
  1.3033 +   Element.prototype;
  1.3034 +
  1.3035 +  if (F.ElementExtensions) {
  1.3036 +    copy(Element.Methods, elementPrototype);
  1.3037 +    copy(Element.Methods.Simulated, elementPrototype, true);
  1.3038 +  }
  1.3039 +
  1.3040 +  if (F.SpecificElementExtensions) {
  1.3041 +    for (var tag in Element.Methods.ByTag) {
  1.3042 +      var klass = findDOMClass(tag);
  1.3043 +      if (Object.isUndefined(klass)) continue;
  1.3044 +      copy(T[tag], klass.prototype);
  1.3045 +    }
  1.3046 +  }
  1.3047 +
  1.3048 +  Object.extend(Element, Element.Methods);
  1.3049 +  delete Element.ByTag;
  1.3050 +
  1.3051 +  if (Element.extend.refresh) Element.extend.refresh();
  1.3052 +  Element.cache = { };
  1.3053 +};
  1.3054 +
  1.3055 +
  1.3056 +document.viewport = {
  1.3057 +
  1.3058 +  getDimensions: function() {
  1.3059 +    return { width: this.getWidth(), height: this.getHeight() };
  1.3060 +  },
  1.3061 +
  1.3062 +  getScrollOffsets: function() {
  1.3063 +    return Element._returnOffset(
  1.3064 +      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
  1.3065 +      window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop);
  1.3066 +  }
  1.3067 +};
  1.3068 +
  1.3069 +(function(viewport) {
  1.3070 +  var B = Prototype.Browser, doc = document, element, property = {};
  1.3071 +
  1.3072 +  function getRootElement() {
  1.3073 +    if (B.WebKit && !doc.evaluate)
  1.3074 +      return document;
  1.3075 +
  1.3076 +    if (B.Opera && window.parseFloat(window.opera.version()) < 9.5)
  1.3077 +      return document.body;
  1.3078 +
  1.3079 +    return document.documentElement;
  1.3080 +  }
  1.3081 +
  1.3082 +  function define(D) {
  1.3083 +    if (!element) element = getRootElement();
  1.3084 +
  1.3085 +    property[D] = 'client' + D;
  1.3086 +
  1.3087 +    viewport['get' + D] = function() { return element[property[D]] };
  1.3088 +    return viewport['get' + D]();
  1.3089 +  }
  1.3090 +
  1.3091 +  viewport.getWidth  = define.curry('Width');
  1.3092 +
  1.3093 +  viewport.getHeight = define.curry('Height');
  1.3094 +})(document.viewport);
  1.3095 +
  1.3096 +
  1.3097 +Element.Storage = {
  1.3098 +  UID: 1
  1.3099 +};
  1.3100 +
  1.3101 +Element.addMethods({
  1.3102 +  getStorage: function(element) {
  1.3103 +    if (!(element = $(element))) return;
  1.3104 +
  1.3105 +    var uid;
  1.3106 +    if (element === window) {
  1.3107 +      uid = 0;
  1.3108 +    } else {
  1.3109 +      if (typeof element._prototypeUID === "undefined")
  1.3110 +        element._prototypeUID = [Element.Storage.UID++];
  1.3111 +      uid = element._prototypeUID[0];
  1.3112 +    }
  1.3113 +
  1.3114 +    if (!Element.Storage[uid])
  1.3115 +      Element.Storage[uid] = $H();
  1.3116 +
  1.3117 +    return Element.Storage[uid];
  1.3118 +  },
  1.3119 +
  1.3120 +  store: function(element, key, value) {
  1.3121 +    if (!(element = $(element))) return;
  1.3122 +
  1.3123 +    if (arguments.length === 2) {
  1.3124 +      Element.getStorage(element).update(key);
  1.3125 +    } else {
  1.3126 +      Element.getStorage(element).set(key, value);
  1.3127 +    }
  1.3128 +
  1.3129 +    return element;
  1.3130 +  },
  1.3131 +
  1.3132 +  retrieve: function(element, key, defaultValue) {
  1.3133 +    if (!(element = $(element))) return;
  1.3134 +    var hash = Element.getStorage(element), value = hash.get(key);
  1.3135 +
  1.3136 +    if (Object.isUndefined(value)) {
  1.3137 +      hash.set(key, defaultValue);
  1.3138 +      value = defaultValue;
  1.3139 +    }
  1.3140 +
  1.3141 +    return value;
  1.3142 +  },
  1.3143 +
  1.3144 +  clone: function(element, deep) {
  1.3145 +    if (!(element = $(element))) return;
  1.3146 +    var clone = element.cloneNode(deep);
  1.3147 +    clone._prototypeUID = void 0;
  1.3148 +    if (deep) {
  1.3149 +      var descendants = Element.select(clone, '*'),
  1.3150 +          i = descendants.length;
  1.3151 +      while (i--) {
  1.3152 +        descendants[i]._prototypeUID = void 0;
  1.3153 +      }
  1.3154 +    }
  1.3155 +    return Element.extend(clone);
  1.3156 +  }
  1.3157 +});
  1.3158 +/* Portions of the Selector class are derived from Jack Slocum's DomQuery,
  1.3159 + * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
  1.3160 + * license.  Please see http://www.yui-ext.com/ for more information. */
  1.3161 +
  1.3162 +var Selector = Class.create({
  1.3163 +  initialize: function(expression) {
  1.3164 +    this.expression = expression.strip();
  1.3165 +
  1.3166 +    if (this.shouldUseSelectorsAPI()) {
  1.3167 +      this.mode = 'selectorsAPI';
  1.3168 +    } else if (this.shouldUseXPath()) {
  1.3169 +      this.mode = 'xpath';
  1.3170 +      this.compileXPathMatcher();
  1.3171 +    } else {
  1.3172 +      this.mode = "normal";
  1.3173 +      this.compileMatcher();
  1.3174 +    }
  1.3175 +
  1.3176 +  },
  1.3177 +
  1.3178 +  shouldUseXPath: (function() {
  1.3179 +
  1.3180 +    var IS_DESCENDANT_SELECTOR_BUGGY = (function(){
  1.3181 +      var isBuggy = false;
  1.3182 +      if (document.evaluate && window.XPathResult) {
  1.3183 +        var el = document.createElement('div');
  1.3184 +        el.innerHTML = '<ul><li></li></ul><div><ul><li></li></ul></div>';
  1.3185 +
  1.3186 +        var xpath = ".//*[local-name()='ul' or local-name()='UL']" +
  1.3187 +          "//*[local-name()='li' or local-name()='LI']";
  1.3188 +
  1.3189 +        var result = document.evaluate(xpath, el, null,
  1.3190 +          XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  1.3191 +
  1.3192 +        isBuggy = (result.snapshotLength !== 2);
  1.3193 +        el = null;
  1.3194 +      }
  1.3195 +      return isBuggy;
  1.3196 +    })();
  1.3197 +
  1.3198 +    return function() {
  1.3199 +      if (!Prototype.BrowserFeatures.XPath) return false;
  1.3200 +
  1.3201 +      var e = this.expression;
  1.3202 +
  1.3203 +      if (Prototype.Browser.WebKit &&
  1.3204 +       (e.include("-of-type") || e.include(":empty")))
  1.3205 +        return false;
  1.3206 +
  1.3207 +      if ((/(\[[\w-]*?:|:checked)/).test(e))
  1.3208 +        return false;
  1.3209 +
  1.3210 +      if (IS_DESCENDANT_SELECTOR_BUGGY) return false;
  1.3211 +
  1.3212 +      return true;
  1.3213 +    }
  1.3214 +
  1.3215 +  })(),
  1.3216 +
  1.3217 +  shouldUseSelectorsAPI: function() {
  1.3218 +    if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
  1.3219 +
  1.3220 +    if (Selector.CASE_INSENSITIVE_CLASS_NAMES) return false;
  1.3221 +
  1.3222 +    if (!Selector._div) Selector._div = new Element('div');
  1.3223 +
  1.3224 +    try {
  1.3225 +      Selector._div.querySelector(this.expression);
  1.3226 +    } catch(e) {
  1.3227 +      return false;
  1.3228 +    }
  1.3229 +
  1.3230 +    return true;
  1.3231 +  },
  1.3232 +
  1.3233 +  compileMatcher: function() {
  1.3234 +    var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
  1.3235 +        c = Selector.criteria, le, p, m, len = ps.length, name;
  1.3236 +
  1.3237 +    if (Selector._cache[e]) {
  1.3238 +      this.matcher = Selector._cache[e];
  1.3239 +      return;
  1.3240 +    }
  1.3241 +
  1.3242 +    this.matcher = ["this.matcher = function(root) {",
  1.3243 +                    "var r = root, h = Selector.handlers, c = false, n;"];
  1.3244 +
  1.3245 +    while (e && le != e && (/\S/).test(e)) {
  1.3246 +      le = e;
  1.3247 +      for (var i = 0; i<len; i++) {
  1.3248 +        p = ps[i].re;
  1.3249 +        name = ps[i].name;
  1.3250 +        if (m = e.match(p)) {
  1.3251 +          this.matcher.push(Object.isFunction(c[name]) ? c[name](m) :
  1.3252 +            new Template(c[name]).evaluate(m));
  1.3253 +          e = e.replace(m[0], '');
  1.3254 +          break;
  1.3255 +        }
  1.3256 +      }
  1.3257 +    }
  1.3258 +
  1.3259 +    this.matcher.push("return h.unique(n);\n}");
  1.3260 +    eval(this.matcher.join('\n'));
  1.3261 +    Selector._cache[this.expression] = this.matcher;
  1.3262 +  },
  1.3263 +
  1.3264 +  compileXPathMatcher: function() {
  1.3265 +    var e = this.expression, ps = Selector.patterns,
  1.3266 +        x = Selector.xpath, le, m, len = ps.length, name;
  1.3267 +
  1.3268 +    if (Selector._cache[e]) {
  1.3269 +      this.xpath = Selector._cache[e]; return;
  1.3270 +    }
  1.3271 +
  1.3272 +    this.matcher = ['.//*'];
  1.3273 +    while (e && le != e && (/\S/).test(e)) {
  1.3274 +      le = e;
  1.3275 +      for (var i = 0; i<len; i++) {
  1.3276 +        name = ps[i].name;
  1.3277 +        if (m = e.match(ps[i].re)) {
  1.3278 +          this.matcher.push(Object.isFunction(x[name]) ? x[name](m) :
  1.3279 +            new Template(x[name]).evaluate(m));
  1.3280 +          e = e.replace(m[0], '');
  1.3281 +          break;
  1.3282 +        }
  1.3283 +      }
  1.3284 +    }
  1.3285 +
  1.3286 +    this.xpath = this.matcher.join('');
  1.3287 +    Selector._cache[this.expression] = this.xpath;
  1.3288 +  },
  1.3289 +
  1.3290 +  findElements: function(root) {
  1.3291 +    root = root || document;
  1.3292 +    var e = this.expression, results;
  1.3293 +
  1.3294 +    switch (this.mode) {
  1.3295 +      case 'selectorsAPI':
  1.3296 +        if (root !== document) {
  1.3297 +          var oldId = root.id, id = $(root).identify();
  1.3298 +          id = id.replace(/([\.:])/g, "\\$1");
  1.3299 +          e = "#" + id + " " + e;
  1.3300 +        }
  1.3301 +
  1.3302 +        results = $A(root.querySelectorAll(e)).map(Element.extend);
  1.3303 +        root.id = oldId;
  1.3304 +
  1.3305 +        return results;
  1.3306 +      case 'xpath':
  1.3307 +        return document._getElementsByXPath(this.xpath, root);
  1.3308 +      default:
  1.3309 +       return this.matcher(root);
  1.3310 +    }
  1.3311 +  },
  1.3312 +
  1.3313 +  match: function(element) {
  1.3314 +    this.tokens = [];
  1.3315 +
  1.3316 +    var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
  1.3317 +    var le, p, m, len = ps.length, name;
  1.3318 +
  1.3319 +    while (e && le !== e && (/\S/).test(e)) {
  1.3320 +      le = e;
  1.3321 +      for (var i = 0; i<len; i++) {
  1.3322 +        p = ps[i].re;
  1.3323 +        name = ps[i].name;
  1.3324 +        if (m = e.match(p)) {
  1.3325 +          if (as[name]) {
  1.3326 +            this.tokens.push([name, Object.clone(m)]);
  1.3327 +            e = e.replace(m[0], '');
  1.3328 +          } else {
  1.3329 +            return this.findElements(document).include(element);
  1.3330 +          }
  1.3331 +        }
  1.3332 +      }
  1.3333 +    }
  1.3334 +
  1.3335 +    var match = true, name, matches;
  1.3336 +    for (var i = 0, token; token = this.tokens[i]; i++) {
  1.3337 +      name = token[0], matches = token[1];
  1.3338 +      if (!Selector.assertions[name](element, matches)) {
  1.3339 +        match = false; break;
  1.3340 +      }
  1.3341 +    }
  1.3342 +
  1.3343 +    return match;
  1.3344 +  },
  1.3345 +
  1.3346 +  toString: function() {
  1.3347 +    return this.expression;
  1.3348 +  },
  1.3349 +
  1.3350 +  inspect: function() {
  1.3351 +    return "#<Selector:" + this.expression.inspect() + ">";
  1.3352 +  }
  1.3353 +});
  1.3354 +
  1.3355 +if (Prototype.BrowserFeatures.SelectorsAPI &&
  1.3356 + document.compatMode === 'BackCompat') {
  1.3357 +  Selector.CASE_INSENSITIVE_CLASS_NAMES = (function(){
  1.3358 +    var div = document.createElement('div'),
  1.3359 +     span = document.createElement('span');
  1.3360 +
  1.3361 +    div.id = "prototype_test_id";
  1.3362 +    span.className = 'Test';
  1.3363 +    div.appendChild(span);
  1.3364 +    var isIgnored = (div.querySelector('#prototype_test_id .test') !== null);
  1.3365 +    div = span = null;
  1.3366 +    return isIgnored;
  1.3367 +  })();
  1.3368 +}
  1.3369 +
  1.3370 +Object.extend(Selector, {
  1.3371 +  _cache: { },
  1.3372 +
  1.3373 +  xpath: {
  1.3374 +    descendant:   "//*",
  1.3375 +    child:        "/*",
  1.3376 +    adjacent:     "/following-sibling::*[1]",
  1.3377 +    laterSibling: '/following-sibling::*',
  1.3378 +    tagName:      function(m) {
  1.3379 +      if (m[1] == '*') return '';
  1.3380 +      return "[local-name()='" + m[1].toLowerCase() +
  1.3381 +             "' or local-name()='" + m[1].toUpperCase() + "']";
  1.3382 +    },
  1.3383 +    className:    "[contains(concat(' ', @class, ' '), ' #{1} ')]",
  1.3384 +    id:           "[@id='#{1}']",
  1.3385 +    attrPresence: function(m) {
  1.3386 +      m[1] = m[1].toLowerCase();
  1.3387 +      return new Template("[@#{1}]").evaluate(m);
  1.3388 +    },
  1.3389 +    attr: function(m) {
  1.3390 +      m[1] = m[1].toLowerCase();
  1.3391 +      m[3] = m[5] || m[6];
  1.3392 +      return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
  1.3393 +    },
  1.3394 +    pseudo: function(m) {
  1.3395 +      var h = Selector.xpath.pseudos[m[1]];
  1.3396 +      if (!h) return '';
  1.3397 +      if (Object.isFunction(h)) return h(m);
  1.3398 +      return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
  1.3399 +    },
  1.3400 +    operators: {
  1.3401 +      '=':  "[@#{1}='#{3}']",
  1.3402 +      '!=': "[@#{1}!='#{3}']",
  1.3403 +      '^=': "[starts-with(@#{1}, '#{3}')]",
  1.3404 +      '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
  1.3405 +      '*=': "[contains(@#{1}, '#{3}')]",
  1.3406 +      '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
  1.3407 +      '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
  1.3408 +    },
  1.3409 +    pseudos: {
  1.3410 +      'first-child': '[not(preceding-sibling::*)]',
  1.3411 +      'last-child':  '[not(following-sibling::*)]',
  1.3412 +      'only-child':  '[not(preceding-sibling::* or following-sibling::*)]',
  1.3413 +      'empty':       "[count(*) = 0 and (count(text()) = 0)]",
  1.3414 +      'checked':     "[@checked]",
  1.3415 +      'disabled':    "[(@disabled) and (@type!='hidden')]",
  1.3416 +      'enabled':     "[not(@disabled) and (@type!='hidden')]",
  1.3417 +      'not': function(m) {
  1.3418 +        var e = m[6], p = Selector.patterns,
  1.3419 +            x = Selector.xpath, le, v, len = p.length, name;
  1.3420 +
  1.3421 +        var exclusion = [];
  1.3422 +        while (e && le != e && (/\S/).test(e)) {
  1.3423 +          le = e;
  1.3424 +          for (var i = 0; i<len; i++) {
  1.3425 +            name = p[i].name
  1.3426 +            if (m = e.match(p[i].re)) {
  1.3427 +              v = Object.isFunction(x[name]) ? x[name](m) : new Template(x[name]).evaluate(m);
  1.3428 +              exclusion.push("(" + v.substring(1, v.length - 1) + ")");
  1.3429 +              e = e.replace(m[0], '');
  1.3430 +              break;
  1.3431 +            }
  1.3432 +          }
  1.3433 +        }
  1.3434 +        return "[not(" + exclusion.join(" and ") + ")]";
  1.3435 +      },
  1.3436 +      'nth-child':      function(m) {
  1.3437 +        return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
  1.3438 +      },
  1.3439 +      'nth-last-child': function(m) {
  1.3440 +        return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
  1.3441 +      },
  1.3442 +      'nth-of-type':    function(m) {
  1.3443 +        return Selector.xpath.pseudos.nth("position() ", m);
  1.3444 +      },
  1.3445 +      'nth-last-of-type': function(m) {
  1.3446 +        return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
  1.3447 +      },
  1.3448 +      'first-of-type':  function(m) {
  1.3449 +        m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
  1.3450 +      },
  1.3451 +      'last-of-type':   function(m) {
  1.3452 +        m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
  1.3453 +      },
  1.3454 +      'only-of-type':   function(m) {
  1.3455 +        var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
  1.3456 +      },
  1.3457 +      nth: function(fragment, m) {
  1.3458 +        var mm, formula = m[6], predicate;
  1.3459 +        if (formula == 'even') formula = '2n+0';
  1.3460 +        if (formula == 'odd')  formula = '2n+1';
  1.3461 +        if (mm = formula.match(/^(\d+)$/)) // digit only
  1.3462 +          return '[' + fragment + "= " + mm[1] + ']';
  1.3463 +        if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
  1.3464 +          if (mm[1] == "-") mm[1] = -1;
  1.3465 +          var a = mm[1] ? Number(mm[1]) : 1;
  1.3466 +          var b = mm[2] ? Number(mm[2]) : 0;
  1.3467 +          predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
  1.3468 +          "((#{fragment} - #{b}) div #{a} >= 0)]";
  1.3469 +          return new Template(predicate).evaluate({
  1.3470 +            fragment: fragment, a: a, b: b });
  1.3471 +        }
  1.3472 +      }
  1.3473 +    }
  1.3474 +  },
  1.3475 +
  1.3476 +  criteria: {
  1.3477 +    tagName:      'n = h.tagName(n, r, "#{1}", c);      c = false;',
  1.3478 +    className:    'n = h.className(n, r, "#{1}", c);    c = false;',
  1.3479 +    id:           'n = h.id(n, r, "#{1}", c);           c = false;',
  1.3480 +    attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
  1.3481 +    attr: function(m) {
  1.3482 +      m[3] = (m[5] || m[6]);
  1.3483 +      return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
  1.3484 +    },
  1.3485 +    pseudo: function(m) {
  1.3486 +      if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
  1.3487 +      return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
  1.3488 +    },
  1.3489 +    descendant:   'c = "descendant";',
  1.3490 +    child:        'c = "child";',
  1.3491 +    adjacent:     'c = "adjacent";',
  1.3492 +    laterSibling: 'c = "laterSibling";'
  1.3493 +  },
  1.3494 +
  1.3495 +  patterns: [
  1.3496 +    { name: 'laterSibling', re: /^\s*~\s*/ },
  1.3497 +    { name: 'child',        re: /^\s*>\s*/ },
  1.3498 +    { name: 'adjacent',     re: /^\s*\+\s*/ },
  1.3499 +    { name: 'descendant',   re: /^\s/ },
  1.3500 +
  1.3501 +    { name: 'tagName',      re: /^\s*(\*|[\w\-]+)(\b|$)?/ },
  1.3502 +    { name: 'id',           re: /^#([\w\-\*]+)(\b|$)/ },
  1.3503 +    { name: 'className',    re: /^\.([\w\-\*]+)(\b|$)/ },
  1.3504 +    { name: 'pseudo',       re: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/ },
  1.3505 +    { name: 'attrPresence', re: /^\[((?:[\w-]+:)?[\w-]+)\]/ },
  1.3506 +    { name: 'attr',         re: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ }
  1.3507 +  ],
  1.3508 +
  1.3509 +  assertions: {
  1.3510 +    tagName: function(element, matches) {
  1.3511 +      return matches[1].toUpperCase() == element.tagName.toUpperCase();
  1.3512 +    },
  1.3513 +
  1.3514 +    className: function(element, matches) {
  1.3515 +      return Element.hasClassName(element, matches[1]);
  1.3516 +    },
  1.3517 +
  1.3518 +    id: function(element, matches) {
  1.3519 +      return element.id === matches[1];
  1.3520 +    },
  1.3521 +
  1.3522 +    attrPresence: function(element, matches) {
  1.3523 +      return Element.hasAttribute(element, matches[1]);
  1.3524 +    },
  1.3525 +
  1.3526 +    attr: function(element, matches) {
  1.3527 +      var nodeValue = Element.readAttribute(element, matches[1]);
  1.3528 +      return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
  1.3529 +    }
  1.3530 +  },
  1.3531 +
  1.3532 +  handlers: {
  1.3533 +    concat: function(a, b) {
  1.3534 +      for (var i = 0, node; node = b[i]; i++)
  1.3535 +        a.push(node);
  1.3536 +      return a;
  1.3537 +    },
  1.3538 +
  1.3539 +    mark: function(nodes) {
  1.3540 +      var _true = Prototype.emptyFunction;
  1.3541 +      for (var i = 0, node; node = nodes[i]; i++)
  1.3542 +        node._countedByPrototype = _true;
  1.3543 +      return nodes;
  1.3544 +    },
  1.3545 +
  1.3546 +    unmark: (function(){
  1.3547 +
  1.3548 +      var PROPERTIES_ATTRIBUTES_MAP = (function(){
  1.3549 +        var el = document.createElement('div'),
  1.3550 +            isBuggy = false,
  1.3551 +            propName = '_countedByPrototype',
  1.3552 +            value = 'x'
  1.3553 +        el[propName] = value;
  1.3554 +        isBuggy = (el.getAttribute(propName) === value);
  1.3555 +        el = null;
  1.3556 +        return isBuggy;
  1.3557 +      })();
  1.3558 +
  1.3559 +      return PROPERTIES_ATTRIBUTES_MAP ?
  1.3560 +        function(nodes) {
  1.3561 +          for (var i = 0, node; node = nodes[i]; i++)
  1.3562 +            node.removeAttribute('_countedByPrototype');
  1.3563 +          return nodes;
  1.3564 +        } :
  1.3565 +        function(nodes) {
  1.3566 +          for (var i = 0, node; node = nodes[i]; i++)
  1.3567 +            node._countedByPrototype = void 0;
  1.3568 +          return nodes;
  1.3569 +        }
  1.3570 +    })(),
  1.3571 +
  1.3572 +    index: function(parentNode, reverse, ofType) {
  1.3573 +      parentNode._countedByPrototype = Prototype.emptyFunction;
  1.3574 +      if (reverse) {
  1.3575 +        for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
  1.3576 +          var node = nodes[i];
  1.3577 +          if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
  1.3578 +        }
  1.3579 +      } else {
  1.3580 +        for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
  1.3581 +          if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
  1.3582 +      }
  1.3583 +    },
  1.3584 +
  1.3585 +    unique: function(nodes) {
  1.3586 +      if (nodes.length == 0) return nodes;
  1.3587 +      var results = [], n;
  1.3588 +      for (var i = 0, l = nodes.length; i < l; i++)
  1.3589 +        if (typeof (n = nodes[i])._countedByPrototype == 'undefined') {
  1.3590 +          n._countedByPrototype = Prototype.emptyFunction;
  1.3591 +          results.push(Element.extend(n));
  1.3592 +        }
  1.3593 +      return Selector.handlers.unmark(results);
  1.3594 +    },
  1.3595 +
  1.3596 +    descendant: function(nodes) {
  1.3597 +      var h = Selector.handlers;
  1.3598 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3599 +        h.concat(results, node.getElementsByTagName('*'));
  1.3600 +      return results;
  1.3601 +    },
  1.3602 +
  1.3603 +    child: function(nodes) {
  1.3604 +      var h = Selector.handlers;
  1.3605 +      for (var i = 0, results = [], node; node = nodes[i]; i++) {
  1.3606 +        for (var j = 0, child; child = node.childNodes[j]; j++)
  1.3607 +          if (child.nodeType == 1 && child.tagName != '!') results.push(child);
  1.3608 +      }
  1.3609 +      return results;
  1.3610 +    },
  1.3611 +
  1.3612 +    adjacent: function(nodes) {
  1.3613 +      for (var i = 0, results = [], node; node = nodes[i]; i++) {
  1.3614 +        var next = this.nextElementSibling(node);
  1.3615 +        if (next) results.push(next);
  1.3616 +      }
  1.3617 +      return results;
  1.3618 +    },
  1.3619 +
  1.3620 +    laterSibling: function(nodes) {
  1.3621 +      var h = Selector.handlers;
  1.3622 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3623 +        h.concat(results, Element.nextSiblings(node));
  1.3624 +      return results;
  1.3625 +    },
  1.3626 +
  1.3627 +    nextElementSibling: function(node) {
  1.3628 +      while (node = node.nextSibling)
  1.3629 +        if (node.nodeType == 1) return node;
  1.3630 +      return null;
  1.3631 +    },
  1.3632 +
  1.3633 +    previousElementSibling: function(node) {
  1.3634 +      while (node = node.previousSibling)
  1.3635 +        if (node.nodeType == 1) return node;
  1.3636 +      return null;
  1.3637 +    },
  1.3638 +
  1.3639 +    tagName: function(nodes, root, tagName, combinator) {
  1.3640 +      var uTagName = tagName.toUpperCase();
  1.3641 +      var results = [], h = Selector.handlers;
  1.3642 +      if (nodes) {
  1.3643 +        if (combinator) {
  1.3644 +          if (combinator == "descendant") {
  1.3645 +            for (var i = 0, node; node = nodes[i]; i++)
  1.3646 +              h.concat(results, node.getElementsByTagName(tagName));
  1.3647 +            return results;
  1.3648 +          } else nodes = this[combinator](nodes);
  1.3649 +          if (tagName == "*") return nodes;
  1.3650 +        }
  1.3651 +        for (var i = 0, node; node = nodes[i]; i++)
  1.3652 +          if (node.tagName.toUpperCase() === uTagName) results.push(node);
  1.3653 +        return results;
  1.3654 +      } else return root.getElementsByTagName(tagName);
  1.3655 +    },
  1.3656 +
  1.3657 +    id: function(nodes, root, id, combinator) {
  1.3658 +      var targetNode = $(id), h = Selector.handlers;
  1.3659 +
  1.3660 +      if (root == document) {
  1.3661 +        if (!targetNode) return [];
  1.3662 +        if (!nodes) return [targetNode];
  1.3663 +      } else {
  1.3664 +        if (!root.sourceIndex || root.sourceIndex < 1) {
  1.3665 +          var nodes = root.getElementsByTagName('*');
  1.3666 +          for (var j = 0, node; node = nodes[j]; j++) {
  1.3667 +            if (node.id === id) return [node];
  1.3668 +          }
  1.3669 +        }
  1.3670 +      }
  1.3671 +
  1.3672 +      if (nodes) {
  1.3673 +        if (combinator) {
  1.3674 +          if (combinator == 'child') {
  1.3675 +            for (var i = 0, node; node = nodes[i]; i++)
  1.3676 +              if (targetNode.parentNode == node) return [targetNode];
  1.3677 +          } else if (combinator == 'descendant') {
  1.3678 +            for (var i = 0, node; node = nodes[i]; i++)
  1.3679 +              if (Element.descendantOf(targetNode, node)) return [targetNode];
  1.3680 +          } else if (combinator == 'adjacent') {
  1.3681 +            for (var i = 0, node; node = nodes[i]; i++)
  1.3682 +              if (Selector.handlers.previousElementSibling(targetNode) == node)
  1.3683 +                return [targetNode];
  1.3684 +          } else nodes = h[combinator](nodes);
  1.3685 +        }
  1.3686 +        for (var i = 0, node; node = nodes[i]; i++)
  1.3687 +          if (node == targetNode) return [targetNode];
  1.3688 +        return [];
  1.3689 +      }
  1.3690 +      return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
  1.3691 +    },
  1.3692 +
  1.3693 +    className: function(nodes, root, className, combinator) {
  1.3694 +      if (nodes && combinator) nodes = this[combinator](nodes);
  1.3695 +      return Selector.handlers.byClassName(nodes, root, className);
  1.3696 +    },
  1.3697 +
  1.3698 +    byClassName: function(nodes, root, className) {
  1.3699 +      if (!nodes) nodes = Selector.handlers.descendant([root]);
  1.3700 +      var needle = ' ' + className + ' ';
  1.3701 +      for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
  1.3702 +        nodeClassName = node.className;
  1.3703 +        if (nodeClassName.length == 0) continue;
  1.3704 +        if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
  1.3705 +          results.push(node);
  1.3706 +      }
  1.3707 +      return results;
  1.3708 +    },
  1.3709 +
  1.3710 +    attrPresence: function(nodes, root, attr, combinator) {
  1.3711 +      if (!nodes) nodes = root.getElementsByTagName("*");
  1.3712 +      if (nodes && combinator) nodes = this[combinator](nodes);
  1.3713 +      var results = [];
  1.3714 +      for (var i = 0, node; node = nodes[i]; i++)
  1.3715 +        if (Element.hasAttribute(node, attr)) results.push(node);
  1.3716 +      return results;
  1.3717 +    },
  1.3718 +
  1.3719 +    attr: function(nodes, root, attr, value, operator, combinator) {
  1.3720 +      if (!nodes) nodes = root.getElementsByTagName("*");
  1.3721 +      if (nodes && combinator) nodes = this[combinator](nodes);
  1.3722 +      var handler = Selector.operators[operator], results = [];
  1.3723 +      for (var i = 0, node; node = nodes[i]; i++) {
  1.3724 +        var nodeValue = Element.readAttribute(node, attr);
  1.3725 +        if (nodeValue === null) continue;
  1.3726 +        if (handler(nodeValue, value)) results.push(node);
  1.3727 +      }
  1.3728 +      return results;
  1.3729 +    },
  1.3730 +
  1.3731 +    pseudo: function(nodes, name, value, root, combinator) {
  1.3732 +      if (nodes && combinator) nodes = this[combinator](nodes);
  1.3733 +      if (!nodes) nodes = root.getElementsByTagName("*");
  1.3734 +      return Selector.pseudos[name](nodes, value, root);
  1.3735 +    }
  1.3736 +  },
  1.3737 +
  1.3738 +  pseudos: {
  1.3739 +    'first-child': function(nodes, value, root) {
  1.3740 +      for (var i = 0, results = [], node; node = nodes[i]; i++) {
  1.3741 +        if (Selector.handlers.previousElementSibling(node)) continue;
  1.3742 +          results.push(node);
  1.3743 +      }
  1.3744 +      return results;
  1.3745 +    },
  1.3746 +    'last-child': function(nodes, value, root) {
  1.3747 +      for (var i = 0, results = [], node; node = nodes[i]; i++) {
  1.3748 +        if (Selector.handlers.nextElementSibling(node)) continue;
  1.3749 +          results.push(node);
  1.3750 +      }
  1.3751 +      return results;
  1.3752 +    },
  1.3753 +    'only-child': function(nodes, value, root) {
  1.3754 +      var h = Selector.handlers;
  1.3755 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3756 +        if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
  1.3757 +          results.push(node);
  1.3758 +      return results;
  1.3759 +    },
  1.3760 +    'nth-child':        function(nodes, formula, root) {
  1.3761 +      return Selector.pseudos.nth(nodes, formula, root);
  1.3762 +    },
  1.3763 +    'nth-last-child':   function(nodes, formula, root) {
  1.3764 +      return Selector.pseudos.nth(nodes, formula, root, true);
  1.3765 +    },
  1.3766 +    'nth-of-type':      function(nodes, formula, root) {
  1.3767 +      return Selector.pseudos.nth(nodes, formula, root, false, true);
  1.3768 +    },
  1.3769 +    'nth-last-of-type': function(nodes, formula, root) {
  1.3770 +      return Selector.pseudos.nth(nodes, formula, root, true, true);
  1.3771 +    },
  1.3772 +    'first-of-type':    function(nodes, formula, root) {
  1.3773 +      return Selector.pseudos.nth(nodes, "1", root, false, true);
  1.3774 +    },
  1.3775 +    'last-of-type':     function(nodes, formula, root) {
  1.3776 +      return Selector.pseudos.nth(nodes, "1", root, true, true);
  1.3777 +    },
  1.3778 +    'only-of-type':     function(nodes, formula, root) {
  1.3779 +      var p = Selector.pseudos;
  1.3780 +      return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
  1.3781 +    },
  1.3782 +
  1.3783 +    getIndices: function(a, b, total) {
  1.3784 +      if (a == 0) return b > 0 ? [b] : [];
  1.3785 +      return $R(1, total).inject([], function(memo, i) {
  1.3786 +        if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
  1.3787 +        return memo;
  1.3788 +      });
  1.3789 +    },
  1.3790 +
  1.3791 +    nth: function(nodes, formula, root, reverse, ofType) {
  1.3792 +      if (nodes.length == 0) return [];
  1.3793 +      if (formula == 'even') formula = '2n+0';
  1.3794 +      if (formula == 'odd')  formula = '2n+1';
  1.3795 +      var h = Selector.handlers, results = [], indexed = [], m;
  1.3796 +      h.mark(nodes);
  1.3797 +      for (var i = 0, node; node = nodes[i]; i++) {
  1.3798 +        if (!node.parentNode._countedByPrototype) {
  1.3799 +          h.index(node.parentNode, reverse, ofType);
  1.3800 +          indexed.push(node.parentNode);
  1.3801 +        }
  1.3802 +      }
  1.3803 +      if (formula.match(/^\d+$/)) { // just a number
  1.3804 +        formula = Number(formula);
  1.3805 +        for (var i = 0, node; node = nodes[i]; i++)
  1.3806 +          if (node.nodeIndex == formula) results.push(node);
  1.3807 +      } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
  1.3808 +        if (m[1] == "-") m[1] = -1;
  1.3809 +        var a = m[1] ? Number(m[1]) : 1;
  1.3810 +        var b = m[2] ? Number(m[2]) : 0;
  1.3811 +        var indices = Selector.pseudos.getIndices(a, b, nodes.length);
  1.3812 +        for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
  1.3813 +          for (var j = 0; j < l; j++)
  1.3814 +            if (node.nodeIndex == indices[j]) results.push(node);
  1.3815 +        }
  1.3816 +      }
  1.3817 +      h.unmark(nodes);
  1.3818 +      h.unmark(indexed);
  1.3819 +      return results;
  1.3820 +    },
  1.3821 +
  1.3822 +    'empty': function(nodes, value, root) {
  1.3823 +      for (var i = 0, results = [], node; node = nodes[i]; i++) {
  1.3824 +        if (node.tagName == '!' || node.firstChild) continue;
  1.3825 +        results.push(node);
  1.3826 +      }
  1.3827 +      return results;
  1.3828 +    },
  1.3829 +
  1.3830 +    'not': function(nodes, selector, root) {
  1.3831 +      var h = Selector.handlers, selectorType, m;
  1.3832 +      var exclusions = new Selector(selector).findElements(root);
  1.3833 +      h.mark(exclusions);
  1.3834 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3835 +        if (!node._countedByPrototype) results.push(node);
  1.3836 +      h.unmark(exclusions);
  1.3837 +      return results;
  1.3838 +    },
  1.3839 +
  1.3840 +    'enabled': function(nodes, value, root) {
  1.3841 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3842 +        if (!node.disabled && (!node.type || node.type !== 'hidden'))
  1.3843 +          results.push(node);
  1.3844 +      return results;
  1.3845 +    },
  1.3846 +
  1.3847 +    'disabled': function(nodes, value, root) {
  1.3848 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3849 +        if (node.disabled) results.push(node);
  1.3850 +      return results;
  1.3851 +    },
  1.3852 +
  1.3853 +    'checked': function(nodes, value, root) {
  1.3854 +      for (var i = 0, results = [], node; node = nodes[i]; i++)
  1.3855 +        if (node.checked) results.push(node);
  1.3856 +      return results;
  1.3857 +    }
  1.3858 +  },
  1.3859 +
  1.3860 +  operators: {
  1.3861 +    '=':  function(nv, v) { return nv == v; },
  1.3862 +    '!=': function(nv, v) { return nv != v; },
  1.3863 +    '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
  1.3864 +    '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
  1.3865 +    '*=': function(nv, v) { return nv == v || nv && nv.include(v); },
  1.3866 +    '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
  1.3867 +    '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
  1.3868 +     '-').include('-' + (v || "").toUpperCase() + '-'); }
  1.3869 +  },
  1.3870 +
  1.3871 +  split: function(expression) {
  1.3872 +    var expressions = [];
  1.3873 +    expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
  1.3874 +      expressions.push(m[1].strip());
  1.3875 +    });
  1.3876 +    return expressions;
  1.3877 +  },
  1.3878 +
  1.3879 +  matchElements: function(elements, expression) {
  1.3880 +    var matches = $$(expression), h = Selector.handlers;
  1.3881 +    h.mark(matches);
  1.3882 +    for (var i = 0, results = [], element; element = elements[i]; i++)
  1.3883 +      if (element._countedByPrototype) results.push(element);
  1.3884 +    h.unmark(matches);
  1.3885 +    return results;
  1.3886 +  },
  1.3887 +
  1.3888 +  findElement: function(elements, expression, index) {
  1.3889 +    if (Object.isNumber(expression)) {
  1.3890 +      index = expression; expression = false;
  1.3891 +    }
  1.3892 +    return Selector.matchElements(elements, expression || '*')[index || 0];
  1.3893 +  },
  1.3894 +
  1.3895 +  findChildElements: function(element, expressions) {
  1.3896 +    expressions = Selector.split(expressions.join(','));
  1.3897 +    var results = [], h = Selector.handlers;
  1.3898 +    for (var i = 0, l = expressions.length, selector; i < l; i++) {
  1.3899 +      selector = new Selector(expressions[i].strip());
  1.3900 +      h.concat(results, selector.findElements(element));
  1.3901 +    }
  1.3902 +    return (l > 1) ? h.unique(results) : results;
  1.3903 +  }
  1.3904 +});
  1.3905 +
  1.3906 +if (Prototype.Browser.IE) {
  1.3907 +  Object.extend(Selector.handlers, {
  1.3908 +    concat: function(a, b) {
  1.3909 +      for (var i = 0, node; node = b[i]; i++)
  1.3910 +        if (node.tagName !== "!") a.push(node);
  1.3911 +      return a;
  1.3912 +    }
  1.3913 +  });
  1.3914 +}
  1.3915 +
  1.3916 +function $$() {
  1.3917 +  return Selector.findChildElements(document, $A(arguments));
  1.3918 +}
  1.3919 +
  1.3920 +var Form = {
  1.3921 +  reset: function(form) {
  1.3922 +    form = $(form);
  1.3923 +    form.reset();
  1.3924 +    return form;
  1.3925 +  },
  1.3926 +
  1.3927 +  serializeElements: function(elements, options) {
  1.3928 +    if (typeof options != 'object') options = { hash: !!options };
  1.3929 +    else if (Object.isUndefined(options.hash)) options.hash = true;
  1.3930 +    var key, value, submitted = false, submit = options.submit;
  1.3931 +
  1.3932 +    var data = elements.inject({ }, function(result, element) {
  1.3933 +      if (!element.disabled && element.name) {
  1.3934 +        key = element.name; value = $(element).getValue();
  1.3935 +        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
  1.3936 +            submit !== false && (!submit || key == submit) && (submitted = true)))) {
  1.3937 +          if (key in result) {
  1.3938 +            if (!Object.isArray(result[key])) result[key] = [result[key]];
  1.3939 +            result[key].push(value);
  1.3940 +          }
  1.3941 +          else result[key] = value;
  1.3942 +        }
  1.3943 +      }
  1.3944 +      return result;
  1.3945 +    });
  1.3946 +
  1.3947 +    return options.hash ? data : Object.toQueryString(data);
  1.3948 +  }
  1.3949 +};
  1.3950 +
  1.3951 +Form.Methods = {
  1.3952 +  serialize: function(form, options) {
  1.3953 +    return Form.serializeElements(Form.getElements(form), options);
  1.3954 +  },
  1.3955 +
  1.3956 +  getElements: function(form) {
  1.3957 +    var elements = $(form).getElementsByTagName('*'),
  1.3958 +        element,
  1.3959 +        arr = [ ],
  1.3960 +        serializers = Form.Element.Serializers;
  1.3961 +    for (var i = 0; element = elements[i]; i++) {
  1.3962 +      arr.push(element);
  1.3963 +    }
  1.3964 +    return arr.inject([], function(elements, child) {
  1.3965 +      if (serializers[child.tagName.toLowerCase()])
  1.3966 +        elements.push(Element.extend(child));
  1.3967 +      return elements;
  1.3968 +    })
  1.3969 +  },
  1.3970 +
  1.3971 +  getInputs: function(form, typeName, name) {
  1.3972 +    form = $(form);
  1.3973 +    var inputs = form.getElementsByTagName('input');
  1.3974 +
  1.3975 +    if (!typeName && !name) return $A(inputs).map(Element.extend);
  1.3976 +
  1.3977 +    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
  1.3978 +      var input = inputs[i];
  1.3979 +      if ((typeName && input.type != typeName) || (name && input.name != name))
  1.3980 +        continue;
  1.3981 +      matchingInputs.push(Element.extend(input));
  1.3982 +    }
  1.3983 +
  1.3984 +    return matchingInputs;
  1.3985 +  },
  1.3986 +
  1.3987 +  disable: function(form) {
  1.3988 +    form = $(form);
  1.3989 +    Form.getElements(form).invoke('disable');
  1.3990 +    return form;
  1.3991 +  },
  1.3992 +
  1.3993 +  enable: function(form) {
  1.3994 +    form = $(form);
  1.3995 +    Form.getElements(form).invoke('enable');
  1.3996 +    return form;
  1.3997 +  },
  1.3998 +
  1.3999 +  findFirstElement: function(form) {
  1.4000 +    var elements = $(form).getElements().findAll(function(element) {
  1.4001 +      return 'hidden' != element.type && !element.disabled;
  1.4002 +    });
  1.4003 +    var firstByIndex = elements.findAll(function(element) {
  1.4004 +      return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
  1.4005 +    }).sortBy(function(element) { return element.tabIndex }).first();
  1.4006 +
  1.4007 +    return firstByIndex ? firstByIndex : elements.find(function(element) {
  1.4008 +      return /^(?:input|select|textarea)$/i.test(element.tagName);
  1.4009 +    });
  1.4010 +  },
  1.4011 +
  1.4012 +  focusFirstElement: function(form) {
  1.4013 +    form = $(form);
  1.4014 +    form.findFirstElement().activate();
  1.4015 +    return form;
  1.4016 +  },
  1.4017 +
  1.4018 +  request: function(form, options) {
  1.4019 +    form = $(form), options = Object.clone(options || { });
  1.4020 +
  1.4021 +    var params = options.parameters, action = form.readAttribute('action') || '';
  1.4022 +    if (action.blank()) action = window.location.href;
  1.4023 +    options.parameters = form.serialize(true);
  1.4024 +
  1.4025 +    if (params) {
  1.4026 +      if (Object.isString(params)) params = params.toQueryParams();
  1.4027 +      Object.extend(options.parameters, params);
  1.4028 +    }
  1.4029 +
  1.4030 +    if (form.hasAttribute('method') && !options.method)
  1.4031 +      options.method = form.method;
  1.4032 +
  1.4033 +    return new Ajax.Request(action, options);
  1.4034 +  }
  1.4035 +};
  1.4036 +
  1.4037 +/*--------------------------------------------------------------------------*/
  1.4038 +
  1.4039 +
  1.4040 +Form.Element = {
  1.4041 +  focus: function(element) {
  1.4042 +    $(element).focus();
  1.4043 +    return element;
  1.4044 +  },
  1.4045 +
  1.4046 +  select: function(element) {
  1.4047 +    $(element).select();
  1.4048 +    return element;
  1.4049 +  }
  1.4050 +};
  1.4051 +
  1.4052 +Form.Element.Methods = {
  1.4053 +
  1.4054 +  serialize: function(element) {
  1.4055 +    element = $(element);
  1.4056 +    if (!element.disabled && element.name) {
  1.4057 +      var value = element.getValue();
  1.4058 +      if (value != undefined) {
  1.4059 +        var pair = { };
  1.4060 +        pair[element.name] = value;
  1.4061 +        return Object.toQueryString(pair);
  1.4062 +      }
  1.4063 +    }
  1.4064 +    return '';
  1.4065 +  },
  1.4066 +
  1.4067 +  getValue: function(element) {
  1.4068 +    element = $(element);
  1.4069 +    var method = element.tagName.toLowerCase();
  1.4070 +    return Form.Element.Serializers[method](element);
  1.4071 +  },
  1.4072 +
  1.4073 +  setValue: function(element, value) {
  1.4074 +    element = $(element);
  1.4075 +    var method = element.tagName.toLowerCase();
  1.4076 +    Form.Element.Serializers[method](element, value);
  1.4077 +    return element;
  1.4078 +  },
  1.4079 +
  1.4080 +  clear: function(element) {
  1.4081 +    $(element).value = '';
  1.4082 +    return element;
  1.4083 +  },
  1.4084 +
  1.4085 +  present: function(element) {
  1.4086 +    return $(element).value != '';
  1.4087 +  },
  1.4088 +
  1.4089 +  activate: function(element) {
  1.4090 +    element = $(element);
  1.4091 +    try {
  1.4092 +      element.focus();
  1.4093 +      if (element.select && (element.tagName.toLowerCase() != 'input' ||
  1.4094 +          !(/^(?:button|reset|submit)$/i.test(element.type))))
  1.4095 +        element.select();
  1.4096 +    } catch (e) { }
  1.4097 +    return element;
  1.4098 +  },
  1.4099 +
  1.4100 +  disable: function(element) {
  1.4101 +    element = $(element);
  1.4102 +    element.disabled = true;
  1.4103 +    return element;
  1.4104 +  },
  1.4105 +
  1.4106 +  enable: function(element) {
  1.4107 +    element = $(element);
  1.4108 +    element.disabled = false;
  1.4109 +    return element;
  1.4110 +  }
  1.4111 +};
  1.4112 +
  1.4113 +/*--------------------------------------------------------------------------*/
  1.4114 +
  1.4115 +var Field = Form.Element;
  1.4116 +
  1.4117 +var $F = Form.Element.Methods.getValue;
  1.4118 +
  1.4119 +/*--------------------------------------------------------------------------*/
  1.4120 +
  1.4121 +Form.Element.Serializers = {
  1.4122 +  input: function(element, value) {
  1.4123 +    switch (element.type.toLowerCase()) {
  1.4124 +      case 'checkbox':
  1.4125 +      case 'radio':
  1.4126 +        return Form.Element.Serializers.inputSelector(element, value);
  1.4127 +      default:
  1.4128 +        return Form.Element.Serializers.textarea(element, value);
  1.4129 +    }
  1.4130 +  },
  1.4131 +
  1.4132 +  inputSelector: function(element, value) {
  1.4133 +    if (Object.isUndefined(value)) return element.checked ? element.value : null;
  1.4134 +    else element.checked = !!value;
  1.4135 +  },
  1.4136 +
  1.4137 +  textarea: function(element, value) {
  1.4138 +    if (Object.isUndefined(value)) return element.value;
  1.4139 +    else element.value = value;
  1.4140 +  },
  1.4141 +
  1.4142 +  select: function(element, value) {
  1.4143 +    if (Object.isUndefined(value))
  1.4144 +      return this[element.type == 'select-one' ?
  1.4145 +        'selectOne' : 'selectMany'](element);
  1.4146 +    else {
  1.4147 +      var opt, currentValue, single = !Object.isArray(value);
  1.4148 +      for (var i = 0, length = element.length; i < length; i++) {
  1.4149 +        opt = element.options[i];
  1.4150 +        currentValue = this.optionValue(opt);
  1.4151 +        if (single) {
  1.4152 +          if (currentValue == value) {
  1.4153 +            opt.selected = true;
  1.4154 +            return;
  1.4155 +          }
  1.4156 +        }
  1.4157 +        else opt.selected = value.include(currentValue);
  1.4158 +      }
  1.4159 +    }
  1.4160 +  },
  1.4161 +
  1.4162 +  selectOne: function(element) {
  1.4163 +    var index = element.selectedIndex;
  1.4164 +    return index >= 0 ? this.optionValue(element.options[index]) : null;
  1.4165 +  },
  1.4166 +
  1.4167 +  selectMany: function(element) {
  1.4168 +    var values, length = element.length;
  1.4169 +    if (!length) return null;
  1.4170 +
  1.4171 +    for (var i = 0, values = []; i < length; i++) {
  1.4172 +      var opt = element.options[i];
  1.4173 +      if (opt.selected) values.push(this.optionValue(opt));
  1.4174 +    }
  1.4175 +    return values;
  1.4176 +  },
  1.4177 +
  1.4178 +  optionValue: function(opt) {
  1.4179 +    return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
  1.4180 +  }
  1.4181 +};
  1.4182 +
  1.4183 +/*--------------------------------------------------------------------------*/
  1.4184 +
  1.4185 +
  1.4186 +Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
  1.4187 +  initialize: function($super, element, frequency, callback) {
  1.4188 +    $super(callback, frequency);
  1.4189 +    this.element   = $(element);
  1.4190 +    this.lastValue = this.getValue();
  1.4191 +  },
  1.4192 +
  1.4193 +  execute: function() {
  1.4194 +    var value = this.getValue();
  1.4195 +    if (Object.isString(this.lastValue) && Object.isString(value) ?
  1.4196 +        this.lastValue != value : String(this.lastValue) != String(value)) {
  1.4197 +      this.callback(this.element, value);
  1.4198 +      this.lastValue = value;
  1.4199 +    }
  1.4200 +  }
  1.4201 +});
  1.4202 +
  1.4203 +Form.Element.Observer = Class.create(Abstract.TimedObserver, {
  1.4204 +  getValue: function() {
  1.4205 +    return Form.Element.getValue(this.element);
  1.4206 +  }
  1.4207 +});
  1.4208 +
  1.4209 +Form.Observer = Class.create(Abstract.TimedObserver, {
  1.4210 +  getValue: function() {
  1.4211 +    return Form.serialize(this.element);
  1.4212 +  }
  1.4213 +});
  1.4214 +
  1.4215 +/*--------------------------------------------------------------------------*/
  1.4216 +
  1.4217 +Abstract.EventObserver = Class.create({
  1.4218 +  initialize: function(element, callback) {
  1.4219 +    this.element  = $(element);
  1.4220 +    this.callback = callback;
  1.4221 +
  1.4222 +    this.lastValue = this.getValue();
  1.4223 +    if (this.element.tagName.toLowerCase() == 'form')
  1.4224 +      this.registerFormCallbacks();
  1.4225 +    else
  1.4226 +      this.registerCallback(this.element);
  1.4227 +  },
  1.4228 +
  1.4229 +  onElementEvent: function() {
  1.4230 +    var value = this.getValue();
  1.4231 +    if (this.lastValue != value) {
  1.4232 +      this.callback(this.element, value);
  1.4233 +      this.lastValue = value;
  1.4234 +    }
  1.4235 +  },
  1.4236 +
  1.4237 +  registerFormCallbacks: function() {
  1.4238 +    Form.getElements(this.element).each(this.registerCallback, this);
  1.4239 +  },
  1.4240 +
  1.4241 +  registerCallback: function(element) {
  1.4242 +    if (element.type) {
  1.4243 +      switch (element.type.toLowerCase()) {
  1.4244 +        case 'checkbox':
  1.4245 +        case 'radio':
  1.4246 +          Event.observe(element, 'click', this.onElementEvent.bind(this));
  1.4247 +          break;
  1.4248 +        default:
  1.4249 +          Event.observe(element, 'change', this.onElementEvent.bind(this));
  1.4250 +          break;
  1.4251 +      }
  1.4252 +    }
  1.4253 +  }
  1.4254 +});
  1.4255 +
  1.4256 +Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
  1.4257 +  getValue: function() {
  1.4258 +    return Form.Element.getValue(this.element);
  1.4259 +  }
  1.4260 +});
  1.4261 +
  1.4262 +Form.EventObserver = Class.create(Abstract.EventObserver, {
  1.4263 +  getValue: function() {
  1.4264 +    return Form.serialize(this.element);
  1.4265 +  }
  1.4266 +});
  1.4267 +(function() {
  1.4268 +
  1.4269 +  var Event = {
  1.4270 +    KEY_BACKSPACE: 8,
  1.4271 +    KEY_TAB:       9,
  1.4272 +    KEY_RETURN:   13,
  1.4273 +    KEY_ESC:      27,
  1.4274 +    KEY_LEFT:     37,
  1.4275 +    KEY_UP:       38,
  1.4276 +    KEY_RIGHT:    39,
  1.4277 +    KEY_DOWN:     40,
  1.4278 +    KEY_DELETE:   46,
  1.4279 +    KEY_HOME:     36,
  1.4280 +    KEY_END:      35,
  1.4281 +    KEY_PAGEUP:   33,
  1.4282 +    KEY_PAGEDOWN: 34,
  1.4283 +    KEY_INSERT:   45,
  1.4284 +
  1.4285 +    cache: {}
  1.4286 +  };
  1.4287 +
  1.4288 +  var docEl = document.documentElement;
  1.4289 +  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
  1.4290 +    && 'onmouseleave' in docEl;
  1.4291 +
  1.4292 +  var _isButton;
  1.4293 +  if (Prototype.Browser.IE) {
  1.4294 +    var buttonMap = { 0: 1, 1: 4, 2: 2 };
  1.4295 +    _isButton = function(event, code) {
  1.4296 +      return event.button === buttonMap[code];
  1.4297 +    };
  1.4298 +  } else if (Prototype.Browser.WebKit) {
  1.4299 +    _isButton = function(event, code) {
  1.4300 +      switch (code) {
  1.4301 +        case 0: return event.which == 1 && !event.metaKey;
  1.4302 +        case 1: return event.which == 1 && event.metaKey;
  1.4303 +        default: return false;
  1.4304 +      }
  1.4305 +    };
  1.4306 +  } else {
  1.4307 +    _isButton = function(event, code) {
  1.4308 +      return event.which ? (event.which === code + 1) : (event.button === code);
  1.4309 +    };
  1.4310 +  }
  1.4311 +
  1.4312 +  function isLeftClick(event)   { return _isButton(event, 0) }
  1.4313 +
  1.4314 +  function isMiddleClick(event) { return _isButton(event, 1) }
  1.4315 +
  1.4316 +  function isRightClick(event)  { return _isButton(event, 2) }
  1.4317 +
  1.4318 +  function element(event) {
  1.4319 +    event = Event.extend(event);
  1.4320 +
  1.4321 +    var node = event.target, type = event.type,
  1.4322 +     currentTarget = event.currentTarget;
  1.4323 +
  1.4324 +    if (currentTarget && currentTarget.tagName) {
  1.4325 +      if (type === 'load' || type === 'error' ||
  1.4326 +        (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
  1.4327 +          && currentTarget.type === 'radio'))
  1.4328 +            node = currentTarget;
  1.4329 +    }
  1.4330 +
  1.4331 +    if (node.nodeType == Node.TEXT_NODE)
  1.4332 +      node = node.parentNode;
  1.4333 +
  1.4334 +    return Element.extend(node);
  1.4335 +  }
  1.4336 +
  1.4337 +  function findElement(event, expression) {
  1.4338 +    var element = Event.element(event);
  1.4339 +    if (!expression) return element;
  1.4340 +    var elements = [element].concat(element.ancestors());
  1.4341 +    return Selector.findElement(elements, expression, 0);
  1.4342 +  }
  1.4343 +
  1.4344 +  function pointer(event) {
  1.4345 +    return { x: pointerX(event), y: pointerY(event) };
  1.4346 +  }
  1.4347 +
  1.4348 +  function pointerX(event) {
  1.4349 +    var docElement = document.documentElement,
  1.4350 +     body = document.body || { scrollLeft: 0 };
  1.4351 +
  1.4352 +    return event.pageX || (event.clientX +
  1.4353 +      (docElement.scrollLeft || body.scrollLeft) -
  1.4354 +      (docElement.clientLeft || 0));
  1.4355 +  }
  1.4356 +
  1.4357 +  function pointerY(event) {
  1.4358 +    var docElement = document.documentElement,
  1.4359 +     body = document.body || { scrollTop: 0 };
  1.4360 +
  1.4361 +    return  event.pageY || (event.clientY +
  1.4362 +       (docElement.scrollTop || body.scrollTop) -
  1.4363 +       (docElement.clientTop || 0));
  1.4364 +  }
  1.4365 +
  1.4366 +
  1.4367 +  function stop(event) {
  1.4368 +    Event.extend(event);
  1.4369 +    event.preventDefault();
  1.4370 +    event.stopPropagation();
  1.4371 +
  1.4372 +    event.stopped = true;
  1.4373 +  }
  1.4374 +
  1.4375 +  Event.Methods = {
  1.4376 +    isLeftClick: isLeftClick,
  1.4377 +    isMiddleClick: isMiddleClick,
  1.4378 +    isRightClick: isRightClick,
  1.4379 +
  1.4380 +    element: element,
  1.4381 +    findElement: findElement,
  1.4382 +
  1.4383 +    pointer: pointer,
  1.4384 +    pointerX: pointerX,
  1.4385 +    pointerY: pointerY,
  1.4386 +
  1.4387 +    stop: stop
  1.4388 +  };
  1.4389 +
  1.4390 +
  1.4391 +  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
  1.4392 +    m[name] = Event.Methods[name].methodize();
  1.4393 +    return m;
  1.4394 +  });
  1.4395 +
  1.4396 +  if (Prototype.Browser.IE) {
  1.4397 +    function _relatedTarget(event) {
  1.4398 +      var element;
  1.4399 +      switch (event.type) {
  1.4400 +        case 'mouseover': element = event.fromElement; break;
  1.4401 +        case 'mouseout':  element = event.toElement;   break;
  1.4402 +        default: return null;
  1.4403 +      }
  1.4404 +      return Element.extend(element);
  1.4405 +    }
  1.4406 +
  1.4407 +    Object.extend(methods, {
  1.4408 +      stopPropagation: function() { this.cancelBubble = true },
  1.4409 +      preventDefault:  function() { this.returnValue = false },
  1.4410 +      inspect: function() { return '[object Event]' }
  1.4411 +    });
  1.4412 +
  1.4413 +    Event.extend = function(event, element) {
  1.4414 +      if (!event) return false;
  1.4415 +      if (event._extendedByPrototype) return event;
  1.4416 +
  1.4417 +      event._extendedByPrototype = Prototype.emptyFunction;
  1.4418 +      var pointer = Event.pointer(event);
  1.4419 +
  1.4420 +      Object.extend(event, {
  1.4421 +        target: event.srcElement || element,
  1.4422 +        relatedTarget: _relatedTarget(event),
  1.4423 +        pageX:  pointer.x,
  1.4424 +        pageY:  pointer.y
  1.4425 +      });
  1.4426 +
  1.4427 +      return Object.extend(event, methods);
  1.4428 +    };
  1.4429 +  } else {
  1.4430 +    Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__;
  1.4431 +    Object.extend(Event.prototype, methods);
  1.4432 +    Event.extend = Prototype.K;
  1.4433 +  }
  1.4434 +
  1.4435 +  function _createResponder(element, eventName, handler) {
  1.4436 +    var registry = Element.retrieve(element, 'prototype_event_registry');
  1.4437 +
  1.4438 +    if (Object.isUndefined(registry)) {
  1.4439 +      CACHE.push(element);
  1.4440 +      registry = Element.retrieve(element, 'prototype_event_registry', $H());
  1.4441 +    }
  1.4442 +
  1.4443 +    var respondersForEvent = registry.get(eventName);
  1.4444 +    if (Object.isUndefined(respondersForEvent)) {
  1.4445 +      respondersForEvent = [];
  1.4446 +      registry.set(eventName, respondersForEvent);
  1.4447 +    }
  1.4448 +
  1.4449 +    if (respondersForEvent.pluck('handler').include(handler)) return false;
  1.4450 +
  1.4451 +    var responder;
  1.4452 +    if (eventName.include(":")) {
  1.4453 +      responder = function(event) {
  1.4454 +        if (Object.isUndefined(event.eventName))
  1.4455 +          return false;
  1.4456 +
  1.4457 +        if (event.eventName !== eventName)
  1.4458 +          return false;
  1.4459 +
  1.4460 +        Event.extend(event, element);
  1.4461 +        handler.call(element, event);
  1.4462 +      };
  1.4463 +    } else {
  1.4464 +      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED &&
  1.4465 +       (eventName === "mouseenter" || eventName === "mouseleave")) {
  1.4466 +        if (eventName === "mouseenter" || eventName === "mouseleave") {
  1.4467 +          responder = function(event) {
  1.4468 +            Event.extend(event, element);
  1.4469 +
  1.4470 +            var parent = event.relatedTarget;
  1.4471 +            while (parent && parent !== element) {
  1.4472 +              try { parent = parent.parentNode; }
  1.4473 +              catch(e) { parent = element; }
  1.4474 +            }
  1.4475 +
  1.4476 +            if (parent === element) return;
  1.4477 +
  1.4478 +            handler.call(element, event);
  1.4479 +          };
  1.4480 +        }
  1.4481 +      } else {
  1.4482 +        responder = function(event) {
  1.4483 +          Event.extend(event, element);
  1.4484 +          handler.call(element, event);
  1.4485 +        };
  1.4486 +      }
  1.4487 +    }
  1.4488 +
  1.4489 +    responder.handler = handler;
  1.4490 +    respondersForEvent.push(responder);
  1.4491 +    return responder;
  1.4492 +  }
  1.4493 +
  1.4494 +  function _destroyCache() {
  1.4495 +    for (var i = 0, length = CACHE.length; i < length; i++) {
  1.4496 +      Event.stopObserving(CACHE[i]);
  1.4497 +      CACHE[i] = null;
  1.4498 +    }
  1.4499 +  }
  1.4500 +
  1.4501 +  var CACHE = [];
  1.4502 +
  1.4503 +  if (Prototype.Browser.IE)
  1.4504 +    window.attachEvent('onunload', _destroyCache);
  1.4505 +
  1.4506 +  if (Prototype.Browser.WebKit)
  1.4507 +    window.addEventListener('unload', Prototype.emptyFunction, false);
  1.4508 +
  1.4509 +
  1.4510 +  var _getDOMEventName = Prototype.K;
  1.4511 +
  1.4512 +  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {
  1.4513 +    _getDOMEventName = function(eventName) {
  1.4514 +      var translations = { mouseenter: "mouseover", mouseleave: "mouseout" };
  1.4515 +      return eventName in translations ? translations[eventName] : eventName;
  1.4516 +    };
  1.4517 +  }
  1.4518 +
  1.4519 +  function observe(element, eventName, handler) {
  1.4520 +    element = $(element);
  1.4521 +
  1.4522 +    var responder = _createResponder(element, eventName, handler);
  1.4523 +
  1.4524 +    if (!responder) return element;
  1.4525 +
  1.4526 +    if (eventName.include(':')) {
  1.4527 +      if (element.addEventListener)
  1.4528 +        element.addEventListener("dataavailable", responder, false);
  1.4529 +      else {
  1.4530 +        element.attachEvent("ondataavailable", responder);
  1.4531 +        element.attachEvent("onfilterchange", responder);
  1.4532 +      }
  1.4533 +    } else {
  1.4534 +      var actualEventName = _getDOMEventName(eventName);
  1.4535 +
  1.4536 +      if (element.addEventListener)
  1.4537 +        element.addEventListener(actualEventName, responder, false);
  1.4538 +      else
  1.4539 +        element.attachEvent("on" + actualEventName, responder);
  1.4540 +    }
  1.4541 +
  1.4542 +    return element;
  1.4543 +  }
  1.4544 +
  1.4545 +  function stopObserving(element, eventName, handler) {
  1.4546 +    element = $(element);
  1.4547 +
  1.4548 +    var registry = Element.retrieve(element, 'prototype_event_registry');
  1.4549 +
  1.4550 +    if (Object.isUndefined(registry)) return element;
  1.4551 +
  1.4552 +    if (eventName && !handler) {
  1.4553 +      var responders = registry.get(eventName);
  1.4554 +
  1.4555 +      if (Object.isUndefined(responders)) return element;
  1.4556 +
  1.4557 +      responders.each( function(r) {
  1.4558 +        Element.stopObserving(element, eventName, r.handler);
  1.4559 +      });
  1.4560 +      return element;
  1.4561 +    } else if (!eventName) {
  1.4562 +      registry.each( function(pair) {
  1.4563 +        var eventName = pair.key, responders = pair.value;
  1.4564 +
  1.4565 +        responders.each( function(r) {
  1.4566 +          Element.stopObserving(element, eventName, r.handler);
  1.4567 +        });
  1.4568 +      });
  1.4569 +      return element;
  1.4570 +    }
  1.4571 +
  1.4572 +    var responders = registry.get(eventName);
  1.4573 +
  1.4574 +    if (!responders) return;
  1.4575 +
  1.4576 +    var responder = responders.find( function(r) { return r.handler === handler; });
  1.4577 +    if (!responder) return element;
  1.4578 +
  1.4579 +    var actualEventName = _getDOMEventName(eventName);
  1.4580 +
  1.4581 +    if (eventName.include(':')) {
  1.4582 +      if (element.removeEventListener)
  1.4583 +        element.removeEventListener("dataavailable", responder, false);
  1.4584 +      else {
  1.4585 +        element.detachEvent("ondataavailable", responder);
  1.4586 +        element.detachEvent("onfilterchange",  responder);
  1.4587 +      }
  1.4588 +    } else {
  1.4589 +      if (element.removeEventListener)
  1.4590 +        element.removeEventListener(actualEventName, responder, false);
  1.4591 +      else
  1.4592 +        element.detachEvent('on' + actualEventName, responder);
  1.4593 +    }
  1.4594 +
  1.4595 +    registry.set(eventName, responders.without(responder));
  1.4596 +
  1.4597 +    return element;
  1.4598 +  }
  1.4599 +
  1.4600 +  function fire(element, eventName, memo, bubble) {
  1.4601 +    element = $(element);
  1.4602 +
  1.4603 +    if (Object.isUndefined(bubble))
  1.4604 +      bubble = true;
  1.4605 +
  1.4606 +    if (element == document && document.createEvent && !element.dispatchEvent)
  1.4607 +      element = document.documentElement;
  1.4608 +
  1.4609 +    var event;
  1.4610 +    if (document.createEvent) {
  1.4611 +      event = document.createEvent('HTMLEvents');
  1.4612 +      event.initEvent('dataavailable', true, true);
  1.4613 +    } else {
  1.4614 +      event = document.createEventObject();
  1.4615 +      event.eventType = bubble ? 'ondataavailable' : 'onfilterchange';
  1.4616 +    }
  1.4617 +
  1.4618 +    event.eventName = eventName;
  1.4619 +    event.memo = memo || { };
  1.4620 +
  1.4621 +    if (document.createEvent)
  1.4622 +      element.dispatchEvent(event);
  1.4623 +    else
  1.4624 +      element.fireEvent(event.eventType, event);
  1.4625 +
  1.4626 +    return Event.extend(event);
  1.4627 +  }
  1.4628 +
  1.4629 +
  1.4630 +  Object.extend(Event, Event.Methods);
  1.4631 +
  1.4632 +  Object.extend(Event, {
  1.4633 +    fire:          fire,
  1.4634 +    observe:       observe,
  1.4635 +    stopObserving: stopObserving
  1.4636 +  });
  1.4637 +
  1.4638 +  Element.addMethods({
  1.4639 +    fire:          fire,
  1.4640 +
  1.4641 +    observe:       observe,
  1.4642 +
  1.4643 +    stopObserving: stopObserving
  1.4644 +  });
  1.4645 +
  1.4646 +  Object.extend(document, {
  1.4647 +    fire:          fire.methodize(),
  1.4648 +
  1.4649 +    observe:       observe.methodize(),
  1.4650 +
  1.4651 +    stopObserving: stopObserving.methodize(),
  1.4652 +
  1.4653 +    loaded:        false
  1.4654 +  });
  1.4655 +
  1.4656 +  if (window.Event) Object.extend(window.Event, Event);
  1.4657 +  else window.Event = Event;
  1.4658 +})();
  1.4659 +
  1.4660 +(function() {
  1.4661 +  /* Support for the DOMContentLoaded event is based on work by Dan Webb,
  1.4662 +     Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */
  1.4663 +
  1.4664 +  var timer;
  1.4665 +
  1.4666 +  function fireContentLoadedEvent() {
  1.4667 +    if (document.loaded) return;
  1.4668 +    if (timer) window.clearTimeout(timer);
  1.4669 +    document.loaded = true;
  1.4670 +    document.fire('dom:loaded');
  1.4671 +  }
  1.4672 +
  1.4673 +  function checkReadyState() {
  1.4674 +    if (document.readyState === 'complete') {
  1.4675 +      document.stopObserving('readystatechange', checkReadyState);
  1.4676 +      fireContentLoadedEvent();
  1.4677 +    }
  1.4678 +  }
  1.4679 +
  1.4680 +  function pollDoScroll() {
  1.4681 +    try { document.documentElement.doScroll('left'); }
  1.4682 +    catch(e) {
  1.4683 +      timer = pollDoScroll.defer();
  1.4684 +      return;
  1.4685 +    }
  1.4686 +    fireContentLoadedEvent();
  1.4687 +  }
  1.4688 +
  1.4689 +  if (document.addEventListener) {
  1.4690 +    document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);
  1.4691 +  } else {
  1.4692 +    document.observe('readystatechange', checkReadyState);
  1.4693 +    if (window == top)
  1.4694 +      timer = pollDoScroll.defer();
  1.4695 +  }
  1.4696 +
  1.4697 +  Event.observe(window, 'load', fireContentLoadedEvent);
  1.4698 +})();
  1.4699 +
  1.4700 +Element.addMethods();
  1.4701 +
  1.4702 +/*------------------------------- DEPRECATED -------------------------------*/
  1.4703 +
  1.4704 +Hash.toQueryString = Object.toQueryString;
  1.4705 +
  1.4706 +var Toggle = { display: Element.toggle };
  1.4707 +
  1.4708 +Element.Methods.childOf = Element.Methods.descendantOf;
  1.4709 +
  1.4710 +var Insertion = {
  1.4711 +  Before: function(element, content) {
  1.4712 +    return Element.insert(element, {before:content});
  1.4713 +  },
  1.4714 +
  1.4715 +  Top: function(element, content) {
  1.4716 +    return Element.insert(element, {top:content});
  1.4717 +  },
  1.4718 +
  1.4719 +  Bottom: function(element, content) {
  1.4720 +    return Element.insert(element, {bottom:content});
  1.4721 +  },
  1.4722 +
  1.4723 +  After: function(element, content) {
  1.4724 +    return Element.insert(element, {after:content});
  1.4725 +  }
  1.4726 +};
  1.4727 +
  1.4728 +var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
  1.4729 +
  1.4730 +var Position = {
  1.4731 +  includeScrollOffsets: false,
  1.4732 +
  1.4733 +  prepare: function() {
  1.4734 +    this.deltaX =  window.pageXOffset
  1.4735 +                || document.documentElement.scrollLeft
  1.4736 +                || document.body.scrollLeft
  1.4737 +                || 0;
  1.4738 +    this.deltaY =  window.pageYOffset
  1.4739 +                || document.documentElement.scrollTop
  1.4740 +                || document.body.scrollTop
  1.4741 +                || 0;
  1.4742 +  },
  1.4743 +
  1.4744 +  within: function(element, x, y) {
  1.4745 +    if (this.includeScrollOffsets)
  1.4746 +      return this.withinIncludingScrolloffsets(element, x, y);
  1.4747 +    this.xcomp = x;
  1.4748 +    this.ycomp = y;
  1.4749 +    this.offset = Element.cumulativeOffset(element);
  1.4750 +
  1.4751 +    return (y >= this.offset[1] &&
  1.4752 +            y <  this.offset[1] + element.offsetHeight &&
  1.4753 +            x >= this.offset[0] &&
  1.4754 +            x <  this.offset[0] + element.offsetWidth);
  1.4755 +  },
  1.4756 +
  1.4757 +  withinIncludingScrolloffsets: function(element, x, y) {
  1.4758 +    var offsetcache = Element.cumulativeScrollOffset(element);
  1.4759 +
  1.4760 +    this.xcomp = x + offsetcache[0] - this.deltaX;
  1.4761 +    this.ycomp = y + offsetcache[1] - this.deltaY;
  1.4762 +    this.offset = Element.cumulativeOffset(element);
  1.4763 +
  1.4764 +    return (this.ycomp >= this.offset[1] &&
  1.4765 +            this.ycomp <  this.offset[1] + element.offsetHeight &&
  1.4766 +            this.xcomp >= this.offset[0] &&
  1.4767 +            this.xcomp <  this.offset[0] + element.offsetWidth);
  1.4768 +  },
  1.4769 +
  1.4770 +  overlap: function(mode, element) {
  1.4771 +    if (!mode) return 0;
  1.4772 +    if (mode == 'vertical')
  1.4773 +      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
  1.4774 +        element.offsetHeight;
  1.4775 +    if (mode == 'horizontal')
  1.4776 +      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
  1.4777 +        element.offsetWidth;
  1.4778 +  },
  1.4779 +
  1.4780 +
  1.4781 +  cumulativeOffset: Element.Methods.cumulativeOffset,
  1.4782 +
  1.4783 +  positionedOffset: Element.Methods.positionedOffset,
  1.4784 +
  1.4785 +  absolutize: function(element) {
  1.4786 +    Position.prepare();
  1.4787 +    return Element.absolutize(element);
  1.4788 +  },
  1.4789 +
  1.4790 +  relativize: function(element) {
  1.4791 +    Position.prepare();
  1.4792 +    return Element.relativize(element);
  1.4793 +  },
  1.4794 +
  1.4795 +  realOffset: Element.Methods.cumulativeScrollOffset,
  1.4796 +
  1.4797 +  offsetParent: Element.Methods.getOffsetParent,
  1.4798 +
  1.4799 +  page: Element.Methods.viewportOffset,
  1.4800 +
  1.4801 +  clone: function(source, target, options) {
  1.4802 +    options = options || { };
  1.4803 +    return Element.clonePosition(target, source, options);
  1.4804 +  }
  1.4805 +};
  1.4806 +
  1.4807 +/*--------------------------------------------------------------------------*/
  1.4808 +
  1.4809 +if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
  1.4810 +  function iter(name) {
  1.4811 +    return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
  1.4812 +  }
  1.4813 +
  1.4814 +  instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
  1.4815 +  function(element, className) {
  1.4816 +    className = className.toString().strip();
  1.4817 +    var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
  1.4818 +    return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
  1.4819 +  } : function(element, className) {
  1.4820 +    className = className.toString().strip();
  1.4821 +    var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
  1.4822 +    if (!classNames && !className) return elements;
  1.4823 +
  1.4824 +    var nodes = $(element).getElementsByTagName('*');
  1.4825 +    className = ' ' + className + ' ';
  1.4826 +
  1.4827 +    for (var i = 0, child, cn; child = nodes[i]; i++) {
  1.4828 +      if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
  1.4829 +          (classNames && classNames.all(function(name) {
  1.4830 +            return !name.toString().blank() && cn.include(' ' + name + ' ');
  1.4831 +          }))))
  1.4832 +        elements.push(Element.extend(child));
  1.4833 +    }
  1.4834 +    return elements;
  1.4835 +  };
  1.4836 +
  1.4837 +  return function(className, parentElement) {
  1.4838 +    return $(parentElement || document.body).getElementsByClassName(className);
  1.4839 +  };
  1.4840 +}(Element.Methods);
  1.4841 +
  1.4842 +/*--------------------------------------------------------------------------*/
  1.4843 +
  1.4844 +Element.ClassNames = Class.create();
  1.4845 +Element.ClassNames.prototype = {
  1.4846 +  initialize: function(element) {
  1.4847 +    this.element = $(element);
  1.4848 +  },
  1.4849 +
  1.4850 +  _each: function(iterator) {
  1.4851 +    this.element.className.split(/\s+/).select(function(name) {
  1.4852 +      return name.length > 0;
  1.4853 +    })._each(iterator);
  1.4854 +  },
  1.4855 +
  1.4856 +  set: function(className) {
  1.4857 +    this.element.className = className;
  1.4858 +  },
  1.4859 +
  1.4860 +  add: function(classNameToAdd) {
  1.4861 +    if (this.include(classNameToAdd)) return;
  1.4862 +    this.set($A(this).concat(classNameToAdd).join(' '));
  1.4863 +  },
  1.4864 +
  1.4865 +  remove: function(classNameToRemove) {
  1.4866 +    if (!this.include(classNameToRemove)) return;
  1.4867 +    this.set($A(this).without(classNameToRemove).join(' '));
  1.4868 +  },
  1.4869 +
  1.4870 +  toString: function() {
  1.4871 +    return $A(this).join(' ');
  1.4872 +  }
  1.4873 +};
  1.4874 +
  1.4875 +Object.extend(Element.ClassNames.prototype, Enumerable);
  1.4876 +
  1.4877 +/*--------------------------------------------------------------------------*/