diff onlypaths/js/prototype.js @ 46:26c2b3ad21c7 laserkard

[svn r47] saving progresswww.cinemassacre.com/new/?page_id=30
author rlm
date Sun, 31 Jan 2010 12:33:33 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/onlypaths/js/prototype.js	Sun Jan 31 12:33:33 2010 -0500
     1.3 @@ -0,0 +1,1785 @@
     1.4 +/*  Prototype JavaScript framework, version 1.4.0
     1.5 + *  (c) 2005 Sam Stephenson <sam@conio.net>
     1.6 + *
     1.7 + *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
     1.8 + *  against the source tree, available from the Prototype darcs repository.
     1.9 + *
    1.10 + *  Prototype is freely distributable under the terms of an MIT-style license.
    1.11 + *
    1.12 + *  For details, see the Prototype web site: http://prototype.conio.net/
    1.13 + *
    1.14 +/*--------------------------------------------------------------------------*/
    1.15 +
    1.16 +var Prototype = {
    1.17 +  Version: '1.4.0',
    1.18 +  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
    1.19 +
    1.20 +  emptyFunction: function() {},
    1.21 +  K: function(x) {return x}
    1.22 +}
    1.23 +
    1.24 +var Class = {
    1.25 +  create: function() {
    1.26 +    return function() {
    1.27 +      this.initialize.apply(this, arguments);
    1.28 +    }
    1.29 +  }
    1.30 +}
    1.31 +
    1.32 +var Abstract = new Object();
    1.33 +
    1.34 +Object.extend = function(destination, source) {
    1.35 +  for (property in source) {
    1.36 +    destination[property] = source[property];
    1.37 +  }
    1.38 +  return destination;
    1.39 +}
    1.40 +
    1.41 +Object.inspect = function(object) {
    1.42 +  try {
    1.43 +    if (object == undefined) return 'undefined';
    1.44 +    if (object == null) return 'null';
    1.45 +    return object.inspect ? object.inspect() : object.toString();
    1.46 +  } catch (e) {
    1.47 +    if (e instanceof RangeError) return '...';
    1.48 +    throw e;
    1.49 +  }
    1.50 +}
    1.51 +
    1.52 +Function.prototype.bind = function() {
    1.53 +  var __method = this, args = $A(arguments), object = args.shift();
    1.54 +  return function() {
    1.55 +    return __method.apply(object, args.concat($A(arguments)));
    1.56 +  }
    1.57 +}
    1.58 +
    1.59 +Function.prototype.bindAsEventListener = function(object) {
    1.60 +  var __method = this;
    1.61 +  return function(event) {
    1.62 +    return __method.call(object, event || window.event);
    1.63 +  }
    1.64 +}
    1.65 +
    1.66 +Object.extend(Number.prototype, {
    1.67 +  toColorPart: function() {
    1.68 +    var digits = this.toString(16);
    1.69 +    if (this < 16) return '0' + digits;
    1.70 +    return digits;
    1.71 +  },
    1.72 +
    1.73 +  succ: function() {
    1.74 +    return this + 1;
    1.75 +  },
    1.76 +
    1.77 +  times: function(iterator) {
    1.78 +    $R(0, this, true).each(iterator);
    1.79 +    return this;
    1.80 +  }
    1.81 +});
    1.82 +
    1.83 +var Try = {
    1.84 +  these: function() {
    1.85 +    var returnValue;
    1.86 +
    1.87 +    for (var i = 0; i < arguments.length; i++) {
    1.88 +      var lambda = arguments[i];
    1.89 +      try {
    1.90 +        returnValue = lambda();
    1.91 +        break;
    1.92 +      } catch (e) {}
    1.93 +    }
    1.94 +
    1.95 +    return returnValue;
    1.96 +  }
    1.97 +}
    1.98 +
    1.99 +/*--------------------------------------------------------------------------*/
   1.100 +
   1.101 +var PeriodicalExecuter = Class.create();
   1.102 +PeriodicalExecuter.prototype = {
   1.103 +  initialize: function(callback, frequency) {
   1.104 +    this.callback = callback;
   1.105 +    this.frequency = frequency;
   1.106 +    this.currentlyExecuting = false;
   1.107 +
   1.108 +    this.registerCallback();
   1.109 +  },
   1.110 +
   1.111 +  registerCallback: function() {
   1.112 +    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
   1.113 +  },
   1.114 +
   1.115 +  onTimerEvent: function() {
   1.116 +    if (!this.currentlyExecuting) {
   1.117 +      try {
   1.118 +        this.currentlyExecuting = true;
   1.119 +        this.callback();
   1.120 +      } finally {
   1.121 +        this.currentlyExecuting = false;
   1.122 +      }
   1.123 +    }
   1.124 +  }
   1.125 +}
   1.126 +
   1.127 +/*--------------------------------------------------------------------------*/
   1.128 +
   1.129 +function $() {
   1.130 +  var elements = new Array();
   1.131 +
   1.132 +  for (var i = 0; i < arguments.length; i++) {
   1.133 +    var element = arguments[i];
   1.134 +    if (typeof element == 'string')
   1.135 +      element = document.getElementById(element);
   1.136 +
   1.137 +    if (arguments.length == 1)
   1.138 +      return element;
   1.139 +
   1.140 +    elements.push(element);
   1.141 +  }
   1.142 +
   1.143 +  return elements;
   1.144 +}
   1.145 +Object.extend(String.prototype, {
   1.146 +  stripTags: function() {
   1.147 +    return this.replace(/<\/?[^>]+>/gi, '');
   1.148 +  },
   1.149 +
   1.150 +  stripScripts: function() {
   1.151 +    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
   1.152 +  },
   1.153 +
   1.154 +  extractScripts: function() {
   1.155 +    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
   1.156 +    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
   1.157 +    return (this.match(matchAll) || []).map(function(scriptTag) {
   1.158 +      return (scriptTag.match(matchOne) || ['', ''])[1];
   1.159 +    });
   1.160 +  },
   1.161 +
   1.162 +  evalScripts: function() {
   1.163 +    return this.extractScripts().map(eval);
   1.164 +  },
   1.165 +
   1.166 +  escapeHTML: function() {
   1.167 +    var div = document.createElement('div');
   1.168 +    var text = document.createTextNode(this);
   1.169 +    div.appendChild(text);
   1.170 +    return div.innerHTML;
   1.171 +  },
   1.172 +
   1.173 +  unescapeHTML: function() {
   1.174 +    var div = document.createElement('div');
   1.175 +    div.innerHTML = this.stripTags();
   1.176 +    return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
   1.177 +  },
   1.178 +
   1.179 +  toQueryParams: function() {
   1.180 +    var pairs = this.match(/^\??(.*)$/)[1].split('&');
   1.181 +    return pairs.inject({}, function(params, pairString) {
   1.182 +      var pair = pairString.split('=');
   1.183 +      params[pair[0]] = pair[1];
   1.184 +      return params;
   1.185 +    });
   1.186 +  },
   1.187 +
   1.188 +  toArray: function() {
   1.189 +    return this.split('');
   1.190 +  },
   1.191 +
   1.192 +  camelize: function() {
   1.193 +    var oStringList = this.split('-');
   1.194 +    if (oStringList.length == 1) return oStringList[0];
   1.195 +
   1.196 +    var camelizedString = this.indexOf('-') == 0
   1.197 +      ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
   1.198 +      : oStringList[0];
   1.199 +
   1.200 +    for (var i = 1, len = oStringList.length; i < len; i++) {
   1.201 +      var s = oStringList[i];
   1.202 +      camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
   1.203 +    }
   1.204 +
   1.205 +    return camelizedString;
   1.206 +  },
   1.207 +
   1.208 +  inspect: function() {
   1.209 +    return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
   1.210 +  }
   1.211 +});
   1.212 +
   1.213 +String.prototype.parseQuery = String.prototype.toQueryParams;
   1.214 +
   1.215 +var $break    = new Object();
   1.216 +var $continue = new Object();
   1.217 +
   1.218 +var Enumerable = {
   1.219 +  each: function(iterator) {
   1.220 +    var index = 0;
   1.221 +    try {
   1.222 +      this._each(function(value) {
   1.223 +        try {
   1.224 +          iterator(value, index++);
   1.225 +        } catch (e) {
   1.226 +          if (e != $continue) throw e;
   1.227 +        }
   1.228 +      });
   1.229 +    } catch (e) {
   1.230 +      if (e != $break) throw e;
   1.231 +    }
   1.232 +  },
   1.233 +
   1.234 +  all: function(iterator) {
   1.235 +    var result = true;
   1.236 +    this.each(function(value, index) {
   1.237 +      result = result && !!(iterator || Prototype.K)(value, index);
   1.238 +      if (!result) throw $break;
   1.239 +    });
   1.240 +    return result;
   1.241 +  },
   1.242 +
   1.243 +  any: function(iterator) {
   1.244 +    var result = true;
   1.245 +    this.each(function(value, index) {
   1.246 +      if (result = !!(iterator || Prototype.K)(value, index))
   1.247 +        throw $break;
   1.248 +    });
   1.249 +    return result;
   1.250 +  },
   1.251 +
   1.252 +  collect: function(iterator) {
   1.253 +    var results = [];
   1.254 +    this.each(function(value, index) {
   1.255 +      results.push(iterator(value, index));
   1.256 +    });
   1.257 +    return results;
   1.258 +  },
   1.259 +
   1.260 +  detect: function (iterator) {
   1.261 +    var result;
   1.262 +    this.each(function(value, index) {
   1.263 +      if (iterator(value, index)) {
   1.264 +        result = value;
   1.265 +        throw $break;
   1.266 +      }
   1.267 +    });
   1.268 +    return result;
   1.269 +  },
   1.270 +
   1.271 +  findAll: function(iterator) {
   1.272 +    var results = [];
   1.273 +    this.each(function(value, index) {
   1.274 +      if (iterator(value, index))
   1.275 +        results.push(value);
   1.276 +    });
   1.277 +    return results;
   1.278 +  },
   1.279 +
   1.280 +  grep: function(pattern, iterator) {
   1.281 +    var results = [];
   1.282 +    this.each(function(value, index) {
   1.283 +      var stringValue = value.toString();
   1.284 +      if (stringValue.match(pattern))
   1.285 +        results.push((iterator || Prototype.K)(value, index));
   1.286 +    })
   1.287 +    return results;
   1.288 +  },
   1.289 +
   1.290 +  include: function(object) {
   1.291 +    var found = false;
   1.292 +    this.each(function(value) {
   1.293 +      if (value == object) {
   1.294 +        found = true;
   1.295 +        throw $break;
   1.296 +      }
   1.297 +    });
   1.298 +    return found;
   1.299 +  },
   1.300 +
   1.301 +  inject: function(memo, iterator) {
   1.302 +    this.each(function(value, index) {
   1.303 +      memo = iterator(memo, value, index);
   1.304 +    });
   1.305 +    return memo;
   1.306 +  },
   1.307 +
   1.308 +  invoke: function(method) {
   1.309 +    var args = $A(arguments).slice(1);
   1.310 +    return this.collect(function(value) {
   1.311 +      return value[method].apply(value, args);
   1.312 +    });
   1.313 +  },
   1.314 +
   1.315 +  max: function(iterator) {
   1.316 +    var result;
   1.317 +    this.each(function(value, index) {
   1.318 +      value = (iterator || Prototype.K)(value, index);
   1.319 +      if (value >= (result || value))
   1.320 +        result = value;
   1.321 +    });
   1.322 +    return result;
   1.323 +  },
   1.324 +
   1.325 +  min: function(iterator) {
   1.326 +    var result;
   1.327 +    this.each(function(value, index) {
   1.328 +      value = (iterator || Prototype.K)(value, index);
   1.329 +      if (value <= (result || value))
   1.330 +        result = value;
   1.331 +    });
   1.332 +    return result;
   1.333 +  },
   1.334 +
   1.335 +  partition: function(iterator) {
   1.336 +    var trues = [], falses = [];
   1.337 +    this.each(function(value, index) {
   1.338 +      ((iterator || Prototype.K)(value, index) ?
   1.339 +        trues : falses).push(value);
   1.340 +    });
   1.341 +    return [trues, falses];
   1.342 +  },
   1.343 +
   1.344 +  pluck: function(property) {
   1.345 +    var results = [];
   1.346 +    this.each(function(value, index) {
   1.347 +      results.push(value[property]);
   1.348 +    });
   1.349 +    return results;
   1.350 +  },
   1.351 +
   1.352 +  reject: function(iterator) {
   1.353 +    var results = [];
   1.354 +    this.each(function(value, index) {
   1.355 +      if (!iterator(value, index))
   1.356 +        results.push(value);
   1.357 +    });
   1.358 +    return results;
   1.359 +  },
   1.360 +
   1.361 +  sortBy: function(iterator) {
   1.362 +    return this.collect(function(value, index) {
   1.363 +      return {value: value, criteria: iterator(value, index)};
   1.364 +    }).sort(function(left, right) {
   1.365 +      var a = left.criteria, b = right.criteria;
   1.366 +      return a < b ? -1 : a > b ? 1 : 0;
   1.367 +    }).pluck('value');
   1.368 +  },
   1.369 +
   1.370 +  toArray: function() {
   1.371 +    return this.collect(Prototype.K);
   1.372 +  },
   1.373 +
   1.374 +  zip: function() {
   1.375 +    var iterator = Prototype.K, args = $A(arguments);
   1.376 +    if (typeof args.last() == 'function')
   1.377 +      iterator = args.pop();
   1.378 +
   1.379 +    var collections = [this].concat(args).map($A);
   1.380 +    return this.map(function(value, index) {
   1.381 +      iterator(value = collections.pluck(index));
   1.382 +      return value;
   1.383 +    });
   1.384 +  },
   1.385 +
   1.386 +  inspect: function() {
   1.387 +    return '#<Enumerable:' + this.toArray().inspect() + '>';
   1.388 +  }
   1.389 +}
   1.390 +
   1.391 +Object.extend(Enumerable, {
   1.392 +  map:     Enumerable.collect,
   1.393 +  find:    Enumerable.detect,
   1.394 +  select:  Enumerable.findAll,
   1.395 +  member:  Enumerable.include,
   1.396 +  entries: Enumerable.toArray
   1.397 +});
   1.398 +var $A = Array.from = function(iterable) {
   1.399 +  if (!iterable) return [];
   1.400 +  if (iterable.toArray) {
   1.401 +    return iterable.toArray();
   1.402 +  } else {
   1.403 +    var results = [];
   1.404 +    for (var i = 0; i < iterable.length; i++)
   1.405 +      results.push(iterable[i]);
   1.406 +    return results;
   1.407 +  }
   1.408 +}
   1.409 +
   1.410 +Object.extend(Array.prototype, Enumerable);
   1.411 +
   1.412 +Array.prototype._reverse = Array.prototype.reverse;
   1.413 +
   1.414 +Object.extend(Array.prototype, {
   1.415 +  _each: function(iterator) {
   1.416 +    for (var i = 0; i < this.length; i++)
   1.417 +      iterator(this[i]);
   1.418 +  },
   1.419 +
   1.420 +  clear: function() {
   1.421 +    this.length = 0;
   1.422 +    return this;
   1.423 +  },
   1.424 +
   1.425 +  first: function() {
   1.426 +    return this[0];
   1.427 +  },
   1.428 +
   1.429 +  last: function() {
   1.430 +    return this[this.length - 1];
   1.431 +  },
   1.432 +
   1.433 +  compact: function() {
   1.434 +    return this.select(function(value) {
   1.435 +      return value != undefined || value != null;
   1.436 +    });
   1.437 +  },
   1.438 +
   1.439 +  flatten: function() {
   1.440 +    return this.inject([], function(array, value) {
   1.441 +      return array.concat(value.constructor == Array ?
   1.442 +        value.flatten() : [value]);
   1.443 +    });
   1.444 +  },
   1.445 +
   1.446 +  without: function() {
   1.447 +    var values = $A(arguments);
   1.448 +    return this.select(function(value) {
   1.449 +      return !values.include(value);
   1.450 +    });
   1.451 +  },
   1.452 +
   1.453 +  indexOf: function(object) {
   1.454 +    for (var i = 0; i < this.length; i++)
   1.455 +      if (this[i] == object) return i;
   1.456 +    return -1;
   1.457 +  },
   1.458 +
   1.459 +  reverse: function(inline) {
   1.460 +    return (inline !== false ? this : this.toArray())._reverse();
   1.461 +  },
   1.462 +
   1.463 +  shift: function() {
   1.464 +    var result = this[0];
   1.465 +    for (var i = 0; i < this.length - 1; i++)
   1.466 +      this[i] = this[i + 1];
   1.467 +    this.length--;
   1.468 +    return result;
   1.469 +  },
   1.470 +
   1.471 +  inspect: function() {
   1.472 +    return '[' + this.map(Object.inspect).join(', ') + ']';
   1.473 +  }
   1.474 +});
   1.475 +var Hash = {
   1.476 +  _each: function(iterator) {
   1.477 +    for (key in this) {
   1.478 +      var value = this[key];
   1.479 +      if (typeof value == 'function') continue;
   1.480 +
   1.481 +      var pair = [key, value];
   1.482 +      pair.key = key;
   1.483 +      pair.value = value;
   1.484 +      iterator(pair);
   1.485 +    }
   1.486 +  },
   1.487 +
   1.488 +  keys: function() {
   1.489 +    return this.pluck('key');
   1.490 +  },
   1.491 +
   1.492 +  values: function() {
   1.493 +    return this.pluck('value');
   1.494 +  },
   1.495 +
   1.496 +  merge: function(hash) {
   1.497 +    return $H(hash).inject($H(this), function(mergedHash, pair) {
   1.498 +      mergedHash[pair.key] = pair.value;
   1.499 +      return mergedHash;
   1.500 +    });
   1.501 +  },
   1.502 +
   1.503 +  toQueryString: function() {
   1.504 +    return this.map(function(pair) {
   1.505 +      return pair.map(encodeURIComponent).join('=');
   1.506 +    }).join('&');
   1.507 +  },
   1.508 +
   1.509 +  inspect: function() {
   1.510 +    return '#<Hash:{' + this.map(function(pair) {
   1.511 +      return pair.map(Object.inspect).join(': ');
   1.512 +    }).join(', ') + '}>';
   1.513 +  }
   1.514 +}
   1.515 +
   1.516 +function $H(object) {
   1.517 +  var hash = Object.extend({}, object || {});
   1.518 +  Object.extend(hash, Enumerable);
   1.519 +  Object.extend(hash, Hash);
   1.520 +  return hash;
   1.521 +}
   1.522 +ObjectRange = Class.create();
   1.523 +Object.extend(ObjectRange.prototype, Enumerable);
   1.524 +Object.extend(ObjectRange.prototype, {
   1.525 +  initialize: function(start, end, exclusive) {
   1.526 +    this.start = start;
   1.527 +    this.end = end;
   1.528 +    this.exclusive = exclusive;
   1.529 +  },
   1.530 +
   1.531 +  _each: function(iterator) {
   1.532 +    var value = this.start;
   1.533 +    do {
   1.534 +      iterator(value);
   1.535 +      value = value.succ();
   1.536 +    } while (this.include(value));
   1.537 +  },
   1.538 +
   1.539 +  include: function(value) {
   1.540 +    if (value < this.start)
   1.541 +      return false;
   1.542 +    if (this.exclusive)
   1.543 +      return value < this.end;
   1.544 +    return value <= this.end;
   1.545 +  }
   1.546 +});
   1.547 +
   1.548 +var $R = function(start, end, exclusive) {
   1.549 +  return new ObjectRange(start, end, exclusive);
   1.550 +}
   1.551 +
   1.552 +var Ajax = {
   1.553 +  getTransport: function() {
   1.554 +    return Try.these(
   1.555 +      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
   1.556 +      function() {return new ActiveXObject('Microsoft.XMLHTTP')},
   1.557 +      function() {return new XMLHttpRequest()}
   1.558 +    ) || false;
   1.559 +  },
   1.560 +
   1.561 +  activeRequestCount: 0
   1.562 +}
   1.563 +
   1.564 +Ajax.Responders = {
   1.565 +  responders: [],
   1.566 +
   1.567 +  _each: function(iterator) {
   1.568 +    this.responders._each(iterator);
   1.569 +  },
   1.570 +
   1.571 +  register: function(responderToAdd) {
   1.572 +    if (!this.include(responderToAdd))
   1.573 +      this.responders.push(responderToAdd);
   1.574 +  },
   1.575 +
   1.576 +  unregister: function(responderToRemove) {
   1.577 +    this.responders = this.responders.without(responderToRemove);
   1.578 +  },
   1.579 +
   1.580 +  dispatch: function(callback, request, transport, json) {
   1.581 +    this.each(function(responder) {
   1.582 +      if (responder[callback] && typeof responder[callback] == 'function') {
   1.583 +        try {
   1.584 +          responder[callback].apply(responder, [request, transport, json]);
   1.585 +        } catch (e) {}
   1.586 +      }
   1.587 +    });
   1.588 +  }
   1.589 +};
   1.590 +
   1.591 +Object.extend(Ajax.Responders, Enumerable);
   1.592 +
   1.593 +Ajax.Responders.register({
   1.594 +  onCreate: function() {
   1.595 +    Ajax.activeRequestCount++;
   1.596 +  },
   1.597 +
   1.598 +  onComplete: function() {
   1.599 +    Ajax.activeRequestCount--;
   1.600 +  }
   1.601 +});
   1.602 +
   1.603 +Ajax.Base = function() {};
   1.604 +Ajax.Base.prototype = {
   1.605 +  setOptions: function(options) {
   1.606 +    this.options = {
   1.607 +      method:       'post',
   1.608 +      asynchronous: true,
   1.609 +      parameters:   ''
   1.610 +    }
   1.611 +    Object.extend(this.options, options || {});
   1.612 +  },
   1.613 +
   1.614 +  responseIsSuccess: function() {
   1.615 +    return this.transport.status == undefined
   1.616 +        || this.transport.status == 0
   1.617 +        || (this.transport.status >= 200 && this.transport.status < 300);
   1.618 +  },
   1.619 +
   1.620 +  responseIsFailure: function() {
   1.621 +    return !this.responseIsSuccess();
   1.622 +  }
   1.623 +}
   1.624 +
   1.625 +Ajax.Request = Class.create();
   1.626 +Ajax.Request.Events =
   1.627 +  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
   1.628 +
   1.629 +Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
   1.630 +  initialize: function(url, options) {
   1.631 +    this.transport = Ajax.getTransport();
   1.632 +    this.setOptions(options);
   1.633 +    this.request(url);
   1.634 +  },
   1.635 +
   1.636 +  request: function(url) {
   1.637 +    var parameters = this.options.parameters || '';
   1.638 +    if (parameters.length > 0) parameters += '&_=';
   1.639 +
   1.640 +    try {
   1.641 +      this.url = url;
   1.642 +      if (this.options.method == 'get' && parameters.length > 0)
   1.643 +        this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
   1.644 +
   1.645 +      Ajax.Responders.dispatch('onCreate', this, this.transport);
   1.646 +
   1.647 +      this.transport.open(this.options.method, this.url,
   1.648 +        this.options.asynchronous);
   1.649 +
   1.650 +      if (this.options.asynchronous) {
   1.651 +        this.transport.onreadystatechange = this.onStateChange.bind(this);
   1.652 +        setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
   1.653 +      }
   1.654 +
   1.655 +      this.setRequestHeaders();
   1.656 +
   1.657 +      var body = this.options.postBody ? this.options.postBody : parameters;
   1.658 +      this.transport.send(this.options.method == 'post' ? body : null);
   1.659 +
   1.660 +    } catch (e) {
   1.661 +      this.dispatchException(e);
   1.662 +    }
   1.663 +  },
   1.664 +
   1.665 +  setRequestHeaders: function() {
   1.666 +    var requestHeaders =
   1.667 +      ['X-Requested-With', 'XMLHttpRequest',
   1.668 +       'X-Prototype-Version', Prototype.Version];
   1.669 +
   1.670 +    if (this.options.method == 'post') {
   1.671 +      requestHeaders.push('Content-type',
   1.672 +        'application/x-www-form-urlencoded');
   1.673 +
   1.674 +      /* Force "Connection: close" for Mozilla browsers to work around
   1.675 +       * a bug where XMLHttpReqeuest sends an incorrect Content-length
   1.676 +       * header. See Mozilla Bugzilla #246651.
   1.677 +       */
   1.678 +      if (this.transport.overrideMimeType)
   1.679 +        requestHeaders.push('Connection', 'close');
   1.680 +    }
   1.681 +
   1.682 +    if (this.options.requestHeaders)
   1.683 +      requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
   1.684 +
   1.685 +    for (var i = 0; i < requestHeaders.length; i += 2)
   1.686 +      this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
   1.687 +  },
   1.688 +
   1.689 +  onStateChange: function() {
   1.690 +    var readyState = this.transport.readyState;
   1.691 +    if (readyState != 1)
   1.692 +      this.respondToReadyState(this.transport.readyState);
   1.693 +  },
   1.694 +
   1.695 +  header: function(name) {
   1.696 +    try {
   1.697 +      return this.transport.getResponseHeader(name);
   1.698 +    } catch (e) {}
   1.699 +  },
   1.700 +
   1.701 +  evalJSON: function() {
   1.702 +    try {
   1.703 +      return eval(this.header('X-JSON'));
   1.704 +    } catch (e) {}
   1.705 +  },
   1.706 +
   1.707 +  evalResponse: function() {
   1.708 +    try {
   1.709 +      return eval(this.transport.responseText);
   1.710 +    } catch (e) {
   1.711 +      this.dispatchException(e);
   1.712 +    }
   1.713 +  },
   1.714 +
   1.715 +  respondToReadyState: function(readyState) {
   1.716 +    var event = Ajax.Request.Events[readyState];
   1.717 +    var transport = this.transport, json = this.evalJSON();
   1.718 +
   1.719 +    if (event == 'Complete') {
   1.720 +      try {
   1.721 +        (this.options['on' + this.transport.status]
   1.722 +         || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
   1.723 +         || Prototype.emptyFunction)(transport, json);
   1.724 +      } catch (e) {
   1.725 +        this.dispatchException(e);
   1.726 +      }
   1.727 +
   1.728 +      if ((this.header('Content-type') || '').match(/^text\/javascript/i))
   1.729 +        this.evalResponse();
   1.730 +    }
   1.731 +
   1.732 +    try {
   1.733 +      (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
   1.734 +      Ajax.Responders.dispatch('on' + event, this, transport, json);
   1.735 +    } catch (e) {
   1.736 +      this.dispatchException(e);
   1.737 +    }
   1.738 +
   1.739 +    /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
   1.740 +    if (event == 'Complete')
   1.741 +      this.transport.onreadystatechange = Prototype.emptyFunction;
   1.742 +  },
   1.743 +
   1.744 +  dispatchException: function(exception) {
   1.745 +    (this.options.onException || Prototype.emptyFunction)(this, exception);
   1.746 +    Ajax.Responders.dispatch('onException', this, exception);
   1.747 +  }
   1.748 +});
   1.749 +
   1.750 +Ajax.Updater = Class.create();
   1.751 +
   1.752 +Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
   1.753 +  initialize: function(container, url, options) {
   1.754 +    this.containers = {
   1.755 +      success: container.success ? $(container.success) : $(container),
   1.756 +      failure: container.failure ? $(container.failure) :
   1.757 +        (container.success ? null : $(container))
   1.758 +    }
   1.759 +
   1.760 +    this.transport = Ajax.getTransport();
   1.761 +    this.setOptions(options);
   1.762 +
   1.763 +    var onComplete = this.options.onComplete || Prototype.emptyFunction;
   1.764 +    this.options.onComplete = (function(transport, object) {
   1.765 +      this.updateContent();
   1.766 +      onComplete(transport, object);
   1.767 +    }).bind(this);
   1.768 +
   1.769 +    this.request(url);
   1.770 +  },
   1.771 +
   1.772 +  updateContent: function() {
   1.773 +    var receiver = this.responseIsSuccess() ?
   1.774 +      this.containers.success : this.containers.failure;
   1.775 +    var response = this.transport.responseText;
   1.776 +
   1.777 +    if (!this.options.evalScripts)
   1.778 +      response = response.stripScripts();
   1.779 +
   1.780 +    if (receiver) {
   1.781 +      if (this.options.insertion) {
   1.782 +        new this.options.insertion(receiver, response);
   1.783 +      } else {
   1.784 +        Element.update(receiver, response);
   1.785 +      }
   1.786 +    }
   1.787 +
   1.788 +    if (this.responseIsSuccess()) {
   1.789 +      if (this.onComplete)
   1.790 +        setTimeout(this.onComplete.bind(this), 10);
   1.791 +    }
   1.792 +  }
   1.793 +});
   1.794 +
   1.795 +Ajax.PeriodicalUpdater = Class.create();
   1.796 +Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
   1.797 +  initialize: function(container, url, options) {
   1.798 +    this.setOptions(options);
   1.799 +    this.onComplete = this.options.onComplete;
   1.800 +
   1.801 +    this.frequency = (this.options.frequency || 2);
   1.802 +    this.decay = (this.options.decay || 1);
   1.803 +
   1.804 +    this.updater = {};
   1.805 +    this.container = container;
   1.806 +    this.url = url;
   1.807 +
   1.808 +    this.start();
   1.809 +  },
   1.810 +
   1.811 +  start: function() {
   1.812 +    this.options.onComplete = this.updateComplete.bind(this);
   1.813 +    this.onTimerEvent();
   1.814 +  },
   1.815 +
   1.816 +  stop: function() {
   1.817 +    this.updater.onComplete = undefined;
   1.818 +    clearTimeout(this.timer);
   1.819 +    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
   1.820 +  },
   1.821 +
   1.822 +  updateComplete: function(request) {
   1.823 +    if (this.options.decay) {
   1.824 +      this.decay = (request.responseText == this.lastText ?
   1.825 +        this.decay * this.options.decay : 1);
   1.826 +
   1.827 +      this.lastText = request.responseText;
   1.828 +    }
   1.829 +    this.timer = setTimeout(this.onTimerEvent.bind(this),
   1.830 +      this.decay * this.frequency * 1000);
   1.831 +  },
   1.832 +
   1.833 +  onTimerEvent: function() {
   1.834 +    this.updater = new Ajax.Updater(this.container, this.url, this.options);
   1.835 +  }
   1.836 +});
   1.837 +document.getElementsByClassName = function(className, parentElement) {
   1.838 +  var children = ($(parentElement) || document.body).getElementsByTagName('*');
   1.839 +  return $A(children).inject([], function(elements, child) {
   1.840 +    if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
   1.841 +      elements.push(child);
   1.842 +    return elements;
   1.843 +  });
   1.844 +}
   1.845 +
   1.846 +/*--------------------------------------------------------------------------*/
   1.847 +
   1.848 +if (!window.Element) {
   1.849 +  var Element = new Object();
   1.850 +}
   1.851 +
   1.852 +Object.extend(Element, {
   1.853 +  visible: function(element) {
   1.854 +    return $(element).style.display != 'none';
   1.855 +  },
   1.856 +
   1.857 +  toggle: function() {
   1.858 +    for (var i = 0; i < arguments.length; i++) {
   1.859 +      var element = $(arguments[i]);
   1.860 +      Element[Element.visible(element) ? 'hide' : 'show'](element);
   1.861 +    }
   1.862 +  },
   1.863 +
   1.864 +  hide: function() {
   1.865 +    for (var i = 0; i < arguments.length; i++) {
   1.866 +      var element = $(arguments[i]);
   1.867 +      element.style.display = 'none';
   1.868 +    }
   1.869 +  },
   1.870 +
   1.871 +  show: function() {
   1.872 +    for (var i = 0; i < arguments.length; i++) {
   1.873 +      var element = $(arguments[i]);
   1.874 +      element.style.display = '';
   1.875 +    }
   1.876 +  },
   1.877 +
   1.878 +  remove: function(element) {
   1.879 +    element = $(element);
   1.880 +    element.parentNode.removeChild(element);
   1.881 +  },
   1.882 +
   1.883 +  update: function(element, html) {
   1.884 +    $(element).innerHTML = html.stripScripts();
   1.885 +    setTimeout(function() {html.evalScripts()}, 10);
   1.886 +  },
   1.887 +
   1.888 +  getHeight: function(element) {
   1.889 +    element = $(element);
   1.890 +    return element.offsetHeight;
   1.891 +  },
   1.892 +
   1.893 +  classNames: function(element) {
   1.894 +    return new Element.ClassNames(element);
   1.895 +  },
   1.896 +
   1.897 +  hasClassName: function(element, className) {
   1.898 +    if (!(element = $(element))) return;
   1.899 +    return Element.classNames(element).include(className);
   1.900 +  },
   1.901 +
   1.902 +  addClassName: function(element, className) {
   1.903 +    if (!(element = $(element))) return;
   1.904 +    return Element.classNames(element).add(className);
   1.905 +  },
   1.906 +
   1.907 +  removeClassName: function(element, className) {
   1.908 +    if (!(element = $(element))) return;
   1.909 +    return Element.classNames(element).remove(className);
   1.910 +  },
   1.911 +
   1.912 +  // removes whitespace-only text node children
   1.913 +  cleanWhitespace: function(element) {
   1.914 +    element = $(element);
   1.915 +    for (var i = 0; i < element.childNodes.length; i++) {
   1.916 +      var node = element.childNodes[i];
   1.917 +      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
   1.918 +        Element.remove(node);
   1.919 +    }
   1.920 +  },
   1.921 +
   1.922 +  empty: function(element) {
   1.923 +    return $(element).innerHTML.match(/^\s*$/);
   1.924 +  },
   1.925 +
   1.926 +  scrollTo: function(element) {
   1.927 +    element = $(element);
   1.928 +    var x = element.x ? element.x : element.offsetLeft,
   1.929 +        y = element.y ? element.y : element.offsetTop;
   1.930 +    window.scrollTo(x, y);
   1.931 +  },
   1.932 +
   1.933 +  getStyle: function(element, style) {
   1.934 +    element = $(element);
   1.935 +    var value = element.style[style.camelize()];
   1.936 +    if (!value) {
   1.937 +      if (document.defaultView && document.defaultView.getComputedStyle) {
   1.938 +        var css = document.defaultView.getComputedStyle(element, null);
   1.939 +        value = css ? css.getPropertyValue(style) : null;
   1.940 +      } else if (element.currentStyle) {
   1.941 +        value = element.currentStyle[style.camelize()];
   1.942 +      }
   1.943 +    }
   1.944 +
   1.945 +    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
   1.946 +      if (Element.getStyle(element, 'position') == 'static') value = 'auto';
   1.947 +
   1.948 +    return value == 'auto' ? null : value;
   1.949 +  },
   1.950 +
   1.951 +  setStyle: function(element, style) {
   1.952 +    element = $(element);
   1.953 +    for (name in style)
   1.954 +      element.style[name.camelize()] = style[name];
   1.955 +  },
   1.956 +
   1.957 +  getDimensions: function(element) {
   1.958 +    element = $(element);
   1.959 +    if (Element.getStyle(element, 'display') != 'none')
   1.960 +      return {width: element.offsetWidth, height: element.offsetHeight};
   1.961 +
   1.962 +    // All *Width and *Height properties give 0 on elements with display none,
   1.963 +    // so enable the element temporarily
   1.964 +    var els = element.style;
   1.965 +    var originalVisibility = els.visibility;
   1.966 +    var originalPosition = els.position;
   1.967 +    els.visibility = 'hidden';
   1.968 +    els.position = 'absolute';
   1.969 +    els.display = '';
   1.970 +    var originalWidth = element.clientWidth;
   1.971 +    var originalHeight = element.clientHeight;
   1.972 +    els.display = 'none';
   1.973 +    els.position = originalPosition;
   1.974 +    els.visibility = originalVisibility;
   1.975 +    return {width: originalWidth, height: originalHeight};
   1.976 +  },
   1.977 +
   1.978 +  makePositioned: function(element) {
   1.979 +    element = $(element);
   1.980 +    var pos = Element.getStyle(element, 'position');
   1.981 +    if (pos == 'static' || !pos) {
   1.982 +      element._madePositioned = true;
   1.983 +      element.style.position = 'relative';
   1.984 +      // Opera returns the offset relative to the positioning context, when an
   1.985 +      // element is position relative but top and left have not been defined
   1.986 +      if (window.opera) {
   1.987 +        element.style.top = 0;
   1.988 +        element.style.left = 0;
   1.989 +      }
   1.990 +    }
   1.991 +  },
   1.992 +
   1.993 +  undoPositioned: function(element) {
   1.994 +    element = $(element);
   1.995 +    if (element._madePositioned) {
   1.996 +      element._madePositioned = undefined;
   1.997 +      element.style.position =
   1.998 +        element.style.top =
   1.999 +        element.style.left =
  1.1000 +        element.style.bottom =
  1.1001 +        element.style.right = '';
  1.1002 +    }
  1.1003 +  },
  1.1004 +
  1.1005 +  makeClipping: function(element) {
  1.1006 +    element = $(element);
  1.1007 +    if (element._overflow) return;
  1.1008 +    element._overflow = element.style.overflow;
  1.1009 +    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
  1.1010 +      element.style.overflow = 'hidden';
  1.1011 +  },
  1.1012 +
  1.1013 +  undoClipping: function(element) {
  1.1014 +    element = $(element);
  1.1015 +    if (element._overflow) return;
  1.1016 +    element.style.overflow = element._overflow;
  1.1017 +    element._overflow = undefined;
  1.1018 +  }
  1.1019 +});
  1.1020 +
  1.1021 +var Toggle = new Object();
  1.1022 +Toggle.display = Element.toggle;
  1.1023 +
  1.1024 +/*--------------------------------------------------------------------------*/
  1.1025 +
  1.1026 +Abstract.Insertion = function(adjacency) {
  1.1027 +  this.adjacency = adjacency;
  1.1028 +}
  1.1029 +
  1.1030 +Abstract.Insertion.prototype = {
  1.1031 +  initialize: function(element, content) {
  1.1032 +    this.element = $(element);
  1.1033 +    this.content = content.stripScripts();
  1.1034 +
  1.1035 +    if (this.adjacency && this.element.insertAdjacentHTML) {
  1.1036 +      try {
  1.1037 +        this.element.insertAdjacentHTML(this.adjacency, this.content);
  1.1038 +      } catch (e) {
  1.1039 +        if (this.element.tagName.toLowerCase() == 'tbody') {
  1.1040 +          this.insertContent(this.contentFromAnonymousTable());
  1.1041 +        } else {
  1.1042 +          throw e;
  1.1043 +        }
  1.1044 +      }
  1.1045 +    } else {
  1.1046 +      this.range = this.element.ownerDocument.createRange();
  1.1047 +      if (this.initializeRange) this.initializeRange();
  1.1048 +      this.insertContent([this.range.createContextualFragment(this.content)]);
  1.1049 +    }
  1.1050 +
  1.1051 +    setTimeout(function() {content.evalScripts()}, 10);
  1.1052 +  },
  1.1053 +
  1.1054 +  contentFromAnonymousTable: function() {
  1.1055 +    var div = document.createElement('div');
  1.1056 +    div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
  1.1057 +    return $A(div.childNodes[0].childNodes[0].childNodes);
  1.1058 +  }
  1.1059 +}
  1.1060 +
  1.1061 +var Insertion = new Object();
  1.1062 +
  1.1063 +Insertion.Before = Class.create();
  1.1064 +Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
  1.1065 +  initializeRange: function() {
  1.1066 +    this.range.setStartBefore(this.element);
  1.1067 +  },
  1.1068 +
  1.1069 +  insertContent: function(fragments) {
  1.1070 +    fragments.each((function(fragment) {
  1.1071 +      this.element.parentNode.insertBefore(fragment, this.element);
  1.1072 +    }).bind(this));
  1.1073 +  }
  1.1074 +});
  1.1075 +
  1.1076 +Insertion.Top = Class.create();
  1.1077 +Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
  1.1078 +  initializeRange: function() {
  1.1079 +    this.range.selectNodeContents(this.element);
  1.1080 +    this.range.collapse(true);
  1.1081 +  },
  1.1082 +
  1.1083 +  insertContent: function(fragments) {
  1.1084 +    fragments.reverse(false).each((function(fragment) {
  1.1085 +      this.element.insertBefore(fragment, this.element.firstChild);
  1.1086 +    }).bind(this));
  1.1087 +  }
  1.1088 +});
  1.1089 +
  1.1090 +Insertion.Bottom = Class.create();
  1.1091 +Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
  1.1092 +  initializeRange: function() {
  1.1093 +    this.range.selectNodeContents(this.element);
  1.1094 +    this.range.collapse(this.element);
  1.1095 +  },
  1.1096 +
  1.1097 +  insertContent: function(fragments) {
  1.1098 +    fragments.each((function(fragment) {
  1.1099 +      this.element.appendChild(fragment);
  1.1100 +    }).bind(this));
  1.1101 +  }
  1.1102 +});
  1.1103 +
  1.1104 +Insertion.After = Class.create();
  1.1105 +Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
  1.1106 +  initializeRange: function() {
  1.1107 +    this.range.setStartAfter(this.element);
  1.1108 +  },
  1.1109 +
  1.1110 +  insertContent: function(fragments) {
  1.1111 +    fragments.each((function(fragment) {
  1.1112 +      this.element.parentNode.insertBefore(fragment,
  1.1113 +        this.element.nextSibling);
  1.1114 +    }).bind(this));
  1.1115 +  }
  1.1116 +});
  1.1117 +
  1.1118 +/*--------------------------------------------------------------------------*/
  1.1119 +
  1.1120 +Element.ClassNames = Class.create();
  1.1121 +Element.ClassNames.prototype = {
  1.1122 +  initialize: function(element) {
  1.1123 +    this.element = $(element);
  1.1124 +  },
  1.1125 +
  1.1126 +  _each: function(iterator) {
  1.1127 +    this.element.className.split(/\s+/).select(function(name) {
  1.1128 +      return name.length > 0;
  1.1129 +    })._each(iterator);
  1.1130 +  },
  1.1131 +
  1.1132 +  set: function(className) {
  1.1133 +    this.element.className = className;
  1.1134 +  },
  1.1135 +
  1.1136 +  add: function(classNameToAdd) {
  1.1137 +    if (this.include(classNameToAdd)) return;
  1.1138 +    this.set(this.toArray().concat(classNameToAdd).join(' '));
  1.1139 +  },
  1.1140 +
  1.1141 +  remove: function(classNameToRemove) {
  1.1142 +    if (!this.include(classNameToRemove)) return;
  1.1143 +    this.set(this.select(function(className) {
  1.1144 +      return className != classNameToRemove;
  1.1145 +    }).join(' '));
  1.1146 +  },
  1.1147 +
  1.1148 +  toString: function() {
  1.1149 +    return this.toArray().join(' ');
  1.1150 +  }
  1.1151 +}
  1.1152 +
  1.1153 +Object.extend(Element.ClassNames.prototype, Enumerable);
  1.1154 +var Field = {
  1.1155 +  clear: function() {
  1.1156 +    for (var i = 0; i < arguments.length; i++)
  1.1157 +      $(arguments[i]).value = '';
  1.1158 +  },
  1.1159 +
  1.1160 +  focus: function(element) {
  1.1161 +    $(element).focus();
  1.1162 +  },
  1.1163 +
  1.1164 +  present: function() {
  1.1165 +    for (var i = 0; i < arguments.length; i++)
  1.1166 +      if ($(arguments[i]).value == '') return false;
  1.1167 +    return true;
  1.1168 +  },
  1.1169 +
  1.1170 +  select: function(element) {
  1.1171 +    $(element).select();
  1.1172 +  },
  1.1173 +
  1.1174 +  activate: function(element) {
  1.1175 +    element = $(element);
  1.1176 +    element.focus();
  1.1177 +    if (element.select)
  1.1178 +      element.select();
  1.1179 +  }
  1.1180 +}
  1.1181 +
  1.1182 +/*--------------------------------------------------------------------------*/
  1.1183 +
  1.1184 +var Form = {
  1.1185 +  serialize: function(form) {
  1.1186 +    var elements = Form.getElements($(form));
  1.1187 +    var queryComponents = new Array();
  1.1188 +
  1.1189 +    for (var i = 0; i < elements.length; i++) {
  1.1190 +      var queryComponent = Form.Element.serialize(elements[i]);
  1.1191 +      if (queryComponent)
  1.1192 +        queryComponents.push(queryComponent);
  1.1193 +    }
  1.1194 +
  1.1195 +    return queryComponents.join('&');
  1.1196 +  },
  1.1197 +
  1.1198 +  getElements: function(form) {
  1.1199 +    form = $(form);
  1.1200 +    var elements = new Array();
  1.1201 +
  1.1202 +    for (tagName in Form.Element.Serializers) {
  1.1203 +      var tagElements = form.getElementsByTagName(tagName);
  1.1204 +      for (var j = 0; j < tagElements.length; j++)
  1.1205 +        elements.push(tagElements[j]);
  1.1206 +    }
  1.1207 +    return elements;
  1.1208 +  },
  1.1209 +
  1.1210 +  getInputs: function(form, typeName, name) {
  1.1211 +    form = $(form);
  1.1212 +    var inputs = form.getElementsByTagName('input');
  1.1213 +
  1.1214 +    if (!typeName && !name)
  1.1215 +      return inputs;
  1.1216 +
  1.1217 +    var matchingInputs = new Array();
  1.1218 +    for (var i = 0; i < inputs.length; i++) {
  1.1219 +      var input = inputs[i];
  1.1220 +      if ((typeName && input.type != typeName) ||
  1.1221 +          (name && input.name != name))
  1.1222 +        continue;
  1.1223 +      matchingInputs.push(input);
  1.1224 +    }
  1.1225 +
  1.1226 +    return matchingInputs;
  1.1227 +  },
  1.1228 +
  1.1229 +  disable: function(form) {
  1.1230 +    var elements = Form.getElements(form);
  1.1231 +    for (var i = 0; i < elements.length; i++) {
  1.1232 +      var element = elements[i];
  1.1233 +      element.blur();
  1.1234 +      element.disabled = 'true';
  1.1235 +    }
  1.1236 +  },
  1.1237 +
  1.1238 +  enable: function(form) {
  1.1239 +    var elements = Form.getElements(form);
  1.1240 +    for (var i = 0; i < elements.length; i++) {
  1.1241 +      var element = elements[i];
  1.1242 +      element.disabled = '';
  1.1243 +    }
  1.1244 +  },
  1.1245 +
  1.1246 +  findFirstElement: function(form) {
  1.1247 +    return Form.getElements(form).find(function(element) {
  1.1248 +      return element.type != 'hidden' && !element.disabled &&
  1.1249 +        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
  1.1250 +    });
  1.1251 +  },
  1.1252 +
  1.1253 +  focusFirstElement: function(form) {
  1.1254 +    Field.activate(Form.findFirstElement(form));
  1.1255 +  },
  1.1256 +
  1.1257 +  reset: function(form) {
  1.1258 +    $(form).reset();
  1.1259 +  }
  1.1260 +}
  1.1261 +
  1.1262 +Form.Element = {
  1.1263 +  serialize: function(element) {
  1.1264 +    element = $(element);
  1.1265 +    var method = element.tagName.toLowerCase();
  1.1266 +    var parameter = Form.Element.Serializers[method](element);
  1.1267 +
  1.1268 +    if (parameter) {
  1.1269 +      var key = encodeURIComponent(parameter[0]);
  1.1270 +      if (key.length == 0) return;
  1.1271 +
  1.1272 +      if (parameter[1].constructor != Array)
  1.1273 +        parameter[1] = [parameter[1]];
  1.1274 +
  1.1275 +      return parameter[1].map(function(value) {
  1.1276 +        return key + '=' + encodeURIComponent(value);
  1.1277 +      }).join('&');
  1.1278 +    }
  1.1279 +  },
  1.1280 +
  1.1281 +  getValue: function(element) {
  1.1282 +    element = $(element);
  1.1283 +    var method = element.tagName.toLowerCase();
  1.1284 +    var parameter = Form.Element.Serializers[method](element);
  1.1285 +
  1.1286 +    if (parameter)
  1.1287 +      return parameter[1];
  1.1288 +  }
  1.1289 +}
  1.1290 +
  1.1291 +Form.Element.Serializers = {
  1.1292 +  input: function(element) {
  1.1293 +    switch (element.type.toLowerCase()) {
  1.1294 +      case 'submit':
  1.1295 +      case 'hidden':
  1.1296 +      case 'password':
  1.1297 +      case 'text':
  1.1298 +        return Form.Element.Serializers.textarea(element);
  1.1299 +      case 'checkbox':
  1.1300 +      case 'radio':
  1.1301 +        return Form.Element.Serializers.inputSelector(element);
  1.1302 +    }
  1.1303 +    return false;
  1.1304 +  },
  1.1305 +
  1.1306 +  inputSelector: function(element) {
  1.1307 +    if (element.checked)
  1.1308 +      return [element.name, element.value];
  1.1309 +  },
  1.1310 +
  1.1311 +  textarea: function(element) {
  1.1312 +    return [element.name, element.value];
  1.1313 +  },
  1.1314 +
  1.1315 +  select: function(element) {
  1.1316 +    return Form.Element.Serializers[element.type == 'select-one' ?
  1.1317 +      'selectOne' : 'selectMany'](element);
  1.1318 +  },
  1.1319 +
  1.1320 +  selectOne: function(element) {
  1.1321 +    var value = '', opt, index = element.selectedIndex;
  1.1322 +    if (index >= 0) {
  1.1323 +      opt = element.options[index];
  1.1324 +      value = opt.value;
  1.1325 +      if (!value && !('value' in opt))
  1.1326 +        value = opt.text;
  1.1327 +    }
  1.1328 +    return [element.name, value];
  1.1329 +  },
  1.1330 +
  1.1331 +  selectMany: function(element) {
  1.1332 +    var value = new Array();
  1.1333 +    for (var i = 0; i < element.length; i++) {
  1.1334 +      var opt = element.options[i];
  1.1335 +      if (opt.selected) {
  1.1336 +        var optValue = opt.value;
  1.1337 +        if (!optValue && !('value' in opt))
  1.1338 +          optValue = opt.text;
  1.1339 +        value.push(optValue);
  1.1340 +      }
  1.1341 +    }
  1.1342 +    return [element.name, value];
  1.1343 +  }
  1.1344 +}
  1.1345 +
  1.1346 +/*--------------------------------------------------------------------------*/
  1.1347 +
  1.1348 +var $F = Form.Element.getValue;
  1.1349 +
  1.1350 +/*--------------------------------------------------------------------------*/
  1.1351 +
  1.1352 +Abstract.TimedObserver = function() {}
  1.1353 +Abstract.TimedObserver.prototype = {
  1.1354 +  initialize: function(element, frequency, callback) {
  1.1355 +    this.frequency = frequency;
  1.1356 +    this.element   = $(element);
  1.1357 +    this.callback  = callback;
  1.1358 +
  1.1359 +    this.lastValue = this.getValue();
  1.1360 +    this.registerCallback();
  1.1361 +  },
  1.1362 +
  1.1363 +  registerCallback: function() {
  1.1364 +    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  1.1365 +  },
  1.1366 +
  1.1367 +  onTimerEvent: function() {
  1.1368 +    var value = this.getValue();
  1.1369 +    if (this.lastValue != value) {
  1.1370 +      this.callback(this.element, value);
  1.1371 +      this.lastValue = value;
  1.1372 +    }
  1.1373 +  }
  1.1374 +}
  1.1375 +
  1.1376 +Form.Element.Observer = Class.create();
  1.1377 +Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
  1.1378 +  getValue: function() {
  1.1379 +    return Form.Element.getValue(this.element);
  1.1380 +  }
  1.1381 +});
  1.1382 +
  1.1383 +Form.Observer = Class.create();
  1.1384 +Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
  1.1385 +  getValue: function() {
  1.1386 +    return Form.serialize(this.element);
  1.1387 +  }
  1.1388 +});
  1.1389 +
  1.1390 +/*--------------------------------------------------------------------------*/
  1.1391 +
  1.1392 +Abstract.EventObserver = function() {}
  1.1393 +Abstract.EventObserver.prototype = {
  1.1394 +  initialize: function(element, callback) {
  1.1395 +    this.element  = $(element);
  1.1396 +    this.callback = callback;
  1.1397 +
  1.1398 +    this.lastValue = this.getValue();
  1.1399 +    if (this.element.tagName.toLowerCase() == 'form')
  1.1400 +      this.registerFormCallbacks();
  1.1401 +    else
  1.1402 +      this.registerCallback(this.element);
  1.1403 +  },
  1.1404 +
  1.1405 +  onElementEvent: function() {
  1.1406 +    var value = this.getValue();
  1.1407 +    if (this.lastValue != value) {
  1.1408 +      this.callback(this.element, value);
  1.1409 +      this.lastValue = value;
  1.1410 +    }
  1.1411 +  },
  1.1412 +
  1.1413 +  registerFormCallbacks: function() {
  1.1414 +    var elements = Form.getElements(this.element);
  1.1415 +    for (var i = 0; i < elements.length; i++)
  1.1416 +      this.registerCallback(elements[i]);
  1.1417 +  },
  1.1418 +
  1.1419 +  registerCallback: function(element) {
  1.1420 +    if (element.type) {
  1.1421 +      switch (element.type.toLowerCase()) {
  1.1422 +        case 'checkbox':
  1.1423 +        case 'radio':
  1.1424 +          Event.observe(element, 'click', this.onElementEvent.bind(this));
  1.1425 +          break;
  1.1426 +        case 'password':
  1.1427 +        case 'text':
  1.1428 +        case 'textarea':
  1.1429 +        case 'select-one':
  1.1430 +        case 'select-multiple':
  1.1431 +          Event.observe(element, 'change', this.onElementEvent.bind(this));
  1.1432 +          break;
  1.1433 +      }
  1.1434 +    }
  1.1435 +  }
  1.1436 +}
  1.1437 +
  1.1438 +Form.Element.EventObserver = Class.create();
  1.1439 +Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
  1.1440 +  getValue: function() {
  1.1441 +    return Form.Element.getValue(this.element);
  1.1442 +  }
  1.1443 +});
  1.1444 +
  1.1445 +Form.EventObserver = Class.create();
  1.1446 +Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
  1.1447 +  getValue: function() {
  1.1448 +    return Form.serialize(this.element);
  1.1449 +  }
  1.1450 +});
  1.1451 +if (!window.Event) {
  1.1452 +  var Event = new Object();
  1.1453 +}
  1.1454 +
  1.1455 +Object.extend(Event, {
  1.1456 +  KEY_BACKSPACE: 8,
  1.1457 +  KEY_TAB:       9,
  1.1458 +  KEY_RETURN:   13,
  1.1459 +  KEY_ESC:      27,
  1.1460 +  KEY_LEFT:     37,
  1.1461 +  KEY_UP:       38,
  1.1462 +  KEY_RIGHT:    39,
  1.1463 +  KEY_DOWN:     40,
  1.1464 +  KEY_DELETE:   46,
  1.1465 +
  1.1466 +  element: function(event) {
  1.1467 +    return event.target || event.srcElement;
  1.1468 +  },
  1.1469 +
  1.1470 +  isLeftClick: function(event) {
  1.1471 +    return (((event.which) && (event.which == 1)) ||
  1.1472 +            ((event.button) && (event.button == 1)));
  1.1473 +  },
  1.1474 +
  1.1475 +  pointerX: function(event) {
  1.1476 +    return event.pageX || (event.clientX +
  1.1477 +      (document.documentElement.scrollLeft || document.body.scrollLeft));
  1.1478 +  },
  1.1479 +
  1.1480 +  pointerY: function(event) {
  1.1481 +    return event.pageY || (event.clientY +
  1.1482 +      (document.documentElement.scrollTop || document.body.scrollTop));
  1.1483 +  },
  1.1484 +
  1.1485 +  stop: function(event) {
  1.1486 +    if (event.preventDefault) {
  1.1487 +      event.preventDefault();
  1.1488 +      event.stopPropagation();
  1.1489 +    } else {
  1.1490 +      event.returnValue = false;
  1.1491 +      event.cancelBubble = true;
  1.1492 +    }
  1.1493 +  },
  1.1494 +
  1.1495 +  // find the first node with the given tagName, starting from the
  1.1496 +  // node the event was triggered on; traverses the DOM upwards
  1.1497 +  findElement: function(event, tagName) {
  1.1498 +    var element = Event.element(event);
  1.1499 +    while (element.parentNode && (!element.tagName ||
  1.1500 +        (element.tagName.toUpperCase() != tagName.toUpperCase())))
  1.1501 +      element = element.parentNode;
  1.1502 +    return element;
  1.1503 +  },
  1.1504 +
  1.1505 +  observers: false,
  1.1506 +
  1.1507 +  _observeAndCache: function(element, name, observer, useCapture) {
  1.1508 +    if (!this.observers) this.observers = [];
  1.1509 +    if (element.addEventListener) {
  1.1510 +      this.observers.push([element, name, observer, useCapture]);
  1.1511 +      element.addEventListener(name, observer, useCapture);
  1.1512 +    } else if (element.attachEvent) {
  1.1513 +      this.observers.push([element, name, observer, useCapture]);
  1.1514 +      element.attachEvent('on' + name, observer);
  1.1515 +    }
  1.1516 +  },
  1.1517 +
  1.1518 +  unloadCache: function() {
  1.1519 +    if (!Event.observers) return;
  1.1520 +    for (var i = 0; i < Event.observers.length; i++) {
  1.1521 +      Event.stopObserving.apply(this, Event.observers[i]);
  1.1522 +      Event.observers[i][0] = null;
  1.1523 +    }
  1.1524 +    Event.observers = false;
  1.1525 +  },
  1.1526 +
  1.1527 +  observe: function(element, name, observer, useCapture) {
  1.1528 +    var element = $(element);
  1.1529 +    useCapture = useCapture || false;
  1.1530 +
  1.1531 +    if (name == 'keypress' &&
  1.1532 +        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
  1.1533 +        || element.attachEvent))
  1.1534 +      name = 'keydown';
  1.1535 +
  1.1536 +    this._observeAndCache(element, name, observer, useCapture);
  1.1537 +  },
  1.1538 +
  1.1539 +  stopObserving: function(element, name, observer, useCapture) {
  1.1540 +    var element = $(element);
  1.1541 +    useCapture = useCapture || false;
  1.1542 +
  1.1543 +    if (name == 'keypress' &&
  1.1544 +        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
  1.1545 +        || element.detachEvent))
  1.1546 +      name = 'keydown';
  1.1547 +
  1.1548 +    if (element.removeEventListener) {
  1.1549 +      element.removeEventListener(name, observer, useCapture);
  1.1550 +    } else if (element.detachEvent) {
  1.1551 +      element.detachEvent('on' + name, observer);
  1.1552 +    }
  1.1553 +  }
  1.1554 +});
  1.1555 +
  1.1556 +/* prevent memory leaks in IE */
  1.1557 +Event.observe(window, 'unload', Event.unloadCache, false);
  1.1558 +var Position = {
  1.1559 +  // set to true if needed, warning: firefox performance problems
  1.1560 +  // NOT neeeded for page scrolling, only if draggable contained in
  1.1561 +  // scrollable elements
  1.1562 +  includeScrollOffsets: false,
  1.1563 +
  1.1564 +  // must be called before calling withinIncludingScrolloffset, every time the
  1.1565 +  // page is scrolled
  1.1566 +  prepare: function() {
  1.1567 +    this.deltaX =  window.pageXOffset
  1.1568 +                || document.documentElement.scrollLeft
  1.1569 +                || document.body.scrollLeft
  1.1570 +                || 0;
  1.1571 +    this.deltaY =  window.pageYOffset
  1.1572 +                || document.documentElement.scrollTop
  1.1573 +                || document.body.scrollTop
  1.1574 +                || 0;
  1.1575 +  },
  1.1576 +
  1.1577 +  realOffset: function(element) {
  1.1578 +    var valueT = 0, valueL = 0;
  1.1579 +    do {
  1.1580 +      valueT += element.scrollTop  || 0;
  1.1581 +      valueL += element.scrollLeft || 0;
  1.1582 +      element = element.parentNode;
  1.1583 +    } while (element);
  1.1584 +    return [valueL, valueT];
  1.1585 +  },
  1.1586 +
  1.1587 +  cumulativeOffset: function(element) {
  1.1588 +    var valueT = 0, valueL = 0;
  1.1589 +    do {
  1.1590 +      valueT += element.offsetTop  || 0;
  1.1591 +      valueL += element.offsetLeft || 0;
  1.1592 +      element = element.offsetParent;
  1.1593 +    } while (element);
  1.1594 +    return [valueL, valueT];
  1.1595 +  },
  1.1596 +
  1.1597 +  positionedOffset: function(element) {
  1.1598 +    var valueT = 0, valueL = 0;
  1.1599 +    do {
  1.1600 +      valueT += element.offsetTop  || 0;
  1.1601 +      valueL += element.offsetLeft || 0;
  1.1602 +      element = element.offsetParent;
  1.1603 +      if (element) {
  1.1604 +        p = Element.getStyle(element, 'position');
  1.1605 +        if (p == 'relative' || p == 'absolute') break;
  1.1606 +      }
  1.1607 +    } while (element);
  1.1608 +    return [valueL, valueT];
  1.1609 +  },
  1.1610 +
  1.1611 +  offsetParent: function(element) {
  1.1612 +    if (element.offsetParent) return element.offsetParent;
  1.1613 +    if (element == document.body) return element;
  1.1614 +
  1.1615 +    while ((element = element.parentNode) && element != document.body)
  1.1616 +      if (Element.getStyle(element, 'position') != 'static')
  1.1617 +        return element;
  1.1618 +
  1.1619 +    return document.body;
  1.1620 +  },
  1.1621 +
  1.1622 +  // caches x/y coordinate pair to use with overlap
  1.1623 +  within: function(element, x, y) {
  1.1624 +    if (this.includeScrollOffsets)
  1.1625 +      return this.withinIncludingScrolloffsets(element, x, y);
  1.1626 +    this.xcomp = x;
  1.1627 +    this.ycomp = y;
  1.1628 +    this.offset = this.cumulativeOffset(element);
  1.1629 +
  1.1630 +    return (y >= this.offset[1] &&
  1.1631 +            y <  this.offset[1] + element.offsetHeight &&
  1.1632 +            x >= this.offset[0] &&
  1.1633 +            x <  this.offset[0] + element.offsetWidth);
  1.1634 +  },
  1.1635 +
  1.1636 +  withinIncludingScrolloffsets: function(element, x, y) {
  1.1637 +    var offsetcache = this.realOffset(element);
  1.1638 +
  1.1639 +    this.xcomp = x + offsetcache[0] - this.deltaX;
  1.1640 +    this.ycomp = y + offsetcache[1] - this.deltaY;
  1.1641 +    this.offset = this.cumulativeOffset(element);
  1.1642 +
  1.1643 +    return (this.ycomp >= this.offset[1] &&
  1.1644 +            this.ycomp <  this.offset[1] + element.offsetHeight &&
  1.1645 +            this.xcomp >= this.offset[0] &&
  1.1646 +            this.xcomp <  this.offset[0] + element.offsetWidth);
  1.1647 +  },
  1.1648 +
  1.1649 +  // within must be called directly before
  1.1650 +  overlap: function(mode, element) {
  1.1651 +    if (!mode) return 0;
  1.1652 +    if (mode == 'vertical')
  1.1653 +      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
  1.1654 +        element.offsetHeight;
  1.1655 +    if (mode == 'horizontal')
  1.1656 +      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
  1.1657 +        element.offsetWidth;
  1.1658 +  },
  1.1659 +
  1.1660 +  clone: function(source, target) {
  1.1661 +    source = $(source);
  1.1662 +    target = $(target);
  1.1663 +    target.style.position = 'absolute';
  1.1664 +    var offsets = this.cumulativeOffset(source);
  1.1665 +    target.style.top    = offsets[1] + 'px';
  1.1666 +    target.style.left   = offsets[0] + 'px';
  1.1667 +    target.style.width  = source.offsetWidth + 'px';
  1.1668 +    target.style.height = source.offsetHeight + 'px';
  1.1669 +  },
  1.1670 +
  1.1671 +  page: function(forElement) {
  1.1672 +    var valueT = 0, valueL = 0;
  1.1673 +
  1.1674 +    var element = forElement;
  1.1675 +    do {
  1.1676 +      valueT += element.offsetTop  || 0;
  1.1677 +      valueL += element.offsetLeft || 0;
  1.1678 +
  1.1679 +      // Safari fix
  1.1680 +      if (element.offsetParent==document.body)
  1.1681 +        if (Element.getStyle(element,'position')=='absolute') break;
  1.1682 +
  1.1683 +    } while (element = element.offsetParent);
  1.1684 +
  1.1685 +    element = forElement;
  1.1686 +    do {
  1.1687 +      valueT -= element.scrollTop  || 0;
  1.1688 +      valueL -= element.scrollLeft || 0;
  1.1689 +    } while (element = element.parentNode);
  1.1690 +
  1.1691 +    return [valueL, valueT];
  1.1692 +  },
  1.1693 +
  1.1694 +  clone: function(source, target) {
  1.1695 +    var options = Object.extend({
  1.1696 +      setLeft:    true,
  1.1697 +      setTop:     true,
  1.1698 +      setWidth:   true,
  1.1699 +      setHeight:  true,
  1.1700 +      offsetTop:  0,
  1.1701 +      offsetLeft: 0
  1.1702 +    }, arguments[2] || {})
  1.1703 +
  1.1704 +    // find page position of source
  1.1705 +    source = $(source);
  1.1706 +    var p = Position.page(source);
  1.1707 +
  1.1708 +    // find coordinate system to use
  1.1709 +    target = $(target);
  1.1710 +    var delta = [0, 0];
  1.1711 +    var parent = null;
  1.1712 +    // delta [0,0] will do fine with position: fixed elements,
  1.1713 +    // position:absolute needs offsetParent deltas
  1.1714 +    if (Element.getStyle(target,'position') == 'absolute') {
  1.1715 +      parent = Position.offsetParent(target);
  1.1716 +      delta = Position.page(parent);
  1.1717 +    }
  1.1718 +
  1.1719 +    // correct by body offsets (fixes Safari)
  1.1720 +    if (parent == document.body) {
  1.1721 +      delta[0] -= document.body.offsetLeft;
  1.1722 +      delta[1] -= document.body.offsetTop;
  1.1723 +    }
  1.1724 +
  1.1725 +    // set position
  1.1726 +    if(options.setLeft)   target.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
  1.1727 +    if(options.setTop)    target.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
  1.1728 +    if(options.setWidth)  target.style.width = source.offsetWidth + 'px';
  1.1729 +    if(options.setHeight) target.style.height = source.offsetHeight + 'px';
  1.1730 +  },
  1.1731 +
  1.1732 +  absolutize: function(element) {
  1.1733 +    element = $(element);
  1.1734 +    if (element.style.position == 'absolute') return;
  1.1735 +    Position.prepare();
  1.1736 +
  1.1737 +    var offsets = Position.positionedOffset(element);
  1.1738 +    var top     = offsets[1];
  1.1739 +    var left    = offsets[0];
  1.1740 +    var width   = element.clientWidth;
  1.1741 +    var height  = element.clientHeight;
  1.1742 +
  1.1743 +    element._originalLeft   = left - parseFloat(element.style.left  || 0);
  1.1744 +    element._originalTop    = top  - parseFloat(element.style.top || 0);
  1.1745 +    element._originalWidth  = element.style.width;
  1.1746 +    element._originalHeight = element.style.height;
  1.1747 +
  1.1748 +    element.style.position = 'absolute';
  1.1749 +    element.style.top    = top + 'px';;
  1.1750 +    element.style.left   = left + 'px';;
  1.1751 +    element.style.width  = width + 'px';;
  1.1752 +    element.style.height = height + 'px';;
  1.1753 +  },
  1.1754 +
  1.1755 +  relativize: function(element) {
  1.1756 +    element = $(element);
  1.1757 +    if (element.style.position == 'relative') return;
  1.1758 +    Position.prepare();
  1.1759 +
  1.1760 +    element.style.position = 'relative';
  1.1761 +    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
  1.1762 +    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
  1.1763 +
  1.1764 +    element.style.top    = top + 'px';
  1.1765 +    element.style.left   = left + 'px';
  1.1766 +    element.style.height = element._originalHeight;
  1.1767 +    element.style.width  = element._originalWidth;
  1.1768 +  }
  1.1769 +}
  1.1770 +
  1.1771 +// Safari returns margins on body which is incorrect if the child is absolutely
  1.1772 +// positioned.  For performance reasons, redefine Position.cumulativeOffset for
  1.1773 +// KHTML/WebKit only.
  1.1774 +if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
  1.1775 +  Position.cumulativeOffset = function(element) {
  1.1776 +    var valueT = 0, valueL = 0;
  1.1777 +    do {
  1.1778 +      valueT += element.offsetTop  || 0;
  1.1779 +      valueL += element.offsetLeft || 0;
  1.1780 +      if (element.offsetParent == document.body)
  1.1781 +        if (Element.getStyle(element, 'position') == 'absolute') break;
  1.1782 +
  1.1783 +      element = element.offsetParent;
  1.1784 +    } while (element);
  1.1785 +
  1.1786 +    return [valueL, valueT];
  1.1787 +  }
  1.1788 +}
  1.1789 \ No newline at end of file