/*plik prototype.js*/
/*  Prototype JavaScript framework, version 1.4.0
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *
 *  THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
 *  against the source tree, available from the Prototype darcs repository.
 *
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *
 *  For details, see the Prototype web site: http://prototype.conio.net/
 *
/*--------------------------------------------------------------------------*/

var Prototype = {
  Version: '1.4.0',
  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',

  emptyFunction: function() {},
  K: function(x) {return x}
}

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}

var Abstract = new Object();

Object.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

Object.inspect = function(object) {
  try {
    if (object == undefined) return 'undefined';
    if (object == null) return 'null';
    return object.inspect ? object.inspect() : object.toString();
  } catch (e) {
    if (e instanceof RangeError) return '...';
    throw e;
  }
}

Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}

Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    return __method.call(object, event || window.event);
  }
}

Object.extend(Number.prototype, {
  toColorPart: function() {
    var digits = this.toString(16);
    if (this < 16) return '0' + digits;
    return digits;
  },

  succ: function() {
    return this + 1;
  },

  times: function(iterator) {
    $R(0, this, true).each(iterator);
    return this;
  }
});

var Try = {
  these: function() {
    var returnValue;

    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }

    return returnValue;
  }
}

/*--------------------------------------------------------------------------*/

var PeriodicalExecuter = Class.create();
PeriodicalExecuter.prototype = {
  initialize: function(callback, frequency) {
    this.callback = callback;
    this.frequency = frequency;
    this.currentlyExecuting = false;

    this.registerCallback();
  },

  registerCallback: function() {
    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  },

  onTimerEvent: function() {
    if (!this.currentlyExecuting) {
      try {
        this.currentlyExecuting = true;
        this.callback();
      } finally {
        this.currentlyExecuting = false;
      }
    }
  }
}

/*--------------------------------------------------------------------------*/

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
Object.extend(String.prototype, {
  stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },

  stripScripts: function() {
    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
  },

  extractScripts: function() {
    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
    return (this.match(matchAll) || []).map(function(scriptTag) {
      return (scriptTag.match(matchOne) || ['', ''])[1];
    });
  },

  evalScripts: function() {
    return this.extractScripts().map(eval);
  },

  escapeHTML: function() {
    var div = document.createElement('div');
    var text = document.createTextNode(this);
    div.appendChild(text);
    return div.innerHTML;
  },

  unescapeHTML: function() {
    var div = document.createElement('div');
    div.innerHTML = this.stripTags();
    return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
  },

  toQueryParams: function() {
    var pairs = this.match(/^\??(.*)$/)[1].split('&');
    return pairs.inject({}, function(params, pairString) {
      var pair = pairString.split('=');
      params[pair[0]] = pair[1];
      return params;
    });
  },

  toArray: function() {
    return this.split('');
  },

  camelize: function() {
    var oStringList = this.split('-');
    if (oStringList.length == 1) return oStringList[0];

    var camelizedString = this.indexOf('-') == 0
      ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
      : oStringList[0];

    for (var i = 1, len = oStringList.length; i < len; i++) {
      var s = oStringList[i];
      camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
    }

    return camelizedString;
  },

  inspect: function() {
    return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
  }
});

String.prototype.parseQuery = String.prototype.toQueryParams;

var $break    = new Object();
var $continue = new Object();

var Enumerable = {
  each: function(iterator) {
    var index = 0;
    try {
      this._each(function(value) {
        try {
          iterator(value, index++);
        } catch (e) {
          if (e != $continue) throw e;
        }
      });
    } catch (e) {
      if (e != $break) throw e;
    }
  },

  all: function(iterator) {
    var result = true;
    this.each(function(value, index) {
      result = result && !!(iterator || Prototype.K)(value, index);
      if (!result) throw $break;
    });
    return result;
  },

  any: function(iterator) {
    var result = true;
    this.each(function(value, index) {
      if (result = !!(iterator || Prototype.K)(value, index))
        throw $break;
    });
    return result;
  },

  collect: function(iterator) {
    var results = [];
    this.each(function(value, index) {
      results.push(iterator(value, index));
    });
    return results;
  },

  detect: function (iterator) {
    var result;
    this.each(function(value, index) {
      if (iterator(value, index)) {
        result = value;
        throw $break;
      }
    });
    return result;
  },

  findAll: function(iterator) {
    var results = [];
    this.each(function(value, index) {
      if (iterator(value, index))
        results.push(value);
    });
    return results;
  },

  grep: function(pattern, iterator) {
    var results = [];
    this.each(function(value, index) {
      var stringValue = value.toString();
      if (stringValue.match(pattern))
        results.push((iterator || Prototype.K)(value, index));
    })
    return results;
  },

  include: function(object) {
    var found = false;
    this.each(function(value) {
      if (value == object) {
        found = true;
        throw $break;
      }
    });
    return found;
  },

  inject: function(memo, iterator) {
    this.each(function(value, index) {
      memo = iterator(memo, value, index);
    });
    return memo;
  },

  invoke: function(method) {
    var args = $A(arguments).slice(1);
    return this.collect(function(value) {
      return value[method].apply(value, args);
    });
  },

  max: function(iterator) {
    var result;
    this.each(function(value, index) {
      value = (iterator || Prototype.K)(value, index);
      if (value >= (result || value))
        result = value;
    });
    return result;
  },

  min: function(iterator) {
    var result;
    this.each(function(value, index) {
      value = (iterator || Prototype.K)(value, index);
      if (value <= (result || value))
        result = value;
    });
    return result;
  },

  partition: function(iterator) {
    var trues = [], falses = [];
    this.each(function(value, index) {
      ((iterator || Prototype.K)(value, index) ?
        trues : falses).push(value);
    });
    return [trues, falses];
  },

  pluck: function(property) {
    var results = [];
    this.each(function(value, index) {
      results.push(value[property]);
    });
    return results;
  },

  reject: function(iterator) {
    var results = [];
    this.each(function(value, index) {
      if (!iterator(value, index))
        results.push(value);
    });
    return results;
  },

  sortBy: function(iterator) {
    return this.collect(function(value, index) {
      return {value: value, criteria: iterator(value, index)};
    }).sort(function(left, right) {
      var a = left.criteria, b = right.criteria;
      return a < b ? -1 : a > b ? 1 : 0;
    }).pluck('value');
  },

  toArray: function() {
    return this.collect(Prototype.K);
  },

  zip: function() {
    var iterator = Prototype.K, args = $A(arguments);
    if (typeof args.last() == 'function')
      iterator = args.pop();

    var collections = [this].concat(args).map($A);
    return this.map(function(value, index) {
      iterator(value = collections.pluck(index));
      return value;
    });
  },

  inspect: function() {
    return '#<Enumerable:' + this.toArray().inspect() + '>';
  }
}

Object.extend(Enumerable, {
  map:     Enumerable.collect,
  find:    Enumerable.detect,
  select:  Enumerable.findAll,
  member:  Enumerable.include,
  entries: Enumerable.toArray
});
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}

Object.extend(Array.prototype, Enumerable);

Array.prototype._reverse = Array.prototype.reverse;

Object.extend(Array.prototype, {
  _each: function(iterator) {
    for (var i = 0; i < this.length; i++)
      iterator(this[i]);
  },

  clear: function() {
    this.length = 0;
    return this;
  },

  first: function() {
    return this[0];
  },

  last: function() {
    return this[this.length - 1];
  },

  compact: function() {
    return this.select(function(value) {
      return value != undefined || value != null;
    });
  },

  flatten: function() {
    return this.inject([], function(array, value) {
      return array.concat(value.constructor == Array ?
        value.flatten() : [value]);
    });
  },

  without: function() {
    var values = $A(arguments);
    return this.select(function(value) {
      return !values.include(value);
    });
  },

  indexOf: function(object) {
    for (var i = 0; i < this.length; i++)
      if (this[i] == object) return i;
    return -1;
  },

  reverse: function(inline) {
    return (inline !== false ? this : this.toArray())._reverse();
  },

  shift: function() {
    var result = this[0];
    for (var i = 0; i < this.length - 1; i++)
      this[i] = this[i + 1];
    this.length--;
    return result;
  },

  inspect: function() {
    return '[' + this.map(Object.inspect).join(', ') + ']';
  }
});
var Hash = {
  _each: function(iterator) {
    for (key in this) {
      var value = this[key];
      if (typeof value == 'function') continue;

      var pair = [key, value];
      pair.key = key;
      pair.value = value;
      iterator(pair);
    }
  },

  keys: function() {
    return this.pluck('key');
  },

  values: function() {
    return this.pluck('value');
  },

  merge: function(hash) {
    return $H(hash).inject($H(this), function(mergedHash, pair) {
      mergedHash[pair.key] = pair.value;
      return mergedHash;
    });
  },

  toQueryString: function() {
    return this.map(function(pair) {
      return pair.map(encodeURIComponent).join('=');
    }).join('&');
  },

  inspect: function() {
    return '#<Hash:{' + this.map(function(pair) {
      return pair.map(Object.inspect).join(': ');
    }).join(', ') + '}>';
  }
}

function $H(object) {
  var hash = Object.extend({}, object || {});
  Object.extend(hash, Enumerable);
  Object.extend(hash, Hash);
  return hash;
}
ObjectRange = Class.create();
Object.extend(ObjectRange.prototype, Enumerable);
Object.extend(ObjectRange.prototype, {
  initialize: function(start, end, exclusive) {
    this.start = start;
    this.end = end;
    this.exclusive = exclusive;
  },

  _each: function(iterator) {
    var value = this.start;
    do {
      iterator(value);
      value = value.succ();
    } while (this.include(value));
  },

  include: function(value) {
    if (value < this.start)
      return false;
    if (this.exclusive)
      return value < this.end;
    return value <= this.end;
  }
});

var $R = function(start, end, exclusive) {
  return new ObjectRange(start, end, exclusive);
}

var Ajax = {
  getTransport: function() {
    return Try.these(
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')},
      function() {return new XMLHttpRequest()}
    ) || false;
  },

  activeRequestCount: 0
}

Ajax.Responders = {
  responders: [],

  _each: function(iterator) {
    this.responders._each(iterator);
  },

  register: function(responderToAdd) {
    if (!this.include(responderToAdd))
      this.responders.push(responderToAdd);
  },

  unregister: function(responderToRemove) {
    this.responders = this.responders.without(responderToRemove);
  },

  dispatch: function(callback, request, transport, json) {
    this.each(function(responder) {
      if (responder[callback] && typeof responder[callback] == 'function') {
        try {
          responder[callback].apply(responder, [request, transport, json]);
        } catch (e) {}
      }
    });
  }
};

Object.extend(Ajax.Responders, Enumerable);

Ajax.Responders.register({
  onCreate: function() {
    Ajax.activeRequestCount++;
  },

  onComplete: function() {
    Ajax.activeRequestCount--;
  }
});

Ajax.Base = function() {};
Ajax.Base.prototype = {
  setOptions: function(options) {
    this.options = {
      method:       'post',
      asynchronous: true,
      parameters:   ''
    }
    Object.extend(this.options, options || {});
  },

  responseIsSuccess: function() {
    return this.transport.status == undefined
        || this.transport.status == 0
        || (this.transport.status >= 200 && this.transport.status < 300);
  },

  responseIsFailure: function() {
    return !this.responseIsSuccess();
  }
}

Ajax.Request = Class.create();
Ajax.Request.Events =
  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];

Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
  initialize: function(url, options) {
    this.transport = Ajax.getTransport();
    this.setOptions(options);
    this.request(url);
  },

  request: function(url) {
    var parameters = this.options.parameters || '';
    if (parameters.length > 0) parameters += '&_=';

    try {
      this.url = url;
      if (this.options.method == 'get' && parameters.length > 0)
        this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;

      Ajax.Responders.dispatch('onCreate', this, this.transport);

      this.transport.open(this.options.method, this.url,
        this.options.asynchronous);

      if (this.options.asynchronous) {
        this.transport.onreadystatechange = this.onStateChange.bind(this);
        setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
      }

      this.setRequestHeaders();

      var body = this.options.postBody ? this.options.postBody : parameters;
      this.transport.send(this.options.method == 'post' ? body : null);

    } catch (e) {
      this.dispatchException(e);
    }
  },

  setRequestHeaders: function() {
    var requestHeaders =
      ['X-Requested-With', 'XMLHttpRequest',
       'X-Prototype-Version', Prototype.Version];

    if (this.options.method == 'post') {
      requestHeaders.push('Content-type',
        'application/x-www-form-urlencoded');

      /* Force "Connection: close" for Mozilla browsers to work around
       * a bug where XMLHttpReqeuest sends an incorrect Content-length
       * header. See Mozilla Bugzilla #246651.
       */
      if (this.transport.overrideMimeType)
        requestHeaders.push('Connection', 'close');
    }

    if (this.options.requestHeaders)
      requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);

    for (var i = 0; i < requestHeaders.length; i += 2)
      this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
  },

  onStateChange: function() {
    var readyState = this.transport.readyState;
    if (readyState != 1)
      this.respondToReadyState(this.transport.readyState);
  },

  header: function(name) {
    try {
      return this.transport.getResponseHeader(name);
    } catch (e) {}
  },

  evalJSON: function() {
    try {
      return eval(this.header('X-JSON'));
    } catch (e) {}
  },

  evalResponse: function() {
    try {
      return eval(this.transport.responseText);
    } catch (e) {
      this.dispatchException(e);
    }
  },

  respondToReadyState: function(readyState) {
    var event = Ajax.Request.Events[readyState];
    var transport = this.transport, json = this.evalJSON();

    if (event == 'Complete') {
      try {
        (this.options['on' + this.transport.status]
         || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
         || Prototype.emptyFunction)(transport, json);
      } catch (e) {
        this.dispatchException(e);
      }

      if ((this.header('Content-type') || '').match(/^text\/javascript/i))
        this.evalResponse();
    }

    try {
      (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
      Ajax.Responders.dispatch('on' + event, this, transport, json);
    } catch (e) {
      this.dispatchException(e);
    }

    /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
    if (event == 'Complete')
      this.transport.onreadystatechange = Prototype.emptyFunction;
  },

  dispatchException: function(exception) {
    (this.options.onException || Prototype.emptyFunction)(this, exception);
    Ajax.Responders.dispatch('onException', this, exception);
  }
});

Ajax.Updater = Class.create();

Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
  initialize: function(container, url, options) {
    this.containers = {
      success: container.success ? $(container.success) : $(container),
      failure: container.failure ? $(container.failure) :
        (container.success ? null : $(container))
    }

    this.transport = Ajax.getTransport();
    this.setOptions(options);

    var onComplete = this.options.onComplete || Prototype.emptyFunction;
    this.options.onComplete = (function(transport, object) {
      this.updateContent();
      onComplete(transport, object);
    }).bind(this);

    this.request(url);
  },

  updateContent: function() {
    var receiver = this.responseIsSuccess() ?
      this.containers.success : this.containers.failure;
    var response = this.transport.responseText;

    if (!this.options.evalScripts)
      response = response.stripScripts();

    if (receiver) {
      if (this.options.insertion) {
        new this.options.insertion(receiver, response);
      } else {
        Element.update(receiver, response);
      }
    }

    if (this.responseIsSuccess()) {
      if (this.onComplete)
        setTimeout(this.onComplete.bind(this), 10);
    }
  }
});

Ajax.PeriodicalUpdater = Class.create();
Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
  initialize: function(container, url, options) {
    this.setOptions(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);

    this.updater = {};
    this.container = container;
    this.url = url;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(request) {
    if (this.options.decay) {
      this.decay = (request.responseText == this.lastText ?
        this.decay * this.options.decay : 1);

      this.lastText = request.responseText;
    }
    this.timer = setTimeout(this.onTimerEvent.bind(this),
      this.decay * this.frequency * 1000);
  },

  onTimerEvent: function() {
    this.updater = new Ajax.Updater(this.container, this.url, this.options);
  }
});
document.getElementsByClassName = function(className, parentElement) {
  var children = ($(parentElement) || document.body).getElementsByTagName('*');
  return $A(children).inject([], function(elements, child) {
    if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
      elements.push(child);
    return elements;
  });
}

/*--------------------------------------------------------------------------*/

if (!window.Element) {
  var Element = new Object();
}

Object.extend(Element, {
  visible: function(element) {
    return $(element).style.display != 'none';
  },

  toggle: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      Element[Element.visible(element) ? 'hide' : 'show'](element);
    }
  },

  hide: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = 'none';
    }
  },

  show: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = '';
    }
  },

  remove: function(element) {
    element = $(element);
    element.parentNode.removeChild(element);
  },

  update: function(element, html) {
    $(element).innerHTML = html.stripScripts();
    setTimeout(function() {html.evalScripts()}, 10);
  },

  getHeight: function(element) {
    element = $(element);
    return element.offsetHeight;
  },

  classNames: function(element) {
    return new Element.ClassNames(element);
  },

  hasClassName: function(element, className) {
    if (!(element = $(element))) return;
    return Element.classNames(element).include(className);
  },

  addClassName: function(element, className) {
    if (!(element = $(element))) return;
    return Element.classNames(element).add(className);
  },

  removeClassName: function(element, className) {
    if (!(element = $(element))) return;
    return Element.classNames(element).remove(className);
  },

  // removes whitespace-only text node children
  cleanWhitespace: function(element) {
    element = $(element);
    for (var i = 0; i < element.childNodes.length; i++) {
      var node = element.childNodes[i];
      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
        Element.remove(node);
    }
  },

  empty: function(element) {
    return $(element).innerHTML.match(/^\s*$/);
  },

  scrollTo: function(element) {
    element = $(element);
    var x = element.x ? element.x : element.offsetLeft,
        y = element.y ? element.y : element.offsetTop;
    window.scrollTo(x, y);
  },

  getStyle: function(element, style) {
    element = $(element);
    var value = element.style[style.camelize()];
    if (!value) {
      if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(element, null);
        value = css ? css.getPropertyValue(style) : null;
      } else if (element.currentStyle) {
        value = element.currentStyle[style.camelize()];
      }
    }

    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
      if (Element.getStyle(element, 'position') == 'static') value = 'auto';

    return value == 'auto' ? null : value;
  },

  setStyle: function(element, style) {
    element = $(element);
    for (name in style)
      element.style[name.camelize()] = style[name];
  },

  getDimensions: function(element) {
    element = $(element);
    if (Element.getStyle(element, 'display') != 'none')
      return {width: element.offsetWidth, height: element.offsetHeight};

    // All *Width and *Height properties give 0 on elements with display none,
    // so enable the element temporarily
    var els = element.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = '';
    var originalWidth = element.clientWidth;
    var originalHeight = element.clientHeight;
    els.display = 'none';
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  },

  makePositioned: function(element) {
    element = $(element);
    var pos = Element.getStyle(element, 'position');
    if (pos == 'static' || !pos) {
      element._madePositioned = true;
      element.style.position = 'relative';
      // Opera returns the offset relative to the positioning context, when an
      // element is position relative but top and left have not been defined
      if (window.opera) {
        element.style.top = 0;
        element.style.left = 0;
      }
    }
  },

  undoPositioned: function(element) {
    element = $(element);
    if (element._madePositioned) {
      element._madePositioned = undefined;
      element.style.position =
        element.style.top =
        element.style.left =
        element.style.bottom =
        element.style.right = '';
    }
  },

  makeClipping: function(element) {
    element = $(element);
    if (element._overflow) return;
    element._overflow = element.style.overflow;
    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
      element.style.overflow = 'hidden';
  },

  undoClipping: function(element) {
    element = $(element);
    if (element._overflow) return;
    element.style.overflow = element._overflow;
    element._overflow = undefined;
  }
});

var Toggle = new Object();
Toggle.display = Element.toggle;

/*--------------------------------------------------------------------------*/

Abstract.Insertion = function(adjacency) {
  this.adjacency = adjacency;
}

Abstract.Insertion.prototype = {
  initialize: function(element, content) {
    this.element = $(element);
    this.content = content.stripScripts();

    if (this.adjacency && this.element.insertAdjacentHTML) {
      try {
        this.element.insertAdjacentHTML(this.adjacency, this.content);
      } catch (e) {
        if (this.element.tagName.toLowerCase() == 'tbody') {
          this.insertContent(this.contentFromAnonymousTable());
        } else {
          throw e;
        }
      }
    } else {
      this.range = this.element.ownerDocument.createRange();
      if (this.initializeRange) this.initializeRange();
      this.insertContent([this.range.createContextualFragment(this.content)]);
    }

    setTimeout(function() {content.evalScripts()}, 10);
  },

  contentFromAnonymousTable: function() {
    var div = document.createElement('div');
    div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
    return $A(div.childNodes[0].childNodes[0].childNodes);
  }
}

var Insertion = new Object();

Insertion.Before = Class.create();
Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
  initializeRange: function() {
    this.range.setStartBefore(this.element);
  },

  insertContent: function(fragments) {
    fragments.each((function(fragment) {
      this.element.parentNode.insertBefore(fragment, this.element);
    }).bind(this));
  }
});

Insertion.Top = Class.create();
Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
  initializeRange: function() {
    this.range.selectNodeContents(this.element);
    this.range.collapse(true);
  },

  insertContent: function(fragments) {
    fragments.reverse(false).each((function(fragment) {
      this.element.insertBefore(fragment, this.element.firstChild);
    }).bind(this));
  }
});

Insertion.Bottom = Class.create();
Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
  initializeRange: function() {
    this.range.selectNodeContents(this.element);
    this.range.collapse(this.element);
  },

  insertContent: function(fragments) {
    fragments.each((function(fragment) {
      this.element.appendChild(fragment);
    }).bind(this));
  }
});

Insertion.After = Class.create();
Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
  initializeRange: function() {
    this.range.setStartAfter(this.element);
  },

  insertContent: function(fragments) {
    fragments.each((function(fragment) {
      this.element.parentNode.insertBefore(fragment,
        this.element.nextSibling);
    }).bind(this));
  }
});

/*--------------------------------------------------------------------------*/

Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
  initialize: function(element) {
    this.element = $(element);
  },

  _each: function(iterator) {
    this.element.className.split(/\s+/).select(function(name) {
      return name.length > 0;
    })._each(iterator);
  },

  set: function(className) {
    this.element.className = className;
  },

  add: function(classNameToAdd) {
    if (this.include(classNameToAdd)) return;
    this.set(this.toArray().concat(classNameToAdd).join(' '));
  },

  remove: function(classNameToRemove) {
    if (!this.include(classNameToRemove)) return;
    this.set(this.select(function(className) {
      return className != classNameToRemove;
    }).join(' '));
  },

  toString: function() {
    return this.toArray().join(' ');
  }
}

Object.extend(Element.ClassNames.prototype, Enumerable);
var Field = {
  clear: function() {
    for (var i = 0; i < arguments.length; i++)
      $(arguments[i]).value = '';
  },

  focus: function(element) {
    $(element).focus();
  },

  present: function() {
    for (var i = 0; i < arguments.length; i++)
      if ($(arguments[i]).value == '') return false;
    return true;
  },

  select: function(element) {
    $(element).select();
  },

  activate: function(element) {
    element = $(element);
    element.focus();
    if (element.select)
      element.select();
  }
}

/*--------------------------------------------------------------------------*/

var Form = {
  serialize: function(form) {
    var elements = Form.getElements($(form));
    var queryComponents = new Array();

    for (var i = 0; i < elements.length; i++) {
      var queryComponent = Form.Element.serialize(elements[i]);
      if (queryComponent)
        queryComponents.push(queryComponent);
    }

    return queryComponents.join('&');
  },

  getElements: function(form) {
    form = $(form);
    var elements = new Array();

    for (tagName in Form.Element.Serializers) {
      var tagElements = form.getElementsByTagName(tagName);
      for (var j = 0; j < tagElements.length; j++)
        elements.push(tagElements[j]);
    }
    return elements;
  },

  getInputs: function(form, typeName, name) {
    form = $(form);
    var inputs = form.getElementsByTagName('input');

    if (!typeName && !name)
      return inputs;

    var matchingInputs = new Array();
    for (var i = 0; i < inputs.length; i++) {
      var input = inputs[i];
      if ((typeName && input.type != typeName) ||
          (name && input.name != name))
        continue;
      matchingInputs.push(input);
    }

    return matchingInputs;
  },

  disable: function(form) {
    var elements = Form.getElements(form);
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      element.blur();
      element.disabled = 'true';
    }
  },

  enable: function(form) {
    var elements = Form.getElements(form);
    for (var i = 0; i < elements.length; i++) {
      var element = elements[i];
      element.disabled = '';
    }
  },

  findFirstElement: function(form) {
    return Form.getElements(form).find(function(element) {
      return element.type != 'hidden' && !element.disabled &&
        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
    });
  },

  focusFirstElement: function(form) {
    Field.activate(Form.findFirstElement(form));
  },

  reset: function(form) {
    $(form).reset();
  }
}

Form.Element = {
  serialize: function(element) {
    element = $(element);
    var method = element.tagName.toLowerCase();
    var parameter = Form.Element.Serializers[method](element);

    if (parameter) {
      var key = encodeURIComponent(parameter[0]);
      if (key.length == 0) return;

      if (parameter[1].constructor != Array)
        parameter[1] = [parameter[1]];

      return parameter[1].map(function(value) {
        return key + '=' + encodeURIComponent(value);
      }).join('&');
    }
  },

  getValue: function(element) {
    element = $(element);
    var method = element.tagName.toLowerCase();
    var parameter = Form.Element.Serializers[method](element);

    if (parameter)
      return parameter[1];
  }
}

Form.Element.Serializers = {
  input: function(element) {
    switch (element.type.toLowerCase()) {
      case 'submit':
      case 'hidden':
      case 'password':
      case 'text':
        return Form.Element.Serializers.textarea(element);
      case 'checkbox':
      case 'radio':
        return Form.Element.Serializers.inputSelector(element);
    }
    return false;
  },

  inputSelector: function(element) {
    if (element.checked)
      return [element.name, element.value];
  },

  textarea: function(element) {
    return [element.name, element.value];
  },

  select: function(element) {
    return Form.Element.Serializers[element.type == 'select-one' ?
      'selectOne' : 'selectMany'](element);
  },

  selectOne: function(element) {
    var value = '', opt, index = element.selectedIndex;
    if (index >= 0) {
      opt = element.options[index];
      value = opt.value;
      if (!value && !('value' in opt))
        value = opt.text;
    }
    return [element.name, value];
  },

  selectMany: function(element) {
    var value = new Array();
    for (var i = 0; i < element.length; i++) {
      var opt = element.options[i];
      if (opt.selected) {
        var optValue = opt.value;
        if (!optValue && !('value' in opt))
          optValue = opt.text;
        value.push(optValue);
      }
    }
    return [element.name, value];
  }
}

/*--------------------------------------------------------------------------*/

var $F = Form.Element.getValue;

/*--------------------------------------------------------------------------*/

Abstract.TimedObserver = function() {}
Abstract.TimedObserver.prototype = {
  initialize: function(element, frequency, callback) {
    this.frequency = frequency;
    this.element   = $(element);
    this.callback  = callback;

    this.lastValue = this.getValue();
    this.registerCallback();
  },

  registerCallback: function() {
    setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
  },

  onTimerEvent: function() {
    var value = this.getValue();
    if (this.lastValue != value) {
      this.callback(this.element, value);
      this.lastValue = value;
    }
  }
}

Form.Element.Observer = Class.create();
Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
  getValue: function() {
    return Form.Element.getValue(this.element);
  }
});

Form.Observer = Class.create();
Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
  getValue: function() {
    return Form.serialize(this.element);
  }
});

/*--------------------------------------------------------------------------*/

Abstract.EventObserver = function() {}
Abstract.EventObserver.prototype = {
  initialize: function(element, callback) {
    this.element  = $(element);
    this.callback = callback;

    this.lastValue = this.getValue();
    if (this.element.tagName.toLowerCase() == 'form')
      this.registerFormCallbacks();
    else
      this.registerCallback(this.element);
  },

  onElementEvent: function() {
    var value = this.getValue();
    if (this.lastValue != value) {
      this.callback(this.element, value);
      this.lastValue = value;
    }
  },

  registerFormCallbacks: function() {
    var elements = Form.getElements(this.element);
    for (var i = 0; i < elements.length; i++)
      this.registerCallback(elements[i]);
  },

  registerCallback: function(element) {
    if (element.type) {
      switch (element.type.toLowerCase()) {
        case 'checkbox':
        case 'radio':
          Event.observe(element, 'click', this.onElementEvent.bind(this));
          break;
        case 'password':
        case 'text':
        case 'textarea':
        case 'select-one':
        case 'select-multiple':
          Event.observe(element, 'change', this.onElementEvent.bind(this));
          break;
      }
    }
  }
}

Form.Element.EventObserver = Class.create();
Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
  getValue: function() {
    return Form.Element.getValue(this.element);
  }
});

Form.EventObserver = Class.create();
Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
  getValue: function() {
    return Form.serialize(this.element);
  }
});
if (!window.Event) {
  var Event = new Object();
}

Object.extend(Event, {
  KEY_BACKSPACE: 8,
  KEY_TAB:       9,
  KEY_RETURN:   13,
  KEY_ESC:      27,
  KEY_LEFT:     37,
  KEY_UP:       38,
  KEY_RIGHT:    39,
  KEY_DOWN:     40,
  KEY_DELETE:   46,

  element: function(event) {
    return event.target || event.srcElement;
  },

  isLeftClick: function(event) {
    return (((event.which) && (event.which == 1)) ||
            ((event.button) && (event.button == 1)));
  },

  pointerX: function(event) {
    return event.pageX || (event.clientX +
      (document.documentElement.scrollLeft || document.body.scrollLeft));
  },

  pointerY: function(event) {
    return event.pageY || (event.clientY +
      (document.documentElement.scrollTop || document.body.scrollTop));
  },

  stop: function(event) {
    if (event.preventDefault) {
      event.preventDefault();
      event.stopPropagation();
    } else {
      event.returnValue = false;
      event.cancelBubble = true;
    }
  },

  // find the first node with the given tagName, starting from the
  // node the event was triggered on; traverses the DOM upwards
  findElement: function(event, tagName) {
    var element = Event.element(event);
    while (element.parentNode && (!element.tagName ||
        (element.tagName.toUpperCase() != tagName.toUpperCase())))
      element = element.parentNode;
    return element;
  },

  observers: false,

  _observeAndCache: function(element, name, observer, useCapture) {
    if (!this.observers) this.observers = [];
    if (element.addEventListener) {
      this.observers.push([element, name, observer, useCapture]);
      element.addEventListener(name, observer, useCapture);
    } else if (element.attachEvent) {
      this.observers.push([element, name, observer, useCapture]);
      element.attachEvent('on' + name, observer);
    }
  },

  unloadCache: function() {
    if (!Event.observers) return;
    for (var i = 0; i < Event.observers.length; i++) {
      Event.stopObserving.apply(this, Event.observers[i]);
      Event.observers[i][0] = null;
    }
    Event.observers = false;
  },

  observe: function(element, name, observer, useCapture) {
    var element = $(element);
    useCapture = useCapture || false;

    if (name == 'keypress' &&
        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
        || element.attachEvent))
      name = 'keydown';

    this._observeAndCache(element, name, observer, useCapture);
  },

  stopObserving: function(element, name, observer, useCapture) {
    var element = $(element);
    useCapture = useCapture || false;

    if (name == 'keypress' &&
        (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
        || element.detachEvent))
      name = 'keydown';

    if (element.removeEventListener) {
      element.removeEventListener(name, observer, useCapture);
    } else if (element.detachEvent) {
      element.detachEvent('on' + name, observer);
    }
  }
});

/* prevent memory leaks in IE */
Event.observe(window, 'unload', Event.unloadCache, false);
var Position = {
  // set to true if needed, warning: firefox performance problems
  // NOT neeeded for page scrolling, only if draggable contained in
  // scrollable elements
  includeScrollOffsets: false,

  // must be called before calling withinIncludingScrolloffset, every time the
  // page is scrolled
  prepare: function() {
    this.deltaX =  window.pageXOffset
                || document.documentElement.scrollLeft
                || document.body.scrollLeft
                || 0;
    this.deltaY =  window.pageYOffset
                || document.documentElement.scrollTop
                || document.body.scrollTop
                || 0;
  },

  realOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element);
    return [valueL, valueT];
  },

  cumulativeOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
    } while (element);
    return [valueL, valueT];
  },

  positionedOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      element = element.offsetParent;
      if (element) {
        p = Element.getStyle(element, 'position');
        if (p == 'relative' || p == 'absolute') break;
      }
    } while (element);
    return [valueL, valueT];
  },

  offsetParent: function(element) {
    if (element.offsetParent) return element.offsetParent;
    if (element == document.body) return element;

    while ((element = element.parentNode) && element != document.body)
      if (Element.getStyle(element, 'position') != 'static')
        return element;

    return document.body;
  },

  // caches x/y coordinate pair to use with overlap
  within: function(element, x, y) {
    if (this.includeScrollOffsets)
      return this.withinIncludingScrolloffsets(element, x, y);
    this.xcomp = x;
    this.ycomp = y;
    this.offset = this.cumulativeOffset(element);

    return (y >= this.offset[1] &&
            y <  this.offset[1] + element.offsetHeight &&
            x >= this.offset[0] &&
            x <  this.offset[0] + element.offsetWidth);
  },

  withinIncludingScrolloffsets: function(element, x, y) {
    var offsetcache = this.realOffset(element);

    this.xcomp = x + offsetcache[0] - this.deltaX;
    this.ycomp = y + offsetcache[1] - this.deltaY;
    this.offset = this.cumulativeOffset(element);

    return (this.ycomp >= this.offset[1] &&
            this.ycomp <  this.offset[1] + element.offsetHeight &&
            this.xcomp >= this.offset[0] &&
            this.xcomp <  this.offset[0] + element.offsetWidth);
  },

  // within must be called directly before
  overlap: function(mode, element) {
    if (!mode) return 0;
    if (mode == 'vertical')
      return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
        element.offsetHeight;
    if (mode == 'horizontal')
      return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
        element.offsetWidth;
  },

  clone: function(source, target) {
    source = $(source);
    target = $(target);
    target.style.position = 'absolute';
    var offsets = this.cumulativeOffset(source);
    target.style.top    = offsets[1] + 'px';
    target.style.left   = offsets[0] + 'px';
    target.style.width  = source.offsetWidth + 'px';
    target.style.height = source.offsetHeight + 'px';
  },

  page: function(forElement) {
    var valueT = 0, valueL = 0;

    var element = forElement;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;

      // Safari fix
      if (element.offsetParent==document.body)
        if (Element.getStyle(element,'position')=='absolute') break;

    } while (element = element.offsetParent);

    element = forElement;
    do {
      valueT -= element.scrollTop  || 0;
      valueL -= element.scrollLeft || 0;
    } while (element = element.parentNode);

    return [valueL, valueT];
  },

  clone: function(source, target) {
    var options = Object.extend({
      setLeft:    true,
      setTop:     true,
      setWidth:   true,
      setHeight:  true,
      offsetTop:  0,
      offsetLeft: 0
    }, arguments[2] || {})

    // find page position of source
    source = $(source);
    var p = Position.page(source);

    // find coordinate system to use
    target = $(target);
    var delta = [0, 0];
    var parent = null;
    // delta [0,0] will do fine with position: fixed elements,
    // position:absolute needs offsetParent deltas
    if (Element.getStyle(target,'position') == 'absolute') {
      parent = Position.offsetParent(target);
      delta = Position.page(parent);
    }

    // correct by body offsets (fixes Safari)
    if (parent == document.body) {
      delta[0] -= document.body.offsetLeft;
      delta[1] -= document.body.offsetTop;
    }

    // set position
    if(options.setLeft)   target.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
    if(options.setTop)    target.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
    if(options.setWidth)  target.style.width = source.offsetWidth + 'px';
    if(options.setHeight) target.style.height = source.offsetHeight + 'px';
  },

  absolutize: function(element) {
    element = $(element);
    if (element.style.position == 'absolute') return;
    Position.prepare();

    var offsets = Position.positionedOffset(element);
    var top     = offsets[1];
    var left    = offsets[0];
    var width   = element.clientWidth;
    var height  = element.clientHeight;

    element._originalLeft   = left - parseFloat(element.style.left  || 0);
    element._originalTop    = top  - parseFloat(element.style.top || 0);
    element._originalWidth  = element.style.width;
    element._originalHeight = element.style.height;

    element.style.position = 'absolute';
    element.style.top    = top + 'px';;
    element.style.left   = left + 'px';;
    element.style.width  = width + 'px';;
    element.style.height = height + 'px';;
  },

  relativize: function(element) {
    element = $(element);
    if (element.style.position == 'relative') return;
    Position.prepare();

    element.style.position = 'relative';
    var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
    var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);

    element.style.top    = top + 'px';
    element.style.left   = left + 'px';
    element.style.height = element._originalHeight;
    element.style.width  = element._originalWidth;
  }
}

// Safari returns margins on body which is incorrect if the child is absolutely
// positioned.  For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
  Position.cumulativeOffset = function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.offsetTop  || 0;
      valueL += element.offsetLeft || 0;
      if (element.offsetParent == document.body)
        if (Element.getStyle(element, 'position') == 'absolute') break;

      element = element.offsetParent;
    } while (element);

    return [valueL, valueT];
  }
}

/*plik lightbox.js*/
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
/*

	Table of Contents
	-----------------
	Configuration
	Global Variables

	Extending Built-in Objects	
	- Object.extend(Element)
	- Array.prototype.removeDuplicates()
	- Array.prototype.empty()

	Lightbox Class Declaration
	- initialize()
	- updateImageList()
	- start()
	- changeImage()
	- resizeImageContainer()
	- showImage()
	- updateDetails()
	- updateNav()
	- enableKeyboardNav()
	- disableKeyboardNav()
	- keyboardAction()
	- preloadNeighborImages()
	- end()
	
	Miscellaneous Functions
	- getPageScroll()
	- getPageSize()
	- getKey()
	- listenKey()
	- showSelectBoxes()
	- hideSelectBoxes()
	- showFlash()
	- hideFlash()
	- pause()
	- initLightbox()
	
	Function Calls
	- addLoadEvent(initLightbox)
	
*/
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "/images/loading.gif";		
var fileBottomNavCloseImage = "/images/closelabel.gif";

var overlayOpacity = 0.8;	// controls transparency of shadow overlay

var animate = true;			// toggles resizing animations
var resizeSpeed = 7;		// controls the speed of the image resizing animations (1=slowest and 10=fastest)

var borderSize = 10;		//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(animate == true){
	overlayDuration = 0.2;	// shadow fade in/out duration
	if(resizeSpeed > 10){ resizeSpeed = 10;}
	if(resizeSpeed < 1){ resizeSpeed = 1;}
	resizeDuration = (11 - resizeSpeed) * 0.15;
} else { 
	overlayDuration = 0;
	resizeDuration = 0;
}

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setLeft: function(element,l) {
	   	element = $(element);
    	element.style.left = l +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
    for(i = 0; i < this.length; i++){
        for(j = this.length-1; j>i; j--){        
            if(this[i][0] == this[j][0]){
                this.splice(j,1);
            }
        }
    }
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

//
//	Lightbox Class Declaration
//	- initialize()
//	- start()
//	- changeImage()
//	- resizeImageContainer()
//	- showImage()
//	- updateDetails()
//	- updateNav()
//	- enableKeyboardNav()
//	- disableKeyboardNav()
//	- keyboardNavAction()
//	- preloadNeighborImages()
//	- end()
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Calls updateImageList and then
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		
		this.updateImageList();

		// Code inserts html at the bottom of the page that looks similar to this:
		//
		//	<div id="overlay"></div>
		//	<div id="lightbox">
		//		<div id="outerImageContainer">
		//			<div id="imageContainer">
		//				<img id="lightboxImage">
		//				<div style="" id="hoverNav">
		//					<a href="#" id="prevLink"></a>
		//					<a href="#" id="nextLink"></a>
		//				</div>
		//				<div id="loading">
		//					<a href="#" id="loadingLink">
		//						<img src="images/loading.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//		<div id="imageDataContainer">
		//			<div id="imageData">
		//				<div id="imageDetails">
		//					<span id="caption"></span>
		//					<span id="numberDisplay"></span>
		//				</div>
		//				<div id="bottomNav">
		//					<a href="#" id="bottomNavClose">
		//						<img src="images/close.gif">
		//					</a>
		//				</div>
		//			</div>
		//		</div>
		//	</div>


		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.style.display = 'none';
		objOverlay.onclick = function() { myLightbox.end(); }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objLightbox.onclick = function(e) {	// close Lightbox is user clicks shadow overlay
			if (!e) var e = window.event;
			var clickObj = Event.element(e).id;
			if ( clickObj == 'lightbox') {
				myLightbox.end();
			}
		};
		objBody.appendChild(objLightbox);
			
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
		// If animations are turned off, it will be hidden as to prevent a flicker of a
		// white 250 by 250 box.
		if(animate){
			Element.setWidth('outerImageContainer', 250);
			Element.setHeight('outerImageContainer', 250);			
		} else {
			Element.setWidth('outerImageContainer', 1);
			Element.setHeight('outerImageContainer', 1);			
		}

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
	
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
	},


	//
	// updateImageList()
	// Loops through anchor tags looking for 'lightbox' references and applies onclick
	// events to appropriate links. You can rerun after dynamically adding images w/ajax.
	//
	updateImageList: function() {	
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		// loop through all area tags
		// todo: combine anchor & area tag loops
		for (var i=0; i< areas.length; i++){
			var area = areas[i];
			
			var relAttribute = String(area.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				area.onclick = function () {myLightbox.start(this); return false;}
			}
		}
	},
	
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();
		hideFlash();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });

		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName( imageLink.tagName);

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		Element.show('lightbox');
		
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {	
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		if(animate){ Element.show('loading');}
		Element.hide('lightboxImage');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
		Element.hide('numberDisplay');		
		
		imgPreloader = new Image();
		
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
			
			imgPreloader.onload=function(){};	//	clear onLoad, IE behaves irratically with animated gifs otherwise 
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		// get curren width and height
		this.widthCurrent = Element.getWidth('outerImageContainer');
		this.heightCurrent = Element.getHeight('outerImageContainer');

		// get new width and height
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));

		// scalars based on change from old to new
		this.xScale = ( widthNew / this.widthCurrent) * 100;
		this.yScale = ( heightNew / this.heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = this.widthCurrent - widthNew;
		hDiff = this.heightCurrent - heightNew;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth( 'imageDataContainer', widthNew);

		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){	myLightbox.updateDetails(); } });
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {
	
		// if caption is not null
		if(imageArray[activeImage][1]){
			Element.show('caption');
			Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		}
		
		// if image is part of set display 'Image x of x' 
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Zdjęcie " + eval(activeImage + 1) + " z " + imageArray.length);
		}

		new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				// update overlay size and update nav
				var arrayPageSize = getPageSize();
				Element.setHeight('overlay', arrayPageSize[1]);
				myLightbox.updateNav();
				}
			} 
		);
	},

	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		Element.show('hoverNav');				

		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
			escapeKey = 27;
		} else { // mozilla
			keycode = e.keyCode;
			escapeKey = e.DOM_VK_ESCAPE;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){	// close lightbox
			myLightbox.end();
		} else if((key == 'p') || (keycode == 37)){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if((key == 'n') || (keycode == 39)){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}

	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		new Effect.Fade('overlay', { duration: overlayDuration});
		showSelectBoxes();
		showFlash();
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }
	
// ---------------------------------------------------

function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}

	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}

}


// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//

function pause(ms){
	var date = new Date();
	curDate = null;
	do{var curDate = new Date();}
	while( curDate - date < ms);
}
/*
function pause(numberMillis) {
	var curently = new Date().getTime() + sender;
	while (new Date().getTime();	
}
*/
// ---------------------------------------------------



function initLightbox() { myLightbox = new Lightbox(); }
Event.observe(window, 'load', initLightbox, false);

/*plik functions.js*/
function init(){
	var stretchers = document.getElementsByClassName('tab-box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, height: true, duration: 400}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
function init_blok_najczesciej(){
	var stretchers = document.getElementsByClassName('tab-box-najczesciej');
	var toggles = document.getElementsByClassName('tab-najczesciej');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, height: true, duration: 400}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}
function init_blok_warto_przeczytac(){
	var stretchers = document.getElementsByClassName('tab-box-warto-przeczytac');
	var toggles = document.getElementsByClassName('tab-warto-przeczytac');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, height: true, duration: 400}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
	if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}

function articlePrint (plik,width,height)
{
	var w=800, h=600;
	okno = null;
	if(window.screen)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	dane="width="+width+",height="+height+",left="+(w-width)/2+",top="+(h-height)/2+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no";
	okno=window.open(plik,'pop',dane);
}

function SubmitImage()
{
	document.form.action = "/dodaj_artykul.html";
	document.form.submit()
}
function SubmitForm(nazwa)
{
	switch(nazwa)
	{
		case 'Zapisz':
		{
			document.form.action = "/dodaj_artykul.html";
			document.form.zapisz = nazwa;
			document.form.submit()
		}
	}
}
function DelImage(nazwa)
{
	var zmienna = "\""+nazwa+"\"";
	document.form.method = "POST";
	document.form.action = "/dodaj_artykul.html";
	document.form.usun = zmienna;
	alert(document.form.usun);
	
	document.form.submit()
}

// wyswietlanie wskazówek przy inputach
function setVisible(x)
{
switch (x)
{
case 'reg.login' : current=(document.getElementById('hint-login').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-login').style.visibility = current; break;
case 'reg.haslo' : current=(document.getElementById('hint-haslo').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-haslo').style.visibility = current; break;
case 'reg.haslo2' : current=(document.getElementById('hint-haslo2').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-haslo2').style.visibility = current; break;
case 'reg.email' : current=(document.getElementById('hint-email').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-email').style.visibility = current; break;
case 'reg.plec' : current=(document.getElementById('hint-plec').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-plec').style.visibility = current; break;
case 'reg.profil.szkoly' : current=(document.getElementById('hint-profil').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-profil').style.visibility = current; break;
case 'reg.wielkosc.miasta' : current=(document.getElementById('hint-wielkosc').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-wielkosc').style.visibility = current; break;
case 'reminder' : current=(document.getElementById('hint-reminder').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-reminder').style.visibility = current; break;
case 'tytul' : current=(document.getElementById('hint-tytul').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-tytul').style.visibility = current; break;
case 'zajawka' : current=(document.getElementById('hint-zajawka').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-zajawka').style.visibility = current; break;
case 'zdjecie' : current=(document.getElementById('hint-zdjecie').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-zdjecie').style.visibility = current; break;
case 'tagi' : current=(document.getElementById('hint-tagi').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-tagi').style.visibility = current; break;
case 'uwagi' : current=(document.getElementById('hint-uwagi').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-uwagi').style.visibility = current; break;
case 'status' : current=(document.getElementById('hint-status').style.visibility == 'visible') ? 'hidden' : 'visible';
				   document.getElementById('hint-status').style.visibility = current; break;
}
}
// zliczanie liter pozostalych do wpisania

function pobierz_parametr()
{
	ilosc = document.getElementsByName('ankieta_odpowiedz');
	
	for (var i=0; i < ilosc.length; i++)
	{
		if(ilosc[i].checked==true)
		{
			location.href =ilosc[i].value;
		}
	}
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("#CHAR#",length);
}

// schowaj submenu po kliknieciu poza nim
function menuHide(speed)
{
	$j('.subcat').hide(speed);  
}

// rozwijanie submenu
function menu()
{
	$j("body").bind("click",function()  
	{
		menuHide(100);
	});
	
	$j('.expand-arrow').click(function()
	{
		$j(this).parents('li.h-drop').children('.subcat').toggle('slideDown'); 
		$j('.subcat:visible').not($j(this).parents('li.h-drop').children('.subcat')).hide(100);  
		return false;
	});

}

// chowanie kontentu
function prezentacja_zwijaj(rid)
{
	current=(document.getElementById(rid).style.display == 'none') ? 'block' : 'none';
	document.getElementById(rid).style.display = current;
	
	if ( current == 'none'){
	document.getElementById('roller').innerHTML = '<a class="roll" href="#" onclick="prezentacja_zwijaj(\'tematy-numeru\'); return false;">Rozwiń <img src="/images/down_arrow.gif" alt="Rozwiń" border="0"/></a>';
	}else{
	document.getElementById('roller').innerHTML = '<a class="roll" href="#" onclick="prezentacja_zwijaj(\'tematy-numeru\'); return false;">Zwiń <img src="/images/up_arrow.gif" alt="Zwiń" border="0"/></a>';	
	}
	
	var waznosc=new Date();
	var coockie_name = 'presentation-tabs-status'

	waznosc.setTime(waznosc.getTime()+1000*60*60*24*7);
	//ustawianie daty wygaśnięcia (na 7 dni)
	document.cookie = coockie_name+"="+current+";path=/;expires=" + waznosc.toGMTString();
	//tworzy cookie, parametr
}

function faq(div_styl, div_styl_pyt, pyt_styl, img, id)
{
	span_style=(document.getElementById(pyt_styl).style.fontWeight == 'bold') ? 'normal' : 'bold';
	document.getElementById(pyt_styl).style.fontWeight = span_style;
	
	if (document.getElementById(pyt_styl).style.fontWeight == 'bold')
	{
		document.getElementById(div_styl).style.border = '1px dashed #9cd3f2';
		document.getElementById(div_styl_pyt).style.borderBottom = '1px dashed #9cd3f2';
	}
	else
	{
		document.getElementById(div_styl).style.border = 'none';
		document.getElementById(div_styl_pyt).style.borderBottom = 'none';
	}
	
	img_src=(document.getElementById(img).src == 'http://'+location.host+'/images/expanded.gif') ? 'http://'+location.host+'/images/collapsed.gif' : 'http://'+location.host+'/images/expanded.gif';
	document.getElementById(img).src = img_src;
	
	current=(document.getElementById(id).style.display == 'none') ? 'block' : 'none';
	document.getElementById(id).style.display = current;
}


function podglad() 
{ 
    window.open("/podglad.html","myNewWin","width=620,height=600,menubar=no, toolbar=no, location=no, scrollbars=yes"); 
}


/*plik validation.js*/
/*--------------------------------------------------------------------------------------------*\

  validation.js
  -------------

  v2.3, June 2007

  This script provides generic validation for any web form. For a discussion and example usage 
  of this script, go to http://www.benjaminkeen.com/software/js_validation

  This script is written by Ben Keen with additional code contributed by Mihai Ionescu and 
  Nathan Howard. It is free to distribute, to re-write - to do what ever you want with it.

  Before using it, please read the following disclaimer.

  THIS SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS WITHOUT WARRANTY OF ANY KIND. BENJAMINKEEN.COM 
  SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF 
  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL BENJAMINKEEN.COM BE 
  LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF BENJAMINKEEN.COM 
  HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. USER AGREES TO HOLD 
  BENJAMINKEEN.COM HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.

\*--------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------*\
  Function: validateFields()
  Purpose:  generic form field validation.
  Parameters: form  - the name of the form to validate
              rules - an array of the validation rules. Each rule is a string of the form:

   "[if:FIELDNAME=VALUE,]REQUIREMENT,fieldname[,fieldname2 [,fieldname3, date_flag]],error message"

              if:FIELDNAME=VALUE,   This allows us to only validate a field only if a fieldname 
                       FIELDNAME has a value VALUE. This option allows for nesting; i.e. you can 
                       have multiple if clauses, separated by a comma. They will be examined in the 
                       order in which they appear in the line.

              Valid REQUIREMENT strings are: 
                "required"     - field must be filled in
                "digits_only"  - field must contain digits only
                "is_alpha"     - field must only contain alphanumeric characters (0-9, a-Z)
                "custom_alpha" - field must be of the custom format specified.
                      fieldname:  the name of the field
                      fieldname2: a character or sequence of special characters. These characters are:
                          L   An uppercase Letter.          V   An uppercase Vowel.
                          l   A lowercase letter.           v   A lowercase vowel.
                          D   A letter (upper or lower).    F   A vowel (upper or lower).
                          C   An uppercase Consonant.       x   Any number, 0-9.
                          c   A lowercase consonant.        X   Any number, 1-9.
                          E   A consonant (upper or lower).
                "reg_exp"      - field must match the supplied regular expression.  
                      fieldname:  the name of the field
                      fieldname2: the regular expression
                      fieldname3: (optional) flags for the reg exp (like i for case insensitive
                "letters_only" - field must only contains letters (a-Z)

                "length=X"     - field has to be X characters long
                "length=X-Y"   - field has to be between X and Y (inclusive) characters long
                "length>X"     - field has to be greater than X characters long
                "length>=X"    - field has to be greater than or equal to X characters long
                "length<X"     - field has to be less than X characters long
                "length<=X"    - field has to be less than or equal to X characters long
                
                "valid_email"  - field has to be a valid email address
                "valid_date"   - field has to be a valid date
                      fieldname:  MONTH 
                      fieldname2: DAY 
                      fieldname3: YEAR
                      date_flag:  "later_date" / "any_date"
                "same_as"      - fieldname is the same as fieldname2 (for password comparison)

                "range=X-Y"    - field must be a number between the range of X and Y inclusive
                "range>X"      - field must be a number greater than X
                "range>=X"     - field must be a number greater than or equal to X
                "range<X"      - field must be a number less than X
                "range<=X"     - field must be a number less than or equal to X

  Comments:   With both digits_only, is_alpha, letters_only and valid_email options, if the empty 
              string is passed in it won't generate an error, thus allowing validation of 
              non-required fields. So, for example, if you want a field to be a valid email address, 
              provide validation for both "required" and "valid_email".
\*------------------------------------------------------------------------------------------------*/
function validateFields(form, rules)
{
  // loop through rules
  for (var i=0; i<rules.length; i++)
  {
    // split row into component parts 
    var row = rules[i].split(",");

    // while the row begins with "if:..." test the condition. If true, strip the
    // if:..., part and continue evaluating the rest of the line. Keep repeating 
    // this while the line begins with an if-condition. If it fails any of the 
    // conditions, don't bother validating the rest of the line.
    var satisfiesIfConditions = true;
    while (row[0].match("^if:"))
    {
      var condition = row[0];
      condition = condition.replace("if:", "");

      // check if it's a = or != test
      var comparison = "equal";
      var parts = new Array();
      if (condition.search("!=") != -1)
      {
        parts = condition.split("!=");
        comparison = "not_equal";
      }
      else
        parts = condition.split("=");
    
      var fieldToCheck = parts[0];
      var valueToCheck = parts[1];
      
      // find value of FIELDNAME for conditional check
      var fieldnameValue = "";
      if (form[fieldToCheck].type == undefined) // RADIO
      {
        for (var j=0; j<form[fieldToCheck].length; j++)
        {
          if (form[fieldToCheck][j].checked)
            fieldnameValue = form[fieldToCheck][j].value;
        }
      }
      // single checkbox      
      else if (form[fieldToCheck].type == "checkbox")
      {
        if (form[fieldToCheck].checked)
          fieldnameValue = form[parts[0]].value;
      }      
      // all other field types
      else
        fieldnameValue = form[parts[0]].value;

      // if the VALUE is NOT the same, we don't need to validate this field. Return.
      if (comparison == "equal" &&  fieldnameValue != valueToCheck)
      {
        satisfiesIfConditions = false;
        break;
      }
      else if (comparison == "not_equal" && fieldnameValue == valueToCheck)
      {
        satisfiesIfConditions = false;
        break;      
      }
      else
        row.shift();    // remove this if-condition from line, and continue validating line
    }

    if (!satisfiesIfConditions)
      continue;


    var requirement = row[0];
    var fieldName   = row[1];

    // depending on the validation test, store the incoming strings for use later...
    if (row.length == 6)        // valid_date
    {
      var fieldName2   = row[2];
      var fieldName3   = row[3];
      var date_flag    = row[4];
      var errorMessage = row[5];
    }
    else if (row.length == 5)     // reg_exp (WITH flags like g, i, m)
    {
      var fieldName2   = row[2];
      var fieldName3   = row[3];
      var errorMessage = row[4];
    }
    else if (row.length == 4)     // same_as, custom_alpha, reg_exp (without flags like g, i, m)
    {
      var fieldName2   = row[2];
      var errorMessage = row[3];
    }
    else
      var errorMessage = row[2];    // everything else!


    // if the requirement is "length...", rename requirement to "length" for switch statement
    if (requirement.match("^length"))
    {
      var lengthRequirements = requirement;
      requirement = "length";
    }

    // if the requirement is "range=...", rename requirement to "range" for switch statement
    if (requirement.match("^range"))
    {
      var rangeRequirements = requirement;
      requirement = "range";
    }


    // now, validate whatever is required of the field
    switch (requirement)
    {
      case "required":
     
        // if radio buttons or multiple checkboxes:
        if (form[fieldName].type == undefined)
        {
          var oneIsChecked = false;
          for (var j=0; j<form[fieldName].length; j++)
          {
            if (form[fieldName][j].checked)
              oneIsChecked = true;
          }
          if (!oneIsChecked)
          {
            alertMessage(form[fieldName], errorMessage);
            return false;           
          }
        }
        else if (form[fieldName].type == "select-multiple")
        {          
          var oneIsSelected = false;
          for (k=0; k<form[fieldName].length; k++)
          {
            if (form[fieldName][k].selected)
              oneIsSelected = true;
          }

          // if no options have been selected, or if there ARE no options in the multi-select 
          // dropdown, return false
          if (!oneIsSelected || form[fieldName].length == 0)
          {
            alertMessage(form[fieldName], errorMessage);
            return false;          
          }
        }
        // a single checkbox
        else if (form[fieldName].type == "checkbox")
        {
          if (!form[fieldName].checked)
          {
            alertMessage(form[fieldName], errorMessage);
            return false;           
          }
        }
        // otherwise, just perform ordinary "required" check.
        else if (!form[fieldName].value)
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "digits_only":       
        if (form[fieldName].value && form[fieldName].value.match(/\D/))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "letters_only": 
        if (form[fieldName].value && form[fieldName].value.match(/[^a-zA-Z]/))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "is_alpha": 
        if (form[fieldName].value && form[fieldName].value.match(/\W/))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "custom_alpha":
        var conversion = {
          "L": "[A-Z]",
          "V": "[AEIOU]",
          "l": "[a-z]",
          "v": "[aeiou]",
          "D": "[a-zA-Z]",
          "F": "[aeiouAEIOU]",
          "C": "[BCDFGHJKLMNPQRSTVWXYZ]",
          "x": "[0-9]",
          "c": "[bcdfghjklmnpqrstvwxyz]",
          "X": "[1-9]",
          "E": "[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]"
            };

        var reg_exp_str = "";
        for (j=0; j<fieldName2.length; j++)
        {
          if (conversion[fieldName2.charAt(j)])
            reg_exp_str += conversion[fieldName2.charAt(j)];
          else
            reg_exp_str += fieldName2.charAt(j);
        }
        var reg_exp = new RegExp(reg_exp_str);

        if (form[fieldName].value && reg_exp.exec(form[fieldName].value) == null)
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }        
        break;

      case "reg_exp":
        var reg_exp_str = fieldName2;

        // rather crumby, but...
        if (row.length == 5)
          var reg_exp = new RegExp(reg_exp_str, fieldName3);
        else
          var reg_exp = new RegExp(reg_exp_str);

        if (form[fieldName].value && reg_exp.exec(form[fieldName].value) == null)
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }        
        break;

      case "length":
        comparison_rule = "";
        rule_string = "";

        // if-else order is important here: needs to check for >= before >
        if      (lengthRequirements.match(/length=/))
        { 
          comparison_rule = "equal"; 
          rule_string = lengthRequirements.replace("length=", ""); 
        }
        else if (lengthRequirements.match(/length>=/))
        {
          comparison_rule = "greater_than_or_equal"; 
          rule_string = lengthRequirements.replace("length>=", "");
        }
        else if (lengthRequirements.match(/length>/))
        {
          comparison_rule = "greater_than"; 
          rule_string = lengthRequirements.replace("length>", "");
        }
        else if (lengthRequirements.match(/length<=/))
        {
          comparison_rule = "less_than_or_equal"; 
          rule_string = lengthRequirements.replace("length<=", "");
        }        
        else if (lengthRequirements.match(/length</))
        {
          comparison_rule = "less_than"; 
          rule_string = lengthRequirements.replace("length<", "");
        }

        // now perform the appropriate validation
        switch (comparison_rule)
        {
          case "greater_than_or_equal":
            if (!(form[fieldName].value.length >= parseInt(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "greater_than":
            if (!(form[fieldName].value.length > parseInt(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "less_than_or_equal":
            if (!(form[fieldName].value.length <= parseInt(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "less_than":
            if (!(form[fieldName].value.length < parseInt(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "equal":
            var range_or_exact_number = rule_string.match(/[^_]+/);
            var fieldCount = range_or_exact_number[0].split("-");
    
            // if the user supplied two length fields, make sure the field is within that range
            if (fieldCount.length == 2)
            {
              if (form[fieldName].value.length < fieldCount[0] || form[fieldName].value.length > fieldCount[1])
              {
                alertMessage(form[fieldName], errorMessage);
                return false;
              }
            }
    
            // otherwise, check it's EXACTLY the size the user specified 
            else
            {
              if (form[fieldName].value.length != fieldCount[0])
              {
                alertMessage(form[fieldName], errorMessage);
                return false;
              }
            }     

            break;
        }
        break;

      // this is also true if field is empty [should be same for digits_only]
      case "valid_email":
        if (form[fieldName].value && !isValidEmail(form[fieldName].value))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;         
        }
        break;

      case "valid_date":

        // this is written for future extensibility of isValidDate function to allow 
        // checking for dates BEFORE today, AFTER today, IS today and ANY day.
        var isLaterDate = false;
        if    (date_flag == "later_date")
          isLaterDate = true;
        else if (date_flag == "any_date")
          isLaterDate = false;

        if (!isValidDate(form[fieldName].value, form[fieldName2].value, form[fieldName3].value, isLaterDate))
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }
        break;

      case "same_as":
        if (form[fieldName].value != form[fieldName2].value)
        {
          alertMessage(form[fieldName], errorMessage);
          return false;
        }       
        break;

      case "range":
     
        comparison_rule = "";
        rule_string = "";

        // if-else order is important here: needs to check for >= before >
        if      (rangeRequirements.match(/range=/))
        { 
          comparison_rule = "equal";
          rule_string = rangeRequirements.replace("range=", ""); 
        }
        else if (rangeRequirements.match(/range>=/))
        {
          comparison_rule = "greater_than_or_equal";
          rule_string = rangeRequirements.replace("range>=", "");
        }
        else if (rangeRequirements.match(/range>/))
        {
          comparison_rule = "greater_than";
          rule_string = rangeRequirements.replace("range>", "");
        }
        else if (rangeRequirements.match(/range<=/))
        {
          comparison_rule = "less_than_or_equal";
          rule_string = rangeRequirements.replace("range<=", "");
        }        
        else if (rangeRequirements.match(/range</))
        {
          comparison_rule = "less_than";
          rule_string = rangeRequirements.replace("range<", "");
        }

        // now perform the appropriate validation
        switch (comparison_rule)
        {
          case "greater_than_or_equal":
            if (!(form[fieldName].value >= Number(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "greater_than":
            if (!(form[fieldName].value > Number(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "less_than_or_equal":
            if (!(form[fieldName].value <= Number(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "less_than":
            if (!(form[fieldName].value < Number(rule_string)))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;

          case "equal":
            var rangeValues = rule_string.split("-");
            
            // if the user supplied two length fields, make sure the field is within that range
            if ((form[fieldName].value < Number(rangeValues[0])) || (form[fieldName].value > Number(rangeValues[1])))
            {
              alertMessage(form[fieldName], errorMessage);
              return false;
            }
            break;
        }
        break;

      case "function":
        custom_function = fieldName;
        if (!(eval(custom_function + "()")))
          return false;
        break;

      default:
        alert("Unknown requirement flag in validateFields(): " + requirement);
        return false;
    }
  }
  
  return true;
}


/*--------------------------------------------------------------------------------------------*\
  Function: alertMessage()
  Purpose:  simple helper function which alerts a message, then focuses on and highlights 
            a particular field.
\*--------------------------------------------------------------------------------------------*/
function alertMessage(obj, message)
{ 
  var backgroundColor = "#F2F9FF";

  alert(message);

  // if "obj" is an array: it's a radio button. Focus on the first element.
  if (obj.type == undefined)
    obj[0].focus();
  else
  {
    obj.style.background = backgroundColor;
    obj.focus();
  }
  return false;
}


/*--------------------------------------------------------------------------------------------*\
  Function: isValidEmail
  Purpose:  tests a string is a valid email
\*--------------------------------------------------------------------------------------------*/
function isValidEmail(str)
{
  // trim starting / ending whitespace
  str = str.replace(/^\s*/, "");
  str = str.replace(/\s*$/, "");

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)

  if (str.indexOf(at)==-1)
    return false
  
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    return false
  
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    return false

  if (str.indexOf(at,(lat+1))!=-1)
    return false

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    return false

  if (str.indexOf(dot,(lat+2))==-1)
    return false

  if (str.indexOf(" ")!=-1)
    return false

  return true;
}


// helper function to check to see if a string is empty
function isEmpty(str)
{  
  return ((str == null) || (str.length == 0));
}


/*--------------------------------------------------------------------------------------------*\
  Function: isWhitespace()
  Purpose:  Returns true if string parameter is empty or whitespace characters only.
\*--------------------------------------------------------------------------------------------*/
function isWhitespace(s)
{
  var i;

  // Is s empty?
  if (isEmpty(s)) return true;

  for (var i=0; i<s.length; i++)
  {   
    var c = s.charAt(i);
    if (whitespace.indexOf(c) == -1)
      return false;
  }

  return true;
}


/*----------------------------------------------------------------------------*\
  Function:   isValidDate()
  Purpose:    to check an incoming date is valid. If any of the date parameters  
              fail, it returns a string message denoting the problem.
  Parameters: month       - an integer between 1 and 12
              day         - an integer between 1 and 31 (depending on month)
              year        - a 4-digit integer value
              isLaterDate - a boolean value. If true, the function verifies the 
                            date being passed in is LATER than the current date.
\*----------------------------------------------------------------------------*/
function isValidDate(month, day, year, isLaterDate)
{
  // depending on the year, calculate the number of days in the month
  if (year % 4 == 0)      // LEAP YEAR 
    var daysInMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  else
    var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


  // first, check the incoming month and year are valid. 
  if (!month || !day || !year)          return false;
  if (1 > month || month > 12)          return false;
  if (year < 0)                         return false;
  if (1 > day || day > daysInMonth[month-1]) return false;


  // if required, verify the incoming date is LATER than the current date.
  if (isLaterDate)
  {
    // get current date
    var today = new Date();
    var currMonth = today.getMonth() + 1; // since returns 0-11
    var currDay   = today.getDate();
    var currYear  = today.getFullYear();

    // zero-pad today's month & day
    if (String(currMonth).length == 1)  currMonth = "0" + currMonth;
    if (String(currDay).length == 1)  currDay   = "0" + currDay;    
    currDate = String(currYear) + String(currMonth) + String(currDay);
    
    // zero-pad incoming month & day
    if (String(month).length == 1)  month = "0" + month;
    if (String(day).length == 1)  day   = "0" + day;
    incomingDate = String(year) + String(month) + String(day);

    if (Number(currDate) > Number(incomingDate))
      return false;
  }
  
  return true;
}


/*plik swfobject.js*/
/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;


/*plik jquery.js*/
(function(){
/*
 * jQuery 1.1.4 - New Wave Javascript
 *
 * Copyright (c) 2007 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2007-08-23 21:49:27 -0400 (Thu, 23 Aug 2007) $
 * $Rev: 2862 $
 */
// Map over jQuery in case of overwrite
if ( typeof jQuery != "undefined" )
    var _jQuery = jQuery;

var jQuery = window.jQuery = function(a,c) {
    // If the context is global, return a new object
    if ( window == this || !this.init )
        return new jQuery(a,c);
    
    return this.init(a,c);
};

// Map over the $ in case of overwrite
if ( typeof $ != "undefined" )
    var _$ = $;
    
// Map the jQuery namespace to the '$' one
window.$ = jQuery;

var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;

jQuery.fn = jQuery.prototype = {
    init: function(a,c) {
        // Make sure that a selection was provided
        a = a || document;

        // Handle HTML strings
        if ( typeof a  == "string" ) {
            var m = quickExpr.exec(a);
            if ( m && (m[1] || !c) ) {
                // HANDLE: $(html) -> $(array)
                if ( m[1] )
                    a = jQuery.clean( [ m[1] ] );

                // HANDLE: $("#id")
                else {
                    var tmp = document.getElementById( m[3] );
                    if ( tmp )
                        // Handle the case where IE and Opera return items
                        // by name instead of ID
                        if ( tmp.id != m[3] )
                            return jQuery().find( a );
                        else {
                            this[0] = tmp;
                            this.length = 1;
                            return this;
                        }
                    else
                        a = [];
                }

            // HANDLE: $(expr)
            } else
                return new jQuery( c ).find( a );

        // HANDLE: $(function)
        // Shortcut for document ready
        } else if ( jQuery.isFunction(a) )
            return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );

        return this.setArray(
            // HANDLE: $(array)
            a.constructor == Array && a ||

            // HANDLE: $(arraylike)
            // Watch for when an array-like object is passed as the selector
            (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||

            // HANDLE: $(*)
            [ a ] );
    },
    jquery: "1.1.4",

    size: function() {
        return this.length;
    },
    
    length: 0,

    get: function( num ) {
        return num == undefined ?

            // Return a 'clean' array
            jQuery.makeArray( this ) :

            // Return just the object
            this[num];
    },
    pushStack: function( a ) {
        var ret = jQuery(a);
        ret.prevObject = this;
        return ret;
    },
    setArray: function( a ) {
        this.length = 0;
        Array.prototype.push.apply( this, a );
        return this;
    },
    each: function( fn, args ) {
        return jQuery.each( this, fn, args );
    },
    index: function( obj ) {
        var pos = -1;
        this.each(function(i){
            if ( this == obj ) pos = i;
        });
        return pos;
    },

    attr: function( key, value, type ) {
        var obj = key;
        
        // Look for the case where we're accessing a style value
        if ( key.constructor == String )
            if ( value == undefined )
                return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
            else {
                obj = {};
                obj[ key ] = value;
            }
        
        // Check to see if we're setting style values
        return this.each(function(index){
            // Set all the styles
            for ( var prop in obj )
                jQuery.attr(
                    type ? this.style : this,
                    prop, jQuery.prop(this, obj[prop], type, index, prop)
                );
        });
    },

    css: function( key, value ) {
        return this.attr( key, value, "curCSS" );
    },

    text: function(e) {
        if ( typeof e != "object" && e != null )
            return this.empty().append( document.createTextNode( e ) );

        var t = "";
        jQuery.each( e || this, function(){
            jQuery.each( this.childNodes, function(){
                if ( this.nodeType != 8 )
                    t += this.nodeType != 1 ?
                        this.nodeValue : jQuery.fn.text([ this ]);
            });
        });
        return t;
    },

    wrap: function() {
        // The elements to wrap the target around
        var a, args = arguments;

        // Wrap each of the matched elements individually
        return this.each(function(){
            if ( !a )
                a = jQuery.clean(args, this.ownerDocument);

            // Clone the structure that we're using to wrap
            var b = a[0].cloneNode(true);

            // Insert it before the element to be wrapped
            this.parentNode.insertBefore( b, this );

            // Find the deepest point in the wrap structure
            while ( b.firstChild )
                b = b.firstChild;

            // Move the matched element to within the wrap structure
            b.appendChild( this );
        });
    },
    append: function() {
        return this.domManip(arguments, true, 1, function(a){
            this.appendChild( a );
        });
    },
    prepend: function() {
        return this.domManip(arguments, true, -1, function(a){
            this.insertBefore( a, this.firstChild );
        });
    },
    before: function() {
        return this.domManip(arguments, false, 1, function(a){
            this.parentNode.insertBefore( a, this );
        });
    },
    after: function() {
        return this.domManip(arguments, false, -1, function(a){
            this.parentNode.insertBefore( a, this.nextSibling );
        });
    },
    end: function() {
        return this.prevObject || jQuery([]);
    },
    find: function(t) {
        var data = jQuery.map(this, function(a){ return jQuery.find(t,a); });
        return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ?
            jQuery.unique( data ) : data );
    },
    clone: function(deep) {
        deep = deep != undefined ? deep : true;
        var $this = this.add(this.find("*"));
        if (jQuery.browser.msie) {
            // Need to remove events on the element and its descendants
            $this.each(function() {
                this._$events = {};
                for (var type in this.$events)
                    this._$events[type] = jQuery.extend({},this.$events[type]);
            }).unbind();
        }

        // Do the clone
        var r = this.pushStack( jQuery.map( this, function(a){
            return a.cloneNode( deep );
        }) );

        if (jQuery.browser.msie) {
            $this.each(function() {
                // Add the events back to the original and its descendants
                var events = this._$events;
                for (var type in events)
                    for (var handler in events[type])
                        jQuery.event.add(this, type, events[type][handler], events[type][handler].data);
                this._$events = null;
            });
        }

        // copy form values over
        if (deep) {
            var inputs = r.add(r.find('*')).filter('select,input[@type=checkbox]');
            $this.filter('select,input[@type=checkbox]').each(function(i) {
                if (this.selectedIndex)
                    inputs[i].selectedIndex = this.selectedIndex;
                if (this.checked)
                    inputs[i].checked = true;
            });
        }

        // Return the cloned set
        return r;
    },

    filter: function(t) {
        return this.pushStack(
            jQuery.isFunction( t ) &&
            jQuery.grep(this, function(el, index){
                return t.apply(el, [index]);
            }) ||

            jQuery.multiFilter(t,this) );
    },

    not: function(t) {
        return this.pushStack(
            t.constructor == String &&
            jQuery.multiFilter(t, this, true) ||

            jQuery.grep(this, function(a) {
                return ( t.constructor == Array || t.jquery )
                    ? jQuery.inArray( a, t ) < 0
                    : a != t;
            })
        );
    },

    add: function(t) {
        return this.pushStack( jQuery.merge(
            this.get(),
            t.constructor == String ?
                jQuery(t).get() :
                t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
                    t : [t] )
        );
    },
    is: function(expr) {
        return expr ? jQuery.multiFilter(expr,this).length > 0 : false;
    },

    val: function( val ) {
        return val == undefined ?
            ( this.length ? this[0].value : null ) :
            this.attr( "value", val );
    },

    html: function( val ) {
        return val == undefined ?
            ( this.length ? this[0].innerHTML : null ) :
            this.empty().append( val );
    },

    slice: function() {
        return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
    },
    domManip: function(args, table, dir, fn){
        var clone = this.length > 1, a; 

        return this.each(function(){
            if ( !a ) {
                a = jQuery.clean(args, this.ownerDocument);
                if ( dir < 0 )
                    a.reverse();
            }

            var obj = this;

            if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
                obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));

            jQuery.each( a, function(){
                if ( jQuery.nodeName(this, "script") ) {
                    if ( this.src )
                        jQuery.ajax({ url: this.src, async: false, dataType: "script" });
                    else
                        jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
                } else
                    fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
            });
        });
    }
};

jQuery.extend = jQuery.fn.extend = function() {
    // copy reference to target object
    var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false;

    // Handle a deep copy situation
    if ( target.constructor == Boolean ) {
        deep = target;
        target = arguments[1] || {};
    }

    // extend jQuery itself if only one argument is passed
    if ( al == 1 ) {
        target = this;
        a = 0;
    }

    var prop;

    for ( ; a < al; a++ )
        // Only deal with non-null/undefined values
        if ( (prop = arguments[a]) != null )
            // Extend the base object
            for ( var i in prop ) {
                // Prevent never-ending loop
                if ( target == prop[i] )
                    continue;

                // Recurse if we're merging object values
                if ( deep && typeof prop[i] == 'object' && target[i] )
                    jQuery.extend( target[i], prop[i] );

                // Don't bring in undefined values
                else if ( prop[i] != undefined )
                    target[i] = prop[i];
            }

    // Return the modified object
    return target;
};

jQuery.extend({
    noConflict: function(deep) {
        window.$ = _$;
        if ( deep )
            window.jQuery = _jQuery;
        return jQuery;
    },

    // This may seem like some crazy code, but trust me when I say that this
    // is the only cross-browser way to do this. --John
    isFunction: function( fn ) {
        return !!fn && typeof fn != "string" && !fn.nodeName && 
            fn.constructor != Array && /function/i.test( fn + "" );
    },
    
    // check if an element is in a XML document
    isXMLDoc: function(elem) {
        return elem.documentElement && !elem.body ||
            elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
    },

    // Evalulates a script in a global context
    // Evaluates Async. in Safari 2 :-(
    globalEval: function( data ) {
        data = jQuery.trim( data );
        if ( data ) {
            if ( window.execScript )
                window.execScript( data );
            else if ( jQuery.browser.safari )
                // safari doesn't provide a synchronous global eval
                window.setTimeout( data, 0 );
            else
                eval.call( window, data );
        }
    },

    nodeName: function( elem, name ) {
        return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
    },
    // args is for internal usage only
    each: function( obj, fn, args ) {
        if ( args ) {
            if ( obj.length == undefined )
                for ( var i in obj )
                    fn.apply( obj[i], args );
            else
                for ( var i = 0, ol = obj.length; i < ol; i++ )
                    if ( fn.apply( obj[i], args ) === false ) break;

        // A special, fast, case for the most common use of each
        } else {
            if ( obj.length == undefined )
                for ( var i in obj )
                    fn.call( obj[i], i, obj[i] );
            else
                for ( var i = 0, ol = obj.length, val = obj[0]; 
                    i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){}
        }

        return obj;
    },
    
    prop: function(elem, value, type, index, prop){
            // Handle executable functions
            if ( jQuery.isFunction( value ) )
                value = value.call( elem, [index] );
                
            // exclude the following css properties to add px
            var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;

            // Handle passing in a number to a CSS property
            return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
                value + "px" :
                value;
    },

    className: {
        // internal only, use addClass("class")
        add: function( elem, c ){
            jQuery.each( (c || "").split(/\s+/), function(i, cur){
                if ( !jQuery.className.has( elem.className, cur ) )
                    elem.className += ( elem.className ? " " : "" ) + cur;
            });
        },

        // internal only, use removeClass("class")
        remove: function( elem, c ){
            elem.className = c != undefined ?
                jQuery.grep( elem.className.split(/\s+/), function(cur){
                    return !jQuery.className.has( c, cur );    
                }).join(" ") : "";
        },

        // internal only, use is(".class")
        has: function( t, c ) {
            return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;
        }
    },
    swap: function(e,o,f) {
        for ( var i in o ) {
            e.style["old"+i] = e.style[i];
            e.style[i] = o[i];
        }
        f.apply( e, [] );
        for ( var i in o )
            e.style[i] = e.style["old"+i];
    },

    css: function(e,p) {
        if ( p == "height" || p == "width" ) {
            var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];

            jQuery.each( d, function(){
                old["padding" + this] = 0;
                old["border" + this + "Width"] = 0;
            });

            jQuery.swap( e, old, function() {
                if ( jQuery(e).is(':visible') ) {
                    oHeight = e.offsetHeight;
                    oWidth = e.offsetWidth;
                } else {
                    e = jQuery(e.cloneNode(true))
                        .find(":radio").removeAttr("checked").end()
                        .css({
                            visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
                        }).appendTo(e.parentNode)[0];

                    var parPos = jQuery.css(e.parentNode,"position") || "static";
                    if ( parPos == "static" )
                        e.parentNode.style.position = "relative";

                    oHeight = e.clientHeight;
                    oWidth = e.clientWidth;

                    if ( parPos == "static" )
                        e.parentNode.style.position = "static";

                    e.parentNode.removeChild(e);
                }
            });

            return p == "height" ? oHeight : oWidth;
        }

        return jQuery.curCSS( e, p );
    },

    curCSS: function(elem, prop, force) {
        var ret, stack = [], swap = [];

        // A helper method for determining if an element's values are broken
        function color(a){
            if ( !jQuery.browser.safari )
                return false;

            var ret = document.defaultView.getComputedStyle(a,null);
            return !ret || ret.getPropertyValue("color") == "";
        }

        if (prop == "opacity" && jQuery.browser.msie) {
            ret = jQuery.attr(elem.style, "opacity");
            return ret == "" ? "1" : ret;
        }
        
        if (prop.match(/float/i))
            prop = styleFloat;

        if (!force && elem.style[prop])
            ret = elem.style[prop];

        else if (document.defaultView && document.defaultView.getComputedStyle) {

            if (prop.match(/float/i))
                prop = "float";

            prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
            var cur = document.defaultView.getComputedStyle(elem, null);

            if ( cur && !color(elem) )
                ret = cur.getPropertyValue(prop);

            // If the element isn't reporting its values properly in Safari
            // then some display: none elements are involved
            else {
                // Locate all of the parent display: none elements
                for ( var a = elem; a && color(a); a = a.parentNode )
                    stack.unshift(a);

                // Go through and make them visible, but in reverse
                // (It would be better if we knew the exact display type that they had)
                for ( a = 0; a < stack.length; a++ )
                    if ( color(stack[a]) ) {
                        swap[a] = stack[a].style.display;
                        stack[a].style.display = "block";
                    }

                // Since we flip the display style, we have to handle that
                // one special, otherwise get the value
                ret = prop == "display" && swap[stack.length-1] != null ?
                    "none" :
                    document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || "";

                // Finally, revert the display styles back
                for ( a = 0; a < swap.length; a++ )
                    if ( swap[a] != null )
                        stack[a].style.display = swap[a];
            }

            if ( prop == "opacity" && ret == "" )
                ret = "1";

        } else if (elem.currentStyle) {
            var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
            ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
        }

        return ret;
    },
    
    clean: function(a, doc) {
        var r = [];
        doc = doc || document;

        jQuery.each( a, function(i,arg){
            if ( !arg ) return;

            if ( arg.constructor == Number )
                arg = arg.toString();
            
            // Convert html string into DOM nodes
            if ( typeof arg == "string" ) {
                // Trim whitespace, otherwise indexOf won't work as expected
                var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];

                var wrap =
                    // option or optgroup
                    !s.indexOf("<opt") &&
                    [1, "<select>", "</select>"] ||
                    
                    !s.indexOf("<leg") &&
                    [1, "<fieldset>", "</fieldset>"] ||
                    
                    s.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
                    [1, "<table>", "</table>"] ||
                    
                    !s.indexOf("<tr") &&
                    [2, "<table><tbody>", "</tbody></table>"] ||
                    
                     // <thead> matched above
                    (!s.indexOf("<td") || !s.indexOf("<th")) &&
                    [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
                    
                    !s.indexOf("<col") &&
                    [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] ||

                    // IE can't serialize <link> and <script> tags normally
                    jQuery.browser.msie &&
                    [1, "div<div>", "</div>"] ||
                    
                    [0,"",""];

                // Go to html and back, then peel off extra wrappers
                div.innerHTML = wrap[1] + arg + wrap[2];
                
                // Move to the right depth
                while ( wrap[0]-- )
                    div = div.lastChild;
                
                // Remove IE's autoinserted <tbody> from table fragments
                if ( jQuery.browser.msie ) {
                    
                    // String was a <table>, *may* have spurious <tbody>
                    if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 
                        tb = div.firstChild && div.firstChild.childNodes;
                        
                    // String was a bare <thead> or <tfoot>
                    else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
                        tb = div.childNodes;

                    for ( var n = tb.length-1; n >= 0 ; --n )
                        if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
                            tb[n].parentNode.removeChild(tb[n]);
    
                    // IE completely kills leading whitespace when innerHTML is used    
                    if ( /^\s/.test(arg) )    
                        div.insertBefore( doc.createTextNode( arg.match(/^\s*/)[0] ), div.firstChild );

                }
                
                arg = jQuery.makeArray( div.childNodes );
            }

            if ( 0 === arg.length && (!jQuery.nodeName(arg, "form") && !jQuery.nodeName(arg, "select")) )
                return;

            if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )
                r.push( arg );
            else
                r = jQuery.merge( r, arg );

        });

        return r;
    },
    
    attr: function(elem, name, value){
        var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;

        // Safari mis-reports the default selected property of a hidden option
        // Accessing the parent's selectedIndex property fixes it
        if ( name == "selected" && jQuery.browser.safari )
            elem.parentNode.selectedIndex;
        
        // Certain attributes only work when accessed via the old DOM 0 way
        if ( fix[name] ) {
            if ( value != undefined ) elem[fix[name]] = value;
            return elem[fix[name]];
        } else if ( jQuery.browser.msie && name == "style" )
            return jQuery.attr( elem.style, "cssText", value );

        else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
            return elem.getAttributeNode(name).nodeValue;

        // IE elem.getAttribute passes even for style
        else if ( elem.tagName ) {

            if ( value != undefined ) elem.setAttribute( name, value );
            if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) 
                return elem.getAttribute( name, 2 );
            return elem.getAttribute( name );

        // elem is actually elem.style ... set the style
        } else {
            // IE actually uses filters for opacity
            if ( name == "opacity" && jQuery.browser.msie ) {
                if ( value != undefined ) {
                    // IE has trouble with opacity if it does not have layout
                    // Force it by setting the zoom level
                    elem.zoom = 1; 
    
                    // Set the alpha filter to set the opacity
                    elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
                        (parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
                }
    
                return elem.filter ? 
                    (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
            }
            name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
            if ( value != undefined ) elem[name] = value;
            return elem[name];
        }
    },
    trim: function(t){
        return (t||"").replace(/^\s+|\s+$/g, "");
    },

    makeArray: function( a ) {
        var r = [];

        // Need to use typeof to fight Safari childNodes crashes
        if ( typeof a != "array" )
            for ( var i = 0, al = a.length; i < al; i++ )
                r.push( a[i] );
        else
            r = a.slice( 0 );

        return r;
    },

    inArray: function( b, a ) {
        for ( var i = 0, al = a.length; i < al; i++ )
            if ( a[i] == b )
                return i;
        return -1;
    },
    merge: function(first, second) {
        // We have to loop this way because IE & Opera overwrite the length
        // expando of getElementsByTagName

        // Also, we need to make sure that the correct elements are being returned
        // (IE returns comment nodes in a '*' query)
        if ( jQuery.browser.msie ) {
            for ( var i = 0; second[i]; i++ )
                if ( second[i].nodeType != 8 )
                    first.push(second[i]);
        } else
            for ( var i = 0; second[i]; i++ )
                first.push(second[i]);

        return first;
    },
    unique: function(first) {
        var r = [], num = jQuery.mergeNum++;

        try {
            for ( var i = 0, fl = first.length; i < fl; i++ )
                if ( num != first[i].mergeNum ) {
                    first[i].mergeNum = num;
                    r.push(first[i]);
                }
        } catch(e) {
            r = first;
        }

        return r;
    },

    mergeNum: 0,
    grep: function(elems, fn, inv) {
        // If a string is passed in for the function, make a function
        // for it (a handy shortcut)
        if ( typeof fn == "string" )
            fn = eval("false||function(a,i){return " + fn + "}");

        var result = [];

        // Go through the array, only saving the items
        // that pass the validator function
        for ( var i = 0, el = elems.length; i < el; i++ )
            if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
                result.push( elems[i] );

        return result;
    },
    map: function(elems, fn) {
        // If a string is passed in for the function, make a function
        // for it (a handy shortcut)
        if ( typeof fn == "string" )
            fn = eval("false||function(a){return " + fn + "}");

        var result = [];

        // Go through the array, translating each of the items to their
        // new value (or values).
        for ( var i = 0, el = elems.length; i < el; i++ ) {
            var val = fn(elems[i],i);

            if ( val !== null && val != undefined ) {
                if ( val.constructor != Array ) val = [val];
                result = result.concat( val );
            }
        }

        return result;
    }
});
 
/*
 * Whether the W3C compliant box model is being used.
 *
 * @property
 * @name $.boxModel
 * @type Boolean
 * @cat JavaScript
 */
var userAgent = navigator.userAgent.toLowerCase();

// Figure out what browser is being used
jQuery.browser = {
    version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
    safari: /webkit/.test(userAgent),
    opera: /opera/.test(userAgent),
    msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
    mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};

var styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat";
    
jQuery.extend({
    // Check to see if the W3C box model is being used
    boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
    
    styleFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
    
    props: {
        "for": "htmlFor",
        "class": "className",
        "float": styleFloat,
        cssFloat: styleFloat,
        styleFloat: styleFloat,
        innerHTML: "innerHTML",
        className: "className",
        value: "value",
        disabled: "disabled",
        checked: "checked",
        readonly: "readOnly",
        selected: "selected",
        maxlength: "maxLength"
    }
});

jQuery.each({
    parent: "a.parentNode",
    parents: "jQuery.parents(a)",
    next: "jQuery.nth(a,2,'nextSibling')",
    prev: "jQuery.nth(a,2,'previousSibling')",
    siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
    children: "jQuery.sibling(a.firstChild)"
}, function(i,n){
    jQuery.fn[ i ] = function(a) {
        var ret = jQuery.map(this,n);
        if ( a && typeof a == "string" )
            ret = jQuery.multiFilter(a,ret);
        return this.pushStack( jQuery.unique(ret) );
    };
});

jQuery.each({
    appendTo: "append",
    prependTo: "prepend",
    insertBefore: "before",
    insertAfter: "after"
}, function(i,n){
    jQuery.fn[ i ] = function(){
        var a = arguments;
        return this.each(function(){
            for ( var j = 0, al = a.length; j < al; j++ )
                jQuery(a[j])[n]( this );
        });
    };
});

jQuery.each( {
    removeAttr: function( key ) {
        jQuery.attr( this, key, "" );
        this.removeAttribute( key );
    },
    addClass: function(c){
        jQuery.className.add(this,c);
    },
    removeClass: function(c){
        jQuery.className.remove(this,c);
    },
    toggleClass: function( c ){
        jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
    },
    remove: function(a){
        if ( !a || jQuery.filter( a, [this] ).r.length )
            this.parentNode.removeChild( this );
    },
    empty: function() {
        while ( this.firstChild )
            this.removeChild( this.firstChild );
    }
}, function(i,n){
    jQuery.fn[ i ] = function() {
        return this.each( n, arguments );
    };
});

// DEPRECATED
jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
    jQuery.fn[ n ] = function(num,fn) {
        return this.filter( ":" + n + "(" + num + ")", fn );
    };
});

jQuery.each( [ "height", "width" ], function(i,n){
    jQuery.fn[ n ] = function(h) {
        return h == undefined ?
            ( this.length ? jQuery.css( this[0], n ) : null ) :
            this.css( n, h.constructor == String ? h : h + "px" );
    };
});

var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
        "(?:[\\w*_-]|\\\\.)" :
        "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
    quickChild = new RegExp("^[/>]\\s*(" + chars + "+)"),
    quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
    quickClass = new RegExp("^([#.]?)(" + chars + "*)");

jQuery.extend({
    expr: {
        "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
        "#": "a.getAttribute('id')==m[2]",
        ":": {
            // Position Checks
            lt: "i<m[3]-0",
            gt: "i>m[3]-0",
            nth: "m[3]-0==i",
            eq: "m[3]-0==i",
            first: "i==0",
            last: "i==r.length-1",
            even: "i%2==0",
            odd: "i%2",

            // Child Checks
            "first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
            "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
            "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",

            // Parent Checks
            parent: "a.firstChild",
            empty: "!a.firstChild",

            // Text Check
            contains: "(a.textContent||a.innerText||'').indexOf(m[3])>=0",

            // Visibility
            visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
            hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',

            // Form attributes
            enabled: "!a.disabled",
            disabled: "a.disabled",
            checked: "a.checked",
            selected: "a.selected||jQuery.attr(a,'selected')",

            // Form elements
            text: "'text'==a.type",
            radio: "'radio'==a.type",
            checkbox: "'checkbox'==a.type",
            file: "'file'==a.type",
            password: "'password'==a.type",
            submit: "'submit'==a.type",
            image: "'image'==a.type",
            reset: "'reset'==a.type",
            button: '"button"==a.type||jQuery.nodeName(a,"button")',
            input: "/input|select|textarea|button/i.test(a.nodeName)",

            // :has()
            has: "jQuery.find(m[3],a).length"
        },
        // DEPRECATED
        "[": "jQuery.find(m[2],a).length"
    },
    
    // The regular expressions that power the parsing engine
    parse: [
        // Match: [@value='test'], [@foo]
        /^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,

        // DEPRECATED
        // Match: [div], [div p]
        /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,

        // Match: :contains('foo')
        /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,

        // Match: :even, :last-chlid, #id, .class
        new RegExp("^([:.#]*)(" + chars + "+)")
    ],

    multiFilter: function( expr, elems, not ) {
        var old, cur = [];

        while ( expr && expr != old ) {
            old = expr;
            var f = jQuery.filter( expr, elems, not );
            expr = f.t.replace(/^\s*,\s*/, "" );
            cur = not ? elems = f.r : jQuery.merge( cur, f.r );
        }

        return cur;
    },
    find: function( t, context ) {
        // Quickly handle non-string expressions
        if ( typeof t != "string" )
            return [ t ];

        // Make sure that the context is a DOM Element
        if ( context && !context.nodeType )
            context = null;

        // Set the correct context (if none is provided)
        context = context || document;

        // DEPRECATED
        // Handle the common XPath // expression
        if ( !t.indexOf("//") ) {
            //context = context.documentElement;
            t = t.substr(2,t.length);

        // DEPRECATED
        // And the / root expression
        } else if ( !t.indexOf("/") && !context.ownerDocument ) {
            context = context.documentElement;
            t = t.substr(1,t.length);
            if ( t.indexOf("/") >= 1 )
                t = t.substr(t.indexOf("/"),t.length);
        }

        // Initialize the search
        var ret = [context], done = [], last;

        // Continue while a selector expression exists, and while
        // we're no longer looping upon ourselves
        while ( t && last != t ) {
            var r = [];
            last = t;

            // DEPRECATED
            t = jQuery.trim(t).replace( /^\/\//, "" );

            var foundToken = false;

            // An attempt at speeding up child selectors that
            // point to a specific element tag
            var re = quickChild;
            var m = re.exec(t);

            if ( m ) {
                var nodeName = m[1].toUpperCase();

                // Perform our own iteration and filter
                for ( var i = 0; ret[i]; i++ )
                    for ( var c = ret[i].firstChild; c; c = c.nextSibling )
                        if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) )
                            r.push( c );

                ret = r;
                t = t.replace( re, "" );
                if ( t.indexOf(" ") == 0 ) continue;
                foundToken = true;
            } else {
                // (.. and /) DEPRECATED
                re = /^((\/?\.\.)|([>\/+~]))\s*(\w*)/i;

                if ( (m = re.exec(t)) != null ) {
                    r = [];

                    var nodeName = m[4], mergeNum = jQuery.mergeNum++;
                    m = m[1];

                    for ( var j = 0, rl = ret.length; j < rl; j++ )
                        if ( m.indexOf("..") < 0 ) {
                            var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
                            for ( ; n; n = n.nextSibling )
                                if ( n.nodeType == 1 ) {
                                    if ( m == "~" && n.mergeNum == mergeNum ) break;
                                    
                                    if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
                                        if ( m == "~" ) n.mergeNum = mergeNum;
                                        r.push( n );
                                    }
                                    
                                    if ( m == "+" ) break;
                                }
                        // DEPRECATED
                        } else
                            r.push( ret[j].parentNode );

                    ret = r;

                    // And remove the token
                    t = jQuery.trim( t.replace( re, "" ) );
                    foundToken = true;
                }
            }

            // See if there's still an expression, and that we haven't already
            // matched a token
            if ( t && !foundToken ) {
                // Handle multiple expressions
                if ( !t.indexOf(",") ) {
                    // Clean the result set
                    if ( context == ret[0] ) ret.shift();

                    // Merge the result sets
                    done = jQuery.merge( done, ret );

                    // Reset the context
                    r = ret = [context];

                    // Touch up the selector string
                    t = " " + t.substr(1,t.length);

                } else {
                    // Optimize for the case nodeName#idName
                    var re2 = quickID;
                    var m = re2.exec(t);
                    
                    // Re-organize the results, so that they're consistent
                    if ( m ) {
                       m = [ 0, m[2], m[3], m[1] ];

                    } else {
                        // Otherwise, do a traditional filter check for
                        // ID, class, and element selectors
                        re2 = quickClass;
                        m = re2.exec(t);
                    }

                    m[2] = m[2].replace(/\\/g, "");

                    var elem = ret[ret.length-1];

                    // Try to do a global search by ID, where we can
                    if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
                        // Optimization for HTML document case
                        var oid = elem.getElementById(m[2]);
                        
                        // Do a quick check for the existence of the actual ID attribute
                        // to avoid selecting by the name attribute in IE
                        // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
                        if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
                            oid = jQuery('[@id="'+m[2]+'"]', elem)[0];

                        // Do a quick check for node name (where applicable) so
                        // that div#foo searches will be really fast
                        ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
                    } else {
                        // We need to find all descendant elements
                        for ( var i = 0; ret[i]; i++ ) {
                            // Grab the tag name being searched for
                            var tag = m[1] != "" || m[0] == "" ? "*" : m[2];

                            // Handle IE7 being really dumb about <object>s
                            if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
                                tag = "param";

                            r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
                        }

                        // It's faster to filter by class and be done with it
                        if ( m[1] == "." )
                            r = jQuery.classFilter( r, m[2] );

                        // Same with ID filtering
                        if ( m[1] == "#" ) {
                            var tmp = [];

                            // Try to find the element with the ID
                            for ( var i = 0; r[i]; i++ )
                                if ( r[i].getAttribute("id") == m[2] ) {
                                    tmp = [ r[i] ];
                                    break;
                                }

                            r = tmp;
                        }

                        ret = r;
                    }

                    t = t.replace( re2, "" );
                }

            }

            // If a selector string still exists
            if ( t ) {
                // Attempt to filter it
                var val = jQuery.filter(t,r);
                ret = r = val.r;
                t = jQuery.trim(val.t);
            }
        }

        // An error occurred with the selector;
        // just return an empty set instead
        if ( t )
            ret = [];

        // Remove the root context
        if ( ret && context == ret[0] )
            ret.shift();

        // And combine the results
        done = jQuery.merge( done, ret );

        return done;
    },

    classFilter: function(r,m,not){
        m = " " + m + " ";
        var tmp = [];
        for ( var i = 0; r[i]; i++ ) {
            var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
            if ( !not && pass || not && !pass )
                tmp.push( r[i] );
        }
        return tmp;
    },

    filter: function(t,r,not) {
        var last;

        // Look for common filter expressions
        while ( t  && t != last ) {
            last = t;

            var p = jQuery.parse, m;

            for ( var i = 0; p[i]; i++ ) {
                m = p[i].exec( t );

                if ( m ) {
                    // Remove what we just matched
                    t = t.substring( m[0].length );

                    m[2] = m[2].replace(/\\/g, "");
                    break;
                }
            }

            if ( !m )
                break;

            // :not() is a special case that can be optimized by
            // keeping it out of the expression list
            if ( m[1] == ":" && m[2] == "not" )
                r = jQuery.filter(m[3], r, true).r;

            // We can get a big speed boost by filtering by class here
            else if ( m[1] == "." )
                r = jQuery.classFilter(r, m[2], not);

            else if ( m[1] == "@" ) {
                var tmp = [], type = m[3];
                
                for ( var i = 0, rl = r.length; i < rl; i++ ) {
                    var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
                    
                    if ( z == null || /href|src|selected/.test(m[2]) )
                        z = jQuery.attr(a,m[2]) || '';

                    if ( (type == "" && !!z ||
                         type == "=" && z == m[5] ||
                         type == "!=" && z != m[5] ||
                         type == "^=" && z && !z.indexOf(m[5]) ||
                         type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
                         (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
                            tmp.push( a );
                }
                
                r = tmp;

            // We can get a speed boost by handling nth-child here
            } else if ( m[1] == ":" && m[2] == "nth-child" ) {
                var num = jQuery.mergeNum++, tmp = [],
                    test = /(\d*)n\+?(\d*)/.exec(
                        m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
                        !/\D/.test(m[3]) && "n+" + m[3] || m[3]),
                    first = (test[1] || 1) - 0, last = test[2] - 0;

                for ( var i = 0, rl = r.length; i < rl; i++ ) {
                    var node = r[i], parentNode = node.parentNode;

                    if ( num != parentNode.mergeNum ) {
                        var c = 1;

                        for ( var n = parentNode.firstChild; n; n = n.nextSibling )
                            if ( n.nodeType == 1 )
                                n.nodeIndex = c++;

                        parentNode.mergeNum = num;
                    }

                    var add = false;

                    if ( first == 1 ) {
                        if ( last == 0 || node.nodeIndex == last )
                            add = true;
                    } else if ( (node.nodeIndex + last) % first == 0 )
                        add = true;

                    if ( add ^ not )
                        tmp.push( node );
                }

                r = tmp;

            // Otherwise, find the expression to execute
            } else {
                var f = jQuery.expr[m[1]];
                if ( typeof f != "string" )
                    f = jQuery.expr[m[1]][m[2]];

                // Build a custom macro to enclose it
                f = eval("false||function(a,i){return " + f + "}");

                // Execute it against the current filter
                r = jQuery.grep( r, f, not );
            }
        }

        // Return an array of filtered elements (r)
        // and the modified expression string (t)
        return { r: r, t: t };
    },
    parents: function( elem ){
        var matched = [];
        var cur = elem.parentNode;
        while ( cur && cur != document ) {
            matched.push( cur );
            cur = cur.parentNode;
        }
        return matched;
    },
    nth: function(cur,result,dir,elem){
        result = result || 1;
        var num = 0;

        for ( ; cur; cur = cur[dir] )
            if ( cur.nodeType == 1 && ++num == result )
                break;

        return cur;
    },
    sibling: function( n, elem ) {
        var r = [];

        for ( ; n; n = n.nextSibling ) {
            if ( n.nodeType == 1 && (!elem || n != elem) )
                r.push( n );
        }

        return r;
    }
});
/*
 * A number of helper functions used for managing events.
 * Many of the ideas behind this code orignated from 
 * Dean Edwards' addEvent library.
 */
jQuery.event = {

    // Bind an event to an element
    // Original by Dean Edwards
    add: function(element, type, handler, data) {
        // For whatever reason, IE has trouble passing the window object
        // around, causing it to be cloned in the process
        if ( jQuery.browser.msie && element.setInterval != undefined )
            element = window;
        
        // Make sure that the function being executed has a unique ID
        if ( !handler.guid )
            handler.guid = this.guid++;
            
        // if data is passed, bind to handler 
        if( data != undefined ) { 
            // Create temporary function pointer to original handler 
            var fn = handler; 

            // Create unique handler function, wrapped around original handler 
            handler = function() { 
                // Pass arguments and context to original handler 
                return fn.apply(this, arguments); 
            };

            // Store data in unique handler 
            handler.data = data;

            // Set the guid of unique handler to the same of original handler, so it can be removed 
            handler.guid = fn.guid;
        }

        // Init the element's event structure
        if (!element.$events)
            element.$events = {};
        
        if (!element.$handle)
            element.$handle = function() {
                // returned undefined or false
                var val;

                // Handle the second event of a trigger and when
                // an event is called after a page has unloaded
                if ( typeof jQuery == "undefined" || jQuery.event.triggered )
                  return val;
                
                val = jQuery.event.handle.apply(element, arguments);
                
                return val;
            };

        // Get the current list of functions bound to this event
        var handlers = element.$events[type];

        // Init the event handler queue
        if (!handlers) {
            handlers = element.$events[type] = {};    
            
            // And bind the global event handler to the element
            if (element.addEventListener)
                element.addEventListener(type, element.$handle, false);
            else
                element.attachEvent("on" + type, element.$handle);
        }

        // Add the function to the element's handler list
        handlers[handler.guid] = handler;

        // Keep track of which events have been used, for global triggering
        this.global[type] = true;
    },

    guid: 1,
    global: {},

    // Detach an event or set of events from an element
    remove: function(element, type, handler) {
        var events = element.$events, ret, index;

        if ( events ) {
            // type is actually an event object here
            if ( type && type.type ) {
                handler = type.handler;
                type = type.type;
            }
            
            if ( !type ) {
                for ( type in events )
                    this.remove( element, type );

            } else if ( events[type] ) {
                // remove the given handler for the given type
                if ( handler )
                    delete events[type][handler.guid];
                
                // remove all handlers for the given type
                else
                    for ( handler in element.$events[type] )
                        delete events[type][handler];

                // remove generic event handler if no more handlers exist
                for ( ret in events[type] ) break;
                if ( !ret ) {
                    if (element.removeEventListener)
                        element.removeEventListener(type, element.$handle, false);
                    else
                        element.detachEvent("on" + type, element.$handle);
                    ret = null;
                    delete events[type];
                }
            }

            // Remove the expando if it's no longer used
            for ( ret in events ) break;
            if ( !ret )
                element.$handle = element.$events = null;
        }
    },

    trigger: function(type, data, element) {
        // Clone the incoming data, if any
        data = jQuery.makeArray(data || []);

        // Handle a global trigger
        if ( !element ) {
            // Only trigger if we've ever bound an event for it
            if ( this.global[type] )
                jQuery("*").add([window, document]).trigger(type, data);

        // Handle triggering a single element
        } else {
            var val, ret, fn = jQuery.isFunction( element[ type ] || null );
            
            // Pass along a fake event
            data.unshift( this.fix({ type: type, target: element }) );

            // Trigger the event
            if ( jQuery.isFunction( element.$handle ) )
                val = element.$handle.apply( element, data );
            if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false )
                val = false;

            if ( fn && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) {
                this.triggered = true;
                element[ type ]();
            }

            this.triggered = false;
        }
    },

    handle: function(event) {
        // returned undefined or false
        var val;

        // Empty object is for triggered events with no data
        event = jQuery.event.fix( event || window.event || {} ); 

        var c = this.$events && this.$events[event.type], args = Array.prototype.slice.call( arguments, 1 );
        args.unshift( event );

        for ( var j in c ) {
            // Pass in a reference to the handler function itself
            // So that we can later remove it
            args[0].handler = c[j];
            args[0].data = c[j].data;

            if ( c[j].apply( this, args ) === false ) {
                event.preventDefault();
                event.stopPropagation();
                val = false;
            }
        }

        // Clean up added properties in IE to prevent memory leak
        if (jQuery.browser.msie)
            event.target = event.preventDefault = event.stopPropagation =
                event.handler = event.data = null;

        return val;
    },

    fix: function(event) {
        // store a copy of the original event object 
        // and clone to set read-only properties
        var originalEvent = event;
        event = jQuery.extend({}, originalEvent);
        
        // add preventDefault and stopPropagation since 
        // they will not work on the clone
        event.preventDefault = function() {
            // if preventDefault exists run it on the original event
            if (originalEvent.preventDefault)
                originalEvent.preventDefault();
            // otherwise set the returnValue property of the original event to false (IE)
            originalEvent.returnValue = false;
        };
        event.stopPropagation = function() {
            // if stopPropagation exists run it on the original event
            if (originalEvent.stopPropagation)
                originalEvent.stopPropagation();
            // otherwise set the cancelBubble property of the original event to true (IE)
            originalEvent.cancelBubble = true;
        };
        
        // Fix target property, if necessary
        if ( !event.target && event.srcElement )
            event.target = event.srcElement;
                
        // check if target is a textnode (safari)
        if (jQuery.browser.safari && event.target.nodeType == 3)
            event.target = originalEvent.target.parentNode;

        // Add relatedTarget, if necessary
        if ( !event.relatedTarget && event.fromElement )
            event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;

        // Calculate pageX/Y if missing and clientX/Y available
        if ( event.pageX == null && event.clientX != null ) {
            var e = document.documentElement, b = document.body;
            event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft || 0);
            event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop || 0);
        }
            
        // Add which for key events
        if ( !event.which && (event.charCode || event.keyCode) )
            event.which = event.charCode || event.keyCode;
        
        // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
        if ( !event.metaKey && event.ctrlKey )
            event.metaKey = event.ctrlKey;

        // Add which for click: 1 == left; 2 == middle; 3 == right
        // Note: button is not normalized, so don't use it
        if ( !event.which && event.button )
            event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
            
        return event;
    }
};

jQuery.fn.extend({
    bind: function( type, data, fn ) {
        return type == "unload" ? this.one(type, data, fn) : this.each(function(){
            jQuery.event.add( this, type, fn || data, fn && data );
        });
    },
    one: function( type, data, fn ) {
        return this.each(function(){
            jQuery.event.add( this, type, function(event) {
                jQuery(this).unbind(event);
                return (fn || data).apply( this, arguments);
            }, fn && data);
        });
    },
    unbind: function( type, fn ) {
        return this.each(function(){
            jQuery.event.remove( this, type, fn );
        });
    },
    trigger: function( type, data ) {
        return this.each(function(){
            jQuery.event.trigger( type, data, this );
        });
    },
    toggle: function() {
        // Save reference to arguments for access in closure
        var a = arguments;

        return this.click(function(e) {
            // Figure out which function to execute
            this.lastToggle = 0 == this.lastToggle ? 1 : 0;
            
            // Make sure that clicks stop
            e.preventDefault();
            
            // and execute the function
            return a[this.lastToggle].apply( this, [e] ) || false;
        });
    },
    hover: function(f,g) {
        
        // A private function for handling mouse 'hovering'
        function handleHover(e) {
            // Check if mouse(over|out) are still within the same parent element
            var p = e.relatedTarget;
    
            // Traverse up the tree
            while ( p && p != this ) try { p = p.parentNode; } catch(e) { p = this; };
            
            // If we actually just moused on to a sub-element, ignore it
            if ( p == this ) return false;
            
            // Execute the right function
            return (e.type == "mouseover" ? f : g).apply(this, [e]);
        }
        
        // Bind the function to the two event listeners
        return this.mouseover(handleHover).mouseout(handleHover);
    },
    ready: function(f) {
        // Attach the listeners
        bindReady();

        // If the DOM is already ready
        if ( jQuery.isReady )
            // Execute the function immediately
            f.apply( document, [jQuery] );
            
        // Otherwise, remember the function for later
        else
            // Add the function to the wait list
            jQuery.readyList.push( function() { return f.apply(this, [jQuery]); } );
    
        return this;
    }
});

jQuery.extend({
    /*
     * All the code that makes DOM Ready work nicely.
     */
    isReady: false,
    readyList: [],
    
    // Handle when the DOM is ready
    ready: function() {
        // Make sure that the DOM is not already loaded
        if ( !jQuery.isReady ) {
            // Remember that the DOM is ready
            jQuery.isReady = true;
            
            // If there are functions bound, to execute
            if ( jQuery.readyList ) {
                // Execute all of them
                jQuery.each( jQuery.readyList, function(){
                    this.apply( document );
                });
                
                // Reset the list of functions
                jQuery.readyList = null;
            }
            // Remove event listener to avoid memory leak
            if ( jQuery.browser.mozilla || jQuery.browser.opera )
                document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
            
            // Remove script element used by IE hack
            if( !window.frames.length ) // don't remove if frames are present (#1187)
                jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
        }
    }
});

    jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
        "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 
        "submit,keydown,keypress,keyup,error").split(","), function(i,o){
        
        // Handle event binding
        jQuery.fn[o] = function(f){
            return f ? this.bind(o, f) : this.trigger(o);
        };
            
    });

var readyBound = false;

function bindReady(){
    if ( readyBound ) return;
    readyBound = true;

    // If Mozilla is used
    if ( jQuery.browser.mozilla || jQuery.browser.opera )
        // Use the handy event callback
        document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
    
    // If IE is used, use the excellent hack by Matthias Miller
    // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
    else if ( jQuery.browser.msie ) {
    
        // Only works if you document.write() it
        document.write("<scr" + "ipt id=__ie_init defer=true " + 
            "src=//:><\/script>");
    
        // Use the defer script hack
        var script = document.getElementById("__ie_init");
        
        // script does not exist if jQuery is loaded dynamically
        if ( script ) 
            script.onreadystatechange = function() {
                if ( document.readyState != "complete" ) return;
                jQuery.ready();
            };
    
        // Clear from memory
        script = null;
    
    // If Safari  is used
    } else if ( jQuery.browser.safari )
        // Continually check to see if the document.readyState is valid
        jQuery.safariTimer = setInterval(function(){
            // loaded and complete are both valid states
            if ( document.readyState == "loaded" || 
                document.readyState == "complete" ) {
    
                // If either one are found, remove the timer
                clearInterval( jQuery.safariTimer );
                jQuery.safariTimer = null;
    
                // and execute any waiting functions
                jQuery.ready();
            }
        }, 10); 

    // A fallback to window.onload, that will always work
    jQuery.event.add( window, "load", jQuery.ready );
}
jQuery.fn.extend({
    // DEPRECATED
    loadIfModified: function( url, params, callback ) {
        this.load( url, params, callback, 1 );
    },
    load: function( url, params, callback, ifModified ) {
        if ( jQuery.isFunction( url ) )
            return this.bind("load", url);

        callback = callback || function(){};

        // Default to a GET request
        var type = "GET";

        // If the second parameter was provided
        if ( params )
            // If it's a function
            if ( jQuery.isFunction( params ) ) {
                // We assume that it's the callback
                callback = params;
                params = null;

            // Otherwise, build a param string
            } else {
                params = jQuery.param( params );
                type = "POST";
            }

        var self = this;

        // Request the remote document
        jQuery.ajax({
            url: url,
            type: type,
            data: params,
            ifModified: ifModified,
            complete: function(res, status){
                // If successful, inject the HTML into all the matched elements
                if ( status == "success" || !ifModified && status == "notmodified" )
                    self.html(res.responseText);

                // Add delay to account for Safari's delay in globalEval
                setTimeout(function(){
                    self.each( callback, [res.responseText, status, res] );
                }, 13);
            }
        });
        return this;
    },
    serialize: function() {
        return jQuery.param( this );
    },

    // DEPRECATED
    // This method no longer does anything - all script evaluation is
    // taken care of within the HTML injection methods.
    evalScripts: function(){}

});

// Attach a bunch of functions for handling common AJAX events

jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
    jQuery.fn[o] = function(f){
        return this.bind(o, f);
    };
});

jQuery.extend({
    get: function( url, data, callback, type, ifModified ) {
        // shift arguments if data argument was ommited
        if ( jQuery.isFunction( data ) ) {
            callback = data;
            data = null;
        }
        
        return jQuery.ajax({
            type: "GET",
            url: url,
            data: data,
            success: callback,
            dataType: type,
            ifModified: ifModified
        });
    },
    // DEPRECATED
    getIfModified: function( url, data, callback, type ) {
        return jQuery.get(url, data, callback, type, 1);
    },
    getScript: function( url, callback ) {
        return jQuery.get(url, null, callback, "script");
    },
    getJSON: function( url, data, callback ) {
        return jQuery.get(url, data, callback, "json");
    },
    post: function( url, data, callback, type ) {
        if ( jQuery.isFunction( data ) ) {
            callback = data;
            data = {};
        }

        return jQuery.ajax({
            type: "POST",
            url: url,
            data: data,
            success: callback,
            dataType: type
        });
    },
    // DEPRECATED
    ajaxTimeout: function( timeout ) {
        jQuery.ajaxSettings.timeout = timeout;
    },
    ajaxSetup: function( settings ) {
        jQuery.extend( jQuery.ajaxSettings, settings );
    },

    ajaxSettings: {
        global: true,
        type: "GET",
        timeout: 0,
        contentType: "application/x-www-form-urlencoded",
        processData: true,
        async: true,
        data: null
    },
    
    // Last-Modified header cache for next request
    lastModified: {},
    ajax: function( s ) {
        // Extend the settings, but re-extend 's' so that it can be
        // checked again later (in the test suite, specifically)
        s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));

        // if data available
        if ( s.data ) {
            // convert data if not already a string
            if ( s.processData && typeof s.data != "string" )
                s.data = jQuery.param(s.data);

            // append data to url for get requests
            if ( s.type.toLowerCase() == "get" ) {
                // "?" + data or "&" + data (in case there are already params)
                s.url += (s.url.indexOf("?") > -1 ? "&" : "?") + s.data;

                // IE likes to send both get and post data, prevent this
                s.data = null;
            }
        }

        // Watch for a new set of requests
        if ( s.global && ! jQuery.active++ )
            jQuery.event.trigger( "ajaxStart" );

        var requestDone = false;

        // Create the request object; Microsoft failed to properly
        // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
        var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

        // Open the socket
        xml.open(s.type, s.url, s.async);

        // Set the correct header, if data is being sent
        if ( s.data )
            xml.setRequestHeader("Content-Type", s.contentType);

        // Set the If-Modified-Since header, if ifModified mode.
        if ( s.ifModified )
            xml.setRequestHeader("If-Modified-Since",
                jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );

        // Set header so the called script knows that it's an XMLHttpRequest
        xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");

        // Allow custom headers/mimetypes
        if( s.beforeSend )
            s.beforeSend(xml);
            
        if ( s.global )
            jQuery.event.trigger("ajaxSend", [xml, s]);

        // Wait for a response to come back
        var onreadystatechange = function(isTimeout){
            // The transfer is complete and the data is available, or the request timed out
            if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
                requestDone = true;
                
                // clear poll interval
                if (ival) {
                    clearInterval(ival);
                    ival = null;
                }
                
                var status = isTimeout == "timeout" && "timeout" ||
                    !jQuery.httpSuccess( xml ) && "error" ||
                    s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
                    "success";

                if ( status == "success" ) {
                    // Watch for, and catch, XML document parse errors
                    try {
                        // process the data (runs the xml through httpData regardless of callback)
                        var data = jQuery.httpData( xml, s.dataType );
                    } catch(e) {
                        status = "parsererror";
                    }
                }

                // Make sure that the request was successful or notmodified
                if ( status == "success" ) {
                    // Cache Last-Modified header, if ifModified mode.
                    var modRes;
                    try {
                        modRes = xml.getResponseHeader("Last-Modified");
                    } catch(e) {} // swallow exception thrown by FF if header is not available
    
                    if ( s.ifModified && modRes )
                        jQuery.lastModified[s.url] = modRes;
    
                    // If a local callback was specified, fire it and pass it the data
                    if ( s.success )
                        s.success( data, status );
    
                    // Fire the global callback
                    if ( s.global )
                        jQuery.event.trigger( "ajaxSuccess", [xml, s] );
                } else
                    jQuery.handleError(s, xml, status);

                // The request was completed
                if( s.global )
                    jQuery.event.trigger( "ajaxComplete", [xml, s] );

                // Handle the global AJAX counter
                if ( s.global && ! --jQuery.active )
                    jQuery.event.trigger( "ajaxStop" );

                // Process result
                if ( s.complete )
                    s.complete(xml, status);

                // Stop memory leaks
                if(s.async)
                    xml = null;
            }
        };
        
        if ( s.async ) {
            // don't attach the handler to the request, just poll it instead
            var ival = setInterval(onreadystatechange, 13); 

            // Timeout checker
            if ( s.timeout > 0 )
                setTimeout(function(){
                    // Check to see if the request is still happening
                    if ( xml ) {
                        // Cancel the request
                        xml.abort();
    
                        if( !requestDone )
                            onreadystatechange( "timeout" );
                    }
                }, s.timeout);
        }
            
        // Send the data
        try {
            xml.send(s.data);
        } catch(e) {
            jQuery.handleError(s, xml, null, e);
        }
        
        // firefox 1.5 doesn't fire statechange for sync requests
        if ( !s.async )
            onreadystatechange();
        
        // return XMLHttpRequest to allow aborting the request etc.
        return xml;
    },

    handleError: function( s, xml, status, e ) {
        // If a local callback was specified, fire it
        if ( s.error ) s.error( xml, status, e );

        // Fire the global callback
        if ( s.global )
            jQuery.event.trigger( "ajaxError", [xml, s, e] );
    },

    // Counter for holding the number of active queries
    active: 0,

    // Determines if an XMLHttpRequest was successful or not
    httpSuccess: function( r ) {
        try {
            return !r.status && location.protocol == "file:" ||
                ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
                jQuery.browser.safari && r.status == undefined;
        } catch(e){}
        return false;
    },

    // Determines if an XMLHttpRequest returns NotModified
    httpNotModified: function( xml, url ) {
        try {
            var xmlRes = xml.getResponseHeader("Last-Modified");

            // Firefox always returns 200. check Last-Modified date
            return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
                jQuery.browser.safari && xml.status == undefined;
        } catch(e){}
        return false;
    },

    /* Get the data out of an XMLHttpRequest.
     * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
     * otherwise return plain text.
     * (String) data - The type of data that you're expecting back,
     * (e.g. "xml", "html", "script")
     */
    httpData: function( r, type ) {
        var ct = r.getResponseHeader("content-type");
        var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
        data = xml ? r.responseXML : r.responseText;

        if ( xml && data.documentElement.tagName == "parsererror" )
            throw "parsererror";

        // If the type is "script", eval it in global context
        if ( type == "script" )
            jQuery.globalEval( data );

        // Get the JavaScript object, if JSON is used.
        if ( type == "json" )
            data = eval("(" + data + ")");

        return data;
    },

    // Serialize an array of form elements or a set of
    // key/values into a query string
    param: function( a ) {
        var s = [];

        // If an array was passed in, assume that it is an array
        // of form elements
        if ( a.constructor == Array || a.jquery )
            // Serialize the form elements
            jQuery.each( a, function(){
                s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
            });

        // Otherwise, assume that it's an object of key/value pairs
        else
            // Serialize the key/values
            for ( var j in a )
                // If the value is an array then the key names need to be repeated
                if ( a[j] && a[j].constructor == Array )
                    jQuery.each( a[j], function(){
                        s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
                    });
                else
                    s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );

        // Return the resulting serialization
        return s.join("&");
    }

});
jQuery.fn.extend({

    show: function(speed,callback){
        return speed ?
            this.animate({
                height: "show", width: "show", opacity: "show"
            }, speed, callback) :
            
            this.filter(":hidden").each(function(){
                this.style.display = this.oldblock ? this.oldblock : "";
                if ( jQuery.css(this,"display") == "none" )
                    this.style.display = "block";
            }).end();
    },

    hide: function(speed,callback){
        return speed ?
            this.animate({
                height: "hide", width: "hide", opacity: "hide"
            }, speed, callback) :
            
            this.filter(":visible").each(function(){
                this.oldblock = this.oldblock || jQuery.css(this,"display");
                if ( this.oldblock == "none" )
                    this.oldblock = "block";
                this.style.display = "none";
            }).end();
    },

    // Save the old toggle function
    _toggle: jQuery.fn.toggle,
    toggle: function( fn, fn2 ){
        return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
            this._toggle( fn, fn2 ) :
            fn ?
                this.animate({
                    height: "toggle", width: "toggle", opacity: "toggle"
                }, fn, fn2) :
                this.each(function(){
                    jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
                });
    },
    slideDown: function(speed,callback){
        return this.animate({height: "show"}, speed, callback);
    },
    slideUp: function(speed,callback){
        return this.animate({height: "hide"}, speed, callback);
    },
    slideToggle: function(speed, callback){
        return this.animate({height: "toggle"}, speed, callback);
    },
    fadeIn: function(speed, callback){
        return this.animate({opacity: "show"}, speed, callback);
    },
    fadeOut: function(speed, callback){
        return this.animate({opacity: "hide"}, speed, callback);
    },
    fadeTo: function(speed,to,callback){
        return this.animate({opacity: to}, speed, callback);
    },
    animate: function( prop, speed, easing, callback ) {
        return this.queue(function(){
            var hidden = jQuery(this).is(":hidden"),
                opt = jQuery.speed(speed, easing, callback),
                self = this;
            
            for ( var p in prop ) {
                if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
                    return jQuery.isFunction(opt.complete) && opt.complete.apply(this);

                if ( p == "height" || p == "width" ) {
                    // Store display property
                    opt.display = jQuery.css(this, "display");

                    // Make sure that nothing sneaks out
                    opt.overflow = this.style.overflow;
                }
            }

            if ( opt.overflow != null )
                this.style.overflow = "hidden";

            this.curAnim = jQuery.extend({}, prop);
            
            jQuery.each( prop, function(name, val){
                var e = new jQuery.fx( self, opt, name );
                if ( val.constructor == Number )
                    e.custom( e.cur() || 0, val );
                else
                    e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
            });

            // For JS strict compliance
            return true;
        });
    },
    queue: function(type,fn){
        if ( !fn ) {
            fn = type;
            type = "fx";
        }
    
        return this.each(function(){
            if ( !this.queue )
                this.queue = {};
    
            if ( !this.queue[type] )
                this.queue[type] = [];
    
            this.queue[type].push( fn );
        
            if ( this.queue[type].length == 1 )
                fn.apply(this);
        });
    }

});

jQuery.extend({
    
    speed: function(speed, easing, fn) {
        var opt = speed && speed.constructor == Object ? speed : {
            complete: fn || !fn && easing || 
                jQuery.isFunction( speed ) && speed,
            duration: speed,
            easing: fn && easing || easing && easing.constructor != Function && easing
        };

        opt.duration = (opt.duration && opt.duration.constructor == Number ? 
            opt.duration : 
            { slow: 600, fast: 200 }[opt.duration]) || 400;
    
        // Queueing
        opt.old = opt.complete;
        opt.complete = function(){
            jQuery.dequeue(this, "fx");
            if ( jQuery.isFunction( opt.old ) )
                opt.old.apply( this );
        };
    
        return opt;
    },
    
    easing: {
        linear: function( p, n, firstNum, diff ) {
            return firstNum + diff * p;
        },
        swing: function( p, n, firstNum, diff ) {
            return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
        }
    },
    
    queue: {},
    
    dequeue: function(elem,type){
        type = type || "fx";
    
        if ( elem.queue && elem.queue[type] ) {
            // Remove self
            elem.queue[type].shift();
    
            // Get next function
            var f = elem.queue[type][0];
        
            if ( f ) f.apply( elem );
        }
    },

    timers: [],

    /*
     * I originally wrote fx() as a clone of moo.fx and in the process
     * of making it small in size the code became illegible to sane
     * people. You've been warned.
     */
    
    fx: function( elem, options, prop ){

        var z = this;

        // The styles
        var y = elem.style;
        
        // Simple function for setting a style value
        z.a = function(){
            if ( options.step )
                options.step.apply( elem, [ z.now ] );

            if ( prop == "opacity" )
                jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
            else {
                y[prop] = parseInt(z.now) + "px";

                // Set display property to block for height/width animations
                if ( prop == "height" || prop == "width" )
                    y.display = "block";
            }
        };

        // Figure out the maximum number to run to
        z.max = function(){
            return parseFloat( jQuery.css(elem,prop) );
        };

        // Get the current size
        z.cur = function(){
            var r = parseFloat( jQuery.curCSS(elem, prop) );
            return r && r > -10000 ? r : z.max();
        };

        // Start an animation from one number to another
        z.custom = function(from,to){
            z.startTime = (new Date()).getTime();
            z.now = from;
            z.a();

            jQuery.timers.push(function(){
                return z.step(from, to);
            });

            if ( jQuery.timers.length == 1 ) {
                var timer = setInterval(function(){
                    var timers = jQuery.timers;
                    
                    for ( var i = 0; i < timers.length; i++ )
                        if ( !timers[i]() )
                            timers.splice(i--, 1);

                    if ( !timers.length )
                        clearInterval( timer );
                }, 13);
            }
        };

        // Simple 'show' function
        z.show = function(){
            if ( !elem.orig ) elem.orig = {};

            // Remember where we started, so that we can go back to it later
            elem.orig[prop] = jQuery.attr( elem.style, prop );

            options.show = true;

            // Begin the animation
            z.custom(0, this.cur());

            // Make sure that we start at a small width/height to avoid any
            // flash of content
            if ( prop != "opacity" )
                y[prop] = "1px";
            
            // Start by showing the element
            jQuery(elem).show();
        };

        // Simple 'hide' function
        z.hide = function(){
            if ( !elem.orig ) elem.orig = {};

            // Remember where we started, so that we can go back to it later
            elem.orig[prop] = jQuery.attr( elem.style, prop );

            options.hide = true;

            // Begin the animation
            z.custom(this.cur(), 0);
        };

        // Each step of an animation
        z.step = function(firstNum, lastNum){
            var t = (new Date()).getTime();

            if (t > options.duration + z.startTime) {
                z.now = lastNum;
                z.a();

                if (elem.curAnim) elem.curAnim[ prop ] = true;

                var done = true;
                for ( var i in elem.curAnim )
                    if ( elem.curAnim[i] !== true )
                        done = false;

                if ( done ) {
                    if ( options.display != null ) {
                        // Reset the overflow
                        y.overflow = options.overflow;
                    
                        // Reset the display
                        y.display = options.display;
                        if ( jQuery.css(elem, "display") == "none" )
                            y.display = "block";
                    }

                    // Hide the element if the "hide" operation was done
                    if ( options.hide )
                        y.display = "none";

                    // Reset the properties, if the item has been hidden or shown
                    if ( options.hide || options.show )
                        for ( var p in elem.curAnim )
                            jQuery.attr(y, p, elem.orig[p]);
                }

                // If a callback was provided, execute it
                if ( done && jQuery.isFunction( options.complete ) )
                    // Execute the complete function
                    options.complete.apply( elem );

                return false;
            } else {
                var n = t - this.startTime;
                // Figure out where in the animation we are and set the number
                var p = n / options.duration;
                
                // Perform the easing function, defaults to swing
                z.now = jQuery.easing[options.easing || (jQuery.easing.swing ? "swing" : "linear")](p, n, firstNum, (lastNum-firstNum), options.duration);

                // Perform the next step of the animation
                z.a();
            }

            return true;
        };
    
    }
});
})();

var $j = jQuery.noConflict();


/*plik prototype.lite.js*/
/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = [];
	$c(children).each(function(child){
		if (Element.hasClassName(child, className)) elements.push(child);
	});  
	return elements;
}

//useful array functions
Array.prototype.each = function(func){
	for(var i=0;ob=this[i];i++) func(ob, i);
}

function $c(array){
	var nArray = [];
	for (i=0;el=array[i];i++) nArray.push(el);
	return nArray;
}

/*plik moo.fx.js*/
/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
Friday, February 24, 2006
v 1.2.2
*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	go: function() {
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 13);
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.go();
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.el.iniWidth = this.el.offsetWidth;
		this.el.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.el.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
		this.setOpacity(this.now);
	},
	
	setOpacity: function(opacity) {
		if (opacity == 0) this.el.style.visibility = "hidden";
		else this.el.style.visibility = "visible";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.el.style.opacity = opacity;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}

/*plik moo.fx.pack.js*/
/*
moo.fx pack, effects extensions for moo.fx.
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE
for more info visit (http://moofx.mad4milk.net).
Friday, February 24, 2006
v 1.2.2
*/

//smooth scroll
fx.Scroll = Class.create();
fx.Scroll.prototype = Object.extend(new fx.Base(), {
	initialize: function(options) {
		this.setOptions(options);
	},

	scrollTo: function(el){
		var dest = Position.cumulativeOffset($(el))[1];
		var client = window.innerHeight || document.documentElement.clientHeight;
		var full = document.documentElement.scrollHeight;
		var top = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
		if (dest+client > full) this.custom(top, dest - client + (full-dest));
		else this.custom(top, dest);
	},

	increase: function(){
		window.scrollTo(0, this.now);
	}
});

//text size modify, now works with pixels too.
fx.Text = Class.create();
fx.Text.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.setOptions(options);
		if (!this.options.unit) this.options.unit = "em";
	},

	increase: function() {
		this.el.style.fontSize = this.now + this.options.unit;
	}
});

//composition effect: widht/height/opacity
fx.Combo = Class.create();
fx.Combo.prototype = {
	setOptions: function(options) {
		this.options = {
			opacity: true,
			height: true,
			width: false
		}
		Object.extend(this.options, options || {});
	},

	initialize: function(el, options) {
		this.el = $(el);
		this.setOptions(options);
		if (this.options.opacity) {
			this.el.o = new fx.Opacity(el, options);
			options.onComplete = null;
		}
		if (this.options.height) {
			this.el.h = new fx.Height(el, options);
			options.onComplete = null;	
		}
		if (this.options.width) this.el.w = new fx.Width(el, options);
	},
	
	toggle: function() { this.checkExec('toggle'); },

	hide: function(){ this.checkExec('hide'); },
	
	clearTimer: function(){ this.checkExec('clearTimer'); },
	
	checkExec: function(func){
		if (this.el.o) this.el.o[func]();
		if (this.el.h) this.el.h[func]();
		if (this.el.w) this.el.w[func]();
	},
	
	//only if width+height
	resizeTo: function(hto, wto) {
		if (this.el.h && this.el.w) {
			this.el.h.custom(this.el.offsetHeight, this.el.offsetHeight + hto);
			this.el.w.custom(this.el.offsetWidth, this.el.offsetWidth + wto);
		}
	},

	customSize: function(hto, wto) {
		if (this.el.h && this.el.w) {
			this.el.h.custom(this.el.offsetHeight, hto);
			this.el.w.custom(this.el.offsetWidth, wto);
		}
	}
}

fx.Accordion = Class.create();
fx.Accordion.prototype = {
	setOptions: function(options) {
		this.options = {
			delay: 100,
			opacity: false
		}
		Object.extend(this.options, options || {});
	},

	initialize: function(togglers, elements, options) {
		this.elements = elements;
		this.setOptions(options);
		var options = options || '';
		elements.each(function(el, i){
			options.onComplete = function(){
				if (el.offsetHeight > 0) el.style.height = '1%';
			}
			el.fx = new fx.Combo(el, options);
			el.fx.hide();
		});

		togglers.each(function(tog, i){
			tog.onclick = function(){
				this.showThisHideOpen(elements[i]);
			}.bind(this);
		}.bind(this));
	},

	showThisHideOpen: function(toShow){
		if (toShow.offsetHeight == 0) setTimeout(function(){this.clearAndToggle(toShow);}.bind(this), this.options.delay);
		this.elements.each(function(el, i){
			if (el.offsetHeight > 0 && el != toShow) this.clearAndToggle(el);
		}.bind(this));
	},

	clearAndToggle: function(el){
		el.fx.clearTimer();
		el.fx.toggle();
	}
}

var Remember = new Object();
Remember = function(){};
Remember.prototype = {
	initialize: function(el, options){
		this.el = $(el);
		this.days = 365;
		this.options = options;
		this.effect();
		var cookie = this.readCookie();
		if (cookie) {
			this.fx.now = cookie;
			this.fx.increase();
		}
	},

	//cookie functions based on code by Peter-Paul Koch
	setCookie: function(value) {
		var date = new Date();
		date.setTime(date.getTime()+(this.days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		document.cookie = this.el+this.el.id+this.prefix+"="+value+expires+"; path=/";
	},

	readCookie: function() {
		var nameEQ = this.el+this.el.id+this.prefix + "=";
		var ca = document.cookie.split(';');
		for(var i=0;c=ca[i];i++) {
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return false;
	},

	custom: function(from, to){
		if (this.fx.now != to) {
			this.setCookie(to);
			this.fx.custom(from, to);
		}
	}
}

fx.RememberHeight = Class.create();
fx.RememberHeight.prototype = Object.extend(new Remember(), {
	effect: function(){
		this.fx = new fx.Height(this.el, this.options);
		this.prefix = 'height';
	},
	
	toggle: function(){
		if (this.el.offsetHeight == 0) this.setCookie(this.el.scrollHeight);
		else this.setCookie(0);
		this.fx.toggle();
	},
	
	resize: function(to){
		this.setCookie(this.el.offsetHeight+to);
		this.fx.custom(this.el.offsetHeight,this.el.offsetHeight+to);
	},

	hide: function(){
		if (!this.readCookie()) {
			this.fx.hide();
		}
	}
});

fx.RememberText = Class.create();
fx.RememberText.prototype = Object.extend(new Remember(), {
	effect: function(){
		this.fx = new fx.Text(this.el, this.options);
		this.prefix = 'text';
	}
});

//useful for-replacement
Array.prototype.each = function(func){
	for(var i=0;ob=this[i];i++) func(ob, i);
}

//Easing Equations (c) 2003 Robert Penner, all rights reserved.
//This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html.

//expo
fx.expoIn = function(pos){
	return Math.pow(2, 10 * (pos - 1));
}
fx.expoOut = function(pos){
	return (-Math.pow(2, -10 * pos) + 1);
}

//quad
fx.quadIn = function(pos){
	return Math.pow(pos, 2);
}
fx.quadOut = function(pos){
	return -(pos)*(pos-2);
}

//circ
fx.circOut = function(pos){
	return Math.sqrt(1 - Math.pow(pos-1,2));
}
fx.circIn = function(pos){
	return -(Math.sqrt(1 - Math.pow(pos, 2)) - 1);
}

//back
fx.backIn = function(pos){
	return (pos)*pos*((2.7)*pos - 1.7);
}
fx.backOut = function(pos){
	return ((pos-1)*(pos-1)*((2.7)*(pos-1) + 1.7) + 1);
}

//sine
fx.sineOut = function(pos){
	return Math.sin(pos * (Math.PI/2));
}
fx.sineIn = function(pos){
	return -Math.cos(pos * (Math.PI/2)) + 1;
}
fx.sineInOut = function(pos){
	return -(Math.cos(Math.PI*pos) - 1)/2;
}



