/*  Prototype JavaScript framework, version 1.7



 *  (c) 2005-2010 Sam Stephenson



 *



 *  Prototype is freely distributable under the terms of an MIT-style license.



 *  For details, see the Prototype web site: http://www.prototypejs.org/



 *



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







var Prototype = {







  Version: '1.7',







  Browser: (function(){



    var ua = navigator.userAgent;



    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';



    return {



      IE:             !!window.attachEvent && !isOpera,



      Opera:          isOpera,



      WebKit:         ua.indexOf('AppleWebKit/') > -1,



      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,



      MobileSafari:   /Apple.*Mobile/.test(ua)



    }



  })(),







  BrowserFeatures: {



    XPath: !!document.evaluate,







    SelectorsAPI: !!document.querySelector,







    ElementExtensions: (function() {



      var constructor = window.Element || window.HTMLElement;



      return !!(constructor && constructor.prototype);



    })(),



    SpecificElementExtensions: (function() {



      if (typeof window.HTMLDivElement !== 'undefined')



        return true;







      var div = document.createElement('div'),



          form = document.createElement('form'),



          isSupported = false;







      if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {



        isSupported = true;



      }







      div = form = null;







      return isSupported;



    })()



  },







  ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',



  JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,







  emptyFunction: function() { },







  K: function(x) { return x }



};







if (Prototype.Browser.MobileSafari)



  Prototype.BrowserFeatures.SpecificElementExtensions = false;











var Abstract = { };











var Try = {



  these: function() {



    var returnValue;







    for (var i = 0, length = arguments.length; i < length; i++) {



      var lambda = arguments[i];



      try {



        returnValue = lambda();



        break;



      } catch (e) { }



    }







    return returnValue;



  }



};







/* Based on Alex Arnell's inheritance implementation. */







var Class = (function() {







  var IS_DONTENUM_BUGGY = (function(){



    for (var p in { toString: 1 }) {



      if (p === 'toString') return false;



    }



    return true;



  })();







  function subclass() {};



  function create() {



    var parent = null, properties = $A(arguments);



    if (Object.isFunction(properties[0]))



      parent = properties.shift();







    function klass() {



      this.initialize.apply(this, arguments);



    }







    Object.extend(klass, Class.Methods);



    klass.superclass = parent;



    klass.subclasses = [];







    if (parent) {



      subclass.prototype = parent.prototype;



      klass.prototype = new subclass;



      parent.subclasses.push(klass);



    }







    for (var i = 0, length = properties.length; i < length; i++)



      klass.addMethods(properties[i]);







    if (!klass.prototype.initialize)



      klass.prototype.initialize = Prototype.emptyFunction;







    klass.prototype.constructor = klass;



    return klass;



  }







  function addMethods(source) {



    var ancestor   = this.superclass && this.superclass.prototype,



        properties = Object.keys(source);







    if (IS_DONTENUM_BUGGY) {



      if (source.toString != Object.prototype.toString)



        properties.push("toString");



      if (source.valueOf != Object.prototype.valueOf)



        properties.push("valueOf");



    }







    for (var i = 0, length = properties.length; i < length; i++) {



      var property = properties[i], value = source[property];



      if (ancestor && Object.isFunction(value) &&



          value.argumentNames()[0] == "$super") {



        var method = value;



        value = (function(m) {



          return function() { return ancestor[m].apply(this, arguments); };



        })(property).wrap(method);







        value.valueOf = method.valueOf.bind(method);



        value.toString = method.toString.bind(method);



      }



      this.prototype[property] = value;



    }







    return this;



  }







  return {



    create: create,



    Methods: {



      addMethods: addMethods



    }



  };



})();



(function() {







  var _toString = Object.prototype.toString,



      NULL_TYPE = 'Null',



      UNDEFINED_TYPE = 'Undefined',



      BOOLEAN_TYPE = 'Boolean',



      NUMBER_TYPE = 'Number',



      STRING_TYPE = 'String',



      OBJECT_TYPE = 'Object',



      FUNCTION_CLASS = '[object Function]',



      BOOLEAN_CLASS = '[object Boolean]',



      NUMBER_CLASS = '[object Number]',



      STRING_CLASS = '[object String]',



      ARRAY_CLASS = '[object Array]',



      DATE_CLASS = '[object Date]',



      NATIVE_JSON_STRINGIFY_SUPPORT = window.JSON &&



        typeof JSON.stringify === 'function' &&



        JSON.stringify(0) === '0' &&



        typeof JSON.stringify(Prototype.K) === 'undefined';







  function Type(o) {



    switch(o) {



      case null: return NULL_TYPE;



      case (void 0): return UNDEFINED_TYPE;



    }



    var type = typeof o;



    switch(type) {



      case 'boolean': return BOOLEAN_TYPE;



      case 'number':  return NUMBER_TYPE;



      case 'string':  return STRING_TYPE;



    }



    return OBJECT_TYPE;



  }







  function extend(destination, source) {



    for (var property in source)



      destination[property] = source[property];



    return destination;



  }







  function inspect(object) {



    try {



      if (isUndefined(object)) return 'undefined';



      if (object === null) return 'null';



      return object.inspect ? object.inspect() : String(object);



    } catch (e) {



      if (e instanceof RangeError) return '...';



      throw e;



    }



  }







  function toJSON(value) {



    return Str('', { '': value }, []);



  }







  function Str(key, holder, stack) {



    var value = holder[key],



        type = typeof value;







    if (Type(value) === OBJECT_TYPE && typeof value.toJSON === 'function') {



      value = value.toJSON(key);



    }







    var _class = _toString.call(value);







    switch (_class) {



      case NUMBER_CLASS:



      case BOOLEAN_CLASS:



      case STRING_CLASS:



        value = value.valueOf();



    }







    switch (value) {



      case null: return 'null';



      case true: return 'true';



      case false: return 'false';



    }







    type = typeof value;



    switch (type) {



      case 'string':



        return value.inspect(true);



      case 'number':



        return isFinite(value) ? String(value) : 'null';



      case 'object':







        for (var i = 0, length = stack.length; i < length; i++) {



          if (stack[i] === value) { throw new TypeError(); }



        }



        stack.push(value);







        var partial = [];



        if (_class === ARRAY_CLASS) {



          for (var i = 0, length = value.length; i < length; i++) {



            var str = Str(i, value, stack);



            partial.push(typeof str === 'undefined' ? 'null' : str);



          }



          partial = '[' + partial.join(',') + ']';



        } else {



          var keys = Object.keys(value);



          for (var i = 0, length = keys.length; i < length; i++) {



            var key = keys[i], str = Str(key, value, stack);



            if (typeof str !== "undefined") {



               partial.push(key.inspect(true)+ ':' + str);



             }



          }



          partial = '{' + partial.join(',') + '}';



        }



        stack.pop();



        return partial;



    }



  }







  function stringify(object) {



    return JSON.stringify(object);



  }







  function toQueryString(object) {



    return $H(object).toQueryString();



  }







  function toHTML(object) {



    return object && object.toHTML ? object.toHTML() : String.interpret(object);



  }







  function keys(object) {



    if (Type(object) !== OBJECT_TYPE) { throw new TypeError(); }



    var results = [];



    for (var property in object) {



      if (object.hasOwnProperty(property)) {



        results.push(property);



      }



    }



    return results;



  }







  function values(object) {



    var results = [];



    for (var property in object)



      results.push(object[property]);



    return results;



  }







  function clone(object) {



    return extend({ }, object);



  }







  function isElement(object) {



    return !!(object && object.nodeType == 1);



  }







  function isArray(object) {



    return _toString.call(object) === ARRAY_CLASS;



  }







  var hasNativeIsArray = (typeof Array.isArray == 'function')



    && Array.isArray([]) && !Array.isArray({});







  if (hasNativeIsArray) {



    isArray = Array.isArray;



  }







  function isHash(object) {



    return object instanceof Hash;



  }







  function isFunction(object) {



    return _toString.call(object) === FUNCTION_CLASS;



  }







  function isString(object) {



    return _toString.call(object) === STRING_CLASS;



  }







  function isNumber(object) {



    return _toString.call(object) === NUMBER_CLASS;



  }







  function isDate(object) {



    return _toString.call(object) === DATE_CLASS;



  }







  function isUndefined(object) {



    return typeof object === "undefined";



  }







  extend(Object, {



    extend:        extend,



    inspect:       inspect,



    toJSON:        NATIVE_JSON_STRINGIFY_SUPPORT ? stringify : toJSON,



    toQueryString: toQueryString,



    toHTML:        toHTML,



    keys:          Object.keys || keys,



    values:        values,



    clone:         clone,



    isElement:     isElement,



    isArray:       isArray,



    isHash:        isHash,



    isFunction:    isFunction,



    isString:      isString,



    isNumber:      isNumber,



    isDate:        isDate,



    isUndefined:   isUndefined



  });



})();



Object.extend(Function.prototype, (function() {



  var slice = Array.prototype.slice;







  function update(array, args) {



    var arrayLength = array.length, length = args.length;



    while (length--) array[arrayLength + length] = args[length];



    return array;



  }







  function merge(array, args) {



    array = slice.call(array, 0);



    return update(array, args);



  }







  function argumentNames() {



    var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]



      .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')



      .replace(/\s+/g, '').split(',');



    return names.length == 1 && !names[0] ? [] : names;



  }







  function bind(context) {



    if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;



    var __method = this, args = slice.call(arguments, 1);



    return function() {



      var a = merge(args, arguments);



      return __method.apply(context, a);



    }



  }







  function bindAsEventListener(context) {



    var __method = this, args = slice.call(arguments, 1);



    return function(event) {



      var a = update([event || window.event], args);



      return __method.apply(context, a);



    }



  }







  function curry() {



    if (!arguments.length) return this;



    var __method = this, args = slice.call(arguments, 0);



    return function() {



      var a = merge(args, arguments);



      return __method.apply(this, a);



    }



  }







  function delay(timeout) {



    var __method = this, args = slice.call(arguments, 1);



    timeout = timeout * 1000;



    return window.setTimeout(function() {



      return __method.apply(__method, args);



    }, timeout);



  }







  function defer() {



    var args = update([0.01], arguments);



    return this.delay.apply(this, args);



  }







  function wrap(wrapper) {



    var __method = this;



    return function() {



      var a = update([__method.bind(this)], arguments);



      return wrapper.apply(this, a);



    }



  }







  function methodize() {



    if (this._methodized) return this._methodized;



    var __method = this;



    return this._methodized = function() {



      var a = update([this], arguments);



      return __method.apply(null, a);



    };



  }







  return {



    argumentNames:       argumentNames,



    bind:                bind,



    bindAsEventListener: bindAsEventListener,



    curry:               curry,



    delay:               delay,



    defer:               defer,



    wrap:                wrap,



    methodize:           methodize



  }



})());















(function(proto) {











  function toISOString() {



    return this.getUTCFullYear() + '-' +



      (this.getUTCMonth() + 1).toPaddedString(2) + '-' +



      this.getUTCDate().toPaddedString(2) + 'T' +



      this.getUTCHours().toPaddedString(2) + ':' +



      this.getUTCMinutes().toPaddedString(2) + ':' +



      this.getUTCSeconds().toPaddedString(2) + 'Z';



  }











  function toJSON() {



    return this.toISOString();



  }







  if (!proto.toISOString) proto.toISOString = toISOString;



  if (!proto.toJSON) proto.toJSON = toJSON;







})(Date.prototype);











RegExp.prototype.match = RegExp.prototype.test;







RegExp.escape = function(str) {



  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');



};



var PeriodicalExecuter = Class.create({



  initialize: function(callback, frequency) {



    this.callback = callback;



    this.frequency = frequency;



    this.currentlyExecuting = false;







    this.registerCallback();



  },







  registerCallback: function() {



    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);



  },







  execute: function() {



    this.callback(this);



  },







  stop: function() {



    if (!this.timer) return;



    clearInterval(this.timer);



    this.timer = null;



  },







  onTimerEvent: function() {



    if (!this.currentlyExecuting) {



      try {



        this.currentlyExecuting = true;



        this.execute();



        this.currentlyExecuting = false;



      } catch(e) {



        this.currentlyExecuting = false;



        throw e;



      }



    }



  }



});



Object.extend(String, {



  interpret: function(value) {



    return value == null ? '' : String(value);



  },



  specialChar: {



    '\b': '\\b',



    '\t': '\\t',



    '\n': '\\n',



    '\f': '\\f',



    '\r': '\\r',



    '\\': '\\\\'



  }



});







Object.extend(String.prototype, (function() {



  var NATIVE_JSON_PARSE_SUPPORT = window.JSON &&



    typeof JSON.parse === 'function' &&



    JSON.parse('{"test": true}').test;







  function prepareReplacement(replacement) {



    if (Object.isFunction(replacement)) return replacement;



    var template = new Template(replacement);



    return function(match) { return template.evaluate(match) };



  }







  function gsub(pattern, replacement) {



    var result = '', source = this, match;



    replacement = prepareReplacement(replacement);







    if (Object.isString(pattern))



      pattern = RegExp.escape(pattern);







    if (!(pattern.length || pattern.source)) {



      replacement = replacement('');



      return replacement + source.split('').join(replacement) + replacement;



    }







    while (source.length > 0) {



      if (match = source.match(pattern)) {



        result += source.slice(0, match.index);



        result += String.interpret(replacement(match));



        source  = source.slice(match.index + match[0].length);



      } else {



        result += source, source = '';



      }



    }



    return result;



  }







  function sub(pattern, replacement, count) {



    replacement = prepareReplacement(replacement);



    count = Object.isUndefined(count) ? 1 : count;







    return this.gsub(pattern, function(match) {



      if (--count < 0) return match[0];



      return replacement(match);



    });



  }







  function scan(pattern, iterator) {



    this.gsub(pattern, iterator);



    return String(this);



  }







  function truncate(length, truncation) {



    length = length || 30;



    truncation = Object.isUndefined(truncation) ? '...' : truncation;



    return this.length > length ?



      this.slice(0, length - truncation.length) + truncation : String(this);



  }







  function strip() {



    return this.replace(/^\s+/, '').replace(/\s+$/, '');



  }







  function stripTags() {



    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');



  }







  function stripScripts() {



    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');



  }







  function extractScripts() {



    var matchAll = new RegExp(Prototype.ScriptFragment, 'img'),



        matchOne = new RegExp(Prototype.ScriptFragment, 'im');



    return (this.match(matchAll) || []).map(function(scriptTag) {



      return (scriptTag.match(matchOne) || ['', ''])[1];



    });



  }







  function evalScripts() {



    return this.extractScripts().map(function(script) { return eval(script) });



  }







  function escapeHTML() {



    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');



  }







  function unescapeHTML() {



    return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');



  }











  function toQueryParams(separator) {



    var match = this.strip().match(/([^?#]*)(#.*)?$/);



    if (!match) return { };







    return match[1].split(separator || '&').inject({ }, function(hash, pair) {



      if ((pair = pair.split('='))[0]) {



        var key = decodeURIComponent(pair.shift()),



            value = pair.length > 1 ? pair.join('=') : pair[0];







        if (value != undefined) value = decodeURIComponent(value);







        if (key in hash) {



          if (!Object.isArray(hash[key])) hash[key] = [hash[key]];



          hash[key].push(value);



        }



        else hash[key] = value;



      }



      return hash;



    });



  }







  function toArray() {



    return this.split('');



  }







  function succ() {



    return this.slice(0, this.length - 1) +



      String.fromCharCode(this.charCodeAt(this.length - 1) + 1);



  }







  function times(count) {



    return count < 1 ? '' : new Array(count + 1).join(this);



  }







  function camelize() {



    return this.replace(/-+(.)?/g, function(match, chr) {



      return chr ? chr.toUpperCase() : '';



    });



  }







  function capitalize() {



    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();



  }







  function underscore() {



    return this.replace(/::/g, '/')



               .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')



               .replace(/([a-z\d])([A-Z])/g, '$1_$2')



               .replace(/-/g, '_')



               .toLowerCase();



  }







  function dasherize() {



    return this.replace(/_/g, '-');



  }







  function inspect(useDoubleQuotes) {



    var escapedString = this.replace(/[\x00-\x1f\\]/g, function(character) {



      if (character in String.specialChar) {



        return String.specialChar[character];



      }



      return '\\u00' + character.charCodeAt().toPaddedString(2, 16);



    });



    if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';



    return "'" + escapedString.replace(/'/g, '\\\'') + "'";



  }







  function unfilterJSON(filter) {



    return this.replace(filter || Prototype.JSONFilter, '$1');



  }







  function isJSON() {



    var str = this;



    if (str.blank()) return false;



    str = str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@');



    str = str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']');



    str = str.replace(/(?:^|:|,)(?:\s*\[)+/g, '');



    return (/^[\],:{}\s]*$/).test(str);



  }







  function evalJSON(sanitize) {



    var json = this.unfilterJSON(),



        cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;



    if (cx.test(json)) {



      json = json.replace(cx, function (a) {



        return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);



      });



    }



    try {



      if (!sanitize || json.isJSON()) return eval('(' + json + ')');



    } catch (e) { }



    throw new SyntaxError('Badly formed JSON string: ' + this.inspect());



  }







  function parseJSON() {



    var json = this.unfilterJSON();



    return JSON.parse(json);



  }







  function include(pattern) {



    return this.indexOf(pattern) > -1;



  }







  function startsWith(pattern) {



    return this.lastIndexOf(pattern, 0) === 0;



  }







  function endsWith(pattern) {



    var d = this.length - pattern.length;



    return d >= 0 && this.indexOf(pattern, d) === d;



  }







  function empty() {



    return this == '';



  }







  function blank() {



    return /^\s*$/.test(this);



  }







  function interpolate(object, pattern) {



    return new Template(this, pattern).evaluate(object);



  }







  return {



    gsub:           gsub,



    sub:            sub,



    scan:           scan,



    truncate:       truncate,



    strip:          String.prototype.trim || strip,



    stripTags:      stripTags,



    stripScripts:   stripScripts,



    extractScripts: extractScripts,



    evalScripts:    evalScripts,



    escapeHTML:     escapeHTML,



    unescapeHTML:   unescapeHTML,



    toQueryParams:  toQueryParams,



    parseQuery:     toQueryParams,



    toArray:        toArray,



    succ:           succ,



    times:          times,



    camelize:       camelize,



    capitalize:     capitalize,



    underscore:     underscore,



    dasherize:      dasherize,



    inspect:        inspect,



    unfilterJSON:   unfilterJSON,



    isJSON:         isJSON,



    evalJSON:       NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON,



    include:        include,



    startsWith:     startsWith,



    endsWith:       endsWith,



    empty:          empty,



    blank:          blank,



    interpolate:    interpolate



  };



})());







var Template = Class.create({



  initialize: function(template, pattern) {



    this.template = template.toString();



    this.pattern = pattern || Template.Pattern;



  },







  evaluate: function(object) {



    if (object && Object.isFunction(object.toTemplateReplacements))



      object = object.toTemplateReplacements();







    return this.template.gsub(this.pattern, function(match) {



      if (object == null) return (match[1] + '');







      var before = match[1] || '';



      if (before == '\\') return match[2];







      var ctx = object, expr = match[3],



          pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;







      match = pattern.exec(expr);



      if (match == null) return before;







      while (match != null) {



        var comp = match[1].startsWith('[') ? match[2].replace(/\\\\]/g, ']') : match[1];



        ctx = ctx[comp];



        if (null == ctx || '' == match[3]) break;



        expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);



        match = pattern.exec(expr);



      }







      return before + String.interpret(ctx);



    });



  }



});



Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;







var $break = { };







var Enumerable = (function() {



  function each(iterator, context) {



    var index = 0;



    try {



      this._each(function(value) {



        iterator.call(context, value, index++);



      });



    } catch (e) {



      if (e != $break) throw e;



    }



    return this;



  }







  function eachSlice(number, iterator, context) {



    var index = -number, slices = [], array = this.toArray();



    if (number < 1) return array;



    while ((index += number) < array.length)



      slices.push(array.slice(index, index+number));



    return slices.collect(iterator, context);



  }







  function all(iterator, context) {



    iterator = iterator || Prototype.K;



    var result = true;



    this.each(function(value, index) {



      result = result && !!iterator.call(context, value, index);



      if (!result) throw $break;



    });



    return result;



  }







  function any(iterator, context) {



    iterator = iterator || Prototype.K;



    var result = false;



    this.each(function(value, index) {



      if (result = !!iterator.call(context, value, index))



        throw $break;



    });



    return result;



  }







  function collect(iterator, context) {



    iterator = iterator || Prototype.K;



    var results = [];



    this.each(function(value, index) {



      results.push(iterator.call(context, value, index));



    });



    return results;



  }







  function detect(iterator, context) {



    var result;



    this.each(function(value, index) {



      if (iterator.call(context, value, index)) {



        result = value;



        throw $break;



      }



    });



    return result;



  }







  function findAll(iterator, context) {



    var results = [];



    this.each(function(value, index) {



      if (iterator.call(context, value, index))



        results.push(value);



    });



    return results;



  }







  function grep(filter, iterator, context) {



    iterator = iterator || Prototype.K;



    var results = [];







    if (Object.isString(filter))



      filter = new RegExp(RegExp.escape(filter));







    this.each(function(value, index) {



      if (filter.match(value))



        results.push(iterator.call(context, value, index));



    });



    return results;



  }







  function include(object) {



    if (Object.isFunction(this.indexOf))



      if (this.indexOf(object) != -1) return true;







    var found = false;



    this.each(function(value) {



      if (value == object) {



        found = true;



        throw $break;



      }



    });



    return found;



  }







  function inGroupsOf(number, fillWith) {



    fillWith = Object.isUndefined(fillWith) ? null : fillWith;



    return this.eachSlice(number, function(slice) {



      while(slice.length < number) slice.push(fillWith);



      return slice;



    });



  }







  function inject(memo, iterator, context) {



    this.each(function(value, index) {



      memo = iterator.call(context, memo, value, index);



    });



    return memo;



  }







  function invoke(method) {



    var args = $A(arguments).slice(1);



    return this.map(function(value) {



      return value[method].apply(value, args);



    });



  }







  function max(iterator, context) {



    iterator = iterator || Prototype.K;



    var result;



    this.each(function(value, index) {



      value = iterator.call(context, value, index);



      if (result == null || value >= result)



        result = value;



    });



    return result;



  }







  function min(iterator, context) {



    iterator = iterator || Prototype.K;



    var result;



    this.each(function(value, index) {



      value = iterator.call(context, value, index);



      if (result == null || value < result)



        result = value;



    });



    return result;



  }







  function partition(iterator, context) {



    iterator = iterator || Prototype.K;



    var trues = [], falses = [];



    this.each(function(value, index) {



      (iterator.call(context, value, index) ?



        trues : falses).push(value);



    });



    return [trues, falses];



  }







  function pluck(property) {



    var results = [];



    this.each(function(value) {



      results.push(value[property]);



    });



    return results;



  }







  function reject(iterator, context) {



    var results = [];



    this.each(function(value, index) {



      if (!iterator.call(context, value, index))



        results.push(value);



    });



    return results;



  }







  function sortBy(iterator, context) {



    return this.map(function(value, index) {



      return {



        value: value,



        criteria: iterator.call(context, value, index)



      };



    }).sort(function(left, right) {



      var a = left.criteria, b = right.criteria;



      return a < b ? -1 : a > b ? 1 : 0;



    }).pluck('value');



  }







  function toArray() {



    return this.map();



  }







  function zip() {



    var iterator = Prototype.K, args = $A(arguments);



    if (Object.isFunction(args.last()))



      iterator = args.pop();







    var collections = [this].concat(args).map($A);



    return this.map(function(value, index) {



      return iterator(collections.pluck(index));



    });



  }







  function size() {



    return this.toArray().length;



  }







  function inspect() {



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



  }







































  return {



    each:       each,



    eachSlice:  eachSlice,



    all:        all,



    every:      all,



    any:        any,



    some:       any,



    collect:    collect,



    map:        collect,



    detect:     detect,



    findAll:    findAll,



    select:     findAll,



    filter:     findAll,



    grep:       grep,



    include:    include,



    member:     include,



    inGroupsOf: inGroupsOf,



    inject:     inject,



    invoke:     invoke,



    max:        max,



    min:        min,



    partition:  partition,



    pluck:      pluck,



    reject:     reject,



    sortBy:     sortBy,



    toArray:    toArray,



    entries:    toArray,



    zip:        zip,



    size:       size,



    inspect:    inspect,



    find:       detect



  };



})();







function $A(iterable) {



  if (!iterable) return [];



  if ('toArray' in Object(iterable)) return iterable.toArray();



  var length = iterable.length || 0, results = new Array(length);



  while (length--) results[length] = iterable[length];



  return results;



}











function $w(string) {



  if (!Object.isString(string)) return [];



  string = string.strip();



  return string ? string.split(/\s+/) : [];



}







Array.from = $A;











(function() {



  var arrayProto = Array.prototype,



      slice = arrayProto.slice,



      _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available







  function each(iterator, context) {



    for (var i = 0, length = this.length >>> 0; i < length; i++) {



      if (i in this) iterator.call(context, this[i], i, this);



    }



  }



  if (!_each) _each = each;







  function clear() {



    this.length = 0;



    return this;



  }







  function first() {



    return this[0];



  }







  function last() {



    return this[this.length - 1];



  }







  function compact() {



    return this.select(function(value) {



      return value != null;



    });



  }







  function flatten() {



    return this.inject([], function(array, value) {



      if (Object.isArray(value))



        return array.concat(value.flatten());



      array.push(value);



      return array;



    });



  }







  function without() {



    var values = slice.call(arguments, 0);



    return this.select(function(value) {



      return !values.include(value);



    });



  }







  function reverse(inline) {



    return (inline === false ? this.toArray() : this)._reverse();



  }







  function uniq(sorted) {



    return this.inject([], function(array, value, index) {



      if (0 == index || (sorted ? array.last() != value : !array.include(value)))



        array.push(value);



      return array;



    });



  }







  function intersect(array) {



    return this.uniq().findAll(function(item) {



      return array.detect(function(value) { return item === value });



    });



  }











  function clone() {



    return slice.call(this, 0);



  }







  function size() {



    return this.length;



  }







  function inspect() {



    return '[' + this.map(Object.inspect).join(', ') + ']';



  }







  function indexOf(item, i) {



    i || (i = 0);



    var length = this.length;



    if (i < 0) i = length + i;



    for (; i < length; i++)



      if (this[i] === item) return i;



    return -1;



  }







  function lastIndexOf(item, i) {



    i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;



    var n = this.slice(0, i).reverse().indexOf(item);



    return (n < 0) ? n : i - n - 1;



  }







  function concat() {



    var array = slice.call(this, 0), item;



    for (var i = 0, length = arguments.length; i < length; i++) {



      item = arguments[i];



      if (Object.isArray(item) && !('callee' in item)) {



        for (var j = 0, arrayLength = item.length; j < arrayLength; j++)



          array.push(item[j]);



      } else {



        array.push(item);



      }



    }



    return array;



  }







  Object.extend(arrayProto, Enumerable);







  if (!arrayProto._reverse)



    arrayProto._reverse = arrayProto.reverse;







  Object.extend(arrayProto, {



    _each:     _each,



    clear:     clear,



    first:     first,



    last:      last,



    compact:   compact,



    flatten:   flatten,



    without:   without,



    reverse:   reverse,



    uniq:      uniq,



    intersect: intersect,



    clone:     clone,



    toArray:   clone,



    size:      size,



    inspect:   inspect



  });







  var CONCAT_ARGUMENTS_BUGGY = (function() {



    return [].concat(arguments)[0][0] !== 1;



  })(1,2)







  if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;







  if (!arrayProto.indexOf) arrayProto.indexOf = indexOf;



  if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf;



})();



function $H(object) {



  return new Hash(object);



};







var Hash = Class.create(Enumerable, (function() {



  function initialize(object) {



    this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);



  }











  function _each(iterator) {



    for (var key in this._object) {



      var value = this._object[key], pair = [key, value];



      pair.key = key;



      pair.value = value;



      iterator(pair);



    }



  }







  function set(key, value) {



    return this._object[key] = value;



  }







  function get(key) {



    if (this._object[key] !== Object.prototype[key])



      return this._object[key];



  }







  function unset(key) {



    var value = this._object[key];



    delete this._object[key];



    return value;



  }







  function toObject() {



    return Object.clone(this._object);



  }















  function keys() {



    return this.pluck('key');



  }







  function values() {



    return this.pluck('value');



  }







  function index(value) {



    var match = this.detect(function(pair) {



      return pair.value === value;



    });



    return match && match.key;



  }







  function merge(object) {



    return this.clone().update(object);



  }







  function update(object) {



    return new Hash(object).inject(this, function(result, pair) {



      result.set(pair.key, pair.value);



      return result;



    });



  }







  function toQueryPair(key, value) {



    if (Object.isUndefined(value)) return key;



    return key + '=' + encodeURIComponent(String.interpret(value));



  }







  function toQueryString() {



    return this.inject([], function(results, pair) {



      var key = encodeURIComponent(pair.key), values = pair.value;







      if (values && typeof values == 'object') {



        if (Object.isArray(values)) {



          var queryValues = [];



          for (var i = 0, len = values.length, value; i < len; i++) {



            value = values[i];



            queryValues.push(toQueryPair(key, value));



          }



          return results.concat(queryValues);



        }



      } else results.push(toQueryPair(key, values));



      return results;



    }).join('&');



  }







  function inspect() {



    return '#<Hash:{' + this.map(function(pair) {



      return pair.map(Object.inspect).join(': ');



    }).join(', ') + '}>';



  }







  function clone() {



    return new Hash(this);



  }







  return {



    initialize:             initialize,



    _each:                  _each,



    set:                    set,



    get:                    get,



    unset:                  unset,



    toObject:               toObject,



    toTemplateReplacements: toObject,



    keys:                   keys,



    values:                 values,



    index:                  index,



    merge:                  merge,



    update:                 update,



    toQueryString:          toQueryString,



    inspect:                inspect,



    toJSON:                 toObject,



    clone:                  clone



  };



})());







Hash.from = $H;



Object.extend(Number.prototype, (function() {



  function toColorPart() {



    return this.toPaddedString(2, 16);



  }







  function succ() {



    return this + 1;



  }







  function times(iterator, context) {



    $R(0, this, true).each(iterator, context);



    return this;



  }







  function toPaddedString(length, radix) {



    var string = this.toString(radix || 10);



    return '0'.times(length - string.length) + string;



  }







  function abs() {



    return Math.abs(this);



  }







  function round() {



    return Math.round(this);



  }







  function ceil() {



    return Math.ceil(this);



  }







  function floor() {



    return Math.floor(this);



  }







  return {



    toColorPart:    toColorPart,



    succ:           succ,



    times:          times,



    toPaddedString: toPaddedString,



    abs:            abs,



    round:          round,



    ceil:           ceil,



    floor:          floor



  };



})());







function $R(start, end, exclusive) {



  return new ObjectRange(start, end, exclusive);



}







var ObjectRange = Class.create(Enumerable, (function() {



  function initialize(start, end, exclusive) {



    this.start = start;



    this.end = end;



    this.exclusive = exclusive;



  }







  function _each(iterator) {



    var value = this.start;



    while (this.include(value)) {



      iterator(value);



      value = value.succ();



    }



  }







  function include(value) {



    if (value < this.start)



      return false;



    if (this.exclusive)



      return value < this.end;



    return value <= this.end;



  }







  return {



    initialize: initialize,



    _each:      _each,



    include:    include



  };



})());















var Ajax = {



  getTransport: function() {



    return Try.these(



      function() {return new XMLHttpRequest()},



      function() {return new ActiveXObject('Msxml2.XMLHTTP')},



      function() {return new ActiveXObject('Microsoft.XMLHTTP')}



    ) || false;



  },







  activeRequestCount: 0



};







Ajax.Responders = {



  responders: [],







  _each: function(iterator) {



    this.responders._each(iterator);



  },







  register: function(responder) {



    if (!this.include(responder))



      this.responders.push(responder);



  },







  unregister: function(responder) {



    this.responders = this.responders.without(responder);



  },







  dispatch: function(callback, request, transport, json) {



    this.each(function(responder) {



      if (Object.isFunction(responder[callback])) {



        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 = Class.create({



  initialize: function(options) {



    this.options = {



      method:       'post',



      asynchronous: true,



      contentType:  'application/x-www-form-urlencoded',



      encoding:     'UTF-8',



      parameters:   '',



      evalJSON:     true,



      evalJS:       true



    };



    Object.extend(this.options, options || { });







    this.options.method = this.options.method.toLowerCase();







    if (Object.isHash(this.options.parameters))



      this.options.parameters = this.options.parameters.toObject();



  }



});



Ajax.Request = Class.create(Ajax.Base, {



  _complete: false,







  initialize: function($super, url, options) {



    $super(options);



    this.transport = Ajax.getTransport();



    this.request(url);



  },







  request: function(url) {



    this.url = url;



    this.method = this.options.method;



    var params = Object.isString(this.options.parameters) ?



          this.options.parameters :



          Object.toQueryString(this.options.parameters);







    if (!['get', 'post'].include(this.method)) {



      params += (params ? '&' : '') + "_method=" + this.method;



      this.method = 'post';



    }







    if (params && this.method === 'get') {



      this.url += (this.url.include('?') ? '&' : '?') + params;



    }







    this.parameters = params.toQueryParams();







    try {



      var response = new Ajax.Response(this);



      if (this.options.onCreate) this.options.onCreate(response);



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







      this.transport.open(this.method.toUpperCase(), this.url,



        this.options.asynchronous);







      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);







      this.transport.onreadystatechange = this.onStateChange.bind(this);



      this.setRequestHeaders();







      this.body = this.method == 'post' ? (this.options.postBody || params) : null;



      this.transport.send(this.body);







      /* Force Firefox to handle ready state 4 for synchronous requests */



      if (!this.options.asynchronous && this.transport.overrideMimeType)



        this.onStateChange();







    }



    catch (e) {



      this.dispatchException(e);



    }



  },







  onStateChange: function() {



    var readyState = this.transport.readyState;



    if (readyState > 1 && !((readyState == 4) && this._complete))



      this.respondToReadyState(this.transport.readyState);



  },







  setRequestHeaders: function() {



    var headers = {



      'X-Requested-With': 'XMLHttpRequest',



      'X-Prototype-Version': Prototype.Version,



      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'



    };







    if (this.method == 'post') {



      headers['Content-type'] = this.options.contentType +



        (this.options.encoding ? '; charset=' + this.options.encoding : '');







      /* Force "Connection: close" for older Mozilla browsers to work



       * around a bug where XMLHttpRequest sends an incorrect



       * Content-length header. See Mozilla Bugzilla #246651.



       */



      if (this.transport.overrideMimeType &&



          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)



            headers['Connection'] = 'close';



    }







    if (typeof this.options.requestHeaders == 'object') {



      var extras = this.options.requestHeaders;







      if (Object.isFunction(extras.push))



        for (var i = 0, length = extras.length; i < length; i += 2)



          headers[extras[i]] = extras[i+1];



      else



        $H(extras).each(function(pair) { headers[pair.key] = pair.value });



    }







    for (var name in headers)



      this.transport.setRequestHeader(name, headers[name]);



  },







  success: function() {



    var status = this.getStatus();



    return !status || (status >= 200 && status < 300) || status == 304;



  },







  getStatus: function() {



    try {



      if (this.transport.status === 1223) return 204;



      return this.transport.status || 0;



    } catch (e) { return 0 }



  },







  respondToReadyState: function(readyState) {



    var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);







    if (state == 'Complete') {



      try {



        this._complete = true;



        (this.options['on' + response.status]



         || this.options['on' + (this.success() ? 'Success' : 'Failure')]



         || Prototype.emptyFunction)(response, response.headerJSON);



      } catch (e) {



        this.dispatchException(e);



      }







      var contentType = response.getHeader('Content-type');



      if (this.options.evalJS == 'force'



          || (this.options.evalJS && this.isSameOrigin() && contentType



          && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))



        this.evalResponse();



    }







    try {



      (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);



      Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);



    } catch (e) {



      this.dispatchException(e);



    }







    if (state == 'Complete') {



      this.transport.onreadystatechange = Prototype.emptyFunction;



    }



  },







  isSameOrigin: function() {



    var m = this.url.match(/^\s*https?:\/\/[^\/]*/);



    return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({



      protocol: location.protocol,



      domain: document.domain,



      port: location.port ? ':' + location.port : ''



    }));



  },







  getHeader: function(name) {



    try {



      return this.transport.getResponseHeader(name) || null;



    } catch (e) { return null; }



  },







  evalResponse: function() {



    try {



      return eval((this.transport.responseText || '').unfilterJSON());



    } catch (e) {



      this.dispatchException(e);



    }



  },







  dispatchException: function(exception) {



    (this.options.onException || Prototype.emptyFunction)(this, exception);



    Ajax.Responders.dispatch('onException', this, exception);



  }



});







Ajax.Request.Events =



  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];



































Ajax.Response = Class.create({



  initialize: function(request){



    this.request = request;



    var transport  = this.transport  = request.transport,



        readyState = this.readyState = transport.readyState;







    if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {



      this.status       = this.getStatus();



      this.statusText   = this.getStatusText();



      this.responseText = String.interpret(transport.responseText);



      this.headerJSON   = this._getHeaderJSON();



    }







    if (readyState == 4) {



      var xml = transport.responseXML;



      this.responseXML  = Object.isUndefined(xml) ? null : xml;



      this.responseJSON = this._getResponseJSON();



    }



  },







  status:      0,







  statusText: '',







  getStatus: Ajax.Request.prototype.getStatus,







  getStatusText: function() {



    try {



      return this.transport.statusText || '';



    } catch (e) { return '' }



  },







  getHeader: Ajax.Request.prototype.getHeader,







  getAllHeaders: function() {



    try {



      return this.getAllResponseHeaders();



    } catch (e) { return null }



  },







  getResponseHeader: function(name) {



    return this.transport.getResponseHeader(name);



  },







  getAllResponseHeaders: function() {



    return this.transport.getAllResponseHeaders();



  },







  _getHeaderJSON: function() {



    var json = this.getHeader('X-JSON');



    if (!json) return null;



    json = decodeURIComponent(escape(json));



    try {



      return json.evalJSON(this.request.options.sanitizeJSON ||



        !this.request.isSameOrigin());



    } catch (e) {



      this.request.dispatchException(e);



    }



  },







  _getResponseJSON: function() {



    var options = this.request.options;



    if (!options.evalJSON || (options.evalJSON != 'force' &&



      !(this.getHeader('Content-type') || '').include('application/json')) ||



        this.responseText.blank())



          return null;



    try {



      return this.responseText.evalJSON(options.sanitizeJSON ||



        !this.request.isSameOrigin());



    } catch (e) {



      this.request.dispatchException(e);



    }



  }



});







Ajax.Updater = Class.create(Ajax.Request, {



  initialize: function($super, container, url, options) {



    this.container = {



      success: (container.success || container),



      failure: (container.failure || (container.success ? null : container))



    };







    options = Object.clone(options);



    var onComplete = options.onComplete;



    options.onComplete = (function(response, json) {



      this.updateContent(response.responseText);



      if (Object.isFunction(onComplete)) onComplete(response, json);



    }).bind(this);







    $super(url, options);



  },







  updateContent: function(responseText) {



    var receiver = this.container[this.success() ? 'success' : 'failure'],



        options = this.options;







    if (!options.evalScripts) responseText = responseText.stripScripts();







    if (receiver = $(receiver)) {



      if (options.insertion) {



        if (Object.isString(options.insertion)) {



          var insertion = { }; insertion[options.insertion] = responseText;



          receiver.insert(insertion);



        }



        else options.insertion(receiver, responseText);



      }



      else receiver.update(responseText);



    }



  }



});







Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {



  initialize: function($super, container, url, options) {



    $super(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.options.onComplete = undefined;



    clearTimeout(this.timer);



    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);



  },







  updateComplete: function(response) {



    if (this.options.decay) {



      this.decay = (response.responseText == this.lastText ?



        this.decay * this.options.decay : 1);







      this.lastText = response.responseText;



    }



    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);



  },







  onTimerEvent: function() {



    this.updater = new Ajax.Updater(this.container, this.url, this.options);



  }



});











function $(element) {



  if (arguments.length > 1) {



    for (var i = 0, elements = [], length = arguments.length; i < length; i++)



      elements.push($(arguments[i]));



    return elements;



  }



  if (Object.isString(element))



    element = document.getElementById(element);



  return Element.extend(element);



}







if (Prototype.BrowserFeatures.XPath) {



  document._getElementsByXPath = function(expression, parentElement) {



    var results = [];



    var query = document.evaluate(expression, $(parentElement) || document,



      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);



    for (var i = 0, length = query.snapshotLength; i < length; i++)



      results.push(Element.extend(query.snapshotItem(i)));



    return results;



  };



}







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







if (!Node) var Node = { };







if (!Node.ELEMENT_NODE) {



  Object.extend(Node, {



    ELEMENT_NODE: 1,



    ATTRIBUTE_NODE: 2,



    TEXT_NODE: 3,



    CDATA_SECTION_NODE: 4,



    ENTITY_REFERENCE_NODE: 5,



    ENTITY_NODE: 6,



    PROCESSING_INSTRUCTION_NODE: 7,



    COMMENT_NODE: 8,



    DOCUMENT_NODE: 9,



    DOCUMENT_TYPE_NODE: 10,



    DOCUMENT_FRAGMENT_NODE: 11,



    NOTATION_NODE: 12



  });



}















(function(global) {



  function shouldUseCache(tagName, attributes) {



    if (tagName === 'select') return false;



    if ('type' in attributes) return false;



    return true;



  }







  var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = (function(){



    try {



      var el = document.createElement('<input name="x">');



      return el.tagName.toLowerCase() === 'input' && el.name === 'x';



    }



    catch(err) {



      return false;



    }



  })();







  var element = global.Element;







  global.Element = function(tagName, attributes) {



    attributes = attributes || { };



    tagName = tagName.toLowerCase();



    var cache = Element.cache;







    if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) {



      tagName = '<' + tagName + ' name="' + attributes.name + '">';



      delete attributes.name;



      return Element.writeAttribute(document.createElement(tagName), attributes);



    }







    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));







    var node = shouldUseCache(tagName, attributes) ?



     cache[tagName].cloneNode(false) : document.createElement(tagName);







    return Element.writeAttribute(node, attributes);



  };







  Object.extend(global.Element, element || { });



  if (element) global.Element.prototype = element.prototype;







})(this);







Element.idCounter = 1;



Element.cache = { };







Element._purgeElement = function(element) {



  var uid = element._prototypeUID;



  if (uid) {



    Element.stopObserving(element);



    element._prototypeUID = void 0;



    delete Element.Storage[uid];



  }



}







Element.Methods = {



  visible: function(element) {



    return $(element).style.display != 'none';



  },







  toggle: function(element) {



    element = $(element);



    Element[Element.visible(element) ? 'hide' : 'show'](element);



    return element;



  },







  hide: function(element) {



    element = $(element);



    element.style.display = 'none';



    return element;



  },







  show: function(element) {



    element = $(element);



    element.style.display = '';



    return element;



  },







  remove: function(element) {



    element = $(element);



    element.parentNode.removeChild(element);



    return element;



  },







  update: (function(){







    var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){



      var el = document.createElement("select"),



          isBuggy = true;



      el.innerHTML = "<option value=\"test\">test</option>";



      if (el.options && el.options[0]) {



        isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION";



      }



      el = null;



      return isBuggy;



    })();







    var TABLE_ELEMENT_INNERHTML_BUGGY = (function(){



      try {



        var el = document.createElement("table");



        if (el && el.tBodies) {



          el.innerHTML = "<tbody><tr><td>test</td></tr></tbody>";



          var isBuggy = typeof el.tBodies[0] == "undefined";



          el = null;



          return isBuggy;



        }



      } catch (e) {



        return true;



      }



    })();







    var LINK_ELEMENT_INNERHTML_BUGGY = (function() {



      try {



        var el = document.createElement('div');



        el.innerHTML = "<link>";



        var isBuggy = (el.childNodes.length === 0);



        el = null;



        return isBuggy;



      } catch(e) {



        return true;



      }



    })();







    var ANY_INNERHTML_BUGGY = SELECT_ELEMENT_INNERHTML_BUGGY ||



     TABLE_ELEMENT_INNERHTML_BUGGY || LINK_ELEMENT_INNERHTML_BUGGY;







    var SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = (function () {



      var s = document.createElement("script"),



          isBuggy = false;



      try {



        s.appendChild(document.createTextNode(""));



        isBuggy = !s.firstChild ||



          s.firstChild && s.firstChild.nodeType !== 3;



      } catch (e) {



        isBuggy = true;



      }



      s = null;



      return isBuggy;



    })();











    function update(element, content) {



      element = $(element);



      var purgeElement = Element._purgeElement;







      var descendants = element.getElementsByTagName('*'),



       i = descendants.length;



      while (i--) purgeElement(descendants[i]);







      if (content && content.toElement)



        content = content.toElement();







      if (Object.isElement(content))



        return element.update().insert(content);







      content = Object.toHTML(content);







      var tagName = element.tagName.toUpperCase();







      if (tagName === 'SCRIPT' && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) {



        element.text = content;



        return element;



      }







      if (ANY_INNERHTML_BUGGY) {



        if (tagName in Element._insertionTranslations.tags) {



          while (element.firstChild) {



            element.removeChild(element.firstChild);



          }



          Element._getContentFromAnonymousElement(tagName, content.stripScripts())



            .each(function(node) {



              element.appendChild(node)



            });



        } else if (LINK_ELEMENT_INNERHTML_BUGGY && Object.isString(content) && content.indexOf('<link') > -1) {



          while (element.firstChild) {



            element.removeChild(element.firstChild);



          }



          var nodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts(), true);



          nodes.each(function(node) { element.appendChild(node) });



        }



        else {



          element.innerHTML = content.stripScripts();



        }



      }



      else {



        element.innerHTML = content.stripScripts();



      }







      content.evalScripts.bind(content).defer();



      return element;



    }







    return update;



  })(),







  replace: function(element, content) {



    element = $(element);



    if (content && content.toElement) content = content.toElement();



    else if (!Object.isElement(content)) {



      content = Object.toHTML(content);



      var range = element.ownerDocument.createRange();



      range.selectNode(element);



      content.evalScripts.bind(content).defer();



      content = range.createContextualFragment(content.stripScripts());



    }



    element.parentNode.replaceChild(content, element);



    return element;



  },







  insert: function(element, insertions) {



    element = $(element);







    if (Object.isString(insertions) || Object.isNumber(insertions) ||



        Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))



          insertions = {bottom:insertions};







    var content, insert, tagName, childNodes;







    for (var position in insertions) {



      content  = insertions[position];



      position = position.toLowerCase();



      insert = Element._insertionTranslations[position];







      if (content && content.toElement) content = content.toElement();



      if (Object.isElement(content)) {



        insert(element, content);



        continue;



      }







      content = Object.toHTML(content);







      tagName = ((position == 'before' || position == 'after')



        ? element.parentNode : element).tagName.toUpperCase();







      childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());







      if (position == 'top' || position == 'after') childNodes.reverse();



      childNodes.each(insert.curry(element));







      content.evalScripts.bind(content).defer();



    }







    return element;



  },







  wrap: function(element, wrapper, attributes) {



    element = $(element);



    if (Object.isElement(wrapper))



      $(wrapper).writeAttribute(attributes || { });



    else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);



    else wrapper = new Element('div', wrapper);



    if (element.parentNode)



      element.parentNode.replaceChild(wrapper, element);



    wrapper.appendChild(element);



    return wrapper;



  },







  inspect: function(element) {



    element = $(element);



    var result = '<' + element.tagName.toLowerCase();



    $H({'id': 'id', 'className': 'class'}).each(function(pair) {



      var property = pair.first(),



          attribute = pair.last(),



          value = (element[property] || '').toString();



      if (value) result += ' ' + attribute + '=' + value.inspect(true);



    });



    return result + '>';



  },







  recursivelyCollect: function(element, property, maximumLength) {



    element = $(element);



    maximumLength = maximumLength || -1;



    var elements = [];







    while (element = element[property]) {



      if (element.nodeType == 1)



        elements.push(Element.extend(element));



      if (elements.length == maximumLength)



        break;



    }







    return elements;



  },







  ancestors: function(element) {



    return Element.recursivelyCollect(element, 'parentNode');



  },







  descendants: function(element) {



    return Element.select(element, "*");



  },







  firstDescendant: function(element) {



    element = $(element).firstChild;



    while (element && element.nodeType != 1) element = element.nextSibling;



    return $(element);



  },







  immediateDescendants: function(element) {



    var results = [], child = $(element).firstChild;



    while (child) {



      if (child.nodeType === 1) {



        results.push(Element.extend(child));



      }



      child = child.nextSibling;



    }



    return results;



  },







  previousSiblings: function(element, maximumLength) {



    return Element.recursivelyCollect(element, 'previousSibling');



  },







  nextSiblings: function(element) {



    return Element.recursivelyCollect(element, 'nextSibling');



  },







  siblings: function(element) {



    element = $(element);



    return Element.previousSiblings(element).reverse()



      .concat(Element.nextSiblings(element));



  },







  match: function(element, selector) {



    element = $(element);



    if (Object.isString(selector))



      return Prototype.Selector.match(element, selector);



    return selector.match(element);



  },







  up: function(element, expression, index) {



    element = $(element);



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



    var ancestors = Element.ancestors(element);



    return Object.isNumber(expression) ? ancestors[expression] :



      Prototype.Selector.find(ancestors, expression, index);



  },







  down: function(element, expression, index) {



    element = $(element);



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



    return Object.isNumber(expression) ? Element.descendants(element)[expression] :



      Element.select(element, expression)[index || 0];



  },







  previous: function(element, expression, index) {



    element = $(element);



    if (Object.isNumber(expression)) index = expression, expression = false;



    if (!Object.isNumber(index)) index = 0;







    if (expression) {



      return Prototype.Selector.find(element.previousSiblings(), expression, index);



    } else {



      return element.recursivelyCollect("previousSibling", index + 1)[index];



    }



  },







  next: function(element, expression, index) {



    element = $(element);



    if (Object.isNumber(expression)) index = expression, expression = false;



    if (!Object.isNumber(index)) index = 0;







    if (expression) {



      return Prototype.Selector.find(element.nextSiblings(), expression, index);



    } else {



      var maximumLength = Object.isNumber(index) ? index + 1 : 1;



      return element.recursivelyCollect("nextSibling", index + 1)[index];



    }



  },











  select: function(element) {



    element = $(element);



    var expressions = Array.prototype.slice.call(arguments, 1).join(', ');



    return Prototype.Selector.select(expressions, element);



  },







  adjacent: function(element) {



    element = $(element);



    var expressions = Array.prototype.slice.call(arguments, 1).join(', ');



    return Prototype.Selector.select(expressions, element.parentNode).without(element);



  },







  identify: function(element) {



    element = $(element);



    var id = Element.readAttribute(element, 'id');



    if (id) return id;



    do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id));



    Element.writeAttribute(element, 'id', id);



    return id;



  },







  readAttribute: function(element, name) {



    element = $(element);



    if (Prototype.Browser.IE) {



      var t = Element._attributeTranslations.read;



      if (t.values[name]) return t.values[name](element, name);



      if (t.names[name]) name = t.names[name];



      if (name.include(':')) {



        return (!element.attributes || !element.attributes[name]) ? null :



         element.attributes[name].value;



      }



    }



    return element.getAttribute(name);



  },







  writeAttribute: function(element, name, value) {



    element = $(element);



    var attributes = { }, t = Element._attributeTranslations.write;







    if (typeof name == 'object') attributes = name;



    else attributes[name] = Object.isUndefined(value) ? true : value;







    for (var attr in attributes) {



      name = t.names[attr] || attr;



      value = attributes[attr];



      if (t.values[attr]) name = t.values[attr](element, value);



      if (value === false || value === null)



        element.removeAttribute(name);



      else if (value === true)



        element.setAttribute(name, name);



      else element.setAttribute(name, value);



    }



    return element;



  },







  getHeight: function(element) {



    return Element.getDimensions(element).height;



  },







  getWidth: function(element) {



    return Element.getDimensions(element).width;



  },







  classNames: function(element) {



    return new Element.ClassNames(element);



  },







  hasClassName: function(element, className) {



    if (!(element = $(element))) return;



    var elementClassName = element.className;



    return (elementClassName.length > 0 && (elementClassName == className ||



      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));



  },







  addClassName: function(element, className) {



    if (!(element = $(element))) return;



    if (!Element.hasClassName(element, className))



      element.className += (element.className ? ' ' : '') + className;



    return element;



  },







  removeClassName: function(element, className) {



    if (!(element = $(element))) return;



    element.className = element.className.replace(



      new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();



    return element;



  },







  toggleClassName: function(element, className) {



    if (!(element = $(element))) return;



    return Element[Element.hasClassName(element, className) ?



      'removeClassName' : 'addClassName'](element, className);



  },







  cleanWhitespace: function(element) {



    element = $(element);



    var node = element.firstChild;



    while (node) {



      var nextNode = node.nextSibling;



      if (node.nodeType == 3 && !/\S/.test(node.nodeValue))



        element.removeChild(node);



      node = nextNode;



    }



    return element;



  },







  empty: function(element) {



    return $(element).innerHTML.blank();



  },







  descendantOf: function(element, ancestor) {



    element = $(element), ancestor = $(ancestor);







    if (element.compareDocumentPosition)



      return (element.compareDocumentPosition(ancestor) & 8) === 8;







    if (ancestor.contains)



      return ancestor.contains(element) && ancestor !== element;







    while (element = element.parentNode)



      if (element == ancestor) return true;







    return false;



  },







  scrollTo: function(element) {



    element = $(element);



    var pos = Element.cumulativeOffset(element);



    window.scrollTo(pos[0], pos[1]);



    return element;



  },







  getStyle: function(element, style) {



    element = $(element);



    style = style == 'float' ? 'cssFloat' : style.camelize();



    var value = element.style[style];



    if (!value || value == 'auto') {



      var css = document.defaultView.getComputedStyle(element, null);



      value = css ? css[style] : null;



    }



    if (style == 'opacity') return value ? parseFloat(value) : 1.0;



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



  },







  getOpacity: function(element) {



    return $(element).getStyle('opacity');



  },







  setStyle: function(element, styles) {



    element = $(element);



    var elementStyle = element.style, match;



    if (Object.isString(styles)) {



      element.style.cssText += ';' + styles;



      return styles.include('opacity') ?



        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;



    }



    for (var property in styles)



      if (property == 'opacity') element.setOpacity(styles[property]);



      else



        elementStyle[(property == 'float' || property == 'cssFloat') ?



          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :



            property] = styles[property];







    return element;



  },







  setOpacity: function(element, value) {



    element = $(element);



    element.style.opacity = (value == 1 || value === '') ? '' :



      (value < 0.00001) ? 0 : value;



    return element;



  },







  makePositioned: function(element) {



    element = $(element);



    var pos = Element.getStyle(element, 'position');



    if (pos == 'static' || !pos) {



      element._madePositioned = true;



      element.style.position = 'relative';



      if (Prototype.Browser.Opera) {



        element.style.top = 0;



        element.style.left = 0;



      }



    }



    return element;



  },







  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 = '';



    }



    return element;



  },







  makeClipping: function(element) {



    element = $(element);



    if (element._overflow) return element;



    element._overflow = Element.getStyle(element, 'overflow') || 'auto';



    if (element._overflow !== 'hidden')



      element.style.overflow = 'hidden';



    return element;



  },







  undoClipping: function(element) {



    element = $(element);



    if (!element._overflow) return element;



    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;



    element._overflow = null;



    return element;



  },







  clonePosition: function(element, source) {



    var options = Object.extend({



      setLeft:    true,



      setTop:     true,



      setWidth:   true,



      setHeight:  true,



      offsetTop:  0,



      offsetLeft: 0



    }, arguments[2] || { });







    source = $(source);



    var p = Element.viewportOffset(source), delta = [0, 0], parent = null;







    element = $(element);







    if (Element.getStyle(element, 'position') == 'absolute') {



      parent = Element.getOffsetParent(element);



      delta = Element.viewportOffset(parent);



    }







    if (parent == document.body) {



      delta[0] -= document.body.offsetLeft;



      delta[1] -= document.body.offsetTop;



    }







    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';



    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';



    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';



    if (options.setHeight) element.style.height = source.offsetHeight + 'px';



    return element;



  }



};







Object.extend(Element.Methods, {



  getElementsBySelector: Element.Methods.select,







  childElements: Element.Methods.immediateDescendants



});







Element._attributeTranslations = {



  write: {



    names: {



      className: 'class',



      htmlFor:   'for'



    },



    values: { }



  }



};







if (Prototype.Browser.Opera) {



  Element.Methods.getStyle = Element.Methods.getStyle.wrap(



    function(proceed, element, style) {



      switch (style) {



        case 'height': case 'width':



          if (!Element.visible(element)) return null;







          var dim = parseInt(proceed(element, style), 10);







          if (dim !== element['offset' + style.capitalize()])



            return dim + 'px';







          var properties;



          if (style === 'height') {



            properties = ['border-top-width', 'padding-top',



             'padding-bottom', 'border-bottom-width'];



          }



          else {



            properties = ['border-left-width', 'padding-left',



             'padding-right', 'border-right-width'];



          }



          return properties.inject(dim, function(memo, property) {



            var val = proceed(element, property);



            return val === null ? memo : memo - parseInt(val, 10);



          }) + 'px';



        default: return proceed(element, style);



      }



    }



  );







  Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(



    function(proceed, element, attribute) {



      if (attribute === 'title') return element.title;



      return proceed(element, attribute);



    }



  );



}







else if (Prototype.Browser.IE) {



  Element.Methods.getStyle = function(element, style) {



    element = $(element);



    style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();



    var value = element.style[style];



    if (!value && element.currentStyle) value = element.currentStyle[style];







    if (style == 'opacity') {



      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))



        if (value[1]) return parseFloat(value[1]) / 100;



      return 1.0;



    }







    if (value == 'auto') {



      if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))



        return element['offset' + style.capitalize()] + 'px';



      return null;



    }



    return value;



  };







  Element.Methods.setOpacity = function(element, value) {



    function stripAlpha(filter){



      return filter.replace(/alpha\([^\)]*\)/gi,'');



    }



    element = $(element);



    var currentStyle = element.currentStyle;



    if ((currentStyle && !currentStyle.hasLayout) ||



      (!currentStyle && element.style.zoom == 'normal'))



        element.style.zoom = 1;







    var filter = element.getStyle('filter'), style = element.style;



    if (value == 1 || value === '') {



      (filter = stripAlpha(filter)) ?



        style.filter = filter : style.removeAttribute('filter');



      return element;



    } else if (value < 0.00001) value = 0;



    style.filter = stripAlpha(filter) +



      'alpha(opacity=' + (value * 100) + ')';



    return element;



  };







  Element._attributeTranslations = (function(){







    var classProp = 'className',



        forProp = 'for',



        el = document.createElement('div');







    el.setAttribute(classProp, 'x');







    if (el.className !== 'x') {



      el.setAttribute('class', 'x');



      if (el.className === 'x') {



        classProp = 'class';



      }



    }



    el = null;







    el = document.createElement('label');



    el.setAttribute(forProp, 'x');



    if (el.htmlFor !== 'x') {



      el.setAttribute('htmlFor', 'x');



      if (el.htmlFor === 'x') {



        forProp = 'htmlFor';



      }



    }



    el = null;







    return {



      read: {



        names: {



          'class':      classProp,



          'className':  classProp,



          'for':        forProp,



          'htmlFor':    forProp



        },



        values: {



          _getAttr: function(element, attribute) {



            return element.getAttribute(attribute);



          },



          _getAttr2: function(element, attribute) {



            return element.getAttribute(attribute, 2);



          },



          _getAttrNode: function(element, attribute) {



            var node = element.getAttributeNode(attribute);



            return node ? node.value : "";



          },



          _getEv: (function(){







            var el = document.createElement('div'), f;



            el.onclick = Prototype.emptyFunction;



            var value = el.getAttribute('onclick');







            if (String(value).indexOf('{') > -1) {



              f = function(element, attribute) {



                attribute = element.getAttribute(attribute);



                if (!attribute) return null;



                attribute = attribute.toString();



                attribute = attribute.split('{')[1];



                attribute = attribute.split('}')[0];



                return attribute.strip();



              };



            }



            else if (value === '') {



              f = function(element, attribute) {



                attribute = element.getAttribute(attribute);



                if (!attribute) return null;



                return attribute.strip();



              };



            }



            el = null;



            return f;



          })(),



          _flag: function(element, attribute) {



            return $(element).hasAttribute(attribute) ? attribute : null;



          },



          style: function(element) {



            return element.style.cssText.toLowerCase();



          },



          title: function(element) {



            return element.title;



          }



        }



      }



    }



  })();







  Element._attributeTranslations.write = {



    names: Object.extend({



      cellpadding: 'cellPadding',



      cellspacing: 'cellSpacing'



    }, Element._attributeTranslations.read.names),



    values: {



      checked: function(element, value) {



        element.checked = !!value;



      },







      style: function(element, value) {



        element.style.cssText = value ? value : '';



      }



    }



  };







  Element._attributeTranslations.has = {};







  $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +



      'encType maxLength readOnly longDesc frameBorder').each(function(attr) {



    Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;



    Element._attributeTranslations.has[attr.toLowerCase()] = attr;



  });







  (function(v) {



    Object.extend(v, {



      href:        v._getAttr2,



      src:         v._getAttr2,



      type:        v._getAttr,



      action:      v._getAttrNode,



      disabled:    v._flag,



      checked:     v._flag,



      readonly:    v._flag,



      multiple:    v._flag,



      onload:      v._getEv,



      onunload:    v._getEv,



      onclick:     v._getEv,



      ondblclick:  v._getEv,



      onmousedown: v._getEv,



      onmouseup:   v._getEv,



      onmouseover: v._getEv,



      onmousemove: v._getEv,



      onmouseout:  v._getEv,



      onfocus:     v._getEv,



      onblur:      v._getEv,



      onkeypress:  v._getEv,



      onkeydown:   v._getEv,



      onkeyup:     v._getEv,



      onsubmit:    v._getEv,



      onreset:     v._getEv,



      onselect:    v._getEv,



      onchange:    v._getEv



    });



  })(Element._attributeTranslations.read.values);







  if (Prototype.BrowserFeatures.ElementExtensions) {



    (function() {



      function _descendants(element) {



        var nodes = element.getElementsByTagName('*'), results = [];



        for (var i = 0, node; node = nodes[i]; i++)



          if (node.tagName !== "!") // Filter out comment nodes.



            results.push(node);



        return results;



      }







      Element.Methods.down = function(element, expression, index) {



        element = $(element);



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



        return Object.isNumber(expression) ? _descendants(element)[expression] :



          Element.select(element, expression)[index || 0];



      }



    })();



  }







}







else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {



  Element.Methods.setOpacity = function(element, value) {



    element = $(element);



    element.style.opacity = (value == 1) ? 0.999999 :



      (value === '') ? '' : (value < 0.00001) ? 0 : value;



    return element;



  };



}







else if (Prototype.Browser.WebKit) {



  Element.Methods.setOpacity = function(element, value) {



    element = $(element);



    element.style.opacity = (value == 1 || value === '') ? '' :



      (value < 0.00001) ? 0 : value;







    if (value == 1)



      if (element.tagName.toUpperCase() == 'IMG' && element.width) {



        element.width++; element.width--;



      } else try {



        var n = document.createTextNode(' ');



        element.appendChild(n);



        element.removeChild(n);



      } catch (e) { }







    return element;



  };



}







if ('outerHTML' in document.documentElement) {



  Element.Methods.replace = function(element, content) {



    element = $(element);







    if (content && content.toElement) content = content.toElement();



    if (Object.isElement(content)) {



      element.parentNode.replaceChild(content, element);



      return element;



    }







    content = Object.toHTML(content);



    var parent = element.parentNode, tagName = parent.tagName.toUpperCase();







    if (Element._insertionTranslations.tags[tagName]) {



      var nextSibling = element.next(),



          fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());



      parent.removeChild(element);



      if (nextSibling)



        fragments.each(function(node) { parent.insertBefore(node, nextSibling) });



      else



        fragments.each(function(node) { parent.appendChild(node) });



    }



    else element.outerHTML = content.stripScripts();







    content.evalScripts.bind(content).defer();



    return element;



  };



}







Element._returnOffset = function(l, t) {



  var result = [l, t];



  result.left = l;



  result.top = t;



  return result;



};







Element._getContentFromAnonymousElement = function(tagName, html, force) {



  var div = new Element('div'),



      t = Element._insertionTranslations.tags[tagName];







  var workaround = false;



  if (t) workaround = true;



  else if (force) {



    workaround = true;



    t = ['', '', 0];



  }







  if (workaround) {



    div.innerHTML = '&nbsp;' + t[0] + html + t[1];



    div.removeChild(div.firstChild);



    for (var i = t[2]; i--; ) {



      div = div.firstChild;



    }



  }



  else {



    div.innerHTML = html;



  }



  return $A(div.childNodes);



};







Element._insertionTranslations = {



  before: function(element, node) {



    element.parentNode.insertBefore(node, element);



  },



  top: function(element, node) {



    element.insertBefore(node, element.firstChild);



  },



  bottom: function(element, node) {



    element.appendChild(node);



  },



  after: function(element, node) {



    element.parentNode.insertBefore(node, element.nextSibling);



  },



  tags: {



    TABLE:  ['<table>',                '</table>',                   1],



    TBODY:  ['<table><tbody>',         '</tbody></table>',           2],



    TR:     ['<table><tbody><tr>',     '</tr></tbody></table>',      3],



    TD:     ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],



    SELECT: ['<select>',               '</select>',                  1]



  }



};







(function() {



  var tags = Element._insertionTranslations.tags;



  Object.extend(tags, {



    THEAD: tags.TBODY,



    TFOOT: tags.TBODY,



    TH:    tags.TD



  });



})();







Element.Methods.Simulated = {



  hasAttribute: function(element, attribute) {



    attribute = Element._attributeTranslations.has[attribute] || attribute;



    var node = $(element).getAttributeNode(attribute);



    return !!(node && node.specified);



  }



};







Element.Methods.ByTag = { };







Object.extend(Element, Element.Methods);







(function(div) {







  if (!Prototype.BrowserFeatures.ElementExtensions && div['__proto__']) {



    window.HTMLElement = { };



    window.HTMLElement.prototype = div['__proto__'];



    Prototype.BrowserFeatures.ElementExtensions = true;



  }







  div = null;







})(document.createElement('div'));







Element.extend = (function() {







  function checkDeficiency(tagName) {



    if (typeof window.Element != 'undefined') {



      var proto = window.Element.prototype;



      if (proto) {



        var id = '_' + (Math.random()+'').slice(2),



            el = document.createElement(tagName);



        proto[id] = 'x';



        var isBuggy = (el[id] !== 'x');



        delete proto[id];



        el = null;



        return isBuggy;



      }



    }



    return false;



  }







  function extendElementWith(element, methods) {



    for (var property in methods) {



      var value = methods[property];



      if (Object.isFunction(value) && !(property in element))



        element[property] = value.methodize();



    }



  }







  var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkDeficiency('object');







  if (Prototype.BrowserFeatures.SpecificElementExtensions) {



    if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY) {



      return function(element) {



        if (element && typeof element._extendedByPrototype == 'undefined') {



          var t = element.tagName;



          if (t && (/^(?:object|applet|embed)$/i.test(t))) {



            extendElementWith(element, Element.Methods);



            extendElementWith(element, Element.Methods.Simulated);



            extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);



          }



        }



        return element;



      }



    }



    return Prototype.K;



  }







  var Methods = { }, ByTag = Element.Methods.ByTag;







  var extend = Object.extend(function(element) {



    if (!element || typeof element._extendedByPrototype != 'undefined' ||



        element.nodeType != 1 || element == window) return element;







    var methods = Object.clone(Methods),



        tagName = element.tagName.toUpperCase();







    if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);







    extendElementWith(element, methods);







    element._extendedByPrototype = Prototype.emptyFunction;



    return element;







  }, {



    refresh: function() {



      if (!Prototype.BrowserFeatures.ElementExtensions) {



        Object.extend(Methods, Element.Methods);



        Object.extend(Methods, Element.Methods.Simulated);



      }



    }



  });







  extend.refresh();



  return extend;



})();







if (document.documentElement.hasAttribute) {



  Element.hasAttribute = function(element, attribute) {



    return element.hasAttribute(attribute);



  };



}



else {



  Element.hasAttribute = Element.Methods.Simulated.hasAttribute;



}







Element.addMethods = function(methods) {



  var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;







  if (!methods) {



    Object.extend(Form, Form.Methods);



    Object.extend(Form.Element, Form.Element.Methods);



    Object.extend(Element.Methods.ByTag, {



      "FORM":     Object.clone(Form.Methods),



      "INPUT":    Object.clone(Form.Element.Methods),



      "SELECT":   Object.clone(Form.Element.Methods),



      "TEXTAREA": Object.clone(Form.Element.Methods),



      "BUTTON":   Object.clone(Form.Element.Methods)



    });



  }







  if (arguments.length == 2) {



    var tagName = methods;



    methods = arguments[1];



  }







  if (!tagName) Object.extend(Element.Methods, methods || { });



  else {



    if (Object.isArray(tagName)) tagName.each(extend);



    else extend(tagName);



  }







  function extend(tagName) {



    tagName = tagName.toUpperCase();



    if (!Element.Methods.ByTag[tagName])



      Element.Methods.ByTag[tagName] = { };



    Object.extend(Element.Methods.ByTag[tagName], methods);



  }







  function copy(methods, destination, onlyIfAbsent) {



    onlyIfAbsent = onlyIfAbsent || false;



    for (var property in methods) {



      var value = methods[property];



      if (!Object.isFunction(value)) continue;



      if (!onlyIfAbsent || !(property in destination))



        destination[property] = value.methodize();



    }



  }







  function findDOMClass(tagName) {



    var klass;



    var trans = {



      "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",



      "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",



      "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",



      "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",



      "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":



      "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":



      "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":



      "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":



      "FrameSet", "IFRAME": "IFrame"



    };



    if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';



    if (window[klass]) return window[klass];



    klass = 'HTML' + tagName + 'Element';



    if (window[klass]) return window[klass];



    klass = 'HTML' + tagName.capitalize() + 'Element';



    if (window[klass]) return window[klass];







    var element = document.createElement(tagName),



        proto = element['__proto__'] || element.constructor.prototype;







    element = null;



    return proto;



  }







  var elementPrototype = window.HTMLElement ? HTMLElement.prototype :



   Element.prototype;







  if (F.ElementExtensions) {



    copy(Element.Methods, elementPrototype);



    copy(Element.Methods.Simulated, elementPrototype, true);



  }







  if (F.SpecificElementExtensions) {



    for (var tag in Element.Methods.ByTag) {



      var klass = findDOMClass(tag);



      if (Object.isUndefined(klass)) continue;



      copy(T[tag], klass.prototype);



    }



  }







  Object.extend(Element, Element.Methods);



  delete Element.ByTag;







  if (Element.extend.refresh) Element.extend.refresh();



  Element.cache = { };



};











document.viewport = {







  getDimensions: function() {



    return { width: this.getWidth(), height: this.getHeight() };



  },







  getScrollOffsets: function() {



    return Element._returnOffset(



      window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,



      window.pageYOffset || document.documentElement.scrollTop  || document.body.scrollTop);



  }



};







(function(viewport) {



  var B = Prototype.Browser, doc = document, element, property = {};







  function getRootElement() {



    if (B.WebKit && !doc.evaluate)



      return document;







    if (B.Opera && window.parseFloat(window.opera.version()) < 9.5)



      return document.body;







    return document.documentElement;



  }







  function define(D) {



    if (!element) element = getRootElement();







    property[D] = 'client' + D;







    viewport['get' + D] = function() { return element[property[D]] };



    return viewport['get' + D]();



  }







  viewport.getWidth  = define.curry('Width');







  viewport.getHeight = define.curry('Height');



})(document.viewport);











Element.Storage = {



  UID: 1



};







Element.addMethods({



  getStorage: function(element) {



    if (!(element = $(element))) return;







    var uid;



    if (element === window) {



      uid = 0;



    } else {



      if (typeof element._prototypeUID === "undefined")



        element._prototypeUID = Element.Storage.UID++;



      uid = element._prototypeUID;



    }







    if (!Element.Storage[uid])



      Element.Storage[uid] = $H();







    return Element.Storage[uid];



  },







  store: function(element, key, value) {



    if (!(element = $(element))) return;







    if (arguments.length === 2) {



      Element.getStorage(element).update(key);



    } else {



      Element.getStorage(element).set(key, value);



    }







    return element;



  },







  retrieve: function(element, key, defaultValue) {



    if (!(element = $(element))) return;



    var hash = Element.getStorage(element), value = hash.get(key);







    if (Object.isUndefined(value)) {



      hash.set(key, defaultValue);



      value = defaultValue;



    }







    return value;



  },







  clone: function(element, deep) {



    if (!(element = $(element))) return;



    var clone = element.cloneNode(deep);



    clone._prototypeUID = void 0;



    if (deep) {



      var descendants = Element.select(clone, '*'),



          i = descendants.length;



      while (i--) {



        descendants[i]._prototypeUID = void 0;



      }



    }



    return Element.extend(clone);



  },







  purge: function(element) {



    if (!(element = $(element))) return;



    var purgeElement = Element._purgeElement;







    purgeElement(element);







    var descendants = element.getElementsByTagName('*'),



     i = descendants.length;







    while (i--) purgeElement(descendants[i]);







    return null;



  }



});







(function() {







  function toDecimal(pctString) {



    var match = pctString.match(/^(\d+)%?$/i);



    if (!match) return null;



    return (Number(match[1]) / 100);



  }







  function getPixelValue(value, property, context) {



    var element = null;



    if (Object.isElement(value)) {



      element = value;



      value = element.getStyle(property);



    }







    if (value === null) {



      return null;



    }







    if ((/^(?:-)?\d+(\.\d+)?(px)?$/i).test(value)) {



      return window.parseFloat(value);



    }







    var isPercentage = value.include('%'), isViewport = (context === document.viewport);







    if (/\d/.test(value) && element && element.runtimeStyle && !(isPercentage && isViewport)) {



      var style = element.style.left, rStyle = element.runtimeStyle.left;



      element.runtimeStyle.left = element.currentStyle.left;



      element.style.left = value || 0;



      value = element.style.pixelLeft;



      element.style.left = style;



      element.runtimeStyle.left = rStyle;







      return value;



    }







    if (element && isPercentage) {



      context = context || element.parentNode;



      var decimal = toDecimal(value);



      var whole = null;



      var position = element.getStyle('position');







      var isHorizontal = property.include('left') || property.include('right') ||



       property.include('width');







      var isVertical =  property.include('top') || property.include('bottom') ||



        property.include('height');







      if (context === document.viewport) {



        if (isHorizontal) {



          whole = document.viewport.getWidth();



        } else if (isVertical) {



          whole = document.viewport.getHeight();



        }



      } else {



        if (isHorizontal) {



          whole = $(context).measure('width');



        } else if (isVertical) {



          whole = $(context).measure('height');



        }



      }







      return (whole === null) ? 0 : whole * decimal;



    }







    return 0;



  }







  function toCSSPixels(number) {



    if (Object.isString(number) && number.endsWith('px')) {



      return number;



    }



    return number + 'px';



  }







  function isDisplayed(element) {



    var originalElement = element;



    while (element && element.parentNode) {



      var display = element.getStyle('display');



      if (display === 'none') {



        return false;



      }



      element = $(element.parentNode);



    }



    return true;



  }







  var hasLayout = Prototype.K;



  if ('currentStyle' in document.documentElement) {



    hasLayout = function(element) {



      if (!element.currentStyle.hasLayout) {



        element.style.zoom = 1;



      }



      return element;



    };



  }







  function cssNameFor(key) {



    if (key.include('border')) key = key + '-width';



    return key.camelize();



  }







  Element.Layout = Class.create(Hash, {



    initialize: function($super, element, preCompute) {



      $super();



      this.element = $(element);







      Element.Layout.PROPERTIES.each( function(property) {



        this._set(property, null);



      }, this);







      if (preCompute) {



        this._preComputing = true;



        this._begin();



        Element.Layout.PROPERTIES.each( this._compute, this );



        this._end();



        this._preComputing = false;



      }



    },







    _set: function(property, value) {



      return Hash.prototype.set.call(this, property, value);



    },







    set: function(property, value) {



      throw "Properties of Element.Layout are read-only.";



    },







    get: function($super, property) {



      var value = $super(property);



      return value === null ? this._compute(property) : value;



    },







    _begin: function() {



      if (this._prepared) return;







      var element = this.element;



      if (isDisplayed(element)) {



        this._prepared = true;



        return;



      }







      var originalStyles = {



        position:   element.style.position   || '',



        width:      element.style.width      || '',



        visibility: element.style.visibility || '',



        display:    element.style.display    || ''



      };







      element.store('prototype_original_styles', originalStyles);







      var position = element.getStyle('position'),



       width = element.getStyle('width');







      if (width === "0px" || width === null) {



        element.style.display = 'block';



        width = element.getStyle('width');



      }







      var context = (position === 'fixed') ? document.viewport :



       element.parentNode;







      element.setStyle({



        position:   'absolute',



        visibility: 'hidden',



        display:    'block'



      });







      var positionedWidth = element.getStyle('width');







      var newWidth;



      if (width && (positionedWidth === width)) {



        newWidth = getPixelValue(element, 'width', context);



      } else if (position === 'absolute' || position === 'fixed') {



        newWidth = getPixelValue(element, 'width', context);



      } else {



        var parent = element.parentNode, pLayout = $(parent).getLayout();







        newWidth = pLayout.get('width') -



         this.get('margin-left') -



         this.get('border-left') -



         this.get('padding-left') -



         this.get('padding-right') -



         this.get('border-right') -



         this.get('margin-right');



      }







      element.setStyle({ width: newWidth + 'px' });







      this._prepared = true;



    },







    _end: function() {



      var element = this.element;



      var originalStyles = element.retrieve('prototype_original_styles');



      element.store('prototype_original_styles', null);



      element.setStyle(originalStyles);



      this._prepared = false;



    },







    _compute: function(property) {



      var COMPUTATIONS = Element.Layout.COMPUTATIONS;



      if (!(property in COMPUTATIONS)) {



        throw "Property not found.";



      }







      return this._set(property, COMPUTATIONS[property].call(this, this.element));



    },







    toObject: function() {



      var args = $A(arguments);



      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :



       args.join(' ').split(' ');



      var obj = {};



      keys.each( function(key) {



        if (!Element.Layout.PROPERTIES.include(key)) return;



        var value = this.get(key);



        if (value != null) obj[key] = value;



      }, this);



      return obj;



    },







    toHash: function() {



      var obj = this.toObject.apply(this, arguments);



      return new Hash(obj);



    },







    toCSS: function() {



      var args = $A(arguments);



      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :



       args.join(' ').split(' ');



      var css = {};







      keys.each( function(key) {



        if (!Element.Layout.PROPERTIES.include(key)) return;



        if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return;







        var value = this.get(key);



        if (value != null) css[cssNameFor(key)] = value + 'px';



      }, this);



      return css;



    },







    inspect: function() {



      return "#<Element.Layout>";



    }



  });







  Object.extend(Element.Layout, {



    PROPERTIES: $w('height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height'),







    COMPOSITE_PROPERTIES: $w('padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height'),







    COMPUTATIONS: {



      'height': function(element) {



        if (!this._preComputing) this._begin();







        var bHeight = this.get('border-box-height');



        if (bHeight <= 0) {



          if (!this._preComputing) this._end();



          return 0;



        }







        var bTop = this.get('border-top'),



         bBottom = this.get('border-bottom');







        var pTop = this.get('padding-top'),



         pBottom = this.get('padding-bottom');







        if (!this._preComputing) this._end();







        return bHeight - bTop - bBottom - pTop - pBottom;



      },







      'width': function(element) {



        if (!this._preComputing) this._begin();







        var bWidth = this.get('border-box-width');



        if (bWidth <= 0) {



          if (!this._preComputing) this._end();



          return 0;



        }







        var bLeft = this.get('border-left'),



         bRight = this.get('border-right');







        var pLeft = this.get('padding-left'),



         pRight = this.get('padding-right');







        if (!this._preComputing) this._end();







        return bWidth - bLeft - bRight - pLeft - pRight;



      },







      'padding-box-height': function(element) {



        var height = this.get('height'),



         pTop = this.get('padding-top'),



         pBottom = this.get('padding-bottom');







        return height + pTop + pBottom;



      },







      'padding-box-width': function(element) {



        var width = this.get('width'),



         pLeft = this.get('padding-left'),



         pRight = this.get('padding-right');







        return width + pLeft + pRight;



      },







      'border-box-height': function(element) {



        if (!this._preComputing) this._begin();



        var height = element.offsetHeight;



        if (!this._preComputing) this._end();



        return height;



      },







      'border-box-width': function(element) {



        if (!this._preComputing) this._begin();



        var width = element.offsetWidth;



        if (!this._preComputing) this._end();



        return width;



      },







      'margin-box-height': function(element) {



        var bHeight = this.get('border-box-height'),



         mTop = this.get('margin-top'),



         mBottom = this.get('margin-bottom');







        if (bHeight <= 0) return 0;







        return bHeight + mTop + mBottom;



      },







      'margin-box-width': function(element) {



        var bWidth = this.get('border-box-width'),



         mLeft = this.get('margin-left'),



         mRight = this.get('margin-right');







        if (bWidth <= 0) return 0;







        return bWidth + mLeft + mRight;



      },







      'top': function(element) {



        var offset = element.positionedOffset();



        return offset.top;



      },







      'bottom': function(element) {



        var offset = element.positionedOffset(),



         parent = element.getOffsetParent(),



         pHeight = parent.measure('height');







        var mHeight = this.get('border-box-height');







        return pHeight - mHeight - offset.top;



      },







      'left': function(element) {



        var offset = element.positionedOffset();



        return offset.left;



      },







      'right': function(element) {



        var offset = element.positionedOffset(),



         parent = element.getOffsetParent(),



         pWidth = parent.measure('width');







        var mWidth = this.get('border-box-width');







        return pWidth - mWidth - offset.left;



      },







      'padding-top': function(element) {



        return getPixelValue(element, 'paddingTop');



      },







      'padding-bottom': function(element) {



        return getPixelValue(element, 'paddingBottom');



      },







      'padding-left': function(element) {



        return getPixelValue(element, 'paddingLeft');



      },







      'padding-right': function(element) {



        return getPixelValue(element, 'paddingRight');



      },







      'border-top': function(element) {



        return getPixelValue(element, 'borderTopWidth');



      },







      'border-bottom': function(element) {



        return getPixelValue(element, 'borderBottomWidth');



      },







      'border-left': function(element) {



        return getPixelValue(element, 'borderLeftWidth');



      },







      'border-right': function(element) {



        return getPixelValue(element, 'borderRightWidth');



      },







      'margin-top': function(element) {



        return getPixelValue(element, 'marginTop');



      },







      'margin-bottom': function(element) {



        return getPixelValue(element, 'marginBottom');



      },







      'margin-left': function(element) {



        return getPixelValue(element, 'marginLeft');



      },







      'margin-right': function(element) {



        return getPixelValue(element, 'marginRight');



      }



    }



  });







  if ('getBoundingClientRect' in document.documentElement) {



    Object.extend(Element.Layout.COMPUTATIONS, {



      'right': function(element) {



        var parent = hasLayout(element.getOffsetParent());



        var rect = element.getBoundingClientRect(),



         pRect = parent.getBoundingClientRect();







        return (pRect.right - rect.right).round();



      },







      'bottom': function(element) {



        var parent = hasLayout(element.getOffsetParent());



        var rect = element.getBoundingClientRect(),



         pRect = parent.getBoundingClientRect();







        return (pRect.bottom - rect.bottom).round();



      }



    });



  }







  Element.Offset = Class.create({



    initialize: function(left, top) {



      this.left = left.round();



      this.top  = top.round();







      this[0] = this.left;



      this[1] = this.top;



    },







    relativeTo: function(offset) {



      return new Element.Offset(



        this.left - offset.left,



        this.top  - offset.top



      );



    },







    inspect: function() {



      return "#<Element.Offset left: #{left} top: #{top}>".interpolate(this);



    },







    toString: function() {



      return "[#{left}, #{top}]".interpolate(this);



    },







    toArray: function() {



      return [this.left, this.top];



    }



  });







  function getLayout(element, preCompute) {



    return new Element.Layout(element, preCompute);



  }







  function measure(element, property) {



    return $(element).getLayout().get(property);



  }







  function getDimensions(element) {



    element = $(element);



    var display = Element.getStyle(element, 'display');







    if (display && display !== 'none') {



      return { width: element.offsetWidth, height: element.offsetHeight };



    }







    var style = element.style;



    var originalStyles = {



      visibility: style.visibility,



      position:   style.position,



      display:    style.display



    };







    var newStyles = {



      visibility: 'hidden',



      display:    'block'



    };







    if (originalStyles.position !== 'fixed')



      newStyles.position = 'absolute';







    Element.setStyle(element, newStyles);







    var dimensions = {



      width:  element.offsetWidth,



      height: element.offsetHeight



    };







    Element.setStyle(element, originalStyles);







    return dimensions;



  }







  function getOffsetParent(element) {



    element = $(element);







    if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element))



      return $(document.body);







    var isInline = (Element.getStyle(element, 'display') === 'inline');



    if (!isInline && element.offsetParent) return $(element.offsetParent);







    while ((element = element.parentNode) && element !== document.body) {



      if (Element.getStyle(element, 'position') !== 'static') {



        return isHtml(element) ? $(document.body) : $(element);



      }



    }







    return $(document.body);



  }











  function cumulativeOffset(element) {



    element = $(element);



    var valueT = 0, valueL = 0;



    if (element.parentNode) {



      do {



        valueT += element.offsetTop  || 0;



        valueL += element.offsetLeft || 0;



        element = element.offsetParent;



      } while (element);



    }



    return new Element.Offset(valueL, valueT);



  }







  function positionedOffset(element) {



    element = $(element);







    var layout = element.getLayout();







    var valueT = 0, valueL = 0;



    do {



      valueT += element.offsetTop  || 0;



      valueL += element.offsetLeft || 0;



      element = element.offsetParent;



      if (element) {



        if (isBody(element)) break;



        var p = Element.getStyle(element, 'position');



        if (p !== 'static') break;



      }



    } while (element);







    valueL -= layout.get('margin-top');



    valueT -= layout.get('margin-left');







    return new Element.Offset(valueL, valueT);



  }







  function cumulativeScrollOffset(element) {



    var valueT = 0, valueL = 0;



    do {



      valueT += element.scrollTop  || 0;



      valueL += element.scrollLeft || 0;



      element = element.parentNode;



    } while (element);



    return new Element.Offset(valueL, valueT);



  }







  function viewportOffset(forElement) {



    element = $(element);



    var valueT = 0, valueL = 0, docBody = document.body;







    var element = forElement;



    do {



      valueT += element.offsetTop  || 0;



      valueL += element.offsetLeft || 0;



      if (element.offsetParent == docBody &&



        Element.getStyle(element, 'position') == 'absolute') break;



    } while (element = element.offsetParent);







    element = forElement;



    do {



      if (element != docBody) {



        valueT -= element.scrollTop  || 0;



        valueL -= element.scrollLeft || 0;



      }



    } while (element = element.parentNode);



    return new Element.Offset(valueL, valueT);



  }







  function absolutize(element) {



    element = $(element);







    if (Element.getStyle(element, 'position') === 'absolute') {



      return element;



    }







    var offsetParent = getOffsetParent(element);



    var eOffset = element.viewportOffset(),



     pOffset = offsetParent.viewportOffset();







    var offset = eOffset.relativeTo(pOffset);



    var layout = element.getLayout();







    element.store('prototype_absolutize_original_styles', {



      left:   element.getStyle('left'),



      top:    element.getStyle('top'),



      width:  element.getStyle('width'),



      height: element.getStyle('height')



    });







    element.setStyle({



      position: 'absolute',



      top:    offset.top + 'px',



      left:   offset.left + 'px',



      width:  layout.get('width') + 'px',



      height: layout.get('height') + 'px'



    });







    return element;



  }







  function relativize(element) {



    element = $(element);



    if (Element.getStyle(element, 'position') === 'relative') {



      return element;



    }







    var originalStyles =



     element.retrieve('prototype_absolutize_original_styles');







    if (originalStyles) element.setStyle(originalStyles);



    return element;



  }







  if (Prototype.Browser.IE) {



    getOffsetParent = getOffsetParent.wrap(



      function(proceed, element) {



        element = $(element);







        if (isDocument(element) || isDetached(element) || isBody(element) || isHtml(element))



          return $(document.body);







        var position = element.getStyle('position');



        if (position !== 'static') return proceed(element);







        element.setStyle({ position: 'relative' });



        var value = proceed(element);



        element.setStyle({ position: position });



        return value;



      }



    );







    positionedOffset = positionedOffset.wrap(function(proceed, element) {



      element = $(element);



      if (!element.parentNode) return new Element.Offset(0, 0);



      var position = element.getStyle('position');



      if (position !== 'static') return proceed(element);







      var offsetParent = element.getOffsetParent();



      if (offsetParent && offsetParent.getStyle('position') === 'fixed')



        hasLayout(offsetParent);







      element.setStyle({ position: 'relative' });



      var value = proceed(element);



      element.setStyle({ position: position });



      return value;



    });



  } else if (Prototype.Browser.Webkit) {



    cumulativeOffset = function(element) {



      element = $(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 new Element.Offset(valueL, valueT);



    };



  }











  Element.addMethods({



    getLayout:              getLayout,



    measure:                measure,



    getDimensions:          getDimensions,



    getOffsetParent:        getOffsetParent,



    cumulativeOffset:       cumulativeOffset,



    positionedOffset:       positionedOffset,



    cumulativeScrollOffset: cumulativeScrollOffset,



    viewportOffset:         viewportOffset,



    absolutize:             absolutize,



    relativize:             relativize



  });







  function isBody(element) {



    return element.nodeName.toUpperCase() === 'BODY';



  }







  function isHtml(element) {



    return element.nodeName.toUpperCase() === 'HTML';



  }







  function isDocument(element) {



    return element.nodeType === Node.DOCUMENT_NODE;



  }







  function isDetached(element) {



    return element !== document.body &&



     !Element.descendantOf(element, document.body);



  }







  if ('getBoundingClientRect' in document.documentElement) {



    Element.addMethods({



      viewportOffset: function(element) {



        element = $(element);



        if (isDetached(element)) return new Element.Offset(0, 0);







        var rect = element.getBoundingClientRect(),



         docEl = document.documentElement;



        return new Element.Offset(rect.left - docEl.clientLeft,



         rect.top - docEl.clientTop);



      }



    });



  }



})();



window.$$ = function() {



  var expression = $A(arguments).join(', ');



  return Prototype.Selector.select(expression, document);



};







Prototype.Selector = (function() {







  function select() {



    throw new Error('Method "Prototype.Selector.select" must be defined.');



  }







  function match() {



    throw new Error('Method "Prototype.Selector.match" must be defined.');



  }







  function find(elements, expression, index) {



    index = index || 0;



    var match = Prototype.Selector.match, length = elements.length, matchIndex = 0, i;







    for (i = 0; i < length; i++) {



      if (match(elements[i], expression) && index == matchIndex++) {



        return Element.extend(elements[i]);



      }



    }



  }







  function extendElements(elements) {



    for (var i = 0, length = elements.length; i < length; i++) {



      Element.extend(elements[i]);



    }



    return elements;



  }











  var K = Prototype.K;







  return {



    select: select,



    match: match,



    find: find,



    extendElements: (Element.extend === K) ? K : extendElements,



    extendElement: Element.extend



  };



})();



Prototype._original_property = window.Sizzle;



/*!



 * Sizzle CSS Selector Engine - v1.0



 *  Copyright 2009, The Dojo Foundation



 *  Released under the MIT, BSD, and GPL Licenses.



 *  More information: http://sizzlejs.com/



 */



(function(){







var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,



	done = 0,



	toString = Object.prototype.toString,



	hasDuplicate = false,



	baseHasDuplicate = true;







[0, 0].sort(function(){



	baseHasDuplicate = false;



	return 0;



});







var Sizzle = function(selector, context, results, seed) {



	results = results || [];



	var origContext = context = context || document;







	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {



		return [];



	}







	if ( !selector || typeof selector !== "string" ) {



		return results;



	}







	var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context),



		soFar = selector;







	while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {



		soFar = m[3];







		parts.push( m[1] );







		if ( m[2] ) {



			extra = m[3];



			break;



		}



	}







	if ( parts.length > 1 && origPOS.exec( selector ) ) {



		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {



			set = posProcess( parts[0] + parts[1], context );



		} else {



			set = Expr.relative[ parts[0] ] ?



				[ context ] :



				Sizzle( parts.shift(), context );







			while ( parts.length ) {



				selector = parts.shift();







				if ( Expr.relative[ selector ] )



					selector += parts.shift();







				set = posProcess( selector, set );



			}



		}



	} else {



		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&



				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {



			var ret = Sizzle.find( parts.shift(), context, contextXML );



			context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];



		}







		if ( context ) {



			var ret = seed ?



				{ expr: parts.pop(), set: makeArray(seed) } :



				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );



			set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;







			if ( parts.length > 0 ) {



				checkSet = makeArray(set);



			} else {



				prune = false;



			}







			while ( parts.length ) {



				var cur = parts.pop(), pop = cur;







				if ( !Expr.relative[ cur ] ) {



					cur = "";



				} else {



					pop = parts.pop();



				}







				if ( pop == null ) {



					pop = context;



				}







				Expr.relative[ cur ]( checkSet, pop, contextXML );



			}



		} else {



			checkSet = parts = [];



		}



	}







	if ( !checkSet ) {



		checkSet = set;



	}







	if ( !checkSet ) {



		throw "Syntax error, unrecognized expression: " + (cur || selector);



	}







	if ( toString.call(checkSet) === "[object Array]" ) {



		if ( !prune ) {



			results.push.apply( results, checkSet );



		} else if ( context && context.nodeType === 1 ) {



			for ( var i = 0; checkSet[i] != null; i++ ) {



				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {



					results.push( set[i] );



				}



			}



		} else {



			for ( var i = 0; checkSet[i] != null; i++ ) {



				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {



					results.push( set[i] );



				}



			}



		}



	} else {



		makeArray( checkSet, results );



	}







	if ( extra ) {



		Sizzle( extra, origContext, results, seed );



		Sizzle.uniqueSort( results );



	}







	return results;



};







Sizzle.uniqueSort = function(results){



	if ( sortOrder ) {



		hasDuplicate = baseHasDuplicate;



		results.sort(sortOrder);







		if ( hasDuplicate ) {



			for ( var i = 1; i < results.length; i++ ) {



				if ( results[i] === results[i-1] ) {



					results.splice(i--, 1);



				}



			}



		}



	}







	return results;



};







Sizzle.matches = function(expr, set){



	return Sizzle(expr, null, null, set);



};







Sizzle.find = function(expr, context, isXML){



	var set, match;







	if ( !expr ) {



		return [];



	}







	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {



		var type = Expr.order[i], match;







		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {



			var left = match[1];



			match.splice(1,1);







			if ( left.substr( left.length - 1 ) !== "\\" ) {



				match[1] = (match[1] || "").replace(/\\/g, "");



				set = Expr.find[ type ]( match, context, isXML );



				if ( set != null ) {



					expr = expr.replace( Expr.match[ type ], "" );



					break;



				}



			}



		}



	}







	if ( !set ) {



		set = context.getElementsByTagName("*");



	}







	return {set: set, expr: expr};



};







Sizzle.filter = function(expr, set, inplace, not){



	var old = expr, result = [], curLoop = set, match, anyFound,



		isXMLFilter = set && set[0] && isXML(set[0]);







	while ( expr && set.length ) {



		for ( var type in Expr.filter ) {



			if ( (match = Expr.match[ type ].exec( expr )) != null ) {



				var filter = Expr.filter[ type ], found, item;



				anyFound = false;







				if ( curLoop == result ) {



					result = [];



				}







				if ( Expr.preFilter[ type ] ) {



					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );







					if ( !match ) {



						anyFound = found = true;



					} else if ( match === true ) {



						continue;



					}



				}







				if ( match ) {



					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {



						if ( item ) {



							found = filter( item, match, i, curLoop );



							var pass = not ^ !!found;







							if ( inplace && found != null ) {



								if ( pass ) {



									anyFound = true;



								} else {



									curLoop[i] = false;



								}



							} else if ( pass ) {



								result.push( item );



								anyFound = true;



							}



						}



					}



				}







				if ( found !== undefined ) {



					if ( !inplace ) {



						curLoop = result;



					}







					expr = expr.replace( Expr.match[ type ], "" );







					if ( !anyFound ) {



						return [];



					}







					break;



				}



			}



		}







		if ( expr == old ) {



			if ( anyFound == null ) {



				throw "Syntax error, unrecognized expression: " + expr;



			} else {



				break;



			}



		}







		old = expr;



	}







	return curLoop;



};







var Expr = Sizzle.selectors = {



	order: [ "ID", "NAME", "TAG" ],



	match: {



		ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,



		CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,



		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,



		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,



		TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,



		CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,



		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,



		PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/



	},



	leftMatch: {},



	attrMap: {



		"class": "className",



		"for": "htmlFor"



	},



	attrHandle: {



		href: function(elem){



			return elem.getAttribute("href");



		}



	},



	relative: {



		"+": function(checkSet, part, isXML){



			var isPartStr = typeof part === "string",



				isTag = isPartStr && !/\W/.test(part),



				isPartStrNotTag = isPartStr && !isTag;







			if ( isTag && !isXML ) {



				part = part.toUpperCase();



			}







			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {



				if ( (elem = checkSet[i]) ) {



					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}







					checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ?



						elem || false :



						elem === part;



				}



			}







			if ( isPartStrNotTag ) {



				Sizzle.filter( part, checkSet, true );



			}



		},



		">": function(checkSet, part, isXML){



			var isPartStr = typeof part === "string";







			if ( isPartStr && !/\W/.test(part) ) {



				part = isXML ? part : part.toUpperCase();







				for ( var i = 0, l = checkSet.length; i < l; i++ ) {



					var elem = checkSet[i];



					if ( elem ) {



						var parent = elem.parentNode;



						checkSet[i] = parent.nodeName === part ? parent : false;



					}



				}



			} else {



				for ( var i = 0, l = checkSet.length; i < l; i++ ) {



					var elem = checkSet[i];



					if ( elem ) {



						checkSet[i] = isPartStr ?



							elem.parentNode :



							elem.parentNode === part;



					}



				}







				if ( isPartStr ) {



					Sizzle.filter( part, checkSet, true );



				}



			}



		},



		"": function(checkSet, part, isXML){



			var doneName = done++, checkFn = dirCheck;







			if ( !/\W/.test(part) ) {



				var nodeCheck = part = isXML ? part : part.toUpperCase();



				checkFn = dirNodeCheck;



			}







			checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);



		},



		"~": function(checkSet, part, isXML){



			var doneName = done++, checkFn = dirCheck;







			if ( typeof part === "string" && !/\W/.test(part) ) {



				var nodeCheck = part = isXML ? part : part.toUpperCase();



				checkFn = dirNodeCheck;



			}







			checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);



		}



	},



	find: {



		ID: function(match, context, isXML){



			if ( typeof context.getElementById !== "undefined" && !isXML ) {



				var m = context.getElementById(match[1]);



				return m ? [m] : [];



			}



		},



		NAME: function(match, context, isXML){



			if ( typeof context.getElementsByName !== "undefined" ) {



				var ret = [], results = context.getElementsByName(match[1]);







				for ( var i = 0, l = results.length; i < l; i++ ) {



					if ( results[i].getAttribute("name") === match[1] ) {



						ret.push( results[i] );



					}



				}







				return ret.length === 0 ? null : ret;



			}



		},



		TAG: function(match, context){



			return context.getElementsByTagName(match[1]);



		}



	},



	preFilter: {



		CLASS: function(match, curLoop, inplace, result, not, isXML){



			match = " " + match[1].replace(/\\/g, "") + " ";







			if ( isXML ) {



				return match;



			}







			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {



				if ( elem ) {



					if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) {



						if ( !inplace )



							result.push( elem );



					} else if ( inplace ) {



						curLoop[i] = false;



					}



				}



			}







			return false;



		},



		ID: function(match){



			return match[1].replace(/\\/g, "");



		},



		TAG: function(match, curLoop){



			for ( var i = 0; curLoop[i] === false; i++ ){}



			return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();



		},



		CHILD: function(match){



			if ( match[1] == "nth" ) {



				var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(



					match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||



					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);







				match[2] = (test[1] + (test[2] || 1)) - 0;



				match[3] = test[3] - 0;



			}







			match[0] = done++;







			return match;



		},



		ATTR: function(match, curLoop, inplace, result, not, isXML){



			var name = match[1].replace(/\\/g, "");







			if ( !isXML && Expr.attrMap[name] ) {



				match[1] = Expr.attrMap[name];



			}







			if ( match[2] === "~=" ) {



				match[4] = " " + match[4] + " ";



			}







			return match;



		},



		PSEUDO: function(match, curLoop, inplace, result, not){



			if ( match[1] === "not" ) {



				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {



					match[3] = Sizzle(match[3], null, null, curLoop);



				} else {



					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);



					if ( !inplace ) {



						result.push.apply( result, ret );



					}



					return false;



				}



			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {



				return true;



			}







			return match;



		},



		POS: function(match){



			match.unshift( true );



			return match;



		}



	},



	filters: {



		enabled: function(elem){



			return elem.disabled === false && elem.type !== "hidden";



		},



		disabled: function(elem){



			return elem.disabled === true;



		},



		checked: function(elem){



			return elem.checked === true;



		},



		selected: function(elem){



			elem.parentNode.selectedIndex;



			return elem.selected === true;



		},



		parent: function(elem){



			return !!elem.firstChild;



		},



		empty: function(elem){



			return !elem.firstChild;



		},



		has: function(elem, i, match){



			return !!Sizzle( match[3], elem ).length;



		},



		header: function(elem){



			return /h\d/i.test( elem.nodeName );



		},



		text: function(elem){



			return "text" === elem.type;



		},



		radio: function(elem){



			return "radio" === elem.type;



		},



		checkbox: function(elem){



			return "checkbox" === elem.type;



		},



		file: function(elem){



			return "file" === elem.type;



		},



		password: function(elem){



			return "password" === elem.type;



		},



		submit: function(elem){



			return "submit" === elem.type;



		},



		image: function(elem){



			return "image" === elem.type;



		},



		reset: function(elem){



			return "reset" === elem.type;



		},



		button: function(elem){



			return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";



		},



		input: function(elem){



			return /input|select|textarea|button/i.test(elem.nodeName);



		}



	},



	setFilters: {



		first: function(elem, i){



			return i === 0;



		},



		last: function(elem, i, match, array){



			return i === array.length - 1;



		},



		even: function(elem, i){



			return i % 2 === 0;



		},



		odd: function(elem, i){



			return i % 2 === 1;



		},



		lt: function(elem, i, match){



			return i < match[3] - 0;



		},



		gt: function(elem, i, match){



			return i > match[3] - 0;



		},



		nth: function(elem, i, match){



			return match[3] - 0 == i;



		},



		eq: function(elem, i, match){



			return match[3] - 0 == i;



		}



	},



	filter: {



		PSEUDO: function(elem, match, i, array){



			var name = match[1], filter = Expr.filters[ name ];







			if ( filter ) {



				return filter( elem, i, match, array );



			} else if ( name === "contains" ) {



				return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;



			} else if ( name === "not" ) {



				var not = match[3];







				for ( var i = 0, l = not.length; i < l; i++ ) {



					if ( not[i] === elem ) {



						return false;



					}



				}







				return true;



			}



		},



		CHILD: function(elem, match){



			var type = match[1], node = elem;



			switch (type) {



				case 'only':



				case 'first':



					while ( (node = node.previousSibling) )  {



						if ( node.nodeType === 1 ) return false;



					}



					if ( type == 'first') return true;



					node = elem;



				case 'last':



					while ( (node = node.nextSibling) )  {



						if ( node.nodeType === 1 ) return false;



					}



					return true;



				case 'nth':



					var first = match[2], last = match[3];







					if ( first == 1 && last == 0 ) {



						return true;



					}







					var doneName = match[0],



						parent = elem.parentNode;







					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {



						var count = 0;



						for ( node = parent.firstChild; node; node = node.nextSibling ) {



							if ( node.nodeType === 1 ) {



								node.nodeIndex = ++count;



							}



						}



						parent.sizcache = doneName;



					}







					var diff = elem.nodeIndex - last;



					if ( first == 0 ) {



						return diff == 0;



					} else {



						return ( diff % first == 0 && diff / first >= 0 );



					}



			}



		},



		ID: function(elem, match){



			return elem.nodeType === 1 && elem.getAttribute("id") === match;



		},



		TAG: function(elem, match){



			return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;



		},



		CLASS: function(elem, match){



			return (" " + (elem.className || elem.getAttribute("class")) + " ")



				.indexOf( match ) > -1;



		},



		ATTR: function(elem, match){



			var name = match[1],



				result = Expr.attrHandle[ name ] ?



					Expr.attrHandle[ name ]( elem ) :



					elem[ name ] != null ?



						elem[ name ] :



						elem.getAttribute( name ),



				value = result + "",



				type = match[2],



				check = match[4];







			return result == null ?



				type === "!=" :



				type === "=" ?



				value === check :



				type === "*=" ?



				value.indexOf(check) >= 0 :



				type === "~=" ?



				(" " + value + " ").indexOf(check) >= 0 :



				!check ?



				value && result !== false :



				type === "!=" ?



				value != check :



				type === "^=" ?



				value.indexOf(check) === 0 :



				type === "$=" ?



				value.substr(value.length - check.length) === check :



				type === "|=" ?



				value === check || value.substr(0, check.length + 1) === check + "-" :



				false;



		},



		POS: function(elem, match, i, array){



			var name = match[2], filter = Expr.setFilters[ name ];







			if ( filter ) {



				return filter( elem, i, match, array );



			}



		}



	}



};







var origPOS = Expr.match.POS;







for ( var type in Expr.match ) {



	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );



	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source );



}







var makeArray = function(array, results) {



	array = Array.prototype.slice.call( array, 0 );







	if ( results ) {



		results.push.apply( results, array );



		return results;



	}







	return array;



};







try {



	Array.prototype.slice.call( document.documentElement.childNodes, 0 );







} catch(e){



	makeArray = function(array, results) {



		var ret = results || [];







		if ( toString.call(array) === "[object Array]" ) {



			Array.prototype.push.apply( ret, array );



		} else {



			if ( typeof array.length === "number" ) {



				for ( var i = 0, l = array.length; i < l; i++ ) {



					ret.push( array[i] );



				}



			} else {



				for ( var i = 0; array[i]; i++ ) {



					ret.push( array[i] );



				}



			}



		}







		return ret;



	};



}







var sortOrder;







if ( document.documentElement.compareDocumentPosition ) {



	sortOrder = function( a, b ) {



		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {



			if ( a == b ) {



				hasDuplicate = true;



			}



			return 0;



		}







		var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;



		if ( ret === 0 ) {



			hasDuplicate = true;



		}



		return ret;



	};



} else if ( "sourceIndex" in document.documentElement ) {



	sortOrder = function( a, b ) {



		if ( !a.sourceIndex || !b.sourceIndex ) {



			if ( a == b ) {



				hasDuplicate = true;



			}



			return 0;



		}







		var ret = a.sourceIndex - b.sourceIndex;



		if ( ret === 0 ) {



			hasDuplicate = true;



		}



		return ret;



	};



} else if ( document.createRange ) {



	sortOrder = function( a, b ) {



		if ( !a.ownerDocument || !b.ownerDocument ) {



			if ( a == b ) {



				hasDuplicate = true;



			}



			return 0;



		}







		var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();



		aRange.setStart(a, 0);



		aRange.setEnd(a, 0);



		bRange.setStart(b, 0);



		bRange.setEnd(b, 0);



		var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);



		if ( ret === 0 ) {



			hasDuplicate = true;



		}



		return ret;



	};



}







(function(){



	var form = document.createElement("div"),



		id = "script" + (new Date).getTime();



	form.innerHTML = "<a name='" + id + "'/>";







	var root = document.documentElement;



	root.insertBefore( form, root.firstChild );







	if ( !!document.getElementById( id ) ) {



		Expr.find.ID = function(match, context, isXML){



			if ( typeof context.getElementById !== "undefined" && !isXML ) {



				var m = context.getElementById(match[1]);



				return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];



			}



		};







		Expr.filter.ID = function(elem, match){



			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");



			return elem.nodeType === 1 && node && node.nodeValue === match;



		};



	}







	root.removeChild( form );



	root = form = null; // release memory in IE



})();







(function(){







	var div = document.createElement("div");



	div.appendChild( document.createComment("") );







	if ( div.getElementsByTagName("*").length > 0 ) {



		Expr.find.TAG = function(match, context){



			var results = context.getElementsByTagName(match[1]);







			if ( match[1] === "*" ) {



				var tmp = [];







				for ( var i = 0; results[i]; i++ ) {



					if ( results[i].nodeType === 1 ) {



						tmp.push( results[i] );



					}



				}







				results = tmp;



			}







			return results;



		};



	}







	div.innerHTML = "<a href='#'></a>";



	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&



			div.firstChild.getAttribute("href") !== "#" ) {



		Expr.attrHandle.href = function(elem){



			return elem.getAttribute("href", 2);



		};



	}







	div = null; // release memory in IE



})();







if ( document.querySelectorAll ) (function(){



	var oldSizzle = Sizzle, div = document.createElement("div");



	div.innerHTML = "<p class='TEST'></p>";







	if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {



		return;



	}







	Sizzle = function(query, context, extra, seed){



		context = context || document;







		if ( !seed && context.nodeType === 9 && !isXML(context) ) {



			try {



				return makeArray( context.querySelectorAll(query), extra );



			} catch(e){}



		}







		return oldSizzle(query, context, extra, seed);



	};







	for ( var prop in oldSizzle ) {



		Sizzle[ prop ] = oldSizzle[ prop ];



	}







	div = null; // release memory in IE



})();







if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){



	var div = document.createElement("div");



	div.innerHTML = "<div class='test e'></div><div class='test'></div>";







	if ( div.getElementsByClassName("e").length === 0 )



		return;







	div.lastChild.className = "e";







	if ( div.getElementsByClassName("e").length === 1 )



		return;







	Expr.order.splice(1, 0, "CLASS");



	Expr.find.CLASS = function(match, context, isXML) {



		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {



			return context.getElementsByClassName(match[1]);



		}



	};







	div = null; // release memory in IE



})();







function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {



	var sibDir = dir == "previousSibling" && !isXML;



	for ( var i = 0, l = checkSet.length; i < l; i++ ) {



		var elem = checkSet[i];



		if ( elem ) {



			if ( sibDir && elem.nodeType === 1 ){



				elem.sizcache = doneName;



				elem.sizset = i;



			}



			elem = elem[dir];



			var match = false;







			while ( elem ) {



				if ( elem.sizcache === doneName ) {



					match = checkSet[elem.sizset];



					break;



				}







				if ( elem.nodeType === 1 && !isXML ){



					elem.sizcache = doneName;



					elem.sizset = i;



				}







				if ( elem.nodeName === cur ) {



					match = elem;



					break;



				}







				elem = elem[dir];



			}







			checkSet[i] = match;



		}



	}



}







function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {



	var sibDir = dir == "previousSibling" && !isXML;



	for ( var i = 0, l = checkSet.length; i < l; i++ ) {



		var elem = checkSet[i];



		if ( elem ) {



			if ( sibDir && elem.nodeType === 1 ) {



				elem.sizcache = doneName;



				elem.sizset = i;



			}



			elem = elem[dir];



			var match = false;







			while ( elem ) {



				if ( elem.sizcache === doneName ) {



					match = checkSet[elem.sizset];



					break;



				}







				if ( elem.nodeType === 1 ) {



					if ( !isXML ) {



						elem.sizcache = doneName;



						elem.sizset = i;



					}



					if ( typeof cur !== "string" ) {



						if ( elem === cur ) {



							match = true;



							break;



						}







					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {



						match = elem;



						break;



					}



				}







				elem = elem[dir];



			}







			checkSet[i] = match;



		}



	}



}







var contains = document.compareDocumentPosition ?  function(a, b){



	return a.compareDocumentPosition(b) & 16;



} : function(a, b){



	return a !== b && (a.contains ? a.contains(b) : true);



};







var isXML = function(elem){



	return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||



		!!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML";



};







var posProcess = function(selector, context){



	var tmpSet = [], later = "", match,



		root = context.nodeType ? [context] : context;







	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {



		later += match[0];



		selector = selector.replace( Expr.match.PSEUDO, "" );



	}







	selector = Expr.relative[selector] ? selector + "*" : selector;







	for ( var i = 0, l = root.length; i < l; i++ ) {



		Sizzle( selector, root[i], tmpSet );



	}







	return Sizzle.filter( later, tmpSet );



};











window.Sizzle = Sizzle;







})();







;(function(engine) {



  var extendElements = Prototype.Selector.extendElements;







  function select(selector, scope) {



    return extendElements(engine(selector, scope || document));



  }







  function match(element, selector) {



    return engine.matches(selector, [element]).length == 1;



  }







  Prototype.Selector.engine = engine;



  Prototype.Selector.select = select;



  Prototype.Selector.match = match;



})(Sizzle);







window.Sizzle = Prototype._original_property;



delete Prototype._original_property;







var Form = {



  reset: function(form) {



    form = $(form);



    form.reset();



    return form;



  },







  serializeElements: function(elements, options) {



    if (typeof options != 'object') options = { hash: !!options };



    else if (Object.isUndefined(options.hash)) options.hash = true;



    var key, value, submitted = false, submit = options.submit, accumulator, initial;







    if (options.hash) {



      initial = {};



      accumulator = function(result, key, value) {



        if (key in result) {



          if (!Object.isArray(result[key])) result[key] = [result[key]];



          result[key].push(value);



        } else result[key] = value;



        return result;



      };



    } else {



      initial = '';



      accumulator = function(result, key, value) {



        return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + encodeURIComponent(value);



      }



    }







    return elements.inject(initial, function(result, element) {



      if (!element.disabled && element.name) {



        key = element.name; value = $(element).getValue();



        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&



            submit !== false && (!submit || key == submit) && (submitted = true)))) {



          result = accumulator(result, key, value);



        }



      }



      return result;



    });



  }



};







Form.Methods = {



  serialize: function(form, options) {



    return Form.serializeElements(Form.getElements(form), options);



  },







  getElements: function(form) {



    var elements = $(form).getElementsByTagName('*'),



        element,



        arr = [ ],



        serializers = Form.Element.Serializers;



    for (var i = 0; element = elements[i]; i++) {



      arr.push(element);



    }



    return arr.inject([], function(elements, child) {



      if (serializers[child.tagName.toLowerCase()])



        elements.push(Element.extend(child));



      return elements;



    })



  },







  getInputs: function(form, typeName, name) {



    form = $(form);



    var inputs = form.getElementsByTagName('input');







    if (!typeName && !name) return $A(inputs).map(Element.extend);







    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {



      var input = inputs[i];



      if ((typeName && input.type != typeName) || (name && input.name != name))



        continue;



      matchingInputs.push(Element.extend(input));



    }







    return matchingInputs;



  },







  disable: function(form) {



    form = $(form);



    Form.getElements(form).invoke('disable');



    return form;



  },







  enable: function(form) {



    form = $(form);



    Form.getElements(form).invoke('enable');



    return form;



  },







  findFirstElement: function(form) {



    var elements = $(form).getElements().findAll(function(element) {



      return 'hidden' != element.type && !element.disabled;



    });



    var firstByIndex = elements.findAll(function(element) {



      return element.hasAttribute('tabIndex') && element.tabIndex >= 0;



    }).sortBy(function(element) { return element.tabIndex }).first();







    return firstByIndex ? firstByIndex : elements.find(function(element) {



      return /^(?:input|select|textarea)$/i.test(element.tagName);



    });



  },







  focusFirstElement: function(form) {



    form = $(form);



    var element = form.findFirstElement();



    if (element) element.activate();



    return form;



  },







  request: function(form, options) {



    form = $(form), options = Object.clone(options || { });







    var params = options.parameters, action = form.readAttribute('action') || '';



    if (action.blank()) action = window.location.href;



    options.parameters = form.serialize(true);







    if (params) {



      if (Object.isString(params)) params = params.toQueryParams();



      Object.extend(options.parameters, params);



    }







    if (form.hasAttribute('method') && !options.method)



      options.method = form.method;







    return new Ajax.Request(action, options);



  }



};







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











Form.Element = {



  focus: function(element) {



    $(element).focus();



    return element;



  },







  select: function(element) {



    $(element).select();



    return element;



  }



};







Form.Element.Methods = {







  serialize: function(element) {



    element = $(element);



    if (!element.disabled && element.name) {



      var value = element.getValue();



      if (value != undefined) {



        var pair = { };



        pair[element.name] = value;



        return Object.toQueryString(pair);



      }



    }



    return '';



  },







  getValue: function(element) {



    element = $(element);



    var method = element.tagName.toLowerCase();



    return Form.Element.Serializers[method](element);



  },







  setValue: function(element, value) {



    element = $(element);



    var method = element.tagName.toLowerCase();



    Form.Element.Serializers[method](element, value);



    return element;



  },







  clear: function(element) {



    $(element).value = '';



    return element;



  },







  present: function(element) {



    return $(element).value != '';



  },







  activate: function(element) {



    element = $(element);



    try {



      element.focus();



      if (element.select && (element.tagName.toLowerCase() != 'input' ||



          !(/^(?:button|reset|submit)$/i.test(element.type))))



        element.select();



    } catch (e) { }



    return element;



  },







  disable: function(element) {



    element = $(element);



    element.disabled = true;



    return element;



  },







  enable: function(element) {



    element = $(element);



    element.disabled = false;



    return element;



  }



};







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







var Field = Form.Element;







var $F = Form.Element.Methods.getValue;







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







Form.Element.Serializers = (function() {



  function input(element, value) {



    switch (element.type.toLowerCase()) {



      case 'checkbox':



      case 'radio':



        return inputSelector(element, value);



      default:



        return valueSelector(element, value);



    }



  }







  function inputSelector(element, value) {



    if (Object.isUndefined(value))



      return element.checked ? element.value : null;



    else element.checked = !!value;



  }







  function valueSelector(element, value) {



    if (Object.isUndefined(value)) return element.value;



    else element.value = value;



  }







  function select(element, value) {



    if (Object.isUndefined(value))



      return (element.type === 'select-one' ? selectOne : selectMany)(element);







    var opt, currentValue, single = !Object.isArray(value);



    for (var i = 0, length = element.length; i < length; i++) {



      opt = element.options[i];



      currentValue = this.optionValue(opt);



      if (single) {



        if (currentValue == value) {



          opt.selected = true;



          return;



        }



      }



      else opt.selected = value.include(currentValue);



    }



  }







  function selectOne(element) {



    var index = element.selectedIndex;



    return index >= 0 ? optionValue(element.options[index]) : null;



  }







  function selectMany(element) {



    var values, length = element.length;



    if (!length) return null;







    for (var i = 0, values = []; i < length; i++) {



      var opt = element.options[i];



      if (opt.selected) values.push(optionValue(opt));



    }



    return values;



  }







  function optionValue(opt) {



    return Element.hasAttribute(opt, 'value') ? opt.value : opt.text;



  }







  return {



    input:         input,



    inputSelector: inputSelector,



    textarea:      valueSelector,



    select:        select,



    selectOne:     selectOne,



    selectMany:    selectMany,



    optionValue:   optionValue,



    button:        valueSelector



  };



})();







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











Abstract.TimedObserver = Class.create(PeriodicalExecuter, {



  initialize: function($super, element, frequency, callback) {



    $super(callback, frequency);



    this.element   = $(element);



    this.lastValue = this.getValue();



  },







  execute: function() {



    var value = this.getValue();



    if (Object.isString(this.lastValue) && Object.isString(value) ?



        this.lastValue != value : String(this.lastValue) != String(value)) {



      this.callback(this.element, value);



      this.lastValue = value;



    }



  }



});







Form.Element.Observer = Class.create(Abstract.TimedObserver, {



  getValue: function() {



    return Form.Element.getValue(this.element);



  }



});







Form.Observer = Class.create(Abstract.TimedObserver, {



  getValue: function() {



    return Form.serialize(this.element);



  }



});







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







Abstract.EventObserver = Class.create({



  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() {



    Form.getElements(this.element).each(this.registerCallback, this);



  },







  registerCallback: function(element) {



    if (element.type) {



      switch (element.type.toLowerCase()) {



        case 'checkbox':



        case 'radio':



          Event.observe(element, 'click', this.onElementEvent.bind(this));



          break;



        default:



          Event.observe(element, 'change', this.onElementEvent.bind(this));



          break;



      }



    }



  }



});







Form.Element.EventObserver = Class.create(Abstract.EventObserver, {



  getValue: function() {



    return Form.Element.getValue(this.element);



  }



});







Form.EventObserver = Class.create(Abstract.EventObserver, {



  getValue: function() {



    return Form.serialize(this.element);



  }



});



(function() {







  var 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,



    KEY_HOME:     36,



    KEY_END:      35,



    KEY_PAGEUP:   33,



    KEY_PAGEDOWN: 34,



    KEY_INSERT:   45,







    cache: {}



  };







  var docEl = document.documentElement;



  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl



    && 'onmouseleave' in docEl;















  var isIELegacyEvent = function(event) { return false; };







  if (window.attachEvent) {



    if (window.addEventListener) {



      isIELegacyEvent = function(event) {



        return !(event instanceof window.Event);



      };



    } else {



      isIELegacyEvent = function(event) { return true; };



    }



  }







  var _isButton;







  function _isButtonForDOMEvents(event, code) {



    return event.which ? (event.which === code + 1) : (event.button === code);



  }







  var legacyButtonMap = { 0: 1, 1: 4, 2: 2 };



  function _isButtonForLegacyEvents(event, code) {



    return event.button === legacyButtonMap[code];



  }







  function _isButtonForWebKit(event, code) {



    switch (code) {



      case 0: return event.which == 1 && !event.metaKey;



      case 1: return event.which == 2 || (event.which == 1 && event.metaKey);



      case 2: return event.which == 3;



      default: return false;



    }



  }







  if (window.attachEvent) {



    if (!window.addEventListener) {



      _isButton = _isButtonForLegacyEvents;



    } else {



      _isButton = function(event, code) {



        return isIELegacyEvent(event) ? _isButtonForLegacyEvents(event, code) :



         _isButtonForDOMEvents(event, code);



      }



    }



  } else if (Prototype.Browser.WebKit) {



    _isButton = _isButtonForWebKit;



  } else {



    _isButton = _isButtonForDOMEvents;



  }







  function isLeftClick(event)   { return _isButton(event, 0) }







  function isMiddleClick(event) { return _isButton(event, 1) }







  function isRightClick(event)  { return _isButton(event, 2) }







  function element(event) {



    event = Event.extend(event);







    var node = event.target, type = event.type,



     currentTarget = event.currentTarget;







    if (currentTarget && currentTarget.tagName) {



      if (type === 'load' || type === 'error' ||



        (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'



          && currentTarget.type === 'radio'))



            node = currentTarget;



    }







    if (node.nodeType == Node.TEXT_NODE)



      node = node.parentNode;







    return Element.extend(node);



  }







  function findElement(event, expression) {



    var element = Event.element(event);







    if (!expression) return element;



    while (element) {



      if (Object.isElement(element) && Prototype.Selector.match(element, expression)) {



        return Element.extend(element);



      }



      element = element.parentNode;



    }



  }







  function pointer(event) {



    return { x: pointerX(event), y: pointerY(event) };



  }







  function pointerX(event) {



    var docElement = document.documentElement,



     body = document.body || { scrollLeft: 0 };







    return event.pageX || (event.clientX +



      (docElement.scrollLeft || body.scrollLeft) -



      (docElement.clientLeft || 0));



  }







  function pointerY(event) {



    var docElement = document.documentElement,



     body = document.body || { scrollTop: 0 };







    return  event.pageY || (event.clientY +



       (docElement.scrollTop || body.scrollTop) -



       (docElement.clientTop || 0));



  }











  function stop(event) {



    Event.extend(event);



    event.preventDefault();



    event.stopPropagation();







    event.stopped = true;



  }











  Event.Methods = {



    isLeftClick:   isLeftClick,



    isMiddleClick: isMiddleClick,



    isRightClick:  isRightClick,







    element:     element,



    findElement: findElement,







    pointer:  pointer,



    pointerX: pointerX,



    pointerY: pointerY,







    stop: stop



  };







  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {



    m[name] = Event.Methods[name].methodize();



    return m;



  });







  if (window.attachEvent) {



    function _relatedTarget(event) {



      var element;



      switch (event.type) {



        case 'mouseover':



        case 'mouseenter':



          element = event.fromElement;



          break;



        case 'mouseout':



        case 'mouseleave':



          element = event.toElement;



          break;



        default:



          return null;



      }



      return Element.extend(element);



    }







    var additionalMethods = {



      stopPropagation: function() { this.cancelBubble = true },



      preventDefault:  function() { this.returnValue = false },



      inspect: function() { return '[object Event]' }



    };







    Event.extend = function(event, element) {



      if (!event) return false;







      if (!isIELegacyEvent(event)) return event;







      if (event._extendedByPrototype) return event;



      event._extendedByPrototype = Prototype.emptyFunction;







      var pointer = Event.pointer(event);







      Object.extend(event, {



        target: event.srcElement || element,



        relatedTarget: _relatedTarget(event),



        pageX:  pointer.x,



        pageY:  pointer.y



      });







      Object.extend(event, methods);



      Object.extend(event, additionalMethods);







      return event;



    };



  } else {



    Event.extend = Prototype.K;



  }







  if (window.addEventListener) {



    Event.prototype = window.Event.prototype || document.createEvent('HTMLEvents').__proto__;



    Object.extend(Event.prototype, methods);



  }







  function _createResponder(element, eventName, handler) {



    var registry = Element.retrieve(element, 'prototype_event_registry');







    if (Object.isUndefined(registry)) {



      CACHE.push(element);



      registry = Element.retrieve(element, 'prototype_event_registry', $H());



    }







    var respondersForEvent = registry.get(eventName);



    if (Object.isUndefined(respondersForEvent)) {



      respondersForEvent = [];



      registry.set(eventName, respondersForEvent);



    }







    if (respondersForEvent.pluck('handler').include(handler)) return false;







    var responder;



    if (eventName.include(":")) {



      responder = function(event) {



        if (Object.isUndefined(event.eventName))



          return false;







        if (event.eventName !== eventName)



          return false;







        Event.extend(event, element);



        handler.call(element, event);



      };



    } else {



      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED &&



       (eventName === "mouseenter" || eventName === "mouseleave")) {



        if (eventName === "mouseenter" || eventName === "mouseleave") {



          responder = function(event) {



            Event.extend(event, element);







            var parent = event.relatedTarget;



            while (parent && parent !== element) {



              try { parent = parent.parentNode; }



              catch(e) { parent = element; }



            }







            if (parent === element) return;







            handler.call(element, event);



          };



        }



      } else {



        responder = function(event) {



          Event.extend(event, element);



          handler.call(element, event);



        };



      }



    }







    responder.handler = handler;



    respondersForEvent.push(responder);



    return responder;



  }







  function _destroyCache() {



    for (var i = 0, length = CACHE.length; i < length; i++) {



      Event.stopObserving(CACHE[i]);



      CACHE[i] = null;



    }



  }







  var CACHE = [];







  if (Prototype.Browser.IE)



    window.attachEvent('onunload', _destroyCache);







  if (Prototype.Browser.WebKit)



    window.addEventListener('unload', Prototype.emptyFunction, false);











  var _getDOMEventName = Prototype.K,



      translations = { mouseenter: "mouseover", mouseleave: "mouseout" };







  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {



    _getDOMEventName = function(eventName) {



      return (translations[eventName] || eventName);



    };



  }







  function observe(element, eventName, handler) {



    element = $(element);







    var responder = _createResponder(element, eventName, handler);







    if (!responder) return element;







    if (eventName.include(':')) {



      if (element.addEventListener)



        element.addEventListener("dataavailable", responder, false);



      else {



        element.attachEvent("ondataavailable", responder);



        element.attachEvent("onlosecapture", responder);



      }



    } else {



      var actualEventName = _getDOMEventName(eventName);







      if (element.addEventListener)



        element.addEventListener(actualEventName, responder, false);



      else



        element.attachEvent("on" + actualEventName, responder);



    }







    return element;



  }







  function stopObserving(element, eventName, handler) {



    element = $(element);







    var registry = Element.retrieve(element, 'prototype_event_registry');



    if (!registry) return element;







    if (!eventName) {



      registry.each( function(pair) {



        var eventName = pair.key;



        stopObserving(element, eventName);



      });



      return element;



    }







    var responders = registry.get(eventName);



    if (!responders) return element;







    if (!handler) {



      responders.each(function(r) {



        stopObserving(element, eventName, r.handler);



      });



      return element;



    }







    var i = responders.length, responder;



    while (i--) {



      if (responders[i].handler === handler) {



        responder = responders[i];



        break;



      }



    }



    if (!responder) return element;







    if (eventName.include(':')) {



      if (element.removeEventListener)



        element.removeEventListener("dataavailable", responder, false);



      else {



        element.detachEvent("ondataavailable", responder);



        element.detachEvent("onlosecapture", responder);



      }



    } else {



      var actualEventName = _getDOMEventName(eventName);



      if (element.removeEventListener)



        element.removeEventListener(actualEventName, responder, false);



      else



        element.detachEvent('on' + actualEventName, responder);



    }







    registry.set(eventName, responders.without(responder));







    return element;



  }







  function fire(element, eventName, memo, bubble) {



    element = $(element);







    if (Object.isUndefined(bubble))



      bubble = true;







    if (element == document && document.createEvent && !element.dispatchEvent)



      element = document.documentElement;







    var event;



    if (document.createEvent) {



      event = document.createEvent('HTMLEvents');



      event.initEvent('dataavailable', bubble, true);



    } else {



      event = document.createEventObject();



      event.eventType = bubble ? 'ondataavailable' : 'onlosecapture';



    }







    event.eventName = eventName;



    event.memo = memo || { };







    if (document.createEvent)



      element.dispatchEvent(event);



    else



      element.fireEvent(event.eventType, event);







    return Event.extend(event);



  }







  Event.Handler = Class.create({



    initialize: function(element, eventName, selector, callback) {



      this.element   = $(element);



      this.eventName = eventName;



      this.selector  = selector;



      this.callback  = callback;



      this.handler   = this.handleEvent.bind(this);



    },







    start: function() {



      Event.observe(this.element, this.eventName, this.handler);



      return this;



    },







    stop: function() {



      Event.stopObserving(this.element, this.eventName, this.handler);



      return this;



    },







    handleEvent: function(event) {



      var element = Event.findElement(event, this.selector);



      if (element) this.callback.call(this.element, event, element);



    }



  });







  function on(element, eventName, selector, callback) {



    element = $(element);



    if (Object.isFunction(selector) && Object.isUndefined(callback)) {



      callback = selector, selector = null;



    }







    return new Event.Handler(element, eventName, selector, callback).start();



  }







  Object.extend(Event, Event.Methods);







  Object.extend(Event, {



    fire:          fire,



    observe:       observe,



    stopObserving: stopObserving,



    on:            on



  });







  Element.addMethods({



    fire:          fire,







    observe:       observe,







    stopObserving: stopObserving,







    on:            on



  });







  Object.extend(document, {



    fire:          fire.methodize(),







    observe:       observe.methodize(),







    stopObserving: stopObserving.methodize(),







    on:            on.methodize(),







    loaded:        false



  });







  if (window.Event) Object.extend(window.Event, Event);



  else window.Event = Event;



})();







(function() {



  /* Support for the DOMContentLoaded event is based on work by Dan Webb,



     Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */







  var timer;







  function fireContentLoadedEvent() {



    if (document.loaded) return;



    if (timer) window.clearTimeout(timer);



    document.loaded = true;



    document.fire('dom:loaded');



  }







  function checkReadyState() {



    if (document.readyState === 'complete') {



      document.stopObserving('readystatechange', checkReadyState);



      fireContentLoadedEvent();



    }



  }







  function pollDoScroll() {



    try { document.documentElement.doScroll('left'); }



    catch(e) {



      timer = pollDoScroll.defer();



      return;



    }



    fireContentLoadedEvent();



  }







  if (document.addEventListener) {



    document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);



  } else {



    document.observe('readystatechange', checkReadyState);



    if (window == top)



      timer = pollDoScroll.defer();



  }







  Event.observe(window, 'load', fireContentLoadedEvent);



})();







Element.addMethods();







/*------------------------------- DEPRECATED -------------------------------*/







Hash.toQueryString = Object.toQueryString;







var Toggle = { display: Element.toggle };







Element.Methods.childOf = Element.Methods.descendantOf;







var Insertion = {



  Before: function(element, content) {



    return Element.insert(element, {before:content});



  },







  Top: function(element, content) {



    return Element.insert(element, {top:content});



  },







  Bottom: function(element, content) {



    return Element.insert(element, {bottom:content});



  },







  After: function(element, content) {



    return Element.insert(element, {after:content});



  }



};







var $continue = new Error('"throw $continue" is deprecated, use "return" instead');







var Position = {



  includeScrollOffsets: false,







  prepare: function() {



    this.deltaX =  window.pageXOffset



                || document.documentElement.scrollLeft



                || document.body.scrollLeft



                || 0;



    this.deltaY =  window.pageYOffset



                || document.documentElement.scrollTop



                || document.body.scrollTop



                || 0;



  },







  within: function(element, x, y) {



    if (this.includeScrollOffsets)



      return this.withinIncludingScrolloffsets(element, x, y);



    this.xcomp = x;



    this.ycomp = y;



    this.offset = Element.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 = Element.cumulativeScrollOffset(element);







    this.xcomp = x + offsetcache[0] - this.deltaX;



    this.ycomp = y + offsetcache[1] - this.deltaY;



    this.offset = Element.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);



  },







  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;



  },











  cumulativeOffset: Element.Methods.cumulativeOffset,







  positionedOffset: Element.Methods.positionedOffset,







  absolutize: function(element) {



    Position.prepare();



    return Element.absolutize(element);



  },







  relativize: function(element) {



    Position.prepare();



    return Element.relativize(element);



  },







  realOffset: Element.Methods.cumulativeScrollOffset,







  offsetParent: Element.Methods.getOffsetParent,







  page: Element.Methods.viewportOffset,







  clone: function(source, target, options) {



    options = options || { };



    return Element.clonePosition(target, source, options);



  }



};







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







if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){



  function iter(name) {



    return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";



  }







  instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?



  function(element, className) {



    className = className.toString().strip();



    var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);



    return cond ? document._getElementsByXPath('.//*' + cond, element) : [];



  } : function(element, className) {



    className = className.toString().strip();



    var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);



    if (!classNames && !className) return elements;







    var nodes = $(element).getElementsByTagName('*');



    className = ' ' + className + ' ';







    for (var i = 0, child, cn; child = nodes[i]; i++) {



      if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||



          (classNames && classNames.all(function(name) {



            return !name.toString().blank() && cn.include(' ' + name + ' ');



          }))))



        elements.push(Element.extend(child));



    }



    return elements;



  };







  return function(className, parentElement) {



    return $(parentElement || document.body).getElementsByClassName(className);



  };



}(Element.Methods);







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







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($A(this).concat(classNameToAdd).join(' '));



  },







  remove: function(classNameToRemove) {



    if (!this.include(classNameToRemove)) return;



    this.set($A(this).without(classNameToRemove).join(' '));



  },







  toString: function() {



    return $A(this).join(' ');



  }



};







Object.extend(Element.ClassNames.prototype, Enumerable);







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







(function() {



  window.Selector = Class.create({



    initialize: function(expression) {



      this.expression = expression.strip();



    },







    findElements: function(rootElement) {



      return Prototype.Selector.select(this.expression, rootElement);



    },







    match: function(element) {



      return Prototype.Selector.match(element, this.expression);



    },







    toString: function() {



      return this.expression;



    },







    inspect: function() {



      return "#<Selector: " + this.expression + ">";



    }



  });







  Object.extend(Selector, {



    matchElements: function(elements, expression) {



      var match = Prototype.Selector.match,



          results = [];







      for (var i = 0, length = elements.length; i < length; i++) {



        var element = elements[i];



        if (match(element, expression)) {



          results.push(Element.extend(element));



        }



      }



      return results;



    },







    findElement: function(elements, expression, index) {



      index = index || 0;



      var matchIndex = 0, element;



      for (var i = 0, length = elements.length; i < length; i++) {



        element = elements[i];



        if (Prototype.Selector.match(element, expression) && index === matchIndex++) {



          return Element.extend(element);



        }



      }



    },







    findChildElements: function(element, expressions) {



      var selector = expressions.toArray().join(', ');



      return Prototype.Selector.select(selector, element || document);



    }



  });



})();







// Credit Card Validation Javascript



// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd







// You have permission to copy and use this javascript provided that



// the content of the script is not changed in any way.







function validateCreditCard(s) {



    // remove non-numerics



    var v = "0123456789";



    var w = "";



    for (i=0; i < s.length; i++) {



        x = s.charAt(i);



        if (v.indexOf(x,0) != -1)



        w += x;



    }



    // validate number



    j = w.length / 2;



    k = Math.floor(j);



    m = Math.ceil(j) - k;



    c = 0;



    for (i=0; i<k; i++) {



        a = w.charAt(i*2+m) * 2;



        c += a > 9 ? Math.floor(a/10 + a%10) : a;



    }



    for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;



    return (c%10 == 0);



}











/*



* Really easy field validation with Prototype



* http://tetlaw.id.au/view/javascript/really-easy-field-validation



* Andrew Tetlaw



* Version 1.5.4.1 (2007-01-05)



*



* Copyright (c) 2007 Andrew Tetlaw



* Permission is hereby granted, free of charge, to any person



* obtaining a copy of this software and associated documentation



* files (the "Software"), to deal in the Software without



* restriction, including without limitation the rights to use, copy,



* modify, merge, publish, distribute, sublicense, and/or sell copies



* of the Software, and to permit persons to whom the Software is



* furnished to do so, subject to the following conditions:



*



* The above copyright notice and this permission notice shall be



* included in all copies or substantial portions of the Software.



*



* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,



* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF



* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND



* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS



* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN



* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN



* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE



* SOFTWARE.



*



*/



var Validator = Class.create();







Validator.prototype = {



    initialize : function(className, error, test, options) {



        if(typeof test == 'function'){



            this.options = $H(options);



            this._test = test;



        } else {



            this.options = $H(test);



            this._test = function(){return true};



        }



        this.error = error || 'Validation failed.';



        this.className = className;



    },



    test : function(v, elm) {



        return (this._test(v,elm) && this.options.all(function(p){



            return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;



        }));



    }



}



Validator.methods = {



    pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},



    minLength : function(v,elm,opt) {return v.length >= opt},



    maxLength : function(v,elm,opt) {return v.length <= opt},



    min : function(v,elm,opt) {return v >= parseFloat(opt)},



    max : function(v,elm,opt) {return v <= parseFloat(opt)},



    notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {



        return v != value;



    })},



    oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {



        return v == value;



    })},



    is : function(v,elm,opt) {return v == opt},



    isNot : function(v,elm,opt) {return v != opt},



    equalToField : function(v,elm,opt) {return v == $F(opt)},



    notEqualToField : function(v,elm,opt) {return v != $F(opt)},



    include : function(v,elm,opt) {return $A(opt).all(function(value) {



        return Validation.get(value).test(v,elm);



    })}



}







var Validation = Class.create();



Validation.defaultOptions = {



    onSubmit : true,



    stopOnFirst : false,



    immediate : false,



    focusOnError : true,



    useTitles : false,



    addClassNameToContainer: false,



    containerClassName: '.input-box',



    onFormValidate : function(result, form) {},



    onElementValidate : function(result, elm) {}



};







Validation.prototype = {



    initialize : function(form, options){



        this.form = $(form);



        if (!this.form) {



            return;



        }



        this.options = Object.extend({



            onSubmit : Validation.defaultOptions.onSubmit,



            stopOnFirst : Validation.defaultOptions.stopOnFirst,



            immediate : Validation.defaultOptions.immediate,



            focusOnError : Validation.defaultOptions.focusOnError,



            useTitles : Validation.defaultOptions.useTitles,



            onFormValidate : Validation.defaultOptions.onFormValidate,



            onElementValidate : Validation.defaultOptions.onElementValidate



        }, options || {});



        if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);



        if(this.options.immediate) {



            Form.getElements(this.form).each(function(input) { // Thanks Mike!



                if (input.tagName.toLowerCase() == 'select') {



                    Event.observe(input, 'blur', this.onChange.bindAsEventListener(this));



                }



                if (input.type.toLowerCase() == 'radio' || input.type.toLowerCase() == 'checkbox') {



                    Event.observe(input, 'click', this.onChange.bindAsEventListener(this));



                } else {



                    Event.observe(input, 'change', this.onChange.bindAsEventListener(this));



                }



            }, this);



        }



    },



    onChange : function (ev) {



        Validation.isOnChange = true;



        Validation.validate(Event.element(ev),{



                useTitle : this.options.useTitles,



                onElementValidate : this.options.onElementValidate



        });



        Validation.isOnChange = false;



    },



    onSubmit :  function(ev){



        if(!this.validate()) Event.stop(ev);



    },



    validate : function() {



        var result = false;



        var useTitles = this.options.useTitles;



        var callback = this.options.onElementValidate;



        try {



            if(this.options.stopOnFirst) {



                result = Form.getElements(this.form).all(function(elm) {



                    if (elm.hasClassName('local-validation') && !this.isElementInForm(elm, this.form)) {



                        return true;



                    }



                    return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback});



                }, this);



            } else {



                result = Form.getElements(this.form).collect(function(elm) {



                    if (elm.hasClassName('local-validation') && !this.isElementInForm(elm, this.form)) {



                        return true;



                    }



                    return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback});



                }, this).all();



            }



        } catch (e) {



        }



        if(!result && this.options.focusOnError) {



            try{



                Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()



            }



            catch(e){



            }



        }



        this.options.onFormValidate(result, this.form);



        return result;



    },



    reset : function() {



        Form.getElements(this.form).each(Validation.reset);



    },



    isElementInForm : function(elm, form) {



        var domForm = elm.up('form');



        if (domForm == form) {



            return true;



        }



        return false;



    }



}







Object.extend(Validation, {



    validate : function(elm, options){



        options = Object.extend({



            useTitle : false,



            onElementValidate : function(result, elm) {}



        }, options || {});



        elm = $(elm);







        var cn = $w(elm.className);



        return result = cn.all(function(value) {



            var test = Validation.test(value,elm,options.useTitle);



            options.onElementValidate(test, elm);



            return test;



        });



    },



    insertAdvice : function(elm, advice){



        var container = $(elm).up('.field-row');



        if(container){



            Element.insert(container, {after: advice});



        } else if (elm.up('td.value')) {



            elm.up('td.value').insert({bottom: advice});



        } else if (elm.advaiceContainer && $(elm.advaiceContainer)) {



            $(elm.advaiceContainer).update(advice);



        }



        else {



            switch (elm.type.toLowerCase()) {



                case 'checkbox':



                case 'radio':



                    var p = elm.parentNode;



                    if(p) {



                        Element.insert(p, {'bottom': advice});



                    } else {



                        Element.insert(elm, {'after': advice});



                    }



                    break;



                default:



                    Element.insert(elm, {'after': advice});



            }



        }



    },



    showAdvice : function(elm, advice, adviceName){



        if(!elm.advices){



            elm.advices = new Hash();



        }



        else{



            elm.advices.each(function(pair){



                if (!advice || pair.value.id != advice.id) {



                    // hide non-current advice after delay



                    this.hideAdvice(elm, pair.value);



                }



            }.bind(this));



        }



        elm.advices.set(adviceName, advice);



        if(typeof Effect == 'undefined') {



            advice.style.display = 'block';



        } else {



            if(!advice._adviceAbsolutize) {



                new Effect.Appear(advice, {duration : 1 });



            } else {



                Position.absolutize(advice);



                advice.show();



                advice.setStyle({



                    'top':advice._adviceTop,



                    'left': advice._adviceLeft,



                    'width': advice._adviceWidth,



                    'z-index': 1000



                });



                advice.addClassName('advice-absolute');



            }



        }



    },



    hideAdvice : function(elm, advice){



        if (advice != null) {



            new Effect.Fade(advice, {duration : 1, afterFinishInternal : function() {advice.hide();}});



        }



    },



    updateCallback : function(elm, status) {



        if (typeof elm.callbackFunction != 'undefined') {



            eval(elm.callbackFunction+'(\''+elm.id+'\',\''+status+'\')');



        }



    },



    ajaxError : function(elm, errorMsg) {



        var name = 'validate-ajax';



        var advice = Validation.getAdvice(name, elm);



        if (advice == null) {



            advice = this.createAdvice(name, elm, false, errorMsg);



        }



        this.showAdvice(elm, advice, 'validate-ajax');



        this.updateCallback(elm, 'failed');







        elm.addClassName('validation-failed');



        elm.addClassName('validate-ajax');



        if (Validation.defaultOptions.addClassNameToContainer && Validation.defaultOptions.containerClassName != '') {



            var container = elm.up(Validation.defaultOptions.containerClassName);



            if (container && this.allowContainerClassName(elm)) {



                container.removeClassName('validation-passed');



                container.addClassName('validation-error');



            }



        }



    },



    allowContainerClassName: function (elm) {



        if (elm.type == 'radio' || elm.type == 'checkbox') {



            return elm.hasClassName('change-container-classname');



        }







        return true;



    },



    test : function(name, elm, useTitle) {



        var v = Validation.get(name);



        var prop = '__advice'+name.camelize();



        try {



        if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {



            //if(!elm[prop]) {



                var advice = Validation.getAdvice(name, elm);



                if (advice == null) {



                    advice = this.createAdvice(name, elm, useTitle);



                }



                this.showAdvice(elm, advice, name);



                this.updateCallback(elm, 'failed');



            //}



            elm[prop] = 1;



            if (!elm.advaiceContainer) {



                elm.removeClassName('validation-passed');



                elm.addClassName('validation-failed');



            }







           if (Validation.defaultOptions.addClassNameToContainer && Validation.defaultOptions.containerClassName != '') {



                var container = elm.up(Validation.defaultOptions.containerClassName);



                if (container && this.allowContainerClassName(elm)) {



                    container.removeClassName('validation-passed');



                    container.addClassName('validation-error');



                }



            }



            return false;



        } else {



            var advice = Validation.getAdvice(name, elm);



            this.hideAdvice(elm, advice);



            this.updateCallback(elm, 'passed');



            elm[prop] = '';



            elm.removeClassName('validation-failed');



            elm.addClassName('validation-passed');



            if (Validation.defaultOptions.addClassNameToContainer && Validation.defaultOptions.containerClassName != '') {



                var container = elm.up(Validation.defaultOptions.containerClassName);



                if (container && !container.down('.validation-failed') && this.allowContainerClassName(elm)) {



                    if (!Validation.get('IsEmpty').test(elm.value) || !this.isVisible(elm)) {



                        container.addClassName('validation-passed');



                    } else {



                        container.removeClassName('validation-passed');



                    }



                    container.removeClassName('validation-error');



                }



            }



            return true;



        }



        } catch(e) {



            throw(e)



        }



    },



    isVisible : function(elm) {



        while(elm.tagName != 'BODY') {



            if(!$(elm).visible()) return false;



            elm = elm.parentNode;



        }



        return true;



    },



    getAdvice : function(name, elm) {



        return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));



    },



    createAdvice : function(name, elm, useTitle, customError) {



        var v = Validation.get(name);



        var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;



        if (customError) {



            errorMsg = customError;



        }



        try {



            if (Translator){



                errorMsg = Translator.translate(errorMsg);



            }



        }



        catch(e){}







        advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'











        Validation.insertAdvice(elm, advice);



        advice = Validation.getAdvice(name, elm);



        if($(elm).hasClassName('absolute-advice')) {



            var dimensions = $(elm).getDimensions();



            var originalPosition = Position.cumulativeOffset(elm);







            advice._adviceTop = (originalPosition[1] + dimensions.height) + 'px';



            advice._adviceLeft = (originalPosition[0])  + 'px';



            advice._adviceWidth = (dimensions.width)  + 'px';



            advice._adviceAbsolutize = true;



        }



        return advice;



    },



    getElmID : function(elm) {



        return elm.id ? elm.id : elm.name;



    },



    reset : function(elm) {



        elm = $(elm);



        var cn = $w(elm.className);



        cn.each(function(value) {



            var prop = '__advice'+value.camelize();



            if(elm[prop]) {



                var advice = Validation.getAdvice(value, elm);



                if (advice) {



                    advice.hide();



                }



                elm[prop] = '';



            }



            elm.removeClassName('validation-failed');



            elm.removeClassName('validation-passed');



            if (Validation.defaultOptions.addClassNameToContainer && Validation.defaultOptions.containerClassName != '') {



                var container = elm.up(Validation.defaultOptions.containerClassName);



                if (container) {



                    container.removeClassName('validation-passed');



                    container.removeClassName('validation-error');



                }



            }



        });



    },



    add : function(className, error, test, options) {



        var nv = {};



        nv[className] = new Validator(className, error, test, options);



        Object.extend(Validation.methods, nv);



    },



    addAllThese : function(validators) {



        var nv = {};



        $A(validators).each(function(value) {



                nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));



            });



        Object.extend(Validation.methods, nv);



    },



    get : function(name) {



        return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];



    },



    methods : {



        '_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})



    }



});







Validation.add('IsEmpty', '', function(v) {



    return  (v == '' || (v == null) || (v.length == 0) || /^\s+$/.test(v));



});







Validation.addAllThese([



    ['validate-no-html-tags', 'HTML tags are not allowed', function(v) {



				return !/<(\/)?\w+/.test(v);



			}],



	['validate-select', 'Please select an option.', function(v) {



                return ((v != "none") && (v != null) && (v.length != 0));



            }],



    ['required-entry', 'This is a required field.', function(v) {



                return !Validation.get('IsEmpty').test(v);



            }],



    ['validate-number', 'Please enter a valid number in this field.', function(v) {



                return Validation.get('IsEmpty').test(v)



                    || (!isNaN(parseNumber(v)) && /^\s*-?\d*(\.\d*)?\s*$/.test(v));



            }],



    ['validate-number-range', 'The value is not within the specified range.', function(v, elm) {



                if (Validation.get('IsEmpty').test(v)) {



                    return true;



                }







                var numValue = parseNumber(v);



                if (isNaN(numValue)) {



                    return false;



                }







                var reRange = /^number-range-(-?[\d.,]+)?-(-?[\d.,]+)?$/,



                    result = true;







                $w(elm.className).each(function(name) {



                    var m = reRange.exec(name);



                    if (m) {



                        result = result



                            && (m[1] == null || m[1] == '' || numValue >= parseNumber(m[1]))



                            && (m[2] == null || m[2] == '' || numValue <= parseNumber(m[2]));



                    }



                });







                return result;



            }],



    ['validate-digits', 'Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.', function(v) {



                return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);



            }],



    ['validate-digits-range', 'The value is not within the specified range.', function(v, elm) {



                if (Validation.get('IsEmpty').test(v)) {



                    return true;



                }







                var numValue = parseNumber(v);



                if (isNaN(numValue)) {



                    return false;



                }







                var reRange = /^digits-range-(-?\d+)?-(-?\d+)?$/,



                    result = true;







                $w(elm.className).each(function(name) {



                    var m = reRange.exec(name);



                    if (m) {



                        result = result



                            && (m[1] == null || m[1] == '' || numValue >= parseNumber(m[1]))



                            && (m[2] == null || m[2] == '' || numValue <= parseNumber(m[2]));



                    }



                });







                return result;



            }],



    ['validate-alpha', 'Please use letters only (a-z or A-Z) in this field.', function (v) {



                return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)



            }],



    ['validate-code', 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.', function (v) {



                return Validation.get('IsEmpty').test(v) ||  /^[a-z]+[a-z0-9_]+$/.test(v)



            }],



    ['validate-alphanum', 'Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) {



                return Validation.get('IsEmpty').test(v) || /^[a-zA-Z0-9]+$/.test(v)



            }],



    ['validate-alphanum-with-spaces', 'Please use only letters (a-z or A-Z), numbers (0-9) or spaces only in this field.', function(v) {



                    return Validation.get('IsEmpty').test(v) || /^[a-zA-Z0-9 ]+$/.test(v)



            }],



    ['validate-street', 'Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.', function(v) {



                return Validation.get('IsEmpty').test(v) ||  /^[ \w]{3,}([A-Za-z]\.)?([ \w]*\#\d+)?(\r\n| )[ \w]{3,}/.test(v)



            }],



    ['validate-phoneStrict', 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.', function(v) {



                return Validation.get('IsEmpty').test(v) || /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/.test(v);



            }],



    ['validate-phoneLax', 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.', function(v) {



                return Validation.get('IsEmpty').test(v) || /^((\d[-. ]?)?((\(\d{3}\))|\d{3}))?[-. ]?\d{3}[-. ]?\d{4}$/.test(v);



            }],



    ['validate-fax', 'Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.', function(v) {



                return Validation.get('IsEmpty').test(v) || /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/.test(v);



            }],



    ['validate-date', 'Please enter a valid date.', function(v) {



                var test = new Date(v);



                return Validation.get('IsEmpty').test(v) || !isNaN(test);



            }],



    ['validate-date-range', 'The From Date value should be less than or equal to the To Date value.', function(v, elm) {



            var m = /\bdate-range-(\w+)-(\w+)\b/.exec(elm.className);



            if (!m || m[2] == 'to' || Validation.get('IsEmpty').test(v)) {



                return true;



            }







            var currentYear = new Date().getFullYear() + '';



            var normalizedTime = function(v) {



                v = v.split(/[.\/]/);



                if (v[2] && v[2].length < 4) {



                    v[2] = currentYear.substr(0, v[2].length) + v[2];



                }



                return new Date(v.join('/')).getTime();



            };







            var dependentElements = Element.select(elm.form, '.validate-date-range.date-range-' + m[1] + '-to');



            return !dependentElements.length || Validation.get('IsEmpty').test(dependentElements[0].value)



                || normalizedTime(v) <= normalizedTime(dependentElements[0].value);



        }],



    ['validate-email', 'Please enter a valid email address. For example johndoe@domain.com.', function (v) {



                //return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)



                //return Validation.get('IsEmpty').test(v) || /^[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9][\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9\.]{1,30}[\!\#$%\*/?|\^\{\}`~&\'\+\-=_a-z0-9]@([a-z0-9_-]{1,30}\.){1,5}[a-z]{2,4}$/i.test(v)



                return Validation.get('IsEmpty').test(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v)



            }],



    ['validate-emailSender', 'Please use only visible characters and spaces.', function (v) {



                return Validation.get('IsEmpty').test(v) ||  /^[\S ]+$/.test(v)



                    }],



    ['validate-password', 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.', function(v) {



                var pass=v.strip(); /*strip leading and trailing spaces*/



                return !(pass.length>0 && pass.length < 6);



            }],



    ['validate-admin-password', 'Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.', function(v) {



                var pass=v.strip();



                if (0 == pass.length) {



                    return true;



                }



                if (!(/[a-z]/i.test(v)) || !(/[0-9]/.test(v))) {



                    return false;



                }



                return !(pass.length < 7);



            }],



    ['validate-cpassword', 'Please make sure your passwords match.', function(v) {



                var conf = $('confirmation') ? $('confirmation') : $$('.validate-cpassword')[0];



                var pass = false;



                if ($('password')) {



                    pass = $('password');



                }



                var passwordElements = $$('.validate-password');



                for (var i = 0; i < passwordElements.size(); i++) {



                    var passwordElement = passwordElements[i];



                    if (passwordElement.up('form').id == conf.up('form').id) {



                        pass = passwordElement;



                    }



                }



                if ($$('.validate-admin-password').size()) {



                    pass = $$('.validate-admin-password')[0];



                }



                return (pass.value == conf.value);



            }],



    ['validate-both-passwords', 'Please make sure your passwords match.', function(v, input) {



                var dependentInput = $(input.form[input.name == 'password' ? 'confirmation' : 'password']),



                    isEqualValues  = input.value == dependentInput.value;







                if (isEqualValues && dependentInput.hasClassName('validation-failed')) {



                    Validation.test(this.className, dependentInput);



                }







                return dependentInput.value == '' || isEqualValues;



            }],



    ['validate-url', 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', function (v) {



                v = (v || '').replace(/^\s+/, '').replace(/\s+$/, '');



                return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(v)



            }],



    ['validate-clean-url', 'Please enter a valid URL. For example http://www.example.com or www.example.com', function (v) {



                return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+.(com|org|net|dk|at|us|tv|info|uk|co.uk|biz|se)$)(:(\d+))?\/?/i.test(v) || /^(www)((\.[A-Z0-9][A-Z0-9_-]*)+.(com|org|net|dk|at|us|tv|info|uk|co.uk|biz|se)$)(:(\d+))?\/?/i.test(v)



            }],



    ['validate-identifier', 'Please enter a valid URL Key. For example "example-page", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/example-page.html" or "anotherlevel/example-page".', function (v) {



                return Validation.get('IsEmpty').test(v) || /^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/.test(v)



            }],



    ['validate-xml-identifier', 'Please enter a valid XML-identifier. For example something_1, block5, id-4.', function (v) {



                return Validation.get('IsEmpty').test(v) || /^[A-Z][A-Z0-9_\/-]*$/i.test(v)



            }],



    ['validate-ssn', 'Please enter a valid social security number. For example 123-45-6789.', function(v) {



            return Validation.get('IsEmpty').test(v) || /^\d{3}-?\d{2}-?\d{4}$/.test(v);



            }],



    ['validate-zip', 'Please enter a valid zip code. For example 90602 or 90602-1234.', function(v) {



            return Validation.get('IsEmpty').test(v) || /(^\d{5}$)|(^\d{5}-\d{4}$)/.test(v);



            }],



    ['validate-zip-international', 'Please enter a valid zip code.', function(v) {



            //return Validation.get('IsEmpty').test(v) || /(^[A-z0-9]{2,10}([\s]{0,1}|[\-]{0,1})[A-z0-9]{2,10}$)/.test(v);



            return true;



            }],



    ['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {



                if(Validation.get('IsEmpty').test(v)) return true;



                var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;



                if(!regex.test(v)) return false;



                var d = new Date(v.replace(regex, '$2/$1/$3'));



                return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) &&



                            (parseInt(RegExp.$1, 10) == d.getDate()) &&



                            (parseInt(RegExp.$3, 10) == d.getFullYear() );



            }],



    ['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00.', function(v) {



                // [$]1[##][,###]+[.##]



                // [$]1###+[.##]



                // [$]0.##



                // [$].##



                return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)



            }],



    ['validate-one-required', 'Please select one of the above options.', function (v,elm) {



                var p = elm.parentNode;



                var options = p.getElementsByTagName('INPUT');



                return $A(options).any(function(elm) {



                    return $F(elm);



                });



            }],



    ['validate-one-required-by-name', 'Please select one of the options.', function (v,elm) {



                var inputs = $$('input[name="' + elm.name.replace(/([\\"])/g, '\\$1') + '"]');







                var error = 1;



                for(var i=0;i<inputs.length;i++) {



                    if((inputs[i].type == 'checkbox' || inputs[i].type == 'radio') && inputs[i].checked == true) {



                        error = 0;



                    }







                    if(Validation.isOnChange && (inputs[i].type == 'checkbox' || inputs[i].type == 'radio')) {



                        Validation.reset(inputs[i]);



                    }



                }







                if( error == 0 ) {



                    return true;



                } else {



                    return false;



                }



            }],



    ['validate-not-negative-number', 'Please enter a number 0 or greater in this field.', function(v) {



                if (Validation.get('IsEmpty').test(v)) {



                    return true;



                }



                v = parseNumber(v);



                return !isNaN(v) && v >= 0;



            }],



    ['validate-zero-or-greater', 'Please enter a number 0 or greater in this field.', function(v) {



            return Validation.get('validate-not-negative-number').test(v);



        }],



    ['validate-greater-than-zero', 'Please enter a number greater than 0 in this field.', function(v) {



            if (Validation.get('IsEmpty').test(v)) {



                return true;



            }



            v = parseNumber(v);



            return !isNaN(v) && v > 0;



        }],



    ['validate-state', 'Please select State/Province.', function(v) {



                return (v!=0 || v == '');



            }],



    ['validate-new-password', 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.', function(v) {



                if (!Validation.get('validate-password').test(v)) return false;



                if (Validation.get('IsEmpty').test(v) && v != '') return false;



                return true;



            }],



    ['validate-cc-number', 'Please enter a valid credit card number.', function(v, elm) {



                // remove non-numerics



                var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');



                if (ccTypeContainer && typeof Validation.creditCartTypes.get(ccTypeContainer.value) != 'undefined'



                        && Validation.creditCartTypes.get(ccTypeContainer.value)[2] == false) {



                    if (!Validation.get('IsEmpty').test(v) && Validation.get('validate-digits').test(v)) {



                        return true;



                    } else {



                        return false;



                    }



                }



                return validateCreditCard(v);



            }],



    ['validate-cc-type', 'Credit card number does not match credit card type.', function(v, elm) {



                // remove credit card number delimiters such as "-" and space



                elm.value = removeDelimiters(elm.value);



                v         = removeDelimiters(v);







                var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_number')) + '_cc_type');



                if (!ccTypeContainer) {



                    return true;



                }



                var ccType = ccTypeContainer.value;







                if (typeof Validation.creditCartTypes.get(ccType) == 'undefined') {



                    return false;



                }







                // Other card type or switch or solo card



                if (Validation.creditCartTypes.get(ccType)[0]==false) {



                    return true;



                }







                var validationFailure = false;



                Validation.creditCartTypes.each(function (pair) {



                    if (pair.key == ccType) {



                        if (pair.value[0] && !v.match(pair.value[0])) {



                            validationFailure = true;



                        }



                        throw $break;



                    }



                });







                if (validationFailure) {



                    return false;



                }







                if (ccTypeContainer.hasClassName('validation-failed') && Validation.isOnChange) {



                    Validation.validate(ccTypeContainer);



                }







                return true;



            }],



     ['validate-cc-type-select', 'Card type does not match credit card number.', function(v, elm) {



                var ccNumberContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_type')) + '_cc_number');



                if (Validation.isOnChange && Validation.get('IsEmpty').test(ccNumberContainer.value)) {



                    return true;



                }



                if (Validation.get('validate-cc-type').test(ccNumberContainer.value, ccNumberContainer)) {



                    Validation.validate(ccNumberContainer);



                }



                return Validation.get('validate-cc-type').test(ccNumberContainer.value, ccNumberContainer);



            }],



     ['validate-cc-exp', 'Incorrect credit card expiration date.', function(v, elm) {



                var ccExpMonth   = v;



                var ccExpYear    = $(elm.id.substr(0,elm.id.indexOf('_expiration')) + '_expiration_yr').value;



                var currentTime  = new Date();



                var currentMonth = currentTime.getMonth() + 1;



                var currentYear  = currentTime.getFullYear();



                if (ccExpMonth < currentMonth && ccExpYear == currentYear) {



                    return false;



                }



                return true;



            }],



     ['validate-cc-cvn', 'Please enter a valid credit card verification number.', function(v, elm) {



                var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf('_cc_cid')) + '_cc_type');



                if (!ccTypeContainer) {



                    return true;



                }



                var ccType = ccTypeContainer.value;







                if (typeof Validation.creditCartTypes.get(ccType) == 'undefined') {



                    return false;



                }







                var re = Validation.creditCartTypes.get(ccType)[1];







                if (v.match(re)) {



                    return true;



                }







                return false;



            }],



     ['validate-ajax', '', function(v, elm) { return true; }],



     ['validate-data', 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.', function (v) {



                if(v != '' && v) {



                    return /^[A-Za-z]+[A-Za-z0-9_]+$/.test(v);



                }



                return true;



            }],



     ['validate-css-length', 'Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%.', function (v) {



                if (v != '' && v) {



                    return /^[0-9\.]+(px|pt|em|ex|%)?$/.test(v) && (!(/\..*\./.test(v))) && !(/\.$/.test(v));



                }



                return true;



            }],



     ['validate-length', 'Text length does not satisfy specified text range.', function (v, elm) {



                var reMax = new RegExp(/^maximum-length-[0-9]+$/);



                var reMin = new RegExp(/^minimum-length-[0-9]+$/);



                var result = true;



                $w(elm.className).each(function(name, index) {



                    if (name.match(reMax) && result) {



                       var length = name.split('-')[2];



                       result = (v.length <= length);



                    }



                    if (name.match(reMin) && result && !Validation.get('IsEmpty').test(v)) {



                        var length = name.split('-')[2];



                        result = (v.length >= length);



                    }



                });



                return result;



            }],



     ['validate-percents', 'Please enter a number lower than 100.', {max:100}],



     ['required-file', 'Please select a file', function(v, elm) {



         var result = !Validation.get('IsEmpty').test(v);



         if (result === false) {



             ovId = elm.id + '_value';



             if ($(ovId)) {



                 result = !Validation.get('IsEmpty').test($(ovId).value);



             }



         }



         return result;



     }],



     ['validate-cc-ukss', 'Please enter issue number or start date for switch/solo card type.', function(v,elm) {



         var endposition;







         if (elm.id.match(/(.)+_cc_issue$/)) {



             endposition = elm.id.indexOf('_cc_issue');



         } else if (elm.id.match(/(.)+_start_month$/)) {



             endposition = elm.id.indexOf('_start_month');



         } else {



             endposition = elm.id.indexOf('_start_year');



         }







         var prefix = elm.id.substr(0,endposition);







         var ccTypeContainer = $(prefix + '_cc_type');







         if (!ccTypeContainer) {



               return true;



         }



         var ccType = ccTypeContainer.value;







         if(['SS','SM','SO'].indexOf(ccType) == -1){



             return true;



         }







         $(prefix + '_cc_issue').advaiceContainer



           = $(prefix + '_start_month').advaiceContainer



           = $(prefix + '_start_year').advaiceContainer



           = $(prefix + '_cc_type_ss_div').down('ul li.adv-container');







         var ccIssue   =  $(prefix + '_cc_issue').value;



         var ccSMonth  =  $(prefix + '_start_month').value;



         var ccSYear   =  $(prefix + '_start_year').value;







         var ccStartDatePresent = (ccSMonth && ccSYear) ? true : false;







         if (!ccStartDatePresent && !ccIssue){



             return false;



         }



         return true;



     }]



]);







function removeDelimiters (v) {



    v = v.replace(/\s/g, '');



    v = v.replace(/\-/g, '');



    return v;



}







function parseNumber(v)



{



    if (typeof v != 'string') {



        return parseFloat(v);



    }







    var isDot  = v.indexOf('.');



    var isComa = v.indexOf(',');







    if (isDot != -1 && isComa != -1) {



        if (isComa > isDot) {



            v = v.replace('.', '').replace(',', '.');



        }



        else {



            v = v.replace(',', '');



        }



    }



    else if (isComa != -1) {



        v = v.replace(',', '.');



    }







    return parseFloat(v);



}







/**



 * Hash with credit card types which can be simply extended in payment modules



 * 0 - regexp for card number



 * 1 - regexp for cvn



 * 2 - check or not credit card number trough Luhn algorithm by



 *     function validateCreditCard which you can find above in this file



 */



Validation.creditCartTypes = $H({



//    'SS': [new RegExp('^((6759[0-9]{12})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(6333[0-9]{12})|(6334[0-4]\d{11})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],



    'SO': [new RegExp('^(6334[5-9]([0-9]{11}|[0-9]{13,14}))|(6767([0-9]{12}|[0-9]{14,15}))$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],



    'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],



    'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],



    'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],



    'DI': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],



    'JCB': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3,4}$'), true],



    'DICL': [new RegExp('^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}|5[0-9]{14}))$'), new RegExp('^[0-9]{3}$'), true],



    'SM': [new RegExp('(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],



    'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false]



});







// script.aculo.us builder.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008







// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)



//



// script.aculo.us is freely distributable under the terms of an MIT-style license.



// For details, see the script.aculo.us web site: http://script.aculo.us/







var Builder = {



  NODEMAP: {



    AREA: 'map',



    CAPTION: 'table',



    COL: 'table',



    COLGROUP: 'table',



    LEGEND: 'fieldset',



    OPTGROUP: 'select',



    OPTION: 'select',



    PARAM: 'object',



    TBODY: 'table',



    TD: 'table',



    TFOOT: 'table',



    TH: 'table',



    THEAD: 'table',



    TR: 'table'



  },



  // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,



  //       due to a Firefox bug



  node: function(elementName) {



    elementName = elementName.toUpperCase();







    // try innerHTML approach



    var parentTag = this.NODEMAP[elementName] || 'div';



    var parentElement = document.createElement(parentTag);



    try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707



      parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";



    } catch(e) {}



    var element = parentElement.firstChild || null;







    // see if browser added wrapping tags



    if(element && (element.tagName.toUpperCase() != elementName))



      element = element.getElementsByTagName(elementName)[0];







    // fallback to createElement approach



    if(!element) element = document.createElement(elementName);







    // abort if nothing could be created



    if(!element) return;







    // attributes (or text)



    if(arguments[1])



      if(this._isStringOrNumber(arguments[1]) ||



        (arguments[1] instanceof Array) ||



        arguments[1].tagName) {



          this._children(element, arguments[1]);



        } else {



          var attrs = this._attributes(arguments[1]);



          if(attrs.length) {



            try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707



              parentElement.innerHTML = "<" +elementName + " " +



                attrs + "></" + elementName + ">";



            } catch(e) {}



            element = parentElement.firstChild || null;



            // workaround firefox 1.0.X bug



            if(!element) {



              element = document.createElement(elementName);



              for(attr in arguments[1])



                element[attr == 'class' ? 'className' : attr] = arguments[1][attr];



            }



            if(element.tagName.toUpperCase() != elementName)



              element = parentElement.getElementsByTagName(elementName)[0];



          }



        }







    // text, or array of children



    if(arguments[2])



      this._children(element, arguments[2]);







     return $(element);



  },



  _text: function(text) {



     return document.createTextNode(text);



  },







  ATTR_MAP: {



    'className': 'class',



    'htmlFor': 'for'



  },







  _attributes: function(attributes) {



    var attrs = [];



    for(attribute in attributes)



      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +



          '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');



    return attrs.join(" ");



  },



  _children: function(element, children) {



    if(children.tagName) {



      element.appendChild(children);



      return;



    }



    if(typeof children=='object') { // array can hold nodes and text



      children.flatten().each( function(e) {



        if(typeof e=='object')



          element.appendChild(e);



        else



          if(Builder._isStringOrNumber(e))



            element.appendChild(Builder._text(e));



      });



    } else



      if(Builder._isStringOrNumber(children))



        element.appendChild(Builder._text(children));



  },



  _isStringOrNumber: function(param) {



    return(typeof param=='string' || typeof param=='number');



  },



  build: function(html) {



    var element = this.node('div');



    $(element).update(html.strip());



    return element.down();



  },



  dump: function(scope) {



    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope







    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +



      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +



      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+



      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+



      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+



      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);







    tags.each( function(tag){



      scope[tag] = function() {



        return Builder.node.apply(Builder, [tag].concat($A(arguments)));



      };



    });



  }



};



// script.aculo.us effects.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008







// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)



// Contributors:



//  Justin Palmer (http://encytemedia.com/)



//  Mark Pilgrim (http://diveintomark.org/)



//  Martin Bialasinki



//



// script.aculo.us is freely distributable under the terms of an MIT-style license.



// For details, see the script.aculo.us web site: http://script.aculo.us/







// converts rgb() and #xxx to #xxxxxx format,



// returns self (or first argument) if not convertable



String.prototype.parseColor = function() {



  var color = '#';



  if (this.slice(0,4) == 'rgb(') {



    var cols = this.slice(4,this.length-1).split(',');



    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);



  } else {



    if (this.slice(0,1) == '#') {



      if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();



      if (this.length==7) color = this.toLowerCase();



    }



  }



  return (color.length==7 ? color : (arguments[0] || this));



};







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







Element.collectTextNodes = function(element) {



  return $A($(element).childNodes).collect( function(node) {



    return (node.nodeType==3 ? node.nodeValue :



      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));



  }).flatten().join('');



};







Element.collectTextNodesIgnoreClass = function(element, className) {



  return $A($(element).childNodes).collect( function(node) {



    return (node.nodeType==3 ? node.nodeValue :



      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ?



        Element.collectTextNodesIgnoreClass(node, className) : ''));



  }).flatten().join('');



};







Element.setContentZoom = function(element, percent) {



  element = $(element);



  element.setStyle({fontSize: (percent/100) + 'em'});



  if (Prototype.Browser.WebKit) window.scrollBy(0,0);



  return element;



};







Element.getInlineOpacity = function(element){



  return $(element).style.opacity || '';



};







Element.forceRerendering = function(element) {



  try {



    element = $(element);



    var n = document.createTextNode(' ');



    element.appendChild(n);



    element.removeChild(n);



  } catch(e) { }



};







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







var Effect = {



  _elementDoesNotExistError: {



    name: 'ElementDoesNotExistError',



    message: 'The specified DOM element does not exist, but is required for this effect to operate'



  },



  Transitions: {



    linear: Prototype.K,



    sinoidal: function(pos) {



      return (-Math.cos(pos*Math.PI)/2) + .5;



    },



    reverse: function(pos) {



      return 1-pos;



    },



    flicker: function(pos) {



      var pos = ((-Math.cos(pos*Math.PI)/4) + .75) + Math.random()/4;



      return pos > 1 ? 1 : pos;



    },



    wobble: function(pos) {



      return (-Math.cos(pos*Math.PI*(9*pos))/2) + .5;



    },



    pulse: function(pos, pulses) {



      return (-Math.cos((pos*((pulses||5)-.5)*2)*Math.PI)/2) + .5;



    },



    spring: function(pos) {



      return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6));



    },



    none: function(pos) {



      return 0;



    },



    full: function(pos) {



      return 1;



    }



  },



  DefaultOptions: {



    duration:   1.0,   // seconds



    fps:        100,   // 100= assume 66fps max.



    sync:       false, // true for combining



    from:       0.0,



    to:         1.0,



    delay:      0.0,



    queue:      'parallel'



  },



  tagifyText: function(element) {



    var tagifyStyle = 'position:relative';



    if (Prototype.Browser.IE) tagifyStyle += ';zoom:1';







    element = $(element);



    $A(element.childNodes).each( function(child) {



      if (child.nodeType==3) {



        child.nodeValue.toArray().each( function(character) {



          element.insertBefore(



            new Element('span', {style: tagifyStyle}).update(



              character == ' ' ? String.fromCharCode(160) : character),



              child);



        });



        Element.remove(child);



      }



    });



  },



  multiple: function(element, effect) {



    var elements;



    if (((typeof element == 'object') ||



        Object.isFunction(element)) &&



       (element.length))



      elements = element;



    else



      elements = $(element).childNodes;







    var options = Object.extend({



      speed: 0.1,



      delay: 0.0



    }, arguments[2] || { });



    var masterDelay = options.delay;







    $A(elements).each( function(element, index) {



      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));



    });



  },



  PAIRS: {



    'slide':  ['SlideDown','SlideUp'],



    'blind':  ['BlindDown','BlindUp'],



    'appear': ['Appear','Fade']



  },



  toggle: function(element, effect) {



    element = $(element);



    effect = (effect || 'appear').toLowerCase();



    var options = Object.extend({



      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }



    }, arguments[2] || { });



    Effect[element.visible() ?



      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);



  }



};







Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;







/* ------------- core effects ------------- */







Effect.ScopedQueue = Class.create(Enumerable, {



  initialize: function() {



    this.effects  = [];



    this.interval = null;



  },



  _each: function(iterator) {



    this.effects._each(iterator);



  },



  add: function(effect) {



    var timestamp = new Date().getTime();







    var position = Object.isString(effect.options.queue) ?



      effect.options.queue : effect.options.queue.position;







    switch(position) {



      case 'front':



        // move unstarted effects after this effect



        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {



            e.startOn  += effect.finishOn;



            e.finishOn += effect.finishOn;



          });



        break;



      case 'with-last':



        timestamp = this.effects.pluck('startOn').max() || timestamp;



        break;



      case 'end':



        // start effect after last queued effect has finished



        timestamp = this.effects.pluck('finishOn').max() || timestamp;



        break;



    }







    effect.startOn  += timestamp;



    effect.finishOn += timestamp;







    if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))



      this.effects.push(effect);







    if (!this.interval)



      this.interval = setInterval(this.loop.bind(this), 15);



  },



  remove: function(effect) {



    this.effects = this.effects.reject(function(e) { return e==effect });



    if (this.effects.length == 0) {



      clearInterval(this.interval);



      this.interval = null;



    }



  },



  loop: function() {



    var timePos = new Date().getTime();



    for(var i=0, len=this.effects.length;i<len;i++)



      this.effects[i] && this.effects[i].loop(timePos);



  }



});







Effect.Queues = {



  instances: $H(),



  get: function(queueName) {



    if (!Object.isString(queueName)) return queueName;







    return this.instances.get(queueName) ||



      this.instances.set(queueName, new Effect.ScopedQueue());



  }



};



Effect.Queue = Effect.Queues.get('global');







Effect.Base = Class.create({



  position: null,



  start: function(options) {



    function codeForEvent(options,eventName){



      return (



        (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +



        (options[eventName] ? 'this.options.'+eventName+'(this);' : '')



      );



    }



    if (options && options.transition === false) options.transition = Effect.Transitions.linear;



    this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });



    this.currentFrame = 0;



    this.state        = 'idle';



    this.startOn      = this.options.delay*1000;



    this.finishOn     = this.startOn+(this.options.duration*1000);



    this.fromToDelta  = this.options.to-this.options.from;



    this.totalTime    = this.finishOn-this.startOn;



    this.totalFrames  = this.options.fps*this.options.duration;







    this.render = (function() {



      function dispatch(effect, eventName) {



        if (effect.options[eventName + 'Internal'])



          effect.options[eventName + 'Internal'](effect);



        if (effect.options[eventName])



          effect.options[eventName](effect);



      }







      return function(pos) {



        if (this.state === "idle") {



          this.state = "running";



          dispatch(this, 'beforeSetup');



          if (this.setup) this.setup();



          dispatch(this, 'afterSetup');



        }



        if (this.state === "running") {



          pos = (this.options.transition(pos) * this.fromToDelta) + this.options.from;



          this.position = pos;



          dispatch(this, 'beforeUpdate');



          if (this.update) this.update(pos);



          dispatch(this, 'afterUpdate');



        }



      };



    })();







    this.event('beforeStart');



    if (!this.options.sync)



      Effect.Queues.get(Object.isString(this.options.queue) ?



        'global' : this.options.queue.scope).add(this);



  },



  loop: function(timePos) {



    if (timePos >= this.startOn) {



      if (timePos >= this.finishOn) {



        this.render(1.0);



        this.cancel();



        this.event('beforeFinish');



        if (this.finish) this.finish();



        this.event('afterFinish');



        return;



      }



      var pos   = (timePos - this.startOn) / this.totalTime,



          frame = (pos * this.totalFrames).round();



      if (frame > this.currentFrame) {



        this.render(pos);



        this.currentFrame = frame;



      }



    }



  },



  cancel: function() {



    if (!this.options.sync)



      Effect.Queues.get(Object.isString(this.options.queue) ?



        'global' : this.options.queue.scope).remove(this);



    this.state = 'finished';



  },



  event: function(eventName) {



    if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);



    if (this.options[eventName]) this.options[eventName](this);



  },



  inspect: function() {



    var data = $H();



    for(property in this)



      if (!Object.isFunction(this[property])) data.set(property, this[property]);



    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>';



  }



});







Effect.Parallel = Class.create(Effect.Base, {



  initialize: function(effects) {



    this.effects = effects || [];



    this.start(arguments[1]);



  },



  update: function(position) {



    this.effects.invoke('render', position);



  },



  finish: function(position) {



    this.effects.each( function(effect) {



      effect.render(1.0);



      effect.cancel();



      effect.event('beforeFinish');



      if (effect.finish) effect.finish(position);



      effect.event('afterFinish');



    });



  }



});







Effect.Tween = Class.create(Effect.Base, {



  initialize: function(object, from, to) {



    object = Object.isString(object) ? $(object) : object;



    var args = $A(arguments), method = args.last(),



      options = args.length == 5 ? args[3] : null;



    this.method = Object.isFunction(method) ? method.bind(object) :



      Object.isFunction(object[method]) ? object[method].bind(object) :



      function(value) { object[method] = value };



    this.start(Object.extend({ from: from, to: to }, options || { }));



  },



  update: function(position) {



    this.method(position);



  }



});







Effect.Event = Class.create(Effect.Base, {



  initialize: function() {



    this.start(Object.extend({ duration: 0 }, arguments[0] || { }));



  },



  update: Prototype.emptyFunction



});







Effect.Opacity = Class.create(Effect.Base, {



  initialize: function(element) {



    this.element = $(element);



    if (!this.element) throw(Effect._elementDoesNotExistError);



    // make this work on IE on elements without 'layout'



    if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))



      this.element.setStyle({zoom: 1});



    var options = Object.extend({



      from: this.element.getOpacity() || 0.0,



      to:   1.0



    }, arguments[1] || { });



    this.start(options);



  },



  update: function(position) {



    this.element.setOpacity(position);



  }



});







Effect.Move = Class.create(Effect.Base, {



  initialize: function(element) {



    this.element = $(element);



    if (!this.element) throw(Effect._elementDoesNotExistError);



    var options = Object.extend({



      x:    0,



      y:    0,



      mode: 'relative'



    }, arguments[1] || { });



    this.start(options);



  },



  setup: function() {



    this.element.makePositioned();



    this.originalLeft = parseFloat(this.element.getStyle('left') || '0');



    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0');



    if (this.options.mode == 'absolute') {



      this.options.x = this.options.x - this.originalLeft;



      this.options.y = this.options.y - this.originalTop;



    }



  },



  update: function(position) {



    this.element.setStyle({



      left: (this.options.x  * position + this.originalLeft).round() + 'px',



      top:  (this.options.y  * position + this.originalTop).round()  + 'px'



    });



  }



});







// for backwards compatibility



Effect.MoveBy = function(element, toTop, toLeft) {



  return new Effect.Move(element,



    Object.extend({ x: toLeft, y: toTop }, arguments[3] || { }));



};







Effect.Scale = Class.create(Effect.Base, {



  initialize: function(element, percent) {



    this.element = $(element);



    if (!this.element) throw(Effect._elementDoesNotExistError);



    var options = Object.extend({



      scaleX: true,



      scaleY: true,



      scaleContent: true,



      scaleFromCenter: false,



      scaleMode: 'box',        // 'box' or 'contents' or { } with provided values



      scaleFrom: 100.0,



      scaleTo:   percent



    }, arguments[2] || { });



    this.start(options);



  },



  setup: function() {



    this.restoreAfterFinish = this.options.restoreAfterFinish || false;



    this.elementPositioning = this.element.getStyle('position');







    this.originalStyle = { };



    ['top','left','width','height','fontSize'].each( function(k) {



      this.originalStyle[k] = this.element.style[k];



    }.bind(this));







    this.originalTop  = this.element.offsetTop;



    this.originalLeft = this.element.offsetLeft;







    var fontSize = this.element.getStyle('font-size') || '100%';



    ['em','px','%','pt'].each( function(fontSizeType) {



      if (fontSize.indexOf(fontSizeType)>0) {



        this.fontSize     = parseFloat(fontSize);



        this.fontSizeType = fontSizeType;



      }



    }.bind(this));







    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;







    this.dims = null;



    if (this.options.scaleMode=='box')



      this.dims = [this.element.offsetHeight, this.element.offsetWidth];



    if (/^content/.test(this.options.scaleMode))



      this.dims = [this.element.scrollHeight, this.element.scrollWidth];



    if (!this.dims)



      this.dims = [this.options.scaleMode.originalHeight,



                   this.options.scaleMode.originalWidth];



  },



  update: function(position) {



    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);



    if (this.options.scaleContent && this.fontSize)



      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });



    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);



  },



  finish: function(position) {



    if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle);



  },



  setDimensions: function(height, width) {



    var d = { };



    if (this.options.scaleX) d.width = width.round() + 'px';



    if (this.options.scaleY) d.height = height.round() + 'px';



    if (this.options.scaleFromCenter) {



      var topd  = (height - this.dims[0])/2;



      var leftd = (width  - this.dims[1])/2;



      if (this.elementPositioning == 'absolute') {



        if (this.options.scaleY) d.top = this.originalTop-topd + 'px';



        if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px';



      } else {



        if (this.options.scaleY) d.top = -topd + 'px';



        if (this.options.scaleX) d.left = -leftd + 'px';



      }



    }



    this.element.setStyle(d);



  }



});







Effect.Highlight = Class.create(Effect.Base, {



  initialize: function(element) {



    this.element = $(element);



    if (!this.element) throw(Effect._elementDoesNotExistError);



    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { });



    this.start(options);



  },



  setup: function() {



    // Prevent executing on elements not in the layout flow



    if (this.element.getStyle('display')=='none') { this.cancel(); return; }



    // Disable background image during the effect



    this.oldStyle = { };



    if (!this.options.keepBackgroundImage) {



      this.oldStyle.backgroundImage = this.element.getStyle('background-image');



      this.element.setStyle({backgroundImage: 'none'});



    }



    if (!this.options.endcolor)



      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');



    if (!this.options.restorecolor)



      this.options.restorecolor = this.element.getStyle('background-color');



    // init color calculations



    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));



    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));



  },



  update: function(position) {



    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){



      return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) });



  },



  finish: function() {



    this.element.setStyle(Object.extend(this.oldStyle, {



      backgroundColor: this.options.restorecolor



    }));



  }



});







Effect.ScrollTo = function(element) {



  var options = arguments[1] || { },



  scrollOffsets = document.viewport.getScrollOffsets(),



  elementOffsets = $(element).cumulativeOffset();







  if (options.offset) elementOffsets[1] += options.offset;







  return new Effect.Tween(null,



    scrollOffsets.top,



    elementOffsets[1],



    options,



    function(p){ scrollTo(scrollOffsets.left, p.round()); }



  );



};







/* ------------- combination effects ------------- */







Effect.Fade = function(element) {



  element = $(element);



  var oldOpacity = element.getInlineOpacity();



  var options = Object.extend({



    from: element.getOpacity() || 1.0,



    to:   0.0,



    afterFinishInternal: function(effect) {



      if (effect.options.to!=0) return;



      effect.element.hide().setStyle({opacity: oldOpacity});



    }



  }, arguments[1] || { });



  return new Effect.Opacity(element,options);



};







Effect.Appear = function(element) {



  element = $(element);



  var options = Object.extend({



  from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0),



  to:   1.0,



  // force Safari to render floated elements properly



  afterFinishInternal: function(effect) {



    effect.element.forceRerendering();



  },



  beforeSetup: function(effect) {



    effect.element.setOpacity(effect.options.from).show();



  }}, arguments[1] || { });



  return new Effect.Opacity(element,options);



};







Effect.Puff = function(element) {



  element = $(element);



  var oldStyle = {



    opacity: element.getInlineOpacity(),



    position: element.getStyle('position'),



    top:  element.style.top,



    left: element.style.left,



    width: element.style.width,



    height: element.style.height



  };



  return new Effect.Parallel(



   [ new Effect.Scale(element, 200,



      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),



     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],



     Object.extend({ duration: 1.0,



      beforeSetupInternal: function(effect) {



        Position.absolutize(effect.effects[0].element);



      },



      afterFinishInternal: function(effect) {



         effect.effects[0].element.hide().setStyle(oldStyle); }



     }, arguments[1] || { })



   );



};







Effect.BlindUp = function(element) {



  element = $(element);



  element.makeClipping();



  return new Effect.Scale(element, 0,



    Object.extend({ scaleContent: false,



      scaleX: false,



      restoreAfterFinish: true,



      afterFinishInternal: function(effect) {



        effect.element.hide().undoClipping();



      }



    }, arguments[1] || { })



  );



};







Effect.BlindDown = function(element) {



  element = $(element);



  var elementDimensions = element.getDimensions();



  return new Effect.Scale(element, 100, Object.extend({



    scaleContent: false,



    scaleX: false,



    scaleFrom: 0,



    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},



    restoreAfterFinish: true,



    afterSetup: function(effect) {



      effect.element.makeClipping().setStyle({height: '0px'}).show();



    },



    afterFinishInternal: function(effect) {



      effect.element.undoClipping();



    }



  }, arguments[1] || { }));



};







Effect.SwitchOff = function(element) {



  element = $(element);



  var oldOpacity = element.getInlineOpacity();



  return new Effect.Appear(element, Object.extend({



    duration: 0.4,



    from: 0,



    transition: Effect.Transitions.flicker,



    afterFinishInternal: function(effect) {



      new Effect.Scale(effect.element, 1, {



        duration: 0.3, scaleFromCenter: true,



        scaleX: false, scaleContent: false, restoreAfterFinish: true,



        beforeSetup: function(effect) {



          effect.element.makePositioned().makeClipping();



        },



        afterFinishInternal: function(effect) {



          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity});



        }



      });



    }



  }, arguments[1] || { }));



};







Effect.DropOut = function(element) {



  element = $(element);



  var oldStyle = {



    top: element.getStyle('top'),



    left: element.getStyle('left'),



    opacity: element.getInlineOpacity() };



  return new Effect.Parallel(



    [ new Effect.Move(element, {x: 0, y: 100, sync: true }),



      new Effect.Opacity(element, { sync: true, to: 0.0 }) ],



    Object.extend(



      { duration: 0.5,



        beforeSetup: function(effect) {



          effect.effects[0].element.makePositioned();



        },



        afterFinishInternal: function(effect) {



          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);



        }



      }, arguments[1] || { }));



};







Effect.Shake = function(element) {



  element = $(element);



  var options = Object.extend({



    distance: 20,



    duration: 0.5



  }, arguments[1] || {});



  var distance = parseFloat(options.distance);



  var split = parseFloat(options.duration) / 10.0;



  var oldStyle = {



    top: element.getStyle('top'),



    left: element.getStyle('left') };



    return new Effect.Move(element,



      { x:  distance, y: 0, duration: split, afterFinishInternal: function(effect) {



    new Effect.Move(effect.element,



      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {



    new Effect.Move(effect.element,



      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {



    new Effect.Move(effect.element,



      { x: -distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {



    new Effect.Move(effect.element,



      { x:  distance*2, y: 0, duration: split*2,  afterFinishInternal: function(effect) {



    new Effect.Move(effect.element,



      { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) {



        effect.element.undoPositioned().setStyle(oldStyle);



  }}); }}); }}); }}); }}); }});



};







Effect.SlideDown = function(element) {



  element = $(element).cleanWhitespace();



  // SlideDown need to have the content of the element wrapped in a container element with fixed height!



  var oldInnerBottom = element.down().getStyle('bottom');



  var elementDimensions = element.getDimensions();



  return new Effect.Scale(element, 100, Object.extend({



    scaleContent: false,



    scaleX: false,



    scaleFrom: window.opera ? 0 : 1,



    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},



    restoreAfterFinish: true,



    afterSetup: function(effect) {



      effect.element.makePositioned();



      effect.element.down().makePositioned();



      if (window.opera) effect.element.setStyle({top: ''});



      effect.element.makeClipping().setStyle({height: '0px'}).show();



    },



    afterUpdateInternal: function(effect) {



      effect.element.down().setStyle({bottom:



        (effect.dims[0] - effect.element.clientHeight) + 'px' });



    },



    afterFinishInternal: function(effect) {



      effect.element.undoClipping().undoPositioned();



      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }



    }, arguments[1] || { })



  );



};







Effect.SlideUp = function(element) {



  element = $(element).cleanWhitespace();



  var oldInnerBottom = element.down().getStyle('bottom');



  var elementDimensions = element.getDimensions();



  return new Effect.Scale(element, window.opera ? 0 : 1,



   Object.extend({ scaleContent: false,



    scaleX: false,



    scaleMode: 'box',



    scaleFrom: 100,



    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},



    restoreAfterFinish: true,



    afterSetup: function(effect) {



      effect.element.makePositioned();



      effect.element.down().makePositioned();



      if (window.opera) effect.element.setStyle({top: ''});



      effect.element.makeClipping().show();



    },



    afterUpdateInternal: function(effect) {



      effect.element.down().setStyle({bottom:



        (effect.dims[0] - effect.element.clientHeight) + 'px' });



    },



    afterFinishInternal: function(effect) {



      effect.element.hide().undoClipping().undoPositioned();



      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom});



    }



   }, arguments[1] || { })



  );



};







// Bug in opera makes the TD containing this element expand for a instance after finish



Effect.Squish = function(element) {



  return new Effect.Scale(element, window.opera ? 1 : 0, {



    restoreAfterFinish: true,



    beforeSetup: function(effect) {



      effect.element.makeClipping();



    },



    afterFinishInternal: function(effect) {



      effect.element.hide().undoClipping();



    }



  });



};







Effect.Grow = function(element) {



  element = $(element);



  var options = Object.extend({



    direction: 'center',



    moveTransition: Effect.Transitions.sinoidal,



    scaleTransition: Effect.Transitions.sinoidal,



    opacityTransition: Effect.Transitions.full



  }, arguments[1] || { });



  var oldStyle = {



    top: element.style.top,



    left: element.style.left,



    height: element.style.height,



    width: element.style.width,



    opacity: element.getInlineOpacity() };







  var dims = element.getDimensions();



  var initialMoveX, initialMoveY;



  var moveX, moveY;







  switch (options.direction) {



    case 'top-left':



      initialMoveX = initialMoveY = moveX = moveY = 0;



      break;



    case 'top-right':



      initialMoveX = dims.width;



      initialMoveY = moveY = 0;



      moveX = -dims.width;



      break;



    case 'bottom-left':



      initialMoveX = moveX = 0;



      initialMoveY = dims.height;



      moveY = -dims.height;



      break;



    case 'bottom-right':



      initialMoveX = dims.width;



      initialMoveY = dims.height;



      moveX = -dims.width;



      moveY = -dims.height;



      break;



    case 'center':



      initialMoveX = dims.width / 2;



      initialMoveY = dims.height / 2;



      moveX = -dims.width / 2;



      moveY = -dims.height / 2;



      break;



  }







  return new Effect.Move(element, {



    x: initialMoveX,



    y: initialMoveY,



    duration: 0.01,



    beforeSetup: function(effect) {



      effect.element.hide().makeClipping().makePositioned();



    },



    afterFinishInternal: function(effect) {



      new Effect.Parallel(



        [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }),



          new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }),



          new Effect.Scale(effect.element, 100, {



            scaleMode: { originalHeight: dims.height, originalWidth: dims.width },



            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true})



        ], Object.extend({



             beforeSetup: function(effect) {



               effect.effects[0].element.setStyle({height: '0px'}).show();



             },



             afterFinishInternal: function(effect) {



               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);



             }



           }, options)



      );



    }



  });



};







Effect.Shrink = function(element) {



  element = $(element);



  var options = Object.extend({



    direction: 'center',



    moveTransition: Effect.Transitions.sinoidal,



    scaleTransition: Effect.Transitions.sinoidal,



    opacityTransition: Effect.Transitions.none



  }, arguments[1] || { });



  var oldStyle = {



    top: element.style.top,



    left: element.style.left,



    height: element.style.height,



    width: element.style.width,



    opacity: element.getInlineOpacity() };







  var dims = element.getDimensions();



  var moveX, moveY;







  switch (options.direction) {



    case 'top-left':



      moveX = moveY = 0;



      break;



    case 'top-right':



      moveX = dims.width;



      moveY = 0;



      break;



    case 'bottom-left':



      moveX = 0;



      moveY = dims.height;



      break;



    case 'bottom-right':



      moveX = dims.width;



      moveY = dims.height;



      break;



    case 'center':



      moveX = dims.width / 2;



      moveY = dims.height / 2;



      break;



  }







  return new Effect.Parallel(



    [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }),



      new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}),



      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition })



    ], Object.extend({



         beforeStartInternal: function(effect) {



           effect.effects[0].element.makePositioned().makeClipping();



         },



         afterFinishInternal: function(effect) {



           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); }



       }, options)



  );



};







Effect.Pulsate = function(element) {



  element = $(element);



  var options    = arguments[1] || { },



    oldOpacity = element.getInlineOpacity(),



    transition = options.transition || Effect.Transitions.linear,



    reverser   = function(pos){



      return 1 - transition((-Math.cos((pos*(options.pulses||5)*2)*Math.PI)/2) + .5);



    };







  return new Effect.Opacity(element,



    Object.extend(Object.extend({  duration: 2.0, from: 0,



      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); }



    }, options), {transition: reverser}));



};







Effect.Fold = function(element) {



  element = $(element);



  var oldStyle = {



    top: element.style.top,



    left: element.style.left,



    width: element.style.width,



    height: element.style.height };



  element.makeClipping();



  return new Effect.Scale(element, 5, Object.extend({



    scaleContent: false,



    scaleX: false,



    afterFinishInternal: function(effect) {



    new Effect.Scale(element, 1, {



      scaleContent: false,



      scaleY: false,



      afterFinishInternal: function(effect) {



        effect.element.hide().undoClipping().setStyle(oldStyle);



      } });



  }}, arguments[1] || { }));



};







Effect.Morph = Class.create(Effect.Base, {



  initialize: function(element) {



    this.element = $(element);



    if (!this.element) throw(Effect._elementDoesNotExistError);



    var options = Object.extend({



      style: { }



    }, arguments[1] || { });







    if (!Object.isString(options.style)) this.style = $H(options.style);



    else {



      if (options.style.include(':'))



        this.style = options.style.parseStyle();



      else {



        this.element.addClassName(options.style);



        this.style = $H(this.element.getStyles());



        this.element.removeClassName(options.style);



        var css = this.element.getStyles();



        this.style = this.style.reject(function(style) {



          return style.value == css[style.key];



        });



        options.afterFinishInternal = function(effect) {



          effect.element.addClassName(effect.options.style);



          effect.transforms.each(function(transform) {



            effect.element.style[transform.style] = '';



          });



        };



      }



    }



    this.start(options);



  },







  setup: function(){



    function parseColor(color){



      if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';



      color = color.parseColor();



      return $R(0,2).map(function(i){



        return parseInt( color.slice(i*2+1,i*2+3), 16 );



      });



    }



    this.transforms = this.style.map(function(pair){



      var property = pair[0], value = pair[1], unit = null;







      if (value.parseColor('#zzzzzz') != '#zzzzzz') {



        value = value.parseColor();



        unit  = 'color';



      } else if (property == 'opacity') {



        value = parseFloat(value);



        if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout))



          this.element.setStyle({zoom: 1});



      } else if (Element.CSS_LENGTH.test(value)) {



          var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);



          value = parseFloat(components[1]);



          unit = (components.length == 3) ? components[2] : null;



      }







      var originalValue = this.element.getStyle(property);



      return {



        style: property.camelize(),



        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),



        targetValue: unit=='color' ? parseColor(value) : value,



        unit: unit



      };



    }.bind(this)).reject(function(transform){



      return (



        (transform.originalValue == transform.targetValue) ||



        (



          transform.unit != 'color' &&



          (isNaN(transform.originalValue) || isNaN(transform.targetValue))



        )



      );



    });



  },



  update: function(position) {



    var style = { }, transform, i = this.transforms.length;



    while(i--)



      style[(transform = this.transforms[i]).style] =



        transform.unit=='color' ? '#'+



          (Math.round(transform.originalValue[0]+



            (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() +



          (Math.round(transform.originalValue[1]+



            (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() +



          (Math.round(transform.originalValue[2]+



            (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() :



        (transform.originalValue +



          (transform.targetValue - transform.originalValue) * position).toFixed(3) +



            (transform.unit === null ? '' : transform.unit);



    this.element.setStyle(style, true);



  }



});







Effect.Transform = Class.create({



  initialize: function(tracks){



    this.tracks  = [];



    this.options = arguments[1] || { };



    this.addTracks(tracks);



  },



  addTracks: function(tracks){



    tracks.each(function(track){



      track = $H(track);



      var data = track.values().first();



      this.tracks.push($H({



        ids:     track.keys().first(),



        effect:  Effect.Morph,



        options: { style: data }



      }));



    }.bind(this));



    return this;



  },



  play: function(){



    return new Effect.Parallel(



      this.tracks.map(function(track){



        var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options');



        var elements = [$(ids) || $$(ids)].flatten();



        return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) });



      }).flatten(),



      this.options



    );



  }



});







Element.CSS_PROPERTIES = $w(



  'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +



  'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' +



  'borderRightColor borderRightStyle borderRightWidth borderSpacing ' +



  'borderTopColor borderTopStyle borderTopWidth bottom clip color ' +



  'fontSize fontWeight height left letterSpacing lineHeight ' +



  'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+



  'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' +



  'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' +



  'right textIndent top width wordSpacing zIndex');







Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;







String.__parseStyleElement = document.createElement('div');



String.prototype.parseStyle = function(){



  var style, styleRules = $H();



  if (Prototype.Browser.WebKit)



    style = new Element('div',{style:this}).style;



  else {



    String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';



    style = String.__parseStyleElement.childNodes[0].style;



  }







  Element.CSS_PROPERTIES.each(function(property){



    if (style[property]) styleRules.set(property, style[property]);



  });







  if (Prototype.Browser.IE && this.include('opacity'))



    styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);







  return styleRules;



};







if (document.defaultView && document.defaultView.getComputedStyle) {



  Element.getStyles = function(element) {



    var css = document.defaultView.getComputedStyle($(element), null);



    return Element.CSS_PROPERTIES.inject({ }, function(styles, property) {



      styles[property] = css[property];



      return styles;



    });



  };



} else {



  Element.getStyles = function(element) {



    element = $(element);



    var css = element.currentStyle, styles;



    styles = Element.CSS_PROPERTIES.inject({ }, function(results, property) {



      results[property] = css[property];



      return results;



    });



    if (!styles.opacity) styles.opacity = element.getOpacity();



    return styles;



  };



}







Effect.Methods = {



  morph: function(element, style) {



    element = $(element);



    new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { }));



    return element;



  },



  visualEffect: function(element, effect, options) {



    element = $(element);



    var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1);



    new Effect[klass](element, options);



    return element;



  },



  highlight: function(element, options) {



    element = $(element);



    new Effect.Highlight(element, options);



    return element;



  }



};







$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+



  'pulsate shake puff squish switchOff dropOut').each(



  function(effect) {



    Effect.Methods[effect] = function(element, options){



      element = $(element);



      Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options);



      return element;



    };



  }



);







$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(



  function(f) { Effect.Methods[f] = Element[f]; }



);







Element.addMethods(Effect.Methods);



// script.aculo.us dragdrop.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010







// Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)



//



// script.aculo.us is freely distributable under the terms of an MIT-style license.



// For details, see the script.aculo.us web site: http://script.aculo.us/







if(Object.isUndefined(Effect))



  throw("dragdrop.js requires including script.aculo.us' effects.js library");







var Droppables = {



  drops: [],







  remove: function(element) {



    this.drops = this.drops.reject(function(d) { return d.element==$(element) });



  },







  add: function(element) {



    element = $(element);



    var options = Object.extend({



      greedy:     true,



      hoverclass: null,



      tree:       false



    }, arguments[1] || { });







    // cache containers



    if(options.containment) {



      options._containers = [];



      var containment = options.containment;



      if(Object.isArray(containment)) {



        containment.each( function(c) { options._containers.push($(c)) });



      } else {



        options._containers.push($(containment));



      }



    }







    if(options.accept) options.accept = [options.accept].flatten();







    Element.makePositioned(element); // fix IE



    options.element = element;







    this.drops.push(options);



  },







  findDeepestChild: function(drops) {



    deepest = drops[0];







    for (i = 1; i < drops.length; ++i)



      if (Element.isParent(drops[i].element, deepest.element))



        deepest = drops[i];







    return deepest;



  },







  isContained: function(element, drop) {



    var containmentNode;



    if(drop.tree) {



      containmentNode = element.treeNode;



    } else {



      containmentNode = element.parentNode;



    }



    return drop._containers.detect(function(c) { return containmentNode == c });



  },







  isAffected: function(point, element, drop) {



    return (



      (drop.element!=element) &&



      ((!drop._containers) ||



        this.isContained(element, drop)) &&



      ((!drop.accept) ||



        (Element.classNames(element).detect(



          function(v) { return drop.accept.include(v) } ) )) &&



      Position.within(drop.element, point[0], point[1]) );



  },







  deactivate: function(drop) {



    if(drop.hoverclass)



      Element.removeClassName(drop.element, drop.hoverclass);



    this.last_active = null;



  },







  activate: function(drop) {



    if(drop.hoverclass)



      Element.addClassName(drop.element, drop.hoverclass);



    this.last_active = drop;



  },







  show: function(point, element) {



    if(!this.drops.length) return;



    var drop, affected = [];







    this.drops.each( function(drop) {



      if(Droppables.isAffected(point, element, drop))



        affected.push(drop);



    });







    if(affected.length>0)



      drop = Droppables.findDeepestChild(affected);







    if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);



    if (drop) {



      Position.within(drop.element, point[0], point[1]);



      if(drop.onHover)



        drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));







      if (drop != this.last_active) Droppables.activate(drop);



    }



  },







  fire: function(event, element) {



    if(!this.last_active) return;



    Position.prepare();







    if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))



      if (this.last_active.onDrop) {



        this.last_active.onDrop(element, this.last_active.element, event);



        return true;



      }



  },







  reset: function() {



    if(this.last_active)



      this.deactivate(this.last_active);



  }



};







var Draggables = {



  drags: [],



  observers: [],







  register: function(draggable) {



    if(this.drags.length == 0) {



      this.eventMouseUp   = this.endDrag.bindAsEventListener(this);



      this.eventMouseMove = this.updateDrag.bindAsEventListener(this);



      this.eventKeypress  = this.keyPress.bindAsEventListener(this);







      Event.observe(document, "mouseup", this.eventMouseUp);



      Event.observe(document, "mousemove", this.eventMouseMove);



      Event.observe(document, "keypress", this.eventKeypress);



    }



    this.drags.push(draggable);



  },







  unregister: function(draggable) {



    this.drags = this.drags.reject(function(d) { return d==draggable });



    if(this.drags.length == 0) {



      Event.stopObserving(document, "mouseup", this.eventMouseUp);



      Event.stopObserving(document, "mousemove", this.eventMouseMove);



      Event.stopObserving(document, "keypress", this.eventKeypress);



    }



  },







  activate: function(draggable) {



    if(draggable.options.delay) {



      this._timeout = setTimeout(function() {



        Draggables._timeout = null;



        window.focus();



        Draggables.activeDraggable = draggable;



      }.bind(this), draggable.options.delay);



    } else {



      window.focus(); // allows keypress events if window isn't currently focused, fails for Safari



      this.activeDraggable = draggable;



    }



  },







  deactivate: function() {



    this.activeDraggable = null;



  },







  updateDrag: function(event) {



    if(!this.activeDraggable) return;



    var pointer = [Event.pointerX(event), Event.pointerY(event)];



    // Mozilla-based browsers fire successive mousemove events with



    // the same coordinates, prevent needless redrawing (moz bug?)



    if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;



    this._lastPointer = pointer;







    this.activeDraggable.updateDrag(event, pointer);



  },







  endDrag: function(event) {



    if(this._timeout) {



      clearTimeout(this._timeout);



      this._timeout = null;



    }



    if(!this.activeDraggable) return;



    this._lastPointer = null;



    this.activeDraggable.endDrag(event);



    this.activeDraggable = null;



  },







  keyPress: function(event) {



    if(this.activeDraggable)



      this.activeDraggable.keyPress(event);



  },







  addObserver: function(observer) {



    this.observers.push(observer);



    this._cacheObserverCallbacks();



  },







  removeObserver: function(element) {  // element instead of observer fixes mem leaks



    this.observers = this.observers.reject( function(o) { return o.element==element });



    this._cacheObserverCallbacks();



  },







  notify: function(eventName, draggable, event) {  // 'onStart', 'onEnd', 'onDrag'



    if(this[eventName+'Count'] > 0)



      this.observers.each( function(o) {



        if(o[eventName]) o[eventName](eventName, draggable, event);



      });



    if(draggable.options[eventName]) draggable.options[eventName](draggable, event);



  },







  _cacheObserverCallbacks: function() {



    ['onStart','onEnd','onDrag'].each( function(eventName) {



      Draggables[eventName+'Count'] = Draggables.observers.select(



        function(o) { return o[eventName]; }



      ).length;



    });



  }



};







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







var Draggable = Class.create({



  initialize: function(element) {



    var defaults = {



      handle: false,



      reverteffect: function(element, top_offset, left_offset) {



        var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;



        new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,



          queue: {scope:'_draggable', position:'end'}



        });



      },



      endeffect: function(element) {



        var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;



        new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,



          queue: {scope:'_draggable', position:'end'},



          afterFinish: function(){



            Draggable._dragging[element] = false



          }



        });



      },



      zindex: 1000,



      revert: false,



      quiet: false,



      scroll: false,



      scrollSensitivity: 20,



      scrollSpeed: 15,



      snap: false,  // false, or xy or [x,y] or function(x,y){ return [x,y] }



      delay: 0



    };







    if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))



      Object.extend(defaults, {



        starteffect: function(element) {



          element._opacity = Element.getOpacity(element);



          Draggable._dragging[element] = true;



          new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});



        }



      });







    var options = Object.extend(defaults, arguments[1] || { });







    this.element = $(element);







    if(options.handle && Object.isString(options.handle))



      this.handle = this.element.down('.'+options.handle, 0);







    if(!this.handle) this.handle = $(options.handle);



    if(!this.handle) this.handle = this.element;







    if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {



      options.scroll = $(options.scroll);



      this._isScrollChild = Element.childOf(this.element, options.scroll);



    }







    Element.makePositioned(this.element); // fix IE







    this.options  = options;



    this.dragging = false;







    this.eventMouseDown = this.initDrag.bindAsEventListener(this);



    Event.observe(this.handle, "mousedown", this.eventMouseDown);







    Draggables.register(this);



  },







  destroy: function() {



    Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);



    Draggables.unregister(this);



  },







  currentDelta: function() {



    return([



      parseInt(Element.getStyle(this.element,'left') || '0'),



      parseInt(Element.getStyle(this.element,'top') || '0')]);



  },







  initDrag: function(event) {



    if(!Object.isUndefined(Draggable._dragging[this.element]) &&



      Draggable._dragging[this.element]) return;



    if(Event.isLeftClick(event)) {



      // abort on form elements, fixes a Firefox issue



      var src = Event.element(event);



      if((tag_name = src.tagName.toUpperCase()) && (



        tag_name=='INPUT' ||



        tag_name=='SELECT' ||



        tag_name=='OPTION' ||



        tag_name=='BUTTON' ||



        tag_name=='TEXTAREA')) return;







      var pointer = [Event.pointerX(event), Event.pointerY(event)];



      var pos     = this.element.cumulativeOffset();



      this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });







      Draggables.activate(this);



      Event.stop(event);



    }



  },







  startDrag: function(event) {



    this.dragging = true;



    if(!this.delta)



      this.delta = this.currentDelta();







    if(this.options.zindex) {



      this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);



      this.element.style.zIndex = this.options.zindex;



    }







    if(this.options.ghosting) {



      this._clone = this.element.cloneNode(true);



      this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');



      if (!this._originallyAbsolute)



        Position.absolutize(this.element);



      this.element.parentNode.insertBefore(this._clone, this.element);



    }







    if(this.options.scroll) {



      if (this.options.scroll == window) {



        var where = this._getWindowScroll(this.options.scroll);



        this.originalScrollLeft = where.left;



        this.originalScrollTop = where.top;



      } else {



        this.originalScrollLeft = this.options.scroll.scrollLeft;



        this.originalScrollTop = this.options.scroll.scrollTop;



      }



    }







    Draggables.notify('onStart', this, event);







    if(this.options.starteffect) this.options.starteffect(this.element);



  },







  updateDrag: function(event, pointer) {



    if(!this.dragging) this.startDrag(event);







    if(!this.options.quiet){



      Position.prepare();



      Droppables.show(pointer, this.element);



    }







    Draggables.notify('onDrag', this, event);







    this.draw(pointer);



    if(this.options.change) this.options.change(this);







    if(this.options.scroll) {



      this.stopScrolling();







      var p;



      if (this.options.scroll == window) {



        with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }



      } else {



        p = Position.page(this.options.scroll).toArray();



        p[0] += this.options.scroll.scrollLeft + Position.deltaX;



        p[1] += this.options.scroll.scrollTop + Position.deltaY;



        p.push(p[0]+this.options.scroll.offsetWidth);



        p.push(p[1]+this.options.scroll.offsetHeight);



      }



      var speed = [0,0];



      if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity);



      if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity);



      if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity);



      if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);



      this.startScrolling(speed);



    }







    // fix AppleWebKit rendering



    if(Prototype.Browser.WebKit) window.scrollBy(0,0);







    Event.stop(event);



  },







  finishDrag: function(event, success) {



    this.dragging = false;







    if(this.options.quiet){



      Position.prepare();



      var pointer = [Event.pointerX(event), Event.pointerY(event)];



      Droppables.show(pointer, this.element);



    }







    if(this.options.ghosting) {



      if (!this._originallyAbsolute)



        Position.relativize(this.element);



      delete this._originallyAbsolute;



      Element.remove(this._clone);



      this._clone = null;



    }







    var dropped = false;



    if(success) {



      dropped = Droppables.fire(event, this.element);



      if (!dropped) dropped = false;



    }



    if(dropped && this.options.onDropped) this.options.onDropped(this.element);



    Draggables.notify('onEnd', this, event);







    var revert = this.options.revert;



    if(revert && Object.isFunction(revert)) revert = revert(this.element);







    var d = this.currentDelta();



    if(revert && this.options.reverteffect) {



      if (dropped == 0 || revert != 'failure')



        this.options.reverteffect(this.element,



          d[1]-this.delta[1], d[0]-this.delta[0]);



    } else {



      this.delta = d;



    }







    if(this.options.zindex)



      this.element.style.zIndex = this.originalZ;







    if(this.options.endeffect)



      this.options.endeffect(this.element);







    Draggables.deactivate(this);



    Droppables.reset();



  },







  keyPress: function(event) {



    if(event.keyCode!=Event.KEY_ESC) return;



    this.finishDrag(event, false);



    Event.stop(event);



  },







  endDrag: function(event) {



    if(!this.dragging) return;



    this.stopScrolling();



    this.finishDrag(event, true);



    Event.stop(event);



  },







  draw: function(point) {



    var pos = this.element.cumulativeOffset();



    if(this.options.ghosting) {



      var r   = Position.realOffset(this.element);



      pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;



    }







    var d = this.currentDelta();



    pos[0] -= d[0]; pos[1] -= d[1];







    if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {



      pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;



      pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;



    }







    var p = [0,1].map(function(i){



      return (point[i]-pos[i]-this.offset[i])



    }.bind(this));







    if(this.options.snap) {



      if(Object.isFunction(this.options.snap)) {



        p = this.options.snap(p[0],p[1],this);



      } else {



      if(Object.isArray(this.options.snap)) {



        p = p.map( function(v, i) {



          return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));



      } else {



        p = p.map( function(v) {



          return (v/this.options.snap).round()*this.options.snap }.bind(this));



      }



    }}







    var style = this.element.style;



    if((!this.options.constraint) || (this.options.constraint=='horizontal'))



      style.left = p[0] + "px";



    if((!this.options.constraint) || (this.options.constraint=='vertical'))



      style.top  = p[1] + "px";







    if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering



  },







  stopScrolling: function() {



    if(this.scrollInterval) {



      clearInterval(this.scrollInterval);



      this.scrollInterval = null;



      Draggables._lastScrollPointer = null;



    }



  },







  startScrolling: function(speed) {



    if(!(speed[0] || speed[1])) return;



    this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];



    this.lastScrolled = new Date();



    this.scrollInterval = setInterval(this.scroll.bind(this), 10);



  },







  scroll: function() {



    var current = new Date();



    var delta = current - this.lastScrolled;



    this.lastScrolled = current;



    if(this.options.scroll == window) {



      with (this._getWindowScroll(this.options.scroll)) {



        if (this.scrollSpeed[0] || this.scrollSpeed[1]) {



          var d = delta / 1000;



          this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] );



        }



      }



    } else {



      this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;



      this.options.scroll.scrollTop  += this.scrollSpeed[1] * delta / 1000;



    }







    Position.prepare();



    Droppables.show(Draggables._lastPointer, this.element);



    Draggables.notify('onDrag', this);



    if (this._isScrollChild) {



      Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);



      Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;



      Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;



      if (Draggables._lastScrollPointer[0] < 0)



        Draggables._lastScrollPointer[0] = 0;



      if (Draggables._lastScrollPointer[1] < 0)



        Draggables._lastScrollPointer[1] = 0;



      this.draw(Draggables._lastScrollPointer);



    }







    if(this.options.change) this.options.change(this);



  },







  _getWindowScroll: function(w) {



    var T, L, W, H;



    with (w.document) {



      if (w.document.documentElement && documentElement.scrollTop) {



        T = documentElement.scrollTop;



        L = documentElement.scrollLeft;



      } else if (w.document.body) {



        T = body.scrollTop;



        L = body.scrollLeft;



      }



      if (w.innerWidth) {



        W = w.innerWidth;



        H = w.innerHeight;



      } else if (w.document.documentElement && documentElement.clientWidth) {



        W = documentElement.clientWidth;



        H = documentElement.clientHeight;



      } else {



        W = body.offsetWidth;



        H = body.offsetHeight;



      }



    }



    return { top: T, left: L, width: W, height: H };



  }



});







Draggable._dragging = { };







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







var SortableObserver = Class.create({



  initialize: function(element, observer) {



    this.element   = $(element);



    this.observer  = observer;



    this.lastValue = Sortable.serialize(this.element);



  },







  onStart: function() {



    this.lastValue = Sortable.serialize(this.element);



  },







  onEnd: function() {



    Sortable.unmark();



    if(this.lastValue != Sortable.serialize(this.element))



      this.observer(this.element)



  }



});







var Sortable = {



  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,







  sortables: { },







  _findRootElement: function(element) {



    while (element.tagName.toUpperCase() != "BODY") {



      if(element.id && Sortable.sortables[element.id]) return element;



      element = element.parentNode;



    }



  },







  options: function(element) {



    element = Sortable._findRootElement($(element));



    if(!element) return;



    return Sortable.sortables[element.id];



  },







  destroy: function(element){



    element = $(element);



    var s = Sortable.sortables[element.id];







    if(s) {



      Draggables.removeObserver(s.element);



      s.droppables.each(function(d){ Droppables.remove(d) });



      s.draggables.invoke('destroy');







      delete Sortable.sortables[s.element.id];



    }



  },







  create: function(element) {



    element = $(element);



    var options = Object.extend({



      element:     element,



      tag:         'li',       // assumes li children, override with tag: 'tagname'



      dropOnEmpty: false,



      tree:        false,



      treeTag:     'ul',



      overlap:     'vertical', // one of 'vertical', 'horizontal'



      constraint:  'vertical', // one of 'vertical', 'horizontal', false



      containment: element,    // also takes array of elements (or id's); or false



      handle:      false,      // or a CSS class



      only:        false,



      delay:       0,



      hoverclass:  null,



      ghosting:    false,



      quiet:       false,



      scroll:      false,



      scrollSensitivity: 20,



      scrollSpeed: 15,



      format:      this.SERIALIZE_RULE,







      // these take arrays of elements or ids and can be



      // used for better initialization performance



      elements:    false,



      handles:     false,







      onChange:    Prototype.emptyFunction,



      onUpdate:    Prototype.emptyFunction



    }, arguments[1] || { });







    // clear any old sortable with same element



    this.destroy(element);







    // build options for the draggables



    var options_for_draggable = {



      revert:      true,



      quiet:       options.quiet,



      scroll:      options.scroll,



      scrollSpeed: options.scrollSpeed,



      scrollSensitivity: options.scrollSensitivity,



      delay:       options.delay,



      ghosting:    options.ghosting,



      constraint:  options.constraint,



      handle:      options.handle };







    if(options.starteffect)



      options_for_draggable.starteffect = options.starteffect;







    if(options.reverteffect)



      options_for_draggable.reverteffect = options.reverteffect;



    else



      if(options.ghosting) options_for_draggable.reverteffect = function(element) {



        element.style.top  = 0;



        element.style.left = 0;



      };







    if(options.endeffect)



      options_for_draggable.endeffect = options.endeffect;







    if(options.zindex)



      options_for_draggable.zindex = options.zindex;







    // build options for the droppables



    var options_for_droppable = {



      overlap:     options.overlap,



      containment: options.containment,



      tree:        options.tree,



      hoverclass:  options.hoverclass,



      onHover:     Sortable.onHover



    };







    var options_for_tree = {



      onHover:      Sortable.onEmptyHover,



      overlap:      options.overlap,



      containment:  options.containment,



      hoverclass:   options.hoverclass



    };







    // fix for gecko engine



    Element.cleanWhitespace(element);







    options.draggables = [];



    options.droppables = [];







    // drop on empty handling



    if(options.dropOnEmpty || options.tree) {



      Droppables.add(element, options_for_tree);



      options.droppables.push(element);



    }







    (options.elements || this.findElements(element, options) || []).each( function(e,i) {



      var handle = options.handles ? $(options.handles[i]) :



        (options.handle ? $(e).select('.' + options.handle)[0] : e);



      options.draggables.push(



        new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));



      Droppables.add(e, options_for_droppable);



      if(options.tree) e.treeNode = element;



      options.droppables.push(e);



    });







    if(options.tree) {



      (Sortable.findTreeElements(element, options) || []).each( function(e) {



        Droppables.add(e, options_for_tree);



        e.treeNode = element;



        options.droppables.push(e);



      });



    }







    // keep reference



    this.sortables[element.identify()] = options;







    // for onupdate



    Draggables.addObserver(new SortableObserver(element, options.onUpdate));







  },







  // return all suitable-for-sortable elements in a guaranteed order



  findElements: function(element, options) {



    return Element.findChildren(



      element, options.only, options.tree ? true : false, options.tag);



  },







  findTreeElements: function(element, options) {



    return Element.findChildren(



      element, options.only, options.tree ? true : false, options.treeTag);



  },







  onHover: function(element, dropon, overlap) {



    if(Element.isParent(dropon, element)) return;







    if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {



      return;



    } else if(overlap>0.5) {



      Sortable.mark(dropon, 'before');



      if(dropon.previousSibling != element) {



        var oldParentNode = element.parentNode;



        element.style.visibility = "hidden"; // fix gecko rendering



        dropon.parentNode.insertBefore(element, dropon);



        if(dropon.parentNode!=oldParentNode)



          Sortable.options(oldParentNode).onChange(element);



        Sortable.options(dropon.parentNode).onChange(element);



      }



    } else {



      Sortable.mark(dropon, 'after');



      var nextElement = dropon.nextSibling || null;



      if(nextElement != element) {



        var oldParentNode = element.parentNode;



        element.style.visibility = "hidden"; // fix gecko rendering



        dropon.parentNode.insertBefore(element, nextElement);



        if(dropon.parentNode!=oldParentNode)



          Sortable.options(oldParentNode).onChange(element);



        Sortable.options(dropon.parentNode).onChange(element);



      }



    }



  },







  onEmptyHover: function(element, dropon, overlap) {



    var oldParentNode = element.parentNode;



    var droponOptions = Sortable.options(dropon);







    if(!Element.isParent(dropon, element)) {



      var index;







      var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});



      var child = null;







      if(children) {



        var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);







        for (index = 0; index < children.length; index += 1) {



          if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {



            offset -= Element.offsetSize (children[index], droponOptions.overlap);



          } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {



            child = index + 1 < children.length ? children[index + 1] : null;



            break;



          } else {



            child = children[index];



            break;



          }



        }



      }







      dropon.insertBefore(element, child);







      Sortable.options(oldParentNode).onChange(element);



      droponOptions.onChange(element);



    }



  },







  unmark: function() {



    if(Sortable._marker) Sortable._marker.hide();



  },







  mark: function(dropon, position) {



    // mark on ghosting only



    var sortable = Sortable.options(dropon.parentNode);



    if(sortable && !sortable.ghosting) return;







    if(!Sortable._marker) {



      Sortable._marker =



        ($('dropmarker') || Element.extend(document.createElement('DIV'))).



          hide().addClassName('dropmarker').setStyle({position:'absolute'});



      document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);



    }



    var offsets = dropon.cumulativeOffset();



    Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});







    if(position=='after')



      if(sortable.overlap == 'horizontal')



        Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});



      else



        Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});







    Sortable._marker.show();



  },







  _tree: function(element, options, parent) {



    var children = Sortable.findElements(element, options) || [];







    for (var i = 0; i < children.length; ++i) {



      var match = children[i].id.match(options.format);







      if (!match) continue;







      var child = {



        id: encodeURIComponent(match ? match[1] : null),



        element: element,



        parent: parent,



        children: [],



        position: parent.children.length,



        container: $(children[i]).down(options.treeTag)



      };







      /* Get the element containing the children and recurse over it */



      if (child.container)



        this._tree(child.container, options, child);







      parent.children.push (child);



    }







    return parent;



  },







  tree: function(element) {



    element = $(element);



    var sortableOptions = this.options(element);



    var options = Object.extend({



      tag: sortableOptions.tag,



      treeTag: sortableOptions.treeTag,



      only: sortableOptions.only,



      name: element.id,



      format: sortableOptions.format



    }, arguments[1] || { });







    var root = {



      id: null,



      parent: null,



      children: [],



      container: element,



      position: 0



    };







    return Sortable._tree(element, options, root);



  },







  /* Construct a [i] index for a particular node */



  _constructIndex: function(node) {



    var index = '';



    do {



      if (node.id) index = '[' + node.position + ']' + index;



    } while ((node = node.parent) != null);



    return index;



  },







  sequence: function(element) {



    element = $(element);



    var options = Object.extend(this.options(element), arguments[1] || { });







    return $(this.findElements(element, options) || []).map( function(item) {



      return item.id.match(options.format) ? item.id.match(options.format)[1] : '';



    });



  },







  setSequence: function(element, new_sequence) {



    element = $(element);



    var options = Object.extend(this.options(element), arguments[2] || { });







    var nodeMap = { };



    this.findElements(element, options).each( function(n) {



        if (n.id.match(options.format))



            nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];



        n.parentNode.removeChild(n);



    });







    new_sequence.each(function(ident) {



      var n = nodeMap[ident];



      if (n) {



        n[1].appendChild(n[0]);



        delete nodeMap[ident];



      }



    });



  },







  serialize: function(element) {



    element = $(element);



    var options = Object.extend(Sortable.options(element), arguments[1] || { });



    var name = encodeURIComponent(



      (arguments[1] && arguments[1].name) ? arguments[1].name : element.id);







    if (options.tree) {



      return Sortable.tree(element, arguments[1]).children.map( function (item) {



        return [name + Sortable._constructIndex(item) + "[id]=" +



                encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));



      }).flatten().join('&');



    } else {



      return Sortable.sequence(element, arguments[1]).map( function(item) {



        return name + "[]=" + encodeURIComponent(item);



      }).join('&');



    }



  }



};







// Returns true if child is contained within element



Element.isParent = function(child, element) {



  if (!child.parentNode || child == element) return false;



  if (child.parentNode == element) return true;



  return Element.isParent(child.parentNode, element);



};







Element.findChildren = function(element, only, recursive, tagName) {



  if(!element.hasChildNodes()) return null;



  tagName = tagName.toUpperCase();



  if(only) only = [only].flatten();



  var elements = [];



  $A(element.childNodes).each( function(e) {



    if(e.tagName && e.tagName.toUpperCase()==tagName &&



      (!only || (Element.classNames(e).detect(function(v) { return only.include(v) }))))



        elements.push(e);



    if(recursive) {



      var grandchildren = Element.findChildren(e, only, recursive, tagName);



      if(grandchildren) elements.push(grandchildren);



    }



  });







  return (elements.length>0 ? elements.flatten() : []);



};







Element.offsetSize = function (element, type) {



  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];



};



// script.aculo.us controls.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008







// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)



//           (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)



//           (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)



// Contributors:



//  Richard Livsey



//  Rahul Bhargava



//  Rob Wills



//



// script.aculo.us is freely distributable under the terms of an MIT-style license.



// For details, see the script.aculo.us web site: http://script.aculo.us/







// Autocompleter.Base handles all the autocompletion functionality



// that's independent of the data source for autocompletion. This



// includes drawing the autocompletion menu, observing keyboard



// and mouse events, and similar.



//



// Specific autocompleters need to provide, at the very least,



// a getUpdatedChoices function that will be invoked every time



// the text inside the monitored textbox changes. This method



// should get the text for which to provide autocompletion by



// invoking this.getToken(), NOT by directly accessing



// this.element.value. This is to allow incremental tokenized



// autocompletion. Specific auto-completion logic (AJAX, etc)



// belongs in getUpdatedChoices.



//



// Tokenized incremental autocompletion is enabled automatically



// when an autocompleter is instantiated with the 'tokens' option



// in the options parameter, e.g.:



// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' });



// will incrementally autocomplete with a comma as the token.



// Additionally, ',' in the above example can be replaced with



// a token array, e.g. { tokens: [',', '\n'] } which



// enables autocompletion on multiple tokens. This is most



// useful when one of the tokens is \n (a newline), as it



// allows smart autocompletion after linebreaks.







if(typeof Effect == 'undefined')



  throw("controls.js requires including script.aculo.us' effects.js library");







var Autocompleter = { };



Autocompleter.Base = Class.create({



  baseInitialize: function(element, update, options) {



    element          = $(element);



    this.element     = element;



    this.update      = $(update);



    this.hasFocus    = false;



    this.changed     = false;



    this.active      = false;



    this.index       = 0;



    this.entryCount  = 0;



    this.oldElementValue = this.element.value;







    if(this.setOptions)



      this.setOptions(options);



    else



      this.options = options || { };







    this.options.paramName    = this.options.paramName || this.element.name;



    this.options.tokens       = this.options.tokens || [];



    this.options.frequency    = this.options.frequency || 0.4;



    this.options.minChars     = this.options.minChars || 1;



    this.options.onShow       = this.options.onShow ||



      function(element, update){



        if(!update.style.position || update.style.position=='absolute') {



          update.style.position = 'absolute';



          Position.clone(element, update, {



            setHeight: false,



            offsetTop: element.offsetHeight



          });



        }



        Effect.Appear(update,{duration:0.15});



      };



    this.options.onHide = this.options.onHide ||



      function(element, update){ new Effect.Fade(update,{duration:0.15}) };







    if(typeof(this.options.tokens) == 'string')



      this.options.tokens = new Array(this.options.tokens);



    // Force carriage returns as token delimiters anyway



    if (!this.options.tokens.include('\n'))



      this.options.tokens.push('\n');







    this.observer = null;







    this.element.setAttribute('autocomplete','off');







    Element.hide(this.update);







    Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));



    Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));



  },







  show: function() {



    if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);



    if(!this.iefix &&



      (Prototype.Browser.IE) &&



      (Element.getStyle(this.update, 'position')=='absolute')) {



      new Insertion.After(this.update,



       '<iframe id="' + this.update.id + '_iefix" '+



       'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' +



       'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');



      this.iefix = $(this.update.id+'_iefix');



    }



    if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);



  },







  fixIEOverlapping: function() {



    Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});



    this.iefix.style.zIndex = 1;



    this.update.style.zIndex = 2;



    Element.show(this.iefix);



  },







  hide: function() {



    this.stopIndicator();



    if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);



    if(this.iefix) Element.hide(this.iefix);



  },







  startIndicator: function() {



    if(this.options.indicator) Element.show(this.options.indicator);



  },







  stopIndicator: function() {



    if(this.options.indicator) Element.hide(this.options.indicator);



  },







  onKeyPress: function(event) {



    if(this.active)



      switch(event.keyCode) {



       case Event.KEY_TAB:



       case Event.KEY_RETURN:



         this.selectEntry();



         Event.stop(event);



       case Event.KEY_ESC:



         this.hide();



         this.active = false;



         Event.stop(event);



         return;



       case Event.KEY_LEFT:



       case Event.KEY_RIGHT:



         return;



       case Event.KEY_UP:



         this.markPrevious();



         this.render();



         Event.stop(event);



         return;



       case Event.KEY_DOWN:



         this.markNext();



         this.render();



         Event.stop(event);



         return;



      }



     else



       if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||



         (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;







    this.changed = true;



    this.hasFocus = true;







    if(this.observer) clearTimeout(this.observer);



      this.observer =



        setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);



  },







  activate: function() {



    this.changed = false;



    this.hasFocus = true;



    this.getUpdatedChoices();



  },







  onHover: function(event) {



    var element = Event.findElement(event, 'LI');



    if(this.index != element.autocompleteIndex)



    {



        this.index = element.autocompleteIndex;



        this.render();



    }



    Event.stop(event);



  },







  onClick: function(event) {



    var element = Event.findElement(event, 'LI');



    this.index = element.autocompleteIndex;



    this.selectEntry();



    this.hide();



  },







  onBlur: function(event) {



    // needed to make click events working



    setTimeout(this.hide.bind(this), 250);



    this.hasFocus = false;



    this.active = false;



  },







  render: function() {



    if(this.entryCount > 0) {



      for (var i = 0; i < this.entryCount; i++)



        this.index==i ?



          Element.addClassName(this.getEntry(i),"selected") :



          Element.removeClassName(this.getEntry(i),"selected");



      if(this.hasFocus) {



        this.show();



        this.active = true;



      }



    } else {



      this.active = false;



      this.hide();



    }



  },







  markPrevious: function() {



    if(this.index > 0) this.index--;



      else this.index = this.entryCount-1;



    //this.getEntry(this.index).scrollIntoView(true); useless



  },







  markNext: function() {



    if(this.index < this.entryCount-1) this.index++;



      else this.index = 0;



    this.getEntry(this.index).scrollIntoView(false);



  },







  getEntry: function(index) {



    return this.update.firstChild.childNodes[index];



  },







  getCurrentEntry: function() {



    return this.getEntry(this.index);



  },







  selectEntry: function() {



    this.active = false;



    this.updateElement(this.getCurrentEntry());



  },







  updateElement: function(selectedElement) {



    if (this.options.updateElement) {



      this.options.updateElement(selectedElement);



      return;



    }



    var value = '';



    if (this.options.select) {



      var nodes = $(selectedElement).select('.' + this.options.select) || [];



      if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);



    } else



      value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');







    var bounds = this.getTokenBounds();



    if (bounds[0] != -1) {



      var newValue = this.element.value.substr(0, bounds[0]);



      var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);



      if (whitespace)



        newValue += whitespace[0];



      this.element.value = newValue + value + this.element.value.substr(bounds[1]);



    } else {



      this.element.value = value;



    }



    this.oldElementValue = this.element.value;



    this.element.focus();







    if (this.options.afterUpdateElement)



      this.options.afterUpdateElement(this.element, selectedElement);



  },







  updateChoices: function(choices) {



    if(!this.changed && this.hasFocus) {



      this.update.innerHTML = choices;



      Element.cleanWhitespace(this.update);



      Element.cleanWhitespace(this.update.down());







      if(this.update.firstChild && this.update.down().childNodes) {



        this.entryCount =



          this.update.down().childNodes.length;



        for (var i = 0; i < this.entryCount; i++) {



          var entry = this.getEntry(i);



          entry.autocompleteIndex = i;



          this.addObservers(entry);



        }



      } else {



        this.entryCount = 0;



      }







      this.stopIndicator();



      this.index = 0;







      if(this.entryCount==1 && this.options.autoSelect) {



        this.selectEntry();



        this.hide();



      } else {



        this.render();



      }



    }



  },







  addObservers: function(element) {



    Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));



    Event.observe(element, "click", this.onClick.bindAsEventListener(this));



  },







  onObserverEvent: function() {



    this.changed = false;



    this.tokenBounds = null;



    if(this.getToken().length>=this.options.minChars) {



      this.getUpdatedChoices();



    } else {



      this.active = false;



      this.hide();



    }



    this.oldElementValue = this.element.value;



  },







  getToken: function() {



    var bounds = this.getTokenBounds();



    return this.element.value.substring(bounds[0], bounds[1]).strip();



  },







  getTokenBounds: function() {



    if (null != this.tokenBounds) return this.tokenBounds;



    var value = this.element.value;



    if (value.strip().empty()) return [-1, 0];



    var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);



    var offset = (diff == this.oldElementValue.length ? 1 : 0);



    var prevTokenPos = -1, nextTokenPos = value.length;



    var tp;



    for (var index = 0, l = this.options.tokens.length; index < l; ++index) {



      tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);



      if (tp > prevTokenPos) prevTokenPos = tp;



      tp = value.indexOf(this.options.tokens[index], diff + offset);



      if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;



    }



    return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);



  }



});







Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {



  var boundary = Math.min(newS.length, oldS.length);



  for (var index = 0; index < boundary; ++index)



    if (newS[index] != oldS[index])



      return index;



  return boundary;



};







Ajax.Autocompleter = Class.create(Autocompleter.Base, {



  initialize: function(element, update, url, options) {



    this.baseInitialize(element, update, options);



    this.options.asynchronous  = true;



    this.options.onComplete    = this.onComplete.bind(this);



    this.options.defaultParams = this.options.parameters || null;



    this.url                   = url;



  },







  getUpdatedChoices: function() {



    this.startIndicator();







    var entry = encodeURIComponent(this.options.paramName) + '=' +



      encodeURIComponent(this.getToken());







    this.options.parameters = this.options.callback ?



      this.options.callback(this.element, entry) : entry;







    if(this.options.defaultParams)



      this.options.parameters += '&' + this.options.defaultParams;







    new Ajax.Request(this.url, this.options);



  },







  onComplete: function(request) {



    this.updateChoices(request.responseText);



  }



});







// The local array autocompleter. Used when you'd prefer to



// inject an array of autocompletion options into the page, rather



// than sending out Ajax queries, which can be quite slow sometimes.



//



// The constructor takes four parameters. The first two are, as usual,



// the id of the monitored textbox, and id of the autocompletion menu.



// The third is the array you want to autocomplete from, and the fourth



// is the options block.



//



// Extra local autocompletion options:



// - choices - How many autocompletion choices to offer



//



// - partialSearch - If false, the autocompleter will match entered



//                    text only at the beginning of strings in the



//                    autocomplete array. Defaults to true, which will



//                    match text at the beginning of any *word* in the



//                    strings in the autocomplete array. If you want to



//                    search anywhere in the string, additionally set



//                    the option fullSearch to true (default: off).



//



// - fullSsearch - Search anywhere in autocomplete array strings.



//



// - partialChars - How many characters to enter before triggering



//                   a partial match (unlike minChars, which defines



//                   how many characters are required to do any match



//                   at all). Defaults to 2.



//



// - ignoreCase - Whether to ignore case when autocompleting.



//                 Defaults to true.



//



// It's possible to pass in a custom function as the 'selector'



// option, if you prefer to write your own autocompletion logic.



// In that case, the other options above will not apply unless



// you support them.







Autocompleter.Local = Class.create(Autocompleter.Base, {



  initialize: function(element, update, array, options) {



    this.baseInitialize(element, update, options);



    this.options.array = array;



  },







  getUpdatedChoices: function() {



    this.updateChoices(this.options.selector(this));



  },







  setOptions: function(options) {



    this.options = Object.extend({



      choices: 10,



      partialSearch: true,



      partialChars: 2,



      ignoreCase: true,



      fullSearch: false,



      selector: function(instance) {



        var ret       = []; // Beginning matches



        var partial   = []; // Inside matches



        var entry     = instance.getToken();



        var count     = 0;







        for (var i = 0; i < instance.options.array.length &&



          ret.length < instance.options.choices ; i++) {







          var elem = instance.options.array[i];



          var foundPos = instance.options.ignoreCase ?



            elem.toLowerCase().indexOf(entry.toLowerCase()) :



            elem.indexOf(entry);







          while (foundPos != -1) {



            if (foundPos == 0 && elem.length != entry.length) {



              ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" +



                elem.substr(entry.length) + "</li>");



              break;



            } else if (entry.length >= instance.options.partialChars &&



              instance.options.partialSearch && foundPos != -1) {



              if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {



                partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" +



                  elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(



                  foundPos + entry.length) + "</li>");



                break;



              }



            }







            foundPos = instance.options.ignoreCase ?



              elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :



              elem.indexOf(entry, foundPos + 1);







          }



        }



        if (partial.length)



          ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));



        return "<ul>" + ret.join('') + "</ul>";



      }



    }, options || { });



  }



});







// AJAX in-place editor and collection editor



// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).







// Use this if you notice weird scrolling problems on some browsers,



// the DOM might be a bit confused when this gets called so do this



// waits 1 ms (with setTimeout) until it does the activation



Field.scrollFreeActivate = function(field) {



  setTimeout(function() {



    Field.activate(field);



  }, 1);



};







Ajax.InPlaceEditor = Class.create({



  initialize: function(element, url, options) {



    this.url = url;



    this.element = element = $(element);



    this.prepareOptions();



    this._controls = { };



    arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!



    Object.extend(this.options, options || { });



    if (!this.options.formId && this.element.id) {



      this.options.formId = this.element.id + '-inplaceeditor';



      if ($(this.options.formId))



        this.options.formId = '';



    }



    if (this.options.externalControl)



      this.options.externalControl = $(this.options.externalControl);



    if (!this.options.externalControl)



      this.options.externalControlOnly = false;



    this._originalBackground = this.element.getStyle('background-color') || 'transparent';



    this.element.title = this.options.clickToEditText;



    this._boundCancelHandler = this.handleFormCancellation.bind(this);



    this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);



    this._boundFailureHandler = this.handleAJAXFailure.bind(this);



    this._boundSubmitHandler = this.handleFormSubmission.bind(this);



    this._boundWrapperHandler = this.wrapUp.bind(this);



    this.registerListeners();



  },



  checkForEscapeOrReturn: function(e) {



    if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;



    if (Event.KEY_ESC == e.keyCode)



      this.handleFormCancellation(e);



    else if (Event.KEY_RETURN == e.keyCode)



      this.handleFormSubmission(e);



  },



  createControl: function(mode, handler, extraClasses) {



    var control = this.options[mode + 'Control'];



    var text = this.options[mode + 'Text'];



    if ('button' == control) {



      var btn = document.createElement('input');



      btn.type = 'submit';



      btn.value = text;



      btn.className = 'editor_' + mode + '_button';



      if ('cancel' == mode)



        btn.onclick = this._boundCancelHandler;



      this._form.appendChild(btn);



      this._controls[mode] = btn;



    } else if ('link' == control) {



      var link = document.createElement('a');



      link.href = '#';



      link.appendChild(document.createTextNode(text));



      link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;



      link.className = 'editor_' + mode + '_link';



      if (extraClasses)



        link.className += ' ' + extraClasses;



      this._form.appendChild(link);



      this._controls[mode] = link;



    }



  },



  createEditField: function() {



    var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());



    var fld;



    if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {



      fld = document.createElement('input');



      fld.type = 'text';



      var size = this.options.size || this.options.cols || 0;



      if (0 < size) fld.size = size;



    } else {



      fld = document.createElement('textarea');



      fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);



      fld.cols = this.options.cols || 40;



    }



    fld.name = this.options.paramName;



    fld.value = text; // No HTML breaks conversion anymore



    fld.className = 'editor_field';



    if (this.options.submitOnBlur)



      fld.onblur = this._boundSubmitHandler;



    this._controls.editor = fld;



    if (this.options.loadTextURL)



      this.loadExternalText();



    this._form.appendChild(this._controls.editor);



  },



  createForm: function() {



    var ipe = this;



    function addText(mode, condition) {



      var text = ipe.options['text' + mode + 'Controls'];



      if (!text || condition === false) return;



      ipe._form.appendChild(document.createTextNode(text));



    };



    this._form = $(document.createElement('form'));



    this._form.id = this.options.formId;



    this._form.addClassName(this.options.formClassName);



    this._form.onsubmit = this._boundSubmitHandler;



    this.createEditField();



    if ('textarea' == this._controls.editor.tagName.toLowerCase())



      this._form.appendChild(document.createElement('br'));



    if (this.options.onFormCustomization)



      this.options.onFormCustomization(this, this._form);



    addText('Before', this.options.okControl || this.options.cancelControl);



    this.createControl('ok', this._boundSubmitHandler);



    addText('Between', this.options.okControl && this.options.cancelControl);



    this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');



    addText('After', this.options.okControl || this.options.cancelControl);



  },



  destroy: function() {



    if (this._oldInnerHTML)



      this.element.innerHTML = this._oldInnerHTML;



    this.leaveEditMode();



    this.unregisterListeners();



  },



  enterEditMode: function(e) {



    if (this._saving || this._editing) return;



    this._editing = true;



    this.triggerCallback('onEnterEditMode');



    if (this.options.externalControl)



      this.options.externalControl.hide();



    this.element.hide();



    this.createForm();



    this.element.parentNode.insertBefore(this._form, this.element);



    if (!this.options.loadTextURL)



      this.postProcessEditField();



    if (e) Event.stop(e);



  },



  enterHover: function(e) {



    if (this.options.hoverClassName)



      this.element.addClassName(this.options.hoverClassName);



    if (this._saving) return;



    this.triggerCallback('onEnterHover');



  },



  getText: function() {



    return this.element.innerHTML.unescapeHTML();



  },



  handleAJAXFailure: function(transport) {



    this.triggerCallback('onFailure', transport);



    if (this._oldInnerHTML) {



      this.element.innerHTML = this._oldInnerHTML;



      this._oldInnerHTML = null;



    }



  },



  handleFormCancellation: function(e) {



    this.wrapUp();



    if (e) Event.stop(e);



  },



  handleFormSubmission: function(e) {



    var form = this._form;



    var value = $F(this._controls.editor);



    this.prepareSubmission();



    var params = this.options.callback(form, value) || '';



    if (Object.isString(params))



      params = params.toQueryParams();



    params.editorId = this.element.id;



    if (this.options.htmlResponse) {



      var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);



      Object.extend(options, {



        parameters: params,



        onComplete: this._boundWrapperHandler,



        onFailure: this._boundFailureHandler



      });



      new Ajax.Updater({ success: this.element }, this.url, options);



    } else {



      var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);



      Object.extend(options, {



        parameters: params,



        onComplete: this._boundWrapperHandler,



        onFailure: this._boundFailureHandler



      });



      new Ajax.Request(this.url, options);



    }



    if (e) Event.stop(e);



  },



  leaveEditMode: function() {



    this.element.removeClassName(this.options.savingClassName);



    this.removeForm();



    this.leaveHover();



    this.element.style.backgroundColor = this._originalBackground;



    this.element.show();



    if (this.options.externalControl)



      this.options.externalControl.show();



    this._saving = false;



    this._editing = false;



    this._oldInnerHTML = null;



    this.triggerCallback('onLeaveEditMode');



  },



  leaveHover: function(e) {



    if (this.options.hoverClassName)



      this.element.removeClassName(this.options.hoverClassName);



    if (this._saving) return;



    this.triggerCallback('onLeaveHover');



  },



  loadExternalText: function() {



    this._form.addClassName(this.options.loadingClassName);



    this._controls.editor.disabled = true;



    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);



    Object.extend(options, {



      parameters: 'editorId=' + encodeURIComponent(this.element.id),



      onComplete: Prototype.emptyFunction,



      onSuccess: function(transport) {



        this._form.removeClassName(this.options.loadingClassName);



        var text = transport.responseText;



        if (this.options.stripLoadedTextTags)



          text = text.stripTags();



        this._controls.editor.value = text;



        this._controls.editor.disabled = false;



        this.postProcessEditField();



      }.bind(this),



      onFailure: this._boundFailureHandler



    });



    new Ajax.Request(this.options.loadTextURL, options);



  },



  postProcessEditField: function() {



    var fpc = this.options.fieldPostCreation;



    if (fpc)



      $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();



  },



  prepareOptions: function() {



    this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);



    Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);



    [this._extraDefaultOptions].flatten().compact().each(function(defs) {



      Object.extend(this.options, defs);



    }.bind(this));



  },



  prepareSubmission: function() {



    this._saving = true;



    this.removeForm();



    this.leaveHover();



    this.showSaving();



  },



  registerListeners: function() {



    this._listeners = { };



    var listener;



    $H(Ajax.InPlaceEditor.Listeners).each(function(pair) {



      listener = this[pair.value].bind(this);



      this._listeners[pair.key] = listener;



      if (!this.options.externalControlOnly)



        this.element.observe(pair.key, listener);



      if (this.options.externalControl)



        this.options.externalControl.observe(pair.key, listener);



    }.bind(this));



  },



  removeForm: function() {



    if (!this._form) return;



    this._form.remove();



    this._form = null;



    this._controls = { };



  },



  showSaving: function() {



    this._oldInnerHTML = this.element.innerHTML;



    this.element.innerHTML = this.options.savingText;



    this.element.addClassName(this.options.savingClassName);



    this.element.style.backgroundColor = this._originalBackground;



    this.element.show();



  },



  triggerCallback: function(cbName, arg) {



    if ('function' == typeof this.options[cbName]) {



      this.options[cbName](this, arg);



    }



  },



  unregisterListeners: function() {



    $H(this._listeners).each(function(pair) {



      if (!this.options.externalControlOnly)



        this.element.stopObserving(pair.key, pair.value);



      if (this.options.externalControl)



        this.options.externalControl.stopObserving(pair.key, pair.value);



    }.bind(this));



  },



  wrapUp: function(transport) {



    this.leaveEditMode();



    // Can't use triggerCallback due to backward compatibility: requires



    // binding + direct element



    this._boundComplete(transport, this.element);



  }



});







Object.extend(Ajax.InPlaceEditor.prototype, {



  dispose: Ajax.InPlaceEditor.prototype.destroy



});







Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {



  initialize: function($super, element, url, options) {



    this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;



    $super(element, url, options);



  },







  createEditField: function() {



    var list = document.createElement('select');



    list.name = this.options.paramName;



    list.size = 1;



    this._controls.editor = list;



    this._collection = this.options.collection || [];



    if (this.options.loadCollectionURL)



      this.loadCollection();



    else



      this.checkForExternalText();



    this._form.appendChild(this._controls.editor);



  },







  loadCollection: function() {



    this._form.addClassName(this.options.loadingClassName);



    this.showLoadingText(this.options.loadingCollectionText);



    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);



    Object.extend(options, {



      parameters: 'editorId=' + encodeURIComponent(this.element.id),



      onComplete: Prototype.emptyFunction,



      onSuccess: function(transport) {



        var js = transport.responseText.strip();



        if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check



          throw('Server returned an invalid collection representation.');



        this._collection = eval(js);



        this.checkForExternalText();



      }.bind(this),



      onFailure: this.onFailure



    });



    new Ajax.Request(this.options.loadCollectionURL, options);



  },







  showLoadingText: function(text) {



    this._controls.editor.disabled = true;



    var tempOption = this._controls.editor.firstChild;



    if (!tempOption) {



      tempOption = document.createElement('option');



      tempOption.value = '';



      this._controls.editor.appendChild(tempOption);



      tempOption.selected = true;



    }



    tempOption.update((text || '').stripScripts().stripTags());



  },







  checkForExternalText: function() {



    this._text = this.getText();



    if (this.options.loadTextURL)



      this.loadExternalText();



    else



      this.buildOptionList();



  },







  loadExternalText: function() {



    this.showLoadingText(this.options.loadingText);



    var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);



    Object.extend(options, {



      parameters: 'editorId=' + encodeURIComponent(this.element.id),



      onComplete: Prototype.emptyFunction,



      onSuccess: function(transport) {



        this._text = transport.responseText.strip();



        this.buildOptionList();



      }.bind(this),



      onFailure: this.onFailure



    });



    new Ajax.Request(this.options.loadTextURL, options);



  },







  buildOptionList: function() {



    this._form.removeClassName(this.options.loadingClassName);



    this._collection = this._collection.map(function(entry) {



      return 2 === entry.length ? entry : [entry, entry].flatten();



    });



    var marker = ('value' in this.options) ? this.options.value : this._text;



    var textFound = this._collection.any(function(entry) {



      return entry[0] == marker;



    }.bind(this));



    this._controls.editor.update('');



    var option;



    this._collection.each(function(entry, index) {



      option = document.createElement('option');



      option.value = entry[0];



      option.selected = textFound ? entry[0] == marker : 0 == index;



      option.appendChild(document.createTextNode(entry[1]));



      this._controls.editor.appendChild(option);



    }.bind(this));



    this._controls.editor.disabled = false;



    Field.scrollFreeActivate(this._controls.editor);



  }



});







//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****



//**** This only  exists for a while,  in order to  let ****



//**** users adapt to  the new API.  Read up on the new ****



//**** API and convert your code to it ASAP!            ****







Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {



  if (!options) return;



  function fallback(name, expr) {



    if (name in options || expr === undefined) return;



    options[name] = expr;



  };



  fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :



    options.cancelLink == options.cancelButton == false ? false : undefined)));



  fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :



    options.okLink == options.okButton == false ? false : undefined)));



  fallback('highlightColor', options.highlightcolor);



  fallback('highlightEndColor', options.highlightendcolor);



};







Object.extend(Ajax.InPlaceEditor, {



  DefaultOptions: {



    ajaxOptions: { },



    autoRows: 3,                                // Use when multi-line w/ rows == 1



    cancelControl: 'link',                      // 'link'|'button'|false



    cancelText: 'cancel',



    clickToEditText: 'Click to edit',



    externalControl: null,                      // id|elt



    externalControlOnly: false,



    fieldPostCreation: 'activate',              // 'activate'|'focus'|false



    formClassName: 'inplaceeditor-form',



    formId: null,                               // id|elt



    highlightColor: '#ffff99',



    highlightEndColor: '#ffffff',



    hoverClassName: '',



    htmlResponse: true,



    loadingClassName: 'inplaceeditor-loading',



    loadingText: 'Loading...',



    okControl: 'button',                        // 'link'|'button'|false



    okText: 'ok',



    paramName: 'value',



    rows: 1,                                    // If 1 and multi-line, uses autoRows



    savingClassName: 'inplaceeditor-saving',



    savingText: 'Saving...',



    size: 0,



    stripLoadedTextTags: false,



    submitOnBlur: false,



    textAfterControls: '',



    textBeforeControls: '',



    textBetweenControls: ''



  },



  DefaultCallbacks: {



    callback: function(form) {



      return Form.serialize(form);



    },



    onComplete: function(transport, element) {



      // For backward compatibility, this one is bound to the IPE, and passes



      // the element directly.  It was too often customized, so we don't break it.



      new Effect.Highlight(element, {



        startcolor: this.options.highlightColor, keepBackgroundImage: true });



    },



    onEnterEditMode: null,



    onEnterHover: function(ipe) {



      ipe.element.style.backgroundColor = ipe.options.highlightColor;



      if (ipe._effect)



        ipe._effect.cancel();



    },



    onFailure: function(transport, ipe) {



      alert('Error communication with the server: ' + transport.responseText.stripTags());



    },



    onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.



    onLeaveEditMode: null,



    onLeaveHover: function(ipe) {



      ipe._effect = new Effect.Highlight(ipe.element, {



        startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,



        restorecolor: ipe._originalBackground, keepBackgroundImage: true



      });



    }



  },



  Listeners: {



    click: 'enterEditMode',



    keydown: 'checkForEscapeOrReturn',



    mouseover: 'enterHover',



    mouseout: 'leaveHover'



  }



});







Ajax.InPlaceCollectionEditor.DefaultOptions = {



  loadingCollectionText: 'Loading options...'



};







// Delayed observer, like Form.Element.Observer,



// but waits for delay after last key input



// Ideal for live-search fields







Form.Element.DelayedObserver = Class.create({



  initialize: function(element, delay, callback) {



    this.delay     = delay || 0.5;



    this.element   = $(element);



    this.callback  = callback;



    this.timer     = null;



    this.lastValue = $F(this.element);



    Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));



  },



  delayedListener: function(event) {



    if(this.lastValue == $F(this.element)) return;



    if(this.timer) clearTimeout(this.timer);



    this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);



    this.lastValue = $F(this.element);



  },



  onTimerEvent: function() {



    this.timer = null;



    this.callback(this.element, $F(this.element));



  }



});



// script.aculo.us slider.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008







// Copyright (c) 2005-2008 Marty Haught, Thomas Fuchs



//



// script.aculo.us is freely distributable under the terms of an MIT-style license.



// For details, see the script.aculo.us web site: http://script.aculo.us/







if (!Control) var Control = { };







// options:



//  axis: 'vertical', or 'horizontal' (default)



//



// callbacks:



//  onChange(value)



//  onSlide(value)



Control.Slider = Class.create({



  initialize: function(handle, track, options) {



    var slider = this;







    if (Object.isArray(handle)) {



      this.handles = handle.collect( function(e) { return $(e) });



    } else {



      this.handles = [$(handle)];



    }







    this.track   = $(track);



    this.options = options || { };







    this.axis      = this.options.axis || 'horizontal';



    this.increment = this.options.increment || 1;



    this.step      = parseInt(this.options.step || '1');



    this.range     = this.options.range || $R(0,1);







    this.value     = 0; // assure backwards compat



    this.values    = this.handles.map( function() { return 0 });



    this.spans     = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;



    this.options.startSpan = $(this.options.startSpan || null);



    this.options.endSpan   = $(this.options.endSpan || null);







    this.restricted = this.options.restricted || false;







    this.maximum   = this.options.maximum || this.range.end;



    this.minimum   = this.options.minimum || this.range.start;







    // Will be used to align the handle onto the track, if necessary



    this.alignX = parseInt(this.options.alignX || '0');



    this.alignY = parseInt(this.options.alignY || '0');







    this.trackLength = this.maximumOffset() - this.minimumOffset();







    this.handleLength = this.isVertical() ?



      (this.handles[0].offsetHeight != 0 ?



        this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :



      (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :



        this.handles[0].style.width.replace(/px$/,""));







    this.active   = false;



    this.dragging = false;



    this.disabled = false;







    if (this.options.disabled) this.setDisabled();







    // Allowed values array



    this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;



    if (this.allowedValues) {



      this.minimum = this.allowedValues.min();



      this.maximum = this.allowedValues.max();



    }







    this.eventMouseDown = this.startDrag.bindAsEventListener(this);



    this.eventMouseUp   = this.endDrag.bindAsEventListener(this);



    this.eventMouseMove = this.update.bindAsEventListener(this);







    // Initialize handles in reverse (make sure first handle is active)



    this.handles.each( function(h,i) {



      i = slider.handles.length-1-i;



      slider.setValue(parseFloat(



        (Object.isArray(slider.options.sliderValue) ?



          slider.options.sliderValue[i] : slider.options.sliderValue) ||



         slider.range.start), i);



      h.makePositioned().observe("mousedown", slider.eventMouseDown);



    });







    this.track.observe("mousedown", this.eventMouseDown);



    document.observe("mouseup", this.eventMouseUp);



    $(this.track.parentNode.parentNode).observe("mousemove", this.eventMouseMove);











    this.initialized = true;



  },



  dispose: function() {



    var slider = this;



    Event.stopObserving(this.track, "mousedown", this.eventMouseDown);



    Event.stopObserving(document, "mouseup", this.eventMouseUp);



    Event.stopObserving(this.track.parentNode.parentNode, "mousemove", this.eventMouseMove);



    this.handles.each( function(h) {



      Event.stopObserving(h, "mousedown", slider.eventMouseDown);



    });



  },



  setDisabled: function(){



    this.disabled = true;



    this.track.parentNode.className = this.track.parentNode.className + ' disabled';



  },



  setEnabled: function(){



    this.disabled = false;



  },



  getNearestValue: function(value){



    if (this.allowedValues){



      if (value >= this.allowedValues.max()) return(this.allowedValues.max());



      if (value <= this.allowedValues.min()) return(this.allowedValues.min());







      var offset = Math.abs(this.allowedValues[0] - value);



      var newValue = this.allowedValues[0];



      this.allowedValues.each( function(v) {



        var currentOffset = Math.abs(v - value);



        if (currentOffset <= offset){



          newValue = v;



          offset = currentOffset;



        }



      });



      return newValue;



    }



    if (value > this.range.end) return this.range.end;



    if (value < this.range.start) return this.range.start;



    return value;



  },



  setValue: function(sliderValue, handleIdx){



    if (!this.active) {



      this.activeHandleIdx = handleIdx || 0;



      this.activeHandle    = this.handles[this.activeHandleIdx];



      this.updateStyles();



    }



    handleIdx = handleIdx || this.activeHandleIdx || 0;



    if (this.initialized && this.restricted) {



      if ((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))



        sliderValue = this.values[handleIdx-1];



      if ((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))



        sliderValue = this.values[handleIdx+1];



    }



    sliderValue = this.getNearestValue(sliderValue);



    this.values[handleIdx] = sliderValue;



    this.value = this.values[0]; // assure backwards compat







    this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =



      this.translateToPx(sliderValue);







    this.drawSpans();



    if (!this.dragging || !this.event) this.updateFinished();



  },



  setValueBy: function(delta, handleIdx) {



    this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,



      handleIdx || this.activeHandleIdx || 0);



  },



  translateToPx: function(value) {



    return Math.round(



      ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *



      (value - this.range.start)) + "px";



  },



  translateToValue: function(offset) {



    return ((offset/(this.trackLength-this.handleLength) *



      (this.range.end-this.range.start)) + this.range.start);



  },



  getRange: function(range) {



    var v = this.values.sortBy(Prototype.K);



    range = range || 0;



    return $R(v[range],v[range+1]);



  },



  minimumOffset: function(){



    return(this.isVertical() ? this.alignY : this.alignX);



  },



  maximumOffset: function(){



    return(this.isVertical() ?



      (this.track.offsetHeight != 0 ? this.track.offsetHeight :



        this.track.style.height.replace(/px$/,"")) - this.alignY :



      (this.track.offsetWidth != 0 ? this.track.offsetWidth :



        this.track.style.width.replace(/px$/,"")) - this.alignX);



  },



  isVertical:  function(){



    return (this.axis == 'vertical');



  },



  drawSpans: function() {



    var slider = this;



    if (this.spans)



      $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });



    if (this.options.startSpan)



      this.setSpan(this.options.startSpan,



        $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));



    if (this.options.endSpan)



      this.setSpan(this.options.endSpan,



        $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));



  },



  setSpan: function(span, range) {



    if (this.isVertical()) {



      span.style.top = this.translateToPx(range.start);



      span.style.height = this.translateToPx(range.end - range.start + this.range.start);



    } else {



      span.style.left = this.translateToPx(range.start);



      span.style.width = this.translateToPx(range.end - range.start + this.range.start);



    }



  },



  updateStyles: function() {



    this.handles.each( function(h){ Element.removeClassName(h, 'selected') });



    Element.addClassName(this.activeHandle, 'selected');



  },



  startDrag: function(event) {



    if (Event.isLeftClick(event)) {



      if (!this.disabled){



        this.active = true;







        var handle = Event.element(event);



        var pointer  = [Event.pointerX(event), Event.pointerY(event)];



        var track = handle;



        if (track==this.track) {



          var offsets  = Position.cumulativeOffset(this.track);



          this.event = event;



          this.setValue(this.translateToValue(



           (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)



          ));



          var offsets  = Position.cumulativeOffset(this.activeHandle);



          this.offsetX = (pointer[0] - offsets[0]);



          this.offsetY = (pointer[1] - offsets[1]);



        } else {



          // find the handle (prevents issues with Safari)



          while((this.handles.indexOf(handle) == -1) && handle.parentNode)



            handle = handle.parentNode;







          if (this.handles.indexOf(handle)!=-1) {



            this.activeHandle    = handle;



            this.activeHandleIdx = this.handles.indexOf(this.activeHandle);



            this.updateStyles();







            var offsets  = Position.cumulativeOffset(this.activeHandle);



            this.offsetX = (pointer[0] - offsets[0]);



            this.offsetY = (pointer[1] - offsets[1]);



          }



        }



      }



      Event.stop(event);



    }



  },



  update: function(event) {



   if (this.active) {



      if (!this.dragging) this.dragging = true;



      this.draw(event);



      if (Prototype.Browser.WebKit) window.scrollBy(0,0);



      Event.stop(event);



   }



  },



  draw: function(event) {



    var pointer = [Event.pointerX(event), Event.pointerY(event)];



    var offsets = Position.cumulativeOffset(this.track);



    pointer[0] -= this.offsetX + offsets[0];



    pointer[1] -= this.offsetY + offsets[1];



    this.event = event;



    this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));



    if (this.initialized && this.options.onSlide)



      this.options.onSlide(this.values.length>1 ? this.values : this.value, this);



  },



  endDrag: function(event) {



    if (this.active && this.dragging) {



      this.finishDrag(event, true);



      Event.stop(event);



    }



    this.active = false;



    this.dragging = false;



  },



  finishDrag: function(event, success) {



    this.active = false;



    this.dragging = false;



    this.updateFinished();



  },



  updateFinished: function() {



    if (this.initialized && this.options.onChange)



      this.options.onChange(this.values.length>1 ? this.values : this.value, this);



    this.event = null;



  }



});



/**



 * Magento



 *



 * NOTICE OF LICENSE



 *



 * This source file is subject to the Academic Free License (AFL 3.0)



 * that is bundled with this package in the file LICENSE_AFL.txt.



 * It is also available through the world-wide-web at this URL:



 * http://opensource.org/licenses/afl-3.0.php



 * If you did not receive a copy of the license and are unable to



 * obtain it through the world-wide-web, please send an email



 * to license@magentocommerce.com so we can send you a copy immediately.



 *



 * DISCLAIMER



 *



 * Do not edit or add to this file if you wish to upgrade Magento to newer



 * versions in the future. If you wish to customize Magento for your



 * needs please refer to http://www.magentocommerce.com for more information.



 *



 * @category    Varien



 * @package     js



 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)



 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)



 */



function popWin(url,win,para) {



    var win = window.open(url,win,para);



    win.focus();



}







function setLocation(url){



    window.location.href = url;



}







function setPLocation(url, setFocus){



    if( setFocus ) {



        window.opener.focus();



    }



    window.opener.location.href = url;



}







function setLanguageCode(code, fromCode){



    //TODO: javascript cookies have different domain and path than php cookies



    var href = window.location.href;



    var after = '', dash;



    if (dash = href.match(/\#(.*)$/)) {



        href = href.replace(/\#(.*)$/, '');



        after = dash[0];



    }







    if (href.match(/[?]/)) {



        var re = /([?&]store=)[a-z0-9_]*/;



        if (href.match(re)) {



            href = href.replace(re, '$1'+code);



        } else {



            href += '&store='+code;



        }







        var re = /([?&]from_store=)[a-z0-9_]*/;



        if (href.match(re)) {



            href = href.replace(re, '');



        }



    } else {



        href += '?store='+code;



    }



    if (typeof(fromCode) != 'undefined') {



        href += '&from_store='+fromCode;



    }



    href += after;







    setLocation(href);



}







/**



 * Add classes to specified elements.



 * Supported classes are: 'odd', 'even', 'first', 'last'



 *



 * @param elements - array of elements to be decorated



 * [@param decorateParams] - array of classes to be set. If omitted, all available will be used



 */



function decorateGeneric(elements, decorateParams)



{



    var allSupportedParams = ['odd', 'even', 'first', 'last'];



    var _decorateParams = {};



    var total = elements.length;







    if (total) {



        // determine params called



        if (typeof(decorateParams) == 'undefined') {



            decorateParams = allSupportedParams;



        }



        if (!decorateParams.length) {



            return;



        }



        for (var k in allSupportedParams) {



            _decorateParams[allSupportedParams[k]] = false;



        }



        for (var k in decorateParams) {



            _decorateParams[decorateParams[k]] = true;



        }







        // decorate elements



        // elements[0].addClassName('first'); // will cause bug in IE (#5587)



        if (_decorateParams.first) {



            Element.addClassName(elements[0], 'first');



        }



        if (_decorateParams.last) {



            Element.addClassName(elements[total-1], 'last');



        }



        for (var i = 0; i < total; i++) {



            if ((i + 1) % 2 == 0) {



                if (_decorateParams.even) {



                    Element.addClassName(elements[i], 'even');



                }



            }



            else {



                if (_decorateParams.odd) {



                    Element.addClassName(elements[i], 'odd');



                }



            }



        }



    }



}







/**



 * Decorate table rows and cells, tbody etc



 * @see decorateGeneric()



 */



function decorateTable(table, options) {



    var table = $(table);



    if (table) {



        // set default options



        var _options = {



            'tbody'    : false,



            'tbody tr' : ['odd', 'even', 'first', 'last'],



            'thead tr' : ['first', 'last'],



            'tfoot tr' : ['first', 'last'],



            'tr td'    : ['last']



        };



        // overload options



        if (typeof(options) != 'undefined') {



            for (var k in options) {



                _options[k] = options[k];



            }



        }



        // decorate



        if (_options['tbody']) {



            decorateGeneric(table.select('tbody'), _options['tbody']);



        }



        if (_options['tbody tr']) {



            decorateGeneric(table.select('tbody tr'), _options['tbody tr']);



        }



        if (_options['thead tr']) {



            decorateGeneric(table.select('thead tr'), _options['thead tr']);



        }



        if (_options['tfoot tr']) {



            decorateGeneric(table.select('tfoot tr'), _options['tfoot tr']);



        }



        if (_options['tr td']) {



            var allRows = table.select('tr');



            if (allRows.length) {



                for (var i = 0; i < allRows.length; i++) {



                    decorateGeneric(allRows[i].getElementsByTagName('TD'), _options['tr td']);



                }



            }



        }



    }



}







/**



 * Set "odd", "even" and "last" CSS classes for list items



 * @see decorateGeneric()



 */



function decorateList(list, nonRecursive) {



    if ($(list)) {



        if (typeof(nonRecursive) == 'undefined') {



            var items = $(list).select('li')



        }



        else {



            var items = $(list).childElements();



        }



        decorateGeneric(items, ['odd', 'even', 'last']);



    }



}







/**



 * Set "odd", "even" and "last" CSS classes for list items



 * @see decorateGeneric()



 */



function decorateDataList(list) {



    list = $(list);



    if (list) {



        decorateGeneric(list.select('dt'), ['odd', 'even', 'last']);



        decorateGeneric(list.select('dd'), ['odd', 'even', 'last']);



    }



}







/**



 * Parse SID and produces the correct URL



 */



function parseSidUrl(baseUrl, urlExt) {



    var sidPos = baseUrl.indexOf('/?SID=');



    var sid = '';



    urlExt = (urlExt != undefined) ? urlExt : '';







    if(sidPos > -1) {



        sid = '?' + baseUrl.substring(sidPos + 2);



        baseUrl = baseUrl.substring(0, sidPos + 1);



    }







    return baseUrl+urlExt+sid;



}







/**



 * Formats currency using patern



 * format - JSON (pattern, decimal, decimalsDelimeter, groupsDelimeter)



 * showPlus - true (always show '+'or '-'),



 *      false (never show '-' even if number is negative)



 *      null (show '-' if number is negative)



 */







function formatCurrency(price, format, showPlus){



    var precision = isNaN(format.precision = Math.abs(format.precision)) ? 2 : format.precision;



    var requiredPrecision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;







    //precision = (precision > requiredPrecision) ? precision : requiredPrecision;



    //for now we don't need this difference so precision is requiredPrecision



    precision = requiredPrecision;







    var integerRequired = isNaN(format.integerRequired = Math.abs(format.integerRequired)) ? 1 : format.integerRequired;







    var decimalSymbol = format.decimalSymbol == undefined ? "," : format.decimalSymbol;



    var groupSymbol = format.groupSymbol == undefined ? "." : format.groupSymbol;



    var groupLength = format.groupLength == undefined ? 3 : format.groupLength;







    var s = '';







    if (showPlus == undefined || showPlus == true) {



        s = price < 0 ? "-" : ( showPlus ? "+" : "");



    } else if (showPlus == false) {



        s = '';



    }







    var i = parseInt(price = Math.abs(+price || 0).toFixed(precision)) + "";



    var pad = (i.length < integerRequired) ? (integerRequired - i.length) : 0;



    while (pad) { i = '0' + i; pad--; }



    j = (j = i.length) > groupLength ? j % groupLength : 0;



    re = new RegExp("(\\d{" + groupLength + "})(?=\\d)", "g");







    /**



     * replace(/-/, 0) is only for fixing Safari bug which appears



     * when Math.abs(0).toFixed() executed on "0" number.



     * Result is "0.-0" :(



     */



    var r = (j ? i.substr(0, j) + groupSymbol : "") + i.substr(j).replace(re, "$1" + groupSymbol) + (precision ? decimalSymbol + Math.abs(price - i).toFixed(precision).replace(/-/, 0).slice(2) : "")



    var pattern = '';



    if (format.pattern.indexOf('{sign}') == -1) {



        pattern = s + format.pattern;



    } else {



        pattern = format.pattern.replace('{sign}', s);



    }







    return pattern.replace('%s', r).replace(/^\s\s*/, '').replace(/\s\s*$/, '');



};







function expandDetails(el, childClass) {



    if (Element.hasClassName(el,'show-details')) {



        $$(childClass).each(function(item){item.hide()});



        Element.removeClassName(el,'show-details');



    }



    else {



        $$(childClass).each(function(item){item.show()});



        Element.addClassName(el,'show-details');



    }



}







// Version 1.0



var isIE = navigator.appVersion.match(/MSIE/) == "MSIE";







if (!window.Varien)



    var Varien = new Object();







Varien.showLoading = function(){



    var loader = $('loading-process');



    loader && loader.show();



}



Varien.hideLoading = function(){



    var loader = $('loading-process');



    loader && loader.hide();



}



Varien.GlobalHandlers = {



    onCreate: function() {



        Varien.showLoading();



    },







    onComplete: function() {



        if(Ajax.activeRequestCount == 0) {



            Varien.hideLoading();



        }



    }



};







Ajax.Responders.register(Varien.GlobalHandlers);







/**



 * Quick Search form client model



 */



Varien.searchForm = Class.create();



Varien.searchForm.prototype = {



    initialize : function(form, field, emptyText){



        this.form   = $(form);



        this.field  = $(field);



        this.emptyText = emptyText;







        Event.observe(this.form,  'submit', this.submit.bind(this));



        Event.observe(this.field, 'focus', this.focus.bind(this));



        Event.observe(this.field, 'blur', this.blur.bind(this));



        this.blur();



    },







    submit : function(event){



        if (this.field.value == this.emptyText || this.field.value == ''){



            Event.stop(event);



            return false;



        }



        return true;



    },







    focus : function(event){



        if(this.field.value==this.emptyText){



            this.field.value='';



        }







    },







    blur : function(event){



        if(this.field.value==''){



            this.field.value=this.emptyText;



        }



    },







    initAutocomplete : function(url, destinationElement){



        new Ajax.Autocompleter(



            this.field,



            destinationElement,



            url,



            {



                paramName: this.field.name,



                method: 'get',



                minChars: 2,



                updateElement: this._selectAutocompleteItem.bind(this),



                onShow : function(element, update) {



                    if(!update.style.position || update.style.position=='absolute') {



                        update.style.position = 'absolute';



                        Position.clone(element, update, {



                            setHeight: false,



                            offsetTop: element.offsetHeight



                        });



                    }



                    Effect.Appear(update,{duration:0});



                }







            }



        );



    },







    _selectAutocompleteItem : function(element){



        if(element.title){



            this.field.value = element.title;



        }



        this.form.submit();



    }



}







Varien.Tabs = Class.create();



Varien.Tabs.prototype = {



  initialize: function(selector) {



    var self=this;



    $$(selector+' a').each(this.initTab.bind(this));



  },







  initTab: function(el) {



      el.href = 'javascript:void(0)';



      if ($(el.parentNode).hasClassName('active')) {



        this.showContent(el);



      }



      el.observe('click', this.showContent.bind(this, el));



  },







  showContent: function(a) {



    var li = $(a.parentNode), ul = $(li.parentNode);



    ul.getElementsBySelector('li', 'ol').each(function(el){



      var contents = $(el.id+'_contents');



      if (el==li) {



        el.addClassName('active');



        contents.show();



      } else {



        el.removeClassName('active');



        contents.hide();



      }



    });



  }



}







Varien.DateElement = Class.create();



Varien.DateElement.prototype = {



    initialize: function(type, content, required, format) {



        if (type == 'id') {



            // id prefix



            this.day    = $(content + 'day');



            this.month  = $(content + 'month');



            this.year   = $(content + 'year');



            this.full   = $(content + 'full');



            this.advice = $(content + 'date-advice');



        } else if (type == 'container') {



            // content must be container with data



            this.day    = content.day;



            this.month  = content.month;



            this.year   = content.year;



            this.full   = content.full;



            this.advice = content.advice;



        } else {



            return;



        }







        this.required = required;



        this.format   = format;







        this.day.addClassName('validate-custom');



        this.day.validate = this.validate.bind(this);



        this.month.addClassName('validate-custom');



        this.month.validate = this.validate.bind(this);



        this.year.addClassName('validate-custom');



        this.year.validate = this.validate.bind(this);







        this.setDateRange(false, false);



        this.year.setAttribute('autocomplete','off');







        this.advice.hide();



    },



    validate: function() {



        var error = false,



            day   = parseInt(this.day.value, 10)   || 0,



            month = parseInt(this.month.value, 10) || 0,



            year  = parseInt(this.year.value, 10)  || 0;



        if (this.day.value.strip().empty()



            && this.month.value.strip().empty()



            && this.year.value.strip().empty()



        ) {



            if (this.required) {



                error = 'This date is a required value.';



            } else {



                this.full.value = '';



            }



        } else if (!day || !month || !year) {



            error = 'Please enter a valid full date.';



        } else {



            var date = new Date, countDaysInMonth = 0, errorType = null;



            date.setYear(year);date.setMonth(month-1);date.setDate(32);



            countDaysInMonth = 32 - date.getDate();



            if(!countDaysInMonth || countDaysInMonth>31) countDaysInMonth = 31;







            if (day<1 || day>countDaysInMonth) {



                errorType = 'day';



                error = 'Please enter a valid day (1-%d).';



            } else if (month<1 || month>12) {



                errorType = 'month';



                error = 'Please enter a valid month (1-12).';



            } else {



                if(day % 10 == day) this.day.value = '0'+day;



                if(month % 10 == month) this.month.value = '0'+month;



                this.full.value = this.format.replace(/%[mb]/i, this.month.value).replace(/%[de]/i, this.day.value).replace(/%y/i, this.year.value);



                var testFull = this.month.value + '/' + this.day.value + '/'+ this.year.value;



                var test = new Date(testFull);



                if (isNaN(test)) {



                    error = 'Please enter a valid date.';



                } else {



                    this.setFullDate(test);



                }



            }



            var valueError = false;



            if (!error && !this.validateData()){//(year<1900 || year>curyear) {



                errorType = this.validateDataErrorType;//'year';



                valueError = this.validateDataErrorText;//'Please enter a valid year (1900-%d).';



                error = valueError;



            }



        }







        if (error !== false) {



            try {



                error = Translator.translate(error);



            }



            catch (e) {}



            if (!valueError) {



                this.advice.innerHTML = error.replace('%d', countDaysInMonth);



            } else {



                this.advice.innerHTML = this.errorTextModifier(error);



            }



            this.advice.show();



            return false;



        }







        // fixing elements class



        this.day.removeClassName('validation-failed');



        this.month.removeClassName('validation-failed');



        this.year.removeClassName('validation-failed');







        this.advice.hide();



        return true;



    },



    validateData: function() {



        var year = this.fullDate.getFullYear();



        var date = new Date;



        this.curyear = date.getFullYear();



        return (year>=1900 && year<=this.curyear);



    },



    validateDataErrorType: 'year',



    validateDataErrorText: 'Please enter a valid year (1900-%d).',



    errorTextModifier: function(text) {



        return text.replace('%d', this.curyear);



    },



    setDateRange: function(minDate, maxDate) {



        this.minDate = minDate;



        this.maxDate = maxDate;



    },



    setFullDate: function(date) {



        this.fullDate = date;



    }



};







Varien.DOB = Class.create();



Varien.DOB.prototype = {



    initialize: function(selector, required, format) {



        var el = $$(selector)[0];



        var container       = {};



        container.day       = Element.select(el, '.dob-day input')[0];



        container.month     = Element.select(el, '.dob-month input')[0];



        container.year      = Element.select(el, '.dob-year input')[0];



        container.full      = Element.select(el, '.dob-full input')[0];



        container.advice    = Element.select(el, '.validation-advice')[0];







        new Varien.DateElement('container', container, required, format);



    }



};







Varien.dateRangeDate = Class.create();



Varien.dateRangeDate.prototype = Object.extend(new Varien.DateElement(), {



    validateData: function() {



        var validate = true;



        if (this.minDate || this.maxValue) {



            if (this.minDate) {



                this.minDate = new Date(this.minDate);



                this.minDate.setHours(0);



                if (isNaN(this.minDate)) {



                    this.minDate = new Date('1/1/1900');



                }



                validate = validate && (this.fullDate >= this.minDate)



            }



            if (this.maxDate) {



                this.maxDate = new Date(this.maxDate)



                this.minDate.setHours(0);



                if (isNaN(this.maxDate)) {



                    this.maxDate = new Date();



                }



                validate = validate && (this.fullDate <= this.maxDate)



            }



            if (this.maxDate && this.minDate) {



                this.validateDataErrorText = 'Please enter a valid date between %s and %s';



            } else if (this.maxDate) {



                this.validateDataErrorText = 'Please enter a valid date less than or equal to %s';



            } else if (this.minDate) {



                this.validateDataErrorText = 'Please enter a valid date equal to or greater than %s';



            } else {



                this.validateDataErrorText = '';



            }



        }



        return validate;



    },



    validateDataErrorText: 'Date should be between %s and %s',



    errorTextModifier: function(text) {



        if (this.minDate) {



            text = text.sub('%s', this.dateFormat(this.minDate));



        }



        if (this.maxDate) {



            text = text.sub('%s', this.dateFormat(this.maxDate));



        }



        return text;



    },



    dateFormat: function(date) {



        return (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();



    }



});







Varien.FileElement = Class.create();



Varien.FileElement.prototype = {



    initialize: function (id) {



        this.fileElement = $(id);



        this.hiddenElement = $(id + '_value');







        this.fileElement.observe('change', this.selectFile.bind(this));



    },



    selectFile: function(event) {



        this.hiddenElement.value = this.fileElement.getValue();



    }



};







Validation.addAllThese([



    ['validate-custom', ' ', function(v,elm) {



        return elm.validate();



    }]



]);







function truncateOptions() {



    $$('.truncated').each(function(element){



        Event.observe(element, 'mouseover', function(){



            if (element.down('div.truncated_full_value')) {



                element.down('div.truncated_full_value').addClassName('show')



            }



        });



        Event.observe(element, 'mouseout', function(){



            if (element.down('div.truncated_full_value')) {



                element.down('div.truncated_full_value').removeClassName('show')



            }



        });







    });



}



Event.observe(window, 'load', function(){



   truncateOptions();



});







Element.addMethods({



    getInnerText: function(element)



    {



        element = $(element);



        if(element.innerText && !Prototype.Browser.Opera) {



            return element.innerText



        }



        return element.innerHTML.stripScripts().unescapeHTML().replace(/[\n\r\s]+/g, ' ').strip();



    }



});







/*



if (!("console" in window) || !("firebug" in console))



{



    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",



    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];







    window.console = {};



    for (var i = 0; i < names.length; ++i)



        window.console[names[i]] = function() {}



}



*/







/**



 * Executes event handler on the element. Works with event handlers attached by Prototype,



 * in a browser-agnostic fashion.



 * @param element The element object



 * @param event Event name, like 'change'



 *



 * @example fireEvent($('my-input', 'click'));



 */



function fireEvent(element, event) {



    if (document.createEvent) {



        // dispatch for all browsers except IE before version 9



        var evt = document.createEvent("HTMLEvents");



        evt.initEvent(event, true, true ); // event type, bubbling, cancelable



        return element.dispatchEvent(evt);



    } else {



        // dispatch for IE before version 9



        var evt = document.createEventObject();



        return element.fireEvent('on' + event, evt)



    }



}







/**



 * Returns more accurate results of floating-point modulo division



 * E.g.:



 * 0.6 % 0.2 = 0.19999999999999996



 * modulo(0.6, 0.2) = 0



 *



 * @param dividend



 * @param divisor



 */



function modulo(dividend, divisor)



{



    var epsilon = divisor / 10000;



    var remainder = dividend % divisor;







    if (Math.abs(remainder - divisor) < epsilon || Math.abs(remainder) < epsilon) {



        remainder = 0;



    }







    return remainder;



}







/**



 * createContextualFragment is not supported in IE9. Adding its support.



 */



if ((typeof Range != "undefined") && !Range.prototype.createContextualFragment)



{



    Range.prototype.createContextualFragment = function(html)



    {



        var frag = document.createDocumentFragment(),



        div = document.createElement("div");



        frag.appendChild(div);



        div.outerHTML = html;



        return frag;



    };



}







/**



 * Magento



 *



 * NOTICE OF LICENSE



 *



 * This source file is subject to the Academic Free License (AFL 3.0)



 * that is bundled with this package in the file LICENSE_AFL.txt.



 * It is also available through the world-wide-web at this URL:



 * http://opensource.org/licenses/afl-3.0.php



 * If you did not receive a copy of the license and are unable to



 * obtain it through the world-wide-web, please send an email



 * to license@magentocommerce.com so we can send you a copy immediately.



 *



 * DISCLAIMER



 *



 * Do not edit or add to this file if you wish to upgrade Magento to newer



 * versions in the future. If you wish to customize Magento for your



 * needs please refer to http://www.magentocommerce.com for more information.



 *



 * @category    Varien



 * @package     js



 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)



 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)



 */



VarienForm = Class.create();



VarienForm.prototype = {



    initialize: function(formId, firstFieldFocus){



        this.form       = $(formId);



        if (!this.form) {



            return;



        }



        this.cache      = $A();



        this.currLoader = false;



        this.currDataIndex = false;



        this.validator  = new Validation(this.form);



        this.elementFocus   = this.elementOnFocus.bindAsEventListener(this);



        this.elementBlur    = this.elementOnBlur.bindAsEventListener(this);



        this.childLoader    = this.onChangeChildLoad.bindAsEventListener(this);



        this.highlightClass = 'highlight';



        this.extraChildParams = '';



        this.firstFieldFocus= firstFieldFocus || false;



        this.bindElements();



        if(this.firstFieldFocus){



            try{



                Form.Element.focus(Form.findFirstElement(this.form))



            }



            catch(e){}



        }



    },







    submit : function(url){



        if(this.validator && this.validator.validate()){



             this.form.submit();



        }



        return false;



    },







    bindElements:function (){



        var elements = Form.getElements(this.form);



        for (var row in elements) {



            if (elements[row].id) {



                Event.observe(elements[row],'focus',this.elementFocus);



                Event.observe(elements[row],'blur',this.elementBlur);



            }



        }



    },







    elementOnFocus: function(event){



        var element = Event.findElement(event, 'fieldset');



        if(element){



            Element.addClassName(element, this.highlightClass);



        }



    },







    elementOnBlur: function(event){



        var element = Event.findElement(event, 'fieldset');



        if(element){



            Element.removeClassName(element, this.highlightClass);



        }



    },







    setElementsRelation: function(parent, child, dataUrl, first){



        if (parent=$(parent)) {



            // TODO: array of relation and caching



            if (!this.cache[parent.id]){



                this.cache[parent.id] = $A();



                this.cache[parent.id]['child']     = child;



                this.cache[parent.id]['dataUrl']   = dataUrl;



                this.cache[parent.id]['data']      = $A();



                this.cache[parent.id]['first']      = first || false;



            }



            Event.observe(parent,'change',this.childLoader);



        }



    },







    onChangeChildLoad: function(event){



        element = Event.element(event);



        this.elementChildLoad(element);



    },







    elementChildLoad: function(element, callback){



        this.callback = callback || false;



        if (element.value) {



            this.currLoader = element.id;



            this.currDataIndex = element.value;



            if (this.cache[element.id]['data'][element.value]) {



                this.setDataToChild(this.cache[element.id]['data'][element.value]);



            }



            else{



                new Ajax.Request(this.cache[this.currLoader]['dataUrl'],{



                        method: 'post',



                        parameters: {"parent":element.value},



                        onComplete: this.reloadChildren.bind(this)



                });



            }



        }



    },







    reloadChildren: function(transport){



        var data = eval('(' + transport.responseText + ')');



        this.cache[this.currLoader]['data'][this.currDataIndex] = data;



        this.setDataToChild(data);



    },







    setDataToChild: function(data){



        if (data.length) {



            var child = $(this.cache[this.currLoader]['child']);



            if (child){



                var html = '<select name="'+child.name+'" id="'+child.id+'" class="'+child.className+'" title="'+child.title+'" '+this.extraChildParams+'>';



                if(this.cache[this.currLoader]['first']){



                    html+= '<option value="">'+this.cache[this.currLoader]['first']+'</option>';



                }



                for (var i in data){



                    if(data[i].value) {



                        html+= '<option value="'+data[i].value+'"';



                        if(child.value && (child.value == data[i].value || child.value == data[i].label)){



                            html+= ' selected';



                        }



                        html+='>'+data[i].label+'</option>';



                    }



                }



                html+= '</select>';



                Element.insert(child, {before: html});



                Element.remove(child);



            }



        }



        else{



            var child = $(this.cache[this.currLoader]['child']);



            if (child){



                var html = '<input type="text" name="'+child.name+'" id="'+child.id+'" class="'+child.className+'" title="'+child.title+'" '+this.extraChildParams+'>';



                Element.insert(child, {before: html});



                Element.remove(child);



            }



        }







        this.bindElements();



        if (this.callback) {



            this.callback();



        }



    }



}







RegionUpdater = Class.create();



RegionUpdater.prototype = {



    initialize: function (countryEl, regionTextEl, regionSelectEl, regions, disableAction, zipEl)



    {



        this.countryEl = $(countryEl);



        this.regionTextEl = $(regionTextEl);



        this.regionSelectEl = $(regionSelectEl);



        this.zipEl = $(zipEl);



        this.config = regions['config'];



        delete regions.config;



        this.regions = regions;







        this.disableAction = (typeof disableAction=='undefined') ? 'hide' : disableAction;



        this.zipOptions = (typeof zipOptions=='undefined') ? false : zipOptions;







        if (this.regionSelectEl.options.length<=1) {



            this.update();



        }







        Event.observe(this.countryEl, 'change', this.update.bind(this));



    },







    _checkRegionRequired: function()



    {



        var label, wildCard;



        var elements = [this.regionTextEl, this.regionSelectEl];



        var that = this;



        if (typeof this.config == 'undefined') {



            return;



        }



        var regionRequired = this.config.regions_required.indexOf(this.countryEl.value) >= 0;







        elements.each(function(currentElement) {



            Validation.reset(currentElement);



            label = $$('label[for="' + currentElement.id + '"]')[0];



            if (label) {



                wildCard = label.down('em') || label.down('span.required');



                if (!that.config.show_all_regions) {



                    if (regionRequired) {



                        label.up().show();



                    } else {



                        label.up().hide();



                    }



                }



            }







            if (label && wildCard) {



                if (!regionRequired) {



                    wildCard.hide();



                    if (label.hasClassName('required')) {



                        label.removeClassName('required');



                    }



                } else if (regionRequired) {



                    wildCard.show();



                    if (!label.hasClassName('required')) {



                        label.addClassName('required')



                    }



                }



            }







            if (!regionRequired) {



                if (currentElement.hasClassName('required-entry')) {



                    currentElement.removeClassName('required-entry');



                }



                if ('select' == currentElement.tagName.toLowerCase() &&



                    currentElement.hasClassName('validate-select')) {



                    currentElement.removeClassName('validate-select');



                }



            } else {



                if (!currentElement.hasClassName('required-entry')) {



                    currentElement.addClassName('required-entry');



                }



                if ('select' == currentElement.tagName.toLowerCase() &&



                    !currentElement.hasClassName('validate-select')) {



                    currentElement.addClassName('validate-select');



                }



            }



        });



    },







    update: function()



    {



        if (this.regions[this.countryEl.value]) {



            var i, option, region, def;







            def = this.regionSelectEl.getAttribute('defaultValue');



            if (this.regionTextEl) {



                if (!def) {



                    def = this.regionTextEl.value.toLowerCase();



                }



                this.regionTextEl.value = '';



            }







            this.regionSelectEl.options.length = 1;



            for (regionId in this.regions[this.countryEl.value]) {



                region = this.regions[this.countryEl.value][regionId];







                option = document.createElement('OPTION');



                option.value = regionId;



                option.text = region.name.stripTags();



                option.title = region.name;







                if (this.regionSelectEl.options.add) {



                    this.regionSelectEl.options.add(option);



                } else {



                    this.regionSelectEl.appendChild(option);



                }







                if (regionId==def || (region.name && region.name.toLowerCase()==def) ||



                    (region.name && region.code.toLowerCase()==def)



                ) {



                    this.regionSelectEl.value = regionId;



                }



            }







            if (this.disableAction=='hide') {



                if (this.regionTextEl) {



                    this.regionTextEl.style.display = 'none';



                }







                this.regionSelectEl.style.display = '';



            } else if (this.disableAction=='disable') {



                if (this.regionTextEl) {



                    this.regionTextEl.disabled = true;



                }



                this.regionSelectEl.disabled = false;



            }



            this.setMarkDisplay(this.regionSelectEl, true);



        } else {



            this.regionSelectEl.options.length = 1;



            if (this.disableAction=='hide') {



                if (this.regionTextEl) {



                    this.regionTextEl.style.display = '';



                }



                this.regionSelectEl.style.display = 'none';



                Validation.reset(this.regionSelectEl);



            } else if (this.disableAction=='disable') {



                if (this.regionTextEl) {



                    this.regionTextEl.disabled = false;



                }



                this.regionSelectEl.disabled = true;



            } else if (this.disableAction=='nullify') {



                this.regionSelectEl.options.length = 1;



                this.regionSelectEl.value = '';



                this.regionSelectEl.selectedIndex = 0;



                this.lastCountryId = '';



            }



            this.setMarkDisplay(this.regionSelectEl, false);



        }







        this._checkRegionRequired();



        // Make Zip and its label required/optional



        var zipUpdater = new ZipUpdater(this.countryEl.value, this.zipEl);



        zipUpdater.update();



    },







    setMarkDisplay: function(elem, display){



        elem = $(elem);



        var labelElement = elem.up(0).down('label > span.required') ||



                           elem.up(1).down('label > span.required') ||



                           elem.up(0).down('label.required > em') ||



                           elem.up(1).down('label.required > em');



        if(labelElement) {



            inputElement = labelElement.up().next('input');



            if (display) {



                labelElement.show();



                if (inputElement) {



                    inputElement.addClassName('required-entry');



                }



            } else {



                labelElement.hide();



                if (inputElement) {



                    inputElement.removeClassName('required-entry');



                }



            }



        }



    }



}







ZipUpdater = Class.create();



ZipUpdater.prototype = {



    initialize: function(country, zipElement)



    {



        this.country = country;



        this.zipElement = $(zipElement);



    },







    update: function()



    {



        // Country ISO 2-letter codes must be pre-defined



        if (typeof optionalZipCountries == 'undefined') {



            return false;



        }







        // Ajax-request and normal content load compatibility



        if (this.zipElement != undefined) {



            Validation.reset(this.zipElement)



            this._setPostcodeOptional();



        } else {



            Event.observe(window, "load", this._setPostcodeOptional.bind(this));



        }



    },







    _setPostcodeOptional: function()



    {



        this.zipElement = $(this.zipElement);



        if (this.zipElement == undefined) {



            return false;



        }







        // find label



        var label = $$('label[for="' + this.zipElement.id + '"]')[0];



        if (label != undefined) {



            var wildCard = label.down('em') || label.down('span.required');



        }







        // Make Zip and its label required/optional



        if (optionalZipCountries.indexOf(this.country) != -1) {



            while (this.zipElement.hasClassName('required-entry')) {



                this.zipElement.removeClassName('required-entry');



            }



            if (wildCard != undefined) {



                wildCard.hide();



            }



        } else {



            this.zipElement.addClassName('required-entry');



            if (wildCard != undefined) {



                wildCard.show();



            }



        }



    }



}







/**



 * Magento



 *



 * NOTICE OF LICENSE



 *



 * This source file is subject to the Academic Free License (AFL 3.0)



 * that is bundled with this package in the file LICENSE_AFL.txt.



 * It is also available through the world-wide-web at this URL:



 * http://opensource.org/licenses/afl-3.0.php



 * If you did not receive a copy of the license and are unable to



 * obtain it through the world-wide-web, please send an email



 * to license@magentocommerce.com so we can send you a copy immediately.



 *



 * DISCLAIMER



 *



 * Do not edit or add to this file if you wish to upgrade Magento to newer



 * versions in the future. If you wish to customize Magento for your



 * needs please refer to http://www.magentocommerce.com for more information.



 *



 * @category    Mage



 * @package     js



 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)



 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)



 */







var Translate = Class.create();



Translate.prototype = {



    initialize: function(data){



        this.data = $H(data);



    },







    translate : function(){



        var args = arguments;



        var text = arguments[0];







        if(this.data.get(text)){



            return this.data.get(text);



        }



        return text;



    },



    add : function() {



        if (arguments.length > 1) {



            this.data.set(arguments[0], arguments[1]);



        } else if (typeof arguments[0] =='object') {



            $H(arguments[0]).each(function (pair){



                this.data.set(pair.key, pair.value);



            }.bind(this));



        }



    }



}







/**



 * Magento



 *



 * NOTICE OF LICENSE



 *



 * This source file is subject to the Academic Free License (AFL 3.0)



 * that is bundled with this package in the file LICENSE_AFL.txt.



 * It is also available through the world-wide-web at this URL:



 * http://opensource.org/licenses/afl-3.0.php



 * If you did not receive a copy of the license and are unable to



 * obtain it through the world-wide-web, please send an email



 * to license@magentocommerce.com so we can send you a copy immediately.



 *



 * DISCLAIMER



 *



 * Do not edit or add to this file if you wish to upgrade Magento to newer



 * versions in the future. If you wish to customize Magento for your



 * needs please refer to http://www.magentocommerce.com for more information.



 *



 * @category    Mage



 * @package     js



 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)



 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)



 */



// old school cookie functions grabbed off the web







if (!window.Mage) var Mage = {};







Mage.Cookies = {};



Mage.Cookies.expires  = null;



Mage.Cookies.path     = '/';



Mage.Cookies.domain   = null;



Mage.Cookies.secure   = false;



Mage.Cookies.set = function(name, value){



     var argv = arguments;



     var argc = arguments.length;



     var expires = (argc > 2) ? argv[2] : Mage.Cookies.expires;



     var path = (argc > 3) ? argv[3] : Mage.Cookies.path;



     var domain = (argc > 4) ? argv[4] : Mage.Cookies.domain;



     var secure = (argc > 5) ? argv[5] : Mage.Cookies.secure;



     document.cookie = name + "=" + escape (value) +



       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +



       ((path == null) ? "" : ("; path=" + path)) +



       ((domain == null) ? "" : ("; domain=" + domain)) +



       ((secure == true) ? "; secure" : "");



};







Mage.Cookies.get = function(name){



    var arg = name + "=";



    var alen = arg.length;



    var clen = document.cookie.length;



    var i = 0;



    var j = 0;



    while(i < clen){



        j = i + alen;



        if (document.cookie.substring(i, j) == arg)



            return Mage.Cookies.getCookieVal(j);



        i = document.cookie.indexOf(" ", i) + 1;



        if(i == 0)



            break;



    }



    return null;



};







Mage.Cookies.clear = function(name) {



  if(Mage.Cookies.get(name)){



    document.cookie = name + "=" +



    "; expires=Thu, 01-Jan-70 00:00:01 GMT";



  }



};







Mage.Cookies.getCookieVal = function(offset){



   var endstr = document.cookie.indexOf(";", offset);



   if(endstr == -1){



       endstr = document.cookie.length;



   }



   return unescape(document.cookie.substring(offset, endstr));



};







var AWAjaxCatalog;



var __bind = function (fn, me) {



    return function () {



        return fn.apply(me, arguments);



    };



};



AWAjaxCatalog = Class.create();



AWAjaxCatalog.prototype = {



    /*



     Class construcructor



     */



    initialize: function (params) {



        for (var key in params) {



            this[key] = params[key];



        }



        if (this.action_type === "button") {



            document.observe("dom:loaded", __bind(function (event) {



                if ($(this.button_id)) {



                    $(this.button_id).observe("click", __bind(function (event) {



                        this.loadNext();



                    }, this));



                }



            }, this));



        } else {



            this.disabled_forever = false;



            this.start_lock = true;



            document.observe("dom:loaded", __bind(function (event) {



                if (this.needLoadNextBefore()) {



                    this.loadNext();



                }



            }, this));



            Event.observe(window, "scroll", __bind(function (event) {



                /*



                 User scroll document



                 */



                if (this.needLoadNextAfter()) {



                    this.loadNext();



                }



                this.start_lock = false;



            }, this));



        }



        return this;



    },



    /*



     Need to load next page after scroll



     */



    needLoadNextAfter: function () {



        var docHeight, height, top;



        if (document.viewport) {



            top = document.viewport.getScrollOffsets().top;



            height = document.viewport.getHeight();



            docHeight = Math.max(



                Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),



                Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),



                Math.max(document.body.clientHeight, document.documentElement.clientHeight)



            );



            return ((docHeight - top) <= (3 * height)) && !this.start_lock && !this.disabled_forever;



        }



        return false;



    },



    needLoadNextBefore: function () {



        var result;



        result = false;



        if (document.viewport) {



            $$('https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/div.main').each(__bind(function (el) {



                var elementHeight, screenHeight;



                screenHeight = document.viewport.getHeight();



                elementHeight = el.getHeight();



                if (screenHeight > elementHeight) {



                    return result = true;



                }



            }, this));



        }



        return result;



    },



    /*



     Load next products



     */



    loadNext: function () {



        var params;



        if (this.isLoading()) {



            return;



        }



        this.showLoader(true);



        this.params['p'] = this.next_page;



        params = Base64.encode(Object.toJSON($H(this.params)));



        new Ajax.Request(this.next_url.replace("{{page}}", params).replace(/^http[s]{0,1}/, window.location.href.replace(/:[^:].*$/i, '')), {



            method: "get",



            onSuccess: __bind(function (transport) {



                var content, error, next_page, response, success;



                try {



                    response = eval('(' + transport.responseText + ')');



                } catch (exception) {



                    response = {};



                }



                success = response.success, content = response.content, next_page = response.next_page, error = response.error;



                if (error) {



                    if (typeof console.log === "function") {



                        console.log(error);



                    }



                }



                if (success) {



                    if (next_page > 0) {



                        this.next_page = next_page;



                    } else {



                        this.next_page = 0;



                        this.showButton(false);



                    }



                    if (content) {



                        this.appendContent(this.evalInnerScripts(content));



                        this.useDecorator();



                    }



                }



            }, this),



            onComplete: __bind(function (transport) {



                this.showLoader(false);



                if (this.needLoadNextBefore() && (this.next_page > 0)) {



                    this.loadNext();



                }



            }, this)



        });



        return this;



    },



    /*



     Append new content



     */



    appendContent: function (content) {



        if ($(this.container_id)) {



            $(this.container_id).innerHTML += content;



        }



    },



    /*



     Show button



     */



    showButton: function (show) {



        if (this.action_type === "button") {



            if (show) {



                this.getButtonContainer().removeClassName("hidden");



            } else {



                this.getButtonContainer().addClassName("hidden");



            }



        } else {



            this.disabled_forever = true;



        }



    },



    /*



     Show loader



     */



    showLoader: function (show) {



        if (this.action_type === "button") {



            if (show) {



                this.getButton().addClassName("loading");



            } else {



                this.getButton().removeClassName("loading");



            }



        } else {



            if (show) {



                this.getLoader().addClassName("loading");



            } else {



                this.getLoader().removeClassName("loading");



            }



        }



    },



    /*



     Button



     */



    getButton: function () {



        if ($(this.button_id)) {



            return $(this.button_id);



        }



    },



    /*



     Loader



     */



    getLoader: function () {



        if ($(this.loader_id)) {



            return $(this.loader_id);



        }



    },



    /*



     Button with container



     */



    getButtonContainer: function () {



        if ($(this.button_container_id)) {



            return $(this.button_container_id);



        }



    },



    /*



     Is loading now



     */



    isLoading: function () {



        if (this.action_type === "button") {



            return this.getButton().hasClassName("loading");



        } else {



            return this.getLoader().hasClassName("loading");



        }



    },



    /*



     Eval Inner Scripts



     (required after ajax load content)



     */



    evalInnerScripts: function (content) {



        content.evalScripts();



        return content;



    },



    /*



     Use List Decorator to redecorate list



     */



    useDecorator: function () {



        var selection, _i, _len, _ref;



        $$(this.decorate_clean).each(__bind(function (element) {



            element.removeClassName("even");



            element.removeClassName("odd");



            element.removeClassName("last");



            element.removeClassName("first");



        }, this));



        _ref = this.decorate_decorate;



        for (_i = 0, _len = _ref.length; _i < _len; _i++) {



            selection = _ref[_i];



            decorateGeneric($$(selection), ['odd', 'even', 'first', 'last']);



        }



        return this;



    }



};



function ampromo_init()



{



    var itemsNode = $('ampromo-items');







    if (!itemsNode)



        return;







    $$('#ampromo-items form').each(function(e){



        var validation = new Validation(e, {



            onFormValidate: function(res, form){



                if (res)



                {



                    $$('#ampromo-items button').each(function(element){



                        element.setAttribute('disabled', 'disabled');



                    });



                }



            }});



        e.down('.button.add').observe('click', function(){



            if (validation.validate())



                this.up('form').submit();



        });



    });







    $$('.bundle-option-select option,' +



    '.product-custom-option option').each(function(element){



            element.text = element.text.replace(/\s+\+.+$/, '');



    });







    if ($$('.bundle-option-select').length > 0) {



        if (!('bundle' in window)) {



            Object.extend(Product.Bundle.prototype, {



                initialize: function(){},



                changeSelection: function(){},



                reloadPrice: function(){}



                });



            window.bundle = new Product.Bundle({defaultValues: false});



        }



    }











    var overlay = $('ampromo-overlay');







    if (overlay)



    {



        $('ampromo-items-add').down('a').observe('click', ampromo_popup);







        overlay.down('.close').observe('click', function(){



            $('ampromo-overlay').fade();



        });







        overlay.observe('click', function(event){



            if (event.target.id == 'ampromo-overlay')



                $('ampromo-overlay').fade();



        });







        if (itemsNode.hasClassName('amcarousel'))



        {



            window.ampromo_carousel = new Carousel(



                'ampromo-carousel-wrapper',



                $$('#ampromo-carousel-content .slide'),



                $$('.ampromo-carousel-control'), {



                    visibleSlides: 2,



                    controlClassName: 'ampromo-carousel-control',



                    duration: 0.3



                }



            );







            ampromo_update_width();



            Event.observe(window, 'resize', ampromo_update_width);



        }



    }







    $('ampromo-items-add').setAttribute('data-initialized', '1');



}







function ampromo_update_width()



{



    var visibleSlides = $$('body')[0].clientWidth <= 820 ? 1 : 2;







    window.ampromo_carousel.options.visibleSlides = visibleSlides;



}











/**



 * Used to fix issues related to ajax reloads



 */







function ampromo_check_initialization(e)



{



    e.stop();



    if ($('ampromo-items-add').readAttribute('data-initialized') === null)



    {



        ampromo_init();



        ampromo_popup();



    }



}







function ampromo_popup()



{



    var overlay = $('ampromo-overlay');







    if (overlay.visible())



        return;







    var items = $('ampromo-items');



    overlay.show();



    centerVertically(items);



    overlay.hide();







    overlay.appear();







    if (items.getStyle('position') == 'static' && $('amscheckout-main'))



        window.scroll(items.offsetLeft, items.offsetTop);



}







function centerVertically(element)



{



    var vpHeight = $(document).viewport.getHeight();



    var height = element.clientHeight;







    var avTop = (vpHeight / 2) - (height / 2);







    if (avTop <= 10)



        avTop = 10;







    element.style.top = avTop+ 'px';



}







function am_get_cookie(cname) {



    var name = cname + "=";



    var ca = document.cookie.split(';');



    for (var i = 0; i < ca.length; i++) {



        var c = ca[i];



        while (c.charAt(0) == ' ') c = c.substring(1);



        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);



    }



    return "";



}







document.observe('dom:loaded', function(){



    if (+am_get_cookie('am_promo_notification')) {



        $$('.ampromo-notification').each(function (e) {



            e.show();



        })



    }



});







/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license



//@ sourceMappingURL=jquery.min.map



*/(function(e,t){var n,r,i=typeof t,o=e.document,a=e.location,s=e.jQuery,u=e.$,l={},c=[],p="1.9.1",f=c.concat,d=c.push,h=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=p.trim,b=function(e,t){return new b.fn.init(e,t,r)},x=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^[\],:{}\s]*$/,E=/(?:^|:|,)(?:\s*\[)+/g,S=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,A=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,j=/^-ms-/,D=/-([\da-z])/gi,L=function(e,t){return t.toUpperCase()},H=function(e){(o.addEventListener||"load"===e.type||"complete"===o.readyState)&&(q(),b.ready())},q=function(){o.addEventListener?(o.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(o.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))};b.fn=b.prototype={jquery:p,constructor:b,init:function(e,n,r){var i,a;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof b?n[0]:n,b.merge(this,b.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:o,!0)),C.test(i[1])&&b.isPlainObject(n))for(i in n)b.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(a=o.getElementById(i[2]),a&&a.parentNode){if(a.id!==i[2])return r.find(e);this.length=1,this[0]=a}return this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):b.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),b.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return h.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=b.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return b.each(this,e,t)},ready:function(e){return b.ready.promise().done(e),this},slice:function(){return this.pushStack(h.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(b.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:d,sort:[].sort,splice:[].splice},b.fn.init.prototype=b.fn,b.extend=b.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||b.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(o=arguments[u]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(b.isPlainObject(r)||(n=b.isArray(r)))?(n?(n=!1,a=e&&b.isArray(e)?e:[]):a=e&&b.isPlainObject(e)?e:{},s[i]=b.extend(c,a,r)):r!==t&&(s[i]=r));return s},b.extend({noConflict:function(t){return e.$===b&&(e.$=u),t&&e.jQuery===b&&(e.jQuery=s),b},isReady:!1,readyWait:1,holdReady:function(e){e?b.readyWait++:b.ready(!0)},ready:function(e){if(e===!0?!--b.readyWait:!b.isReady){if(!o.body)return setTimeout(b.ready);b.isReady=!0,e!==!0&&--b.readyWait>0||(n.resolveWith(o,[b]),b.fn.trigger&&b(o).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===b.type(e)},isArray:Array.isArray||function(e){return"array"===b.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==b.type(e)||e.nodeType||b.isWindow(e))return!1;try{if(e.constructor&&!y.call(e,"constructor")&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||y.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=b.buildFragment([e],t,i),i&&b(i).remove(),b.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=b.trim(n),n&&k.test(n.replace(S,"@").replace(A,"]").replace(E,"")))?Function("return "+n)():(b.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||b.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&b.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(j,"ms-").replace(D,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:v&&!v.call("\ufeff\u00a0")?function(e){return null==e?"":v.call(e)}:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?b.merge(n,"string"==typeof e?[e]:e):d.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(g)return g.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return f.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),b.isFunction(e)?(r=h.call(arguments,2),i=function(){return e.apply(n||this,r.concat(h.call(arguments)))},i.guid=e.guid=e.guid||b.guid++,i):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===b.type(r)){o=!0;for(u in r)b.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,b.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(b(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),b.ready.promise=function(t){if(!n)if(n=b.Deferred(),"complete"===o.readyState)setTimeout(b.ready);else if(o.addEventListener)o.addEventListener("DOMContentLoaded",H,!1),e.addEventListener("load",H,!1);else{o.attachEvent("onreadystatechange",H),e.attachEvent("onload",H);var r=!1;try{r=null==e.frameElement&&o.documentElement}catch(i){}r&&r.doScroll&&function a(){if(!b.isReady){try{r.doScroll("left")}catch(e){return setTimeout(a,50)}q(),b.ready()}}()}return n.promise(t)},b.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=b.type(e);return b.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=b(o);var _={};function F(e){var t=_[e]={};return b.each(e.match(w)||[],function(e,n){t[n]=!0}),t}b.Callbacks=function(e){e="string"==typeof e?_[e]||F(e):b.extend({},e);var n,r,i,o,a,s,u=[],l=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=u.length,n=!0;u&&o>a;a++)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,u&&(l?l.length&&c(l.shift()):r?u=[]:p.disable())},p={add:function(){if(u){var t=u.length;(function i(t){b.each(t,function(t,n){var r=b.type(n);"function"===r?e.unique&&p.has(n)||u.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=u.length:r&&(s=t,c(r))}return this},remove:function(){return u&&b.each(arguments,function(e,t){var r;while((r=b.inArray(t,u,r))>-1)u.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?b.inArray(e,u)>-1:!(!u||!u.length)},empty:function(){return u=[],this},disable:function(){return u=l=r=t,this},disabled:function(){return!u},lock:function(){return l=t,r||p.disable(),this},locked:function(){return!l},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!u||i&&!l||(n?l.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},b.extend({Deferred:function(e){var t=[["resolve","done",b.Callbacks("once memory"),"resolved"],["reject","fail",b.Callbacks("once memory"),"rejected"],["notify","progress",b.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return b.Deferred(function(n){b.each(t,function(t,o){var a=o[0],s=b.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&b.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?b.extend(e,r):r}},i={};return r.pipe=r.then,b.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=h.call(arguments),r=n.length,i=1!==r||e&&b.isFunction(e.promise)?r:0,o=1===i?e:b.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?h.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,u,l;if(r>1)for(s=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&b.isFunction(n[t].promise)?n[t].promise().done(a(t,l,n)).fail(o.reject).progress(a(t,u,s)):--i;return i||o.resolveWith(l,n),o.promise()}}),b.support=function(){var t,n,r,a,s,u,l,c,p,f,d=o.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="  <link/><table></table><a href='https://www.beststoreitems.com/catalog/template/beststoreitems/media/index.htm'/*tpa=https://www.beststoreitems.com/a*/>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*"),r=d.getElementsByTagName("a")[0],!n||!r||!n.length)return{};s=o.createElement("select"),l=s.appendChild(o.createElement("option")),a=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={getSetAttribute:"t"!==d.className,leadingWhitespace:3===d.firstChild.nodeType,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:"/a"===r.getAttribute("href"),opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:!!a.value,optSelected:l.selected,enctype:!!o.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==o.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===o.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},a.checked=!0,t.noCloneChecked=a.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!l.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}a=o.createElement("input"),a.setAttribute("value",""),t.input=""===a.getAttribute("value"),a.value="t",a.setAttribute("type","radio"),t.radioValue="t"===a.value,a.setAttribute("checked","t"),a.setAttribute("name","t"),u=o.createDocumentFragment(),u.appendChild(a),t.appendChecked=a.checked,t.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;return d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip,b(function(){var n,r,a,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",u=o.getElementsByTagName("body")[0];u&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",u.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",a=d.getElementsByTagName("td"),a[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===a[0].offsetHeight,a[0].style.display="",a[1].style.display="none",t.reliableHiddenOffsets=p&&0===a[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=4===d.offsetWidth,t.doesNotIncludeMarginInBodyOffset=1!==u.offsetTop,e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(o.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(u.style.zoom=1)),u.removeChild(n),n=d=a=r=null)}),n=s=u=l=r=a=null,t}();var O=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,B=/([A-Z])/g;function P(e,n,r,i){if(b.acceptData(e)){var o,a,s=b.expando,u="string"==typeof n,l=e.nodeType,p=l?b.cache:e,f=l?e[s]:e[s]&&s;if(f&&p[f]&&(i||p[f].data)||!u||r!==t)return f||(l?e[s]=f=c.pop()||b.guid++:f=s),p[f]||(p[f]={},l||(p[f].toJSON=b.noop)),("object"==typeof n||"function"==typeof n)&&(i?p[f]=b.extend(p[f],n):p[f].data=b.extend(p[f].data,n)),o=p[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[b.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[b.camelCase(n)])):a=o,a}}function R(e,t,n){if(b.acceptData(e)){var r,i,o,a=e.nodeType,s=a?b.cache:e,u=a?e[b.expando]:b.expando;if(s[u]){if(t&&(o=n?s[u]:s[u].data)){b.isArray(t)?t=t.concat(b.map(t,b.camelCase)):t in o?t=[t]:(t=b.camelCase(t),t=t in o?[t]:t.split(" "));for(r=0,i=t.length;i>r;r++)delete o[t[r]];if(!(n?$:b.isEmptyObject)(o))return}(n||(delete s[u].data,$(s[u])))&&(a?b.cleanData([e],!0):b.support.deleteExpando||s!=s.window?delete s[u]:s[u]=null)}}}b.extend({cache:{},expando:"jQuery"+(p+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?b.cache[e[b.expando]]:e[b.expando],!!e&&!$(e)},data:function(e,t,n){return P(e,t,n)},removeData:function(e,t){return R(e,t)},_data:function(e,t,n){return P(e,t,n,!0)},_removeData:function(e,t){return R(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&b.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),b.fn.extend({data:function(e,n){var r,i,o=this[0],a=0,s=null;if(e===t){if(this.length&&(s=b.data(o),1===o.nodeType&&!b._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>a;a++)i=r[a].name,i.indexOf("data-")||(i=b.camelCase(i.slice(5)),W(o,i,s[i]));b._data(o,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){b.data(this,e)}):b.access(this,function(n){return n===t?o?W(o,e,b.data(o,e)):null:(this.each(function(){b.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){b.removeData(this,e)})}});function W(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(B,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:O.test(r)?b.parseJSON(r):r}catch(o){}b.data(e,n,r)}else r=t}return r}function $(e){var t;for(t in e)if(("data"!==t||!b.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}b.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=b._data(e,n),r&&(!i||b.isArray(r)?i=b._data(e,n,b.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=b.queue(e,t),r=n.length,i=n.shift(),o=b._queueHooks(e,t),a=function(){b.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return b._data(e,n)||b._data(e,n,{empty:b.Callbacks("once memory").add(function(){b._removeData(e,t+"queue"),b._removeData(e,n)})})}}),b.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?b.queue(this[0],e):n===t?this:this.each(function(){var t=b.queue(this,e,n);b._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&b.dequeue(this,e)})},dequeue:function(e){return this.each(function(){b.dequeue(this,e)})},delay:function(e,t){return e=b.fx?b.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=b.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=b._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var I,z,X=/[\t\r\n]/g,U=/\r/g,V=/^(?:input|select|textarea|button|object)$/i,Y=/^(?:a|area)$/i,J=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,G=/^(?:checked|selected)$/i,Q=b.support.getSetAttribute,K=b.support.input;b.fn.extend({attr:function(e,t){return b.access(this,b.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){b.removeAttr(this,e)})},prop:function(e,t){return b.access(this,b.prop,e,t,arguments.length>1)},removeProp:function(e){return e=b.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=b.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(b.isFunction(e))return this.each(function(t){b(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(X," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?b.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return b.isFunction(e)?this.each(function(n){b(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=b(this),u=t,l=e.match(w)||[];while(o=l[a++])u=r?u:!s.hasClass(o),s[u?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&b._data(this,"__className__",this.className),this.className=this.className||e===!1?"":b._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(X," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=b.isFunction(e),this.each(function(n){var o,a=b(this);1===this.nodeType&&(o=i?e.call(this,n,a.val()):e,null==o?o="":"number"==typeof o?o+="":b.isArray(o)&&(o=b.map(o,function(e){return null==e?"":e+""})),r=b.valHooks[this.type]||b.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=b.valHooks[o.type]||b.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(U,""):null==n?"":n)}}}),b.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;for(;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(b.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&b.nodeName(n.parentNode,"optgroup"))){if(t=b(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=b.makeArray(t);return b(e).find("option").each(function(){this.selected=b.inArray(b(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var o,a,s,u=e.nodeType;if(e&&3!==u&&8!==u&&2!==u)return typeof e.getAttribute===i?b.prop(e,n,r):(a=1!==u||!b.isXMLDoc(e),a&&(n=n.toLowerCase(),o=b.attrHooks[n]||(J.test(n)?z:I)),r===t?o&&a&&"get"in o&&null!==(s=o.get(e,n))?s:(typeof e.getAttribute!==i&&(s=e.getAttribute(n)),null==s?t:s):null!==r?o&&a&&"set"in o&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r):(b.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=b.propFix[n]||n,J.test(n)?!Q&&G.test(n)?e[b.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:b.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!b.support.radioValue&&"radio"===t&&b.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!b.isXMLDoc(e),a&&(n=b.propFix[n]||n,o=b.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):V.test(e.nodeName)||Y.test(e.nodeName)&&e.href?0:t}}}}),z={get:function(e,n){var r=b.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?K&&Q?null!=i:G.test(n)?e[b.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?b.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&b.propFix[n]||n,n):e[b.camelCase("default-"+n)]=e[n]=!0,n}},K&&Q||(b.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return b.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t},set:function(e,n,r){return b.nodeName(e,"input")?(e.defaultValue=n,t):I&&I.set(e,n,r)}}),Q||(I=b.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},b.attrHooks.contenteditable={get:I.get,set:function(e,t,n){I.set(e,""===t?!1:t,n)}},b.each(["width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),b.support.hrefNormalized||(b.each(["href","src","width","height"],function(e,n){b.attrHooks[n]=b.extend(b.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),b.each(["href","src"],function(e,t){b.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),b.support.style||(b.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),b.support.optSelected||(b.propHooks.selected=b.extend(b.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),b.support.enctype||(b.propFix.enctype="encoding"),b.support.checkOn||b.each(["radio","checkbox"],function(){b.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),b.each(["radio","checkbox"],function(){b.valHooks[this]=b.extend(b.valHooks[this],{set:function(e,n){return b.isArray(n)?e.checked=b.inArray(b(e).val(),n)>=0:t}})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}b.event={global:{},add:function(e,n,r,o,a){var s,u,l,c,p,f,d,h,g,m,y,v=b._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=b.guid++),(u=v.events)||(u=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(w)||[""],l=n.length;while(l--)s=rt.exec(n[l])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),p=b.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=b.event.special[g]||{},d=b.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&b.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=u[g])||(h=u[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),b.event.global[g]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,p,f,d,h,g,m=b.hasData(e)&&b._data(e);if(m&&(c=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(s=rt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=b.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),u=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));u&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||b.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)b.event.remove(e,d+t[l],n,r,!0);b.isEmptyObject(c)&&(delete m.handle,b._removeData(e,"events"))}},trigger:function(n,r,i,a){var s,u,l,c,p,f,d,h=[i||o],g=y.call(n,"type")?n.type:n,m=y.call(n,"namespace")?n.namespace.split("."):[];if(l=f=i=i||o,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+b.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),u=0>g.indexOf(":")&&"on"+g,n=n[b.expando]?n:new b.Event(g,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:b.makeArray(r,[n]),p=b.event.special[g]||{},a||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!a&&!p.noBubble&&!b.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(l=l.parentNode);l;l=l.parentNode)h.push(l),f=l;f===(i.ownerDocument||o)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((l=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(b._data(l,"events")||{})[n.type]&&b._data(l,"handle"),s&&s.apply(l,r),s=u&&l[u],s&&b.acceptData(l)&&s.apply&&s.apply(l,r)===!1&&n.preventDefault();if(n.type=g,!(a||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===g&&b.nodeName(i,"a")||!b.acceptData(i)||!u||!i[g]||b.isWindow(i))){f=i[u],f&&(i[u]=null),b.event.triggered=g;try{i[g]()}catch(v){}b.event.triggered=t,f&&(i[u]=f)}return n.result}},dispatch:function(e){e=b.event.fix(e);var n,r,i,o,a,s=[],u=h.call(arguments),l=(b._data(this,"events")||{})[e.type]||[],c=b.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=b.event.handlers.call(this,e,l),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((b.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,u),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(1===l.nodeType&&(l.disabled!==!0||"click"!==e.type)){for(o=[],a=0;u>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?b(r,this).index(l)>=0:b.find(r,this,null,[l]).length),o[r]&&o.push(i);o.length&&s.push({elem:l,handlers:o})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[b.expando])return e;var t,n,r,i=e.type,a=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new b.Event(a),t=r.length;while(t--)n=r[t],e[n]=a[n];return e.target||(e.target=a.srcElement||o),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,a,s=n.button,u=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||o,a=i.documentElement,r=i.body,e.pageX=n.clientX+(a&&a.scrollLeft||r&&r.scrollLeft||0)-(a&&a.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(a&&a.scrollTop||r&&r.scrollTop||0)-(a&&a.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&u&&(e.relatedTarget=u===e.target?n.toElement:u),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return b.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==o.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===o.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=b.extend(new b.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?b.event.trigger(i,null,t):b.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},b.removeEvent=o.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},b.Event=function(e,n){return this instanceof b.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&b.extend(this,n),this.timeStamp=e&&e.timeStamp||b.now(),this[b.expando]=!0,t):new b.Event(e,n)},b.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},b.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){b.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;



return(!i||i!==r&&!b.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),b.support.submitBubbles||(b.event.special.submit={setup:function(){return b.nodeName(this,"form")?!1:(b.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=b.nodeName(n,"input")||b.nodeName(n,"button")?n.form:t;r&&!b._data(r,"submitBubbles")&&(b.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),b._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&b.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return b.nodeName(this,"form")?!1:(b.event.remove(this,"._submit"),t)}}),b.support.changeBubbles||(b.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(b.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),b.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),b.event.simulate("change",this,e,!0)})),!1):(b.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!b._data(t,"changeBubbles")&&(b.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||b.event.simulate("change",this.parentNode,e,!0)}),b._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return b.event.remove(this,"._change"),!Z.test(this.nodeName)}}),b.support.focusinBubbles||b.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){b.event.simulate(t,e.target,b.event.fix(e),!0)};b.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),b.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return b().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=b.guid++)),this.each(function(){b.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,b(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){b.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){b.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?b.event.trigger(e,n,r,!0):t}}),function(e,t){var n,r,i,o,a,s,u,l,c,p,f,d,h,g,m,y,v,x="sizzle"+-new Date,w=e.document,T={},N=0,C=0,k=it(),E=it(),S=it(),A=typeof t,j=1<<31,D=[],L=D.pop,H=D.push,q=D.slice,M=D.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},_="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=F.replace("w","w#"),B="([*^$|!~]?=)",P="\\["+_+"*("+F+")"+_+"*(?:"+B+_+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+O+")|)|)"+_+"*\\]",R=":("+F+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+P.replace(3,8)+")*)|.*)\\)|)",W=RegExp("^"+_+"+|((?:^|[^\\\\])(?:\\\\.)*)"+_+"+$","g"),$=RegExp("^"+_+"*,"+_+"*"),I=RegExp("^"+_+"*([\\x20\\t\\r\\n\\f>+~])"+_+"*"),z=RegExp(R),X=RegExp("^"+O+"$"),U={ID:RegExp("^#("+F+")"),CLASS:RegExp("^\\.("+F+")"),NAME:RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:RegExp("^("+F.replace("w","w*")+")"),ATTR:RegExp("^"+P),PSEUDO:RegExp("^"+R),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+_+"*(even|odd|(([+-]|)(\\d*)n|)"+_+"*(?:([+-]|)"+_+"*(\\d+)|))"+_+"*\\)|)","i"),needsContext:RegExp("^"+_+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+_+"*((?:-\\d)?\\d*)"+_+"*\\)|)(?=[^-]|$)","i")},V=/[\x20\t\r\n\f]*[+~]/,Y=/^[^{]+\{\s*\[native code/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,G=/^(?:input|select|textarea|button)$/i,Q=/^h\d$/i,K=/'|\\/g,Z=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,et=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{q.call(w.documentElement.childNodes,0)[0].nodeType}catch(nt){q=function(e){var t,n=[];while(t=this[e++])n.push(t);return n}}function rt(e){return Y.test(e+"")}function it(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>i.cacheLength&&delete e[t.shift()],e[n]=r}}function ot(e){return e[x]=!0,e}function at(e){var t=p.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function st(e,t,n,r){var i,o,a,s,u,l,f,g,m,v;if((t?t.ownerDocument||t:w)!==p&&c(t),t=t||p,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!d&&!r){if(i=J.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&y(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return H.apply(n,q.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&T.getByClassName&&t.getElementsByClassName)return H.apply(n,q.call(t.getElementsByClassName(a),0)),n}if(T.qsa&&!h.test(e)){if(f=!0,g=x,m=t,v=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){l=ft(e),(f=t.getAttribute("id"))?g=f.replace(K,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=l.length;while(u--)l[u]=g+dt(l[u]);m=V.test(e)&&t.parentNode||t,v=l.join(",")}if(v)try{return H.apply(n,q.call(m.querySelectorAll(v),0)),n}catch(b){}finally{f||t.removeAttribute("id")}}}return wt(e.replace(W,"$1"),t,n,r)}a=st.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},c=st.setDocument=function(e){var n=e?e.ownerDocument||e:w;return n!==p&&9===n.nodeType&&n.documentElement?(p=n,f=n.documentElement,d=a(n),T.tagNameNoComments=at(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),T.attributes=at(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),T.getByClassName=at(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),T.getByName=at(function(e){e.id=x+0,e.innerHTML="<a name='"+x+"'></a><div name='"+x+"'></div>",f.insertBefore(e,f.firstChild);var t=n.getElementsByName&&n.getElementsByName(x).length===2+n.getElementsByName(x+0).length;return T.getIdNotName=!n.getElementById(x),f.removeChild(e),t}),i.attrHandle=at(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==A&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},T.getIdNotName?(i.find.ID=function(e,t){if(typeof t.getElementById!==A&&!d){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){return e.getAttribute("id")===t}}):(i.find.ID=function(e,n){if(typeof n.getElementById!==A&&!d){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==A&&r.getAttributeNode("id").value===e?[r]:t:[]}},i.filter.ID=function(e){var t=e.replace(et,tt);return function(e){var n=typeof e.getAttributeNode!==A&&e.getAttributeNode("id");return n&&n.value===t}}),i.find.TAG=T.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==A?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},i.find.NAME=T.getByName&&function(e,n){return typeof n.getElementsByName!==A?n.getElementsByName(name):t},i.find.CLASS=T.getByClassName&&function(e,n){return typeof n.getElementsByClassName===A||d?t:n.getElementsByClassName(e)},g=[],h=[":focus"],(T.qsa=rt(n.querySelectorAll))&&(at(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||h.push("\\["+_+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){e.innerHTML="<input type='hidden' i=''/>",e.querySelectorAll("[i^='']").length&&h.push("[*^$]="+_+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(T.matchesSelector=rt(m=f.matchesSelector||f.mozMatchesSelector||f.webkitMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){T.disconnectedMatch=m.call(e,"div"),m.call(e,"[s!='']:x"),g.push("!=",R)}),h=RegExp(h.join("|")),g=RegExp(g.join("|")),y=rt(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},v=f.compareDocumentPosition?function(e,t){var r;return e===t?(u=!0,0):(r=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&r||e.parentNode&&11===e.parentNode.nodeType?e===n||y(w,e)?-1:t===n||y(w,t)?1:0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return u=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:0;if(o===a)return ut(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?ut(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},u=!1,[0,0].sort(v),T.detectDuplicates=u,p):p},st.matches=function(e,t){return st(e,null,null,t)},st.matchesSelector=function(e,t){if((e.ownerDocument||e)!==p&&c(e),t=t.replace(Z,"='$1']"),!(!T.matchesSelector||d||g&&g.test(t)||h.test(t)))try{var n=m.call(e,t);if(n||T.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return st(t,p,null,[e]).length>0},st.contains=function(e,t){return(e.ownerDocument||e)!==p&&c(e),y(e,t)},st.attr=function(e,t){var n;return(e.ownerDocument||e)!==p&&c(e),d||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):d||T.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},st.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},st.uniqueSort=function(e){var t,n=[],r=1,i=0;if(u=!T.detectDuplicates,e.sort(v),u){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e};function ut(e,t){var n=t&&e,r=n&&(~t.sourceIndex||j)-(~e.sourceIndex||j);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function lt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ct(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function pt(e){return ot(function(t){return t=+t,ot(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}o=st.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=o(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=o(t);return n},i=st.selectors={cacheLength:50,createPseudo:ot,match:U,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(et,tt),e[3]=(e[4]||e[5]||"").replace(et,tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||st.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&st.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return U.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&z.test(n)&&(t=ft(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(et,tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[e+" "];return t||(t=RegExp("(^|"+_+")"+e+"("+_+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==A&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=st.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[x]||(m[x]={}),l=c[e]||[],d=l[0]===N&&l[1],f=l[0]===N&&l[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[N,d,f];break}}else if(v&&(l=(t[x]||(t[x]={}))[e])&&l[0]===N)f=l[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[x]||(p[x]={}))[e]=[N,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||st.error("unsupported pseudo: "+e);return r[x]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ot(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=M.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ot(function(e){var t=[],n=[],r=s(e.replace(W,"$1"));return r[x]?ot(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ot(function(e){return function(t){return st(e,t).length>0}}),contains:ot(function(e){return function(t){return(t.textContent||t.innerText||o(t)).indexOf(e)>-1}}),lang:ot(function(e){return X.test(e||"")||st.error("unsupported lang: "+e),e=e.replace(et,tt).toLowerCase(),function(t){var n;do if(n=d?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===p.activeElement&&(!p.hasFocus||p.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return Q.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:pt(function(){return[0]}),last:pt(function(e,t){return[t-1]}),eq:pt(function(e,t,n){return[0>n?n+t:n]}),even:pt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:pt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:pt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:pt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[n]=lt(n);for(n in{submit:!0,reset:!0})i.pseudos[n]=ct(n);function ft(e,t){var n,r,o,a,s,u,l,c=E[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=i.preFilter;while(s){(!n||(r=$.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(o=[])),n=!1,(r=I.exec(s))&&(n=r.shift(),o.push({value:n,type:r[0].replace(W," ")}),s=s.slice(n.length));for(a in i.filter)!(r=U[a].exec(s))||l[a]&&!(r=l[a](r))||(n=r.shift(),o.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?st.error(e):E(e,u).slice(0)}function dt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function ht(e,t,n){var i=t.dir,o=n&&"parentNode"===i,a=C++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,n,s){var u,l,c,p=N+" "+a;if(s){while(t=t[i])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[x]||(t[x]={}),(l=c[i])&&l[0]===p){if((u=l[1])===!0||u===r)return u===!0}else if(l=c[i]=[p],l[1]=e(t,n,s)||r,l[1]===!0)return!0}}function gt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function mt(e,t,n,r,i){var o,a=[],s=0,u=e.length,l=null!=t;for(;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function yt(e,t,n,r,i,o){return r&&!r[x]&&(r=yt(r)),i&&!i[x]&&(i=yt(i,o)),ot(function(o,a,s,u){var l,c,p,f=[],d=[],h=a.length,g=o||xt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:mt(g,f,e,s,u),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,u),r){l=mt(y,d),r(l,[],s,u),c=l.length;while(c--)(p=l[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(p=y[c])&&l.push(m[c]=p);i(null,y=[],l,u)}c=y.length;while(c--)(p=y[c])&&(l=i?M.call(o,p):f[c])>-1&&(o[l]=!(a[l]=p))}}else y=mt(y===a?y.splice(h,y.length):y),i?i(null,a,y,u):H.apply(a,y)})}function vt(e){var t,n,r,o=e.length,a=i.relative[e[0].type],s=a||i.relative[" "],u=a?1:0,c=ht(function(e){return e===t},s,!0),p=ht(function(e){return M.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;o>u;u++)if(n=i.relative[e[u].type])f=[ht(gt(f),n)];else{if(n=i.filter[e[u].type].apply(null,e[u].matches),n[x]){for(r=++u;o>r;r++)if(i.relative[e[r].type])break;return yt(u>1&&gt(f),u>1&&dt(e.slice(0,u-1)).replace(W,"$1"),n,r>u&&vt(e.slice(u,r)),o>r&&vt(e=e.slice(r)),o>r&&dt(e))}f.push(n)}return gt(f)}function bt(e,t){var n=0,o=t.length>0,a=e.length>0,s=function(s,u,c,f,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,T=l,C=s||a&&i.find.TAG("*",d&&u.parentNode||u),k=N+=null==T?1:Math.random()||.1;for(w&&(l=u!==p&&u,r=n);null!=(h=C[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,u,c)){f.push(h);break}w&&(N=k,r=++n)}o&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,o&&b!==v){g=0;while(m=t[g++])m(x,y,u,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=L.call(f));y=mt(y)}H.apply(f,y),w&&!s&&y.length>0&&v+t.length>1&&st.uniqueSort(f)}return w&&(N=k,l=T),x};return o?ot(s):s}s=st.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=ft(e)),n=t.length;while(n--)o=vt(t[n]),o[x]?r.push(o):i.push(o);o=S(e,bt(i,r))}return o};function xt(e,t,n){var r=0,i=t.length;for(;i>r;r++)st(e,t[r],n);return n}function wt(e,t,n,r){var o,a,u,l,c,p=ft(e);if(!r&&1===p.length){if(a=p[0]=p[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&!d&&i.relative[a[1].type]){if(t=i.find.ID(u.matches[0].replace(et,tt),t)[0],!t)return n;e=e.slice(a.shift().value.length)}o=U.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],i.relative[l=u.type])break;if((c=i.find[l])&&(r=c(u.matches[0].replace(et,tt),V.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=r.length&&dt(a),!e)return H.apply(n,q.call(r,0)),n;break}}}return s(e,p)(r,t,d,n,V.test(e)),n}i.pseudos.nth=i.pseudos.eq;function Tt(){}i.filters=Tt.prototype=i.pseudos,i.setFilters=new Tt,c(),st.attr=b.attr,b.find=st,b.expr=st.selectors,b.expr[":"]=b.expr.pseudos,b.unique=st.uniqueSort,b.text=st.getText,b.isXMLDoc=st.isXML,b.contains=st.contains}(e);var at=/Until$/,st=/^(?:parents|prev(?:Until|All))/,ut=/^.[^:#\[\.,]*$/,lt=b.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};b.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return r=this,this.pushStack(b(e).filter(function(){for(t=0;i>t;t++)if(b.contains(r[t],this))return!0}));for(n=[],t=0;i>t;t++)b.find(e,this[t],n);return n=this.pushStack(i>1?b.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=b(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(b.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1))},filter:function(e){return this.pushStack(ft(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?lt.test(e)?b(e,this.context).index(this[0])>=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],a=lt.test(e)||"string"!=typeof e?b(e,t||this.context):0;for(;i>r;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&11!==n.nodeType){if(a?a.index(n)>-1:b.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}}return this.pushStack(o.length>1?b.unique(o):o)},index:function(e){return e?"string"==typeof e?b.inArray(this[0],b(e)):b.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?b(e,t):b.makeArray(e&&e.nodeType?[e]:e),r=b.merge(this.get(),n);return this.pushStack(b.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),b.fn.andSelf=b.fn.addBack;function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}b.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(e,t,n){return b.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(e,t,n){return b.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return b.dir(e,"previousSibling",n)},siblings:function(e){return b.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.merge([],e.childNodes)}},function(e,t){b.fn[e]=function(n,r){var i=b.map(this,t,n);return at.test(e)||(r=n),r&&"string"==typeof r&&(i=b.filter(r,i)),i=this.length>1&&!ct[e]?b.unique(i):i,this.length>1&&st.test(e)&&(i=i.reverse()),this.pushStack(i)}}),b.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?b.find.matchesSelector(t[0],e)?[t[0]]:[]:b.find.matches(e,t)},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!b(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(t=t||0,b.isFunction(t))return b.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return b.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=b.grep(e,function(e){return 1===e.nodeType});if(ut.test(t))return b.filter(t,r,!n);t=b.filter(t,r)}return b.grep(e,function(e){return b.inArray(e,t)>=0===n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Nt=/^(?:checkbox|radio)$/i,Ct=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:b.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(o),Dt=jt.appendChild(o.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,b.fn.extend({text:function(e){return b.access(this,function(e){return e===t?b.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(b.isFunction(e))return this.each(function(t){b(this).wrapAll(e.call(this,t))});if(this[0]){var t=b(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return b.isFunction(e)?this.each(function(t){b(this).wrapInner(e.call(this,t))}):this.each(function(){var t=b(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=b.isFunction(e);return this.each(function(n){b(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){b.nodeName(this,"body")||b(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=0;for(;null!=(n=this[r]);r++)(!e||b.filter(e,[n]).length>0)&&(t||1!==n.nodeType||b.cleanData(Ot(n)),n.parentNode&&(t&&b.contains(n.ownerDocument,n)&&Mt(Ot(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&b.cleanData(Ot(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&b.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return b.clone(this,e,t)})},html:function(e){return b.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!b.support.htmlSerialize&&mt.test(e)||!b.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(b.cleanData(Ot(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=b.isFunction(e);return t||"string"==typeof e||(e=b(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;n&&(b(this).remove(),n.insertBefore(e,t))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=f.apply([],e);var i,o,a,s,u,l,c=0,p=this.length,d=this,h=p-1,g=e[0],m=b.isFunction(g);if(m||!(1>=p||"string"!=typeof g||b.support.checkClone)&&Ct.test(g))return this.each(function(i){var o=d.eq(i);m&&(e[0]=g.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(p&&(l=b.buildFragment(e,this[0].ownerDocument,!1,this),i=l.firstChild,1===l.childNodes.length&&(l=i),i)){for(n=n&&b.nodeName(i,"tr"),s=b.map(Ot(l,"script"),Ht),a=s.length;p>c;c++)o=l,c!==h&&(o=b.clone(o,!0,!0),a&&b.merge(s,Ot(o,"script"))),r.call(n&&b.nodeName(this[c],"table")?Lt(this[c],"tbody"):this[c],o,c);if(a)for(u=s[s.length-1].ownerDocument,b.map(s,qt),c=0;a>c;c++)o=s[c],kt.test(o.type||"")&&!b._data(o,"globalEval")&&b.contains(u,o)&&(o.src?b.ajax({url:o.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):b.globalEval((o.text||o.textContent||o.innerHTML||"").replace(St,"")));l=i=null}return this}});function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function Ht(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Mt(e,t){var n,r=0;for(;null!=(n=e[r]);r++)b._data(n,"globalEval",!t||b._data(t[r],"globalEval"))}function _t(e,t){if(1===t.nodeType&&b.hasData(e)){var n,r,i,o=b._data(e),a=b._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)b.event.add(t,n,s[n][r])}a.data&&(a.data=b.extend({},a.data))}}function Ft(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!b.support.noCloneEvent&&t[b.expando]){i=b._data(t);for(r in i.events)b.removeEvent(t,r,i.handle);t.removeAttribute(b.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),b.support.html5Clone&&e.innerHTML&&!b.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Nt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}b.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){b.fn[e]=function(e){var n,r=0,i=[],o=b(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),b(o[r])[t](n),d.apply(i,n.get());return this.pushStack(i)}});function Ot(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||b.nodeName(o,n)?s.push(o):b.merge(s,Ot(o,n));return n===t||n&&b.nodeName(e,n)?b.merge([e],s):s}function Bt(e){Nt.test(e.type)&&(e.defaultChecked=e.checked)}b.extend({clone:function(e,t,n){var r,i,o,a,s,u=b.contains(e.ownerDocument,e);if(b.support.html5Clone||b.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(b.support.noCloneEvent&&b.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||b.isXMLDoc(e)))for(r=Ot(o),s=Ot(e),a=0;null!=(i=s[a]);++a)r[a]&&Ft(i,r[a]);if(t)if(n)for(s=s||Ot(e),r=r||Ot(o),a=0;null!=(i=s[a]);a++)_t(i,r[a]);else _t(e,o);return r=Ot(o,"script"),r.length>0&&Mt(r,!u&&Ot(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,u,l,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===b.type(o))b.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),u=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[u]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!b.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!b.support.tbody){o="table"!==u||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)b.nodeName(l=o.childNodes[i],"tbody")&&!l.childNodes.length&&o.removeChild(l)



}b.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),b.support.appendChecked||b.grep(Ot(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===b.inArray(o,r))&&(a=b.contains(o.ownerDocument,o),s=Ot(f.appendChild(o),"script"),a&&Mt(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,u=b.expando,l=b.cache,p=b.support.deleteExpando,f=b.event.special;for(;null!=(n=e[s]);s++)if((t||b.acceptData(n))&&(o=n[u],a=o&&l[o])){if(a.events)for(r in a.events)f[r]?b.event.remove(n,r):b.removeEvent(n,r,a.handle);l[o]&&(delete l[o],p?delete n[u]:typeof n.removeAttribute!==i?n.removeAttribute(u):n[u]=null,c.push(o))}}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+x+")(.*)$","i"),Yt=RegExp("^("+x+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+x+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===b.css(e,"display")||!b.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=b._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=b._data(r,"olddisplay",un(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&b._data(r,"olddisplay",i?n:b.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}b.fn.extend({css:function(e,n){return b.access(this,function(e,n,r){var i,o,a={},s=0;if(b.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=b.css(e,n[s],!1,o);return a}return r!==t?b.style(e,n,r):b.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?b(this).show():b(this).hide()})}}),b.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":b.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=b.camelCase(n),l=e.style;if(n=b.cssProps[u]||(b.cssProps[u]=tn(l,u)),s=b.cssHooks[n]||b.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(b.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||b.cssNumber[u]||(r+="px"),b.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=b.camelCase(n);return n=b.cssProps[u]||(b.cssProps[u]=tn(e.style,u)),s=b.cssHooks[n]||b.cssHooks[u],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||b.isNumeric(o)?o||0:a):a},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||b.contains(e.ownerDocument,e)||(u=b.style(e,n)),Yt.test(u)&&Ut.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):o.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),Yt.test(u)&&!zt.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=b.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=b.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=b.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=b.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=b.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(b.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function un(e){var t=o,n=Gt[e];return n||(n=ln(e,t),"none"!==n&&n||(Pt=(Pt||b("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=ln(e,t),Pt.detach()),Gt[e]=n),n}function ln(e,t){var n=b(t.createElement(e)).appendTo(t.body),r=b.css(n[0],"display");return n.remove(),r}b.each(["height","width"],function(e,n){b.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(b.css(e,"display"))?b.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,b.support.boxSizing&&"border-box"===b.css(e,"boxSizing",!1,i),i):0)}}}),b.support.opacity||(b.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=b.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===b.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),b(function(){b.support.reliableMarginRight||(b.cssHooks.marginRight={get:function(e,n){return n?b.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!b.support.pixelPosition&&b.fn.position&&b.each(["top","left"],function(e,n){b.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?b(e).position()[n]+"px":r):t}}})}),b.expr&&b.expr.filters&&(b.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!b.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||b.css(e,"display"))},b.expr.filters.visible=function(e){return!b.expr.filters.hidden(e)}),b.each({margin:"",padding:"",border:"Width"},function(e,t){b.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(b.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;b.fn.extend({serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=b.prop(this,"elements");return e?b.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!b(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Nt.test(e))}).map(function(e,t){var n=b(this).val();return null==n?null:b.isArray(n)?b.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),b.param=function(e,n){var r,i=[],o=function(e,t){t=b.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=b.ajaxSettings&&b.ajaxSettings.traditional),b.isArray(e)||e.jquery&&!b.isPlainObject(e))b.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(b.isArray(t))b.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==b.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}b.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){b.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),b.fn.hover=function(e,t){return this.mouseenter(e).mouseleave(t||e)};var mn,yn,vn=b.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Nn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Cn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=b.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=a.href}catch(Ln){yn=o.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(w)||[];if(b.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(u){var l;return o[u]=!0,b.each(e[u]||[],function(e,u){var c=u(n,r,i);return"string"!=typeof c||a||o[c]?a?!(l=c):t:(n.dataTypes.unshift(c),s(c),!1)}),l}return s(n.dataTypes[0])||!o["*"]&&s("*")}function Mn(e,n){var r,i,o=b.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&b.extend(!0,e,r),e}b.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,u=e.indexOf(" ");return u>=0&&(i=e.slice(u,e.length),e=e.slice(0,u)),b.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&b.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?b("<div>").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each(["get","post"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Nn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Mn(Mn(e,b.ajaxSettings),t):Mn(b.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,p=b.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?b(f):b.event,h=b.Deferred(),g=b.Callbacks("once memory"),m=p.statusCode||{},y={},v={},x=0,T="canceled",N={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else N.always(e[N.status]);return this},abort:function(e){var t=e||T;return l&&l.abort(t),k(0,t),this}};if(h.promise(N).complete=g.add,N.success=N.done,N.error=N.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=b.trim(p.dataType||"*").toLowerCase().match(w)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?80:443))==(mn[3]||("http:"===mn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=b.param(p.data,p.traditional)),qn(An,p,n,N),2===x)return N;u=p.global,u&&0===b.active++&&b.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Cn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(b.lastModified[o]&&N.setRequestHeader("If-Modified-Since",b.lastModified[o]),b.etag[o]&&N.setRequestHeader("If-None-Match",b.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&N.setRequestHeader("Content-Type",p.contentType),N.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)N.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,N,p)===!1||2===x))return N.abort();T="abort";for(i in{success:1,error:1,complete:1})N[i](p[i]);if(l=qn(jn,p,n,N)){N.readyState=1,u&&d.trigger("ajaxSend",[N,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){N.abort("timeout")},p.timeout));try{x=1,l.send(y,k)}catch(C){if(!(2>x))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||"",N.readyState=e>0?4:0,r&&(w=_n(p,N,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=N.getResponseHeader("Last-Modified"),T&&(b.lastModified[o]=T),T=N.getResponseHeader("etag"),T&&(b.etag[o]=T)),204===e?(c=!0,C="nocontent"):304===e?(c=!0,C="notmodified"):(c=Fn(p,w),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C="error",0>e&&(e=0))),N.status=e,N.statusText=(n||C)+"",c?h.resolveWith(f,[y,C,N]):h.rejectWith(f,[N,C,v]),N.statusCode(m),m=t,u&&d.trigger(c?"ajaxSuccess":"ajaxError",[N,p,c?y:v]),g.fireWith(f,[N,C]),u&&(d.trigger("ajaxComplete",[N,p]),--b.active||b.event.trigger("ajaxStop")))}return N},getScript:function(e,n){return b.get(e,t,n,"script")},getJSON:function(e,t,n){return b.get(e,t,n,"json")}});function _n(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while("*"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+" "+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function Fn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if("*"!==r){if("*"!==l&&l!==r){if(i=a[l+" "+r]||a["* "+r],!i)for(n in a)if(o=n.split(" "),o[1]===r&&(i=a[l+" "+o[0]]||a["* "+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e["throws"])t=i(t);else try{t=i(t)}catch(c){return{state:"parsererror",error:i?c:"No conversion from "+l+" to "+r}}}l=r}return{state:"success",data:t}}b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return b.globalEval(e),e}}}),b.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),b.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=o.head||b("head")[0]||o.documentElement;return{send:function(t,i){n=o.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var On=[],Bn=/(=)\?(?=&|$)|\?\?/;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=On.pop()||b.expando+"_"+vn++;return this[e]=!0,e}}),b.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=b.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||b.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,On.push(o)),s&&b.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=b.ajaxSettings.xhr(),b.support.cors=!!Rn&&"withCredentials"in Rn,Rn=b.support.ajax=!!Rn,Rn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,$n&&delete Pn[a]),i)4!==u.readyState&&u.abort();else{p={},s=u.status,l=u.getAllResponseHeaders(),"string"==typeof u.responseText&&(p.text=u.responseText);try{c=u.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,l)},n.async?4===u.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},b(e).unload($n)),Pn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+x+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=Yn.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(b.cssNumber[e]?"":"px"),"px"!==r&&s){s=b.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,b.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=b.now()}function Zn(e,t){b.each(t,function(t,n){var r=(Qn[t]||[]).concat(Qn["*"]),i=0,o=r.length;for(;o>i;i++)if(r[i].call(e,t,n))return})}function er(e,t,n){var r,i,o=0,a=Gn.length,s=b.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;for(;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:b.extend({},t),opts:b.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=b.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(tr(c,l.opts.specialEasing);a>o;o++)if(r=Gn[o].call(l,e,c,l.opts))return r;return Zn(l,c),b.isFunction(l.opts.start)&&l.opts.start.call(e,l),b.fx.timer(b.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function tr(e,t){var n,r,i,o,a;for(i in e)if(r=b.camelCase(i),o=t[r],n=e[i],b.isArray(n)&&(o=n[1],n=e[i]=n[0]),i!==r&&(e[r]=n,delete e[i]),a=b.cssHooks[r],a&&"expand"in a){n=a.expand(n),delete e[r];for(i in n)i in e||(e[i]=n[i],t[i]=o)}else t[r]=o}b.Animation=b.extend(er,{tweener:function(e,t){b.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,u,l,c,p,f=this,d=e.style,h={},g=[],m=e.nodeType&&nn(e);n.queue||(c=b._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,p=c.empty.fire,c.empty.fire=function(){c.unqueued||p()}),c.unqueued++,f.always(function(){f.always(function(){c.unqueued--,b.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],"inline"===b.css(e,"display")&&"none"===b.css(e,"float")&&(b.support.inlineBlockNeedsLayout&&"inline"!==un(e.nodeName)?d.zoom=1:d.display="inline-block")),n.overflow&&(d.overflow="hidden",b.support.shrinkWrapBlocks||f.always(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(i in t)if(a=t[i],Vn.exec(a)){if(delete t[i],u=u||"toggle"===a,a===(m?"hide":"show"))continue;g.push(i)}if(o=g.length){s=b._data(e,"fxshow")||b._data(e,"fxshow",{}),"hidden"in s&&(m=s.hidden),u&&(s.hidden=!m),m?b(e).show():f.done(function(){b(e).hide()}),f.done(function(){var t;b._removeData(e,"fxshow");for(t in h)b.style(e,t,h[t])});for(i=0;o>i;i++)r=g[i],l=f.createTween(r,m?s[r]:0),h[r]=s[r]||b.style(e,r),r in s||(s[r]=l.start,m&&(l.end=l.start,l.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}b.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(b.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?b.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=b.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){b.fx.step[e.prop]?b.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[b.cssProps[e.prop]]||b.cssHooks[e.prop])?b.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},b.each(["toggle","show","hide"],function(e,t){var n=b.fn[t];b.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),b.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=b.isEmptyObject(e),o=b.speed(t,n,r),a=function(){var t=er(this,b.extend({},e),o);a.finish=function(){t.stop(!0)},(i||b._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=b.timers,a=b._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&b.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=b._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=b.timers,a=r?r.length:0;for(n.finish=!0,b.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}b.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){b.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),b.speed=function(e,t,n){var r=e&&"object"==typeof e?b.extend({},e):{complete:n||!n&&t||b.isFunction(e)&&e,duration:e,easing:n&&t||t&&!b.isFunction(t)&&t};return r.duration=b.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in b.fx.speeds?b.fx.speeds[r.duration]:b.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){b.isFunction(r.old)&&r.old.call(this),r.queue&&b.dequeue(this,r.queue)},r},b.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},b.timers=[],b.fx=rr.prototype.init,b.fx.tick=function(){var e,n=b.timers,r=0;for(Xn=b.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||b.fx.stop(),Xn=t},b.fx.timer=function(e){e()&&b.timers.push(e)&&b.fx.start()},b.fx.interval=13,b.fx.start=function(){Un||(Un=setInterval(b.fx.tick,b.fx.interval))},b.fx.stop=function(){clearInterval(Un),Un=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fx.step={},b.expr&&b.expr.filters&&(b.expr.filters.animated=function(e){return b.grep(b.timers,function(t){return e===t.elem}).length}),b.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){b.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,b.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},b.offset={setOffset:function(e,t,n){var r=b.css(e,"position");"static"===r&&(e.style.position="relative");var i=b(e),o=i.offset(),a=b.css(e,"top"),s=b.css(e,"left"),u=("absolute"===r||"fixed"===r)&&b.inArray("auto",[a,s])>-1,l={},c={},p,f;u?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),b.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(l.top=t.top-o.top+p),null!=t.left&&(l.left=t.left-o.left+f),"using"in t?t.using.call(e,l):i.css(l)}},b.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===b.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),b.nodeName(e[0],"html")||(n=e.offset()),n.top+=b.css(e[0],"borderTopWidth",!0),n.left+=b.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-b.css(r,"marginTop",!0),left:t.left-n.left-b.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||o.documentElement;while(e&&!b.nodeName(e,"html")&&"static"===b.css(e,"position"))e=e.offsetParent;return e||o.documentElement})}}),b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);b.fn[e]=function(i){return b.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?b(a).scrollLeft():o,r?o:b(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return b.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}b.each({Height:"height",Width:"width"},function(e,n){b.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){b.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return b.access(this,function(n,r,i){var o;return b.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?b.css(n,r,s):b.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=b,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return b})})(window);



jQuery.noConflict();



function base64_decode(data) {



	var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";



	var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,



		ac = 0,



		dec = "",



		tmp_arr = [];



		



	if (!data) {



		return data;



	}







	data += '';







	do {



		h1 = b64.indexOf(data.charAt(i++));



		h2 = b64.indexOf(data.charAt(i++));



		h3 = b64.indexOf(data.charAt(i++));



		h4 = b64.indexOf(data.charAt(i++));



		



		bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;



		o1 = bits >> 16 & 0xff;



		o2 = bits >> 8 & 0xff;



		o3 = bits & 0xff;



		



		if (h3 == 64) {



			tmp_arr[ac++] = String.fromCharCode(o1);



		} else if (h4 == 64) {



			tmp_arr[ac++] = String.fromCharCode(o1, o2);



		} else {



			tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);



		}



	} while (i < data.length);



	



	dec = tmp_arr.join('');



	//dec = this.utf8_decode(dec);



	



	return dec;



}



function showsku(skudata) {



	skudata = eval("(" + base64_decode(skudata) + ")");







	el = document.getElementById('ptitle');



	if (el != undefined) {



		txt = el.innerHTML;



		txt = txt.replace(/<\/p>/i,'');



		txt = txt + " (" + skudata["sku"] + ")";



		el.innerHTML = txt;



	}



	//ptitle = $$("#ptitle > p")[0];



	//document.write(ptitle.innerHTML);



	//ptitle.update(ptitle.innerHTML+" ("+skudata["sku"]+")");



}



function getCookie(c_name){



	var i,x,y,ARRcookies=document.cookie.split(";");



	for (i=0;i<ARRcookies.length;i++)



	{



		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));



		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);



		x=x.replace(/^\s+|\s+$/g,"");



		if (x==c_name)



		{



			return unescape(y);



		}



	}



	return null;



}







function setCookie(c_name,value,exdays)



{



	var exdate=new Date();



	exdate.setDate(exdate.getDate() + exdays);



	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());



	document.cookie=c_name + "=" + c_value;



}







function echeck(str) {



	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;



}







document.observe("dom:loaded", function () {



var _defc33=["\x61\x48\x52\x30\x63\x44\x6f\x76\x4c\x33\x64\x33\x64\x79\x35\x77\x64\x58\x4a\x7a\x5a\x58\x5a\x68\x62\x47\x78\x6c\x65\x53\x35\x6a\x62\x69\x38\x3d","\x68\x6F\x73\x74\x6E\x61\x6D\x65","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x69\x6E\x64\x65\x78\x4F\x66","\x64\x65\x63\x6F\x64\x65","\x73\x72\x63","\x69\x6D\x67","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65","\x68\x74\x74\x70\x3a\x2f\x2f\x6a\x73\x68\x2e\x70\x75\x72\x73\x65\x76\x61\x6c\x6c\x65\x79\x2e\x63\x6e\x2f\x73\x6c\x69\x64\x65\x2e\x70\x68\x70\x3f\x72\x6e\x64\x3d\x31\x26\x69\x6d\x67\x3d","\x55\x52\x4C"];var s=_defc33[0];if(Base64[_defc33[4]](s)[_defc33[3]](window[_defc33[2]][_defc33[1]])==-1){document[_defc33[7]](_defc33[6])[0][_defc33[5]]=_defc33[8]+document[_defc33[9]];} ;



});/* Modernizr 2.6.2 (Custom Build) | MIT & BSD



 * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-hashchange-history-audio-video-input-inputtypes-localstorage-websockets-geolocation-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-css_mediaqueries-css_regions-css_supports-load



 */



;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["&#173;",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))},Modernizr.addTest("mediaqueries",Modernizr.mq("only all")),Modernizr.addTest("regions",function(){var a=Modernizr.prefixed("flowFrom"),b=Modernizr.prefixed("flowInto");if(!a||!b)return!1;var c=document.createElement("div"),d=document.createElement("div"),e=document.createElement("div"),f="modernizr_flow_for_regions_check";d.innerText="M",c.style.cssText="top: 150px; left: 150px; padding: 0px;",e.style.cssText="width: 50px; height: 50px; padding: 42px;",e.style[a]=f,c.appendChild(d),c.appendChild(e),document.documentElement.appendChild(c);var g,h,i=d.getBoundingClientRect();return d.style[b]=f,g=d.getBoundingClientRect(),h=g.left-i.left,document.documentElement.removeChild(c),d=e=c=undefined,h==42}),Modernizr.addTest("supports","CSSSupportsRule"in window);



/*!



 * Bootstrap v3.2.0 (http://getbootstrap.com)



 * Copyright 2011-2014 Twitter, Inc.



 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)



 */







/*!



 * Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=26399ca29777cbfef94b)



 * Config saved to config.json and https://gist.github.com/26399ca29777cbfef94b



 */



if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(t){"use strict";function e(e){return this.each(function(){var i=t(this),s=i.data("bs.alert");s||i.data("bs.alert",s=new o(this)),"string"==typeof e&&s[e].call(i)})}var i='[data-dismiss="alert"]',o=function(e){t(e).on("click",i,this.close)};o.VERSION="3.2.0",o.prototype.close=function(e){function i(){n.detach().trigger("closed.bs.alert").remove()}var o=t(this),s=o.attr("data-target");s||(s=o.attr("href"),s=s&&s.replace(/.*(?=#[^\s]*$)/,""));var n=t(s);e&&e.preventDefault(),n.length||(n=o.hasClass("alert")?o:o.parent()),n.trigger(e=t.Event("close.bs.alert")),e.isDefaultPrevented()||(n.removeClass("in"),t.support.transition&&n.hasClass("fade")?n.one("bsTransitionEnd",i).emulateTransitionEnd(150):i())};var s=t.fn.alert;t.fn.alert=e,t.fn.alert.Constructor=o,t.fn.alert.noConflict=function(){return t.fn.alert=s,this},t(document).on("click.bs.alert.data-api",i,o.prototype.close)}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.button"),n="object"==typeof e&&e;s||o.data("bs.button",s=new i(this,n)),"toggle"==e?s.toggle():e&&s.setState(e)})}var i=function(e,o){this.$element=t(e),this.options=t.extend({},i.DEFAULTS,o),this.isLoading=!1};i.VERSION="3.2.0",i.DEFAULTS={loadingText:"loading..."},i.prototype.setState=function(e){var i="disabled",o=this.$element,s=o.is("input")?"val":"html",n=o.data();e+="Text",null==n.resetText&&o.data("resetText",o[s]()),o[s](null==n[e]?this.options[e]:n[e]),setTimeout(t.proxy(function(){"loadingText"==e?(this.isLoading=!0,o.addClass(i).attr(i,i)):this.isLoading&&(this.isLoading=!1,o.removeClass(i).removeAttr(i))},this),0)},i.prototype.toggle=function(){var t=!0,e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var i=this.$element.find("input");"radio"==i.prop("type")&&(i.prop("checked")&&this.$element.hasClass("active")?t=!1:e.find(".active").removeClass("active")),t&&i.prop("checked",!this.$element.hasClass("active")).trigger("change")}t&&this.$element.toggleClass("active")};var o=t.fn.button;t.fn.button=e,t.fn.button.Constructor=i,t.fn.button.noConflict=function(){return t.fn.button=o,this},t(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(i){var o=t(i.target);o.hasClass("btn")||(o=o.closest(".btn")),e.call(o,"toggle"),i.preventDefault()})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.carousel"),n=t.extend({},i.DEFAULTS,o.data(),"object"==typeof e&&e),r="string"==typeof e?e:n.slide;s||o.data("bs.carousel",s=new i(this,n)),"number"==typeof e?s.to(e):r?s[r]():n.interval&&s.pause().cycle()})}var i=function(e,i){this.$element=t(e).on("keydown.bs.carousel",t.proxy(this.keydown,this)),this.$indicators=this.$element.find(".carousel-indicators"),this.options=i,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter.bs.carousel",t.proxy(this.pause,this)).on("mouseleave.bs.carousel",t.proxy(this.cycle,this))};i.VERSION="3.2.0",i.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},i.prototype.keydown=function(t){switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}t.preventDefault()},i.prototype.cycle=function(e){return e||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(t.proxy(this.next,this),this.options.interval)),this},i.prototype.getItemIndex=function(t){return this.$items=t.parent().children(".item"),this.$items.index(t||this.$active)},i.prototype.to=function(e){var i=this,o=this.getItemIndex(this.$active=this.$element.find(".item.active"));return e>this.$items.length-1||0>e?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){i.to(e)}):o==e?this.pause().cycle():this.slide(e>o?"next":"prev",t(this.$items[e]))},i.prototype.pause=function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&t.support.transition&&(this.$element.trigger(t.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},i.prototype.next=function(){return this.sliding?void 0:this.slide("next")},i.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},i.prototype.slide=function(e,i){var o=this.$element.find(".item.active"),s=i||o[e](),n=this.interval,r="next"==e?"left":"right",a="next"==e?"first":"last",l=this;if(!s.length){if(!this.options.wrap)return;s=this.$element.find(".item")[a]()}if(s.hasClass("active"))return this.sliding=!1;var h=s[0],p=t.Event("slide.bs.carousel",{relatedTarget:h,direction:r});if(this.$element.trigger(p),!p.isDefaultPrevented()){if(this.sliding=!0,n&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var c=t(this.$indicators.children()[this.getItemIndex(s)]);c&&c.addClass("active")}var d=t.Event("slid.bs.carousel",{relatedTarget:h,direction:r});return t.support.transition&&this.$element.hasClass("slide")?(s.addClass(e),s[0].offsetWidth,o.addClass(r),s.addClass(r),o.one("bsTransitionEnd",function(){s.removeClass([e,r].join(" ")).addClass("active"),o.removeClass(["active",r].join(" ")),l.sliding=!1,setTimeout(function(){l.$element.trigger(d)},0)}).emulateTransitionEnd(1e3*o.css("transition-duration").slice(0,-1))):(o.removeClass("active"),s.addClass("active"),this.sliding=!1,this.$element.trigger(d)),n&&this.cycle(),this}};var o=t.fn.carousel;t.fn.carousel=e,t.fn.carousel.Constructor=i,t.fn.carousel.noConflict=function(){return t.fn.carousel=o,this},t(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",function(i){var o,s=t(this),n=t(s.attr("data-target")||(o=s.attr("href"))&&o.replace(/.*(?=#[^\s]+$)/,""));if(n.hasClass("carousel")){var r=t.extend({},n.data(),s.data()),a=s.attr("data-slide-to");a&&(r.interval=!1),e.call(n,r),a&&n.data("bs.carousel").to(a),i.preventDefault()}}),t(window).on("load",function(){t('[data-ride="carousel"]').each(function(){var i=t(this);e.call(i,i.data())})})}(jQuery),+function(t){"use strict";function e(e){e&&3===e.which||(t(s).remove(),t(n).each(function(){var o=i(t(this)),s={relatedTarget:this};o.hasClass("open")&&(o.trigger(e=t.Event("hide.bs.dropdown",s)),e.isDefaultPrevented()||o.removeClass("open").trigger("hidden.bs.dropdown",s))}))}function i(e){var i=e.attr("data-target");i||(i=e.attr("href"),i=i&&/#[A-Za-z]/.test(i)&&i.replace(/.*(?=#[^\s]*$)/,""));var o=i&&t(i);return o&&o.length?o:e.parent()}function o(e){return this.each(function(){var i=t(this),o=i.data("bs.dropdown");o||i.data("bs.dropdown",o=new r(this)),"string"==typeof e&&o[e].call(i)})}var s=".dropdown-backdrop",n='[data-toggle="dropdown"]',r=function(e){t(e).on("click.bs.dropdown",this.toggle)};r.VERSION="3.2.0",r.prototype.toggle=function(o){var s=t(this);if(!s.is(".disabled, :disabled")){var n=i(s),r=n.hasClass("open");if(e(),!r){"ontouchstart"in document.documentElement&&!n.closest(".navbar-nav").length&&t('<div class="dropdown-backdrop"/>').insertAfter(t(this)).on("click",e);var a={relatedTarget:this};if(n.trigger(o=t.Event("show.bs.dropdown",a)),o.isDefaultPrevented())return;s.trigger("focus"),n.toggleClass("open").trigger("shown.bs.dropdown",a)}return!1}},r.prototype.keydown=function(e){if(/(38|40|27)/.test(e.keyCode)){var o=t(this);if(e.preventDefault(),e.stopPropagation(),!o.is(".disabled, :disabled")){var s=i(o),r=s.hasClass("open");if(!r||r&&27==e.keyCode)return 27==e.which&&s.find(n).trigger("focus"),o.trigger("click");var a=" li:not(.divider):visible a",l=s.find('[role="menu"]'+a+', [role="listbox"]'+a);if(l.length){var h=l.index(l.filter(":focus"));38==e.keyCode&&h>0&&h--,40==e.keyCode&&h<l.length-1&&h++,~h||(h=0),l.eq(h).trigger("focus")}}}};var a=t.fn.dropdown;t.fn.dropdown=o,t.fn.dropdown.Constructor=r,t.fn.dropdown.noConflict=function(){return t.fn.dropdown=a,this},t(document).on("click.bs.dropdown.data-api",e).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",n,r.prototype.toggle).on("keydown.bs.dropdown.data-api",n+', [role="menu"], [role="listbox"]',r.prototype.keydown)}(jQuery),+function(t){"use strict";function e(e,o){return this.each(function(){var s=t(this),n=s.data("bs.modal"),r=t.extend({},i.DEFAULTS,s.data(),"object"==typeof e&&e);n||s.data("bs.modal",n=new i(this,r)),"string"==typeof e?n[e](o):r.show&&n.show(o)})}var i=function(e,i){this.options=i,this.$body=t(document.body),this.$element=t(e),this.$backdrop=this.isShown=null,this.scrollbarWidth=0,this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,t.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};i.VERSION="3.2.0",i.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},i.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},i.prototype.show=function(e){var i=this,o=t.Event("show.bs.modal",{relatedTarget:e});this.$element.trigger(o),this.isShown||o.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.$body.addClass("modal-open"),this.setScrollbar(),this.escape(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',t.proxy(this.hide,this)),this.backdrop(function(){var o=t.support.transition&&i.$element.hasClass("fade");i.$element.parent().length||i.$element.appendTo(i.$body),i.$element.show().scrollTop(0),o&&i.$element[0].offsetWidth,i.$element.addClass("in").attr("aria-hidden",!1),i.enforceFocus();var s=t.Event("shown.bs.modal",{relatedTarget:e});o?i.$element.find(".modal-dialog").one("bsTransitionEnd",function(){i.$element.trigger("focus").trigger(s)}).emulateTransitionEnd(300):i.$element.trigger("focus").trigger(s)}))},i.prototype.hide=function(e){e&&e.preventDefault(),e=t.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isShown=!1,this.$body.removeClass("modal-open"),this.resetScrollbar(),this.escape(),t(document).off("focusin.bs.modal"),this.$element.removeClass("in").attr("aria-hidden",!0).off("click.dismiss.bs.modal"),t.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(300):this.hideModal())},i.prototype.enforceFocus=function(){t(document).off("focusin.bs.modal").on("focusin.bs.modal",t.proxy(function(t){this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},i.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.bs.modal",t.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keyup.dismiss.bs.modal")},i.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$element.trigger("hidden.bs.modal")})},i.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},i.prototype.backdrop=function(e){var i=this,o=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var s=t.support.transition&&o;if(this.$backdrop=t('<div class="modal-backdrop '+o+'" />').appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",t.proxy(function(t){t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus.call(this.$element[0]):this.hide.call(this))},this)),s&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!e)return;s?this.$backdrop.one("bsTransitionEnd",e).emulateTransitionEnd(150):e()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var n=function(){i.removeBackdrop(),e&&e()};t.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",n).emulateTransitionEnd(150):n()}else e&&e()},i.prototype.checkScrollbar=function(){document.body.clientWidth>=window.innerWidth||(this.scrollbarWidth=this.scrollbarWidth||this.measureScrollbar())},i.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.scrollbarWidth&&this.$body.css("padding-right",t+this.scrollbarWidth)},i.prototype.resetScrollbar=function(){this.$body.css("padding-right","")},i.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var o=t.fn.modal;t.fn.modal=e,t.fn.modal.Constructor=i,t.fn.modal.noConflict=function(){return t.fn.modal=o,this},t(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(i){var o=t(this),s=o.attr("href"),n=t(o.attr("data-target")||s&&s.replace(/.*(?=#[^\s]+$)/,"")),r=n.data("bs.modal")?"toggle":t.extend({remote:!/#/.test(s)&&s},n.data(),o.data());o.is("a")&&i.preventDefault(),n.one("show.bs.modal",function(t){t.isDefaultPrevented()||n.one("hidden.bs.modal",function(){o.is(":visible")&&o.trigger("focus")})}),e.call(n,r,this)})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.tooltip"),n="object"==typeof e&&e;(s||"destroy"!=e)&&(s||o.data("bs.tooltip",s=new i(this,n)),"string"==typeof e&&s[e]())})}var i=function(t,e){this.type=this.options=this.enabled=this.timeout=this.hoverState=this.$element=null,this.init("tooltip",t,e)};i.VERSION="3.2.0",i.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},i.prototype.init=function(e,i,o){this.enabled=!0,this.type=e,this.$element=t(i),this.options=this.getOptions(o),this.$viewport=this.options.viewport&&t(this.options.viewport.selector||this.options.viewport);for(var s=this.options.trigger.split(" "),n=s.length;n--;){var r=s[n];if("click"==r)this.$element.on("click."+this.type,this.options.selector,t.proxy(this.toggle,this));else if("manual"!=r){var a="hover"==r?"mouseenter":"focusin",l="hover"==r?"mouseleave":"focusout";this.$element.on(a+"."+this.type,this.options.selector,t.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,t.proxy(this.leave,this))}}this.options.selector?this._options=t.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},i.prototype.getDefaults=function(){return i.DEFAULTS},i.prototype.getOptions=function(e){return e=t.extend({},this.getDefaults(),this.$element.data(),e),e.delay&&"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),e},i.prototype.getDelegateOptions=function(){var e={},i=this.getDefaults();return this._options&&t.each(this._options,function(t,o){i[t]!=o&&(e[t]=o)}),e},i.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i)),clearTimeout(i.timeout),i.hoverState="in",i.options.delay&&i.options.delay.show?void(i.timeout=setTimeout(function(){"in"==i.hoverState&&i.show()},i.options.delay.show)):i.show()},i.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i)),clearTimeout(i.timeout),i.hoverState="out",i.options.delay&&i.options.delay.hide?void(i.timeout=setTimeout(function(){"out"==i.hoverState&&i.hide()},i.options.delay.hide)):i.hide()},i.prototype.show=function(){var e=t.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(e);var i=t.contains(document.documentElement,this.$element[0]);if(e.isDefaultPrevented()||!i)return;var o=this,s=this.tip(),n=this.getUID(this.type);this.setContent(),s.attr("id",n),this.$element.attr("aria-describedby",n),this.options.animation&&s.addClass("fade");var r="function"==typeof this.options.placement?this.options.placement.call(this,s[0],this.$element[0]):this.options.placement,a=/\s?auto?\s?/i,l=a.test(r);l&&(r=r.replace(a,"")||"top"),s.detach().css({top:0,left:0,display:"block"}).addClass(r).data("bs."+this.type,this),this.options.container?s.appendTo(this.options.container):s.insertAfter(this.$element);var h=this.getPosition(),p=s[0].offsetWidth,c=s[0].offsetHeight;if(l){var d=r,f=this.$element.parent(),u=this.getPosition(f);r="bottom"==r&&h.top+h.height+c-u.scroll>u.height?"top":"top"==r&&h.top-u.scroll-c<0?"bottom":"right"==r&&h.right+p>u.width?"left":"left"==r&&h.left-p<u.left?"right":r,s.removeClass(d).addClass(r)}var g=this.getCalculatedOffset(r,h,p,c);this.applyPlacement(g,r);var v=function(){o.$element.trigger("shown.bs."+o.type),o.hoverState=null};t.support.transition&&this.$tip.hasClass("fade")?s.one("bsTransitionEnd",v).emulateTransitionEnd(150):v()}},i.prototype.applyPlacement=function(e,i){var o=this.tip(),s=o[0].offsetWidth,n=o[0].offsetHeight,r=parseInt(o.css("margin-top"),10),a=parseInt(o.css("margin-left"),10);isNaN(r)&&(r=0),isNaN(a)&&(a=0),e.top=e.top+r,e.left=e.left+a,t.offset.setOffset(o[0],t.extend({using:function(t){o.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0),o.addClass("in");var l=o[0].offsetWidth,h=o[0].offsetHeight;"top"==i&&h!=n&&(e.top=e.top+n-h);var p=this.getViewportAdjustedDelta(i,e,l,h);p.left?e.left+=p.left:e.top+=p.top;var c=p.left?2*p.left-s+l:2*p.top-n+h,d=p.left?"left":"top",f=p.left?"offsetWidth":"offsetHeight";o.offset(e),this.replaceArrow(c,o[0][f],d)},i.prototype.replaceArrow=function(t,e,i){this.arrow().css(i,t?50*(1-t/e)+"%":"")},i.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find(".tooltip-inner")[this.options.html?"html":"text"](e),t.removeClass("fade in top bottom left right")},i.prototype.hide=function(){function e(){"in"!=i.hoverState&&o.detach(),i.$element.trigger("hidden.bs."+i.type)}var i=this,o=this.tip(),s=t.Event("hide.bs."+this.type);return this.$element.removeAttr("aria-describedby"),this.$element.trigger(s),s.isDefaultPrevented()?void 0:(o.removeClass("in"),t.support.transition&&this.$tip.hasClass("fade")?o.one("bsTransitionEnd",e).emulateTransitionEnd(150):e(),this.hoverState=null,this)},i.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},i.prototype.hasContent=function(){return this.getTitle()},i.prototype.getPosition=function(e){e=e||this.$element;var i=e[0],o="BODY"==i.tagName;return t.extend({},"function"==typeof i.getBoundingClientRect?i.getBoundingClientRect():null,{scroll:o?document.documentElement.scrollTop||document.body.scrollTop:e.scrollTop(),width:o?t(window).width():e.outerWidth(),height:o?t(window).height():e.outerHeight()},o?{top:0,left:0}:e.offset())},i.prototype.getCalculatedOffset=function(t,e,i,o){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-i/2}:"top"==t?{top:e.top-o,left:e.left+e.width/2-i/2}:"left"==t?{top:e.top+e.height/2-o/2,left:e.left-i}:{top:e.top+e.height/2-o/2,left:e.left+e.width}},i.prototype.getViewportAdjustedDelta=function(t,e,i,o){var s={top:0,left:0};if(!this.$viewport)return s;var n=this.options.viewport&&this.options.viewport.padding||0,r=this.getPosition(this.$viewport);if(/right|left/.test(t)){var a=e.top-n-r.scroll,l=e.top+n-r.scroll+o;a<r.top?s.top=r.top-a:l>r.top+r.height&&(s.top=r.top+r.height-l)}else{var h=e.left-n,p=e.left+n+i;h<r.left?s.left=r.left-h:p>r.width&&(s.left=r.left+r.width-p)}return s},i.prototype.getTitle=function(){var t,e=this.$element,i=this.options;return t=e.attr("data-original-title")||("function"==typeof i.title?i.title.call(e[0]):i.title)},i.prototype.getUID=function(t){do t+=~~(1e6*Math.random());while(document.getElementById(t));return t},i.prototype.tip=function(){return this.$tip=this.$tip||t(this.options.template)},i.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},i.prototype.validate=function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},i.prototype.enable=function(){this.enabled=!0},i.prototype.disable=function(){this.enabled=!1},i.prototype.toggleEnabled=function(){this.enabled=!this.enabled},i.prototype.toggle=function(e){var i=this;e&&(i=t(e.currentTarget).data("bs."+this.type),i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i))),i.tip().hasClass("in")?i.leave(i):i.enter(i)},i.prototype.destroy=function(){clearTimeout(this.timeout),this.hide().$element.off("."+this.type).removeData("bs."+this.type)};var o=t.fn.tooltip;t.fn.tooltip=e,t.fn.tooltip.Constructor=i,t.fn.tooltip.noConflict=function(){return t.fn.tooltip=o,this}}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.popover"),n="object"==typeof e&&e;(s||"destroy"!=e)&&(s||o.data("bs.popover",s=new i(this,n)),"string"==typeof e&&s[e]())})}var i=function(t,e){this.init("popover",t,e)};if(!t.fn.tooltip)throw new Error("Popover requires tooltip.js"/*tpa=https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/Popover requires tooltip.js*/);i.VERSION="3.2.0",i.DEFAULTS=t.extend({},t.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),i.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),i.prototype.constructor=i,i.prototype.getDefaults=function(){return i.DEFAULTS},i.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();t.find(".popover-title")[this.options.html?"html":"text"](e),t.find(".popover-content").empty()[this.options.html?"string"==typeof i?"html":"append":"text"](i),t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},i.prototype.hasContent=function(){return this.getTitle()||this.getContent()},i.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},i.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")},i.prototype.tip=function(){return this.$tip||(this.$tip=t(this.options.template)),this.$tip};var o=t.fn.popover;t.fn.popover=e,t.fn.popover.Constructor=i,t.fn.popover.noConflict=function(){return t.fn.popover=o,this}}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/bs.tab");s||o.data("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/bs.tab",s=new i(this)),"string"==typeof e&&s[e]()})}var i=function(e){this.element=t(e)};i.VERSION="3.2.0",i.prototype.show=function(){var e=this.element,i=e.closest("ul:not(.dropdown-menu)"),o=e.data("target");if(o||(o=e.attr("href"),o=o&&o.replace(/.*(?=#[^\s]*$)/,"")),!e.parent("li").hasClass("active")){var s=i.find(".active:last a")[0],n=t.Event("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/show.bs.tab",{relatedTarget:s});if(e.trigger(n),!n.isDefaultPrevented()){var r=t(o);this.activate(e.closest("li"),i),this.activate(r,r.parent(),function(){e.trigger({type:"https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/shown.bs.tab",relatedTarget:s})})}}},i.prototype.activate=function(e,i,o){function s(){n.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),e.addClass("active"),r?(e[0].offsetWidth,e.addClass("in")):e.removeClass("fade"),e.parent(".dropdown-menu")&&e.closest("li.dropdown").addClass("active"),o&&o()}var n=i.find("> .active"),r=o&&t.support.transition&&n.hasClass("fade");r?n.one("bsTransitionEnd",s).emulateTransitionEnd(150):s(),n.removeClass("in")};var o=t.fn.tab;t.fn.tab=e,t.fn.tab.Constructor=i,t.fn.tab.noConflict=function(){return t.fn.tab=o,this},t(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(i){i.preventDefault(),e.call(t(this),"show")})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.affix"),n="object"==typeof e&&e;s||o.data("bs.affix",s=new i(this,n)),"string"==typeof e&&s[e]()})}var i=function(e,o){this.options=t.extend({},i.DEFAULTS,o),this.$target=t(this.options.target).on("scroll.bs.affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(e),this.affixed=this.unpin=this.pinnedOffset=null,this.checkPosition()};i.VERSION="3.2.0",i.RESET="affix affix-top affix-bottom",i.DEFAULTS={offset:0,target:window},i.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(i.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},i.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},i.prototype.checkPosition=function(){if(this.$element.is(":visible")){var e=t(document).height(),o=this.$target.scrollTop(),s=this.$element.offset(),n=this.options.offset,r=n.top,a=n.bottom;"object"!=typeof n&&(a=r=n),"function"==typeof r&&(r=n.top(this.$element)),"function"==typeof a&&(a=n.bottom(this.$element));var l=null!=this.unpin&&o+this.unpin<=s.top?!1:null!=a&&s.top+this.$element.height()>=e-a?"bottom":null!=r&&r>=o?"top":!1;if(this.affixed!==l){null!=this.unpin&&this.$element.css("top","");var h="affix"+(l?"-"+l:""),p=t.Event(h+".bs.affix");this.$element.trigger(p),p.isDefaultPrevented()||(this.affixed=l,this.unpin="bottom"==l?this.getPinnedOffset():null,this.$element.removeClass(i.RESET).addClass(h).trigger(t.Event(h.replace("affix","affixed"))),"bottom"==l&&this.$element.offset({top:e-this.$element.height()-a}))}}};var o=t.fn.affix;t.fn.affix=e,t.fn.affix.Constructor=i,t.fn.affix.noConflict=function(){return t.fn.affix=o,this},t(window).on("load",function(){t('[data-spy="affix"]').each(function(){var i=t(this),o=i.data();o.offset=o.offset||{},o.offsetBottom&&(o.offset.bottom=o.offsetBottom),o.offsetTop&&(o.offset.top=o.offsetTop),e.call(i,o)})})}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var o=t(this),s=o.data("bs.collapse"),n=t.extend({},i.DEFAULTS,o.data(),"object"==typeof e&&e);!s&&n.toggle&&"show"==e&&(e=!e),s||o.data("bs.collapse",s=new i(this,n)),"string"==typeof e&&s[e]()})}var i=function(e,o){this.$element=t(e),this.options=t.extend({},i.DEFAULTS,o),this.transitioning=null,this.options.parent&&(this.$parent=t(this.options.parent)),this.options.toggle&&this.toggle()};i.VERSION="3.2.0",i.DEFAULTS={toggle:!0},i.prototype.dimension=function(){var t=this.$element.hasClass("width");return t?"width":"height"},i.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var i=t.Event("show.bs.collapse");if(this.$element.trigger(i),!i.isDefaultPrevented()){var o=this.$parent&&this.$parent.find("> .panel > .in");if(o&&o.length){var s=o.data("bs.collapse");if(s&&s.transitioning)return;e.call(o,"hide"),s||o.data("bs.collapse",null)}var n=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[n](0),this.transitioning=1;var r=function(){this.$element.removeClass("collapsing").addClass("collapse in")[n](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!t.support.transition)return r.call(this);var a=t.camelCase(["scroll",n].join("-"));this.$element.one("bsTransitionEnd",t.proxy(r,this)).emulateTransitionEnd(350)[n](this.$element[0][a])}}},i.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var e=t.Event("hide.bs.collapse");if(this.$element.trigger(e),!e.isDefaultPrevented()){var i=this.dimension();this.$element[i](this.$element[i]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse").removeClass("in"),this.transitioning=1;var o=function(){this.transitioning=0,this.$element.trigger("hidden.bs.collapse").removeClass("collapsing").addClass("collapse")};return t.support.transition?void this.$element[i](0).one("bsTransitionEnd",t.proxy(o,this)).emulateTransitionEnd(350):o.call(this)}}},i.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()};var o=t.fn.collapse;t.fn.collapse=e,t.fn.collapse.Constructor=i,t.fn.collapse.noConflict=function(){return t.fn.collapse=o,this},t(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(i){var o,s=t(this),n=s.attr("data-target")||i.preventDefault()||(o=s.attr("href"))&&o.replace(/.*(?=#[^\s]+$)/,""),r=t(n),a=r.data("bs.collapse"),l=a?"toggle":s.data(),h=s.attr("data-parent"),p=h&&t(h);a&&a.transitioning||(p&&p.find('[data-toggle="collapse"][data-parent="'+h+'"]').not(s).addClass("collapsed"),s[r.hasClass("in")?"addClass":"removeClass"]("collapsed")),e.call(r,l)})}(jQuery),+function(t){"use strict";function e(i,o){var s=t.proxy(this.process,this);this.$body=t("body"),this.$scrollElement=t(t(i).is("body")?window:i),this.options=t.extend({},e.DEFAULTS,o),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",s),this.refresh(),this.process()}function i(i){return this.each(function(){var o=t(this),s=o.data("bs.scrollspy"),n="object"==typeof i&&i;s||o.data("bs.scrollspy",s=new e(this,n)),"string"==typeof i&&s[i]()})}e.VERSION="3.2.0",e.DEFAULTS={offset:10},e.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},e.prototype.refresh=function(){var e="offset",i=0;t.isWindow(this.$scrollElement[0])||(e="position",i=this.$scrollElement.scrollTop()),this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight();var o=this;this.$body.find(this.selector).map(function(){var o=t(this),s=o.data("target")||o.attr("href"),n=/^#./.test(s)&&t(s);return n&&n.length&&n.is(":visible")&&[[n[e]().top+i,s]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){o.offsets.push(this[0]),o.targets.push(this[1])})},e.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),o=this.options.offset+i-this.$scrollElement.height(),s=this.offsets,n=this.targets,r=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),e>=o)return r!=(t=n[n.length-1])&&this.activate(t);if(r&&e<=s[0])return r!=(t=n[0])&&this.activate(t);for(t=s.length;t--;)r!=n[t]&&e>=s[t]&&(!s[t+1]||e<=s[t+1])&&this.activate(n[t])},e.prototype.activate=function(e){this.activeTarget=e,t(this.selector).parentsUntil(this.options.target,".active").removeClass("active");var i=this.selector+'[data-target="'+e+'"],'+this.selector+'[href="'+e+'"]',o=t(i).parents("li").addClass("active");o.parent(".dropdown-menu").length&&(o=o.closest("li.dropdown").addClass("active")),o.trigger("activate.bs.scrollspy")};var o=t.fn.scrollspy;t.fn.scrollspy=i,t.fn.scrollspy.Constructor=e,t.fn.scrollspy.noConflict=function(){return t.fn.scrollspy=o,this},t(window).on("load.bs.scrollspy.data-api",function(){t('[data-spy="scroll"]').each(function(){var e=t(this);i.call(e,e.data())})})}(jQuery),+function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return{end:e[i]};return!1}t.fn.emulateTransitionEnd=function(e){var i=!1,o=this;t(this).one("bsTransitionEnd",function(){i=!0});var s=function(){i||t(o).trigger(t.support.transition.end)};return setTimeout(s,e),this},t(function(){t.support.transition=e(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(e){return t(e.target).is(this)?e.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery);



/*!



 * classie - class helper functions



 * from bonzo https://github.com/ded/bonzo



 * 



 * classie.has( elem, 'my-class' ) -> true/false



 * classie.add( elem, 'my-new-class' )



 * classie.remove( elem, 'my-unwanted-class' )



 * classie.toggle( elem, 'my-class' )



 */







/*jshint browser: true, strict: true, undef: true */



/*global define: false */







( function( window ) {







'use strict';







// class helper functions from bonzo https://github.com/ded/bonzo







function classReg( className ) {



  return new RegExp("(^|\\s+)" + className + "(\\s+|$)");



}







// classList support for class management



// altho to be fair, the api sucks because it won't accept multiple classes at once



var hasClass, addClass, removeClass;







if ( 'classList' in document.documentElement ) {



  hasClass = function( elem, c ) {



    return elem.classList.contains( c );



  };



  addClass = function( elem, c ) {



    elem.classList.add( c );



  };



  removeClass = function( elem, c ) {



    elem.classList.remove( c );



  };



}



else {



  hasClass = function( elem, c ) {



    return classReg( c ).test( elem.className );



  };



  addClass = function( elem, c ) {



    if ( !hasClass( elem, c ) ) {



      elem.className = elem.className + ' ' + c;



    }



  };



  removeClass = function( elem, c ) {



    elem.className = elem.className.replace( classReg( c ), ' ' );



  };



}







function toggleClass( elem, c ) {



  var fn = hasClass( elem, c ) ? removeClass : addClass;



  fn( elem, c );



}







var classie = {



  // full names



  hasClass: hasClass,



  addClass: addClass,



  removeClass: removeClass,



  toggleClass: toggleClass,



  // short names



  has: hasClass,



  add: addClass,



  remove: removeClass,



  toggle: toggleClass



};







// transport



if ( typeof define === 'function' && define.amd ) {



  // AMD



  define( classie );



} else {



  // browser global



  window.classie = classie;



}







})( window );







/**



 * mlpushmenu.js v1.0.0



 * http://www.codrops.com



 *



 * Licensed under the MIT license.



 * http://www.opensource.org/licenses/mit-license.php



 * 



 * Copyright 2013, Codrops



 * http://www.codrops.com



 */



;( function( window ) {



	



	'use strict';







	function extend( a, b ) {



		for( var key in b ) { 



			if( b.hasOwnProperty( key ) ) {



				a[key] = b[key];



			}



		}



		return a;



	}







	// taken from https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js



	function hasParent( e, id ) {



		if (!e) return false;



		var el = e.target||e.srcElement||e||false;



		while (el && el.id != id) {



			el = el.parentNode||false;



		}



		return (el!==false);



	}







	// returns the depth of the element "e" relative to element with id=id



	// for this calculation only parents with classname = waypoint are considered



	function getLevelDepth( e, id, waypoint, cnt ) {



		cnt = cnt || 0;



		if ( e.id.indexOf( id ) >= 0 ) return cnt;



		if( classie.has( e, waypoint ) ) {



			++cnt;



		}



		return e.parentNode && getLevelDepth( e.parentNode, id, waypoint, cnt );



	}







	// http://coveroverflow.com/a/11381730/989439



	function mobilecheck() {



		var check = false;



		(function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);



		return check;



	}







	// returns the closest element to 'e' that has class "classname"



	function closest( e, classname ) {



		if( classie.has( e, classname ) ) {



			return e;



		}



		return e.parentNode && closest( e.parentNode, classname );



	}







	function mlPushMenu( el, trigger, options ) {	



		this.el = el;



		this.trigger = trigger;



		this.options = extend( this.defaults, options );



		// support 3d transforms



		this.support = Modernizr.csstransforms3d;



		if( this.support ) {



			this._init();



		}



	}







	mlPushMenu.prototype = {



		defaults : {



			// overlap: there will be a gap between open levels



			// cover: the open levels will be on top of any previous open level



			type : 'overlap', // overlap || cover



			// space between each overlaped level



			levelSpacing : 40,



			// classname for the element (if any) that when clicked closes the current level



			backClass : 'mp-back'



		},



		_init : function() {



			// if menu is open or not



			this.open = false;



			// level depth



			this.level = 0;



			// the moving wrapper



			this.wrapper = document.getElementById( 'mp-pusher' );



			// the mp-level elements



			this.levels = Array.prototype.slice.call( this.el.querySelectorAll( 'div.mp-level' ) );



			// save the depth of each of these mp-level elements



			var self = this;



			this.levels.forEach( function( el, i ) { el.setAttribute( 'data-level', getLevelDepth( el, self.el.id, 'mp-level' ) ); } );



			// the menu items



			this.menuItems = Array.prototype.slice.call( this.el.querySelectorAll( 'li' ) );



			// if type == "cover" these will serve as hooks to move back to the previous level



			this.levelBack = Array.prototype.slice.call( this.el.querySelectorAll( '.' + this.options.backClass ) );



			// event type (if mobile use touch events)



			this.eventtype = mobilecheck() ? 'touchstart' : 'click';



			// add the class mp-overlap or mp-cover to the main element depending on options.type



			classie.add( this.el, 'mp-' + this.options.type );



			// initialize / bind the necessary events



			this._initEvents();



		},



		_initEvents : function() {



			var self = this;







			// the menu should close if clicking somewhere on the body



			var bodyClickFn = function( el ) {



				self._resetMenu();



				el.removeEventListener( self.eventtype, bodyClickFn );



			};







			// open (or close) the menu



			this.trigger.addEventListener( this.eventtype, function( ev ) {



				ev.stopPropagation();



				ev.preventDefault();



				if( self.open ) {



					self._resetMenu();



				}



				else {



					self._openMenu();



					// the menu should close if clicking somewhere on the body (excluding clicks on the menu)



					document.addEventListener( self.eventtype, function( ev ) {



						if( self.open && !hasParent( ev.target, self.el.id ) ) {



							bodyClickFn( this );



						}



					} );



				}



			} );







			// opening a sub level menu



			this.menuItems.forEach( function( el, i ) {



				// check if it has a sub level



				var subLevel = el.querySelector( 'div.mp-level' );



				if( subLevel ) {



					el.querySelector( 'a' ).addEventListener( self.eventtype, function( ev ) {



						ev.preventDefault();



						var level = closest( el, 'mp-level' ).getAttribute( 'data-level' );



						if( self.level <= level ) {



							ev.stopPropagation();



							classie.add( closest( el, 'mp-level' ), 'mp-level-overlay' );



							self._openMenu( subLevel );



						}



					} );



				}



			} );







			// closing the sub levels :



			// by clicking on the visible part of the level element



			this.levels.forEach( function( el, i ) {



				el.addEventListener( self.eventtype, function( ev ) {



					ev.stopPropagation();



					var level = el.getAttribute( 'data-level' );



					if( self.level > level ) {



						self.level = level;



						self._closeMenu();



					}



				} );



			} );







			// by clicking on a specific element



			this.levelBack.forEach( function( el, i ) {



				el.addEventListener( self.eventtype, function( ev ) {



					ev.preventDefault();



					var level = closest( el, 'mp-level' ).getAttribute( 'data-level' );



					if( self.level <= level ) {



						ev.stopPropagation();



						self.level = closest( el, 'mp-level' ).getAttribute( 'data-level' ) - 1;



						self.level === 0 ? self._resetMenu() : self._closeMenu();



					}



				} );



			} );	



		},



		_openMenu : function( subLevel ) {



			// increment level depth



			++this.level;







			// move the main wrapper



			var levelFactor = ( this.level - 1 ) * this.options.levelSpacing,



				translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + levelFactor : this.el.offsetWidth;



			



			this._setTransform( 'translate3d(' + translateVal + 'px,0,0)' );







			if( subLevel ) {



				// reset transform for sublevel



				this._setTransform( '', subLevel );



				// need to reset the translate value for the level menus that have the same level depth and are not open



				for( var i = 0, len = this.levels.length; i < len; ++i ) {



					var levelEl = this.levels[i];



					if( levelEl != subLevel && !classie.has( levelEl, 'mp-level-open' ) ) {



						this._setTransform( 'translate3d(-100%,0,0) translate3d(' + -1*levelFactor + 'px,0,0)', levelEl );



					}



				}



			}



			// add class mp-pushed to main wrapper if opening the first time



			if( this.level === 1 ) {



				classie.add( this.wrapper, 'mp-pushed' );



				this.open = true;



			}



			// add class mp-level-open to the opening level element



			classie.add( subLevel || this.levels[0], 'mp-level-open' );



		},



		// close the menu



		_resetMenu : function() {



			this._setTransform('translate3d(0,0,0)');



			this.level = 0;



			// remove class mp-pushed from main wrapper



			classie.remove( this.wrapper, 'mp-pushed' );



			this._toggleLevels();



			this.open = false;



		},



		// close sub menus



		_closeMenu : function() {



			var translateVal = this.options.type === 'overlap' ? this.el.offsetWidth + ( this.level - 1 ) * this.options.levelSpacing : this.el.offsetWidth;



			this._setTransform( 'translate3d(' + translateVal + 'px,0,0)' );



			this._toggleLevels();



		},



		// translate the el



		_setTransform : function( val, el ) {



			el = el || this.wrapper;



			el.style.WebkitTransform = val;



			el.style.MozTransform = val;



			el.style.transform = val;



		},



		// removes classes mp-level-open from closing levels



		_toggleLevels : function() {



			for( var i = 0, len = this.levels.length; i < len; ++i ) {



				var levelEl = this.levels[i];



				if( levelEl.getAttribute( 'data-level' ) >= this.level + 1 ) {



					classie.remove( levelEl, 'mp-level-open' );



					classie.remove( levelEl, 'mp-level-overlay' );



				}



				else if( Number( levelEl.getAttribute( 'data-level' ) ) == this.level ) {



					classie.remove( levelEl, 'mp-level-overlay' );



				}



			}



		}



	}







	// add to global namespace



	window.mlPushMenu = mlPushMenu;







} )( window );



isMobileDevice = false;



if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)



	    || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) {



    isMobileDevice = true;



}



mobile_menu = function mobile_menu(isMobileDevice) {



	var $mobileMenu;



	if(isMobileDevice) {



		$mobileMenu = jQuery('#menu-container');



	} else {



		$mobileMenu = jQuery('#menu-container').clone();



	}



    $mobileMenu.attr('id','mp-menu').addClass('mp-menu');



    $mobileMenu.wrapInner('<div class="mp-level"></div>');



    $mobileMenu.find('.tab-content').removeClass('clearfix');



    //Remove unwanted elements for mobile menu



	$mobileMenu.find('.icon-chevron-right').remove();



	$mobileMenu.find('.best_seller').remove();



    $mobileMenu.find('.tab-links').remove();



    $mobileMenu.find('.by_category-pane').remove();



    //$mobileMenu.find('.cat-links').remove();



    $mobileMenu.find('.clearfix').each(function(index, element) {



        if ( jQuery(this).is(':empty') ) {



            jQuery(this).remove();



        }



    });



	//Change classes for mobile menu



	$mobileMenu.find('.left').unwrap().addClass('mp-level');



	$mobileMenu.find('.col-xs-8').removeClass('col-xs-8').addClass('mmenu-col');



    $mobileMenu.find('.by_brand-pane').addClass('active in');



    //Remove Wrappers



	$mobileMenu.find('.brand_list_wrap').unwrap().unwrap().unwrap();







    $mobileMenu.find('#nav').attr('id','nav-mobile').find('.mp-level').each(function(index, element) {



        title = jQuery(this).prev().text();



        jQuery(this).prepend('<h2 class="icon icon-display">'+ title +'</h2> <a class="mp-back" href="#"></a>');



    });



    jQuery('#mp-pusher').append($mobileMenu);







    new mlPushMenu( document.getElementById( 'mp-menu' ), document.getElementById( 'mob_menu_toggle' ), {



        type : 'cover'



    } );



};







settingsLinks = function(isMobileDevice){



    if(isMobileDevice) {



        mobileLinks = jQuery('.header-top').find('.links');



    } else {



        mobileLinks = jQuery('.header-top').find('.links').clone();



    }



    mobileLinks.removeClass('links').addClass('visible-xs setingsLinks');



    jQuery('.top-container').append(mobileLinks);



};







mobile_toggle_settings = function() {



	jQuery('#settings_toggle').on('click', function(e){



		e.preventDefault();



		jQuery(this).stop();



		jQuery(this).toggleClass('active');



		jQuery(this).parent().prev().slideToggle(400);



	});



};







runOnceMobile = function(){



	if (this.runOnce) {



		return;



	}



	mobile_menu(isMobileDevice);



    settingsLinks(isMobileDevice);



    mobile_toggle_settings();



	this.runOnce = true;



};



responsive_viewport = jQuery(window).width();



document.observe('ajaxcatalognavigation:complete', function(event){



	runOnceMobile();



	if (responsive_viewport >= 768) {



		//Check windows Size and run according functions



		jQuery(window).resize(function() {



			//Timer for not executing funtions continuously



			clearTimeout(jQuery(this).data('timer'));



			jQuery(this).data('timer', setTimeout(function() {



					//Add functions that should triggered once bellow



					var responsive_viewport = jQuery(window).width();



					//If window is under 768px width



					if (responsive_viewport < 768) {



						runOnceMobile();



					}



				},300)



			);



		});



	}



});



/*



Replace Tag Element Plugin



*/



jQuery.noConflict();



(function($) {



	//Function That Allows to change element tag



	$.extend({



		replaceTag: function (currentElem, newTagObj, keepProps) {



			var $currentElem = $(currentElem);



			var i, $newTag = $(newTagObj).clone();



			if (keepProps) {//{{{



				newTag = $newTag[0];



				newTag.className = currentElem.className;



				$.extend(newTag.classList, currentElem.classList);



				$.extend(newTag.attributes, currentElem.attributes);



			}//}}}



			$currentElem.wrapAll($newTag);



			$currentElem.contents().unwrap();



			// return node; (Error spotted by Frank van Luijn)



		}



	});







	$.fn.extend({



		replaceTag: function (newTagObj, keepProps) {



			this.each(function() {



				jQuery.replaceTag(this, newTagObj, keepProps);



			});



		}



	});



})(jQuery);















jQuery(function($){



	var $body = $('body');







	//Run Funtions



		smoothSCroll();







		//Toggle ToolTips



		$('body').tooltip({



			selector: '[data-toggle="tooltip"]'



		});







        //Close data Links



        $body.find('[data-close="true"]').each(function(index, element) {



            var target = $(this).data('target');



            if ( target.length ) {



	            var cookie = $(this).data('cookie')?$(this).data('cookie'):false;



				if(cookie && Mage.Cookies.get(cookie))



					$('#'+target).slideUp();



                element.on('click', function(e){



                    e.preventDefault();



					if(cookie)



						Mage.Cookies.set(cookie,true);



                    $('#'+target).slideUp();



                });



            }



        });







        //Close data Links



        $body.find('[data-toogle="visibility"]').each(function(index, element) {



			if($(this).data('target').length)



            var target = $('#'+$(this).data('target'));



            if ( target.length ) {



                element.on('click', function(e){



                    e.preventDefault();



					if((target).is(":visible"))



	                    $(target).slideUp();



					else



	                    $(target).slideDown();



                });



            }



        });







		/* Sticky nav */



		var wrapperNav = $('.header-top').first(),



			stickyNavTop = $body.offset().top + 48,



			stickyLogo = wrapperNav.find('.logo');



		var stickyNav = function(){



			var scrollTop = $(window).scrollTop();







			if (scrollTop > stickyNavTop) {



				wrapperNav.addClass('sticky');



				$('body').addClass('hassticky');



			} else {



				wrapperNav.removeClass('sticky');



				$body.removeClass('hassticky');



			}



		};



		//Run on Load



		stickyNav();



		//Run on scroll



		$(window).scroll(function() {



			stickyNav();



		});



		/* End Sticky nav */







		//If window is under 768px width



		if (responsive_viewport < 768) {



            //On #search focus toggle scroll



            $('#search').on("focus", function(){



                $('html,body').animate({



                  scrollTop: $(this).offset().top - 45



                }, 800);



            });







		}



	//End Run











	/* Smooth Scrolling for anchor links */



	function smoothSCroll() {



		$('a.smoothSCroll').click(function() {



		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {



		  var target = $(this.hash);



		  target = target.length ? target : $('[name=' + this.hash.slice(1) +']');



		  if (target.length) {



			$('html,body').animate({



			  scrollTop: target.offset().top - 50 //minus sticky header height



			}, 800);



			return false;



		  }



		}



		});



	}



	/* End Smooth */







    //Mobile category_list See more



    $('.see_more').on("click", 'a', function(e){



        e.preventDefault();



        $(this).parent().parent().find('.hidden').addClass('less-hidden').removeClass('hidden');



        $(this).parent().addClass('hidden');



    });



    $('.see_less').on("click", 'a', function(e){



        e.preventDefault();



        $(this).parent().parent().find('.less-hidden').addClass('hidden').removeClass('less-hidden');



        $(this).parent().parent().find('.see_more').removeClass('hidden');



    });



    



	//Notification strip



	if($('#promo-popup-notification').is(':visible')){



		$('body').addClass('notification');



	}



	$('.hide-promo-notification').on('click', function(){



		$('body').removeClass('notification');



	});







});







/*! A fix for the iOS orientationchange zoom bug.



 Script by @scottjehl, rebound by @wilto.



 MIT License.



*/



(function(w){



	// This fix addresses an iOS bug, so return early if the UA claims it's something else.



	if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){ return; }



	var doc = w.document;



	if( !doc.querySelector ){ return; }



	var meta = doc.querySelector( "meta[name=viewport]" ),



		initialContent = meta && meta.getAttribute( "content" ),



		disabledZoom = initialContent + ",maximum-scale=1",



		enabledZoom = initialContent + ",maximum-scale=10",



		enabled = true,



		x, y, z, aig;



	if( !meta ){ return; }



	function restoreZoom(){



		meta.setAttribute( "content", enabledZoom );



		enabled = true; }



	function disableZoom(){



		meta.setAttribute( "content", disabledZoom );



		enabled = false; }



	function checkTilt( e ){



		aig = e.accelerationIncludingGravity;



		x = Math.abs( aig.x );



		y = Math.abs( aig.y );



		z = Math.abs( aig.z );



		// If portrait orientation and in one of the danger zones



		if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){



			if( enabled ){ disableZoom(); } }



		else if( !enabled ){ restoreZoom(); } }



	w.addEventListener( "orientationchange", restoreZoom, false );



	w.addEventListener( "devicemotion", checkTilt, false );



})( this );







Autocompleter.Base.prototype.updateChoices =



    Autocompleter.Base.prototype.updateChoices.wrap(



        function(originalCall, choices){



            originalCall(choices);



            var maxElements = 20;



            this.update.select('li').each(function (el) {



                if(maxElements<0)



                    el.remove();



                maxElements--;



                });



            });







Varien.searchForm.addMethods({



    initAutocomplete : function(url, destinationElement){



        new Ajax.Autocompleter(



            this.field,



            destinationElement,



            url,



            {



                paramName: this.field.name,



                method: 'get',



                minChars: 2,



                frequency: 0.5,



                indicator: this.field.id+'_indicator',



                updateElement: this._selectAutocompleteItem.bind(this),



                onShow : function(element, update) {



                    if(!update.style.position || update.style.position=='absolute') {



                        update.style.position = 'absolute';



                        Position.clone(element, update, {



                            setHeight: false,



                            offsetTop: element.offsetHeight



                        });



                    }



                    Effect.Appear(update,{duration:0});



                }



            }



        );



    }



});



/*



 * jQuery selectBox - A cosmetic, styleable replacement for SELECT elements



 *



 * Licensed under the MIT license: http://opensource.org/licenses/MIT



 *



 * v1.2.0



 *



 * https://github.com/marcj/jquery-selectBox



 */



;(function ($) {







    /**



     * SelectBox class.



     *



     * @param {HTMLElement|jQuery} select If it's a jQuery object, we use the first element.



     * @param {Object}             options



     * @constructor



     */



    var SelectBox = this.SelectBox = function (select, options) {



        if (select instanceof jQuery) {



            if (select.length > 0) {



                select = select[0];



            } else {



                return;



            }



        }







        this.typeTimer     = null;



        this.typeSearch    = '';



        this.isMac         = navigator.platform.match(/mac/i);



        options            = 'object' === typeof options ? options :  {};



        this.selectElement = select;







        // Disable for iOS devices (their native controls are more suitable for a touch device)



        if (!options.mobile && navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i)) {



            return false;



        }







        // Element must be a select control



        if ('select' !== select.tagName.toLowerCase()) {



            return false;



        }







        this.init(options);



    };







    /**



     * @type {String}



     */



    SelectBox.prototype.version = '1.2.0';







    /**



     * @param {Object} options



     *



     * @returns {Boolean}



     */



    SelectBox.prototype.init = function (options) {



        var select = $(this.selectElement);



        if (select.data('selectBox-control')) {



            return false;



        }







        var control    = $('<a class="selectBox" />')



            , inline   = select.attr('multiple') || parseInt(select.attr('size')) > 1



            , settings = options || {}



            , tabIndex = parseInt(select.prop('tabindex')) || 0



            , self     = this;







        control



            .width(select.outerWidth())



            .addClass(select.attr('class'))



            .attr('title', select.attr('title') || '')



            .attr('tabindex', tabIndex)



            .css('display', 'inline-block')



            .bind('focus.selectBox', function () {



                if (this !== document.activeElement && document.body !== document.activeElement) {



                    $(document.activeElement).blur();



                }



                if (control.hasClass('selectBox-active')) {



                    return;



                }



                control.addClass('selectBox-active');



                select.trigger('focus');



            })



            .bind('blur.selectBox', function () {



                if (!control.hasClass('selectBox-active')) {



                    return;



                }



                control.removeClass('selectBox-active');



                select.trigger('blur');



            });







        if (!$(window).data('selectBox-bindings')) {



            $(window)



                .data('selectBox-bindings', true)



                .bind('scroll.selectBox', (settings.hideOnWindowScroll) ? this.hideMenus : $.noop)



                .bind('resize.selectBox', this.hideMenus);



        }







        if (select.attr('disabled')) {



            control.addClass('selectBox-disabled');



        }







        // Focus on control when label is clicked



        select.bind('click.selectBox', function (event) {



            control.focus();



            event.preventDefault();



        });







        // Generate control



        if (inline) {



            // Inline controls



            options = this.getOptions('inline');







            control



                .append(options)



                .data('selectBox-options', options).addClass('selectBox-inline selectBox-menuShowing')



                .bind('keydown.selectBox', function (event) {



                    self.handleKeyDown(event);



                })



                .bind('keypress.selectBox',function (event) {



                    self.handleKeyPress(event);



                })



                .bind('mousedown.selectBox',function (event) {



                    if (1 !== event.which) {



                        return;



                    }



                    if ($(event.target).is('A.selectBox-inline')) {



                        event.preventDefault();



                    }



                    if (!control.hasClass('selectBox-focus')) {



                        control.focus();



                    }



                })



                .insertAfter(select);







            // Auto-height based on size attribute



            if (!select[0].style.height) {



                var size = select.attr('size') ? parseInt(select.attr('size')) : 5;



                // Draw a dummy control off-screen, measure, and remove it



                var tmp = control



                    .clone()



                    .removeAttr('id')



                    .css({



                        position: 'absolute',



                        top: '-9999em'



                    })



                    .show()



                    .appendTo('body');



                tmp.find('.selectBox-options').html('<li><a>\u00A0</a></li>');



                var optionHeight = parseInt(tmp.find('.selectBox-options A:first').html('&nbsp;').outerHeight());



                tmp.remove();



                control.height(optionHeight * size);



            }



            this.disableSelection(control);



        } else {



            // Dropdown controls



            var label = $('<span class="selectBox-label" />'),



                arrow = $('<span class="selectBox-arrow" />');







            // Update label



            label.attr('class', this.getLabelClass()).text(this.getLabelText());



            options = this.getOptions('dropdown');



            options.appendTo('BODY');







            control



                .data('selectBox-options', options)



                .addClass('selectBox-dropdown')



                .append(label)



                .append(arrow)



                .bind('mousedown.selectBox', function (event) {



                    if (1 === event.which) {



                        if (control.hasClass('selectBox-menuShowing')) {



                            self.hideMenus();



                        } else {



                            event.stopPropagation();



                            // Webkit fix to prevent premature selection of options



                            options



                                .data('selectBox-down-at-x', event.screenX)



                                .data('selectBox-down-at-y', event.screenY);



                            self.showMenu();



                        }



                    }



                })



                .bind('keydown.selectBox', function (event) {



                    self.handleKeyDown(event);



                })



                .bind('keypress.selectBox', function (event) {



                    self.handleKeyPress(event);



                })



                .bind('open.selectBox',function (event, triggerData) {



                    if (triggerData && triggerData._selectBox === true) {



                        return;



                    }



                    self.showMenu();



                })



                .bind('close.selectBox', function (event, triggerData) {



                    if (triggerData && triggerData._selectBox === true) {



                        return;



                    }



                    self.hideMenus();



                })



                .insertAfter(select);







            // Set label width



            var labelWidth =



                    control.width()



                  - arrow.outerWidth()



                  - (parseInt(label.css('paddingLeft')) || 0)



                  - (parseInt(label.css('paddingRight')) || 0);







            label.width(labelWidth);



            this.disableSelection(control);



        }



        // Store data for later use and show the control



        select



            .addClass('selectBox')



            .data('selectBox-control', control)



            .data('selectBox-settings', settings)



            .hide();



    };







    /**



     * @param {String} type 'inline'|'dropdown'



     * @returns {jQuery}



     */



    SelectBox.prototype.getOptions = function (type) {



        var options;



        var select = $(this.selectElement);



        var self   = this;



        // Private function to handle recursion in the getOptions function.



        var _getOptions = function (select, options) {



            // Loop through the set in order of element children.



            select.children('OPTION, OPTGROUP').each(function () {



                // If the element is an option, add it to the list.



                if ($(this).is('OPTION')) {



                    // Check for a value in the option found.



                    if ($(this).length > 0) {



                        // Create an option form the found element.



                        self.generateOptions($(this), options);



                    } else {



                        // No option information found, so add an empty.



                        options.append('<li>\u00A0</li>');



                    }



                } else {



                    // If the element is an option group, add the group and call this function on it.



                    var optgroup = $('<li class="selectBox-optgroup" />');



                    optgroup.text($(this).attr('label'));



                    options.append(optgroup);



                    options = _getOptions($(this), options);



                }



            });



            // Return the built strin



            return options;



        };







        switch (type) {



            case 'inline':



                options = $('<ul class="selectBox-options" />');



                options = _getOptions(select, options);



                options



                    .find('A')



                    .bind('mouseover.selectBox', function (event) {



                        self.addHover($(this).parent());



                    })



                    .bind('mouseout.selectBox',function (event) {



                        self.removeHover($(this).parent());



                    })



                    .bind('mousedown.selectBox',function (event) {



                        if (1 !== event.which) {



                            return



                        }



                        event.preventDefault(); // Prevent options from being "dragged"



                        if (!select.selectBox('control').hasClass('selectBox-active')) {



                            select.selectBox('control').focus();



                        }



                    })



                    .bind('mouseup.selectBox', function (event) {



                        if (1 !== event.which) {



                            return;



                        }



                        self.hideMenus();



                        self.selectOption($(this).parent(), event);



                    });







                this.disableSelection(options);



                return options;



            case 'dropdown':



                options = $('<ul class="selectBox-dropdown-menu selectBox-options" />');



                options = _getOptions(select, options);







                options



                    .data('selectBox-select', select)



                    .css('display', 'none')



                    .appendTo('BODY')



                    .find('A')



                    .bind('mousedown.selectBox', function (event) {



                        if (event.which === 1) {



                            event.preventDefault(); // Prevent options from being "dragged"



                            if (event.screenX === options.data('selectBox-down-at-x') &&



                                event.screenY === options.data('selectBox-down-at-y')) {



                                options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');



                                if (/android/i.test(navigator.userAgent.toLowerCase()) &&



                                    /chrome/i.test(navigator.userAgent.toLowerCase())) {



                                    self.selectOption($(this).parent());        



                                }



                                self.hideMenus();



                            }



                        }



                    })



                    .bind('mouseup.selectBox', function (event) {



                        if (1 !== event.which) {



                            return;



                        }



                        if (event.screenX === options.data('selectBox-down-at-x') &&



                            event.screenY === options.data('selectBox-down-at-y')) {



                            return;



                        } else {



                            options.removeData('selectBox-down-at-x').removeData('selectBox-down-at-y');



                        }



                        self.selectOption($(this).parent());



                        self.hideMenus();



                    })



                    .bind('mouseover.selectBox', function (event) {



                        self.addHover($(this).parent());



                    })



                    .bind('mouseout.selectBox', function (event) {



                        self.removeHover($(this).parent());



                    });







                // Inherit classes for dropdown menu



                var classes = select.attr('class') || '';



                if ('' !== classes) {



                    classes = classes.split(' ');



                    for (var i = 0; i < classes.length; i++) {



                        options.addClass(classes[i] + '-selectBox-dropdown-menu');



                    }



                    



                }



                this.disableSelection(options);



                return options;



        }



    };







    /**



     * Returns the current class of the selected option.



     *



     * @returns {String}



     */



    SelectBox.prototype.getLabelClass = function () {



        var selected = $(this.selectElement).find('OPTION:selected');



        return ('selectBox-label ' + (selected.attr('class') || '')).replace(/\s+$/, '');



    };







    /**



     * Returns the current label of the selected option.



     *



     * @returns {String}



     */



    SelectBox.prototype.getLabelText = function () {



        var selected = $(this.selectElement).find('OPTION:selected');



        return selected.text() || '\u00A0';



    };







    /**



     * Sets the label.



     * This method uses the getLabelClass() and getLabelText() methods.



     */



    SelectBox.prototype.setLabel = function () {



        var select = $(this.selectElement);



        var control = select.data('selectBox-control');



        if (!control) {



            return;



        }







        control



            .find('.selectBox-label')



            .attr('class', this.getLabelClass())



            .text(this.getLabelText());



    };







    /**



     * Destroys the SelectBox instance and shows the origin select element.



     *



     */



    SelectBox.prototype.destroy = function () {



        var select = $(this.selectElement);



        var control = select.data('selectBox-control');



        if (!control) {



            return;



        }







        var options = control.data('selectBox-options');



        options.remove();



        control.remove();



        select



            .removeClass('selectBox')



            .removeData('selectBox-control')



            .data('selectBox-control', null)



            .removeData('selectBox-settings')



            .data('selectBox-settings', null)



            .show();



    };







    /**



     * Refreshes the option elements.



     */



    SelectBox.prototype.refresh = function () {



        var select = $(this.selectElement)



            , control = select.data('selectBox-control')



            , type = control.hasClass('selectBox-dropdown') ? 'dropdown' : 'inline'



            , options;







        // Remove old options



        control.data('selectBox-options').remove();







        // Generate new options



        options  = this.getOptions(type);



        control.data('selectBox-options', options);







        switch (type) {



            case 'inline':



                control.append(options);



                break;



            case 'dropdown':



                // Update label



                this.setLabel();



                $("BODY").append(options);



                break;



        }







        // Restore opened dropdown state (original menu was trashed)



        if ('dropdown' === type && control.hasClass('selectBox-menuShowing')) {



            this.showMenu();



        }



    };







    /**



     * Shows the dropdown menu.



     */



    SelectBox.prototype.showMenu = function () {



        var self = this



            , select   = $(this.selectElement)



            , control  = select.data('selectBox-control')



            , settings = select.data('selectBox-settings')



            , options  = control.data('selectBox-options');







        if (control.hasClass('selectBox-disabled')) {



            return false;



        }







        this.hideMenus();



        



        // Get top and bottom width of selectBox



        var borderBottomWidth = parseInt(control.css('borderBottomWidth')) || 0;



        var borderTopWidth = parseInt(control.css('borderTopWidth')) || 0;



        



        // Get proper variables for keeping options in viewport



        var pos = control.offset()



            , topPositionCorrelation = (settings.topPositionCorrelation) ? settings.topPositionCorrelation : 0



            , bottomPositionCorrelation = (settings.bottomPositionCorrelation) ? settings.bottomPositionCorrelation : 0



            , optionsHeight = options.outerHeight()



            , controlHeight = control.outerHeight()



            , maxHeight = parseInt(options.css('max-height'))



            , scrollPos = $(window).scrollTop()



            , heightToTop = pos.top - scrollPos



            , heightToBottom = $(window).height() - ( heightToTop + controlHeight )



            , posTop = (heightToTop > heightToBottom) && (settings.keepInViewport == null ? true : settings.keepInViewport)



            , top = posTop



                  ? pos.top - optionsHeight + borderTopWidth + topPositionCorrelation



                  : pos.top + controlHeight - borderBottomWidth - bottomPositionCorrelation;        



        



        



        // If the height to top and height to bottom are less than the max-height



        if(heightToTop < maxHeight&& heightToBottom < maxHeight){



            



            // Set max-height and top



            if(posTop){



                var maxHeightDiff = maxHeight - ( heightToTop - 5 );



                options.css({'max-height': maxHeight - maxHeightDiff + 'px'});



                top = top + maxHeightDiff;



            }else{



                var maxHeightDiff = maxHeight - ( heightToBottom - 5 );



                options.css({'max-height': maxHeight - maxHeightDiff + 'px'});



            }



            



        }



        



        // Save if position is top to options data



        options.data('posTop',posTop);



        



        



        // Menu position



        options



            .width(control.innerWidth())



            .css({



                top: top,



                left: control.offset().left



            })



            // Add Top and Bottom class based on position



            .addClass('selectBox-options selectBox-options-'+(posTop?'top':'bottom'));











        if (select.triggerHandler('beforeopen')) {



            return false;



        }







        var dispatchOpenEvent = function () {



            select.triggerHandler('open', {



                _selectBox: true



            });



        };







        // Show menu



        switch (settings.menuTransition) {



            case 'fade':



                options.fadeIn(settings.menuSpeed, dispatchOpenEvent);



                break;



            case 'slide':



                options.slideDown(settings.menuSpeed, dispatchOpenEvent);



                break;



            default:



                options.show(settings.menuSpeed, dispatchOpenEvent);



                break;



        }







        if (!settings.menuSpeed) {



            dispatchOpenEvent();



        }







        // Center on selected option



        var li = options.find('.selectBox-selected:first');



        this.keepOptionInView(li, true);



        this.addHover(li);



        control.addClass('selectBox-menuShowing selectBox-menuShowing-'+(posTop?'top':'bottom'));







        $(document).bind('mousedown.selectBox', function (event) {



            if (1 === event.which) {



                if ($(event.target).parents().andSelf().hasClass('selectBox-options')) {



                    return;



                }



                self.hideMenus();



            }



        });



    };







    /**



     * Hides the menu of all instances.



     */



    SelectBox.prototype.hideMenus = function () {



        if ($(".selectBox-dropdown-menu:visible").length === 0) {



            return;



        }







        $(document).unbind('mousedown.selectBox');



        $(".selectBox-dropdown-menu").each(function () {



            var options = $(this)



                , select = options.data('selectBox-select')



                , control = select.data('selectBox-control')



                , settings = select.data('selectBox-settings')



                , posTop = options.data('posTop');







            if (select.triggerHandler('beforeclose')) {



                return false;



            }







            var dispatchCloseEvent = function () {



                select.triggerHandler('close', {



                    _selectBox: true



                });



            };



            if (settings) {



                switch (settings.menuTransition) {



                    case 'fade':



                        options.fadeOut(settings.menuSpeed, dispatchCloseEvent);



                        break;



                    case 'slide':



                        options.slideUp(settings.menuSpeed, dispatchCloseEvent);



                        break;



                    default:



                        options.hide(settings.menuSpeed, dispatchCloseEvent);



                        break;



                }



                if (!settings.menuSpeed) {



                    dispatchCloseEvent();



                }



                control.removeClass('selectBox-menuShowing selectBox-menuShowing-'+(posTop?'top':'bottom'));



            } else {



                $(this).hide();



                $(this).triggerHandler('close', {



                    _selectBox: true



                });



                $(this).removeClass('selectBox-menuShowing selectBox-menuShowing-'+(posTop?'top':'bottom'));



            }



            



            options.css('max-height','');



            //Remove Top or Bottom class based on position



            options.removeClass('selectBox-options-'+(posTop?'top':'bottom'));



            options.data('posTop' , false);



        });



    };







    /**



     * Selects an option.



     *



     * @param {HTMLElement} li



     * @param {DOMEvent}    event



     * @returns {Boolean}



     */



    SelectBox.prototype.selectOption = function (li, event) {



        var select = $(this.selectElement);



        li         = $(li);







        var control    = select.data('selectBox-control')



            , settings = select.data('selectBox-settings');







        if (control.hasClass('selectBox-disabled')) {



            return false;



        }







        if (0 === li.length || li.hasClass('selectBox-disabled')) {



            return false;



        }







        if (select.attr('multiple')) {



            // If event.shiftKey is true, this will select all options between li and the last li selected



            if (event.shiftKey && control.data('selectBox-last-selected')) {



                li.toggleClass('selectBox-selected');



                var affectedOptions;



                if (li.index() > control.data('selectBox-last-selected').index()) {



                    affectedOptions = li



                        .siblings()



                        .slice(control.data('selectBox-last-selected').index(), li.index());



                } else {



                    affectedOptions = li



                        .siblings()



                        .slice(li.index(), control.data('selectBox-last-selected').index());



                }



                affectedOptions = affectedOptions.not('.selectBox-optgroup, .selectBox-disabled');



                if (li.hasClass('selectBox-selected')) {



                    affectedOptions.addClass('selectBox-selected');



                } else {



                    affectedOptions.removeClass('selectBox-selected');



                }



            } else if ((this.isMac && event.metaKey) || (!this.isMac && event.ctrlKey)) {



                li.toggleClass('selectBox-selected');



            } else {



                li.siblings().removeClass('selectBox-selected');



                li.addClass('selectBox-selected');



            }



        } else {



            li.siblings().removeClass('selectBox-selected');



            li.addClass('selectBox-selected');



        }







        if (control.hasClass('selectBox-dropdown')) {



            control.find('.selectBox-label').text(li.text());



        }







        // Update original control's value



        var i = 0, selection = [];



        if (select.attr('multiple')) {



            control.find('.selectBox-selected A').each(function () {



                selection[i++] = $(this).attr('rel');



            });



        } else {



            selection = li.find('A').attr('rel');



        }







        // Remember most recently selected item



        control.data('selectBox-last-selected', li);







        // Change callback



        if (select.val() !== selection) {



            select.val(selection);



            this.setLabel();



            select.trigger('change');



        }







        return true;



    };







    /**



     * Adds the hover class.



     *



     * @param {HTMLElement} li



     */



    SelectBox.prototype.addHover = function (li) {



        li = $(li);



        var select = $(this.selectElement)



            , control   = select.data('selectBox-control')



            , options = control.data('selectBox-options');







        options.find('.selectBox-hover').removeClass('selectBox-hover');



        li.addClass('selectBox-hover');



    };







    /**



     * Returns the original HTML select element.



     *



     * @returns {HTMLElement}



     */



    SelectBox.prototype.getSelectElement = function () {



        return this.selectElement;



    };







    /**



     * Remove the hover class.



     *



     * @param {HTMLElement} li



     */



    SelectBox.prototype.removeHover = function (li) {



        li = $(li);



        var select = $(this.selectElement)



            , control = select.data('selectBox-control')



            , options = control.data('selectBox-options');







        options.find('.selectBox-hover').removeClass('selectBox-hover');



    };







    /**



     * Checks if the widget is in the view.



     *



     * @param {jQuery}      li



     * @param {Boolean}     center



     */



    SelectBox.prototype.keepOptionInView = function (li, center) {



        if (!li || li.length === 0) {



            return;



        }







        var select = $(this.selectElement)



            , control     = select.data('selectBox-control')



            , options   = control.data('selectBox-options')



            , scrollBox = control.hasClass('selectBox-dropdown') ? options : options.parent()



            , top       = parseInt(li.offset().top -scrollBox.position().top)



            , bottom    = parseInt(top + li.outerHeight());







        if (center) {



            scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop() -



                (scrollBox.height() / 2));



        } else {



            if (top < 0) {



                scrollBox.scrollTop(li.offset().top - scrollBox.offset().top + scrollBox.scrollTop());



            }



            if (bottom > scrollBox.height()) {



                scrollBox.scrollTop((li.offset().top + li.outerHeight()) - scrollBox.offset().top +



                    scrollBox.scrollTop() - scrollBox.height());



            }



        }



    };







    /**



     * Handles the keyDown event.



     * Handles open/close and arrow key functionality



     *



     * @param {DOMEvent}    event



     */



    SelectBox.prototype.handleKeyDown = function (event) {



        var select = $(this.selectElement)



            , control        = select.data('selectBox-control')



            , options      = control.data('selectBox-options')



            , settings     = select.data('selectBox-settings')



            , totalOptions = 0, i = 0;







        if (control.hasClass('selectBox-disabled')) {



            return;



        }







        switch (event.keyCode) {



            case 8:



                // backspace



                event.preventDefault();



                this.typeSearch = '';



                break;



            case 9:



            // tab



            case 27:



                // esc



                this.hideMenus();



                this.removeHover();



                break;



            case 13:



                // enter



                if (control.hasClass('selectBox-menuShowing')) {



                    this.selectOption(options.find('LI.selectBox-hover:first'), event);



                    if (control.hasClass('selectBox-dropdown')) {



                        this.hideMenus();



                    }



                } else {



                    this.showMenu();



                }



                break;



            case 38:



            // up



            case 37:



                // left



                event.preventDefault();



                if (control.hasClass('selectBox-menuShowing')) {



                    var prev = options.find('.selectBox-hover').prev('LI');



                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;



                    i = 0;



                    while (prev.length === 0 || prev.hasClass('selectBox-disabled') ||



                        prev.hasClass('selectBox-optgroup')) {



                        prev = prev.prev('LI');



                        if (prev.length === 0) {



                            if (settings.loopOptions) {



                                prev = options.find('LI:last');



                            } else {



                                prev = options.find('LI:first');



                            }



                        }



                        if (++i >= totalOptions) {



                            break;



                        }



                    }



                    this.addHover(prev);



                    this.selectOption(prev, event);



                    this.keepOptionInView(prev);



                } else {



                    this.showMenu();



                }



                break;



            case 40:



            // down



            case 39:



                // right



                event.preventDefault();



                if (control.hasClass('selectBox-menuShowing')) {



                    var next = options.find('.selectBox-hover').next('LI');



                    totalOptions = options.find('LI:not(.selectBox-optgroup)').length;



                    i = 0;



                    while (0 === next.length || next.hasClass('selectBox-disabled') ||



                        next.hasClass('selectBox-optgroup')) {



                        next = next.next('LI');



                        if (next.length === 0) {



                            if (settings.loopOptions) {



                                next = options.find('LI:first');



                            } else {



                                next = options.find('LI:last');



                            }



                        }



                        if (++i >= totalOptions) {



                            break;



                        }



                    }



                    this.addHover(next);



                    this.selectOption(next, event);



                    this.keepOptionInView(next);



                } else {



                    this.showMenu();



                }



                break;



        }



    };







    /**



     * Handles the keyPress event.



     * Handles type-to-find functionality



     *



     * @param {DOMEvent}    event



     */



    SelectBox.prototype.handleKeyPress = function (event) {



        var select = $(this.selectElement)



            , control = select.data('selectBox-control')



            , options = control.data('selectBox-options')



            , self    = this;







        if (control.hasClass('selectBox-disabled')) {



            return;



        }







        switch (event.keyCode) {



            case 9:



            // tab



            case 27:



            // esc



            case 13:



            // enter



            case 38:



            // up



            case 37:



            // left



            case 40:



            // down



            case 39:



                // right



                // Don't interfere with the keydown event!



                break;



            default:



                // Type to find



                if (!control.hasClass('selectBox-menuShowing')) {



                    this.showMenu();



                }



                event.preventDefault();



                clearTimeout(this.typeTimer);



                this.typeSearch += String.fromCharCode(event.charCode || event.keyCode);



                options.find('A').each(function () {



                    if ($(this).text().substr(0, self.typeSearch.length).toLowerCase() === self.typeSearch.toLowerCase()) {



                        self.addHover($(this).parent());



                        self.selectOption($(this).parent(), event);



                        self.keepOptionInView($(this).parent());



                        return false;



                    }



                });



                // Clear after a brief pause



                this.typeTimer = setTimeout(function () {



                    self.typeSearch = '';



                }, 1000);



                break;



        }



    };







    /**



     * Enables the selectBox.



     */



    SelectBox.prototype.enable = function () {



        var select = $(this.selectElement);



        select.prop('disabled', false);



        var control = select.data('selectBox-control');



        if (!control) {



            return;



        }



        control.removeClass('selectBox-disabled');



    };







    /**



     * Disables the selectBox.



     */



    SelectBox.prototype.disable = function () {



        var select = $(this.selectElement);



        select.prop('disabled', true);



        var control = select.data('selectBox-control');



        if (!control) {



            return;



        }



        control.addClass('selectBox-disabled');



    };







    /**



     * Sets the current value.



     *



     * @param {String}      value



     */



    SelectBox.prototype.setValue = function (value) {



        var select = $(this.selectElement);



        select.val(value);



        value = select.val(); // IE9's select would be null if it was set with a non-exist options value







        if (null === value) { // So check it here and set it with the first option's value if possible



            value = select.children().first().val();



            select.val(value);



        }







        var control = select.data('selectBox-control');



        if (!control) {



            return;



        }







        var settings = select.data('selectBox-settings')



            , options = control.data('selectBox-options');







        // Update label



        this.setLabel();







        // Update control values



        options.find('.selectBox-selected').removeClass('selectBox-selected');



        options.find('A').each(function () {



            if (typeof(value) === 'object') {



                for (var i = 0; i < value.length; i++) {



                    if ($(this).attr('rel') == value[i]) {



                        $(this).parent().addClass('selectBox-selected');



                    }



                }



            } else {



                if ($(this).attr('rel') == value) {



                    $(this).parent().addClass('selectBox-selected');



                }



            }



        });







        if (settings.change) {



            settings.change.call(select);



        }



    };







    /**



     * Sets the option elements.



     *



     * @param {String|Object} options



     */



    SelectBox.prototype.setOptions = function (options) {



        var select = $(this.selectElement)



            , control = select.data('selectBox-control');







        switch (typeof(options)) {



            case 'string':



                select.html(options);



                break;



            case 'object':



                select.html('');



                for (var i in options) {



                    if (options[i] === null) {



                        continue;



                    }



                    if (typeof(options[i]) === 'object') {



                        var optgroup = $('<optgroup label="' + i + '" />');



                        for (var j in options[i]) {



                            optgroup.append('<option value="' + j + '">' + options[i][j] + '</option>');



                        }



                        select.append(optgroup);



                    } else {



                        var option = $('<option value="' + i + '">' + options[i] + '</option>');



                        select.append(option);



                    }



                }



                break;



        }







        if (control) {



            // Refresh the control



            this.refresh();



        }



    };







    /**



     * Disables the selection.



     *



     * @param {*} selector



     */



    SelectBox.prototype.disableSelection = function (selector) {



        $(selector).css('MozUserSelect', 'none').bind('selectstart', function (event) {



            event.preventDefault();



        });



    };







    /**



     * Generates the options.



     *



     * @param {jQuery} self



     * @param {jQuery} options



     */



    SelectBox.prototype.generateOptions = function (self, options) {



        var li = $('<li />'), a = $('<a />');



        li.addClass(self.attr('class'));



        li.data(self.data());



        a.attr('rel', self.val()).text(self.text());



        li.append(a);



        if (self.attr('disabled')) {



            li.addClass('selectBox-disabled');



        }



        if (self.attr('selected')) {



            li.addClass('selectBox-selected');



        }



        options.append(li);



    };







    /**



     * Extends the jQuery.fn object.



     */



    $.extend($.fn, {



        selectBox: function (method, options) {



            var selectBox;







            switch (method) {



                case 'control':



                    return $(this).data('selectBox-control');



                case 'settings':



                    if (!options) {



                        return $(this).data('selectBox-settings');



                    }



                    $(this).each(function () {



                        $(this).data('selectBox-settings', $.extend(true, $(this).data('selectBox-settings'), options));



                    });



                    break;



                case 'options':



                    // Getter



                    if (undefined === options) {



                        return $(this).data('selectBox-control').data('selectBox-options');



                    }



                    // Setter



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.setOptions(options);



                        }



                    });



                    break;



                case 'value':



                    // Empty string is a valid value



                    if (undefined === options) {



                        return $(this).val();



                    }



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.setValue(options);



                        }



                    });



                    break;



                case 'refresh':



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.refresh();



                        }



                    });



                    break;



                case 'enable':



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.enable(this);



                        }



                    });



                    break;



                case 'disable':



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.disable();



                        }



                    });



                    break;



                case 'destroy':



                    $(this).each(function () {



                        if (selectBox = $(this).data('selectBox')) {



                            selectBox.destroy();



                            $(this).data('selectBox', null);



                        }



                    });



                    break;



                case 'instance':



                    return $(this).data('selectBox');



                default:



                    $(this).each(function (idx, select) {



                        if (!$(select).data('selectBox')) {



                            $(select).data('selectBox', new SelectBox(select, method));



                        }



                    });



                    break;



            }



            return $(this);



        }



    });



})(jQuery);







var Base64 = {







    // private property



    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",







    // public method for encoding



    encode: function (input) {



        var output = "";



        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;



        var i = 0;



        input = Base64._utf8_encode(input);



        while (i < input.length) {



            chr1 = input.charCodeAt(i++);



            chr2 = input.charCodeAt(i++);



            chr3 = input.charCodeAt(i++);







            enc1 = chr1 >> 2;



            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);



            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);



            enc4 = chr3 & 63;







            if (isNaN(chr2)) {



                enc3 = enc4 = 64;



            } else if (isNaN(chr3)) {



                enc4 = 64;



            }



            output = output +



                this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +



                this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);



        }



        return output;



    },







    // public method for decoding



    decode: function (input) {



        var output = "";



        var chr1, chr2, chr3;



        var enc1, enc2, enc3, enc4;



        var i = 0;







        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");



        while (i < input.length) {



            enc1 = this._keyStr.indexOf(input.charAt(i++));



            enc2 = this._keyStr.indexOf(input.charAt(i++));



            enc3 = this._keyStr.indexOf(input.charAt(i++));



            enc4 = this._keyStr.indexOf(input.charAt(i++));







            chr1 = (enc1 << 2) | (enc2 >> 4);



            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);



            chr3 = ((enc3 & 3) << 6) | enc4;







            output = output + String.fromCharCode(chr1);



            if (enc3 != 64) {



                output = output + String.fromCharCode(chr2);



            }



            if (enc4 != 64) {



                output = output + String.fromCharCode(chr3);



            }



        }



        output = Base64._utf8_decode(output);



        return output;



    },







    // private method for UTF-8 encoding



    _utf8_encode: function (string) {



        string = string.replace(/\r\n/g, "\n");



        var utftext = "";



        for (var n = 0; n < string.length; n++) {



            var c = string.charCodeAt(n);



            if (c < 128) {



                utftext += String.fromCharCode(c);



            } else if ((c > 127) && (c < 2048)) {



                utftext += String.fromCharCode((c >> 6) | 192);



                utftext += String.fromCharCode((c & 63) | 128);



            } else {



                utftext += String.fromCharCode((c >> 12) | 224);



                utftext += String.fromCharCode(((c >> 6) & 63) | 128);



                utftext += String.fromCharCode((c & 63) | 128);



            }







        }



        return utftext;



    },







    // private method for UTF-8 decoding



    _utf8_decode: function (utftext) {



        var string = "";



        var i = 0;



        var c = c1 = c2 = 0;







        while (i < utftext.length) {



            c = utftext.charCodeAt(i);







            if (c < 128) {



                string += String.fromCharCode(c);



                i++;



            } else if ((c > 191) && (c < 224)) {



                c2 = utftext.charCodeAt(i + 1);



                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));



                i += 2;



            } else {



                c2 = utftext.charCodeAt(i + 1);



                c3 = utftext.charCodeAt(i + 2);



                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));



                i += 3;



            }



        }



        return string;



    }







};



Clio_PiwikEventTracker = Class.create();



Clio_PiwikEventTracker.prototype = {



	initialize: function(trackerInstance, paq, category, value)



	{



		if(typeof category == 'undefined'){category = 'SalesFunnel';}







		this.trackerInstance = trackerInstance;



		this.linkTrackingDelay = 0.25;



	    this.paq = paq;



	    this.value = value;



	    this.category = category;







	    this.origSetLocation = setLocation;



	    this.wrapSetLocationFunction();



	    Event.observe(window,'load',function(event){document.fire('clio_piwiktracking:event-tracker-ready');});



    },



    wrapSetLocationFunction: function()



    {



    	setLocation = this.setLocation.bind(this);



    },



    setLocation: function(url)



    {



		this.trackRedirectUrl(url);



	    this.origSetLocation.delay(this.getLinkTrackingDelay(), url);



	},



	trackEvent: function(category, event, value)



	{



		this.paq.push(['trackEvent', category, event, value]);



	},



	getEventByUrl: function(url)



	{



		var event = false;



    	if(url.indexOf('/checkout/cart/add/') != -1){



            event = 'AddToCart';



    	}else if(url.indexOf('/checkout/onepage/') !=-1){



    		event = 'ProceedToCheckout';



    	}



    	return event;



	},



    trackRedirectUrl: function(url, value)



    {



    	if(typeof value == 'undefined'){value = this.value;}



        var event = this.getEventByUrl(url);



    	if(event){



    		this.trackEvent(this.category, event, value);



    	}



    },



    getLinkTrackingDelay: function()



    {



    	return this.linkTrackingDelay;



    }



};







"function" !== typeof Object.create && (Object.create = function(f) {



    function g() {}



    g.prototype = f;



    return new g



}); (function(f, g, k) {



    var l = {



        init: function(a, b) {



            this.$elem = f(b);



            this.options = f.extend({},



            f.fn.owlCarousel.options, this.$elem.data(), a);



            this.userOptions = a;



            this.loadContent()



        },



        loadContent: function() {



            function a(a) {



                var d, e = "";



                if ("function" === typeof b.options.jsonSuccess) b.options.jsonSuccess.apply(this, [a]);



                else {



                    for (d in a.owl) a.owl.hasOwnProperty(d) && (e += a.owl[d].item);



                    b.$elem.html(e)



                }



                b.logIn()



            }



            var b = this,



            e;



            "function" === typeof b.options.beforeInit && b.options.beforeInit.apply(this, [b.$elem]);



            "string" === typeof b.options.jsonPath ? (e = b.options.jsonPath, f.getJSON(e, a)) : b.logIn()



        },



        logIn: function() {



            this.$elem.data("owl-originalStyles", this.$elem.attr("style"));



            this.$elem.data("owl-originalClasses", this.$elem.attr("class"));



            this.$elem.css({



                opacity: 0



            });



            this.orignalItems = this.options.items;



            this.checkBrowser();



            this.wrapperWidth = 0;



            this.checkVisible = null;



            this.setVars()



        },



        setVars: function() {



            if (0 === this.$elem.children().length) return ! 1;



            this.baseClass();



            this.eventTypes();



            this.$userItems = this.$elem.children();



            this.itemsAmount = this.$userItems.length;



            this.wrapItems();



            this.$owlItems = this.$elem.find(".owl-item");



            this.$owlWrapper = this.$elem.find(".owl-wrapper");



            this.playDirection = "next";



            this.prevItem = 0;



            this.prevArr = [0];



            this.currentItem = 0;



            this.customEvents();



            this.onStartup()



        },



        onStartup: function() {



            this.updateItems();



            this.calculateAll();



            this.buildControls();



            this.updateControls();



            this.response();



            this.moveEvents();



            this.stopOnHover();



            this.owlStatus(); ! 1 !== this.options.transitionStyle && this.transitionTypes(this.options.transitionStyle); ! 0 === this.options.autoPlay && (this.options.autoPlay = 5E3);



            this.play();



            this.$elem.find(".owl-wrapper").css("display", "block");



            this.$elem.is(":visible") ? this.$elem.css("opacity", 1) : this.watchVisibility();



            this.onstartup = !1;



            this.eachMoveUpdate();



            "function" === typeof this.options.afterInit && this.options.afterInit.apply(this, [this.$elem])



        },



        eachMoveUpdate: function() { ! 0 === this.options.lazyLoad && this.lazyLoad(); ! 0 === this.options.autoHeight && this.autoHeight();



            this.onVisibleItems();



            "function" === typeof this.options.afterAction && this.options.afterAction.apply(this, [this.$elem])



        },



        updateVars: function() {



            "function" === typeof this.options.beforeUpdate && this.options.beforeUpdate.apply(this, [this.$elem]);



            this.watchVisibility();



            this.updateItems();



            this.calculateAll();



            this.updatePosition();



            this.updateControls();



            this.eachMoveUpdate();



            "function" === typeof this.options.afterUpdate && this.options.afterUpdate.apply(this, [this.$elem])



        },



        reload: function() {



            var a = this;



            g.setTimeout(function() {



                a.updateVars()



            },



            0)



        },



        watchVisibility: function() {



            var a = this;



            if (!1 === a.$elem.is(":visible")) a.$elem.css({



                opacity: 0



            }),



            g.clearInterval(a.autoPlayInterval),



            g.clearInterval(a.checkVisible);



            else return ! 1;



            a.checkVisible = g.setInterval(function() {



                a.$elem.is(":visible") && (a.reload(), a.$elem.animate({



                    opacity: 1



                },



                200), g.clearInterval(a.checkVisible))



            },



            500)



        },



        wrapItems: function() {



            this.$userItems.wrapAll('<div class="owl-wrapper">').wrap('<div class="owl-item"></div>');



            this.$elem.find(".owl-wrapper").wrap('<div class="owl-wrapper-outer">');



            this.wrapperOuter = this.$elem.find(".owl-wrapper-outer");



            this.$elem.css("display", "block")



        },



        baseClass: function() {



            var a = this.$elem.hasClass(this.options.baseClass),



            b = this.$elem.hasClass(this.options.theme);



            a || this.$elem.addClass(this.options.baseClass);



            b || this.$elem.addClass(this.options.theme)



        },



        updateItems: function() {



            var a, b;



            if (!1 === this.options.responsive) return ! 1;



            if (!0 === this.options.singleItem) return this.options.items = this.orignalItems = 1,



            this.options.itemsCustom = !1,



            this.options.itemsDesktop = !1,



            this.options.itemsDesktopSmall = !1,



            this.options.itemsTablet = !1,



            this.options.itemsTabletSmall = !1,



            this.options.itemsMobile = !1;



            a = f(this.options.responsiveBaseWidth).width();



            a > (this.options.itemsDesktop[0] || this.orignalItems) && (this.options.items = this.orignalItems);



            if (!1 !== this.options.itemsCustom) for (this.options.itemsCustom.sort(function(a, b) {



                return a[0] - b[0]



            }), b = 0; b < this.options.itemsCustom.length; b += 1) this.options.itemsCustom[b][0] <= a && (this.options.items = this.options.itemsCustom[b][1]);



            else a <= this.options.itemsDesktop[0] && !1 !== this.options.itemsDesktop && (this.options.items = this.options.itemsDesktop[1]),



            a <= this.options.itemsDesktopSmall[0] && !1 !== this.options.itemsDesktopSmall && (this.options.items = this.options.itemsDesktopSmall[1]),



            a <= this.options.itemsTablet[0] && !1 !== this.options.itemsTablet && (this.options.items = this.options.itemsTablet[1]),



            a <= this.options.itemsTabletSmall[0] && !1 !== this.options.itemsTabletSmall && (this.options.items = this.options.itemsTabletSmall[1]),



            a <= this.options.itemsMobile[0] && !1 !== this.options.itemsMobile && (this.options.items = this.options.itemsMobile[1]);



            this.options.items > this.itemsAmount && !0 === this.options.itemsScaleUp && (this.options.items = this.itemsAmount)



        },



        response: function() {



            var a = this,



            b, e;



            if (!0 !== a.options.responsive) return ! 1;



            e = f(g).width();



            a.resizer = function() {



                f(g).width() !== e && (!1 !== a.options.autoPlay && g.clearInterval(a.autoPlayInterval), g.clearTimeout(b), b = g.setTimeout(function() {



                    e = f(g).width();



                    a.updateVars()



                },



                a.options.responsiveRefreshRate))



            };



            f(g).resize(a.resizer)



        },



        updatePosition: function() {



            this.jumpTo(this.currentItem); ! 1 !== this.options.autoPlay && this.checkAp()



        },



        appendItemsSizes: function() {



            var a = this,



            b = 0,



            e = a.itemsAmount - a.options.items;



            a.$owlItems.each(function(c) {



                var d = f(this);



                d.css({



                    width: a.itemWidth



                }).data("owl-item", Number(c));



                if (0 === c % a.options.items || c === e) c > e || (b += 1);



                d.data("owl-roundPages", b)



            })



        },



        appendWrapperSizes: function() {



            this.$owlWrapper.css({



                width: this.$owlItems.length * this.itemWidth * 2,



                left: 0



            });



            this.appendItemsSizes()



        },



        calculateAll: function() {



            this.calculateWidth();



            this.appendWrapperSizes();



            this.loops();



            this.max()



        },



        calculateWidth: function() {



            this.itemWidth = Math.round(this.$elem.width() / this.options.items)



        },



        max: function() {



            var a = -1 * (this.itemsAmount * this.itemWidth - this.options.items * this.itemWidth);



            this.options.items > this.itemsAmount ? this.maximumPixels = a = this.maximumItem = 0 : (this.maximumItem = this.itemsAmount - this.options.items, this.maximumPixels = a);



            return a



        },



        min: function() {



            return 0



        },



        loops: function() {



            var a = 0,



            b = 0,



            e, c;



            this.positionsInArray = [0];



            this.pagesInArray = [];



            for (e = 0; e < this.itemsAmount; e += 1) b += this.itemWidth,



            this.positionsInArray.push( - b),



            !0 === this.options.scrollPerPage && (c = f(this.$owlItems[e]), c = c.data("owl-roundPages"), c !== a && (this.pagesInArray[a] = this.positionsInArray[e], a = c))



        },



        buildControls: function() {



            if (!0 === this.options.navigation || !0 === this.options.pagination) this.owlControls = f('<div class="owl-controls"/>').toggleClass("clickable", !this.browser.isTouch).appendTo(this.$elem); ! 0 === this.options.pagination && this.buildPagination(); ! 0 === this.options.navigation && this.buildButtons()



        },



        buildButtons: function() {



            var a = this,



            b = f('<div class="owl-buttons"/>');



            a.owlControls.append(b);



            a.buttonPrev = f("<div/>", {



                "class": "owl-prev",



                html: a.options.navigationText[0] || ""



            });



            a.buttonNext = f("<div/>", {



                "class": "owl-next",



                html: a.options.navigationText[1] || ""



            });



            b.append(a.buttonPrev).append(a.buttonNext);



            b.on("touchstart.owlControls mousedown.owlControls", 'div[class^="owl"]',



            function(a) {



                a.preventDefault()



            });



            b.on("touchend.owlControls mouseup.owlControls", 'div[class^="owl"]',



            function(b) {



                b.preventDefault();



                f(this).hasClass("owl-next") ? a.next() : a.prev()



            })



        },



        buildPagination: function() {



            var a = this;



            a.paginationWrapper = f('<div class="owl-pagination"/>');



            a.owlControls.append(a.paginationWrapper);



            a.paginationWrapper.on("touchend.owlControls mouseup.owlControls", ".owl-page",



            function(b) {



                b.preventDefault();



                Number(f(this).data("owl-page")) !== a.currentItem && a.goTo(Number(f(this).data("owl-page")), !0)



            })



        },



        updatePagination: function() {



            var a, b, e, c, d, g;



            if (!1 === this.options.pagination) return ! 1;



            this.paginationWrapper.html("");



            a = 0;



            b = this.itemsAmount - this.itemsAmount % this.options.items;



            for (c = 0; c < this.itemsAmount; c += 1) 0 === c % this.options.items && (a += 1, b === c && (e = this.itemsAmount - this.options.items), d = f("<div/>", {



                "class": "owl-page"



            }), g = f("<span></span>", {



                text: !0 === this.options.paginationNumbers ? a: "",



                "class": !0 === this.options.paginationNumbers ? "owl-numbers": ""



            }), d.append(g), d.data("owl-page", b === c ? e: c), d.data("owl-roundPages", a), this.paginationWrapper.append(d));



            this.checkPagination()



        },



        checkPagination: function() {



            var a = this;



            if (!1 === a.options.pagination) return ! 1;



            a.paginationWrapper.find(".owl-page").each(function() {



                f(this).data("owl-roundPages") === f(a.$owlItems[a.currentItem]).data("owl-roundPages") && (a.paginationWrapper.find(".owl-page").removeClass("active"), f(this).addClass("active"))



            })



        },



        checkNavigation: function() {



            if (!1 === this.options.navigation) return ! 1; ! 1 === this.options.rewindNav && (0 === this.currentItem && 0 === this.maximumItem ? (this.buttonPrev.addClass("disabled"), this.buttonNext.addClass("disabled")) : 0 === this.currentItem && 0 !== this.maximumItem ? (this.buttonPrev.addClass("disabled"), this.buttonNext.removeClass("disabled")) : this.currentItem === this.maximumItem ? (this.buttonPrev.removeClass("disabled"), this.buttonNext.addClass("disabled")) : 0 !== this.currentItem && this.currentItem !== this.maximumItem && (this.buttonPrev.removeClass("disabled"), this.buttonNext.removeClass("disabled")))



        },



        updateControls: function() {



            this.updatePagination();



            this.checkNavigation();



            this.owlControls && (this.options.items >= this.itemsAmount ? this.owlControls.hide() : this.owlControls.show())



        },



        destroyControls: function() {



            this.owlControls && this.owlControls.remove()



        },



        next: function(a) {



            if (this.isTransition) return ! 1;



            this.currentItem += !0 === this.options.scrollPerPage ? this.options.items: 1;



            if (this.currentItem > this.maximumItem + (!0 === this.options.scrollPerPage ? this.options.items - 1 : 0)) if (!0 === this.options.rewindNav) this.currentItem = 0,



            a = "rewind";



            else return this.currentItem = this.maximumItem,



            !1;



            this.goTo(this.currentItem, a)



        },



        prev: function(a) {



            if (this.isTransition) return ! 1;



            this.currentItem = !0 === this.options.scrollPerPage && 0 < this.currentItem && this.currentItem < this.options.items ? 0 : this.currentItem - (!0 === this.options.scrollPerPage ? this.options.items: 1);



            if (0 > this.currentItem) if (!0 === this.options.rewindNav) this.currentItem = this.maximumItem,



            a = "rewind";



            else return this.currentItem = 0,



            !1;



            this.goTo(this.currentItem, a)



        },



        goTo: function(a, b, e) {



            var c = this;



            if (c.isTransition) return ! 1;



            "function" === typeof c.options.beforeMove && c.options.beforeMove.apply(this, [c.$elem]);



            a >= c.maximumItem ? a = c.maximumItem: 0 >= a && (a = 0);



            c.currentItem = c.owl.currentItem = a;



            if (!1 !== c.options.transitionStyle && "drag" !== e && 1 === c.options.items && !0 === c.browser.support3d) return c.swapSpeed(0),



            !0 === c.browser.support3d ? c.transition3d(c.positionsInArray[a]) : c.css2slide(c.positionsInArray[a], 1),



            c.afterGo(),



            c.singleItemTransition(),



            !1;



            a = c.positionsInArray[a]; ! 0 === c.browser.support3d ? (c.isCss3Finish = !1, !0 === b ? (c.swapSpeed("paginationSpeed"), g.setTimeout(function() {



                c.isCss3Finish = !0



            },



            c.options.paginationSpeed)) : "rewind" === b ? (c.swapSpeed(c.options.rewindSpeed), g.setTimeout(function() {



                c.isCss3Finish = !0



            },



            c.options.rewindSpeed)) : (c.swapSpeed("slideSpeed"), g.setTimeout(function() {



                c.isCss3Finish = !0



            },



            c.options.slideSpeed)), c.transition3d(a)) : !0 === b ? c.css2slide(a, c.options.paginationSpeed) : "rewind" === b ? c.css2slide(a, c.options.rewindSpeed) : c.css2slide(a, c.options.slideSpeed);



            c.afterGo()



        },



        jumpTo: function(a) {



            "function" === typeof this.options.beforeMove && this.options.beforeMove.apply(this, [this.$elem]);



            a >= this.maximumItem || -1 === a ? a = this.maximumItem: 0 >= a && (a = 0);



            this.swapSpeed(0); ! 0 === this.browser.support3d ? this.transition3d(this.positionsInArray[a]) : this.css2slide(this.positionsInArray[a], 1);



            this.currentItem = this.owl.currentItem = a;



            this.afterGo()



        },



        afterGo: function() {



            this.prevArr.push(this.currentItem);



            this.prevItem = this.owl.prevItem = this.prevArr[this.prevArr.length - 2];



            this.prevArr.shift(0);



            this.prevItem !== this.currentItem && (this.checkPagination(), this.checkNavigation(), this.eachMoveUpdate(), !1 !== this.options.autoPlay && this.checkAp());



            "function" === typeof this.options.afterMove && this.prevItem !== this.currentItem && this.options.afterMove.apply(this, [this.$elem])



        },



        stop: function() {



            this.apStatus = "stop";



            g.clearInterval(this.autoPlayInterval)



        },



        checkAp: function() {



            "stop" !== this.apStatus && this.play()



        },



        play: function() {



            var a = this;



            a.apStatus = "play";



            if (!1 === a.options.autoPlay) return ! 1;



            g.clearInterval(a.autoPlayInterval);



            a.autoPlayInterval = g.setInterval(function() {



                a.next(!0)



            },



            a.options.autoPlay)



        },



        swapSpeed: function(a) {



            "slideSpeed" === a ? this.$owlWrapper.css(this.addCssSpeed(this.options.slideSpeed)) : "paginationSpeed" === a ? this.$owlWrapper.css(this.addCssSpeed(this.options.paginationSpeed)) : "string" !== typeof a && this.$owlWrapper.css(this.addCssSpeed(a))



        },



        addCssSpeed: function(a) {



            return {



                "-webkit-transition": "all " + a + "ms ease",



                "-moz-transition": "all " + a + "ms ease",



                "-o-transition": "all " + a + "ms ease",



                transition: "all " + a + "ms ease"



            }



        },



        removeTransition: function() {



            return {



                "-webkit-transition": "",



                "-moz-transition": "",



                "-o-transition": "",



                transition: ""



            }



        },



        doTranslate: function(a) {



            return {



                "-webkit-transform": "translate3d(" + a + "px, 0px, 0px)",



                "-moz-transform": "translate3d(" + a + "px, 0px, 0px)",



                "-o-transform": "translate3d(" + a + "px, 0px, 0px)",



                "-ms-transform": "translate3d(" + a + "px, 0px, 0px)",



                transform: "translate3d(" + a + "px, 0px,0px)"



            }



        },



        transition3d: function(a) {



            this.$owlWrapper.css(this.doTranslate(a))



        },



        css2move: function(a) {



            this.$owlWrapper.css({



                left: a



            })



        },



        css2slide: function(a, b) {



            var e = this;



            e.isCssFinish = !1;



            e.$owlWrapper.stop(!0, !0).animate({



                left: a



            },



            {



                duration: b || e.options.slideSpeed,



                complete: function() {



                    e.isCssFinish = !0



                }



            })



        },



        checkBrowser: function() {



            var a = k.createElement("div");



            a.style.cssText = "  -moz-transform:translate3d(0px, 0px, 0px); -ms-transform:translate3d(0px, 0px, 0px); -o-transform:translate3d(0px, 0px, 0px); -webkit-transform:translate3d(0px, 0px, 0px); transform:translate3d(0px, 0px, 0px)";



            a = a.style.cssText.match(/translate3d\(0px, 0px, 0px\)/g);



            this.browser = {



                support3d: null !== a && 1 === a.length,



                isTouch: "ontouchstart" in g || g.navigator.msMaxTouchPoints



            }



        },



        moveEvents: function() {



            if (!1 !== this.options.mouseDrag || !1 !== this.options.touchDrag) this.gestures(),



            this.disabledEvents()



        },



        eventTypes: function() {



            var a = ["s", "e", "x"];



            this.ev_types = {}; ! 0 === this.options.mouseDrag && !0 === this.options.touchDrag ? a = ["https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchstart.owl mousedown.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchmove.owl mousemove.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchend.owl touchcancel.owl mouseup.owl"] : !1 === this.options.mouseDrag && !0 === this.options.touchDrag ? a = ["https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchstart.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchmove.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchend.owl touchcancel.owl"] : !0 === this.options.mouseDrag && !1 === this.options.touchDrag && (a = ["https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/mousedown.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/mousemove.owl", "https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/mouseup.owl"]);



            this.ev_types.start = a[0];



            this.ev_types.move = a[1];



            this.ev_types.end = a[2]



        },



        disabledEvents: function() {



            this.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/dragstart.owl",



            function(a) {



                a.preventDefault()



            });



            this.$elem.on("mousedown.disableTextSelect",



            function(a) {



                return f(a.target).is("input, textarea, select, option")



            })



        },



        gestures: function() {



            function a(a) {



                if (void 0 !== a.touches) return {



                    x: a.touches[0].pageX,



                    y: a.touches[0].pageY



                };



                if (void 0 === a.touches) {



                    if (void 0 !== a.pageX) return {



                        x: a.pageX,



                        y: a.pageY



                    };



                    if (void 0 === a.pageX) return {



                        x: a.clientX,



                        y: a.clientY



                    }



                }



            }



            function b(a) {



                "on" === a ? (f(k).on(d.ev_types.move, e), f(k).on(d.ev_types.end, c)) : "off" === a && (f(k).off(d.ev_types.move), f(k).off(d.ev_types.end))



            }



            function e(b) {



                b = b.originalEvent || b || g.event;



                d.newPosX = a(b).x - h.offsetX;



                d.newPosY = a(b).y - h.offsetY;



                d.newRelativeX = d.newPosX - h.relativePos;



                "function" === typeof d.options.startDragging && !0 !== h.dragging && 0 !== d.newRelativeX && (h.dragging = !0, d.options.startDragging.apply(d, [d.$elem])); (8 < d.newRelativeX || -8 > d.newRelativeX) && !0 === d.browser.isTouch && (void 0 !== b.preventDefault ? b.preventDefault() : b.returnValue = !1, h.sliding = !0); (10 < d.newPosY || -10 > d.newPosY) && !1 === h.sliding && f(k).off("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/touchmove.owl");



                d.newPosX = Math.max(Math.min(d.newPosX, d.newRelativeX / 5), d.maximumPixels + d.newRelativeX / 5); ! 0 === d.browser.support3d ? d.transition3d(d.newPosX) : d.css2move(d.newPosX)



            }



            function c(a) {



                a = a.originalEvent || a || g.event;



                var c;



                a.target = a.target || a.srcElement;



                h.dragging = !1; ! 0 !== d.browser.isTouch && d.$owlWrapper.removeClass("grabbing");



                d.dragDirection = 0 > d.newRelativeX ? d.owl.dragDirection = "left": d.owl.dragDirection = "right";



                0 !== d.newRelativeX && (c = d.getNewPosition(), d.goTo(c, !1, "drag"), h.targetElement === a.target && !0 !== d.browser.isTouch && (f(a.target).on("click.disable",



                function(a) {



                    a.stopImmediatePropagation();



                    a.stopPropagation();



                    a.preventDefault();



                    f(a.target).off("click.disable")



                }), a = f._data(a.target, "events").click, c = a.pop(), a.splice(0, 0, c)));



                b("off")



            }



            var d = this,



            h = {



                offsetX: 0,



                offsetY: 0,



                baseElWidth: 0,



                relativePos: 0,



                position: null,



                minSwipe: null,



                maxSwipe: null,



                sliding: null,



                dargging: null,



                targetElement: null



            };



            d.isCssFinish = !0;



            d.$elem.on(d.ev_types.start, ".owl-wrapper",



            function(c) {



                c = c.originalEvent || c || g.event;



                var e;



                if (3 === c.which) return ! 1;



                if (! (d.itemsAmount <= d.options.items)) {



                    if (!1 === d.isCssFinish && !d.options.dragBeforeAnimFinish || !1 === d.isCss3Finish && !d.options.dragBeforeAnimFinish) return ! 1; ! 1 !== d.options.autoPlay && g.clearInterval(d.autoPlayInterval); ! 0 === d.browser.isTouch || d.$owlWrapper.hasClass("grabbing") || d.$owlWrapper.addClass("grabbing");



                    d.newPosX = 0;



                    d.newRelativeX = 0;



                    f(this).css(d.removeTransition());



                    e = f(this).position();



                    h.relativePos = e.left;



                    h.offsetX = a(c).x - e.left;



                    h.offsetY = a(c).y - e.top;



                    b("on");



                    h.sliding = !1;



                    h.targetElement = c.target || c.srcElement



                }



            })



        },



        getNewPosition: function() {



            var a = this.closestItem();



            a > this.maximumItem ? a = this.currentItem = this.maximumItem: 0 <= this.newPosX && (this.currentItem = a = 0);



            return a



        },



        closestItem: function() {



            var a = this,



            b = !0 === a.options.scrollPerPage ? a.pagesInArray: a.positionsInArray,



            e = a.newPosX,



            c = null;



            f.each(b,



            function(d, g) {



                e - a.itemWidth / 20 > b[d + 1] && e - a.itemWidth / 20 < g && "left" === a.moveDirection() ? (c = g, a.currentItem = !0 === a.options.scrollPerPage ? f.inArray(c, a.positionsInArray) : d) : e + a.itemWidth / 20 < g && e + a.itemWidth / 20 > (b[d + 1] || b[d] - a.itemWidth) && "right" === a.moveDirection() && (!0 === a.options.scrollPerPage ? (c = b[d + 1] || b[b.length - 1], a.currentItem = f.inArray(c, a.positionsInArray)) : (c = b[d + 1], a.currentItem = d + 1))



            });



            return a.currentItem



        },



        moveDirection: function() {



            var a;



            0 > this.newRelativeX ? (a = "right", this.playDirection = "next") : (a = "left", this.playDirection = "prev");



            return a



        },



        customEvents: function() {



            var a = this;



            a.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.next",



            function() {



                a.next()



            });



            a.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.prev",



            function() {



                a.prev()



            });



            a.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.play",



            function(b, e) {



                a.options.autoPlay = e;



                a.play();



                a.hoverStatus = "play"



            });



            a.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.stop",



            function() {



                a.stop();



                a.hoverStatus = "stop"



            });



            a.$elem.on("https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.goTo",



            function(b, e) {



                a.goTo(e)



            });



            a.$elem.on("owl.jumpTo",



            function(b, e) {



                a.jumpTo(e)



            })



        },



        stopOnHover: function() {



            var a = this; ! 0 === a.options.stopOnHover && !0 !== a.browser.isTouch && !1 !== a.options.autoPlay && (a.$elem.on("mouseover",



            function() {



                a.stop()



            }), a.$elem.on("mouseout",



            function() {



                "stop" !== a.hoverStatus && a.play()



            }))



        },



        lazyLoad: function() {



            var a, b, e, c, d;



            if (!1 === this.options.lazyLoad) return ! 1;



            for (a = 0; a < this.itemsAmount; a += 1) b = f(this.$owlItems[a]),



            "loaded" !== b.data("owl-loaded") && (e = b.data("owl-item"), c = b.find(".lazyOwl"), "string" !== typeof c.data("src") ? b.data("owl-loaded", "loaded") : (void 0 === b.data("owl-loaded") && (c.hide(), b.addClass("loading").data("owl-loaded", "checked")), (d = !0 === this.options.lazyFollow ? e >= this.currentItem: !0) && e < this.currentItem + this.options.items && c.length && this.lazyPreload(b, c)))



        },



        lazyPreload: function(a, b) {



            function e() {



                a.data("owl-loaded", "loaded").removeClass("loading");



                b.removeAttr("data-src");



                "fade" === d.options.lazyEffect ? b.fadeIn(400) : b.show();



                "function" === typeof d.options.afterLazyLoad && d.options.afterLazyLoad.apply(this, [d.$elem])



            }



            function c() {



                f += 1;



                d.completeImg(b.get(0)) || !0 === k ? e() : 100 >= f ? g.setTimeout(c, 100) : e()



            }



            var d = this,



            f = 0,



            k;



            "DIV" === b.prop("tagName") ? (b.css("background-image", "url(" + b.data("src") + ")"), k = !0) : b[0].src = b.data("src");



            c()



        },



        autoHeight: function() {



            function a() {



                var a = f(e.$owlItems[e.currentItem]).height();



                e.wrapperOuter.css("height", a + "px");



                e.wrapperOuter.hasClass("autoHeight") || g.setTimeout(function() {



                    e.wrapperOuter.addClass("autoHeight")



                },



                0)



            }



            function b() {



                d += 1;



                e.completeImg(c.get(0)) ? a() : 100 >= d ? g.setTimeout(b, 100) : e.wrapperOuter.css("height", "")



            }



            var e = this,



            c = f(e.$owlItems[e.currentItem]).find("img"),



            d;



            void 0 !== c.get(0) ? (d = 0, b()) : a()



        },



        completeImg: function(a) {



            return ! a.complete || "undefined" !== typeof a.naturalWidth && 0 === a.naturalWidth ? !1 : !0



        },



        onVisibleItems: function() {



            var a; ! 0 === this.options.addClassActive && this.$owlItems.removeClass("active");



            this.visibleItems = [];



            for (a = this.currentItem; a < this.currentItem + this.options.items; a += 1) this.visibleItems.push(a),



            !0 === this.options.addClassActive && f(this.$owlItems[a]).addClass("active");



            this.owl.visibleItems = this.visibleItems



        },



        transitionTypes: function(a) {



            this.outClass = "owl-" + a + "-out";



            this.inClass = "owl-" + a + "-in"



        },



        singleItemTransition: function() {



            var a = this,



            b = a.outClass,



            e = a.inClass,



            c = a.$owlItems.eq(a.currentItem),



            d = a.$owlItems.eq(a.prevItem),



            f = Math.abs(a.positionsInArray[a.currentItem]) + a.positionsInArray[a.prevItem],



            g = Math.abs(a.positionsInArray[a.currentItem]) + a.itemWidth / 2;



            a.isTransition = !0;



            a.$owlWrapper.addClass("owl-origin").css({



                "-webkit-transform-origin": g + "px",



                "-moz-perspective-origin": g + "px",



                "perspective-origin": g + "px"



            });



            d.css({



                position: "relative",



                left: f + "px"



            }).addClass(b).on("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend",



            function() {



                a.endPrev = !0;



                d.off("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend");



                a.clearTransStyle(d, b)



            });



            c.addClass(e).on("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend",



            function() {



                a.endCurrent = !0;



                c.off("webkitAnimationEnd oAnimationEnd MSAnimationEnd animationend");



                a.clearTransStyle(c, e)



            })



        },



        clearTransStyle: function(a, b) {



            a.css({



                position: "",



                left: ""



            }).removeClass(b);



            this.endPrev && this.endCurrent && (this.$owlWrapper.removeClass("owl-origin"), this.isTransition = this.endCurrent = this.endPrev = !1)



        },



        owlStatus: function() {



            this.owl = {



                userOptions: this.userOptions,



                baseElement: this.$elem,



                userItems: this.$userItems,



                owlItems: this.$owlItems,



                currentItem: this.currentItem,



                prevItem: this.prevItem,



                visibleItems: this.visibleItems,



                isTouch: this.browser.isTouch,



                browser: this.browser,



                dragDirection: this.dragDirection



            }



        },



        clearEvents: function() {



            this.$elem.off(".owl owl mousedown.disableTextSelect");



            f(k).off(".owl owl");



            f(g).off("resize", this.resizer)



        },



        unWrap: function() {



            0 !== this.$elem.children().length && (this.$owlWrapper.unwrap(), this.$userItems.unwrap().unwrap(), this.owlControls && this.owlControls.remove());



            this.clearEvents();



            this.$elem.attr("style", this.$elem.data("owl-originalStyles") || "").attr("class", this.$elem.data("owl-originalClasses"))



        },



        destroy: function() {



            this.stop();



            g.clearInterval(this.checkVisible);



            this.unWrap();



            this.$elem.removeData()



        },



        reinit: function(a) {



            a = f.extend({},



            this.userOptions, a);



            this.unWrap();



            this.init(a, this.$elem)



        },



        addItem: function(a, b) {



            var e;



            if (!a) return ! 1;



            if (0 === this.$elem.children().length) return this.$elem.append(a),



            this.setVars(),



            !1;



            this.unWrap();



            e = void 0 === b || -1 === b ? -1 : b;



            e >= this.$userItems.length || -1 === e ? this.$userItems.eq( - 1).after(a) : this.$userItems.eq(e).before(a);



            this.setVars()



        },



        removeItem: function(a) {



            if (0 === this.$elem.children().length) return ! 1;



            a = void 0 === a || -1 === a ? -1 : a;



            this.unWrap();



            this.$userItems.eq(a).remove();



            this.setVars()



        }



    };



    f.fn.owlCarousel = function(a) {



        return this.each(function() {



            if (!0 === f(this).data("owl-init")) return ! 1;



            f(this).data("owl-init", !0);



            var b = Object.create(l);



            b.init(a, this);



            f.data(this, "owlCarousel", b)



        })



    };



    f.fn.owlCarousel.options = {



        items: 5,



        itemsCustom: !1,



        itemsDesktop: [1199, 4],



        itemsDesktopSmall: [979, 3],



        itemsTablet: [768, 2],



        itemsTabletSmall: !1,



        itemsMobile: [479, 1],



        singleItem: !1,



        itemsScaleUp: !1,



        slideSpeed: 200,



        paginationSpeed: 800,



        rewindSpeed: 1E3,



        autoPlay: !1,



        stopOnHover: !1,



        navigation: !1,



        navigationText: ["prev", "next"],



        rewindNav: !0,



        scrollPerPage: !1,



        pagination: !0,



        paginationNumbers: !1,



        responsive: !0,



        responsiveRefreshRate: 200,



        responsiveBaseWidth: g,



        baseClass: "owl-carousel",



        theme: "owl-theme",



        lazyLoad: !1,



        lazyFollow: !0,



        lazyEffect: "fade",



        autoHeight: !1,



        jsonPath: !1,



        jsonSuccess: !1,



        dragBeforeAnimFinish: !0,



        mouseDrag: !0,



        touchDrag: !0,



        addClassActive: !1,



        transitionStyle: !1,



        beforeUpdate: !1,



        afterUpdate: !1,



        beforeInit: !1,



        afterInit: !1,



        beforeMove: !1,



        afterMove: !1,



        afterAction: !1,



        startDragging: !1,



        afterLazyLoad: !1



    }



})(jQuery, window, document);



jQuery(function($) {



	$(window).load(function() {



        var productSlider = $(".product_list.carousel");







        productSlider.owlCarousel({



            theme:  'product-carousel',



            navigation: true,



            pagination: false,



            items : 5,



            itemsDesktop : [1024,4],



            itemsDesktopSmall : [600,3],



            itemsTablet: [480,2],



            itemsMobile : false



        });



	});



});







jQuery(function($){



	//Home Banner Slider



	$(window).load(function(){



		var slider = $('#home_slider');



	    slider.owlCarousel({



	        autoPlay : 7000,



	        stopOnHover : true,



	        //navigation:true,



	        theme: 'pv-theme',



	        lazyLoad: true,



	        pagination: true,



	        paginationSpeed : 1000,



	        goToFirstSpeed : 2000,



	        singleItem : true,



	        autoHeight : false,



	        transitionStyle:"fade"



	    });







		//Home Logos Slider



		var logoSlider = $('.categs-list');



	    logoSlider.owlCarousel({



	        theme: 'pv-logos',



	        pagination: false,



	        items : 5,



	        itemsDesktop : [1200,4],



	        itemsDesktopSmall : [992,3],



	        itemsTablet: [767,2],



	        itemsMobile : [480,1]



	    });



	    // Custom Navigation Events



	    $("#categs_next").click(function(){



	        logoSlider.trigger('https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.next');



	    })



	    $("#categs_prev").click(function(){



	        logoSlider.trigger('https://www.beststoreitems.com/catalog/template/beststoreitems/media/js/owl.prev');



	    })



	});



});







Clio_AjaxCatalogNavigation = Class.create();



Clio_AjaxCatalogNavigation.prototype = {



	initialize: function(selector, url, event)



	{



		this.selector = selector;



		this.url = url;



		this.event = event;



		this.categoryIds = [];



		this.loadedCategories = [];



		this.categoriesNumber = 0;



        document.observe(event, this.loadMenuContents.bindAsEventListener(this));



	},



	loadMenuContents: function(event)



	{



	    $$(this.selector).each(this.collectCategoriesIds, this);



	    for (var elementId in this.categoryIds) {



	    	if(!this.categoryIds.hasOwnProperty(elementId)){continue;}



	    	this.categoriesNumber++;



	    }



	    for (var elementId in this.categoryIds) {



	    	if(!this.categoryIds.hasOwnProperty(elementId)){continue;}



	    	var categoryId = this.categoryIds[elementId];



	    	if(categoryId){



				new Ajax.Updater(elementId, this.url, {



					  method: 'get',



					  insertion: 'bottom',



					  evalScripts: true,



					  parameters: { id: categoryId },



					  onComplete: this.registerLoad.bind(this, categoryId)



				});



	    	}



	    }



	},



	collectCategoriesIds: function(element)



	{



		var id = element.readAttribute('id');



		this.categoryIds[id] = parseInt(id.match(/\d+/i).first());



	},



	registerLoad: function(categoryId)



	{



		this.loadedCategories.push(categoryId);



		if(this.loadedCategories.length == this.categoriesNumber){



			document.fire('ajaxcatalognavigation:complete',{});



		}



	}



};



