
var MooTools = {
'version': '1.2.4',
'build': '0d9113241a90b9cd5643b926795852a2026710d4'
};
var Native = function(options){
options = options || {};
var name = options.name;
var legacy = options.legacy;
var protect = options.protect;
var methods = options.implement;
var generics = options.generics;
var initialize = options.initialize;
var afterImplement = options.afterImplement || function(){};
var object = initialize || legacy;
generics = generics !== false;
object.constructor = Native;
object.$family = {name: 'native'};
if (legacy && initialize) object.prototype = legacy.prototype;
object.prototype.constructor = object;
if (name){
var family = name.toLowerCase();
object.prototype.$family = {name: family};
Native.typize(object, family);
}
var add = function(obj, name, method, force){
if (!protect || force || !obj.prototype[name]) obj.prototype[name] = method;
if (generics) Native.genericize(obj, name, protect);
afterImplement.call(obj, name, method);
return obj;
};
object.alias = function(a1, a2, a3){
if (typeof a1 == 'string'){
var pa1 = this.prototype[a1];
if ((a1 = pa1)) return add(this, a2, a1, a3);
}
for (var a in a1) this.alias(a, a1[a], a2);
return this;
};
object.implement = function(a1, a2, a3){
if (typeof a1 == 'string') return add(this, a1, a2, a3);
for (var p in a1) add(this, p, a1[p], a2);
return this;
};
if (methods) object.implement(methods);
return object;
};
Native.genericize = function(object, property, check){
if ((!check || !object[property]) && typeof object.prototype[property] == 'function') object[property] = function(){
var args = Array.prototype.slice.call(arguments);
return object.prototype[property].apply(args.shift(), args);
};
};
Native.implement = function(objects, properties){
for (var i = 0, l = objects.length; i < l; i++) objects[i].implement(properties);
};
Native.typize = function(object, family){
if (!object.type) object.type = function(item){
return ($type(item) === family);
};
};
(function(){
var natives = {'Array': Array, 'Date': Date, 'Function': Function, 'Number': Number, 'RegExp': RegExp, 'String': String};
for (var n in natives) new Native({name: n, initialize: natives[n], protect: true});
var types = {'boolean': Boolean, 'native': Native, 'object': Object};
for (var t in types) Native.typize(types[t], t);
var generics = {
'Array': ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"],
'String': ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"]
};
for (var g in generics){
for (var i = generics[g].length; i--;) Native.genericize(natives[g], generics[g][i], true);
}
})();
var Hash = new Native({
name: 'Hash',
initialize: function(object){
if ($type(object) == 'hash') object = $unlink(object.getClean());
for (var key in object) this[key] = object[key];
return this;
}
});
Hash.implement({
forEach: function(fn, bind){
for (var key in this){
if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this);
}
},
getClean: function(){
var clean = {};
for (var key in this){
if (this.hasOwnProperty(key)) clean[key] = this[key];
}
return clean;
},
getLength: function(){
var length = 0;
for (var key in this){
if (this.hasOwnProperty(key)) length++;
}
return length;
}
});
Hash.alias('forEach', 'each');
Array.implement({
forEach: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++) fn.call(bind, this[i], i, this);
}
});
Array.alias('forEach', 'each');
function $A(iterable){
if (iterable.item){
var l = iterable.length, array = new Array(l);
while (l--) array[l] = iterable[l];
return array;
}
return Array.prototype.slice.call(iterable);
};
function $arguments(i){
return function(){
return arguments[i];
};
};
function $chk(obj){
return !!(obj || obj === 0);
};
function $clear(timer){
clearTimeout(timer);
clearInterval(timer);
return null;
};
function $defined(obj){
return (obj != undefined);
};
function $each(iterable, fn, bind){
var type = $type(iterable);
((type == 'arguments' || type == 'collection' || type == 'array') ? Array : Hash).each(iterable, fn, bind);
};
function $empty(){};
function $extend(original, extended){
for (var key in (extended || {})) original[key] = extended[key];
return original;
};
function $H(object){
return new Hash(object);
};
function $lambda(value){
return ($type(value) == 'function') ? value : function(){
return value;
};
};
function $merge(){
var args = Array.slice(arguments);
args.unshift({});
return $mixin.apply(null, args);
};
function $mixin(mix){
for (var i = 1, l = arguments.length; i < l; i++){
var object = arguments[i];
if ($type(object) != 'object') continue;
for (var key in object){
var op = object[key], mp = mix[key];
mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $mixin(mp, op) : $unlink(op);
}
}
return mix;
};
function $pick(){
for (var i = 0, l = arguments.length; i < l; i++){
if (arguments[i] != undefined) return arguments[i];
}
return null;
};
function $random(min, max){
return Math.floor(Math.random() * (max - min + 1) + min);
};
function $splat(obj){
var type = $type(obj);
return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : [];
};
var $time = Date.now || function(){
return +new Date;
};
function $try(){
for (var i = 0, l = arguments.length; i < l; i++){
try {
return arguments[i]();
} catch(e){}
}
return null;
};
function $type(obj){
if (obj == undefined) return false;
if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name;
if (obj.nodeName){
switch (obj.nodeType){
case 1: return 'element';
case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
}
} else if (typeof obj.length == 'number'){
if (obj.callee) return 'arguments';
else if (obj.item) return 'collection';
}
return typeof obj;
};
function $unlink(object){
var unlinked;
switch ($type(object)){
case 'object':
unlinked = {};
for (var p in object) unlinked[p] = $unlink(object[p]);
break;
case 'hash':
unlinked = new Hash(object);
break;
case 'array':
unlinked = [];
for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]);
break;
default: return object;
}
return unlinked;
};
var Browser = $merge({
Engine: {name: 'unknown', version: 0},
Platform: {name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()},
Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)},
Plugins: {},
Engines: {
presto: function(){
return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925));
},
trident: function(){
return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4);
},
webkit: function(){
return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419);
},
gecko: function(){
return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18);
}
}
}, Browser || {});
Browser.Platform[Browser.Platform.name] = true;
Browser.detect = function(){
for (var engine in this.Engines){
var version = this.Engines[engine]();
if (version){
this.Engine = {name: engine, version: version};
this.Engine[engine] = this.Engine[engine + version] = true;
break;
}
}
return {name: engine, version: version};
};
Browser.detect();
Browser.Request = function(){
return $try(function(){
return new XMLHttpRequest();
}, function(){
return new ActiveXObject('MSXML2.XMLHTTP');
}, function(){
return new ActiveXObject('Microsoft.XMLHTTP');
});
};
Browser.Features.xhr = !!(Browser.Request());
Browser.Plugins.Flash = (function(){
var version = ($try(function(){
return navigator.plugins['Shockwave Flash'].description;
}, function(){
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
}) || '0 r0').match(/\d+/g);
return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0};
})();
function $exec(text){
if (!text) return text;
if (window.execScript){
window.execScript(text);
} else {
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;
document.head.appendChild(script);
document.head.removeChild(script);
}
return text;
};
Native.UID = 1;
var $uid = (Browser.Engine.trident) ? function(item){
return (item.uid || (item.uid = [Native.UID++]))[0];
} : function(item){
return item.uid || (item.uid = Native.UID++);
};
var Window = new Native({
name: 'Window',
legacy: (Browser.Engine.trident) ? null: window.Window,
initialize: function(win){
$uid(win);
if (!win.Element){
win.Element = $empty;
if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2
win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {};
}
win.document.window = win;
return $extend(win, Window.Prototype);
},
afterImplement: function(property, value){
window[property] = Window.Prototype[property] = value;
}
});
Window.Prototype = {$family: {name: 'window'}};
new Window(window);
var Document = new Native({
name: 'Document',
legacy: (Browser.Engine.trident) ? null: window.Document,
initialize: function(doc){
$uid(doc);
doc.head = doc.getElementsByTagName('head')[0];
doc.html = doc.getElementsByTagName('html')[0];
if (Browser.Engine.trident && Browser.Engine.version <= 4) $try(function(){
doc.execCommand("BackgroundImageCache", false, true);
});
if (Browser.Engine.trident) doc.window.attachEvent('onunload', function(){
doc.window.detachEvent('onunload', arguments.callee);
doc.head = doc.html = doc.window = null;
});
return $extend(doc, Document.Prototype);
},
afterImplement: function(property, value){
document[property] = Document.Prototype[property] = value;
}
});
Document.Prototype = {$family: {name: 'document'}};
new Document(document);
Array.implement({
every: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){
if (!fn.call(bind, this[i], i, this)) return false;
}
return true;
},
filter: function(fn, bind){
var results = [];
for (var i = 0, l = this.length; i < l; i++){
if (fn.call(bind, this[i], i, this)) results.push(this[i]);
}
return results;
},
clean: function(){
return this.filter($defined);
},
indexOf: function(item, from){
var len = this.length;
for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
if (this[i] === item) return i;
}
return -1;
},
map: function(fn, bind){
var results = [];
for (var i = 0, l = this.length; i < l; i++) results[i] = fn.call(bind, this[i], i, this);
return results;
},
some: function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){
if (fn.call(bind, this[i], i, this)) return true;
}
return false;
},
associate: function(keys){
var obj = {}, length = Math.min(this.length, keys.length);
for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
return obj;
},
link: function(object){
var result = {};
for (var i = 0, l = this.length; i < l; i++){
for (var key in object){
if (object[key](this[i])){
result[key] = this[i];
delete object[key];
break;
}
}
}
return result;
},
contains: function(item, from){
return this.indexOf(item, from) != -1;
},
extend: function(array){
for (var i = 0, j = array.length; i < j; i++) this.push(array[i]);
return this;
},
getLast: function(){
return (this.length) ? this[this.length - 1] : null;
},
getRandom: function(){
return (this.length) ? this[$random(0, this.length - 1)] : null;
},
include: function(item){
if (!this.contains(item)) this.push(item);
return this;
},
combine: function(array){
for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
return this;
},
erase: function(item){
for (var i = this.length; i--; i){
if (this[i] === item) this.splice(i, 1);
}
return this;
},
empty: function(){
this.length = 0;
return this;
},
flatten: function(){
var array = [];
for (var i = 0, l = this.length; i < l; i++){
var type = $type(this[i]);
if (!type) continue;
array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]);
}
return array;
},
hexToRgb: function(array){
if (this.length != 3) return null;
var rgb = this.map(function(value){
if (value.length == 1) value += value;
return value.toInt(16);
});
return (array) ? rgb : 'rgb(' + rgb + ')';
},
rgbToHex: function(array){
if (this.length < 3) return null;
if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
var hex = [];
for (var i = 0; i < 3; i++){
var bit = (this[i] - 0).toString(16);
hex.push((bit.length == 1) ? '0' + bit : bit);
}
return (array) ? hex : '#' + hex.join('');
}
});
Function.implement({
extend: function(properties){
for (var property in properties) this[property] = properties[property];
return this;
},
create: function(options){
var self = this;
options = options || {};
return function(event){
var args = options.arguments;
args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0);
if (options.event) args = [event || window.event].extend(args);
var returns = function(){
return self.apply(options.bind || null, args);
};
if (options.delay) return setTimeout(returns, options.delay);
if (options.periodical) return setInterval(returns, options.periodical);
if (options.attempt) return $try(returns);
return returns();
};
},
run: function(args, bind){
return this.apply(bind, $splat(args));
},
pass: function(args, bind){
return this.create({bind: bind, arguments: args});
},
bind: function(bind, args){
return this.create({bind: bind, arguments: args});
},
bindWithEvent: function(bind, args){
return this.create({bind: bind, arguments: args, event: true});
},
attempt: function(args, bind){
return this.create({bind: bind, arguments: args, attempt: true})();
},
delay: function(delay, bind, args){
return this.create({bind: bind, arguments: args, delay: delay})();
},
periodical: function(periodical, bind, args){
return this.create({bind: bind, arguments: args, periodical: periodical})();
}
});
Number.implement({
limit: function(min, max){
return Math.min(max, Math.max(min, this));
},
round: function(precision){
precision = Math.pow(10, precision || 0);
return Math.round(this * precision) / precision;
},
times: function(fn, bind){
for (var i = 0; i < this; i++) fn.call(bind, i, this);
},
toFloat: function(){
return parseFloat(this);
},
toInt: function(base){
return parseInt(this, base || 10);
}
});
Number.alias('times', 'each');
(function(math){
var methods = {};
math.each(function(name){
if (!Number[name]) methods[name] = function(){
return Math[name].apply(null, [this].concat($A(arguments)));
};
});
Number.implement(methods);
})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
String.implement({
test: function(regex, params){
return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);
},
contains: function(string, separator){
return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
},
trim: function(){
return this.replace(/^\s+|\s+$/g, '');
},
clean: function(){
return this.replace(/\s+/g, ' ').trim();
},
camelCase: function(){
return this.replace(/-\D/g, function(match){
return match.charAt(1).toUpperCase();
});
},
hyphenate: function(){
return this.replace(/[A-Z]/g, function(match){
return ('-' + match.charAt(0).toLowerCase());
});
},
capitalize: function(){
return this.replace(/\b[a-z]/g, function(match){
return match.toUpperCase();
});
},
escapeRegExp: function(){
return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
toInt: function(base){
return parseInt(this, base || 10);
},
toFloat: function(){
return parseFloat(this);
},
hexToRgb: function(array){
var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex) ? hex.slice(1).hexToRgb(array) : null;
},
rgbToHex: function(array){
var rgb = this.match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHex(array) : null;
},
stripScripts: function(option){
var scripts = '';
var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){
scripts += arguments[1] + '\n';
return '';
});
if (option === true) $exec(scripts);
else if ($type(option) == 'function') option(scripts, text);
return text;
},
substitute: function(object, regexp){
return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] != undefined) ? object[name] : '';
});
}
});
Hash.implement({
has: Object.prototype.hasOwnProperty,
keyOf: function(value){
for (var key in this){
if (this.hasOwnProperty(key) && this[key] === value) return key;
}
return null;
},
hasValue: function(value){
return (Hash.keyOf(this, value) !== null);
},
extend: function(properties){
Hash.each(properties || {}, function(value, key){
Hash.set(this, key, value);
}, this);
return this;
},
combine: function(properties){
Hash.each(properties || {}, function(value, key){
Hash.include(this, key, value);
}, this);
return this;
},
erase: function(key){
if (this.hasOwnProperty(key)) delete this[key];
return this;
},
get: function(key){
return (this.hasOwnProperty(key)) ? this[key] : null;
},
set: function(key, value){
if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
return this;
},
empty: function(){
Hash.each(this, function(value, key){
delete this[key];
}, this);
return this;
},
include: function(key, value){
if (this[key] == undefined) this[key] = value;
return this;
},
map: function(fn, bind){
var results = new Hash;
Hash.each(this, function(value, key){
results.set(key, fn.call(bind, value, key, this));
}, this);
return results;
},
filter: function(fn, bind){
var results = new Hash;
Hash.each(this, function(value, key){
if (fn.call(bind, value, key, this)) results.set(key, value);
}, this);
return results;
},
every: function(fn, bind){
for (var key in this){
if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false;
}
return true;
},
some: function(fn, bind){
for (var key in this){
if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true;
}
return false;
},
getKeys: function(){
var keys = [];
Hash.each(this, function(value, key){
keys.push(key);
});
return keys;
},
getValues: function(){
var values = [];
Hash.each(this, function(value){
values.push(value);
});
return values;
},
toQueryString: function(base){
var queryString = [];
Hash.each(this, function(value, key){
if (base) key = base + '[' + key + ']';
var result;
switch ($type(value)){
case 'object': result = Hash.toQueryString(value, key); break;
case 'array':
var qs = {};
value.each(function(val, i){
qs[i] = val;
});
result = Hash.toQueryString(qs, key);
break;
default: result = key + '=' + encodeURIComponent(value);
}
if (value != undefined) queryString.push(result);
});
return queryString.join('&');
}
});
Hash.alias({keyOf: 'indexOf', hasValue: 'contains'});
var Event = new Native({
name: 'Event',
initialize: function(event, win){
win = win || window;
var doc = win.document;
event = event || win.event;
if (event.$extended) return event;
this.$extended = true;
var type = event.type;
var target = event.target || event.srcElement;
while (target && target.nodeType == 3) target = target.parentNode;
if (type.test(/key/)){
var code = event.which || event.keyCode;
var key = Event.Keys.keyOf(code);
if (type == 'keydown'){
var fKey = code - 111;
if (fKey > 0 && fKey < 13) key = 'f' + fKey;
}
key = key || String.fromCharCode(code).toLowerCase();
} else if (type.match(/(click|mouse|menu)/i)){
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
var page = {
x: event.pageX || event.clientX + doc.scrollLeft,
y: event.pageY || event.clientY + doc.scrollTop
};
var client = {
x: (event.pageX) ? event.pageX - win.pageXOffset : event.clientX,
y: (event.pageY) ? event.pageY - win.pageYOffset : event.clientY
};
if (type.match(/DOMMouseScroll|mousewheel/)){
var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
}
var rightClick = (event.which == 3) || (event.button == 2);
var related = null;
if (type.match(/over|out/)){
switch (type){
case 'mouseover': related = event.relatedTarget || event.fromElement; break;
case 'mouseout': related = event.relatedTarget || event.toElement;
}
if (!(function(){
while (related && related.nodeType == 3) related = related.parentNode;
return true;
}).create({attempt: Browser.Engine.gecko})()) related = false;
}
}
return $extend(this, {
event: event,
type: type,
page: page,
client: client,
rightClick: rightClick,
wheel: wheel,
relatedTarget: related,
target: target,
code: code,
key: key,
shift: event.shiftKey,
control: event.ctrlKey,
alt: event.altKey,
meta: event.metaKey
});
}
});
Event.Keys = new Hash({
'enter': 13,
'up': 38,
'down': 40,
'left': 37,
'right': 39,
'esc': 27,
'space': 32,
'backspace': 8,
'tab': 9,
'delete': 46
});
Event.implement({
stop: function(){
return this.stopPropagation().preventDefault();
},
stopPropagation: function(){
if (this.event.stopPropagation) this.event.stopPropagation();
else this.event.cancelBubble = true;
return this;
},
preventDefault: function(){
if (this.event.preventDefault) this.event.preventDefault();
else this.event.returnValue = false;
return this;
}
});
function Class(params){
if (params instanceof Function) params = {initialize: params};
var newClass = function(){
Object.reset(this);
if (newClass._prototyping) return this;
this._current = $empty;
var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;
delete this._current; delete this.caller;
return value;
}.extend(this);
newClass.implement(params);
newClass.constructor = Class;
newClass.prototype.constructor = newClass;
return newClass;
};
Function.prototype.protect = function(){
this._protected = true;
return this;
};
Object.reset = function(object, key){
if (key == null){
for (var p in object) Object.reset(object, p);
return object;
}
delete object[key];
switch ($type(object[key])){
case 'object':
var F = function(){};
F.prototype = object[key];
var i = new F;
object[key] = Object.reset(i);
break;
case 'array': object[key] = $unlink(object[key]); break;
}
return object;
};
new Native({name: 'Class', initialize: Class}).extend({
instantiate: function(F){
F._prototyping = true;
var proto = new F;
delete F._prototyping;
return proto;
},
wrap: function(self, key, method){
if (method._origin) method = method._origin;
return function(){
if (method._protected && this._current == null) throw new Error('The method "' + key + '" cannot be called.');
var caller = this.caller, current = this._current;
this.caller = current; this._current = arguments.callee;
var result = method.apply(this, arguments);
this._current = current; this.caller = caller;
return result;
}.extend({_owner: self, _origin: method, _name: key});
}
});
Class.implement({
implement: function(key, value){
if ($type(key) == 'object'){
for (var p in key) this.implement(p, key[p]);
return this;
}
var mutator = Class.Mutators[key];
if (mutator){
value = mutator.call(this, value);
if (value == null) return this;
}
var proto = this.prototype;
switch ($type(value)){
case 'function':
if (value._hidden) return this;
proto[key] = Class.wrap(this, key, value);
break;
case 'object':
var previous = proto[key];
if ($type(previous) == 'object') $mixin(previous, value);
else proto[key] = $unlink(value);
break;
case 'array':
proto[key] = $unlink(value);
break;
default: proto[key] = value;
}
return this;
}
});
Class.Mutators = {
Extends: function(parent){
this.parent = parent;
this.prototype = Class.instantiate(parent);
this.implement('parent', function(){
var name = this.caller._name, previous = this.caller._owner.parent.prototype[name];
if (!previous) throw new Error('The method "' + name + '" has no parent.');
return previous.apply(this, arguments);
}.protect());
},
Implements: function(items){
$splat(items).each(function(item){
if (item instanceof Function) item = Class.instantiate(item);
this.implement(item);
}, this);
}
};
var Chain = new Class({
$chain: [],
chain: function(){
this.$chain.extend(Array.flatten(arguments));
return this;
},
callChain: function(){
return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
},
clearChain: function(){
this.$chain.empty();
return this;
}
});
var Events = new Class({
$events: {},
addEvent: function(type, fn, internal){
type = Events.removeOn(type);
if (fn != $empty){
this.$events[type] = this.$events[type] || [];
this.$events[type].include(fn);
if (internal) fn.internal = true;
}
return this;
},
addEvents: function(events){
for (var type in events) this.addEvent(type, events[type]);
return this;
},
fireEvent: function(type, args, delay){
type = Events.removeOn(type);
if (!this.$events || !this.$events[type]) return this;
this.$events[type].each(function(fn){
fn.create({'bind': this, 'delay': delay, 'arguments': args})();
}, this);
return this;
},
removeEvent: function(type, fn){
type = Events.removeOn(type);
if (!this.$events[type]) return this;
if (!fn.internal) this.$events[type].erase(fn);
return this;
},
removeEvents: function(events){
var type;
if ($type(events) == 'object'){
for (type in events) this.removeEvent(type, events[type]);
return this;
}
if (events) events = Events.removeOn(events);
for (type in this.$events){
if (events && events != type) continue;
var fns = this.$events[type];
for (var i = fns.length; i--; i) this.removeEvent(type, fns[i]);
}
return this;
}
});
Events.removeOn = function(string){
return string.replace(/^on([A-Z])/, function(full, first){
return first.toLowerCase();
});
};
var Options = new Class({
setOptions: function(){
this.options = $merge.run([this.options].extend(arguments));
if (!this.addEvent) return this;
for (var option in this.options){
if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
this.addEvent(option, this.options[option]);
delete this.options[option];
}
return this;
}
});
var Element = new Native({
name: 'Element',
legacy: window.Element,
initialize: function(tag, props){
var konstructor = Element.Constructors.get(tag);
if (konstructor) return konstructor(props);
if (typeof tag == 'string') return document.newElement(tag, props);
return document.id(tag).set(props);
},
afterImplement: function(key, value){
Element.Prototype[key] = value;
if (Array[key]) return;
Elements.implement(key, function(){
var items = [], elements = true;
for (var i = 0, j = this.length; i < j; i++){
var returns = this[i][key].apply(this[i], arguments);
items.push(returns);
if (elements) elements = ($type(returns) == 'element');
}
return (elements) ? new Elements(items) : items;
});
}
});
Element.Prototype = {$family: {name: 'element'}};
Element.Constructors = new Hash;
var IFrame = new Native({
name: 'IFrame',
generics: false,
initialize: function(){
var params = Array.link(arguments, {properties: Object.type, iframe: $defined});
var props = params.properties || {};
var iframe = document.id(params.iframe);
var onload = props.onload || $empty;
delete props.onload;
props.id = props.name = $pick(props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + $time());
iframe = new Element(iframe || 'iframe', props);
var onFrameLoad = function(){
var host = $try(function(){
return iframe.contentWindow.location.host;
});
if (!host || host == window.location.host){
var win = new Window(iframe.contentWindow);
new Document(iframe.contentWindow.document);
$extend(win.Element.prototype, Element.Prototype);
}
onload.call(iframe.contentWindow, iframe.contentWindow.document);
};
var contentWindow = $try(function(){
return iframe.contentWindow;
});
((contentWindow && contentWindow.document.body) || window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);
return iframe;
}
});
var Elements = new Native({
initialize: function(elements, options){
options = $extend({ddup: true, cash: true}, options);
elements = elements || [];
if (options.ddup || options.cash){
var uniques = {}, returned = [];
for (var i = 0, l = elements.length; i < l; i++){
var el = document.id(elements[i], !options.cash);
if (options.ddup){
if (uniques[el.uid]) continue;
uniques[el.uid] = true;
}
if (el) returned.push(el);
}
elements = returned;
}
return (options.cash) ? $extend(elements, this) : elements;
}
});
Elements.implement({
filter: function(filter, bind){
if (!filter) return this;
return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item){
return item.match(filter);
} : filter, bind));
}
});
Document.implement({
newElement: function(tag, props){
if (Browser.Engine.trident && props){
['name', 'type', 'checked'].each(function(attribute){
if (!props[attribute]) return;
tag += ' ' + attribute + '="' + props[attribute] + '"';
if (attribute != 'checked') delete props[attribute];
});
tag = '<' + tag + '>';
}
return document.id(this.createElement(tag)).set(props);
},
newTextNode: function(text){
return this.createTextNode(text);
},
getDocument: function(){
return this;
},
getWindow: function(){
return this.window;
},
id: (function(){
var types = {
string: function(id, nocash, doc){
id = doc.getElementById(id);
return (id) ? types.element(id, nocash) : null;
},
element: function(el, nocash){
$uid(el);
if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){
var proto = Element.Prototype;
for (var p in proto) el[p] = proto[p];
};
return el;
},
object: function(obj, nocash, doc){
if (obj.toElement) return types.element(obj.toElement(doc), nocash);
return null;
}
};
types.textnode = types.whitespace = types.window = types.document = $arguments(0);
return function(el, nocash, doc){
if (el && el.$family && el.uid) return el;
var type = $type(el);
return (types[type]) ? types[type](el, nocash, doc || document) : null;
};
})()
});
if (window.$ == null) Window.implement({
$: function(el, nc){
return document.id(el, nc, this.document);
}
});
Window.implement({
$$: function(selector){
if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector);
var elements = [];
var args = Array.flatten(arguments);
for (var i = 0, l = args.length; i < l; i++){
var item = args[i];
switch ($type(item)){
case 'element': elements.push(item); break;
case 'string': elements.extend(this.document.getElements(item, true));
}
}
return new Elements(elements);
},
getDocument: function(){
return this.document;
},
getWindow: function(){
return this;
}
});
Native.implement([Element, Document], {
getElement: function(selector, nocash){
return document.id(this.getElements(selector, true)[0] || null, nocash);
},
getElements: function(tags, nocash){
tags = tags.split(',');
var elements = [];
var ddup = (tags.length > 1);
tags.each(function(tag){
var partial = this.getElementsByTagName(tag.trim());
(ddup) ? elements.extend(partial) : elements = partial;
}, this);
return new Elements(elements, {ddup: ddup, cash: !nocash});
}
});
(function(){
var collected = {}, storage = {};
var props = {input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value'};
var get = function(uid){
return (storage[uid] || (storage[uid] = {}));
};
var clean = function(item, retain){
if (!item) return;
var uid = item.uid;
if (Browser.Engine.trident){
if (item.clearAttributes){
var clone = retain && item.cloneNode(false);
item.clearAttributes();
if (clone) item.mergeAttributes(clone);
} else if (item.removeEvents){
item.removeEvents();
}
if ((/object/i).test(item.tagName)){
for (var p in item){
if (typeof item[p] == 'function') item[p] = $empty;
}
Element.dispose(item);
}
}
if (!uid) return;
collected[uid] = storage[uid] = null;
};
var purge = function(){
Hash.each(collected, clean);
if (Browser.Engine.trident) $A(document.getElementsByTagName('object')).each(clean);
if (window.CollectGarbage) CollectGarbage();
collected = storage = null;
};
var walk = function(element, walk, start, match, all, nocash){
var el = element[start || walk];
var elements = [];
while (el){
if (el.nodeType == 1 && (!match || Element.match(el, match))){
if (!all) return document.id(el, nocash);
elements.push(el);
}
el = el[walk];
}
return (all) ? new Elements(elements, {ddup: false, cash: !nocash}) : null;
};
var attributes = {
'html': 'innerHTML',
'class': 'className',
'for': 'htmlFor',
'defaultValue': 'defaultValue',
'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'
};
var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];
var camels = ['value', 'type', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];
bools = bools.associate(bools);
Hash.extend(attributes, bools);
Hash.extend(attributes, camels.associate(camels.map(String.toLowerCase)));
var inserters = {
before: function(context, element){
if (element.parentNode) element.parentNode.insertBefore(context, element);
},
after: function(context, element){
if (!element.parentNode) return;
var next = element.nextSibling;
(next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context);
},
bottom: function(context, element){
element.appendChild(context);
},
top: function(context, element){
var first = element.firstChild;
(first) ? element.insertBefore(context, first) : element.appendChild(context);
}
};
inserters.inside = inserters.bottom;
Hash.each(inserters, function(inserter, where){
where = where.capitalize();
Element.implement('inject' + where, function(el){
inserter(this, document.id(el, true));
return this;
});
Element.implement('grab' + where, function(el){
inserter(document.id(el, true), this);
return this;
});
});
Element.implement({
set: function(prop, value){
switch ($type(prop)){
case 'object':
for (var p in prop) this.set(p, prop[p]);
break;
case 'string':
var property = Element.Properties.get(prop);
(property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);
}
return this;
},
get: function(prop){
var property = Element.Properties.get(prop);
return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);
},
erase: function(prop){
var property = Element.Properties.get(prop);
(property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
return this;
},
setProperty: function(attribute, value){
var key = attributes[attribute];
if (value == undefined) return this.removeProperty(attribute);
if (key && bools[attribute]) value = !!value;
(key) ? this[key] = value : this.setAttribute(attribute, '' + value);
return this;
},
setProperties: function(attributes){
for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
return this;
},
getProperty: function(attribute){
var key = attributes[attribute];
var value = (key) ? this[key] : this.getAttribute(attribute, 2);
return (bools[attribute]) ? !!value : (key) ? value : value || null;
},
getProperties: function(){
var args = $A(arguments);
return args.map(this.getProperty, this).associate(args);
},
removeProperty: function(attribute){
var key = attributes[attribute];
(key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute);
return this;
},
removeProperties: function(){
Array.each(arguments, this.removeProperty, this);
return this;
},
hasClass: function(className){
return this.className.contains(className, ' ');
},
addClass: function(className){
if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
return this;
},
removeClass: function(className){
this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
return this;
},
toggleClass: function(className){
return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
},
adopt: function(){
Array.flatten(arguments).each(function(element){
element = document.id(element, true);
if (element) this.appendChild(element);
}, this);
return this;
},
appendText: function(text, where){
return this.grab(this.getDocument().newTextNode(text), where);
},
grab: function(el, where){
inserters[where || 'bottom'](document.id(el, true), this);
return this;
},
inject: function(el, where){
inserters[where || 'bottom'](this, document.id(el, true));
return this;
},
replaces: function(el){
el = document.id(el, true);
el.parentNode.replaceChild(this, el);
return this;
},
wraps: function(el, where){
el = document.id(el, true);
return this.replaces(el).grab(el, where);
},
getPrevious: function(match, nocash){
return walk(this, 'previousSibling', null, match, false, nocash);
},
getAllPrevious: function(match, nocash){
return walk(this, 'previousSibling', null, match, true, nocash);
},
getNext: function(match, nocash){
return walk(this, 'nextSibling', null, match, false, nocash);
},
getAllNext: function(match, nocash){
return walk(this, 'nextSibling', null, match, true, nocash);
},
getFirst: function(match, nocash){
return walk(this, 'nextSibling', 'firstChild', match, false, nocash);
},
getLast: function(match, nocash){
return walk(this, 'previousSibling', 'lastChild', match, false, nocash);
},
getParent: function(match, nocash){
return walk(this, 'parentNode', null, match, false, nocash);
},
getParents: function(match, nocash){
return walk(this, 'parentNode', null, match, true, nocash);
},
getSiblings: function(match, nocash){
return this.getParent().getChildren(match, nocash).erase(this);
},
getChildren: function(match, nocash){
return walk(this, 'nextSibling', 'firstChild', match, true, nocash);
},
getWindow: function(){
return this.ownerDocument.window;
},
getDocument: function(){
return this.ownerDocument;
},
getElementById: function(id, nocash){
var el = this.ownerDocument.getElementById(id);
if (!el) return null;
for (var parent = el.parentNode; parent != this; parent = parent.parentNode){
if (!parent) return null;
}
return document.id(el, nocash);
},
getSelected: function(){
return new Elements($A(this.options).filter(function(option){
return option.selected;
}));
},
getComputedStyle: function(property){
if (this.currentStyle) return this.currentStyle[property.camelCase()];
var computed = this.getDocument().defaultView.getComputedStyle(this, null);
return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;
},
toQueryString: function(){
var queryString = [];
this.getElements('input, select, textarea', true).each(function(el){
if (!el.name || el.disabled || el.type == 'submit' || el.type == 'reset' || el.type == 'file') return;
var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){
return opt.value;
}) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;
$splat(value).each(function(val){
if (typeof val != 'undefined') queryString.push(el.name + '=' + encodeURIComponent(val));
});
});
return queryString.join('&');
},
clone: function(contents, keepid){
contents = contents !== false;
var clone = this.cloneNode(contents);
var clean = function(node, element){
if (!keepid) node.removeAttribute('id');
if (Browser.Engine.trident){
node.clearAttributes();
node.mergeAttributes(element);
node.removeAttribute('uid');
if (node.options){
var no = node.options, eo = element.options;
for (var j = no.length; j--;) no[j].selected = eo[j].selected;
}
}
var prop = props[element.tagName.toLowerCase()];
if (prop && element[prop]) node[prop] = element[prop];
};
if (contents){
var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*');
for (var i = ce.length; i--;) clean(ce[i], te[i]);
}
clean(clone, this);
return document.id(clone);
},
destroy: function(){
Element.empty(this);
Element.dispose(this);
clean(this, true);
return null;
},
empty: function(){
$A(this.childNodes).each(function(node){
Element.destroy(node);
});
return this;
},
dispose: function(){
return (this.parentNode) ? this.parentNode.removeChild(this) : this;
},
hasChild: function(el){
el = document.id(el, true);
if (!el) return false;
if (Browser.Engine.webkit && Browser.Engine.version < 420) return $A(this.getElementsByTagName(el.tagName)).contains(el);
return (this.contains) ? (this != el && this.contains(el)) : !!(this.compareDocumentPosition(el) & 16);
},
match: function(tag){
return (!tag || (tag == this) || (Element.get(this, 'tag') == tag));
}
});
Native.implement([Element, Window, Document], {
addListener: function(type, fn){
if (type == 'unload'){
var old = fn, self = this;
fn = function(){
self.removeListener('unload', fn);
old();
};
} else {
collected[this.uid] = this;
}
if (this.addEventListener) this.addEventListener(type, fn, false);
else this.attachEvent('on' + type, fn);
return this;
},
removeListener: function(type, fn){
if (this.removeEventListener) this.removeEventListener(type, fn, false);
else this.detachEvent('on' + type, fn);
return this;
},
retrieve: function(property, dflt){
var storage = get(this.uid), prop = storage[property];
if (dflt != undefined && prop == undefined) prop = storage[property] = dflt;
return $pick(prop);
},
store: function(property, value){
var storage = get(this.uid);
storage[property] = value;
return this;
},
eliminate: function(property){
var storage = get(this.uid);
delete storage[property];
return this;
}
});
window.addListener('unload', purge);
})();
Element.Properties = new Hash;
Element.Properties.style = {
set: function(style){
this.style.cssText = style;
},
get: function(){
return this.style.cssText;
},
erase: function(){
this.style.cssText = '';
}
};
Element.Properties.tag = {
get: function(){
return this.tagName.toLowerCase();
}
};
Element.Properties.html = (function(){
var wrapper = document.createElement('div');
var translations = {
table: [1, '<table>', '</table>'],
select: [1, '<select>', '</select>'],
tbody: [2, '<table><tbody>', '</tbody></table>'],
tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']
};
translations.thead = translations.tfoot = translations.tbody;
var html = {
set: function(){
var html = Array.flatten(arguments).join('');
var wrap = Browser.Engine.trident && translations[this.get('tag')];
if (wrap){
var first = wrapper;
first.innerHTML = wrap[1] + html + wrap[2];
for (var i = wrap[0]; i--;) first = first.firstChild;
this.empty().adopt(first.childNodes);
} else {
this.innerHTML = html;
}
}
};
html.erase = html.set;
return html;
})();
if (Browser.Engine.webkit && Browser.Engine.version < 420) Element.Properties.text = {
get: function(){
if (this.innerText) return this.innerText;
var temp = this.ownerDocument.newElement('div', {html: this.innerHTML}).inject(this.ownerDocument.body);
var text = temp.innerText;
temp.destroy();
return text;
}
};
Element.Properties.events = {set: function(events){
this.addEvents(events);
}};
Native.implement([Element, Window, Document], {
addEvent: function(type, fn){
var events = this.retrieve('events', {});
events[type] = events[type] || {'keys': [], 'values': []};
if (events[type].keys.contains(fn)) return this;
events[type].keys.push(fn);
var realType = type, custom = Element.Events.get(type), condition = fn, self = this;
if (custom){
if (custom.onAdd) custom.onAdd.call(this, fn);
if (custom.condition){
condition = function(event){
if (custom.condition.call(this, event)) return fn.call(this, event);
return true;
};
}
realType = custom.base || realType;
}
var defn = function(){
return fn.call(self);
};
var nativeEvent = Element.NativeEvents[realType];
if (nativeEvent){
if (nativeEvent == 2){
defn = function(event){
event = new Event(event, self.getWindow());
if (condition.call(self, event) === false) event.stop();
};
}
this.addListener(realType, defn);
}
events[type].values.push(defn);
return this;
},
removeEvent: function(type, fn){
var events = this.retrieve('events');
if (!events || !events[type]) return this;
var pos = events[type].keys.indexOf(fn);
if (pos == -1) return this;
events[type].keys.splice(pos, 1);
var value = events[type].values.splice(pos, 1)[0];
var custom = Element.Events.get(type);
if (custom){
if (custom.onRemove) custom.onRemove.call(this, fn);
type = custom.base || type;
}
return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this;
},
addEvents: function(events){
for (var event in events) this.addEvent(event, events[event]);
return this;
},
removeEvents: function(events){
var type;
if ($type(events) == 'object'){
for (type in events) this.removeEvent(type, events[type]);
return this;
}
var attached = this.retrieve('events');
if (!attached) return this;
if (!events){
for (type in attached) this.removeEvents(type);
this.eliminate('events');
} else if (attached[events]){
while (attached[events].keys[0]) this.removeEvent(events, attached[events].keys[0]);
attached[events] = null;
}
return this;
},
fireEvent: function(type, args, delay){
var events = this.retrieve('events');
if (!events || !events[type]) return this;
events[type].keys.each(function(fn){
fn.create({'bind': this, 'delay': delay, 'arguments': args})();
}, this);
return this;
},
cloneEvents: function(from, type){
from = document.id(from);
var fevents = from.retrieve('events');
if (!fevents) return this;
if (!type){
for (var evType in fevents) this.cloneEvents(from, evType);
} else if (fevents[type]){
fevents[type].keys.each(function(fn){
this.addEvent(type, fn);
}, this);
}
return this;
}
});
Element.NativeEvents = {
click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
keydown: 2, keypress: 2, keyup: 2, //keyboard
focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements
load: 1, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
error: 1, abort: 1, scroll: 1 //misc
};
(function(){
var $check = function(event){
var related = event.relatedTarget;
if (related == undefined) return true;
if (related === false) return false;
return ($type(this) != 'document' && related != this && related.prefix != 'xul' && !this.hasChild(related));
};
Element.Events = new Hash({
mouseenter: {
base: 'mouseover',
condition: $check
},
mouseleave: {
base: 'mouseout',
condition: $check
},
mousewheel: {
base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel'
}
});
})();
Element.Properties.styles = {set: function(styles){
this.setStyles(styles);
}};
Element.Properties.opacity = {
set: function(opacity, novisibility){
if (!novisibility){
if (opacity == 0){
if (this.style.visibility != 'hidden') this.style.visibility = 'hidden';
} else {
if (this.style.visibility != 'visible') this.style.visibility = 'visible';
}
}
if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;
if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';
this.style.opacity = opacity;
this.store('opacity', opacity);
},
get: function(){
return this.retrieve('opacity', 1);
}
};
Element.implement({
setOpacity: function(value){
return this.set('opacity', value, true);
},
getOpacity: function(){
return this.get('opacity');
},
setStyle: function(property, value){
switch (property){
case 'opacity': return this.set('opacity', parseFloat(value));
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
}
property = property.camelCase();
if ($type(value) != 'string'){
var map = (Element.Styles.get(property) || '@').split(' ');
value = $splat(value).map(function(val, i){
if (!map[i]) return '';
return ($type(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;
}).join(' ');
} else if (value == String(Number(value))){
value = Math.round(value);
}
this.style[property] = value;
return this;
},
getStyle: function(property){
switch (property){
case 'opacity': return this.get('opacity');
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';
}
property = property.camelCase();
var result = this.style[property];
if (!$chk(result)){
result = [];
for (var style in Element.ShortStyles){
if (property != style) continue;
for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));
return result.join(' ');
}
result = this.getComputedStyle(property);
}
if (result){
result = String(result);
var color = result.match(/rgba?\([\d\s,]+\)/);
if (color) result = result.replace(color[0], color[0].rgbToHex());
}
if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(result, 10)))){
if (property.test(/^(height|width)$/)){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
}, this);
return this['offset' + property.capitalize()] - size + 'px';
}
if ((Browser.Engine.presto) && String(result).test('px')) return result;
if (property.test(/(border(.+)Width|margin|padding)/)) return '0px';
}
return result;
},
setStyles: function(styles){
for (var style in styles) this.setStyle(style, styles[style]);
return this;
},
getStyles: function(){
var result = {};
Array.flatten(arguments).each(function(key){
result[key] = this.getStyle(key);
}, this);
return result;
}
});
Element.Styles = new Hash({
left: '@px', top: '@px', bottom: '@px', right: '@px',
width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',
backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',
fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',
margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',
borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',
zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'
});
Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};
['Top', 'Right', 'Bottom', 'Left'].each(function(direction){
var Short = Element.ShortStyles;
var All = Element.Styles;
['margin', 'padding'].each(function(style){
var sd = style + direction;
Short[style][sd] = All[sd] = '@px';
});
var bd = 'border' + direction;
Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';
var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';
Short[bd] = {};
Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';
Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
});
(function(){
Element.implement({
scrollTo: function(x, y){
if (isBody(this)){
this.getWindow().scrollTo(x, y);
} else {
this.scrollLeft = x;
this.scrollTop = y;
}
return this;
},
getSize: function(){
if (isBody(this)) return this.getWindow().getSize();
return {x: this.offsetWidth, y: this.offsetHeight};
},
getScrollSize: function(){
if (isBody(this)) return this.getWindow().getScrollSize();
return {x: this.scrollWidth, y: this.scrollHeight};
},
getScroll: function(){
if (isBody(this)) return this.getWindow().getScroll();
return {x: this.scrollLeft, y: this.scrollTop};
},
getScrolls: function(){
var element = this, position = {x: 0, y: 0};
while (element && !isBody(element)){
position.x += element.scrollLeft;
position.y += element.scrollTop;
element = element.parentNode;
}
return position;
},
getOffsetParent: function(){
var element = this;
if (isBody(element)) return null;
if (!Browser.Engine.trident) return element.offsetParent;
while ((element = element.parentNode) && !isBody(element)){
if (styleString(element, 'position') != 'static') return element;
}
return null;
},
getOffsets: function(){
if (this.getBoundingClientRect){
var bound = this.getBoundingClientRect(),
html = document.id(this.getDocument().documentElement),
htmlScroll = html.getScroll(),
elemScrolls = this.getScrolls(),
elemScroll = this.getScroll(),
isFixed = (styleString(this, 'position') == 'fixed');
return {
x: bound.left.toInt() + elemScrolls.x - elemScroll.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
y: bound.top.toInt()  + elemScrolls.y - elemScroll.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
};
}
var element = this, position = {x: 0, y: 0};
if (isBody(this)) return position;
while (element && !isBody(element)){
position.x += element.offsetLeft;
position.y += element.offsetTop;
if (Browser.Engine.gecko){
if (!borderBox(element)){
position.x += leftBorder(element);
position.y += topBorder(element);
}
var parent = element.parentNode;
if (parent && styleString(parent, 'overflow') != 'visible'){
position.x += leftBorder(parent);
position.y += topBorder(parent);
}
} else if (element != this && Browser.Engine.webkit){
position.x += leftBorder(element);
position.y += topBorder(element);
}
element = element.offsetParent;
}
if (Browser.Engine.gecko && !borderBox(this)){
position.x -= leftBorder(this);
position.y -= topBorder(this);
}
return position;
},
getPosition: function(relative){
if (isBody(this)) return {x: 0, y: 0};
var offset = this.getOffsets(),
scroll = this.getScrolls();
var position = {
x: offset.x - scroll.x,
y: offset.y - scroll.y
};
var relativePosition = (relative && (relative = document.id(relative))) ? relative.getPosition() : {x: 0, y: 0};
return {x: position.x - relativePosition.x, y: position.y - relativePosition.y};
},
getCoordinates: function(element){
if (isBody(this)) return this.getWindow().getCoordinates();
var position = this.getPosition(element),
size = this.getSize();
var obj = {
left: position.x,
top: position.y,
width: size.x,
height: size.y
};
obj.right = obj.left + obj.width;
obj.bottom = obj.top + obj.height;
return obj;
},
computePosition: function(obj){
return {
left: obj.x - styleNumber(this, 'margin-left'),
top: obj.y - styleNumber(this, 'margin-top')
};
},
setPosition: function(obj){
return this.setStyles(this.computePosition(obj));
}
});
Native.implement([Document, Window], {
getSize: function(){
if (Browser.Engine.presto || Browser.Engine.webkit){
var win = this.getWindow();
return {x: win.innerWidth, y: win.innerHeight};
}
var doc = getCompatElement(this);
return {x: doc.clientWidth, y: doc.clientHeight};
},
getScroll: function(){
var win = this.getWindow(), doc = getCompatElement(this);
return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop};
},
getScrollSize: function(){
var doc = getCompatElement(this), min = this.getSize();
return {x: Math.max(doc.scrollWidth, min.x), y: Math.max(doc.scrollHeight, min.y)};
},
getPosition: function(){
return {x: 0, y: 0};
},
getCoordinates: function(){
var size = this.getSize();
return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x};
}
});
var styleString = Element.getComputedStyle;
function styleNumber(element, style){
return styleString(element, style).toInt() || 0;
};
function borderBox(element){
return styleString(element, '-moz-box-sizing') == 'border-box';
};
function topBorder(element){
return styleNumber(element, 'border-top-width');
};
function leftBorder(element){
return styleNumber(element, 'border-left-width');
};
function isBody(element){
return (/^(?:body|html)$/i).test(element.tagName);
};
function getCompatElement(element){
var doc = element.getDocument();
return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
};
})();
Element.alias('setPosition', 'position'); //compatability
Native.implement([Window, Document, Element], {
getHeight: function(){
return this.getSize().y;
},
getWidth: function(){
return this.getSize().x;
},
getScrollTop: function(){
return this.getScroll().y;
},
getScrollLeft: function(){
return this.getScroll().x;
},
getScrollHeight: function(){
return this.getScrollSize().y;
},
getScrollWidth: function(){
return this.getScrollSize().x;
},
getTop: function(){
return this.getPosition().y;
},
getLeft: function(){
return this.getPosition().x;
}
});
Native.implement([Document, Element], {
getElements: function(expression, nocash){
expression = expression.split(',');
var items, local = {};
for (var i = 0, l = expression.length; i < l; i++){
var selector = expression[i], elements = Selectors.Utils.search(this, selector, local);
if (i != 0 && elements.item) elements = $A(elements);
items = (i == 0) ? elements : (items.item) ? $A(items).concat(elements) : items.concat(elements);
}
return new Elements(items, {ddup: (expression.length > 1), cash: !nocash});
}
});
Element.implement({
match: function(selector){
if (!selector || (selector == this)) return true;
var tagid = Selectors.Utils.parseTagAndID(selector);
var tag = tagid[0], id = tagid[1];
if (!Selectors.Filters.byID(this, id) || !Selectors.Filters.byTag(this, tag)) return false;
var parsed = Selectors.Utils.parseSelector(selector);
return (parsed) ? Selectors.Utils.filter(this, parsed, {}) : true;
}
});
var Selectors = {Cache: {nth: {}, parsed: {}}};
Selectors.RegExps = {
id: (/#([\w-]+)/),
tag: (/^(\w+|\*)/),
quick: (/^(\w+|\*)$/),
splitter: (/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),
combined: (/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)
};
Selectors.Utils = {
chk: function(item, uniques){
if (!uniques) return true;
var uid = $uid(item);
if (!uniques[uid]) return uniques[uid] = true;
return false;
},
parseNthArgument: function(argument){
if (Selectors.Cache.nth[argument]) return Selectors.Cache.nth[argument];
var parsed = argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);
if (!parsed) return false;
var inta = parseInt(parsed[1], 10);
var a = (inta || inta === 0) ? inta : 1;
var special = parsed[2] || false;
var b = parseInt(parsed[3], 10) || 0;
if (a != 0){
b--;
while (b < 1) b += a;
while (b >= a) b -= a;
} else {
a = b;
special = 'index';
}
switch (special){
case 'n': parsed = {a: a, b: b, special: 'n'}; break;
case 'odd': parsed = {a: 2, b: 0, special: 'n'}; break;
case 'even': parsed = {a: 2, b: 1, special: 'n'}; break;
case 'first': parsed = {a: 0, special: 'index'}; break;
case 'last': parsed = {special: 'last-child'}; break;
case 'only': parsed = {special: 'only-child'}; break;
default: parsed = {a: (a - 1), special: 'index'};
}
return Selectors.Cache.nth[argument] = parsed;
},
parseSelector: function(selector){
if (Selectors.Cache.parsed[selector]) return Selectors.Cache.parsed[selector];
var m, parsed = {classes: [], pseudos: [], attributes: []};
while ((m = Selectors.RegExps.combined.exec(selector))){
var cn = m[1], an = m[2], ao = m[3], av = m[5], pn = m[6], pa = m[7];
if (cn){
parsed.classes.push(cn);
} else if (pn){
var parser = Selectors.Pseudo.get(pn);
if (parser) parsed.pseudos.push({parser: parser, argument: pa});
else parsed.attributes.push({name: pn, operator: '=', value: pa});
} else if (an){
parsed.attributes.push({name: an, operator: ao, value: av});
}
}
if (!parsed.classes.length) delete parsed.classes;
if (!parsed.attributes.length) delete parsed.attributes;
if (!parsed.pseudos.length) delete parsed.pseudos;
if (!parsed.classes && !parsed.attributes && !parsed.pseudos) parsed = null;
return Selectors.Cache.parsed[selector] = parsed;
},
parseTagAndID: function(selector){
var tag = selector.match(Selectors.RegExps.tag);
var id = selector.match(Selectors.RegExps.id);
return [(tag) ? tag[1] : '*', (id) ? id[1] : false];
},
filter: function(item, parsed, local){
var i;
if (parsed.classes){
for (i = parsed.classes.length; i--; i){
var cn = parsed.classes[i];
if (!Selectors.Filters.byClass(item, cn)) return false;
}
}
if (parsed.attributes){
for (i = parsed.attributes.length; i--; i){
var att = parsed.attributes[i];
if (!Selectors.Filters.byAttribute(item, att.name, att.operator, att.value)) return false;
}
}
if (parsed.pseudos){
for (i = parsed.pseudos.length; i--; i){
var psd = parsed.pseudos[i];
if (!Selectors.Filters.byPseudo(item, psd.parser, psd.argument, local)) return false;
}
}
return true;
},
getByTagAndID: function(ctx, tag, id){
if (id){
var item = (ctx.getElementById) ? ctx.getElementById(id, true) : Element.getElementById(ctx, id, true);
return (item && Selectors.Filters.byTag(item, tag)) ? [item] : [];
} else {
return ctx.getElementsByTagName(tag);
}
},
search: function(self, expression, local){
var splitters = [];
var selectors = expression.trim().replace(Selectors.RegExps.splitter, function(m0, m1, m2){
splitters.push(m1);
return ':)' + m2;
}).split(':)');
var items, filtered, item;
for (var i = 0, l = selectors.length; i < l; i++){
var selector = selectors[i];
if (i == 0 && Selectors.RegExps.quick.test(selector)){
items = self.getElementsByTagName(selector);
continue;
}
var splitter = splitters[i - 1];
var tagid = Selectors.Utils.parseTagAndID(selector);
var tag = tagid[0], id = tagid[1];
if (i == 0){
items = Selectors.Utils.getByTagAndID(self, tag, id);
} else {
var uniques = {}, found = [];
for (var j = 0, k = items.length; j < k; j++) found = Selectors.Getters[splitter](found, items[j], tag, id, uniques);
items = found;
}
var parsed = Selectors.Utils.parseSelector(selector);
if (parsed){
filtered = [];
for (var m = 0, n = items.length; m < n; m++){
item = items[m];
if (Selectors.Utils.filter(item, parsed, local)) filtered.push(item);
}
items = filtered;
}
}
return items;
}
};
Selectors.Getters = {
' ': function(found, self, tag, id, uniques){
var items = Selectors.Utils.getByTagAndID(self, tag, id);
for (var i = 0, l = items.length; i < l; i++){
var item = items[i];
if (Selectors.Utils.chk(item, uniques)) found.push(item);
}
return found;
},
'>': function(found, self, tag, id, uniques){
var children = Selectors.Utils.getByTagAndID(self, tag, id);
for (var i = 0, l = children.length; i < l; i++){
var child = children[i];
if (child.parentNode == self && Selectors.Utils.chk(child, uniques)) found.push(child);
}
return found;
},
'+': function(found, self, tag, id, uniques){
while ((self = self.nextSibling)){
if (self.nodeType == 1){
if (Selectors.Utils.chk(self, uniques) && Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);
break;
}
}
return found;
},
'~': function(found, self, tag, id, uniques){
while ((self = self.nextSibling)){
if (self.nodeType == 1){
if (!Selectors.Utils.chk(self, uniques)) break;
if (Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);
}
}
return found;
}
};
Selectors.Filters = {
byTag: function(self, tag){
return (tag == '*' || (self.tagName && self.tagName.toLowerCase() == tag));
},
byID: function(self, id){
return (!id || (self.id && self.id == id));
},
byClass: function(self, klass){
return (self.className && self.className.contains && self.className.contains(klass, ' '));
},
byPseudo: function(self, parser, argument, local){
return parser.call(self, argument, local);
},
byAttribute: function(self, name, operator, value){
var result = Element.prototype.getProperty.call(self, name);
if (!result) return (operator == '!=');
if (!operator || value == undefined) return true;
switch (operator){
case '=': return (result == value);
case '*=': return (result.contains(value));
case '^=': return (result.substr(0, value.length) == value);
case '$=': return (result.substr(result.length - value.length) == value);
case '!=': return (result != value);
case '~=': return result.contains(value, ' ');
case '|=': return result.contains(value, '-');
}
return false;
}
};
Selectors.Pseudo = new Hash({
checked: function(){
return this.checked;
},
empty: function(){
return !(this.innerText || this.textContent || '').length;
},
not: function(selector){
return !Element.match(this, selector);
},
contains: function(text){
return (this.innerText || this.textContent || '').contains(text);
},
'first-child': function(){
return Selectors.Pseudo.index.call(this, 0);
},
'last-child': function(){
var element = this;
while ((element = element.nextSibling)){
if (element.nodeType == 1) return false;
}
return true;
},
'only-child': function(){
var prev = this;
while ((prev = prev.previousSibling)){
if (prev.nodeType == 1) return false;
}
var next = this;
while ((next = next.nextSibling)){
if (next.nodeType == 1) return false;
}
return true;
},
'nth-child': function(argument, local){
argument = (argument == undefined) ? 'n' : argument;
var parsed = Selectors.Utils.parseNthArgument(argument);
if (parsed.special != 'n') return Selectors.Pseudo[parsed.special].call(this, parsed.a, local);
var count = 0;
local.positions = local.positions || {};
var uid = $uid(this);
if (!local.positions[uid]){
var self = this;
while ((self = self.previousSibling)){
if (self.nodeType != 1) continue;
count ++;
var position = local.positions[$uid(self)];
if (position != undefined){
count = position + count;
break;
}
}
local.positions[uid] = count;
}
return (local.positions[uid] % parsed.a == parsed.b);
},
index: function(index){
var element = this, count = 0;
while ((element = element.previousSibling)){
if (element.nodeType == 1 && ++count > index) return false;
}
return (count == index);
},
even: function(argument, local){
return Selectors.Pseudo['nth-child'].call(this, '2n+1', local);
},
odd: function(argument, local){
return Selectors.Pseudo['nth-child'].call(this, '2n', local);
},
selected: function(){
return this.selected;
},
enabled: function(){
return (this.disabled === false);
}
});
Element.Events.domready = {
onAdd: function(fn){
if (Browser.loaded) fn.call(this);
}
};
(function(){
var domready = function(){
if (Browser.loaded) return;
Browser.loaded = true;
window.fireEvent('domready');
document.fireEvent('domready');
};
window.addEvent('load', domready);
if (Browser.Engine.trident){
var temp = document.createElement('div');
(function(){
($try(function(){
temp.doScroll(); // Technique by Diego Perini
return document.id(temp).inject(document.body).set('html', 'temp').dispose();
})) ? domready() : arguments.callee.delay(50);
})();
} else if (Browser.Engine.webkit && Browser.Engine.version < 525){
(function(){
(['loaded', 'complete'].contains(document.readyState)) ? domready() : arguments.callee.delay(50);
})();
} else {
document.addEvent('DOMContentLoaded', domready);
}
})();
var JSON = new Hash(this.JSON && {
stringify: JSON.stringify,
parse: JSON.parse
}).extend({
$specialChars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'},
$replaceChars: function(chr){
return JSON.$specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16);
},
encode: function(obj){
switch ($type(obj)){
case 'string':
return '"' + obj.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"';
case 'array':
return '[' + String(obj.map(JSON.encode).clean()) + ']';
case 'object': case 'hash':
var string = [];
Hash.each(obj, function(value, key){
var json = JSON.encode(value);
if (json) string.push(JSON.encode(key) + ':' + json);
});
return '{' + string + '}';
case 'number': case 'boolean': return String(obj);
case false: return 'null';
}
return null;
},
decode: function(string, secure){
if ($type(string) != 'string' || !string.length) return null;
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null;
return eval('(' + string + ')');
}
});
Native.implement([Hash, Array, String, Number], {
toJSON: function(){
return JSON.encode(this);
}
});
var Cookie = new Class({
Implements: Options,
options: {
path: false,
domain: false,
duration: false,
secure: false,
document: document
},
initialize: function(key, options){
this.key = key;
this.setOptions(options);
},
write: function(value){
value = encodeURIComponent(value);
if (this.options.domain) value += '; domain=' + this.options.domain;
if (this.options.path) value += '; path=' + this.options.path;
if (this.options.duration){
var date = new Date();
date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);
value += '; expires=' + date.toGMTString();
}
if (this.options.secure) value += '; secure';
this.options.document.cookie = this.key + '=' + value;
return this;
},
read: function(){
var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)');
return (value) ? decodeURIComponent(value[1]) : null;
},
dispose: function(){
new Cookie(this.key, $merge(this.options, {duration: -1})).write('');
return this;
}
});
Cookie.write = function(key, value, options){
return new Cookie(key, options).write(value);
};
Cookie.read = function(key){
return new Cookie(key).read();
};
Cookie.dispose = function(key, options){
return new Cookie(key, options).dispose();
};
var Swiff = new Class({
Implements: [Options],
options: {
id: null,
height: 1,
width: 1,
container: null,
properties: {},
params: {
quality: 'high',
allowScriptAccess: 'always',
wMode: 'transparent',
swLiveConnect: true
},
callBacks: {},
vars: {}
},
toElement: function(){
return this.object;
},
initialize: function(path, options){
this.instance = 'Swiff_' + $time();
this.setOptions(options);
options = this.options;
var id = this.id = options.id || this.instance;
var container = document.id(options.container);
Swiff.CallBacks[this.instance] = {};
var params = options.params, vars = options.vars, callBacks = options.callBacks;
var properties = $extend({height: options.height, width: options.width}, options.properties);
var self = this;
for (var callBack in callBacks){
Swiff.CallBacks[this.instance][callBack] = (function(option){
return function(){
return option.apply(self.object, arguments);
};
})(callBacks[callBack]);
vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;
}
params.flashVars = Hash.toQueryString(vars);
if (Browser.Engine.trident){
properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
params.movie = path;
} else {
properties.type = 'application/x-shockwave-flash';
properties.data = path;
}
var build = '<object id="' + id + '"';
for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';
build += '>';
for (var param in params){
if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';
}
build += '</object>';
this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;
},
replaces: function(element){
element = document.id(element, true);
element.parentNode.replaceChild(this.toElement(), element);
return this;
},
inject: function(element){
document.id(element, true).appendChild(this.toElement());
return this;
},
remote: function(){
return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments));
}
});
Swiff.CallBacks = {};
Swiff.remote = function(obj, fn){
var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');
return eval(rs);
};
var Fx = new Class({
Implements: [Chain, Events, Options],
options: {
fps: 50,
unit: false,
duration: 500,
link: 'ignore'
},
initialize: function(options){
this.subject = this.subject || this;
this.setOptions(options);
this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt();
var wait = this.options.wait;
if (wait === false) this.options.link = 'cancel';
},
getTransition: function(){
return function(p){
return -(Math.cos(Math.PI * p) - 1) / 2;
};
},
step: function(){
var time = $time();
if (time < this.time + this.options.duration){
var delta = this.transition((time - this.time) / this.options.duration);
this.set(this.compute(this.from, this.to, delta));
} else {
this.set(this.compute(this.from, this.to, 1));
this.complete();
}
},
set: function(now){
return now;
},
compute: function(from, to, delta){
return Fx.compute(from, to, delta);
},
check: function(){
if (!this.timer) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
case 'chain': this.chain(this.caller.bind(this, arguments)); return false;
}
return false;
},
start: function(from, to){
if (!this.check(from, to)) return this;
this.from = from;
this.to = to;
this.time = 0;
this.transition = this.getTransition();
this.startTimer();
this.onStart();
return this;
},
complete: function(){
if (this.stopTimer()) this.onComplete();
return this;
},
cancel: function(){
if (this.stopTimer()) this.onCancel();
return this;
},
onStart: function(){
this.fireEvent('start', this.subject);
},
onComplete: function(){
this.fireEvent('complete', this.subject);
if (!this.callChain()) this.fireEvent('chainComplete', this.subject);
},
onCancel: function(){
this.fireEvent('cancel', this.subject).clearChain();
},
pause: function(){
this.stopTimer();
return this;
},
resume: function(){
this.startTimer();
return this;
},
stopTimer: function(){
if (!this.timer) return false;
this.time = $time() - this.time;
this.timer = $clear(this.timer);
return true;
},
startTimer: function(){
if (this.timer) return false;
this.time = $time() - this.time;
this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);
return true;
}
});
Fx.compute = function(from, to, delta){
return (to - from) * delta + from;
};
Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000};
Fx.CSS = new Class({
Extends: Fx,
prepare: function(element, property, values){
values = $splat(values);
var values1 = values[1];
if (!$chk(values1)){
values[1] = values[0];
values[0] = element.getStyle(property);
}
var parsed = values.map(this.parse);
return {from: parsed[0], to: parsed[1]};
},
parse: function(value){
value = $lambda(value)();
value = (typeof value == 'string') ? value.split(' ') : $splat(value);
return value.map(function(val){
val = String(val);
var found = false;
Fx.CSS.Parsers.each(function(parser, key){
if (found) return;
var parsed = parser.parse(val);
if ($chk(parsed)) found = {value: parsed, parser: parser};
});
found = found || {value: val, parser: Fx.CSS.Parsers.String};
return found;
});
},
compute: function(from, to, delta){
var computed = [];
(Math.min(from.length, to.length)).times(function(i){
computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});
});
computed.$family = {name: 'fx:css:value'};
return computed;
},
serve: function(value, unit){
if ($type(value) != 'fx:css:value') value = this.parse(value);
var returned = [];
value.each(function(bit){
returned = returned.concat(bit.parser.serve(bit.value, unit));
});
return returned;
},
render: function(element, property, value, unit){
element.setStyle(property, this.serve(value, unit));
},
search: function(selector){
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];
var to = {};
Array.each(document.styleSheets, function(sheet, j){
var href = sheet.href;
if (href && href.contains('://') && !href.contains(document.domain)) return;
var rules = sheet.rules || sheet.cssRules;
Array.each(rules, function(rule, i){
if (!rule.style) return;
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){
return m.toLowerCase();
}) : null;
if (!selectorText || !selectorText.test('^' + selector + '$')) return;
Element.Styles.each(function(value, style){
if (!rule.style[style] || Element.ShortStyles[style]) return;
value = String(rule.style[style]);
to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value;
});
});
});
return Fx.CSS.Cache[selector] = to;
}
});
Fx.CSS.Cache = {};
Fx.CSS.Parsers = new Hash({
Color: {
parse: function(value){
if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);
return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false;
},
compute: function(from, to, delta){
return from.map(function(value, i){
return Math.round(Fx.compute(from[i], to[i], delta));
});
},
serve: function(value){
return value.map(Number);
}
},
Number: {
parse: parseFloat,
compute: Fx.compute,
serve: function(value, unit){
return (unit) ? value + unit : value;
}
},
String: {
parse: $lambda(false),
compute: $arguments(1),
serve: $arguments(0)
}
});
Fx.Tween = new Class({
Extends: Fx.CSS,
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
},
set: function(property, now){
if (arguments.length == 1){
now = property;
property = this.property || this.options.property;
}
this.render(this.element, property, now, this.options.unit);
return this;
},
start: function(property, from, to){
if (!this.check(property, from, to)) return this;
var args = Array.flatten(arguments);
this.property = this.options.property || args.shift();
var parsed = this.prepare(this.element, this.property, args);
return this.parent(parsed.from, parsed.to);
}
});
Element.Properties.tween = {
set: function(options){
var tween = this.retrieve('tween');
if (tween) tween.cancel();
return this.eliminate('tween').store('tween:options', $extend({link: 'cancel'}, options));
},
get: function(options){
if (options || !this.retrieve('tween')){
if (options || !this.retrieve('tween:options')) this.set('tween', options);
this.store('tween', new Fx.Tween(this, this.retrieve('tween:options')));
}
return this.retrieve('tween');
}
};
Element.implement({
tween: function(property, from, to){
this.get('tween').start(arguments);
return this;
},
fade: function(how){
var fade = this.get('tween'), o = 'opacity', toggle;
how = $pick(how, 'toggle');
switch (how){
case 'in': fade.start(o, 1); break;
case 'out': fade.start(o, 0); break;
case 'show': fade.set(o, 1); break;
case 'hide': fade.set(o, 0); break;
case 'toggle':
var flag = this.retrieve('fade:flag', this.get('opacity') == 1);
fade.start(o, (flag) ? 0 : 1);
this.store('fade:flag', !flag);
toggle = true;
break;
default: fade.start(o, arguments);
}
if (!toggle) this.eliminate('fade:flag');
return this;
},
highlight: function(start, end){
if (!end){
end = this.retrieve('highlight:original', this.getStyle('background-color'));
end = (end == 'transparent') ? '#fff' : end;
}
var tween = this.get('tween');
tween.start('background-color', start || '#ffff88', end).chain(function(){
this.setStyle('background-color', this.retrieve('highlight:original'));
tween.callChain();
}.bind(this));
return this;
}
});
Fx.Morph = new Class({
Extends: Fx.CSS,
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
},
set: function(now){
if (typeof now == 'string') now = this.search(now);
for (var p in now) this.render(this.element, p, now[p], this.options.unit);
return this;
},
compute: function(from, to, delta){
var now = {};
for (var p in from) now[p] = this.parent(from[p], to[p], delta);
return now;
},
start: function(properties){
if (!this.check(properties)) return this;
if (typeof properties == 'string') properties = this.search(properties);
var from = {}, to = {};
for (var p in properties){
var parsed = this.prepare(this.element, p, properties[p]);
from[p] = parsed.from;
to[p] = parsed.to;
}
return this.parent(from, to);
}
});
Element.Properties.morph = {
set: function(options){
var morph = this.retrieve('morph');
if (morph) morph.cancel();
return this.eliminate('morph').store('morph:options', $extend({link: 'cancel'}, options));
},
get: function(options){
if (options || !this.retrieve('morph')){
if (options || !this.retrieve('morph:options')) this.set('morph', options);
this.store('morph', new Fx.Morph(this, this.retrieve('morph:options')));
}
return this.retrieve('morph');
}
};
Element.implement({
morph: function(props){
this.get('morph').start(props);
return this;
}
});
Fx.implement({
getTransition: function(){
var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;
if (typeof trans == 'string'){
var data = trans.split(':');
trans = Fx.Transitions;
trans = trans[data[0]] || trans[data[0].capitalize()];
if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];
}
return trans;
}
});
Fx.Transition = function(transition, params){
params = $splat(params);
return $extend(transition, {
easeIn: function(pos){
return transition(pos, params);
},
easeOut: function(pos){
return 1 - transition(1 - pos, params);
},
easeInOut: function(pos){
return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2;
}
});
};
Fx.Transitions = new Hash({
linear: $arguments(0)
});
Fx.Transitions.extend = function(transitions){
for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);
};
Fx.Transitions.extend({
Pow: function(p, x){
return Math.pow(p, x[0] || 6);
},
Expo: function(p){
return Math.pow(2, 8 * (p - 1));
},
Circ: function(p){
return 1 - Math.sin(Math.acos(p));
},
Sine: function(p){
return 1 - Math.sin((1 - p) * Math.PI / 2);
},
Back: function(p, x){
x = x[0] || 1.618;
return Math.pow(p, 2) * ((x + 1) * p - x);
},
Bounce: function(p){
var value;
for (var a = 0, b = 1; 1; a += b, b /= 2){
if (p >= (7 - 4 * a) / 11){
value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);
break;
}
}
return value;
},
Elastic: function(p, x){
return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
}
});
['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){
Fx.Transitions[transition] = new Fx.Transition(function(p){
return Math.pow(p, [i + 2]);
});
});
var Request = new Class({
Implements: [Chain, Events, Options],
options: {/*
onRequest: $empty,
onComplete: $empty,
onCancel: $empty,
onSuccess: $empty,
onFailure: $empty,
onException: $empty,*/
url: '',
data: '',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
},
async: true,
format: false,
method: 'post',
link: 'ignore',
isSuccess: null,
emulation: true,
urlEncoded: true,
encoding: 'utf-8',
evalScripts: false,
evalResponse: false,
noCache: false
},
initialize: function(options){
this.xhr = new Browser.Request();
this.setOptions(options);
this.options.isSuccess = this.options.isSuccess || this.isSuccess;
this.headers = new Hash(this.options.headers);
},
onStateChange: function(){
if (this.xhr.readyState != 4 || !this.running) return;
this.running = false;
this.status = 0;
$try(function(){
this.status = this.xhr.status;
}.bind(this));
this.xhr.onreadystatechange = $empty;
if (this.options.isSuccess.call(this, this.status)){
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
this.success(this.response.text, this.response.xml);
} else {
this.response = {text: null, xml: null};
this.failure();
}
},
isSuccess: function(){
return ((this.status >= 200) && (this.status < 300));
},
processScripts: function(text){
if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return $exec(text);
return text.stripScripts(this.options.evalScripts);
},
success: function(text, xml){
this.onSuccess(this.processScripts(text), xml);
},
onSuccess: function(){
this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();
},
failure: function(){
this.onFailure();
},
onFailure: function(){
this.fireEvent('complete').fireEvent('failure', this.xhr);
},
setHeader: function(name, value){
this.headers.set(name, value);
return this;
},
getHeader: function(name){
return $try(function(){
return this.xhr.getResponseHeader(name);
}.bind(this));
},
check: function(){
if (!this.running) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
case 'chain': this.chain(this.caller.bind(this, arguments)); return false;
}
return false;
},
send: function(options){
if (!this.check(options)) return this;
this.running = true;
var type = $type(options);
if (type == 'string' || type == 'element') options = {data: options};
var old = this.options;
options = $extend({data: old.data, url: old.url, method: old.method}, options);
var data = options.data, url = String(options.url), method = options.method.toLowerCase();
switch ($type(data)){
case 'element': data = document.id(data).toQueryString(); break;
case 'object': case 'hash': data = Hash.toQueryString(data);
}
if (this.options.format){
var format = 'format=' + this.options.format;
data = (data) ? format + '&' + data : format;
}
if (this.options.emulation && !['get', 'post'].contains(method)){
var _method = '_method=' + method;
data = (data) ? _method + '&' + data : _method;
method = 'post';
}
if (this.options.urlEncoded && method == 'post'){
var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
this.headers.set('Content-type', 'application/x-www-form-urlencoded' + encoding);
}
if (this.options.noCache){
var noCache = 'noCache=' + new Date().getTime();
data = (data) ? noCache + '&' + data : noCache;
}
var trimPosition = url.lastIndexOf('/');
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);
if (data && method == 'get'){
url = url + (url.contains('?') ? '&' : '?') + data;
data = null;
}
this.xhr.open(method.toUpperCase(), url, this.options.async);
this.xhr.onreadystatechange = this.onStateChange.bind(this);
this.headers.each(function(value, key){
try {
this.xhr.setRequestHeader(key, value);
} catch (e){
this.fireEvent('exception', [key, value]);
}
}, this);
this.fireEvent('request');
this.xhr.send(data);
if (!this.options.async) this.onStateChange();
return this;
},
cancel: function(){
if (!this.running) return this;
this.running = false;
this.xhr.abort();
this.xhr.onreadystatechange = $empty;
this.xhr = new Browser.Request();
this.fireEvent('cancel');
return this;
}
});
(function(){
var methods = {};
['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){
methods[method] = function(){
var params = Array.link(arguments, {url: String.type, data: $defined});
return this.send($extend(params, {method: method}));
};
});
Request.implement(methods);
})();
Element.Properties.send = {
set: function(options){
var send = this.retrieve('send');
if (send) send.cancel();
return this.eliminate('send').store('send:options', $extend({
data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')
}, options));
},
get: function(options){
if (options || !this.retrieve('send')){
if (options || !this.retrieve('send:options')) this.set('send', options);
this.store('send', new Request(this.retrieve('send:options')));
}
return this.retrieve('send');
}
};
Element.implement({
send: function(url){
var sender = this.get('send');
sender.send({data: this, url: url || sender.options.url});
return this;
}
});
Request.HTML = new Class({
Extends: Request,
options: {
update: false,
append: false,
evalScripts: true,
filter: false
},
processHTML: function(text){
var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
text = (match) ? match[1] : text;
var container = new Element('div');
return $try(function(){
var root = '<root>' + text + '</root>', doc;
if (Browser.Engine.trident){
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = false;
doc.loadXML(root);
} else {
doc = new DOMParser().parseFromString(root, 'text/xml');
}
root = doc.getElementsByTagName('root')[0];
if (!root) return null;
for (var i = 0, k = root.childNodes.length; i < k; i++){
var child = Element.clone(root.childNodes[i], true, true);
if (child) container.grab(child);
}
return container;
}) || container.set('html', text);
},
success: function(text){
var options = this.options, response = this.response;
response.html = text.stripScripts(function(script){
response.javascript = script;
});
var temp = this.processHTML(response.html);
response.tree = temp.childNodes;
response.elements = temp.getElements('*');
if (options.filter) response.tree = response.elements.filter(options.filter);
if (options.update) document.id(options.update).empty().set('html', response.html);
else if (options.append) document.id(options.append).adopt(temp.getChildren());
if (options.evalScripts) $exec(response.javascript);
this.onSuccess(response.tree, response.elements, response.html, response.javascript);
}
});
Element.Properties.load = {
set: function(options){
var load = this.retrieve('load');
if (load) load.cancel();
return this.eliminate('load').store('load:options', $extend({data: this, link: 'cancel', update: this, method: 'get'}, options));
},
get: function(options){
if (options || ! this.retrieve('load')){
if (options || !this.retrieve('load:options')) this.set('load', options);
this.store('load', new Request.HTML(this.retrieve('load:options')));
}
return this.retrieve('load');
}
};
Element.implement({
load: function(){
this.get('load').send(Array.link(arguments, {data: Object.type, url: String.type}));
return this;
}
});
Request.JSON = new Class({
Extends: Request,
options: {
secure: true
},
initialize: function(options){
this.parent(options);
this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});
},
success: function(text){
this.response.json = JSON.decode(text, this.options.secure);
this.onSuccess(this.response.json, text);
}
});
MooTools.More = {
'version': '1.2.4.2',
'build': 'bd5a93c0913cce25917c48cbdacde568e15e02ef'
};
(function(){
var data = {
language: 'en-US',
languages: {
'en-US': {}
},
cascades: ['en-US']
};
var cascaded;
MooTools.lang = new Events();
$extend(MooTools.lang, {
setLanguage: function(lang){
if (!data.languages[lang]) return this;
data.language = lang;
this.load();
this.fireEvent('langChange', lang);
return this;
},
load: function() {
var langs = this.cascade(this.getCurrentLanguage());
cascaded = {};
$each(langs, function(set, setName){
cascaded[setName] = this.lambda(set);
}, this);
},
getCurrentLanguage: function(){
return data.language;
},
addLanguage: function(lang){
data.languages[lang] = data.languages[lang] || {};
return this;
},
cascade: function(lang){
var cascades = (data.languages[lang] || {}).cascades || [];
cascades.combine(data.cascades);
cascades.erase(lang).push(lang);
var langs = cascades.map(function(lng){
return data.languages[lng];
}, this);
return $merge.apply(this, langs);
},
lambda: function(set) {
(set || {}).get = function(key, args){
return $lambda(set[key]).apply(this, $splat(args));
};
return set;
},
get: function(set, key, args){
if (cascaded && cascaded[set]) return (key ? cascaded[set].get(key, args) : cascaded[set]);
},
set: function(lang, set, members){
this.addLanguage(lang);
langData = data.languages[lang];
if (!langData[set]) langData[set] = {};
$extend(langData[set], members);
if (lang == this.getCurrentLanguage()){
this.load();
this.fireEvent('langChange', lang);
}
return this;
},
list: function(){
return Hash.getKeys(data.languages);
}
});
})();
(function(){
var global = this;
var log = function(){
if (global.console && console.log){
try {
console.log.apply(console, arguments);
} catch(e) {
console.log(Array.slice(arguments));
}
} else {
Log.logged.push(arguments);
}
return this;
};
var disabled = function(){
this.logged.push(arguments);
return this;
};
this.Log = new Class({
logged: [],
log: disabled,
resetLog: function(){
this.logged.empty();
return this;
},
enableLog: function(){
this.log = log;
this.logged.each(function(args){
this.log.apply(this, args);
}, this);
return this.resetLog();
},
disableLog: function(){
this.log = disabled;
return this;
}
});
Log.extend(new Log).enableLog();
Log.logger = function(){
return this.log.apply(this, arguments);
};
})();
var Depender = {
options: {
loadedSources: [],
loadedScripts: ['Core', 'Browser', 'Array', 'String', 'Function', 'Number', 'Hash', 'Element', 'Event', 'Element.Event', 'Class', 'DomReady', 'Class.Extras', 'Request', 'JSON', 'Request.JSON', 'More', 'Depender', 'Log'],
useScriptInjection: true
},
loaded: [],
sources: {},
libs: {},
include: function(libs){
this.log('include: ', libs);
this.mapLoaded = false;
var loader = function(data){
this.libs = $merge(this.libs, data);
$each(this.libs, function(data, lib){
if (data.scripts) this.loadSource(lib, data.scripts);
}, this);
}.bind(this);
if ($type(libs) == 'string'){
this.log('fetching libs ', libs);
this.request(libs, loader);
} else {
loader(libs);
}
return this;
},
required: [],
require: function(options){
var loaded = function(){
var scripts = this.calculateDependencies(options.scripts);
if (options.sources){
options.sources.each(function(source){
scripts.combine(this.libs[source].files);
}, this);
}
if (options.serial) scripts.combine(this.getLoadedScripts());
options.scripts = scripts;
this.required.push(options);
this.fireEvent('require', options);
this.loadScripts(options.scripts);
};
if (this.mapLoaded){
loaded.call(this);
} else {
this.addEvent('mapLoaded', function(){
loaded.call(this);
this.removeEvent('mapLoaded', arguments.callee);
});
}
return this;
},
cleanDoubleSlash: function(str){
if (!str) return str;
var prefix = '';
if (str.test(/^http:\/\//)){
prefix = 'http://';
str = str.substring(7, str.length);
}
str = str.replace(/\/\//g, '/');
return prefix + str;
},
request: function(url, callback){
new Request.JSON({
url: url,
secure: false,
onSuccess: callback
}).send();
},
loadSource: function(lib, source){
if (this.libs[lib].files){
this.dataLoaded();
return;
}
this.log('loading source: ', source);
this.request(this.cleanDoubleSlash(source + '/scripts.json'), function(result){
this.log('loaded source: ', source);
this.libs[lib].files = result;
this.dataLoaded();
}.bind(this));
},
dataLoaded: function(){
var loaded = true;
$each(this.libs, function(v, k){
if (!this.libs[k].files) loaded = false;
}, this);
if (loaded){
this.mapTree();
this.mapLoaded = true;
this.calculateLoaded();
this.lastLoaded = this.getLoadedScripts().getLength();
this.fireEvent('mapLoaded');
}
},
calculateLoaded: function(){
var set = function(script){
this.scriptsState[script] = true;
}.bind(this);
if (this.options.loadedScripts) this.options.loadedScripts.each(set);
if (this.options.loadedSources){
this.options.loadedSources.each(function(lib){
$each(this.libs[lib].files, function(dir){
$each(dir, function(data, file){
set(file);
}, this);
}, this);
}, this);
}
},
deps: {},
pathMap: {},
mapTree: function(){
$each(this.libs, function(data, source){
$each(data.files, function(scripts, folder){
$each(scripts, function(details, script){
var path = source + ':' + folder + ':' + script;
if (this.deps[path]) return;
this.deps[path] = details.deps;
this.pathMap[script] = path;
}, this);
}, this);
}, this);
},
getDepsForScript: function(script){
return this.deps[this.pathMap[script]] || [];
},
calculateDependencies: function(scripts){
var reqs = [];
$splat(scripts).each(function(script){
if (script == 'None' || !script) return;
var deps = this.getDepsForScript(script);
if (!deps){
if (window.console && console.warn) console.warn('dependencies not mapped: script: %o, map: %o, :deps: %o', script, this.pathMap, this.deps);
} else {
deps.each(function(scr){
if (scr == script || scr == 'None' || !scr) return;
if (!reqs.contains(scr)) reqs.combine(this.calculateDependencies(scr));
reqs.include(scr);
}, this);
}
reqs.include(script);
}, this);
return reqs;
},
getPath: function(script){
try {
var chunks = this.pathMap[script].split(':');
var lib = this.libs[chunks[0]];
var dir = (lib.path || lib.scripts) + '/';
chunks.shift();
return this.cleanDoubleSlash(dir + chunks.join('/') + '.js');
} catch(e){
return script;
}
},
loadScripts: function(scripts){
scripts = scripts.filter(function(s){
if (!this.scriptsState[s] && s != 'None'){
this.scriptsState[s] = false;
return true;
}
}, this);
if (scripts.length){
scripts.each(function(scr){
this.loadScript(scr);
}, this);
} else {
this.check();
}
},
toLoad: [],
loadScript: function(script){
if (this.scriptsState[script] && this.toLoad.length){
this.loadScript(this.toLoad.shift());
return;
} else if (this.loading){
this.toLoad.push(script);
return;
}
var finish = function(){
this.loading = false;
this.scriptLoaded(script);
if (this.toLoad.length) this.loadScript(this.toLoad.shift());
}.bind(this);
var error = function(){
this.log('could not load: ', scriptPath);
}.bind(this);
this.loading = true;
var scriptPath = this.getPath(script);
if (this.options.useScriptInjection){
this.log('injecting script: ', scriptPath);
var loaded = function(){
this.log('loaded script: ', scriptPath);
finish();
}.bind(this);
new Element('script', {
src: scriptPath + (this.options.noCache ? '?noCache=' + new Date().getTime() : ''),
events: {
load: loaded,
readystatechange: function(){
if (['loaded', 'complete'].contains(this.readyState)) loaded();
},
error: error
}
}).inject(this.options.target || document.head);
} else {
this.log('requesting script: ', scriptPath);
new Request({
url: scriptPath,
noCache: this.options.noCache,
onComplete: function(js){
this.log('loaded script: ', scriptPath);
$exec(js);
finish();
}.bind(this),
onFailure: error,
onException: error
}).send();
}
},
scriptsState: $H(),
getLoadedScripts: function(){
return this.scriptsState.filter(function(state){
return state;
});
},
scriptLoaded: function(script){
this.log('loaded script: ', script);
this.scriptsState[script] = true;
this.check();
var loaded = this.getLoadedScripts();
var loadedLength = loaded.getLength();
var toLoad = this.scriptsState.getLength();
this.fireEvent('scriptLoaded', {
script: script,
totalLoaded: (loadedLength / toLoad * 100).round(),
currentLoaded: ((loadedLength - this.lastLoaded) / (toLoad - this.lastLoaded) * 100).round(),
loaded: loaded
});
if (loadedLength == toLoad) this.lastLoaded = loadedLength;
},
lastLoaded: 0,
check: function(){
var incomplete = [];
this.required.each(function(required){
var loaded = [];
required.scripts.each(function(script){
if (this.scriptsState[script]) loaded.push(script);
}, this);
if (required.onStep){
required.onStep({
percent: loaded.length / required.scripts.length * 100,
scripts: loaded
});
};
if (required.scripts.length != loaded.length) return;
required.callback();
this.required.erase(required);
this.fireEvent('requirementLoaded', [loaded, required]);
}, this);
}
};
$extend(Depender, new Events);
$extend(Depender, new Options);
$extend(Depender, new Log);
Depender._setOptions = Depender.setOptions;
Depender.setOptions = function(){
Depender._setOptions.apply(Depender, arguments);
if (this.options.log) Depender.enableLog();
return this;
};
Class.refactor = function(original, refactors){
$each(refactors, function(item, name){
var origin = original.prototype[name];
if (origin && (origin = origin._origin) && typeof item == 'function') original.implement(name, function(){
var old = this.previous;
this.previous = origin;
var value = item.apply(this, arguments);
this.previous = old;
return value;
}); else original.implement(name, item);
});
return original;
};
Class.Mutators.Binds = function(binds){
return binds;
};
Class.Mutators.initialize = function(initialize){
return function(){
$splat(this.Binds).each(function(name){
var original = this[name];
if (original) this[name] = original.bind(this);
}, this);
return initialize.apply(this, arguments);
};
};
Class.Occlude = new Class({
occlude: function(property, element){
element = document.id(element || this.element);
var instance = element.retrieve(property || this.property);
if (instance && !$defined(this.occluded))
return this.occluded = instance;
this.occluded = false;
element.store(property || this.property, this);
return this.occluded;
}
});
(function(){
var wait = {
wait: function(duration){
return this.chain(function(){
this.callChain.delay($pick(duration, 500), this);
}.bind(this));
}
};
Chain.implement(wait);
if (window.Fx){
Fx.implement(wait);
['Css', 'Tween', 'Elements'].each(function(cls){
if (Fx[cls]) Fx[cls].implement(wait);
});
}
Element.implement({
chains: function(effects){
$splat($pick(effects, ['tween', 'morph', 'reveal'])).each(function(effect){
effect = this.get(effect);
if (!effect) return;
effect.setOptions({
link:'chain'
});
}, this);
return this;
},
pauseFx: function(duration, effect){
this.chains(effect).get($pick(effect, 'tween')).wait(duration);
return this;
}
});
})();
Array.implement({
min: function(){
return Math.min.apply(null, this);
},
max: function(){
return Math.max.apply(null, this);
},
average: function(){
return this.length ? this.sum() / this.length : 0;
},
sum: function(){
var result = 0, l = this.length;
if (l){
do {
result += this[--l];
} while (l);
}
return result;
},
unique: function(){
return [].combine(this);
}
});
(function(){
var Date = this.Date;
if (!Date.now) Date.now = $time;
Date.Methods = {
ms: 'Milliseconds',
year: 'FullYear',
min: 'Minutes',
mo: 'Month',
sec: 'Seconds',
hr: 'Hours'
};
['Date', 'Day', 'FullYear', 'Hours', 'Milliseconds', 'Minutes', 'Month', 'Seconds', 'Time', 'TimezoneOffset',
'Week', 'Timezone', 'GMTOffset', 'DayOfYear', 'LastMonth', 'LastDayOfMonth', 'UTCDate', 'UTCDay', 'UTCFullYear',
'AMPM', 'Ordinal', 'UTCHours', 'UTCMilliseconds', 'UTCMinutes', 'UTCMonth', 'UTCSeconds'].each(function(method){
Date.Methods[method.toLowerCase()] = method;
});
var pad = function(what, length){
return new Array(length - String(what).length + 1).join('0') + what;
};
Date.implement({
set: function(prop, value){
switch ($type(prop)){
case 'object':
for (var p in prop) this.set(p, prop[p]);
break;
case 'string':
prop = prop.toLowerCase();
var m = Date.Methods;
if (m[prop]) this['set' + m[prop]](value);
}
return this;
},
get: function(prop){
prop = prop.toLowerCase();
var m = Date.Methods;
if (m[prop]) return this['get' + m[prop]]();
return null;
},
clone: function(){
return new Date(this.get('time'));
},
increment: function(interval, times){
interval = interval || 'day';
times = $pick(times, 1);
switch (interval){
case 'year':
return this.increment('month', times * 12);
case 'month':
var d = this.get('date');
this.set('date', 1).set('mo', this.get('mo') + times);
return this.set('date', d.min(this.get('lastdayofmonth')));
case 'week':
return this.increment('day', times * 7);
case 'day':
return this.set('date', this.get('date') + times);
}
if (!Date.units[interval]) throw new Error(interval + ' is not a supported interval');
return this.set('time', this.get('time') + times * Date.units[interval]());
},
decrement: function(interval, times){
return this.increment(interval, -1 * $pick(times, 1));
},
isLeapYear: function(){
return Date.isLeapYear(this.get('year'));
},
clearTime: function(){
return this.set({hr: 0, min: 0, sec: 0, ms: 0});
},
diff: function(date, resolution){
if ($type(date) == 'string') date = Date.parse(date);
return ((date - this) / Date.units[resolution || 'day'](3, 3)).toInt(); // non-leap year, 30-day month
},
getLastDayOfMonth: function(){
return Date.daysInMonth(this.get('mo'), this.get('year'));
},
getDayOfYear: function(){
return (Date.UTC(this.get('year'), this.get('mo'), this.get('date') + 1)
- Date.UTC(this.get('year'), 0, 1)) / Date.units.day();
},
getWeek: function(){
return (this.get('dayofyear') / 7).ceil();
},
getOrdinal: function(day){
return Date.getMsg('ordinal', day || this.get('date'));
},
getTimezone: function(){
return this.toString()
.replace(/^.*? ([A-Z]{3}).[0-9]{4}.*$/, '$1')
.replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, '$1$2$3');
},
getGMTOffset: function(){
var off = this.get('timezoneOffset');
return ((off > 0) ? '-' : '+') + pad((off.abs() / 60).floor(), 2) + pad(off % 60, 2);
},
setAMPM: function(ampm){
ampm = ampm.toUpperCase();
var hr = this.get('hr');
if (hr > 11 && ampm == 'AM') return this.decrement('hour', 12);
else if (hr < 12 && ampm == 'PM') return this.increment('hour', 12);
return this;
},
getAMPM: function(){
return (this.get('hr') < 12) ? 'AM' : 'PM';
},
parse: function(str){
this.set('time', Date.parse(str));
return this;
},
isValid: function(date) {
return !!(date || this).valueOf();
},
format: function(f){
if (!this.isValid()) return 'invalid date';
f = f || '%x %X';
f = formats[f.toLowerCase()] || f; // replace short-hand with actual format
var d = this;
return f.replace(/%([a-z%])/gi,
function($0, $1){
switch ($1){
case 'a': return Date.getMsg('days')[d.get('day')].substr(0, 3);
case 'A': return Date.getMsg('days')[d.get('day')];
case 'b': return Date.getMsg('months')[d.get('month')].substr(0, 3);
case 'B': return Date.getMsg('months')[d.get('month')];
case 'c': return d.toString();
case 'd': return pad(d.get('date'), 2);
case 'H': return pad(d.get('hr'), 2);
case 'I': return ((d.get('hr') % 12) || 12);
case 'j': return pad(d.get('dayofyear'), 3);
case 'm': return pad((d.get('mo') + 1), 2);
case 'M': return pad(d.get('min'), 2);
case 'o': return d.get('ordinal');
case 'p': return Date.getMsg(d.get('ampm'));
case 'S': return pad(d.get('seconds'), 2);
case 'U': return pad(d.get('week'), 2);
case 'w': return d.get('day');
case 'x': return d.format(Date.getMsg('shortDate'));
case 'X': return d.format(Date.getMsg('shortTime'));
case 'y': return d.get('year').toString().substr(2);
case 'Y': return d.get('year');
case 'T': return d.get('GMTOffset');
case 'Z': return d.get('Timezone');
}
return $1;
}
);
},
toISOString: function(){
return this.format('iso8601');
}
});
Date.alias('toISOString', 'toJSON');
Date.alias('diff', 'compare');
Date.alias('format', 'strftime');
var formats = {
db: '%Y-%m-%d %H:%M:%S',
compact: '%Y%m%dT%H%M%S',
iso8601: '%Y-%m-%dT%H:%M:%S%T',
rfc822: '%a, %d %b %Y %H:%M:%S %Z',
'short': '%d %b %H:%M',
'long': '%B %d, %Y %H:%M'
};
var parsePatterns = [];
var nativeParse = Date.parse;
var parseWord = function(type, word, num){
var ret = -1;
var translated = Date.getMsg(type + 's');
switch ($type(word)){
case 'object':
ret = translated[word.get(type)];
break;
case 'number':
ret = translated[month - 1];
if (!ret) throw new Error('Invalid ' + type + ' index: ' + index);
break;
case 'string':
var match = translated.filter(function(name){
return this.test(name);
}, new RegExp('^' + word, 'i'));
if (!match.length)    throw new Error('Invalid ' + type + ' string');
if (match.length > 1) throw new Error('Ambiguous ' + type);
ret = match[0];
}
return (num) ? translated.indexOf(ret) : ret;
};
Date.extend({
getMsg: function(key, args) {
return MooTools.lang.get('Date', key, args);
},
units: {
ms: $lambda(1),
second: $lambda(1000),
minute: $lambda(60000),
hour: $lambda(3600000),
day: $lambda(86400000),
week: $lambda(608400000),
month: function(month, year){
var d = new Date;
return Date.daysInMonth($pick(month, d.get('mo')), $pick(year, d.get('year'))) * 86400000;
},
year: function(year){
year = year || new Date().get('year');
return Date.isLeapYear(year) ? 31622400000 : 31536000000;
}
},
daysInMonth: function(month, year){
return [31, Date.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
},
isLeapYear: function(year){
return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
},
parse: function(from){
var t = $type(from);
if (t == 'number') return new Date(from);
if (t != 'string') return from;
from = from.clean();
if (!from.length) return null;
var parsed;
parsePatterns.some(function(pattern){
var bits = pattern.re.exec(from);
return (bits) ? (parsed = pattern.handler(bits)) : false;
});
return parsed || new Date(nativeParse(from));
},
parseDay: function(day, num){
return parseWord('day', day, num);
},
parseMonth: function(month, num){
return parseWord('month', month, num);
},
parseUTC: function(value){
var localDate = new Date(value);
var utcSeconds = Date.UTC(
localDate.get('year'),
localDate.get('mo'),
localDate.get('date'),
localDate.get('hr'),
localDate.get('min'),
localDate.get('sec')
);
return new Date(utcSeconds);
},
orderIndex: function(unit){
return Date.getMsg('dateOrder').indexOf(unit) + 1;
},
defineFormat: function(name, format){
formats[name] = format;
},
defineFormats: function(formats){
for (var name in formats) Date.defineFormat(name, formats[name]);
},
parsePatterns: parsePatterns, // this is deprecated
defineParser: function(pattern){
parsePatterns.push((pattern.re && pattern.handler) ? pattern : build(pattern));
},
defineParsers: function(){
Array.flatten(arguments).each(Date.defineParser);
},
define2DigitYearStart: function(year){
startYear = year % 100;
startCentury = year - startYear;
}
});
var startCentury = 1900;
var startYear = 70;
var regexOf = function(type){
return new RegExp('(?:' + Date.getMsg(type).map(function(name){
return name.substr(0, 3);
}).join('|') + ')[a-z]*');
};
var replacers = function(key){
switch(key){
case 'x': // iso8601 covers yyyy-mm-dd, so just check if month is first
return ((Date.orderIndex('month') == 1) ? '%m[.-/]%d' : '%d[.-/]%m') + '([.-/]%y)?';
case 'X':
return '%H([.:]%M)?([.:]%S([.:]%s)?)? ?%p? ?%T?';
}
return null;
};
var keys = {
d: /[0-2]?[0-9]|3[01]/,
H: /[01]?[0-9]|2[0-3]/,
I: /0?[1-9]|1[0-2]/,
M: /[0-5]?\d/,
s: /\d+/,
o: /[a-z]*/,
p: /[ap]\.?m\.?/,
y: /\d{2}|\d{4}/,
Y: /\d{4}/,
T: /Z|[+-]\d{2}(?::?\d{2})?/
};
keys.m = keys.I;
keys.S = keys.M;
var currentLanguage;
var recompile = function(language){
currentLanguage = language;
keys.a = keys.A = regexOf('days');
keys.b = keys.B = regexOf('months');
parsePatterns.each(function(pattern, i){
if (pattern.format) parsePatterns[i] = build(pattern.format);
});
};
var build = function(format){
if (!currentLanguage) return {format: format};
var parsed = [];
var re = (format.source || format) // allow format to be regex
.replace(/%([a-z])/gi,
function($0, $1){
return replacers($1) || $0;
}
).replace(/\((?!\?)/g, '(?:') // make all groups non-capturing
.replace(/ (?!\?|\*)/g, ',? ') // be forgiving with spaces and commas
.replace(/%([a-z%])/gi,
function($0, $1){
var p = keys[$1];
if (!p) return $1;
parsed.push($1);
return '(' + p.source + ')';
}
).replace(/\[a-z\]/gi, '[a-z\\u00c0-\\uffff]'); // handle unicode words
return {
format: format,
re: new RegExp('^' + re + '$', 'i'),
handler: function(bits){
bits = bits.slice(1).associate(parsed);
var date = new Date().clearTime();
if ('d' in bits) handle.call(date, 'd', 1);
if ('m' in bits) handle.call(date, 'm', 1);
for (var key in bits) handle.call(date, key, bits[key]);
return date;
}
};
};
var handle = function(key, value){
if (!value) return this;
switch(key){
case 'a': case 'A': return this.set('day', Date.parseDay(value, true));
case 'b': case 'B': return this.set('mo', Date.parseMonth(value, true));
case 'd': return this.set('date', value);
case 'H': case 'I': return this.set('hr', value);
case 'm': return this.set('mo', value - 1);
case 'M': return this.set('min', value);
case 'p': return this.set('ampm', value.replace(/\./g, ''));
case 'S': return this.set('sec', value);
case 's': return this.set('ms', ('0.' + value) * 1000);
case 'w': return this.set('day', value);
case 'Y': return this.set('year', value);
case 'y':
value = +value;
if (value < 100) value += startCentury + (value < startYear ? 100 : 0);
return this.set('year', value);
case 'T':
if (value == 'Z') value = '+00';
var offset = value.match(/([+-])(\d{2}):?(\d{2})?/);
offset = (offset[1] + '1') * (offset[2] * 60 + (+offset[3] || 0)) + this.getTimezoneOffset();
return this.set('time', this - offset * 60000);
}
return this;
};
Date.defineParsers(
'%Y([-./]%m([-./]%d((T| )%X)?)?)?', // "1999-12-31", "1999-12-31 11:59pm", "1999-12-31 23:59:59", ISO8601
'%Y%m%d(T%H(%M%S?)?)?', // "19991231", "19991231T1159", compact
'%x( %X)?', // "12/31", "12.31.99", "12-31-1999", "12/31/2008 11:59 PM"
'%d%o( %b( %Y)?)?( %X)?', // "31st", "31st December", "31 Dec 1999", "31 Dec 1999 11:59pm"
'%b( %d%o)?( %Y)?( %X)?', // Same as above with month and day switched
'%Y %b( %d%o( %X)?)?', // Same as above with year coming first
'%o %b %d %X %T %Y' // "Thu Oct 22 08:11:23 +0000 2009"
);
MooTools.lang.addEvent('langChange', function(language){
if (MooTools.lang.get('Date')) recompile(language);
}).fireEvent('langChange', MooTools.lang.getCurrentLanguage());
})();
Date.implement({
timeDiffInWords: function(relative_to){
return Date.distanceOfTimeInWords(this, relative_to || new Date);
},
timeDiff: function(to, joiner){
if (to == null) to = new Date;
var delta = ((to - this) / 1000).toInt();
if (!delta) return '0s';
var durations = {s: 60, m: 60, h: 24, d: 365, y: 0};
var duration, vals = [];
for (var step in durations){
if (!delta) break;
if ((duration = durations[step])){
vals.unshift((delta % duration) + step);
delta = (delta / duration).toInt();
} else {
vals.unshift(delta + step);
}
}
return vals.join(joiner || ':');
}
});
Date.alias('timeDiffInWords', 'timeAgoInWords');
Date.extend({
distanceOfTimeInWords: function(from, to){
return Date.getTimePhrase(((to - from) / 1000).toInt());
},
getTimePhrase: function(delta){
var suffix = (delta < 0) ? 'Until' : 'Ago';
if (delta < 0) delta *= -1;
var units = {
minute: 60,
hour: 60,
day: 24,
week: 7,
month: 52 / 12,
year: 12,
eon: Infinity
};
var msg = 'lessThanMinute';
for (var unit in units){
var interval = units[unit];
if (delta < 1.5 * interval){
if (delta > 0.75 * interval) msg = unit;
break;
}
delta /= interval;
msg = unit + 's';
}
return Date.getMsg(msg + suffix).substitute({delta: delta.round()});
}
});
Date.defineParsers(
{
re: /^(?:tod|tom|yes)/i,
handler: function(bits){
var d = new Date().clearTime();
switch(bits[0]){
case 'tom': return d.increment();
case 'yes': return d.decrement();
default: 	return d;
}
}
},
{
re: /^(next|last) ([a-z]+)$/i,
handler: function(bits){
var d = new Date().clearTime();
var day = d.getDay();
var newDay = Date.parseDay(bits[2], true);
var addDays = newDay - day;
if (newDay <= day) addDays += 7;
if (bits[1] == 'last') addDays -= 7;
return d.set('date', d.getDate() + addDays);
}
}
);
Hash.implement({
getFromPath: function(notation){
var source = this.getClean();
notation.replace(/\[([^\]]+)\]|\.([^.[]+)|[^[.]+/g, function(match){
if (!source) return null;
var prop = arguments[2] || arguments[1] || arguments[0];
source = (prop in source) ? source[prop] : null;
return match;
});
return source;
},
cleanValues: function(method){
method = method || $defined;
this.each(function(v, k){
if (!method(v)) this.erase(k);
}, this);
return this;
},
run: function(){
var args = arguments;
this.each(function(v, k){
if ($type(v) == 'function') v.run(args);
});
}
});
(function(){
var special = ['À','à','Á','á','Â','â','Ã','ã','Ä','ä','Å','å','Ă','ă','Ą','ą','Ć','ć','Č','č','Ç','ç', 'Ď','ď','Đ','đ', 'È','è','É','é','Ê','ê','Ë','ë','Ě','ě','Ę','ę', 'Ğ','ğ','Ì','ì','Í','í','Î','î','Ï','ï', 'Ĺ','ĺ','Ľ','ľ','Ł','ł', 'Ñ','ñ','Ň','ň','Ń','ń','Ò','ò','Ó','ó','Ô','ô','Õ','õ','Ö','ö','Ø','ø','ő','Ř','ř','Ŕ','ŕ','Š','š','Ş','ş','Ś','ś', 'Ť','ť','Ť','ť','Ţ','ţ','Ù','ù','Ú','ú','Û','û','Ü','ü','Ů','ů', 'Ÿ','ÿ','ý','Ý','Ž','ž','Ź','ź','Ż','ż', 'Þ','þ','Ð','ð','ß','Œ','œ','Æ','æ','µ'];
var standard = ['A','a','A','a','A','a','A','a','Ae','ae','A','a','A','a','A','a','C','c','C','c','C','c','D','d','D','d', 'E','e','E','e','E','e','E','e','E','e','E','e','G','g','I','i','I','i','I','i','I','i','L','l','L','l','L','l', 'N','n','N','n','N','n', 'O','o','O','o','O','o','O','o','Oe','oe','O','o','o', 'R','r','R','r', 'S','s','S','s','S','s','T','t','T','t','T','t', 'U','u','U','u','U','u','Ue','ue','U','u','Y','y','Y','y','Z','z','Z','z','Z','z','TH','th','DH','dh','ss','OE','oe','AE','ae','u'];
var tidymap = {
"[\xa0\u2002\u2003\u2009]": " ",
"\xb7": "*",
"[\u2018\u2019]": "'",
"[\u201c\u201d]": '"',
"\u2026": "...",
"\u2013": "-",
"\u2014": "--",
"\uFFFD": "&raquo;"
};
var getRegForTag = function(tag, contents) {
tag = tag || '';
var regstr = contents ? "<" + tag + "[^>]*>([\\s\\S]*?)<\/" + tag + ">" : "<\/?" + tag + "([^>]+)?>";
reg = new RegExp(regstr, "gi");
return reg;
};
String.implement({
standardize: function(){
var text = this;
special.each(function(ch, i){
text = text.replace(new RegExp(ch, 'g'), standard[i]);
});
return text;
},
repeat: function(times){
return new Array(times + 1).join(this);
},
pad: function(length, str, dir){
if (this.length >= length) return this;
var pad = (str == null ? ' ' : '' + str).repeat(length - this.length).substr(0, length - this.length);
if (!dir || dir == 'right') return this + pad;
if (dir == 'left') return pad + this;
return pad.substr(0, (pad.length / 2).floor()) + this + pad.substr(0, (pad.length / 2).ceil());
},
getTags: function(tag, contents){
return this.match(getRegForTag(tag, contents)) || [];
},
stripTags: function(tag, contents){
return this.replace(getRegForTag(tag, contents), '');
},
tidy: function(){
var txt = this.toString();
$each(tidymap, function(value, key){
txt = txt.replace(new RegExp(key, 'g'), value);
});
return txt;
}
});
})();
String.implement({
parseQueryString: function(){
var vars = this.split(/[&;]/), res = {};
if (vars.length) vars.each(function(val){
var index = val.indexOf('='),
keys = index < 0 ? [''] : val.substr(0, index).match(/[^\]\[]+/g),
value = decodeURIComponent(val.substr(index + 1)),
obj = res;
keys.each(function(key, i){
var current = obj[key];
if(i < keys.length - 1)
obj = obj[key] = current || {};
else if($type(current) == 'array')
current.push(value);
else
obj[key] = $defined(current) ? [current, value] : value;
});
});
return res;
},
cleanQueryString: function(method){
return this.split('&').filter(function(val){
var index = val.indexOf('='),
key = index < 0 ? '' : val.substr(0, index),
value = val.substr(index + 1);
return method ? method.run([key, value]) : $chk(value);
}).join('&');
}
});
var URI = new Class({
Implements: Options,
options: {
},
regex: /^(?:(\w+):)?(?:\/\/(?:(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)?(\.\.?$|(?:[^?#\/]*\/)*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/,
parts: ['scheme', 'user', 'password', 'host', 'port', 'directory', 'file', 'query', 'fragment'],
schemes: {http: 80, https: 443, ftp: 21, rtsp: 554, mms: 1755, file: 0},
initialize: function(uri, options){
this.setOptions(options);
var base = this.options.base || URI.base;
if(!uri) uri = base;
if (uri && uri.parsed) this.parsed = $unlink(uri.parsed);
else this.set('value', uri.href || uri.toString(), base ? new URI(base) : false);
},
parse: function(value, base){
var bits = value.match(this.regex);
if (!bits) return false;
bits.shift();
return this.merge(bits.associate(this.parts), base);
},
merge: function(bits, base){
if ((!bits || !bits.scheme) && (!base || !base.scheme)) return false;
if (base){
this.parts.every(function(part){
if (bits[part]) return false;
bits[part] = base[part] || '';
return true;
});
}
bits.port = bits.port || this.schemes[bits.scheme.toLowerCase()];
bits.directory = bits.directory ? this.parseDirectory(bits.directory, base ? base.directory : '') : '/';
return bits;
},
parseDirectory: function(directory, baseDirectory) {
directory = (directory.substr(0, 1) == '/' ? '' : (baseDirectory || '/')) + directory;
if (!directory.test(URI.regs.directoryDot)) return directory;
var result = [];
directory.replace(URI.regs.endSlash, '').split('/').each(function(dir){
if (dir == '..' && result.length > 0) result.pop();
else if (dir != '.') result.push(dir);
});
return result.join('/') + '/';
},
combine: function(bits){
return bits.value || bits.scheme + '://' +
(bits.user ? bits.user + (bits.password ? ':' + bits.password : '') + '@' : '') +
(bits.host || '') + (bits.port && bits.port != this.schemes[bits.scheme] ? ':' + bits.port : '') +
(bits.directory || '/') + (bits.file || '') +
(bits.query ? '?' + bits.query : '') +
(bits.fragment ? '#' + bits.fragment : '');
},
set: function(part, value, base){
if (part == 'value'){
var scheme = value.match(URI.regs.scheme);
if (scheme) scheme = scheme[1];
if (scheme && !$defined(this.schemes[scheme.toLowerCase()])) this.parsed = { scheme: scheme, value: value };
else this.parsed = this.parse(value, (base || this).parsed) || (scheme ? { scheme: scheme, value: value } : { value: value });
} else if (part == 'data') {
this.setData(value);
} else {
this.parsed[part] = value;
}
return this;
},
get: function(part, base){
switch(part){
case 'value': return this.combine(this.parsed, base ? base.parsed : false);
case 'data' : return this.getData();
}
return this.parsed[part] || '';
},
go: function(){
document.location.href = this.toString();
},
toURI: function(){
return this;
},
getData: function(key, part){
var qs = this.get(part || 'query');
if (!$chk(qs)) return key ? null : {};
var obj = qs.parseQueryString();
return key ? obj[key] : obj;
},
setData: function(values, merge, part){
if (typeof values == 'string'){
values = this.getData();
values[arguments[0]] = arguments[1];
} else if (merge) {
values = $merge(this.getData(), values);
}
return this.set(part || 'query', Hash.toQueryString(values));
},
clearData: function(part){
return this.set(part || 'query', '');
}
});
URI.prototype.toString = URI.prototype.valueOf = function(){
return this.get('value');
};
URI.regs = {
endSlash: /\/$/,
scheme: /^(\w+):/,
directoryDot: /\.\/|\.$/
};
URI.base = new URI(document.getElements('base[href]', true).getLast(), {base: document.location});
String.implement({
toURI: function(options){
return new URI(this, options);
}
});
URI = Class.refactor(URI, {
combine: function(bits, base){
if (!base || bits.scheme != base.scheme || bits.host != base.host || bits.port != base.port)
return this.previous.apply(this, arguments);
var end = bits.file + (bits.query ? '?' + bits.query : '') + (bits.fragment ? '#' + bits.fragment : '');
if (!base.directory) return (bits.directory || (bits.file ? '' : './')) + end;
var baseDir = base.directory.split('/'),
relDir = bits.directory.split('/'),
path = '',
offset;
var i = 0;
for(offset = 0; offset < baseDir.length && offset < relDir.length && baseDir[offset] == relDir[offset]; offset++);
for(i = 0; i < baseDir.length - offset - 1; i++) path += '../';
for(i = offset; i < relDir.length - 1; i++) path += relDir[i] + '/';
return (path || (bits.file ? '' : './')) + end;
},
toAbsolute: function(base){
base = new URI(base);
if (base) base.set('directory', '').set('file', '');
return this.toRelative(base);
},
toRelative: function(base){
return this.get('value', new URI(base));
}
});
Element.implement({
tidy: function(){
this.set('value', this.get('value').tidy());
},
getTextInRange: function(start, end){
return this.get('value').substring(start, end);
},
getSelectedText: function(){
if (this.setSelectionRange) return this.getTextInRange(this.getSelectionStart(), this.getSelectionEnd());
return document.selection.createRange().text;
},
getSelectedRange: function() {
if ($defined(this.selectionStart)) return {start: this.selectionStart, end: this.selectionEnd};
var pos = {start: 0, end: 0};
var range = this.getDocument().selection.createRange();
if (!range || range.parentElement() != this) return pos;
var dup = range.duplicate();
if (this.type == 'text') {
pos.start = 0 - dup.moveStart('character', -100000);
pos.end = pos.start + range.text.length;
} else {
var value = this.get('value');
var offset = value.length;
dup.moveToElementText(this);
dup.setEndPoint('StartToEnd', range);
if(dup.text.length) offset -= value.match(/[\n\r]*$/)[0].length;
pos.end = offset - dup.text.length;
dup.setEndPoint('StartToStart', range);
pos.start = offset - dup.text.length;
}
return pos;
},
getSelectionStart: function(){
return this.getSelectedRange().start;
},
getSelectionEnd: function(){
return this.getSelectedRange().end;
},
setCaretPosition: function(pos){
if (pos == 'end') pos = this.get('value').length;
this.selectRange(pos, pos);
return this;
},
getCaretPosition: function(){
return this.getSelectedRange().start;
},
selectRange: function(start, end){
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(start, end);
} else {
var value = this.get('value');
var diff = value.substr(start, end - start).replace(/\r/g, '').length;
start = value.substr(0, start).replace(/\r/g, '').length;
var range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', start + diff);
range.moveStart('character', start);
range.select();
}
return this;
},
insertAtCursor: function(value, select){
var pos = this.getSelectedRange();
var text = this.get('value');
this.set('value', text.substring(0, pos.start) + value + text.substring(pos.end, text.length));
if ($pick(select, true)) this.selectRange(pos.start, pos.start + value.length);
else this.setCaretPosition(pos.start + value.length);
return this;
},
insertAroundCursor: function(options, select){
options = $extend({
before: '',
defaultMiddle: '',
after: ''
}, options);
var value = this.getSelectedText() || options.defaultMiddle;
var pos = this.getSelectedRange();
var text = this.get('value');
if (pos.start == pos.end){
this.set('value', text.substring(0, pos.start) + options.before + value + options.after + text.substring(pos.end, text.length));
this.selectRange(pos.start + options.before.length, pos.end + options.before.length + value.length);
} else {
var current = text.substring(pos.start, pos.end);
this.set('value', text.substring(0, pos.start) + options.before + current + options.after + text.substring(pos.end, text.length));
var selStart = pos.start + options.before.length;
if ($pick(select, true)) this.selectRange(selStart, selStart + current.length);
else this.setCaretPosition(selStart + text.length);
}
return this;
}
});
Elements.from = function(text, excludeScripts){
if ($pick(excludeScripts, true)) text = text.stripScripts();
var container, match = text.match(/^\s*<(t[dhr]|tbody|tfoot|thead)/i);
if (match){
container = new Element('table');
var tag = match[1].toLowerCase();
if (['td', 'th', 'tr'].contains(tag)){
container = new Element('tbody').inject(container);
if (tag != 'tr') container = new Element('tr').inject(container);
}
}
return (container || new Element('div')).set('html', text).getChildren();
};
(function(){
var match = /(.*?):relay\(([^)]+)\)$/,
combinators = /[+>~\s]/,
splitType = function(type){
var bits = type.match(match);
return !bits ? {event: type} : {
event: bits[1],
selector: bits[2]
};
},
check = function(e, selector){
var t = e.target;
if (combinators.test(selector = selector.trim())){
var els = this.getElements(selector);
for (var i = els.length; i--; ){
var el = els[i];
if (t == el || el.hasChild(t)) return el;
}
} else {
for ( ; t && t != this; t = t.parentNode){
if (Element.match(t, selector)) return document.id(t);
}
}
return null;
};
var oldAddEvent = Element.prototype.addEvent,
oldRemoveEvent = Element.prototype.removeEvent;
Element.implement({
addEvent: function(type, fn){
var splitted = splitType(type);
if (splitted.selector){
var monitors = this.retrieve('$moo:delegateMonitors', {});
if (!monitors[type]){
var monitor = function(e){
var el = check.call(this, e, splitted.selector);
if (el) this.fireEvent(type, [e, el], 0, el);
}.bind(this);
monitors[type] = monitor;
oldAddEvent.call(this, splitted.event, monitor);
}
}
return oldAddEvent.apply(this, arguments);
},
removeEvent: function(type, fn){
var splitted = splitType(type);
if (splitted.selector){
var events = this.retrieve('events');
if (!events || !events[type] || (fn && !events[type].keys.contains(fn))) return this;
if (fn) oldRemoveEvent.apply(this, [type, fn]);
else oldRemoveEvent.apply(this, type);
events = this.retrieve('events');
if (events && events[type] && events[type].length == 0){
var monitors = this.retrieve('$moo:delegateMonitors', {});
oldRemoveEvent.apply(this, [splitted.event, monitors[type]]);
delete monitors[type];
}
return this;
}
return oldRemoveEvent.apply(this, arguments);
},
fireEvent: function(type, args, delay, bind){
var events = this.retrieve('events');
if (!events || !events[type]) return this;
events[type].keys.each(function(fn){
fn.create({bind: bind || this, delay: delay, arguments: args})();
}, this);
return this;
}
});
})();
Element.implement({
measure: function(fn){
var vis = function(el) {
return !!(!el || el.offsetHeight || el.offsetWidth);
};
if (vis(this)) return fn.apply(this);
var parent = this.getParent(),
restorers = [],
toMeasure = [];
while (!vis(parent) && parent != document.body) {
toMeasure.push(parent.expose());
parent = parent.getParent();
}
var restore = this.expose();
var result = fn.apply(this);
restore();
toMeasure.each(function(restore){
restore();
});
return result;
},
expose: function(){
if (this.getStyle('display') != 'none') return $empty;
var before = this.style.cssText;
this.setStyles({
display: 'block',
position: 'absolute',
visibility: 'hidden'
});
return function(){
this.style.cssText = before;
}.bind(this);
},
getDimensions: function(options){
options = $merge({computeSize: false},options);
var dim = {};
var getSize = function(el, options){
return (options.computeSize)?el.getComputedSize(options):el.getSize();
};
var parent = this.getParent('body');
if (parent && this.getStyle('display') == 'none'){
dim = this.measure(function(){
return getSize(this, options);
});
} else if (parent){
try { //safari sometimes crashes here, so catch it
dim = getSize(this, options);
}catch(e){}
} else {
dim = {x: 0, y: 0};
}
return $chk(dim.x) ? $extend(dim, {width: dim.x, height: dim.y}) : $extend(dim, {x: dim.width, y: dim.height});
},
getComputedSize: function(options){
options = $merge({
styles: ['padding','border'],
plains: {
height: ['top','bottom'],
width: ['left','right']
},
mode: 'both'
}, options);
var size = {width: 0,height: 0};
switch (options.mode){
case 'vertical':
delete size.width;
delete options.plains.width;
break;
case 'horizontal':
delete size.height;
delete options.plains.height;
break;
}
var getStyles = [];
$each(options.plains, function(plain, key){
plain.each(function(edge){
options.styles.each(function(style){
getStyles.push((style == 'border') ? style + '-' + edge + '-' + 'width' : style + '-' + edge);
});
});
});
var styles = {};
getStyles.each(function(style){ styles[style] = this.getComputedStyle(style); }, this);
var subtracted = [];
$each(options.plains, function(plain, key){ //keys: width, height, plains: ['left', 'right'], ['top','bottom']
var capitalized = key.capitalize();
size['total' + capitalized] = size['computed' + capitalized] = 0;
plain.each(function(edge){ //top, left, right, bottom
size['computed' + edge.capitalize()] = 0;
getStyles.each(function(style, i){ //padding, border, etc.
if (style.test(edge)){
styles[style] = styles[style].toInt() || 0; //styles['padding-left'] = 5;
size['total' + capitalized] = size['total' + capitalized] + styles[style];
size['computed' + edge.capitalize()] = size['computed' + edge.capitalize()] + styles[style];
}
if (style.test(edge) && key != style &&
(style.test('border') || style.test('padding')) && !subtracted.contains(style)){
subtracted.push(style);
size['computed' + capitalized] = size['computed' + capitalized]-styles[style];
}
});
});
});
['Width', 'Height'].each(function(value){
var lower = value.toLowerCase();
if(!$chk(size[lower])) return;
size[lower] = size[lower] + this['offset' + value] + size['computed' + value];
size['total' + value] = size[lower] + size['total' + value];
delete size['computed' + value];
}, this);
return $extend(styles, size);
}
});
(function(){
var supportsPositionFixed = false;
window.addEvent('domready', function(){
var test = new Element('div').setStyles({
position: 'fixed',
top: 0,
right: 0
}).inject(document.body);
supportsPositionFixed = (test.offsetTop === 0);
test.dispose();
});
Element.implement({
pin: function(enable){
if (this.getStyle('display') == 'none') return null;
var p,
scroll = window.getScroll();
if (enable !== false){
p = this.getPosition();
if (!this.retrieve('pinned')){
var pos = {
top: p.y - scroll.y,
left: p.x - scroll.x
};
if (supportsPositionFixed){
this.setStyle('position', 'fixed').setStyles(pos);
} else {
this.store('pinnedByJS', true);
this.setStyles({
position: 'absolute',
top: p.y,
left: p.x
}).addClass('isPinned');
this.store('scrollFixer', (function(){
if (this.retrieve('pinned'))
var scroll = window.getScroll();
this.setStyles({
top: pos.top.toInt() + scroll.y,
left: pos.left.toInt() + scroll.x
});
}).bind(this));
window.addEvent('scroll', this.retrieve('scrollFixer'));
}
this.store('pinned', true);
}
} else {
var op;
if (!Browser.Engine.trident){
var parent = this.getParent();
op = (parent.getComputedStyle('position') != 'static' ? parent : parent.getOffsetParent());
}
p = this.getPosition(op);
this.store('pinned', false);
var reposition;
if (supportsPositionFixed && !this.retrieve('pinnedByJS')){
reposition = {
top: p.y + scroll.y,
left: p.x + scroll.x
};
} else {
this.store('pinnedByJS', false);
window.removeEvent('scroll', this.retrieve('scrollFixer'));
reposition = {
top: p.y,
left: p.x
};
}
this.setStyles($merge(reposition, {position: 'absolute'})).removeClass('isPinned');
}
return this;
},
unpin: function(){
return this.pin(false);
},
togglepin: function(){
this.pin(!this.retrieve('pinned'));
}
});
})();
(function(){
var original = Element.prototype.position;
Element.implement({
position: function(options){
if (options && ($defined(options.x) || $defined(options.y))) return original ? original.apply(this, arguments) : this;
$each(options||{}, function(v, k){ if (!$defined(v)) delete options[k]; });
options = $merge({
relativeTo: document.body,
position: {
x: 'center', //left, center, right
y: 'center' //top, center, bottom
},
edge: false,
offset: {x: 0, y: 0},
returnPos: false,
relFixedPosition: false,
ignoreMargins: false,
ignoreScroll: false,
allowNegative: false
}, options);
var parentOffset = {x: 0, y: 0},
parentPositioned = false;
var offsetParent = this.measure(function(){
return document.id(this.getOffsetParent());
});
if (offsetParent && offsetParent != this.getDocument().body){
parentOffset = offsetParent.measure(function(){
return this.getPosition();
});
parentPositioned = offsetParent != document.id(options.relativeTo);
options.offset.x = options.offset.x - parentOffset.x;
options.offset.y = options.offset.y - parentOffset.y;
}
var fixValue = function(option){
if ($type(option) != 'string') return option;
option = option.toLowerCase();
var val = {};
if (option.test('left')) val.x = 'left';
else if (option.test('right')) val.x = 'right';
else val.x = 'center';
if (option.test('upper') || option.test('top')) val.y = 'top';
else if (option.test('bottom')) val.y = 'bottom';
else val.y = 'center';
return val;
};
options.edge = fixValue(options.edge);
options.position = fixValue(options.position);
if (!options.edge){
if (options.position.x == 'center' && options.position.y == 'center') options.edge = {x:'center', y:'center'};
else options.edge = {x:'left', y:'top'};
}
this.setStyle('position', 'absolute');
var rel = document.id(options.relativeTo) || document.body,
calc = rel == document.body ? window.getScroll() : rel.getPosition(),
top = calc.y, left = calc.x;
var scrolls = rel.getScrolls();
top += scrolls.y;
left += scrolls.x;
var dim = this.getDimensions({computeSize: true, styles:['padding', 'border','margin']});
var pos = {},
prefY = options.offset.y,
prefX = options.offset.x,
winSize = window.getSize();
switch(options.position.x){
case 'left':
pos.x = left + prefX;
break;
case 'right':
pos.x = left + prefX + rel.offsetWidth;
break;
default: //center
pos.x = left + ((rel == document.body ? winSize.x : rel.offsetWidth)/2) + prefX;
break;
}
switch(options.position.y){
case 'top':
pos.y = top + prefY;
break;
case 'bottom':
pos.y = top + prefY + rel.offsetHeight;
break;
default: //center
pos.y = top + ((rel == document.body ? winSize.y : rel.offsetHeight)/2) + prefY;
break;
}
if (options.edge){
var edgeOffset = {};
switch(options.edge.x){
case 'left':
edgeOffset.x = 0;
break;
case 'right':
edgeOffset.x = -dim.x-dim.computedRight-dim.computedLeft;
break;
default: //center
edgeOffset.x = -(dim.totalWidth/2);
break;
}
switch(options.edge.y){
case 'top':
edgeOffset.y = 0;
break;
case 'bottom':
edgeOffset.y = -dim.y-dim.computedTop-dim.computedBottom;
break;
default: //center
edgeOffset.y = -(dim.totalHeight/2);
break;
}
pos.x += edgeOffset.x;
pos.y += edgeOffset.y;
}
pos = {
left: ((pos.x >= 0 || parentPositioned || options.allowNegative) ? pos.x : 0).toInt(),
top: ((pos.y >= 0 || parentPositioned || options.allowNegative) ? pos.y : 0).toInt()
};
var xy = {left: 'x', top: 'y'};
['minimum', 'maximum'].each(function(minmax) {
['left', 'top'].each(function(lr) {
var val = options[minmax] ? options[minmax][xy[lr]] : null;
if (val != null && pos[lr] < val) pos[lr] = val;
});
});
if (rel.getStyle('position') == 'fixed' || options.relFixedPosition){
var winScroll = window.getScroll();
pos.top+= winScroll.y;
pos.left+= winScroll.x;
}
if (options.ignoreScroll) {
var relScroll = rel.getScroll();
pos.top-= relScroll.y;
pos.left-= relScroll.x;
}
if (options.ignoreMargins) {
pos.left += (
options.edge.x == 'right' ? dim['margin-right'] :
options.edge.x == 'center' ? -dim['margin-left'] + ((dim['margin-right'] + dim['margin-left'])/2) :
- dim['margin-left']
);
pos.top += (
options.edge.y == 'bottom' ? dim['margin-bottom'] :
options.edge.y == 'center' ? -dim['margin-top'] + ((dim['margin-bottom'] + dim['margin-top'])/2) :
- dim['margin-top']
);
}
pos.left = Math.ceil(pos.left);
pos.top = Math.ceil(pos.top);
if (options.returnPos) return pos;
else this.setStyles(pos);
return this;
}
});
})();
Element.implement({
isDisplayed: function(){
return this.getStyle('display') != 'none';
},
isVisible: function(){
var w = this.offsetWidth,
h = this.offsetHeight;
return (w == 0 && h == 0) ? false : (w > 0 && h > 0) ? true : this.isDisplayed();
},
toggle: function(){
return this[this.isDisplayed() ? 'hide' : 'show']();
},
hide: function(){
var d;
try {
if ((d = this.getStyle('display')) == 'none') d = null;
} catch(e){}
return this.store('originalDisplay', d || 'block').setStyle('display', 'none');
},
show: function(display){
return this.setStyle('display', display || this.retrieve('originalDisplay') || 'block');
},
swapClass: function(remove, add){
return this.removeClass(remove).addClass(add);
}
});
if (!window.Form) window.Form = {};
(function(){
Form.Request = new Class({
Binds: ['onSubmit', 'onFormValidate'],
Implements: [Options, Events, Class.Occlude],
options: {
requestOptions: {
evalScripts: true,
useSpinner: true,
emulation: false,
link: 'ignore'
},
extraData: {},
resetForm: true
},
property: 'form.request',
initialize: function(form, update, options) {
this.element = document.id(form);
if (this.occlude()) return this.occluded;
this.update = document.id(update);
this.setOptions(options);
this.makeRequest();
if (this.options.resetForm) {
this.request.addEvent('success', function(){
$try(function(){ this.element.reset(); }.bind(this));
if (window.OverText) OverText.update();
}.bind(this));
}
this.attach();
},
toElement: function() {
return this.element;
},
makeRequest: function(){
this.request = new Request.HTML($merge({
url: this.element.get('action'),
update: this.update,
emulation: false,
spinnerTarget: this.element,
method: this.element.get('method') || 'post'
}, this.options.requestOptions)).addEvents({
success: function(text, xml){
['success', 'complete'].each(function(evt){
this.fireEvent(evt, [this.update, text, xml]);
}, this);
}.bind(this),
failure: function(xhr){
this.fireEvent('failure', xhr);
}.bind(this),
exception: function(){
this.fireEvent('failure', xhr);
}.bind(this)
});
},
attach: function(attach){
attach = $pick(attach, true);
method = attach ? 'addEvent' : 'removeEvent';
var fv = this.element.retrieve('validator');
if (fv) fv[method]('onFormValidate', this.onFormValidate);
if (!fv || !attach) this.element[method]('submit', this.onSubmit);
},
detach: function(){
this.attach(false);
},
enable: function(){
this.attach();
},
disable: function(){
this.detach();
},
onFormValidate: function(valid, form, e) {
if (valid || !fv.options.stopOnFailure) {
if (e && e.stop) e.stop();
this.send();
}
},
onSubmit: function(e){
if (this.element.retrieve('validator')) {
this.detach();
this.addFormEvent();
return;
}
e.stop();
this.send();
},
send: function(){
var str = this.element.toQueryString().trim();
var data = $H(this.options.extraData).toQueryString();
if (str) str += "&" + data;
else str = data;
this.fireEvent('send', [this.element, str]);
this.request.send({data: str});
return this;
}
});
Element.Properties.formRequest = {
set: function(){
var opt = Array.link(arguments, {options: Object.type, update: Element.type, updateId: String.type});
var update = opt.update || opt.updateId;
var updater = this.retrieve('form.request');
if (update) {
if (updater) updater.update = document.id(update);
this.store('form.request:update', update);
}
if (opt.options) {
if (updater) updater.setOptions(opt.options);
this.store('form.request:options', opt.options);
}
return this;
},
get: function(){
var opt = Array.link(arguments, {options: Object.type, update: Element.type, updateId: String.type});
var update = opt.update || opt.updateId;
if (opt.options || update || !this.retrieve('form.request')){
if (opt.options || !this.retrieve('form.request:options')) this.set('form.request', opt.options);
if (update) this.set('form.request', update);
this.store('form.request', new Form.Request(this, this.retrieve('form.request:update'), this.retrieve('form.request:options')));
}
return this.retrieve('form.request');
}
};
Element.implement({
formUpdate: function(update, options){
this.get('form.request', update, options).send();
return this;
}
});
})();
Form.Request.Append = new Class({
Extends: Form.Request,
options: {
useReveal: true,
revealOptions: {},
inject: 'bottom'
},
makeRequest: function(){
this.request = new Request.HTML($merge({
url: this.element.get('action'),
method: this.element.get('method') || 'post',
spinnerTarget: this.element
}, this.options.requestOptions, {
evalScripts: false
})
).addEvents({
success: function(tree, elements, html, javascript){
var container;
var kids = Elements.from(html);
if (kids.length == 1) {
container = kids[0];
} else {
container = new Element('div', {
styles: {
display: 'none'
}
}).adopt(kids);
}
container.inject(this.update, this.options.inject);
if (this.options.requestOptions.evalScripts) $exec(javascript);
this.fireEvent('beforeEffect', container);
var finish = function(){
this.fireEvent('success', [container, this.update, tree, elements, html, javascript]);
}.bind(this);
if (this.options.useReveal) {
container.get('reveal', this.options.revealOptions).chain(finish);
container.reveal();
} else {
finish();
}
}.bind(this),
failure: function(xhr){
this.fireEvent('failure', xhr);
}.bind(this)
});
}
});
if (!window.Form) window.Form = {};
var InputValidator = new Class({
Implements: [Options],
options: {
errorMsg: 'Validation failed.',
test: function(field){return true;}
},
initialize: function(className, options){
this.setOptions(options);
this.className = className;
},
test: function(field, props){
if (document.id(field)) return this.options.test(document.id(field), props||this.getProps(field));
else return false;
},
getError: function(field, props){
var err = this.options.errorMsg;
if ($type(err) == 'function') err = err(document.id(field), props||this.getProps(field));
return err;
},
getProps: function(field){
if (!document.id(field)) return {};
return field.get('validatorProps');
}
});
Element.Properties.validatorProps = {
set: function(props){
return this.eliminate('validatorProps').store('validatorProps', props);
},
get: function(props){
if (props) this.set(props);
if (this.retrieve('validatorProps')) return this.retrieve('validatorProps');
if (this.getProperty('validatorProps')){
try {
this.store('validatorProps', JSON.decode(this.getProperty('validatorProps')));
}catch(e){
return {};
}
} else {
var vals = this.get('class').split(' ').filter(function(cls){
return cls.test(':');
});
if (!vals.length){
this.store('validatorProps', {});
} else {
props = {};
vals.each(function(cls){
var split = cls.split(':');
if (split[1]) {
try {
props[split[0]] = JSON.decode(split[1]);
} catch(e) {}
}
});
this.store('validatorProps', props);
}
}
return this.retrieve('validatorProps');
}
};
Form.Validator = new Class({
Implements:[Options, Events],
Binds: ['onSubmit'],
options: {/*
onFormValidate: $empty(isValid, form, event),
onElementValidate: $empty(isValid, field, className, warn),
onElementPass: $empty(field),
onElementFail: $empty(field, validatorsFailed) */
fieldSelectors: 'input, select, textarea',
ignoreHidden: true,
ignoreDisabled: true,
useTitles: false,
evaluateOnSubmit: true,
evaluateFieldsOnBlur: true,
evaluateFieldsOnChange: true,
serial: true,
stopOnFailure: true,
warningPrefix: function(){
return Form.Validator.getMsg('warningPrefix') || 'Warning: ';
},
errorPrefix: function(){
return Form.Validator.getMsg('errorPrefix') || 'Error: ';
}
},
initialize: function(form, options){
this.setOptions(options);
this.element = document.id(form);
this.element.store('validator', this);
this.warningPrefix = $lambda(this.options.warningPrefix)();
this.errorPrefix = $lambda(this.options.errorPrefix)();
if (this.options.evaluateOnSubmit) this.element.addEvent('submit', this.onSubmit);
if (this.options.evaluateFieldsOnBlur || this.options.evaluateFieldsOnChange) this.watchFields(this.getFields());
},
toElement: function(){
return this.element;
},
getFields: function(){
return (this.fields = this.element.getElements(this.options.fieldSelectors));
},
watchFields: function(fields){
fields.each(function(el){
if (this.options.evaluateFieldsOnBlur)
el.addEvent('blur', this.validationMonitor.pass([el, false], this));
if (this.options.evaluateFieldsOnChange)
el.addEvent('change', this.validationMonitor.pass([el, true], this));
}, this);
},
validationMonitor: function(){
$clear(this.timer);
this.timer = this.validateField.delay(50, this, arguments);
},
onSubmit: function(event){
if (!this.validate(event) && event) event.preventDefault();
else this.reset();
},
reset: function(){
this.getFields().each(this.resetField, this);
return this;
},
validate: function(event){
var result = this.getFields().map(function(field){
return this.validateField(field, true);
}, this).every(function(v){ return v;});
this.fireEvent('formValidate', [result, this.element, event]);
if (this.options.stopOnFailure && !result && event) event.preventDefault();
return result;
},
validateField: function(field, force){
if (this.paused) return true;
field = document.id(field);
var passed = !field.hasClass('validation-failed');
var failed, warned;
if (this.options.serial && !force){
failed = this.element.getElement('.validation-failed');
warned = this.element.getElement('.warning');
}
if (field && (!failed || force || field.hasClass('validation-failed') || (failed && !this.options.serial))){
var validators = field.className.split(' ').some(function(cn){
return this.getValidator(cn);
}, this);
var validatorsFailed = [];
field.className.split(' ').each(function(className){
if (className && !this.test(className, field)) validatorsFailed.include(className);
}, this);
passed = validatorsFailed.length === 0;
if (validators && !field.hasClass('warnOnly')){
if (passed){
field.addClass('validation-passed').removeClass('validation-failed');
this.fireEvent('elementPass', field);
} else {
field.addClass('validation-failed').removeClass('validation-passed');
this.fireEvent('elementFail', [field, validatorsFailed]);
}
}
if (!warned){
var warnings = field.className.split(' ').some(function(cn){
if (cn.test('^warn-') || field.hasClass('warnOnly'))
return this.getValidator(cn.replace(/^warn-/,''));
else return null;
}, this);
field.removeClass('warning');
var warnResult = field.className.split(' ').map(function(cn){
if (cn.test('^warn-') || field.hasClass('warnOnly'))
return this.test(cn.replace(/^warn-/,''), field, true);
else return null;
}, this);
}
}
return passed;
},
test: function(className, field, warn){
field = document.id(field);
if((this.options.ignoreHidden && !field.isVisible()) || (this.options.ignoreDisabled && field.get('disabled'))) return true;
var validator = this.getValidator(className);
if (field.hasClass('ignoreValidation')) return true;
warn = $pick(warn, false);
if (field.hasClass('warnOnly')) warn = true;
var isValid = validator ? validator.test(field) : true;
if (validator && field.isVisible()) this.fireEvent('elementValidate', [isValid, field, className, warn]);
if (warn) return true;
return isValid;
},
resetField: function(field){
field = document.id(field);
if (field){
field.className.split(' ').each(function(className){
if (className.test('^warn-')) className = className.replace(/^warn-/, '');
field.removeClass('validation-failed');
field.removeClass('warning');
field.removeClass('validation-passed');
}, this);
}
return this;
},
stop: function(){
this.paused = true;
return this;
},
start: function(){
this.paused = false;
return this;
},
ignoreField: function(field, warn){
field = document.id(field);
if (field){
this.enforceField(field);
if (warn) field.addClass('warnOnly');
else field.addClass('ignoreValidation');
}
return this;
},
enforceField: function(field){
field = document.id(field);
if (field) field.removeClass('warnOnly').removeClass('ignoreValidation');
return this;
}
});
Form.Validator.getMsg = function(key){
return MooTools.lang.get('Form.Validator', key);
};
Form.Validator.adders = {
validators:{},
add : function(className, options){
this.validators[className] = new InputValidator(className, options);
if (!this.initialize){
this.implement({
validators: this.validators
});
}
},
addAllThese : function(validators){
$A(validators).each(function(validator){
this.add(validator[0], validator[1]);
}, this);
},
getValidator: function(className){
return this.validators[className.split(':')[0]];
}
};
$extend(Form.Validator, Form.Validator.adders);
Form.Validator.implement(Form.Validator.adders);
Form.Validator.add('IsEmpty', {
errorMsg: false,
test: function(element){
if (element.type == 'select-one' || element.type == 'select')
return !(element.selectedIndex >= 0 && element.options[element.selectedIndex].value != '');
else
return ((element.get('value') == null) || (element.get('value').length == 0));
}
});
Form.Validator.addAllThese([
['required', {
errorMsg: function(){
return Form.Validator.getMsg('required');
},
test: function(element){
return !Form.Validator.getValidator('IsEmpty').test(element);
}
}],
['minLength', {
errorMsg: function(element, props){
if ($type(props.minLength))
return Form.Validator.getMsg('minLength').substitute({minLength:props.minLength,length:element.get('value').length });
else return '';
},
test: function(element, props){
if ($type(props.minLength)) return (element.get('value').length >= $pick(props.minLength, 0));
else return true;
}
}],
['maxLength', {
errorMsg: function(element, props){
if ($type(props.maxLength))
return Form.Validator.getMsg('maxLength').substitute({maxLength:props.maxLength,length:element.get('value').length });
else return '';
},
test: function(element, props){
return (element.get('value').length <= $pick(props.maxLength, 10000));
}
}],
['validate-integer', {
errorMsg: Form.Validator.getMsg.pass('integer'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) || (/^(-?[1-9]\d*|0)$/).test(element.get('value'));
}
}],
['validate-numeric', {
errorMsg: Form.Validator.getMsg.pass('numeric'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) ||
(/^-?(?:0$0(?=\d*\.)|[1-9]|0)\d*(\.\d+)?$/).test(element.get('value'));
}
}],
['validate-digits', {
errorMsg: Form.Validator.getMsg.pass('digits'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) || (/^[\d() .:\-\+#]+$/.test(element.get('value')));
}
}],
['validate-alpha', {
errorMsg: Form.Validator.getMsg.pass('alpha'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) ||  (/^[a-zA-Z]+$/).test(element.get('value'));
}
}],
['validate-alphanum', {
errorMsg: Form.Validator.getMsg.pass('alphanum'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) || !(/\W/).test(element.get('value'));
}
}],
['validate-date', {
errorMsg: function(element, props){
if (Date.parse){
var format = props.dateFormat || '%x';
return Form.Validator.getMsg('dateSuchAs').substitute({date: new Date().format(format)});
} else {
return Form.Validator.getMsg('dateInFormatMDY');
}
},
test: function(element, props){
if (Form.Validator.getValidator('IsEmpty').test(element)) return true;
var d;
if (Date.parse){
var format = props.dateFormat || '%x';
d = Date.parse(element.get('value'));
var formatted = d.format(format);
if (formatted != 'invalid date') element.set('value', formatted);
return !isNaN(d);
} else {
var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
if (!regex.test(element.get('value'))) return false;
d = new Date(element.get('value').replace(regex, '$1/$2/$3'));
return (parseInt(RegExp.$1, 10) == (1 + d.getMonth())) &&
(parseInt(RegExp.$2, 10) == d.getDate()) &&
(parseInt(RegExp.$3, 10) == d.getFullYear());
}
}
}],
['validate-email', {
errorMsg: Form.Validator.getMsg.pass('email'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) || (/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i).test(element.get('value'));
}
}],
['validate-url', {
errorMsg: Form.Validator.getMsg.pass('url'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) || (/^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i).test(element.get('value'));
}
}],
['validate-currency-dollar', {
errorMsg: Form.Validator.getMsg.pass('currencyDollar'),
test: function(element){
return Form.Validator.getValidator('IsEmpty').test(element) ||  (/^\$?\-?([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(element.get('value'));
}
}],
['validate-one-required', {
errorMsg: Form.Validator.getMsg.pass('oneRequired'),
test: function(element, props){
var p = document.id(props['validate-one-required']) || element.getParent();
return p.getElements('input').some(function(el){
if (['checkbox', 'radio'].contains(el.get('type'))) return el.get('checked');
return el.get('value');
});
}
}]
]);
Element.Properties.validator = {
set: function(options){
var validator = this.retrieve('validator');
if (validator) validator.setOptions(options);
return this.store('validator:options');
},
get: function(options){
if (options || !this.retrieve('validator')){
if (options || !this.retrieve('validator:options')) this.set('validator', options);
this.store('validator', new Form.Validator(this, this.retrieve('validator:options')));
}
return this.retrieve('validator');
}
};
Element.implement({
validate: function(options){
this.set('validator', options);
return this.get('validator', options).validate();
}
});
var FormValidator = Form.Validator;
Form.Validator.Inline = new Class({
Extends: Form.Validator,
options: {
scrollToErrorsOnSubmit: true,
scrollFxOptions: {
transition: 'quad:out',
offset: {
y: -20
}
}
},
initialize: function(form, options){
this.parent(form, options);
this.addEvent('onElementValidate', function(isValid, field, className, warn){
var validator = this.getValidator(className);
if (!isValid && validator.getError(field)){
if (warn) field.addClass('warning');
var advice = this.makeAdvice(className, field, validator.getError(field), warn);
this.insertAdvice(advice, field);
this.showAdvice(className, field);
} else {
this.hideAdvice(className, field);
}
});
},
makeAdvice: function(className, field, error, warn){
var errorMsg = (warn)?this.warningPrefix:this.errorPrefix;
errorMsg += (this.options.useTitles) ? field.title || error:error;
var cssClass = (warn) ? 'warning-advice' : 'validation-advice';
var advice = this.getAdvice(className, field);
if(advice) {
advice = advice.set('html', errorMsg);
} else {
advice = new Element('div', {
html: errorMsg,
styles: { display: 'none' },
id: 'advice-' + className + '-' + this.getFieldId(field)
}).addClass(cssClass);
}
field.store('advice-' + className, advice);
return advice;
},
getFieldId : function(field){
return field.id ? field.id : field.id = 'input_' + field.name;
},
showAdvice: function(className, field){
var advice = this.getAdvice(className, field);
if (advice && !field.retrieve(this.getPropName(className))
&& (advice.getStyle('display') == 'none'
|| advice.getStyle('visiblity') == 'hidden'
|| advice.getStyle('opacity') == 0)){
field.store(this.getPropName(className), true);
if (advice.reveal) advice.reveal();
else advice.setStyle('display', 'block');
}
},
hideAdvice: function(className, field){
var advice = this.getAdvice(className, field);
if (advice && field.retrieve(this.getPropName(className))){
field.store(this.getPropName(className), false);
if (advice.dissolve) advice.dissolve();
else advice.setStyle('display', 'none');
}
},
getPropName: function(className){
return 'advice' + className;
},
resetField: function(field){
field = document.id(field);
if (!field) return this;
this.parent(field);
field.className.split(' ').each(function(className){
this.hideAdvice(className, field);
}, this);
return this;
},
getAllAdviceMessages: function(field, force){
var advice = [];
if (field.hasClass('ignoreValidation') && !force) return advice;
var validators = field.className.split(' ').some(function(cn){
var warner = cn.test('^warn-') || field.hasClass('warnOnly');
if (warner) cn = cn.replace(/^warn-/, '');
var validator = this.getValidator(cn);
if (!validator) return;
advice.push({
message: validator.getError(field),
warnOnly: warner,
passed: validator.test(),
validator: validator
});
}, this);
return advice;
},
getAdvice: function(className, field){
return field.retrieve('advice-' + className);
},
insertAdvice: function(advice, field){
var props = field.get('validatorProps');
if (!props.msgPos || !document.id(props.msgPos)){
if(field.type.toLowerCase() == 'radio') field.getParent().adopt(advice);
else advice.inject(document.id(field), 'after');
} else {
document.id(props.msgPos).grab(advice);
}
},
validateField: function(field, force){
var result = this.parent(field, force);
if (this.options.scrollToErrorsOnSubmit && !result){
var failed = document.id(this).getElement('.validation-failed');
var par = document.id(this).getParent();
while (par != document.body && par.getScrollSize().y == par.getSize().y){
par = par.getParent();
}
var fx = par.retrieve('fvScroller');
if (!fx && window.Fx && Fx.Scroll){
fx = new Fx.Scroll(par, this.options.scrollFxOptions);
par.store('fvScroller', fx);
}
if (failed){
if (fx) fx.toElement(failed);
else par.scrollTo(par.getScroll().x, failed.getPosition(par).y - 20);
}
}
return result;
}
});
Form.Validator.addAllThese([
['validate-enforce-oncheck', {
test: function(element, props){
if (element.checked){
var fv = element.getParent('form').retrieve('validator');
if (!fv) return true;
(props.toEnforce || document.id(props.enforceChildrenOf).getElements('input, select, textarea')).map(function(item){
fv.enforceField(item);
});
}
return true;
}
}],
['validate-ignore-oncheck', {
test: function(element, props){
if (element.checked){
var fv = element.getParent('form').retrieve('validator');
if (!fv) return true;
(props.toIgnore || document.id(props.ignoreChildrenOf).getElements('input, select, textarea')).each(function(item){
fv.ignoreField(item);
fv.resetField(item);
});
}
return true;
}
}],
['validate-nospace', {
errorMsg: function(){
return Form.Validator.getMsg('noSpace');
},
test: function(element, props){
return !element.get('value').test(/\s/);
}
}],
['validate-toggle-oncheck', {
test: function(element, props){
var fv = element.getParent('form').retrieve('validator');
if (!fv) return true;
var eleArr = props.toToggle || document.id(props.toToggleChildrenOf).getElements('input, select, textarea');
if (!element.checked){
eleArr.each(function(item){
fv.ignoreField(item);
fv.resetField(item);
});
} else {
eleArr.each(function(item){
fv.enforceField(item);
});
}
return true;
}
}],
['validate-reqchk-bynode', {
errorMsg: function(){
return Form.Validator.getMsg('reqChkByNode');
},
test: function(element, props){
return (document.id(props.nodeId).getElements(props.selector || 'input[type=checkbox], input[type=radio]')).some(function(item){
return item.checked;
});
}
}],
['validate-required-check', {
errorMsg: function(element, props){
return props.useTitle ? element.get('title') : Form.Validator.getMsg('requiredChk');
},
test: function(element, props){
return !!element.checked;
}
}],
['validate-reqchk-byname', {
errorMsg: function(element, props){
return Form.Validator.getMsg('reqChkByName').substitute({label: props.label || element.get('type')});
},
test: function(element, props){
var grpName = props.groupName || element.get('name');
var oneCheckedItem = $$(document.getElementsByName(grpName)).some(function(item, index){
return item.checked;
});
var fv = element.getParent('form').retrieve('validator');
if (oneCheckedItem && fv) fv.resetField(element);
return oneCheckedItem;
}
}],
['validate-match', {
errorMsg: function(element, props){
return Form.Validator.getMsg('match').substitute({matchName: props.matchName || document.id(props.matchInput).get('name')});
},
test: function(element, props){
var eleVal = element.get('value');
var matchVal = document.id(props.matchInput) && document.id(props.matchInput).get('value');
return eleVal && matchVal ? eleVal == matchVal : true;
}
}],
['validate-after-date', {
errorMsg: function(element, props){
return Form.Validator.getMsg('afterDate').substitute({
label: props.afterLabel || (props.afterElement ? Form.Validator.getMsg('startDate') : Form.Validator.getMsg('currentDate'))
});
},
test: function(element, props){
var start = document.id(props.afterElement) ? Date.parse(document.id(props.afterElement).get('value')) : new Date();
var end = Date.parse(element.get('value'));
return end && start ? end >= start : true;
}
}],
['validate-before-date', {
errorMsg: function(element, props){
return Form.Validator.getMsg('beforeDate').substitute({
label: props.beforeLabel || (props.beforeElement ? Form.Validator.getMsg('endDate') : Form.Validator.getMsg('currentDate'))
});
},
test: function(element, props){
var start = Date.parse(element.get('value'));
var end = document.id(props.beforeElement) ? Date.parse(document.id(props.beforeElement).get('value')) : new Date();
return end && start ? end >= start : true;
}
}],
['validate-custom-required', {
errorMsg: function(){
return Form.Validator.getMsg('required');
},
test: function(element, props){
return element.get('value') != props.emptyValue;
}
}],
['validate-same-month', {
errorMsg: function(element, props){
var startMo = document.id(props.sameMonthAs) && document.id(props.sameMonthAs).get('value');
var eleVal = element.get('value');
if (eleVal != '') return Form.Validator.getMsg(startMo ? 'sameMonth' : 'startMonth');
},
test: function(element, props){
var d1 = Date.parse(element.get('value'));
var d2 = Date.parse(document.id(props.sameMonthAs) && document.id(props.sameMonthAs).get('value'));
return d1 && d2 ? d1.format('%B') == d2.format('%B') : true;
}
}],
['validate-cc-num', {
errorMsg: function(element){
var ccNum = element.get('value').ccNum.replace(/[^0-9]/g, '');
return Form.Validator.getMsg('creditcard').substitute({length: ccNum.length});
},
test: function(element){
if (Form.Validator.getValidator('IsEmpty').test(element)) { return true; }
var ccNum = element.get('value');
ccNum = ccNum.replace(/[^0-9]/g, '');
var valid_type = false;
if (ccNum.test(/^4[0-9]{12}([0-9]{3})?$/)) valid_type = 'Visa';
else if (ccNum.test(/^5[1-5]([0-9]{14})$/)) valid_type = 'Master Card';
else if (ccNum.test(/^3[47][0-9]{13}$/)) valid_type = 'American Express';
else if (ccNum.test(/^6011[0-9]{12}$/)) valid_type = 'Discover';
if (valid_type) {
var sum = 0;
var cur = 0;
for(var i=ccNum.length-1; i>=0; --i) {
cur = ccNum.charAt(i).toInt();
if (cur == 0) { continue; }
if ((ccNum.length-i) % 2 == 0) { cur += cur; }
if (cur > 9) { cur = cur.toString().charAt(0).toInt() + cur.toString().charAt(1).toInt(); }
sum += cur;
}
if ((sum % 10) == 0) { return true; }
}
var chunks = '';
while (ccNum != '') {
chunks += ' ' + ccNum.substr(0,4);
ccNum = ccNum.substr(4);
}
element.getParent('form').retrieve('validator').ignoreField(element);
element.set('value', chunks.clean());
element.getParent('form').retrieve('validator').enforceField(element);
return false;
}
}]
]);
var OverText = new Class({
Implements: [Options, Events, Class.Occlude],
Binds: ['reposition', 'assert', 'focus', 'hide'],
options: {/*
textOverride: null,
onFocus: $empty()
onTextHide: $empty(textEl, inputEl),
onTextShow: $empty(textEl, inputEl), */
element: 'label',
positionOptions: {
position: 'upperLeft',
edge: 'upperLeft',
offset: {
x: 4,
y: 2
}
},
poll: false,
pollInterval: 250,
wrap: false
},
property: 'OverText',
initialize: function(element, options){
this.element = document.id(element);
if (this.occlude()) return this.occluded;
this.setOptions(options);
this.attach(this.element);
OverText.instances.push(this);
if (this.options.poll) this.poll();
return this;
},
toElement: function(){
return this.element;
},
attach: function(){
var val = this.options.textOverride || this.element.get('alt') || this.element.get('title');
if (!val) return;
this.text = new Element(this.options.element, {
'class': 'overTxtLabel',
styles: {
lineHeight: 'normal',
position: 'absolute',
cursor: 'text'
},
html: val,
events: {
click: this.hide.pass(this.options.element == 'label', this)
}
}).inject(this.element, 'after');
if (this.options.element == 'label') {
if (!this.element.get('id')) this.element.set('id', 'input_' + new Date().getTime());
this.text.set('for', this.element.get('id'));
}
if (this.options.wrap) {
this.textHolder = new Element('div', {
styles: {
lineHeight: 'normal',
position: 'relative'
},
'class':'overTxtWrapper'
}).adopt(this.text).inject(this.element, 'before');
}
this.element.addEvents({
focus: this.focus,
blur: this.assert,
change: this.assert
}).store('OverTextDiv', this.text);
window.addEvent('resize', this.reposition.bind(this));
this.assert(true);
this.reposition();
},
wrap: function(){
if (this.options.element == 'label') {
if (!this.element.get('id')) this.element.set('id', 'input_' + new Date().getTime());
this.text.set('for', this.element.get('id'));
}
},
startPolling: function(){
this.pollingPaused = false;
return this.poll();
},
poll: function(stop){
if (this.poller && !stop) return this;
var test = function(){
if (!this.pollingPaused) this.assert(true);
}.bind(this);
if (stop) $clear(this.poller);
else this.poller = test.periodical(this.options.pollInterval, this);
return this;
},
stopPolling: function(){
this.pollingPaused = true;
return this.poll(true);
},
focus: function(){
if (this.text && (!this.text.isDisplayed() || this.element.get('disabled'))) return;
this.hide();
},
hide: function(suppressFocus, force){
if (this.text && (this.text.isDisplayed() && (!this.element.get('disabled') || force))){
this.text.hide();
this.fireEvent('textHide', [this.text, this.element]);
this.pollingPaused = true;
try {
if (!suppressFocus) this.element.fireEvent('focus');
this.element.focus();
} catch(e){} //IE barfs if you call focus on hidden elements
}
return this;
},
show: function(){
if (this.text && !this.text.isDisplayed()){
this.text.show();
this.reposition();
this.fireEvent('textShow', [this.text, this.element]);
this.pollingPaused = false;
}
return this;
},
assert: function(suppressFocus){
this[this.test() ? 'show' : 'hide'](suppressFocus);
},
test: function(){
var v = this.element.get('value');
return !v;
},
reposition: function(){
this.assert(true);
if (!this.element.isVisible()) return this.stopPolling().hide();
if (this.text && this.test()) this.text.position($merge(this.options.positionOptions, {relativeTo: this.element}));
return this;
}
});
OverText.instances = [];
$extend(OverText, {
each: function(fn) {
return OverText.instances.map(function(ot, i){
if (ot.element && ot.text) return fn.apply(OverText, [ot, i]);
return null; //the input or the text was destroyed
});
},
update: function(){
return OverText.each(function(ot){
return ot.reposition();
});
},
hideAll: function(){
return OverText.each(function(ot){
return ot.hide(true, true);
});
},
showAll: function(){
return OverText.each(function(ot) {
return ot.show();
});
}
});
if (window.Fx && Fx.Reveal) {
Fx.Reveal.implement({
hideInputs: Browser.Engine.trident ? 'select, input, textarea, object, embed, .overTxtLabel' : false
});
}
Fx.Elements = new Class({
Extends: Fx.CSS,
initialize: function(elements, options){
this.elements = this.subject = $$(elements);
this.parent(options);
},
compute: function(from, to, delta){
var now = {};
for (var i in from){
var iFrom = from[i], iTo = to[i], iNow = now[i] = {};
for (var p in iFrom) iNow[p] = this.parent(iFrom[p], iTo[p], delta);
}
return now;
},
set: function(now){
for (var i in now){
var iNow = now[i];
for (var p in iNow) this.render(this.elements[i], p, iNow[p], this.options.unit);
}
return this;
},
start: function(obj){
if (!this.check(obj)) return this;
var from = {}, to = {};
for (var i in obj){
var iProps = obj[i], iFrom = from[i] = {}, iTo = to[i] = {};
for (var p in iProps){
var parsed = this.prepare(this.elements[i], p, iProps[p]);
iFrom[p] = parsed.from;
iTo[p] = parsed.to;
}
}
return this.parent(from, to);
}
});
var Accordion = Fx.Accordion = new Class({
Extends: Fx.Elements,
options: {/*
onActive: $empty(toggler, section),
onBackground: $empty(toggler, section),
fixedHeight: false,
fixedWidth: false,
*/
display: 0,
show: false,
height: true,
width: false,
opacity: true,
alwaysHide: false,
trigger: 'click',
initialDisplayFx: true,
returnHeightToAuto: true
},
initialize: function(){
var params = Array.link(arguments, {'container': Element.type, 'options': Object.type, 'togglers': $defined, 'elements': $defined});
this.parent(params.elements, params.options);
this.togglers = $$(params.togglers);
this.container = document.id(params.container);
this.previous = -1;
this.internalChain = new Chain();
if (this.options.alwaysHide) this.options.wait = true;
if ($chk(this.options.show)){
this.options.display = false;
this.previous = this.options.show;
}
if (this.options.start){
this.options.display = false;
this.options.show = false;
}
this.effects = {};
if (this.options.opacity) this.effects.opacity = 'fullOpacity';
if (this.options.width) this.effects.width = this.options.fixedWidth ? 'fullWidth' : 'offsetWidth';
if (this.options.height) this.effects.height = this.options.fixedHeight ? 'fullHeight' : 'scrollHeight';
for (var i = 0, l = this.togglers.length; i < l; i++) this.addSection(this.togglers[i], this.elements[i]);
this.elements.each(function(el, i){
if (this.options.show === i){
this.fireEvent('active', [this.togglers[i], el]);
} else {
for (var fx in this.effects) el.setStyle(fx, 0);
}
}, this);
if ($chk(this.options.display)) this.display(this.options.display, this.options.initialDisplayFx);
this.addEvent('complete', this.internalChain.callChain.bind(this.internalChain));
},
addSection: function(toggler, element){
toggler = document.id(toggler);
element = document.id(element);
var test = this.togglers.contains(toggler);
this.togglers.include(toggler);
this.elements.include(element);
var idx = this.togglers.indexOf(toggler);
var displayer = this.display.bind(this, idx);
toggler.store('accordion:display', displayer);
toggler.addEvent(this.options.trigger, displayer);
if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'});
if (this.options.width) element.setStyles({'padding-left': 0, 'border-left': 'none', 'padding-right': 0, 'border-right': 'none'});
element.fullOpacity = 1;
if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth;
if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight;
element.setStyle('overflow', 'hidden');
if (!test){
for (var fx in this.effects) element.setStyle(fx, 0);
}
return this;
},
detach: function(){
this.togglers.each(function(toggler) {
toggler.removeEvent(this.options.trigger, toggler.retrieve('accordion:display'));
}, this);
},
display: function(index, useFx){
if (!this.check(index, useFx)) return this;
useFx = $pick(useFx, true);
if (this.options.returnHeightToAuto){
var prev = this.elements[this.previous];
if (prev && !this.selfHidden){
for (var fx in this.effects){
prev.setStyle(fx, prev[this.effects[fx]]);
}
}
}
index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;
if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;
this.previous = index;
var obj = {};
this.elements.each(function(el, i){
obj[i] = {};
var hide;
if (i != index){
hide = true;
} else if (this.options.alwaysHide && ((el.offsetHeight > 0 && this.options.height) || el.offsetWidth > 0 && this.options.width)){
hide = true;
this.selfHidden = true;
}
this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el]);
for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];
}, this);
this.internalChain.chain(function(){
if (this.options.returnHeightToAuto && !this.selfHidden){
var el = this.elements[index];
if (el) el.setStyle('height', 'auto');
};
}.bind(this));
return useFx ? this.start(obj) : this.set(obj);
}
});
Fx.Move = new Class({
Extends: Fx.Morph,
options: {
relativeTo: document.body,
position: 'center',
edge: false,
offset: {x: 0, y: 0}
},
start: function(destination){
return this.parent(this.element.position($merge(this.options, destination, {returnPos: true})));
}
});
Element.Properties.move = {
set: function(options){
var morph = this.retrieve('move');
if (morph) morph.cancel();
return this.eliminate('move').store('move:options', $extend({link: 'cancel'}, options));
},
get: function(options){
if (options || !this.retrieve('move')){
if (options || !this.retrieve('move:options')) this.set('move', options);
this.store('move', new Fx.Move(this, this.retrieve('move:options')));
}
return this.retrieve('move');
}
};
Element.implement({
move: function(options){
this.get('move').start(options);
return this;
}
});
Fx.Reveal = new Class({
Extends: Fx.Morph,
options: {/*
onShow: $empty(thisElement),
onHide: $empty(thisElement),
onComplete: $empty(thisElement),
heightOverride: null,
widthOverride: null, */
link: 'cancel',
styles: ['padding', 'border', 'margin'],
transitionOpacity: !Browser.Engine.trident4,
mode: 'vertical',
display: 'block',
hideInputs: Browser.Engine.trident ? 'select, input, textarea, object, embed' : false
},
dissolve: function(){
try {
if (!this.hiding && !this.showing){
if (this.element.getStyle('display') != 'none'){
this.hiding = true;
this.showing = false;
this.hidden = true;
this.cssText = this.element.style.cssText;
var startStyles = this.element.getComputedSize({
styles: this.options.styles,
mode: this.options.mode
});
this.element.setStyle('display', 'block');
if (this.options.transitionOpacity) startStyles.opacity = 1;
var zero = {};
$each(startStyles, function(style, name){
zero[name] = [style, 0];
}, this);
this.element.setStyle('overflow', 'hidden');
var hideThese = this.options.hideInputs ? this.element.getElements(this.options.hideInputs) : null;
this.$chain.unshift(function(){
if (this.hidden){
this.hiding = false;
$each(startStyles, function(style, name){
startStyles[name] = style;
}, this);
this.element.style.cssText = this.cssText;
this.element.setStyle('display', 'none');
if (hideThese) hideThese.setStyle('visibility', 'visible');
}
this.fireEvent('hide', this.element);
this.callChain();
}.bind(this));
if (hideThese) hideThese.setStyle('visibility', 'hidden');
this.start(zero);
} else {
this.callChain.delay(10, this);
this.fireEvent('complete', this.element);
this.fireEvent('hide', this.element);
}
} else if (this.options.link == 'chain'){
this.chain(this.dissolve.bind(this));
} else if (this.options.link == 'cancel' && !this.hiding){
this.cancel();
this.dissolve();
}
} catch(e){
this.hiding = false;
this.element.setStyle('display', 'none');
this.callChain.delay(10, this);
this.fireEvent('complete', this.element);
this.fireEvent('hide', this.element);
}
return this;
},
reveal: function(){
try {
if (!this.showing && !this.hiding){
if (this.element.getStyle('display') == 'none' ||
this.element.getStyle('visiblity') == 'hidden' ||
this.element.getStyle('opacity') == 0){
this.showing = true;
this.hiding = this.hidden =  false;
var startStyles;
this.cssText = this.element.style.cssText;
this.element.measure(function(){
startStyles = this.element.getComputedSize({
styles: this.options.styles,
mode: this.options.mode
});
}.bind(this));
$each(startStyles, function(style, name){
startStyles[name] = style;
});
if ($chk(this.options.heightOverride)) startStyles.height = this.options.heightOverride.toInt();
if ($chk(this.options.widthOverride)) startStyles.width = this.options.widthOverride.toInt();
if (this.options.transitionOpacity) {
this.element.setStyle('opacity', 0);
startStyles.opacity = 1;
}
var zero = {
height: 0,
display: this.options.display
};
$each(startStyles, function(style, name){ zero[name] = 0; });
this.element.setStyles($merge(zero, {overflow: 'hidden'}));
var hideThese = this.options.hideInputs ? this.element.getElements(this.options.hideInputs) : null;
if (hideThese) hideThese.setStyle('visibility', 'hidden');
this.start(startStyles);
this.$chain.unshift(function(){
this.element.style.cssText = this.cssText;
this.element.setStyle('display', this.options.display);
if (!this.hidden) this.showing = false;
if (hideThese) hideThese.setStyle('visibility', 'visible');
this.callChain();
this.fireEvent('show', this.element);
}.bind(this));
} else {
this.callChain();
this.fireEvent('complete', this.element);
this.fireEvent('show', this.element);
}
} else if (this.options.link == 'chain'){
this.chain(this.reveal.bind(this));
} else if (this.options.link == 'cancel' && !this.showing){
this.cancel();
this.reveal();
}
} catch(e){
this.element.setStyles({
display: this.options.display,
visiblity: 'visible',
opacity: 1
});
this.showing = false;
this.callChain.delay(10, this);
this.fireEvent('complete', this.element);
this.fireEvent('show', this.element);
}
return this;
},
toggle: function(){
if (this.element.getStyle('display') == 'none' ||
this.element.getStyle('visiblity') == 'hidden' ||
this.element.getStyle('opacity') == 0){
this.reveal();
} else {
this.dissolve();
}
return this;
},
cancel: function(){
this.parent.apply(this, arguments);
this.element.style.cssText = this.cssText;
this.hidding = false;
this.showing = false;
}
});
Element.Properties.reveal = {
set: function(options){
var reveal = this.retrieve('reveal');
if (reveal) reveal.cancel();
return this.eliminate('reveal').store('reveal:options', options);
},
get: function(options){
if (options || !this.retrieve('reveal')){
if (options || !this.retrieve('reveal:options')) this.set('reveal', options);
this.store('reveal', new Fx.Reveal(this, this.retrieve('reveal:options')));
}
return this.retrieve('reveal');
}
};
Element.Properties.dissolve = Element.Properties.reveal;
Element.implement({
reveal: function(options){
this.get('reveal', options).reveal();
return this;
},
dissolve: function(options){
this.get('reveal', options).dissolve();
return this;
},
nix: function(){
var params = Array.link(arguments, {destroy: Boolean.type, options: Object.type});
this.get('reveal', params.options).dissolve().chain(function(){
this[params.destroy ? 'destroy' : 'dispose']();
}.bind(this));
return this;
},
wink: function(){
var params = Array.link(arguments, {duration: Number.type, options: Object.type});
var reveal = this.get('reveal', params.options);
reveal.reveal().chain(function(){
(function(){
reveal.dissolve();
}).delay(params.duration || 2000);
});
}
});
Fx.Scroll = new Class({
Extends: Fx,
options: {
offset: {x: 0, y: 0},
wheelStops: true
},
initialize: function(element, options){
this.element = this.subject = document.id(element);
this.parent(options);
var cancel = this.cancel.bind(this, false);
if ($type(this.element) != 'element') this.element = document.id(this.element.getDocument().body);
var stopper = this.element;
if (this.options.wheelStops){
this.addEvent('start', function(){
stopper.addEvent('mousewheel', cancel);
}, true);
this.addEvent('complete', function(){
stopper.removeEvent('mousewheel', cancel);
}, true);
}
},
set: function(){
var now = Array.flatten(arguments);
if (Browser.Engine.gecko) now = [Math.round(now[0]), Math.round(now[1])];
this.element.scrollTo(now[0], now[1]);
},
compute: function(from, to, delta){
return [0, 1].map(function(i){
return Fx.compute(from[i], to[i], delta);
});
},
start: function(x, y){
if (!this.check(x, y)) return this;
var scrollSize = this.element.getScrollSize(),
scroll = this.element.getScroll(),
values = {x: x, y: y};
for (var z in values){
var max = scrollSize[z];
if ($chk(values[z])) values[z] = ($type(values[z]) == 'number') ? values[z] : max;
else values[z] = scroll[z];
values[z] += this.options.offset[z];
}
return this.parent([scroll.x, scroll.y], [values.x, values.y]);
},
toTop: function(){
return this.start(false, 0);
},
toLeft: function(){
return this.start(0, false);
},
toRight: function(){
return this.start('right', false);
},
toBottom: function(){
return this.start(false, 'bottom');
},
toElement: function(el){
var position = document.id(el).getPosition(this.element);
return this.start(position.x, position.y);
},
scrollIntoView: function(el, axes, offset){
axes = axes ? $splat(axes) : ['x','y'];
var to = {};
el = document.id(el);
var pos = el.getPosition(this.element);
var size = el.getSize();
var scroll = this.element.getScroll();
var containerSize = this.element.getSize();
var edge = {
x: pos.x + size.x,
y: pos.y + size.y
};
['x','y'].each(function(axis) {
if (axes.contains(axis)) {
if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
if (pos[axis] < scroll[axis]) to[axis] = pos[axis];
}
if (to[axis] == null) to[axis] = scroll[axis];
if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
}, this);
if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
return this;
},
scrollToCenter: function(el, axes, offset){
axes = axes ? $splat(axes) : ['x', 'y'];
el = $(el);
var to = {},
pos = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
x: pos.x + size.x,
y: pos.y + size.y
};
['x','y'].each(function(axis){
if(axes.contains(axis)){
to[axis] = pos[axis] - (containerSize[axis] - size[axis])/2;
}
if(to[axis] == null) to[axis] = scroll[axis];
if(offset && offset[axis]) to[axis] = to[axis] + offset[axis];
}, this);
if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
return this;
}
});
Fx.Slide = new Class({
Extends: Fx,
options: {
mode: 'vertical',
hideOverflow: true
},
initialize: function(element, options){
this.addEvent('complete', function(){
this.open = (this.wrapper['offset' + this.layout.capitalize()] != 0);
if (this.open && Browser.Engine.webkit419) this.element.dispose().inject(this.wrapper);
}, true);
this.element = this.subject = document.id(element);
this.parent(options);
var wrapper = this.element.retrieve('wrapper');
var styles = this.element.getStyles('margin', 'position', 'overflow');
if (this.options.hideOverflow) styles = $extend(styles, {overflow: 'hidden'});
this.wrapper = wrapper || new Element('div', {
styles: styles
}).wraps(this.element);
this.element.store('wrapper', this.wrapper).setStyle('margin', 0);
this.now = [];
this.open = true;
},
vertical: function(){
this.margin = 'margin-top';
this.layout = 'height';
this.offset = this.element.offsetHeight;
},
horizontal: function(){
this.margin = 'margin-left';
this.layout = 'width';
this.offset = this.element.offsetWidth;
},
set: function(now){
this.element.setStyle(this.margin, now[0]);
this.wrapper.setStyle(this.layout, now[1]);
return this;
},
compute: function(from, to, delta){
return [0, 1].map(function(i){
return Fx.compute(from[i], to[i], delta);
});
},
start: function(how, mode){
if (!this.check(how, mode)) return this;
this[mode || this.options.mode]();
var margin = this.element.getStyle(this.margin).toInt();
var layout = this.wrapper.getStyle(this.layout).toInt();
var caseIn = [[margin, layout], [0, this.offset]];
var caseOut = [[margin, layout], [-this.offset, 0]];
var start;
switch (how){
case 'in': start = caseIn; break;
case 'out': start = caseOut; break;
case 'toggle': start = (layout == 0) ? caseIn : caseOut;
}
return this.parent(start[0], start[1]);
},
slideIn: function(mode){
return this.start('in', mode);
},
slideOut: function(mode){
return this.start('out', mode);
},
hide: function(mode){
this[mode || this.options.mode]();
this.open = false;
return this.set([-this.offset, 0]);
},
show: function(mode){
this[mode || this.options.mode]();
this.open = true;
return this.set([0, this.offset]);
},
toggle: function(mode){
return this.start('toggle', mode);
}
});
Element.Properties.slide = {
set: function(options){
var slide = this.retrieve('slide');
if (slide) slide.cancel();
return this.eliminate('slide').store('slide:options', $extend({link: 'cancel'}, options));
},
get: function(options){
if (options || !this.retrieve('slide')){
if (options || !this.retrieve('slide:options')) this.set('slide', options);
this.store('slide', new Fx.Slide(this, this.retrieve('slide:options')));
}
return this.retrieve('slide');
}
};
Element.implement({
slide: function(how, mode){
how = how || 'toggle';
var slide = this.get('slide'), toggle;
switch (how){
case 'hide': slide.hide(mode); break;
case 'show': slide.show(mode); break;
case 'toggle':
var flag = this.retrieve('slide:flag', slide.open);
slide[flag ? 'slideOut' : 'slideIn'](mode);
this.store('slide:flag', !flag);
toggle = true;
break;
default: slide.start(how, mode);
}
if (!toggle) this.eliminate('slide:flag');
return this;
}
});
var SmoothScroll = Fx.SmoothScroll = new Class({
Extends: Fx.Scroll,
initialize: function(options, context){
context = context || document;
this.doc = context.getDocument();
var win = context.getWindow();
this.parent(this.doc, options);
this.links = $$(this.options.links || this.doc.links);
var location = win.location.href.match(/^[^#]*/)[0] + '#';
this.links.each(function(link){
if (link.href.indexOf(location) != 0) {return;}
var anchor = link.href.substr(location.length);
if (anchor) this.useLink(link, anchor);
}, this);
if (!Browser.Engine.webkit419) {
this.addEvent('complete', function(){
win.location.hash = this.anchor;
}, true);
}
},
useLink: function(link, anchor){
var el;
link.addEvent('click', function(event){
if (el !== false && !el) el = document.id(anchor) || this.doc.getElement('a[name=' + anchor + ']');
if (el) {
event.preventDefault();
this.anchor = anchor;
this.toElement(el).chain(function(){
this.fireEvent('scrolledTo', [link, el]);
}.bind(this));
link.blur();
}
}.bind(this));
}
});
Fx.Sort = new Class({
Extends: Fx.Elements,
options: {
mode: 'vertical'
},
initialize: function(elements, options){
this.parent(elements, options);
this.elements.each(function(el){
if (el.getStyle('position') == 'static') el.setStyle('position', 'relative');
});
this.setDefaultOrder();
},
setDefaultOrder: function(){
this.currentOrder = this.elements.map(function(el, index){
return index;
});
},
sort: function(newOrder){
if ($type(newOrder) != 'array') return false;
var top = 0,
left = 0,
next = {},
zero = {},
vert = this.options.mode == 'vertical';
var current = this.elements.map(function(el, index){
var size = el.getComputedSize({styles: ['border', 'padding', 'margin']});
var val;
if (vert){
val = {
top: top,
margin: size['margin-top'],
height: size.totalHeight
};
top += val.height - size['margin-top'];
} else {
val = {
left: left,
margin: size['margin-left'],
width: size.totalWidth
};
left += val.width;
}
var plain = vert ? 'top' : 'left';
zero[index] = {};
var start = el.getStyle(plain).toInt();
zero[index][plain] = start || 0;
return val;
}, this);
this.set(zero);
newOrder = newOrder.map(function(i){ return i.toInt(); });
if (newOrder.length != this.elements.length){
this.currentOrder.each(function(index){
if (!newOrder.contains(index)) newOrder.push(index);
});
if (newOrder.length > this.elements.length)
newOrder.splice(this.elements.length-1, newOrder.length - this.elements.length);
}
var margin = top = left = 0;
newOrder.each(function(item, index){
var newPos = {};
if (vert){
newPos.top = top - current[item].top - margin;
top += current[item].height;
} else {
newPos.left = left - current[item].left;
left += current[item].width;
}
margin = margin + current[item].margin;
next[item]=newPos;
}, this);
var mapped = {};
$A(newOrder).sort().each(function(index){
mapped[index] = next[index];
});
this.start(mapped);
this.currentOrder = newOrder;
return this;
},
rearrangeDOM: function(newOrder){
newOrder = newOrder || this.currentOrder;
var parent = this.elements[0].getParent();
var rearranged = [];
this.elements.setStyle('opacity', 0);
newOrder.each(function(index){
rearranged.push(this.elements[index].inject(parent).setStyles({
top: 0,
left: 0
}));
}, this);
this.elements.setStyle('opacity', 1);
this.elements = $$(rearranged);
this.setDefaultOrder();
return this;
},
getDefaultOrder: function(){
return this.elements.map(function(el, index){
return index;
});
},
forward: function(){
return this.sort(this.getDefaultOrder());
},
backward: function(){
return this.sort(this.getDefaultOrder().reverse());
},
reverse: function(){
return this.sort(this.currentOrder.reverse());
},
sortByElements: function(elements){
return this.sort(elements.map(function(el){
return this.elements.indexOf(el);
}, this));
},
swap: function(one, two){
if ($type(one) == 'element') one = this.elements.indexOf(one);
if ($type(two) == 'element') two = this.elements.indexOf(two);
var newOrder = $A(this.currentOrder);
newOrder[this.currentOrder.indexOf(one)] = two;
newOrder[this.currentOrder.indexOf(two)] = one;
return this.sort(newOrder);
}
});
var Drag = new Class({
Implements: [Events, Options],
options: {/*
onBeforeStart: $empty(thisElement),
onStart: $empty(thisElement, event),
onSnap: $empty(thisElement)
onDrag: $empty(thisElement, event),
onCancel: $empty(thisElement),
onComplete: $empty(thisElement, event),*/
snap: 6,
unit: 'px',
grid: false,
style: true,
limit: false,
handle: false,
invert: false,
preventDefault: false,
stopPropagation: false,
modifiers: {x: 'left', y: 'top'}
},
initialize: function(){
var params = Array.link(arguments, {'options': Object.type, 'element': $defined});
this.element = document.id(params.element);
this.document = this.element.getDocument();
this.setOptions(params.options || {});
var htype = $type(this.options.handle);
this.handles = ((htype == 'array' || htype == 'collection') ? $$(this.options.handle) : document.id(this.options.handle)) || this.element;
this.mouse = {'now': {}, 'pos': {}};
this.value = {'start': {}, 'now': {}};
this.selection = (Browser.Engine.trident) ? 'selectstart' : 'mousedown';
this.bound = {
start: this.start.bind(this),
check: this.check.bind(this),
drag: this.drag.bind(this),
stop: this.stop.bind(this),
cancel: this.cancel.bind(this),
eventStop: $lambda(false)
};
this.attach();
},
attach: function(){
this.handles.addEvent('mousedown', this.bound.start);
return this;
},
detach: function(){
this.handles.removeEvent('mousedown', this.bound.start);
return this;
},
start: function(event){
if (event.rightClick) return;
if (this.options.preventDefault) event.preventDefault();
if (this.options.stopPropagation) event.stopPropagation();
this.mouse.start = event.page;
this.fireEvent('beforeStart', this.element);
var limit = this.options.limit;
this.limit = {x: [], y: []};
for (var z in this.options.modifiers){
if (!this.options.modifiers[z]) continue;
if (this.options.style) this.value.now[z] = this.element.getStyle(this.options.modifiers[z]).toInt();
else this.value.now[z] = this.element[this.options.modifiers[z]];
if (this.options.invert) this.value.now[z] *= -1;
this.mouse.pos[z] = event.page[z] - this.value.now[z];
if (limit && limit[z]){
for (var i = 2; i--; i){
if ($chk(limit[z][i])) this.limit[z][i] = $lambda(limit[z][i])();
}
}
}
if ($type(this.options.grid) == 'number') this.options.grid = {x: this.options.grid, y: this.options.grid};
this.document.addEvents({mousemove: this.bound.check, mouseup: this.bound.cancel});
this.document.addEvent(this.selection, this.bound.eventStop);
},
check: function(event){
if (this.options.preventDefault) event.preventDefault();
var distance = Math.round(Math.sqrt(Math.pow(event.page.x - this.mouse.start.x, 2) + Math.pow(event.page.y - this.mouse.start.y, 2)));
if (distance > this.options.snap){
this.cancel();
this.document.addEvents({
mousemove: this.bound.drag,
mouseup: this.bound.stop
});
this.fireEvent('start', [this.element, event]).fireEvent('snap', this.element);
}
},
drag: function(event){
if (this.options.preventDefault) event.preventDefault();
this.mouse.now = event.page;
for (var z in this.options.modifiers){
if (!this.options.modifiers[z]) continue;
this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
if (this.options.invert) this.value.now[z] *= -1;
if (this.options.limit && this.limit[z]){
if ($chk(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])){
this.value.now[z] = this.limit[z][1];
} else if ($chk(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])){
this.value.now[z] = this.limit[z][0];
}
}
if (this.options.grid[z]) this.value.now[z] -= ((this.value.now[z] - (this.limit[z][0]||0)) % this.options.grid[z]);
if (this.options.style) {
this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);
} else {
this.element[this.options.modifiers[z]] = this.value.now[z];
}
}
this.fireEvent('drag', [this.element, event]);
},
cancel: function(event){
this.document.removeEvent('mousemove', this.bound.check);
this.document.removeEvent('mouseup', this.bound.cancel);
if (event){
this.document.removeEvent(this.selection, this.bound.eventStop);
this.fireEvent('cancel', this.element);
}
},
stop: function(event){
this.document.removeEvent(this.selection, this.bound.eventStop);
this.document.removeEvent('mousemove', this.bound.drag);
this.document.removeEvent('mouseup', this.bound.stop);
if (event) this.fireEvent('complete', [this.element, event]);
}
});
Element.implement({
makeResizable: function(options){
var drag = new Drag(this, $merge({modifiers: {x: 'width', y: 'height'}}, options));
this.store('resizer', drag);
return drag.addEvent('drag', function(){
this.fireEvent('resize', drag);
}.bind(this));
}
});
Drag.Move = new Class({
Extends: Drag,
options: {/*
onEnter: $empty(thisElement, overed),
onLeave: $empty(thisElement, overed),
onDrop: $empty(thisElement, overed, event),*/
droppables: [],
container: false,
precalculate: false,
includeMargins: true,
checkDroppables: true
},
initialize: function(element, options){
this.parent(element, options);
element = this.element;
this.droppables = $$(this.options.droppables);
this.container = document.id(this.options.container);
if (this.container && $type(this.container) != 'element')
this.container = document.id(this.container.getDocument().body);
var styles = element.getStyles('left', 'right', 'position');
if (styles.left == 'auto' || styles.top == 'auto')
element.setPosition(element.getPosition(element.getOffsetParent()));
if (styles.position == 'static')
element.setStyle('position', 'absolute');
this.addEvent('start', this.checkDroppables, true);
this.overed = null;
},
start: function(event){
if (this.container) this.options.limit = this.calculateLimit();
if (this.options.precalculate){
this.positions = this.droppables.map(function(el){
return el.getCoordinates();
});
}
this.parent(event);
},
calculateLimit: function(){
var offsetParent = this.element.getOffsetParent(),
containerCoordinates = this.container.getCoordinates(offsetParent),
containerBorder = {},
elementMargin = {},
elementBorder = {},
containerMargin = {},
offsetParentPadding = {};
['top', 'right', 'bottom', 'left'].each(function(pad){
containerBorder[pad] = this.container.getStyle('border-' + pad).toInt();
elementBorder[pad] = this.element.getStyle('border-' + pad).toInt();
elementMargin[pad] = this.element.getStyle('margin-' + pad).toInt();
containerMargin[pad] = this.container.getStyle('margin-' + pad).toInt();
offsetParentPadding[pad] = offsetParent.getStyle('padding-' + pad).toInt();
}, this);
var width = this.element.offsetWidth + elementMargin.left + elementMargin.right,
height = this.element.offsetHeight + elementMargin.top + elementMargin.bottom,
left = 0,
top = 0,
right = containerCoordinates.right - containerBorder.right - width,
bottom = containerCoordinates.bottom - containerBorder.bottom - height;
if (this.options.includeMargins){
left += elementMargin.left;
top += elementMargin.top;
} else {
right += elementMargin.right;
bottom += elementMargin.bottom;
}
if (this.element.getStyle('position') == 'relative'){
var coords = this.element.getCoordinates(offsetParent);
coords.left -= this.element.getStyle('left').toInt();
coords.top -= this.element.getStyle('top').toInt();
left += containerBorder.left - coords.left;
top += containerBorder.top - coords.top;
right += elementMargin.left - coords.left;
bottom += elementMargin.top - coords.top;
if (this.container != offsetParent){
left += containerMargin.left + offsetParentPadding.left;
top += (Browser.Engine.trident4 ? 0 : containerMargin.top) + offsetParentPadding.top;
}
} else {
left -= elementMargin.left;
top -= elementMargin.top;
if (this.container == offsetParent){
right -= containerBorder.left;
bottom -= containerBorder.top;
} else {
left += containerCoordinates.left + containerBorder.left;
top += containerCoordinates.top + containerBorder.top;
}
}
return {
x: [left, right],
y: [top, bottom]
};
},
checkAgainst: function(el, i){
el = (this.positions) ? this.positions[i] : el.getCoordinates();
var now = this.mouse.now;
return (now.x > el.left && now.x < el.right && now.y < el.bottom && now.y > el.top);
},
checkDroppables: function(){
var overed = this.droppables.filter(this.checkAgainst, this).getLast();
if (this.overed != overed){
if (this.overed) this.fireEvent('leave', [this.element, this.overed]);
if (overed) this.fireEvent('enter', [this.element, overed]);
this.overed = overed;
}
},
drag: function(event){
this.parent(event);
if (this.options.checkDroppables && this.droppables.length) this.checkDroppables();
},
stop: function(event){
this.checkDroppables();
this.fireEvent('drop', [this.element, this.overed, event]);
this.overed = null;
return this.parent(event);
}
});
Element.implement({
makeDraggable: function(options){
var drag = new Drag.Move(this, options);
this.store('dragger', drag);
return drag;
}
});
var Slider = new Class({
Implements: [Events, Options],
Binds: ['clickedElement', 'draggedKnob', 'scrolledElement'],
options: {/*
onTick: $empty(intPosition),
onChange: $empty(intStep),
onComplete: $empty(strStep),*/
onTick: function(position){
if (this.options.snap) position = this.toPosition(this.step);
this.knob.setStyle(this.property, position);
},
initialStep: 0,
snap: false,
offset: 0,
range: false,
wheel: false,
steps: 100,
mode: 'horizontal'
},
initialize: function(element, knob, options){
this.setOptions(options);
this.element = document.id(element);
this.knob = document.id(knob);
this.previousChange = this.previousEnd = this.step = -1;
var offset, limit = {}, modifiers = {'x': false, 'y': false};
switch (this.options.mode){
case 'vertical':
this.axis = 'y';
this.property = 'top';
offset = 'offsetHeight';
break;
case 'horizontal':
this.axis = 'x';
this.property = 'left';
offset = 'offsetWidth';
}
this.full = this.element.measure(function(){
this.half = this.knob[offset] / 2;
return this.element[offset] - this.knob[offset] + (this.options.offset * 2);
}.bind(this));
this.min = $chk(this.options.range[0]) ? this.options.range[0] : 0;
this.max = $chk(this.options.range[1]) ? this.options.range[1] : this.options.steps;
this.range = this.max - this.min;
this.steps = this.options.steps || this.full;
this.stepSize = Math.abs(this.range) / this.steps;
this.stepWidth = this.stepSize * this.full / Math.abs(this.range) ;
this.knob.setStyle('position', 'relative').setStyle(this.property, this.options.initialStep ? this.toPosition(this.options.initialStep) : - this.options.offset);
modifiers[this.axis] = this.property;
limit[this.axis] = [- this.options.offset, this.full - this.options.offset];
var dragOptions = {
snap: 0,
limit: limit,
modifiers: modifiers,
onDrag: this.draggedKnob,
onStart: this.draggedKnob,
onBeforeStart: (function(){
this.isDragging = true;
}).bind(this),
onCancel: function() {
this.isDragging = false;
}.bind(this),
onComplete: function(){
this.isDragging = false;
this.draggedKnob();
this.end();
}.bind(this)
};
if (this.options.snap){
dragOptions.grid = Math.ceil(this.stepWidth);
dragOptions.limit[this.axis][1] = this.full;
}
this.drag = new Drag(this.knob, dragOptions);
this.attach();
},
attach: function(){
this.element.addEvent('mousedown', this.clickedElement);
if (this.options.wheel) this.element.addEvent('mousewheel', this.scrolledElement);
this.drag.attach();
return this;
},
detach: function(){
this.element.removeEvent('mousedown', this.clickedElement);
this.element.removeEvent('mousewheel', this.scrolledElement);
this.drag.detach();
return this;
},
set: function(step){
if (!((this.range > 0) ^ (step < this.min))) step = this.min;
if (!((this.range > 0) ^ (step > this.max))) step = this.max;
this.step = Math.round(step);
this.checkStep();
this.fireEvent('tick', this.toPosition(this.step));
this.end();
return this;
},
clickedElement: function(event){
if (this.isDragging || event.target == this.knob) return;
var dir = this.range < 0 ? -1 : 1;
var position = event.page[this.axis] - this.element.getPosition()[this.axis] - this.half;
position = position.limit(-this.options.offset, this.full -this.options.offset);
this.step = Math.round(this.min + dir * this.toStep(position));
this.checkStep();
this.fireEvent('tick', position);
this.end();
},
scrolledElement: function(event){
var mode = (this.options.mode == 'horizontal') ? (event.wheel < 0) : (event.wheel > 0);
this.set(mode ? this.step - this.stepSize : this.step + this.stepSize);
event.stop();
},
draggedKnob: function(){
var dir = this.range < 0 ? -1 : 1;
var position = this.drag.value.now[this.axis];
position = position.limit(-this.options.offset, this.full -this.options.offset);
this.step = Math.round(this.min + dir * this.toStep(position));
this.checkStep();
},
checkStep: function(){
if (this.previousChange != this.step){
this.previousChange = this.step;
this.fireEvent('change', this.step);
}
},
end: function(){
if (this.previousEnd !== this.step){
this.previousEnd = this.step;
this.fireEvent('complete', this.step + '');
}
},
toStep: function(position){
var step = (position + this.options.offset) * this.stepSize / this.full * this.steps;
return this.options.steps ? Math.round(step -= step % this.stepSize) : step;
},
toPosition: function(step){
return (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset;
}
});
var Sortables = new Class({
Implements: [Events, Options],
options: {/*
onSort: $empty(element, clone),
onStart: $empty(element, clone),
onComplete: $empty(element),*/
snap: 4,
opacity: 1,
clone: false,
revert: false,
handle: false,
constrain: false
},
initialize: function(lists, options){
this.setOptions(options);
this.elements = [];
this.lists = [];
this.idle = true;
this.addLists($$(document.id(lists) || lists));
if (!this.options.clone) this.options.revert = false;
if (this.options.revert) this.effect = new Fx.Morph(null, $merge({duration: 250, link: 'cancel'}, this.options.revert));
},
attach: function(){
this.addLists(this.lists);
return this;
},
detach: function(){
this.lists = this.removeLists(this.lists);
return this;
},
addItems: function(){
Array.flatten(arguments).each(function(element){
this.elements.push(element);
var start = element.retrieve('sortables:start', this.start.bindWithEvent(this, element));
(this.options.handle ? element.getElement(this.options.handle) || element : element).addEvent('mousedown', start);
}, this);
return this;
},
addLists: function(){
Array.flatten(arguments).each(function(list){
this.lists.push(list);
this.addItems(list.getChildren());
}, this);
return this;
},
removeItems: function(){
return $$(Array.flatten(arguments).map(function(element){
this.elements.erase(element);
var start = element.retrieve('sortables:start');
(this.options.handle ? element.getElement(this.options.handle) || element : element).removeEvent('mousedown', start);
return element;
}, this));
},
removeLists: function(){
return $$(Array.flatten(arguments).map(function(list){
this.lists.erase(list);
this.removeItems(list.getChildren());
return list;
}, this));
},
getClone: function(event, element){
if (!this.options.clone) return new Element('div').inject(document.body);
if ($type(this.options.clone) == 'function') return this.options.clone.call(this, event, element, this.list);
return element.clone(true).setStyles({
margin: '0px',
position: 'absolute',
visibility: 'hidden',
'width': element.getStyle('width')
}).inject(this.list).setPosition(element.getPosition(element.getOffsetParent()));
},
getDroppables: function(){
var droppables = this.list.getChildren();
if (!this.options.constrain) droppables = this.lists.concat(droppables).erase(this.list);
return droppables.erase(this.clone).erase(this.element);
},
insert: function(dragging, element){
var where = 'inside';
if (this.lists.contains(element)){
this.list = element;
this.drag.droppables = this.getDroppables();
} else {
where = this.element.getAllPrevious().contains(element) ? 'before' : 'after';
}
this.element.inject(element, where);
this.fireEvent('sort', [this.element, this.clone]);
},
start: function(event, element){
if (!this.idle) return;
this.idle = false;
this.element = element;
this.opacity = element.get('opacity');
this.list = element.getParent();
this.clone = this.getClone(event, element);
this.drag = new Drag.Move(this.clone, {
snap: this.options.snap,
container: this.options.constrain && this.element.getParent(),
droppables: this.getDroppables(),
onSnap: function(){
event.stop();
this.clone.setStyle('visibility', 'visible');
this.element.set('opacity', this.options.opacity || 0);
this.fireEvent('start', [this.element, this.clone]);
}.bind(this),
onEnter: this.insert.bind(this),
onCancel: this.reset.bind(this),
onComplete: this.end.bind(this)
});
this.clone.inject(this.element, 'before');
this.drag.start(event);
},
end: function(){
this.drag.detach();
this.element.set('opacity', this.opacity);
if (this.effect){
var dim = this.element.getStyles('width', 'height');
var pos = this.clone.computePosition(this.element.getPosition(this.clone.offsetParent));
this.effect.element = this.clone;
this.effect.start({
top: pos.top,
left: pos.left,
width: dim.width,
height: dim.height,
opacity: 0.25
}).chain(this.reset.bind(this));
} else {
this.reset();
}
},
reset: function(){
this.idle = true;
this.clone.destroy();
this.fireEvent('complete', this.element);
},
serialize: function(){
var params = Array.link(arguments, {modifier: Function.type, index: $defined});
var serial = this.lists.map(function(list){
return list.getChildren().map(params.modifier || function(element){
return element.get('id');
}, this);
}, this);
var index = params.index;
if (this.lists.length == 1) index = 0;
return $chk(index) && index >= 0 && index < this.lists.length ? serial[index] : serial;
}
});
Request.JSONP = new Class({
Implements: [Chain, Events, Options, Log],
options: {/*
onRetry: $empty(intRetries),
onRequest: $empty(scriptElement),
onComplete: $empty(data),
onSuccess: $empty(data),
onCancel: $empty(),
log: false,
*/
url: '',
data: {},
retries: 0,
timeout: 0,
link: 'ignore',
callbackKey: 'callback',
injectScript: document.head
},
initialize: function(options){
this.setOptions(options);
if (this.options.log) this.enableLog();
this.running = false;
this.requests = 0;
this.triesRemaining = [];
},
check: function(){
if (!this.running) return true;
switch (this.options.link){
case 'cancel': this.cancel(); return true;
case 'chain': this.chain(this.caller.bind(this, arguments)); return false;
}
return false;
},
send: function(options){
if (!$chk(arguments[1]) && !this.check(options)) return this;
var type = $type(options),
old = this.options,
index = $chk(arguments[1]) ? arguments[1] : this.requests++;
if (type == 'string' || type == 'element') options = {data: options};
options = $extend({data: old.data, url: old.url}, options);
if (!$chk(this.triesRemaining[index])) this.triesRemaining[index] = this.options.retries;
var remaining = this.triesRemaining[index];
(function(){
var script = this.getScript(options);
this.log('JSONP retrieving script with url: ' + script.get('src'));
this.fireEvent('request', script);
this.running = true;
(function(){
if (remaining){
this.triesRemaining[index] = remaining - 1;
if (script){
script.destroy();
this.send(options, index).fireEvent('retry', this.triesRemaining[index]);
}
} else if(script && this.options.timeout){
script.destroy();
this.cancel().fireEvent('failure');
}
}).delay(this.options.timeout, this);
}).delay(Browser.Engine.trident ? 50 : 0, this);
return this;
},
cancel: function(){
if (!this.running) return this;
this.running = false;
this.fireEvent('cancel');
return this;
},
getScript: function(options){
var index = Request.JSONP.counter,
data;
Request.JSONP.counter++;
switch ($type(options.data)){
case 'element': data = document.id(options.data).toQueryString(); break;
case 'object': case 'hash': data = Hash.toQueryString(options.data);
}
var src = options.url +
(options.url.test('\\?') ? '&' :'?') +
(options.callbackKey || this.options.callbackKey) +
'=Request.JSONP.request_map.request_'+ index +
(data ? '&' + data : '');
if (src.length > 2083) this.log('JSONP '+ src +' will fail in Internet Explorer, which enforces a 2083 bytes length limit on URIs');
var script = new Element('script', {type: 'text/javascript', src: src});
Request.JSONP.request_map['request_' + index] = function(data){ this.success(data, script); }.bind(this);
return script.inject(this.options.injectScript);
},
success: function(data, script){
if (script) script.destroy();
this.running = false;
this.log('JSONP successfully retrieved: ', data);
this.fireEvent('complete', [data]).fireEvent('success', [data]).callChain();
}
});
Request.JSONP.counter = 0;
Request.JSONP.request_map = {};
Request.Queue = new Class({
Implements: [Options, Events],
Binds: ['attach', 'request', 'complete', 'cancel', 'success', 'failure', 'exception'],
options: {/*
onRequest: $empty(argsPassedToOnRequest),
onSuccess: $empty(argsPassedToOnSuccess),
onComplete: $empty(argsPassedToOnComplete),
onCancel: $empty(argsPassedToOnCancel),
onException: $empty(argsPassedToOnException),
onFailure: $empty(argsPassedToOnFailure),
onEnd: $empty,
*/
stopOnFailure: true,
autoAdvance: true,
concurrent: 1,
requests: {}
},
initialize: function(options){
if(options){
var requests = options.requests;
delete options.requests;
}
this.setOptions(options);
this.requests = new Hash;
this.queue = [];
this.reqBinders = {};
if(requests) this.addRequests(requests);
},
addRequest: function(name, request){
this.requests.set(name, request);
this.attach(name, request);
return this;
},
addRequests: function(obj){
$each(obj, function(req, name){
this.addRequest(name, req);
}, this);
return this;
},
getName: function(req){
return this.requests.keyOf(req);
},
attach: function(name, req){
if (req._groupSend) return this;
['request', 'complete', 'cancel', 'success', 'failure', 'exception'].each(function(evt){
if(!this.reqBinders[name]) this.reqBinders[name] = {};
this.reqBinders[name][evt] = function(){
this['on' + evt.capitalize()].apply(this, [name, req].extend(arguments));
}.bind(this);
req.addEvent(evt, this.reqBinders[name][evt]);
}, this);
req._groupSend = req.send;
req.send = function(options){
this.send(name, options);
return req;
}.bind(this);
return this;
},
removeRequest: function(req){
var name = $type(req) == 'object' ? this.getName(req) : req;
if (!name && $type(name) != 'string') return this;
req = this.requests.get(name);
if (!req) return this;
['request', 'complete', 'cancel', 'success', 'failure', 'exception'].each(function(evt){
req.removeEvent(evt, this.reqBinders[name][evt]);
}, this);
req.send = req._groupSend;
delete req._groupSend;
return this;
},
getRunning: function(){
return this.requests.filter(function(r){
return r.running;
});
},
isRunning: function(){
return !!(this.getRunning().getKeys().length);
},
send: function(name, options){
var q = function(){
this.requests.get(name)._groupSend(options);
this.queue.erase(q);
}.bind(this);
q.name = name;
if (this.getRunning().getKeys().length >= this.options.concurrent || (this.error && this.options.stopOnFailure)) this.queue.push(q);
else q();
return this;
},
hasNext: function(name){
return (!name) ? !!this.queue.length : !!this.queue.filter(function(q){ return q.name == name; }).length;
},
resume: function(){
this.error = false;
(this.options.concurrent - this.getRunning().getKeys().length).times(this.runNext, this);
return this;
},
runNext: function(name){
if (!this.queue.length) return this;
if (!name){
this.queue[0]();
} else {
var found;
this.queue.each(function(q){
if (!found && q.name == name){
found = true;
q();
}
});
}
return this;
},
runAll: function() {
this.queue.each(function(q) {
q();
});
return this;
},
clear: function(name){
if (!name){
this.queue.empty();
} else {
this.queue = this.queue.map(function(q){
if (q.name != name) return q;
else return false;
}).filter(function(q){ return q; });
}
return this;
},
cancel: function(name){
this.requests.get(name).cancel();
return this;
},
onRequest: function(){
this.fireEvent('request', arguments);
},
onComplete: function(){
this.fireEvent('complete', arguments);
if (!this.queue.length) this.fireEvent('end');
},
onCancel: function(){
if (this.options.autoAdvance && !this.error) this.runNext();
this.fireEvent('cancel', arguments);
},
onSuccess: function(){
if (this.options.autoAdvance && !this.error) this.runNext();
this.fireEvent('success', arguments);
},
onFailure: function(){
this.error = true;
if (!this.options.stopOnFailure && this.options.autoAdvance) this.runNext();
this.fireEvent('failure', arguments);
},
onException: function(){
this.error = true;
if (!this.options.stopOnFailure && this.options.autoAdvance) this.runNext();
this.fireEvent('exception', arguments);
}
});
Request.implement({
options: {
initialDelay: 5000,
delay: 5000,
limit: 60000
},
startTimer: function(data){
var fn = function(){
if (!this.running) this.send({data: data});
};
this.timer = fn.delay(this.options.initialDelay, this);
this.lastDelay = this.options.initialDelay;
this.completeCheck = function(response){
$clear(this.timer);
this.lastDelay = (response) ? this.options.delay : (this.lastDelay + this.options.delay).min(this.options.limit);
this.timer = fn.delay(this.lastDelay, this);
};
return this.addEvent('complete', this.completeCheck);
},
stopTimer: function(){
$clear(this.timer);
return this.removeEvent('complete', this.completeCheck);
}
});
var Asset = {
javascript: function(source, properties){
properties = $extend({
onload: $empty,
document: document,
check: $lambda(true)
}, properties);
var script = new Element('script', {src: source, type: 'text/javascript'});
var load = properties.onload.bind(script),
check = properties.check,
doc = properties.document;
delete properties.onload;
delete properties.check;
delete properties.document;
script.addEvents({
load: load,
readystatechange: function(){
if (['loaded', 'complete'].contains(this.readyState)) load();
}
}).set(properties);
if (Browser.Engine.webkit419) var checker = (function(){
if (!$try(check)) return;
$clear(checker);
load();
}).periodical(50);
return script.inject(doc.head);
},
css: function(source, properties){
return new Element('link', $merge({
rel: 'stylesheet',
media: 'screen',
type: 'text/css',
href: source
}, properties)).inject(document.head);
},
image: function(source, properties){
properties = $merge({
onload: $empty,
onabort: $empty,
onerror: $empty
}, properties);
var image = new Image();
var element = document.id(image) || new Element('img');
['load', 'abort', 'error'].each(function(name){
var type = 'on' + name;
var event = properties[type];
delete properties[type];
image[type] = function(){
if (!image) return;
if (!element.parentNode){
element.width = image.width;
element.height = image.height;
}
image = image.onload = image.onabort = image.onerror = null;
event.delay(1, element, element);
element.fireEvent(name, element, 1);
};
});
image.src = element.src = source;
if (image && image.complete) image.onload.delay(1);
return element.set(properties);
},
images: function(sources, options){
options = $merge({
onComplete: $empty,
onProgress: $empty,
onError: $empty,
properties: {}
}, options);
sources = $splat(sources);
var images = [];
var counter = 0;
return new Elements(sources.map(function(source){
return Asset.image(source, $extend(options.properties, {
onload: function(){
options.onProgress.call(this, counter, sources.indexOf(source));
counter++;
if (counter == sources.length) options.onComplete();
},
onerror: function(){
options.onError.call(this, counter, sources.indexOf(source));
counter++;
if (counter == sources.length) options.onComplete();
}
}));
}));
}
};
var Color = new Native({
initialize: function(color, type){
if (arguments.length >= 3){
type = 'rgb'; color = Array.slice(arguments, 0, 3);
} else if (typeof color == 'string'){
if (color.match(/rgb/)) color = color.rgbToHex().hexToRgb(true);
else if (color.match(/hsb/)) color = color.hsbToRgb();
else color = color.hexToRgb(true);
}
type = type || 'rgb';
switch (type){
case 'hsb':
var old = color;
color = color.hsbToRgb();
color.hsb = old;
break;
case 'hex': color = color.hexToRgb(true); break;
}
color.rgb = color.slice(0, 3);
color.hsb = color.hsb || color.rgbToHsb();
color.hex = color.rgbToHex();
return $extend(color, this);
}
});
Color.implement({
mix: function(){
var colors = Array.slice(arguments);
var alpha = ($type(colors.getLast()) == 'number') ? colors.pop() : 50;
var rgb = this.slice();
colors.each(function(color){
color = new Color(color);
for (var i = 0; i < 3; i++) rgb[i] = Math.round((rgb[i] / 100 * (100 - alpha)) + (color[i] / 100 * alpha));
});
return new Color(rgb, 'rgb');
},
invert: function(){
return new Color(this.map(function(value){
return 255 - value;
}));
},
setHue: function(value){
return new Color([value, this.hsb[1], this.hsb[2]], 'hsb');
},
setSaturation: function(percent){
return new Color([this.hsb[0], percent, this.hsb[2]], 'hsb');
},
setBrightness: function(percent){
return new Color([this.hsb[0], this.hsb[1], percent], 'hsb');
}
});
var $RGB = function(r, g, b){
return new Color([r, g, b], 'rgb');
};
var $HSB = function(h, s, b){
return new Color([h, s, b], 'hsb');
};
var $HEX = function(hex){
return new Color(hex, 'hex');
};
Array.implement({
rgbToHsb: function(){
var red = this[0],
green = this[1],
blue = this[2],
hue = 0;
var max = Math.max(red, green, blue),
min = Math.min(red, green, blue);
var delta = max - min;
var brightness = max / 255,
saturation = (max != 0) ? delta / max : 0;
if(saturation != 0) {
var rr = (max - red) / delta;
var gr = (max - green) / delta;
var br = (max - blue) / delta;
if (red == max) hue = br - gr;
else if (green == max) hue = 2 + rr - br;
else hue = 4 + gr - rr;
hue /= 6;
if (hue < 0) hue++;
}
return [Math.round(hue * 360), Math.round(saturation * 100), Math.round(brightness * 100)];
},
hsbToRgb: function(){
var br = Math.round(this[2] / 100 * 255);
if (this[1] == 0){
return [br, br, br];
} else {
var hue = this[0] % 360;
var f = hue % 60;
var p = Math.round((this[2] * (100 - this[1])) / 10000 * 255);
var q = Math.round((this[2] * (6000 - this[1] * f)) / 600000 * 255);
var t = Math.round((this[2] * (6000 - this[1] * (60 - f))) / 600000 * 255);
switch (Math.floor(hue / 60)){
case 0: return [br, t, p];
case 1: return [q, br, p];
case 2: return [p, br, t];
case 3: return [p, q, br];
case 4: return [t, p, br];
case 5: return [br, p, q];
}
}
return false;
}
});
String.implement({
rgbToHsb: function(){
var rgb = this.match(/\d{1,3}/g);
return (rgb) ? rgb.rgbToHsb() : null;
},
hsbToRgb: function(){
var hsb = this.match(/\d{1,3}/g);
return (hsb) ? hsb.hsbToRgb() : null;
}
});
var Group = new Class({
initialize: function(){
this.instances = Array.flatten(arguments);
this.events = {};
this.checker = {};
},
addEvent: function(type, fn){
this.checker[type] = this.checker[type] || {};
this.events[type] = this.events[type] || [];
if (this.events[type].contains(fn)) return false;
else this.events[type].push(fn);
this.instances.each(function(instance, i){
instance.addEvent(type, this.check.bind(this, [type, instance, i]));
}, this);
return this;
},
check: function(type, instance, i){
this.checker[type][i] = true;
var every = this.instances.every(function(current, j){
return this.checker[type][j] || false;
}, this);
if (!every) return;
this.checker[type] = {};
this.events[type].each(function(event){
event.call(this, this.instances, instance);
}, this);
}
});
Hash.Cookie = new Class({
Extends: Cookie,
options: {
autoSave: true
},
initialize: function(name, options){
this.parent(name, options);
this.load();
},
save: function(){
var value = JSON.encode(this.hash);
if (!value || value.length > 4096) return false; //cookie would be truncated!
if (value == '{}') this.dispose();
else this.write(value);
return true;
},
load: function(){
this.hash = new Hash(JSON.decode(this.read(), true));
return this;
}
});
Hash.each(Hash.prototype, function(method, name){
if (typeof method == 'function') Hash.Cookie.implement(name, function(){
var value = method.apply(this.hash, arguments);
if (this.options.autoSave) this.save();
return value;
});
});
var IframeShim = new Class({
Implements: [Options, Events, Class.Occlude],
options: {
className: 'iframeShim',
src: 'javascript:false;document.write("");',
display: false,
zIndex: null,
margin: 0,
offset: {x: 0, y: 0},
browsers: (Browser.Engine.trident4 || (Browser.Engine.gecko && !Browser.Engine.gecko19 && Browser.Platform.mac))
},
property: 'IframeShim',
initialize: function(element, options){
this.element = document.id(element);
if (this.occlude()) return this.occluded;
this.setOptions(options);
this.makeShim();
return this;
},
makeShim: function(){
if(this.options.browsers){
var zIndex = this.element.getStyle('zIndex').toInt();
if (!zIndex){
zIndex = 1;
var pos = this.element.getStyle('position');
if (pos == 'static' || !pos) this.element.setStyle('position', 'relative');
this.element.setStyle('zIndex', zIndex);
}
zIndex = ($chk(this.options.zIndex) && zIndex > this.options.zIndex) ? this.options.zIndex : zIndex - 1;
if (zIndex < 0) zIndex = 1;
this.shim = new Element('iframe', {
src: this.options.src,
scrolling: 'no',
frameborder: 0,
styles: {
zIndex: zIndex,
position: 'absolute',
border: 'none',
filter: 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
},
'class': this.options.className
}).store('IframeShim', this);
var inject = (function(){
this.shim.inject(this.element, 'after');
this[this.options.display ? 'show' : 'hide']();
this.fireEvent('inject');
}).bind(this);
if (IframeShim.ready) window.addEvent('load', inject);
else inject();
} else {
this.position = this.hide = this.show = this.dispose = $lambda(this);
}
},
position: function(){
if (!IframeShim.ready || !this.shim) return this;
var size = this.element.measure(function(){
return this.getSize();
});
if (this.options.margin != undefined){
size.x = size.x - (this.options.margin * 2);
size.y = size.y - (this.options.margin * 2);
this.options.offset.x += this.options.margin;
this.options.offset.y += this.options.margin;
}
this.shim.set({width: size.x, height: size.y}).position({
relativeTo: this.element,
offset: this.options.offset
});
return this;
},
hide: function(){
if (this.shim) this.shim.setStyle('display', 'none');
return this;
},
show: function(){
if (this.shim) this.shim.setStyle('display', 'block');
return this.position();
},
dispose: function(){
if (this.shim) this.shim.dispose();
return this;
},
destroy: function(){
if (this.shim) this.shim.destroy();
return this;
}
});
window.addEvent('load', function(){
IframeShim.ready = true;
});
var HtmlTable = new Class({
Implements: [Options, Events, Class.Occlude],
options: {
properties: {
cellpadding: 0,
cellspacing: 0,
border: 0
},
rows: [],
headers: [],
footers: []
},
property: 'HtmlTable',
initialize: function(){
var params = Array.link(arguments, {options: Object.type, table: Element.type});
this.setOptions(params.options);
this.element = params.table || new Element('table', this.options.properties);
if (this.occlude()) return this.occluded;
this.build();
},
build: function(){
this.element.store('HtmlTable', this);
this.body = document.id(this.element.tBodies[0]) || new Element('tbody').inject(this.element);
$$(this.body.rows);
if (this.options.headers.length) this.setHeaders(this.options.headers);
else this.thead = document.id(this.element.tHead);
if (this.thead) this.head = document.id(this.thead.rows[0]);
if (this.options.footers.length) this.setFooters(this.options.footers);
this.tfoot = document.id(this.element.tFoot);
if (this.tfoot) this.foot = document.id(this.thead.rows[0]);
this.options.rows.each(function(row){
this.push(row);
}, this);
['adopt', 'inject', 'wraps', 'grab', 'replaces', 'dispose'].each(function(method){
this[method] = this.element[method].bind(this.element);
}, this);
},
toElement: function(){
return this.element;
},
empty: function(){
this.body.empty();
return this;
},
setHeaders: function(headers){
this.thead = (document.id(this.element.tHead) || new Element('thead').inject(this.element, 'top')).empty();
this.push(headers, this.thead, 'th');
this.head = document.id(this.thead.rows[0]);
return this;
},
setFooters: function(footers){
this.tfoot = (document.id(this.element.tFoot) || new Element('tfoot').inject(this.element, 'top')).empty();
this.push(footers, this.tfoot);
this.foot = document.id(this.thead.rows[0]);
return this;
},
push: function(row, target, tag){
var tds = row.map(function(data){
var td = new Element(tag || 'td', data.properties),
type = data.content || data || '',
element = document.id(type);
if(element) td.adopt(element);
else td.set('html', type);
return td;
});
return {
tr: new Element('tr').inject(target || this.body).adopt(tds),
tds: tds
};
}
});
HtmlTable = Class.refactor(HtmlTable, {
options: {
classZebra: 'table-tr-odd',
zebra: true
},
initialize: function(){
this.previous.apply(this, arguments);
if (this.occluded) return this.occluded;
if (this.options.zebra) this.updateZebras();
},
updateZebras: function(){
Array.each(this.body.rows, this.zebra, this);
},
zebra: function(row, i){
return row[((i % 2) ? 'remove' : 'add')+'Class'](this.options.classZebra);
},
push: function(){
var pushed = this.previous.apply(this, arguments);
if (this.options.zebra) this.updateZebras();
return pushed;
}
});
HtmlTable = Class.refactor(HtmlTable, {
options: {/*
onSort: $empty, */
sortIndex: 0,
sortReverse: false,
parsers: [],
defaultParser: 'string',
classSortable: 'table-sortable',
classHeadSort: 'table-th-sort',
classHeadSortRev: 'table-th-sort-rev',
classNoSort: 'table-th-nosort',
classGroupHead: 'table-tr-group-head',
classGroup: 'table-tr-group',
classCellSort: 'table-td-sort',
classSortSpan: 'table-th-sort-span',
sortable: false
},
initialize: function () {
this.previous.apply(this, arguments);
if (this.occluded) return this.occluded;
this.sorted = {index: null, dir: 1};
this.bound = {
headClick: this.headClick.bind(this)
};
this.sortSpans = new Elements();
if (this.options.sortable) {
this.enableSort();
if (this.options.sortIndex != null) this.sort(this.options.sortIndex, this.options.sortReverse);
}
},
attachSorts: function(attach){
this.element[$pick(attach, true) ? 'addEvent' : 'removeEvent']('click:relay(th)', this.bound.headClick);
},
setHeaders: function(){
this.previous.apply(this, arguments);
if (this.sortEnabled) this.detectParsers();
},
detectParsers: function(force){
if (!this.head) return;
var parsers = this.options.parsers,
rows = this.body.rows;
this.parsers = $$(this.head.cells).map(function(cell, index) {
if (!force && (cell.hasClass(this.options.classNoSort) || cell.retrieve('htmltable-sort'))) return cell.retrieve('htmltable-sort');
var sortSpan = new Element('span', {'html': '&#160;', 'class': this.options.classSortSpan}).inject(cell, 'top');
this.sortSpans.push(sortSpan);
var parser = parsers[index],
cancel;
switch ($type(parser)) {
case 'function': parser = {convert: parser}; cancel = true; break;
case 'string': parser = parser; cancel = true; break;
}
if (!cancel) {
HtmlTable.Parsers.some(function(current) {
var match = current.match;
if (!match) return false;
if (Browser.Engine.trident) return false;
for (var i = 0, j = rows.length; i < j; i++) {
var text = rows[i].cells[index].get('html').clean();
if (text && match.test(text)) {
parser = current;
return true;
}
}
});
}
if (!parser) parser = this.options.defaultParser;
cell.store('htmltable-parser', parser);
return parser;
}, this);
},
headClick: function(event, el) {
if (!this.head) return;
var index = Array.indexOf(this.head.cells, el);
this.sort(index);
return false;
},
sort: function(index, reverse, pre) {
if (!this.head) return;
pre = !!(pre);
var classCellSort = this.options.classCellSort;
var classGroup = this.options.classGroup,
classGroupHead = this.options.classGroupHead;
if (!pre) {
if (index != null) {
if (this.sorted.index == index) {
this.sorted.reverse = !(this.sorted.reverse);
} else {
if (this.sorted.index != null) {
this.sorted.reverse = false;
this.head.cells[this.sorted.index].removeClass(this.options.classHeadSort).removeClass(this.options.classHeadSortRev);
} else {
this.sorted.reverse = true;
}
this.sorted.index = index;
}
} else {
index = this.sorted.index;
}
if (reverse != null) this.sorted.reverse = reverse;
var head = document.id(this.head.cells[index]);
if (head) {
head.addClass(this.options.classHeadSort);
if (this.sorted.reverse) head.addClass(this.options.classHeadSortRev);
else head.removeClass(this.options.classHeadSortRev);
}
this.body.getElements('td').removeClass(this.options.classCellSort);
}
var parser = this.parsers[index];
if ($type(parser) == 'string') parser = HtmlTable.Parsers.get(parser);
if (!parser) return;
if (!Browser.Engine.trident) {
var rel = this.body.getParent();
this.body.dispose();
}
var data = Array.map(this.body.rows, function(row, i) {
var value = parser.convert.call(document.id(row.cells[index]));
return {
position: i,
value: value,
toString:  function() {
return value.toString();
}
};
}, this);
data.reverse(true);
data.sort(function(a, b){
if (a.value === b.value) return 0;
return a.value > b.value ? 1 : -1;
});
if (!this.sorted.reverse) data.reverse(true);
var i = data.length, body = this.body;
var j, position, entry, group;
while (i) {
var item = data[--i];
position = item.position;
var row = body.rows[position];
if (row.disabled) continue;
if (!pre) {
if (group === item.value) {
row.removeClass(classGroupHead).addClass(classGroup);
} else {
group = item.value;
row.removeClass(classGroup).addClass(classGroupHead);
}
if (this.zebra) this.zebra(row, i);
row.cells[index].addClass(classCellSort);
}
body.appendChild(row);
for (j = 0; j < i; j++) {
if (data[j].position > position) data[j].position--;
}
};
data = null;
if (rel) rel.grab(body);
return this.fireEvent('sort', [body, index]);
},
reSort: function(){
if (this.sortEnabled) this.sort.call(this, this.sorted.index, this.sorted.reverse);
return this;
},
enableSort: function(){
this.element.addClass(this.options.classSortable);
this.attachSorts(true);
this.detectParsers();
this.sortEnabled = true;
return this;
},
disableSort: function(){
this.element.remove(this.options.classSortable);
this.attachSorts(false);
this.sortSpans.each(function(span) { span.destroy(); });
this.sortSpans.empty();
this.sortEnabled = false;
return this;
}
});
HtmlTable.Parsers = new Hash({
'date': {
match: /^\d{2}[-\/ ]\d{2}[-\/ ]\d{2,4}$/,
convert: function() {
return Date.parse(this.get('text').format('db'));
},
type: 'date'
},
'input-checked': {
match: / type="(radio|checkbox)" /,
convert: function() {
return this.getElement('input').checked;
}
},
'input-value': {
match: /<input/,
convert: function() {
return this.getElement('input').value;
}
},
'number': {
match: /^\d+[^\d.,]*$/,
convert: function() {
return this.get('text').toInt();
},
number: true
},
'numberLax': {
match: /^[^\d]+\d+$/,
convert: function() {
return this.get('text').replace(/[^-?^0-9]/, '').toInt();
},
number: true
},
'float': {
match: /^[\d]+\.[\d]+/,
convert: function() {
return this.get('text').replace(/[^-?^\d.]/, '').toFloat();
},
number: true
},
'floatLax': {
match: /^[^\d]+[\d]+\.[\d]+$/,
convert: function() {
return this.get('text').replace(/[^-?^\d.]/, '');
},
number: true
},
'string': {
match: null,
convert: function() {
return this.get('text');
}
},
'title': {
match: null,
convert: function() {
return this.title;
}
}
});
HtmlTable = Class.refactor(HtmlTable, {
options: {
useKeyboard: true,
classRowSelected: 'table-tr-selected',
classRowHovered: 'table-tr-hovered',
classSelectable: 'table-selectable',
allowMultiSelect: true,
selectable: false
},
initialize: function(){
this.previous.apply(this, arguments);
if (this.occluded) return this.occluded;
this.selectedRows = new Elements();
this.bound = {
mouseleave: this.mouseleave.bind(this),
focusRow: this.focusRow.bind(this)
};
if (this.options.selectable) this.enableSelect();
},
enableSelect: function(){
this.selectEnabled = true;
this.attachSelects();
this.element.addClass(this.options.classSelectable);
},
disableSelect: function(){
this.selectEnabled = false;
this.attach(false);
this.element.removeClass(this.options.classSelectable);
},
attachSelects: function(attach){
attach = $pick(attach, true);
var method = attach ? 'addEvents' : 'removeEvents';
this.element[method]({
mouseleave: this.bound.mouseleave
});
this.body[method]({
'click:relay(tr)': this.bound.focusRow
});
if (this.options.useKeyboard || this.keyboard){
if (!this.keyboard) this.keyboard = new Keyboard({
events: {
down: function(e) {
e.preventDefault();
this.shiftFocus(1);
}.bind(this),
up: function(e) {
e.preventDefault();
this.shiftFocus(-1);
}.bind(this),
enter: function(e) {
e.preventDefault();
if (this.hover) this.focusRow(this.hover);
}.bind(this)
},
active: true
});
this.keyboard[attach ? 'activate' : 'deactivate']();
}
this.updateSelects();
},
mouseleave: function(){
if (this.hover) this.leaveRow(this.hover);
},
focus: function(){
if (this.keyboard) this.keyboard.activate();
},
blur: function(){
if (this.keyboard) this.keyboard.deactivate();
},
push: function(){
var ret = this.previous.apply(this, arguments);
this.updateSelects();
return ret;
},
updateSelects: function(){
Array.each(this.body.rows, function(row){
var binders = row.retrieve('binders');
if ((binders && this.selectEnabled) || (!binders && !this.selectEnabled)) return;
if (!binders){
binders = {
mouseenter: this.enterRow.bind(this, [row]),
mouseleave: this.leaveRow.bind(this, [row])
};
row.store('binders', binders).addEvents(binders);
} else {
row.removeEvents(binders);
}
}, this);
},
enterRow: function(row){
if (this.hover) this.hover = this.leaveRow(this.hover);
this.hover = row.addClass(this.options.classRowHovered);
},
shiftFocus: function(offset){
if (!this.hover) return this.enterRow(this.body.rows[0]);
var to = Array.indexOf(this.body.rows, this.hover) + offset;
if (to < 0) to = 0;
if (to >= this.body.rows.length) to = this.body.rows.length - 1;
if (this.hover == this.body.rows[to]) return this;
this.enterRow(this.body.rows[to]);
},
leaveRow: function(row){
row.removeClass(this.options.classRowHovered);
},
focusRow: function(){
var row = arguments[1] || arguments[0]; //delegation passes the event first
if (!this.body.getChildren().contains(row)) return;
var unfocus = function(row){
this.selectedRows.erase(row);
row.removeClass(this.options.classRowSelected);
this.fireEvent('rowUnfocus', [row, this.selectedRows]);
}.bind(this);
if (!this.options.allowMultiSelect) this.selectedRows.each(unfocus);
if (!this.selectedRows.contains(row)) {
this.selectedRows.push(row);
row.addClass(this.options.classRowSelected);
this.fireEvent('rowFocus', [row, this.selectedRows]);
} else {
unfocus(row);
}
return false;
},
selectAll: function(status){
status = $pick(status, true);
if (!this.options.allowMultiSelect && status) return;
if (!status) this.selectedRows.removeClass(this.options.classRowSelected).empty();
else this.selectedRows.combine(this.body.rows).addClass(this.options.classRowSelected);
return this;
},
selectNone: function(){
return this.selectAll(false);
}
});
(function(){
var parsed = {};
var modifiers = ['shift', 'control', 'alt', 'meta'];
var regex = /^(?:shift|control|ctrl|alt|meta)$/;
var parse = function(type, eventType){
type = type.toLowerCase().replace(/^(keyup|keydown):/, function($0, $1){
eventType = $1;
return '';
});
if (!parsed[type]){
var key = '', mods = {};
type.split('+').each(function(part){
if (regex.test(part)) mods[part] = true;
else key = part;
});
mods.control = mods.control || mods.ctrl; // allow both control and ctrl
var match = '';
modifiers.each(function(mod){
if (mods[mod]) match += mod + '+';
});
parsed[type] = match + key;
}
return eventType + ':' + parsed[type];
};
this.Keyboard = new Class({
Extends: Events,
Implements: [Options, Log],
options: {
defaultEventType: 'keydown',
active: false,
events: {}
},
initialize: function(options){
this.setOptions(options);
if (Keyboard.manager) Keyboard.manager.manage(this);
this.setup();
},
setup: function(){
this.addEvents(this.options.events);
if (this.options.active) this.activate();
},
handle: function(event, type){
if (!this.active || event.preventKeyboardPropagation) return;
var bubbles = !!this.manager;
if (bubbles && this.activeKB){
this.activeKB.handle(event, type);
if (event.preventKeyboardPropagation) return;
}
this.fireEvent(type, event);
if (!bubbles && this.activeKB) this.activeKB.handle(event, type);
},
addEvent: function(type, fn, internal) {
return this.parent(parse(type, this.options.defaultEventType), fn, internal);
},
removeEvent: function(type, fn) {
return this.parent(parse(type, this.options.defaultEventType), fn);
},
activate: function(){
this.active = true;
return this.enable();
},
deactivate: function(){
this.active = false;
return this.fireEvent('deactivate');
},
toggleActive: function(){
return this[this.active ? 'deactivate' : 'activate']();
},
enable: function(instance){
if (instance) {
if (instance != this.activeKB) this.previous = this.activeKB;
this.activeKB = instance.fireEvent('activate');
} else if (this.manager) {
this.manager.enable(this);
}
return this;
},
relenquish: function(){
if (this.previous) this.enable(this.previous);
},
manage: function(instance) {
if (instance.manager) instance.manager.drop(instance);
this.instances.push(instance);
instance.manager = this;
if (!this.activeKB) this.enable(instance);
else this._disable(instance);
},
_disable: function(instance) {
if (this.activeKB == instance) this.activeKB = null;
},
drop: function(instance) {
this._disable(instance);
this.instances.erase(instance);
},
instances: [],
trace: function(){
this.enableLog();
var item = this;
this.log('the following items have focus: ');
while (item) {
this.log(document.id(item.widget) || item.widget || item, 'active: ' + this.active);
item = item.activeKB;
}
}
});
Keyboard.stop = function(event) {
event.preventKeyboardPropagation = true;
};
Keyboard.manager = new this.Keyboard({
active: true
});
Keyboard.trace = function(){
Keyboard.manager.trace();
};
var handler = function(event){
var mods = '';
modifiers.each(function(mod){
if (event[mod]) mods += mod + '+';
});
Keyboard.manager.handle(event, event.type + ':' + mods + event.key);
};
document.addEvents({
'keyup': handler,
'keydown': handler
});
Event.Keys.extend({
'pageup': 33,
'pagedown': 34,
'end': 35,
'home': 36,
'capslock': 20,
'numlock': 144,
'scrolllock': 145
});
})();
var Mask = new Class({
Implements: [Options, Events],
Binds: ['resize'],
options: {
style: {},
'class': 'mask',
maskMargins: false,
useIframeShim: true
},
initialize: function(target, options){
this.target = document.id(target) || document.body;
this.target.store('mask', this);
this.setOptions(options);
this.render();
this.inject();
},
render: function() {
this.element = new Element('div', {
'class': this.options['class'],
id: this.options.id || 'mask-' + $time(),
styles: $merge(this.options.style, {
display: 'none'
}),
events: {
click: function(){
this.fireEvent('click');
if (this.options.hideOnClick) this.hide();
}.bind(this)
}
});
this.hidden = true;
},
toElement: function(){
return this.element;
},
inject: function(target, where){
where = where || this.options.inject ? this.options.inject.where : '' || this.target == document.body ? 'inside' : 'after';
target = target || this.options.inject ? this.options.inject.target : '' || this.target;
this.element.inject(target, where);
if (this.options.useIframeShim) {
this.shim = new IframeShim(this.element);
this.addEvents({
show: this.shim.show.bind(this.shim),
hide: this.shim.hide.bind(this.shim),
destroy: this.shim.destroy.bind(this.shim)
});
}
},
position: function(){
this.resize(this.options.width, this.options.height);
this.element.position({
relativeTo: this.target,
position: 'topLeft',
ignoreMargins: !this.options.maskMargins,
ignoreScroll: this.target == document.body
});
return this;
},
resize: function(x, y){
var opt = {
styles: ['padding', 'border']
};
if (this.options.maskMargins) opt.styles.push('margin');
var dim = this.target.getComputedSize(opt);
if (this.target == document.body) {
var win = window.getSize();
if (dim.totalHeight < win.y) dim.totalHeight = win.y;
if (dim.totalWidth < win.x) dim.totalWidth = win.x;
}
this.element.setStyles({
width: $pick(x, dim.totalWidth, dim.x),
height: $pick(y, dim.totalHeight, dim.y)
});
return this;
},
show: function(){
if (!this.hidden) return this;
this.target.addEvent('resize', this.resize);
if (this.target != document.body) document.id(document.body).addEvent('resize', this.resize);
this.position();
this.showMask.apply(this, arguments);
return this;
},
showMask: function(){
this.element.setStyle('display', 'block');
this.hidden = false;
this.fireEvent('show');
},
hide: function(){
if (this.hidden) return this;
this.target.removeEvent('resize', this.resize);
this.hideMask.apply(this, arguments);
if (this.options.destroyOnHide) return this.destroy();
return this;
},
hideMask: function(){
this.element.setStyle('display', 'none');
this.hidden = true;
this.fireEvent('hide');
},
toggle: function(){
this[this.hidden ? 'show' : 'hide']();
},
destroy: function(){
this.hide();
this.element.destroy();
this.fireEvent('destroy');
this.target.eliminate('mask');
}
});
Element.Properties.mask = {
set: function(options){
var mask = this.retrieve('mask');
return this.eliminate('mask').store('mask:options', options);
},
get: function(options){
if (options || !this.retrieve('mask')){
if (this.retrieve('mask')) this.retrieve('mask').destroy();
if (options || !this.retrieve('mask:options')) this.set('mask', options);
this.store('mask', new Mask(this, this.retrieve('mask:options')));
}
return this.retrieve('mask');
}
};
Element.implement({
mask: function(options){
this.get('mask', options).show();
return this;
},
unmask: function(){
this.get('mask').hide();
return this;
}
});
var Scroller = new Class({
Implements: [Events, Options],
options: {
area: 20,
velocity: 1,
onChange: function(x, y){
this.element.scrollTo(x, y);
},
fps: 50
},
initialize: function(element, options){
this.setOptions(options);
this.element = document.id(element);
this.listener = ($type(this.element) != 'element') ? document.id(this.element.getDocument().body) : this.element;
this.timer = null;
this.bound = {
attach: this.attach.bind(this),
detach: this.detach.bind(this),
getCoords: this.getCoords.bind(this)
};
},
start: function(){
this.listener.addEvents({
mouseover: this.bound.attach,
mouseout: this.bound.detach
});
},
stop: function(){
this.listener.removeEvents({
mouseover: this.bound.attach,
mouseout: this.bound.detach
});
this.detach();
this.timer = $clear(this.timer);
},
attach: function(){
this.listener.addEvent('mousemove', this.bound.getCoords);
},
detach: function(){
this.listener.removeEvent('mousemove', this.bound.getCoords);
this.timer = $clear(this.timer);
},
getCoords: function(event){
this.page = (this.listener.get('tag') == 'body') ? event.client : event.page;
if (!this.timer) this.timer = this.scroll.periodical(Math.round(1000 / this.options.fps), this);
},
scroll: function(){
var size = this.element.getSize(),
scroll = this.element.getScroll(),
pos = this.element.getOffsets(),
scrollSize = this.element.getScrollSize(),
change = {x: 0, y: 0};
for (var z in this.page){
if (this.page[z] < (this.options.area + pos[z]) && scroll[z] != 0)
change[z] = (this.page[z] - this.options.area - pos[z]) * this.options.velocity;
else if (this.page[z] + this.options.area > (size[z] + pos[z]) && scroll[z] + size[z] != scrollSize[z])
change[z] = (this.page[z] - size[z] + this.options.area - pos[z]) * this.options.velocity;
}
if (change.y || change.x) this.fireEvent('change', [scroll.x + change.x, scroll.y + change.y]);
}
});
(function(){
var read = function(option, element){
return (option) ? ($type(option) == 'function' ? option(element) : element.get(option)) : '';
};
this.Tips = new Class({
Implements: [Events, Options],
options: {
onShow: function(){
this.tip.setStyle('display', 'block');
},
onHide: function(){
this.tip.setStyle('display', 'none');
},
title: 'title',
text: function(element){
return element.get('rel') || element.get('href');
},
showDelay: 100,
hideDelay: 100,
className: 'tip-wrap',
offset: {x: 16, y: 16},
fixed: false
},
initialize: function(){
var params = Array.link(arguments, {options: Object.type, elements: $defined});
this.setOptions(params.options);
document.id(this);
if (params.elements) this.attach(params.elements);
},
toElement: function(){
if (this.tip) return this.tip;
this.container = new Element('div', {'class': 'tip'});
return this.tip = new Element('div', {
'class': this.options.className,
styles: {
position: 'absolute',
top: 0,
left: 0
}
}).adopt(
new Element('div', {'class': 'tip-top'}),
this.container,
new Element('div', {'class': 'tip-bottom'})
).inject(document.body);
},
attach: function(elements){
$$(elements).each(function(element){
var title = read(this.options.title, element),
text = read(this.options.text, element);
element.erase('title').store('tip:native', title).retrieve('tip:title', title);
element.retrieve('tip:text', text);
this.fireEvent('attach', [element]);
var events = ['enter', 'leave'];
if (!this.options.fixed) events.push('move');
events.each(function(value){
var event = element.retrieve('tip:' + value);
if (!event) event = this['element' + value.capitalize()].bindWithEvent(this, element);
element.store('tip:' + value, event).addEvent('mouse' + value, event);
}, this);
}, this);
return this;
},
detach: function(elements){
$$(elements).each(function(element){
['enter', 'leave', 'move'].each(function(value){
element.removeEvent('mouse' + value, element.retrieve('tip:' + value)).eliminate('tip:' + value);
});
this.fireEvent('detach', [element]);
if (this.options.title == 'title'){ // This is necessary to check if we can revert the title
var original = element.retrieve('tip:native');
if (original) element.set('title', original);
}
}, this);
return this;
},
elementEnter: function(event, element){
this.container.empty();
['title', 'text'].each(function(value){
var content = element.retrieve('tip:' + value);
if (content) this.fill(new Element('div', {'class': 'tip-' + value}).inject(this.container), content);
}, this);
$clear(this.timer);
this.timer = this.show.delay(this.options.showDelay, this, element);
this.position((this.options.fixed) ? {page: element.getPosition()} : event);
},
elementLeave: function(event, element){
$clear(this.timer);
this.timer = this.hide.delay(this.options.hideDelay, this, element);
this.fireForParent(event, element);
},
fireForParent: function(event, element){
if (!element) return;
parentNode = element.getParent();
if (parentNode == document.body) return;
if (parentNode.retrieve('tip:enter')) parentNode.fireEvent('mouseenter', event);
else this.fireForParent(parentNode, event);
},
elementMove: function(event, element){
this.position(event);
},
position: function(event){
var size = window.getSize(), scroll = window.getScroll(),
tip = {x: this.tip.offsetWidth, y: this.tip.offsetHeight},
props = {x: 'left', y: 'top'},
obj = {};
for (var z in props){
obj[props[z]] = event.page[z] + this.options.offset[z];
if ((obj[props[z]] + tip[z] - scroll[z]) > size[z]) obj[props[z]] = event.page[z] - this.options.offset[z] - tip[z];
}
this.tip.setStyles(obj);
},
fill: function(element, contents){
if(typeof contents == 'string') element.set('html', contents);
else element.adopt(contents);
},
show: function(element){
this.fireEvent('show', [this.tip, element]);
},
hide: function(element){
this.fireEvent('hide', [this.tip, element]);
}
});
})();
var Spinner = new Class({
Extends: Mask,
options: {
'class':'spinner',
containerPosition: {},
content: {
'class':'spinner-content'
},
messageContainer: {
'class':'spinner-msg'
},
img: {
'class':'spinner-img'
},
fxOptions: {
link: 'chain'
}
},
initialize: function(){
this.parent.apply(this, arguments);
this.target.store('spinner', this);
var deactivate = function(){ this.active = false; }.bind(this);
this.addEvents({
hide: deactivate,
show: deactivate
});
},
render: function(){
this.parent();
this.element.set('id', this.options.id || 'spinner-'+$time());
this.content = document.id(this.options.content) || new Element('div', this.options.content);
this.content.inject(this.element);
if (this.options.message) {
this.msg = document.id(this.options.message) || new Element('p', this.options.messageContainer).appendText(this.options.message);
this.msg.inject(this.content);
}
if (this.options.img) {
this.img = document.id(this.options.img) || new Element('div', this.options.img);
this.img.inject(this.content);
}
this.element.set('tween', this.options.fxOptions);
},
show: function(noFx){
if (this.active) return this.chain(this.show.bind(this));
if (!this.hidden) {
this.callChain.delay(20, this);
return this;
}
this.active = true;
return this.parent(noFx);
},
showMask: function(noFx){
var pos = function(){
this.content.position($merge({
relativeTo: this.element
}, this.options.containerPosition));
}.bind(this);
if (noFx) {
this.parent();
pos();
} else {
this.element.setStyles({
display: 'block',
opacity: 0
}).tween('opacity', this.options.style.opacity || 0.9);
pos();
this.hidden = false;
this.fireEvent('show');
this.callChain();
}
},
hide: function(noFx){
if (this.active) return this.chain(this.hide.bind(this));
if (this.hidden) {
this.callChain.delay(20, this);
return this;
}
this.active = true;
return this.parent(noFx);
},
hideMask: function(noFx){
if (noFx) return this.parent();
this.element.tween('opacity', 0).get('tween').chain(function(){
this.element.setStyle('display', 'none');
this.hidden = true;
this.fireEvent('hide');
this.callChain();
}.bind(this));
},
destroy: function(){
this.content.destroy();
this.parent();
this.target.eliminate('spinner');
}
});
Spinner.implement(new Chain);
if (window.Request) {
Request = Class.refactor(Request, {
options: {
useSpinner: false,
spinnerOptions: {},
spinnerTarget: false
},
initialize: function(options){
this._send = this.send;
this.send = function(options){
if (this.spinner) this.spinner.chain(this._send.bind(this, options)).show();
else this._send(options);
return this;
};
this.previous(options);
var update = document.id(this.options.spinnerTarget) || document.id(this.options.update);
if (this.options.useSpinner && update) {
this.spinner = update.get('spinner', this.options.spinnerOptions);
['onComplete', 'onException', 'onCancel'].each(function(event){
this.addEvent(event, this.spinner.hide.bind(this.spinner));
}, this);
}
},
getSpinner: function(){
return this.spinner;
}
});
}
Element.Properties.spinner = {
set: function(options){
var spinner = this.retrieve('spinner');
return this.eliminate('spinner').store('spinner:options', options);
},
get: function(options){
if (options || !this.retrieve('spinner')){
if (this.retrieve('spinner')) this.retrieve('spinner').destroy();
if (options || !this.retrieve('spinner:options')) this.set('spinner', options);
new Spinner(this, this.retrieve('spinner:options'));
}
return this.retrieve('spinner');
}
};
Element.implement({
spin: function(options){
this.get('spinner', options).show();
return this;
},
unspin: function(){
var opt = Array.link(arguments, {options: Object.type, callback: Function.type});
this.get('spinner', opt.options).hide(opt.callback);
return this;
}
});
MooTools.lang.set('en-US', 'Date', {
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dateOrder: ['month', 'date', 'year'],
shortDate: '%m/%d/%Y',
shortTime: '%I:%M%p',
AM: 'AM',
PM: 'PM',
ordinal: function(dayOfMonth){
return (dayOfMonth > 3 && dayOfMonth < 21) ? 'th' : ['th', 'st', 'nd', 'rd', 'th'][Math.min(dayOfMonth % 10, 4)];
},
lessThanMinuteAgo: 'less than a minute ago',
minuteAgo: 'about a minute ago',
minutesAgo: '{delta} minutes ago',
hourAgo: 'about an hour ago',
hoursAgo: 'about {delta} hours ago',
dayAgo: '1 day ago',
daysAgo: '{delta} days ago',
weekAgo: '1 week ago',
weeksAgo: '{delta} weeks ago',
monthAgo: '1 month ago',
monthsAgo: '{delta} months ago',
yearAgo: '1 year ago',
yearsAgo: '{delta} years ago',
lessThanMinuteUntil: 'less than a minute from now',
minuteUntil: 'about a minute from now',
minutesUntil: '{delta} minutes from now',
hourUntil: 'about an hour from now',
hoursUntil: 'about {delta} hours from now',
dayUntil: '1 day from now',
daysUntil: '{delta} days from now',
weekUntil: '1 week from now',
weeksUntil: '{delta} weeks from now',
monthUntil: '1 month from now',
monthsUntil: '{delta} months from now',
yearUntil: '1 year from now',
yearsUntil: '{delta} years from now'
});
MooTools.lang.set('en-US', 'Form.Validator', {
required:'This field is required.',
minLength:'Please enter at least {minLength} characters (you entered {length} characters).',
maxLength:'Please enter no more than {maxLength} characters (you entered {length} characters).',
integer:'Please enter an integer in this field. Numbers with decimals (e.g. 1.25) are not permitted.',
numeric:'Please enter only numeric values in this field (i.e. "1" or "1.1" or "-1" or "-1.1").',
digits:'Please use numbers and punctuation only in this field (for example, a phone number with dashes or dots is permitted).',
alpha:'Please use letters only (a-z) with in this field. No spaces or other characters are allowed.',
alphanum:'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.',
dateSuchAs:'Please enter a valid date such as {date}',
dateInFormatMDY:'Please enter a valid date such as MM/DD/YYYY (i.e. "12/31/1999")',
email:'Please enter a valid email address. For example "fred@domain.com".',
url:'Please enter a valid URL such as http://www.google.com.',
currencyDollar:'Please enter a valid $ amount. For example $100.00 .',
oneRequired:'Please enter something for at least one of these inputs.',
errorPrefix: 'Error: ',
warningPrefix: 'Warning: ',
noSpace: 'There can be no spaces in this input.',
reqChkByNode: 'No items are selected.',
requiredChk: 'This field is required.',
reqChkByName: 'Please select a {label}.',
match: 'This field needs to match the {matchName} field',
startDate: 'the start date',
endDate: 'the end date',
currendDate: 'the current date',
afterDate: 'The date should be the same or after {label}.',
beforeDate: 'The date should be the same or before {label}.',
startMonth: 'Please select a start month',
sameMonth: 'These two dates must be in the same month - you must change one or the other.',
creditcard: 'The credit card number entered is invalid. Please check the number and try again. {length} digits entered.'
});
(function(global){
var $ = global.document.id || global.$;
var isIE6 = Browser.Engine.trident4; // better compression and faster
var BgIframe = new Class({
Implements: Options,
options: {
top		: 'auto',
left	: 'auto',
width	: 'auto',
height	: 'auto',
opacity	: true,
src		: 'javascript:false;'
},
initialize: function(element, options){
if(!isIE6) return;
this.setOptions(options);
this.element = $(element);
var firstChild = this.element.getFirst();
if(!(firstChild && firstChild.hasClass('bgiframe')))
this.element.grab(document.createElement(this.render()), 'top');
},
toPx: function(n){
return isFinite(n) ? n + 'px' : n;
},
render: function(){
var options = this.options;
return '<iframe class="bgiframe" frameborder="0" tabindex="-1" src="' + options.src + '" ' +
'style="display:block;position:absolute;z-index:-1;' +
(options.opacity !== false ? 'filter:alpha(opacity=\'0\');' : '') +
'top:' + (options.top == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')' : this.toPx(options.top)) + ';' +
'left:' + (options.left == 'auto' ? 'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')' : this.toPx(options.left)) + ';' +
'width:' + (options.width == 'auto' ? 'expression(this.parentNode.offsetWidth+\'px\')' : this.toPx(options.width)) + ';' +
'height:' + (options.height == 'auto' ? 'expression(this.parentNode.offsetHeight+\'px\')' : this.toPx(options.height)) + ';' +
'"/>';
}
});
Element.implement('bgiframe', function(options){
if(isIE6) new BgIframe(this, options);
return this;
});
})(this);
(function(global){
var $ = global.document.id || global.$;
var browserEngine = Browser.Engine; // better compression and faster
$extend(Element.NativeEvents, {
'paste': 2, 'input': 2
});
Element.Events.paste = {
base : (browserEngine.presto || (browserEngine.gecko && browserEngine.version < 19)) ? 'input' : 'paste',
condition: function(e){
this.fireEvent('paste', e, 1);
return false;
}
};
Element.Events.keyrepeat = {
base: (browserEngine.trident) ? 'keydown' : 'keypress',
condition: $lambda(true)
};
var Meio = {};
var globalCache;
var keysThatDontChangeValueOnKeyUp = {
9:   1,  // tab
16:  1,  // shift
17:  1,  // control
18:  1,  // alt
224: 1,  // command (meta onkeypress)
91:  1,  // command (meta onkeydown)
37:  1,  // left
38:  1,  // up
39:  1,  // right
40:  1   // down
};
var encode = function(str){
return str.replace(/"/g, '&quot;').replace(/'/g, '&#39;');
};
Meio.Widget = new Class({
initialize: function(){
this.elements = {};
},
addElement: function(name, obj){
this.elements[name] = obj;
},
addEventToElement: function(name, eventName, event){
this.elements[name].addEvent(eventName, event.bindWithEvent(this));
},
addEventsToElement: function(name, events){
for(eventName in events){
this.addEventToElement(name, eventName, events[eventName]);
};
},
attach: function(){
for(element in this.elements){
this.elements[element].attach();
}
},
detach: function(){
for(element in this.elements){
this.elements[element].detach();
}
},
destroy: function(){
for(element in this.elements){
this.elements[element] && this.elements[element].destroy();
}
}
});
Meio.Autocomplete = new Class({
Extends: Meio.Widget,
Implements: [Options, Events],
options: {
delay: 200,
minChars: 0,
cacheLength: 20,
selectOnTab: true,
maxVisibleItems: 10,
cacheType: 'shared', // 'shared' or 'own'
filter: {
},
fieldOptions: {}, // see Element options
listOptions: {}, // see List options
requestOptions: {}, // see DataRequest options
urlOptions: {} // see URL options
},
initialize: function(input, data, options, listInstance){
this.parent();
this.setOptions(options);
this.active = 0;
this.filters = Meio.Autocomplete.Filter.get(this.options.filter);
this.addElement('list', listInstance || new Meio.Element.List(this.options.listOptions));
this.addListEvents();
this.addElement('field', new Meio.Element.Field(input, this.options.fieldOptions));
this.addFieldEvents();
this.addSelectEvents();
this.attach();
this.initCache();
this.initData(data);
},
addFieldEvents: function(){
this.addEventsToElement('field', {
'beforeKeyrepeat': function(e){
this.active = 1;
var e_key = e.key, list = this.elements.list;
if(e_key == 'up' || e_key == 'down' || (e_key == 'enter' && list.showing)) e.preventDefault();
},
'delayedKeyrepeat': function(e){
var e_key = e.key, field = this.elements.field;
field.keyPressControl[e_key] = true;
switch(e_key){
case 'up': case 'down':
this.focusItem(e_key);
break;
case 'enter':
this.setInputValue();
break;
case 'tab':
if(this.options.selectOnTab) this.setInputValue();
field.keyPressControl[e_key] = false; // tab blurs the input so the keyup event wont happen at the same input you made a keydown
break;
case 'esc':
this.elements.list.hide();
break;
default:
this.setupList();
}
this.oldInputedText = field.node.get('value');
},
'keyup': function(e){
var field = this.elements.field;
if(!keysThatDontChangeValueOnKeyUp[e.code]){
if(!field.keyPressControl[e.key]) this.setupList();
field.keyPressControl[e.key] = false;
}
},
'focus': function(){
this.active = 1;
var list = this.elements.list;
list.focusedItem = null;
list.positionNextTo(this.elements.field.node);
},
'click': function(){
if(this.active++ > 1 && !this.elements.list.showing){
this.forceSetupList();
}
},
'blur': function(e){
this.active = 0;
var list = this.elements.list;
if(list.shouldNotBlur){
this.elements.field.node.setCaretPosition('end');
list.shouldNotBlur = false;
if(list.focusedItem) list.hide();
}else{
list.hide();
}
},
'paste': function(){
return this.setupList();
}
});
},
addListEvents: function(){
this.addEventsToElement('list', {
'mousedown': function(e){
if(this.active && !e.dontHide) this.setInputValue();
}
});
},
update: function(){
var text = this.inputedText, data = this.data, options = this.options, list = this.elements.list;
var filter = this.filters.filter, formatMatch = this.filters.formatMatch, formatItem = this.filters.formatItem;
var cacheKey = data.getKey(), cached = this.cache.get(cacheKey), html;
if(cached){
html = cached.html;
this.itemsData = cached.data;
}else{
data = data.get();
var itemsHtml = [], itemsData = [], classes = list.options.classes;
for(var row, i = 0, n = 0; row = data[i++];){
if(filter.call(this, text, row)){
itemsHtml.push(
'<li title="', encode(formatMatch.call(this, text, row)),
'" data-index="', n,
'" class="', (n%2 ? classes.even : classes.odd), '">',
formatItem.call(this, text, row, n),
'</li>'
);
itemsData.push(row);
n++;
}
}
html = itemsHtml.join('');
this.cache.set(cacheKey, {html: html, data: itemsData});
this.itemsData = itemsData;
}
list.focusedItem = null;
this.fireEvent('deselect', [this.elements]);
list.list.set('html', html);
if(this.options.maxVisibleItems) list.applyMaxHeight(this.options.maxVisibleItems);
},
setupList: function(){
this.inputedText = this.elements.field.node.get('value');
if(this.inputedText !== this.oldInputedText){
this.forceSetupList(this.inputedText);
}else{
this.elements.list.hide();
}
return true;
},
forceSetupList: function(inputedText){
inputedText = inputedText || this.elements.field.node.get('value');
if(inputedText.length >= this.options.minChars){
$clear(this.prepareTimer);
this.prepareTimer = this.data.prepare.delay(this.options.delay, this.data, this.inputedText);
}
},
dataReady: function(){
this.update();
if(this.onUpdate){
this.onUpdate();
this.onUpdate = null;
}
var list = this.elements.list;
if(list.list.get('html')){
if(this.active) list.show();
}else{
this.fireEvent('noItemToList', [this.elements]);
list.hide();
}
},
setInputValue: function(){
var list = this.elements.list;
if(list.focusedItem){
var text = list.focusedItem.get('title');
this.elements.field.node.set('value', text);
var index = list.focusedItem.get('data-index');
this.fireEvent('select', [this.elements, this.itemsData[index], text, index]);
}
list.hide();
},
focusItem: function(direction){
var list = this.elements.list;
if(list.showing){
list.focusItem(direction);
}else{
this.forceSetupList();
this.onUpdate = function(){ list.focusItem(direction); };
}
},
addSelectEvents: function(){
this.addEvents({
select: function(elements){
elements.field.addSelectedClass();
},
deselect: function(elements){
elements.field.removeSelectedClass();
}
});
},
initData: function(data){
this.data = ($type(data) == 'string') ?
new Meio.Autocomplete.Data.Request(data, this.cache, this.elements.field, this.options.requestOptions, this.options.urlOptions) :
new Meio.Autocomplete.Data(data, this.cache);
this.data.addEvent('ready', this.dataReady.bind(this));
},
initCache: function(){
var cacheLength = this.options.cacheLength;
if(this.options.cacheType == 'shared'){
this.cache = globalCache;
this.cache.setMaxLength(cacheLength);
}else{ // 'own'
this.cache = new Meio.Autocomplete.Cache(cacheLength);
}
},
refreshCache: function(cacheLength){
this.cache.refresh();
this.cache.setMaxLength(cacheLength || this.options.cacheLength);
},
refreshAll: function(cacheLength, urlOptions){
this.refreshCache(cacheLength);
this.data.refreshKey(urlOptions);
}
});
Meio.Autocomplete.Select = new Class({
Extends: Meio.Autocomplete,
options: {
syncName: 'id', // if falsy it wont sync at start
valueField: null,
valueFilter: function(data){
return data.id;
}
},
initialize: function(input, data, options, listInstance){
this.parent(input, data, options, listInstance);
this.valueField = $(this.options.valueField);
if(!this.valueField) return;
if(this.options.syncName){
this.syncWithValueField(data);
}
this.addValueFieldEvents();
},
addValueFieldEvents: function(){
this.addEvents({
'select': function(elements, data){
this.valueField.set('value', this.options.valueFilter.call(this, data));
},
'deselect': function(elements){
this.valueField.set('value', '');
}
});
},
syncWithValueField: function(data){
var value = this.getValueFromValueField();
if(!value) return;
this.addParameter(data);
this.addDataReadyEvent(value);
this.data.prepare(this.elements.field.node.get('value'));
},
addParameter: function(data){
this.parameter = {
name: this.options.syncName,
value: function(){ return this.valueField.value; }.bind(this)
};
if(this.data.url) this.data.url.addParameter(this.parameter);
},
addDataReadyEvent: function(value){
var self = this;
this.data.addEvent('ready', function runOnce(){
var values = this.get();
for(var i = values.length; i--;){
if(self.options.valueFilter.call(self, values[i]) == value){
self.elements.field.node.set('value', self.filters.formatMatch.call(self, '', values[i], 0));
}
}
if(this.url) this.url.removeParameter(self.parameter);
this.removeEvent('ready', runOnce);
});
},
getValueFromValueField: function(){
return this.valueField.get('value');
}
});
Meio.Autocomplete.Select.One = new Class({
Extends: Meio.Autocomplete.Select,
options: {
filter: {
path: 'text' // path to the text value on each object thats contained on the data array
}
},
initialize: function(select, options, listInstance){
this.select = $(select);
this.replaceSelect();
this.parent(this.field, this.createDataArray(), $merge(options, {
valueField: this.select,
valueFilter: function(data){ return data.value; }
}), listInstance);
},
replaceSelect: function(){
var selectedOption = this.select.getSelected()[0];
this.field = new Element('input', {type: 'text'});
var optionValue = selectedOption.get('value');
if($chk(optionValue)) this.field.set('value', selectedOption.get('html'));
this.select.setStyle('display', 'none');
this.field.inject(this.select, 'after');
},
createDataArray: function(){
var selectOptions = this.select.options, data = [];
for(var i = 0, selectOption, optionValue; selectOption = selectOptions[i++];){
optionValue = selectOption.value;
if($chk(optionValue)) data.push({value: optionValue, text: selectOption.innerHTML});
}
return data;
},
addValueFieldEvents: function(){
this.addEvents({
'select': function(elements, data, text, index){
var option = this.valueField.getElement('option[value="' + this.options.valueFilter.call(this, data) + '"]');
if(option) option.selected = true;
},
'deselect': function(elements){
var option = this.valueField.getSelected()[0];
if(option) option.selected = false;
}
});
},
getValueFromValueField: function(){
return this.valueField.getSelected()[0].get('value');
}
});
Meio.Element = new Class({
Implements: [Events],
initialize: function(node){
this.setNode(node);
this.createBoundEvents();
this.attach();
},
setNode: function(node){
this.node = node ? $(node) || $$(node)[0] : this.render();
},
createBoundEvents: function(){
this.bound = {};
this.boundEvents.each(function(evt){
this.bound[evt] = function(e){
this.fireEvent('before' + evt.capitalize(), e);
this[evt] && this[evt](e);
this.fireEvent(evt, e);
return true;
}.bindWithEvent(this);
}, this);
},
attach: function(){
for(e in this.bound){
this.node.addEvent(e, this.bound[e]);
}
},
detach: function(){
for(e in this.bound){
this.node.removeEvent(e, this.bound[e]);
}
},
toElement: function(){
this.node;
},
render: $empty
});
Meio.Element.Field = new Class({
Extends: Meio.Element,
Implements: [Options],
options: {
classes: {
loading: 'ma-loading',
selected: 'ma-selected'
}
},
initialize: function(field, options){
this.keyPressControl = {};
this.boundEvents = ['paste', 'focus', 'blur', 'click', 'keyup', 'keyrepeat'];
if(browserEngine.trident4) this.boundEvents.push('keypress'); // yeah super ugly, but what can be awesome with ie?
this.setOptions(options);
this.parent(field);
$(global).addEvent('unload', function(){
if(this.node) this.node.set('autocomplete', 'on'); // if autocomplete is off when you reload the page the input value gets erased
}.bind(this));
},
setNode: function(element){
this.parent(element);
this.node.set('autocomplete', 'off');
},
keyrepeat: function(e){
$clear(this.keyrepeatTimer);
this.keyrepeatTimer = this._keyrepeat.delay(1, this, e);
},
_keyrepeat: function(e){
this.fireEvent('delayedKeyrepeat', e);
},
destroy: function(){
this.detach();
this.node.removeAttribute('autocomplete');
},
addLoadingClass: function(){
this.node.addClass(this.options.classes.loading);
},
removeLoadingClass: function(){
this.node.removeClass(this.options.classes.loading);
},
addSelectedClass: function(){
this.node.addClass(this.options.classes.selected);
},
removeSelectedClass: function(){
this.node.removeClass(this.options.classes.selected);
},
keypress: function(e){
if(e.key == 'enter') this.bound.keyrepeat(e);
}
});
Meio.Element.List = new Class({
Extends: Meio.Element,
Implements: [Options],
options: {
width: 'field', // you can pass any other value settable by set('width') to the list container
classes: {
container: 'ma-container',
hover: 'ma-hover',
odd: 'ma-odd',
even: 'ma-even'
}
},
initialize: function(options){
this.boundEvents = ['mousedown', 'mouseover'];
this.setOptions(options);
this.parent();
this.focusedItem = null;
},
applyMaxHeight: function(maxVisibleItems){
var listChildren = this.list.childNodes;
var node = listChildren[maxVisibleItems - 1] || (listChildren.length ? listChildren[listChildren.length - 1] : null);
if(!node) return;
node = $(node);
for(var i = 2; i--;) this.node.setStyle('height', node.getCoordinates(this.list).bottom);
},
mouseover: function(e){
var item = this.getItemFromEvent(e), hoverClass = this.options.classes.hover;
if(!item) return true;
if(this.focusedItem) this.focusedItem.removeClass(hoverClass);
item.addClass(hoverClass);
this.focusedItem = item;
this.fireEvent('focusItem', [this.focusedItem]);
},
mousedown: function(e){
e.preventDefault();
this.shouldNotBlur = true;
if(!(this.focusedItem = this.getItemFromEvent(e))){
e.dontHide = true;
return true;
}
this.focusedItem.removeClass(this.options.classes.hover);
},
focusItem: function(direction){
var hoverClass = this.options.classes.hover, newFocusedItem;
if(this.focusedItem){
if((newFocusedItem = this.focusedItem[direction == 'up' ? 'getPrevious' : 'getNext']())){
this.focusedItem.removeClass(hoverClass);
newFocusedItem.addClass(hoverClass);
this.focusedItem = newFocusedItem;
this.scrollFocusedItem(direction);
}
}
else{
if((newFocusedItem = this.list.getFirst())){
newFocusedItem.addClass(hoverClass);
this.focusedItem = newFocusedItem;
}
}
},
scrollFocusedItem: function(direction){
var focusedItemCoordinates = this.focusedItem.getCoordinates(this.list),
scrollTop = this.node.scrollTop;
if(direction == 'down'){
var delta = focusedItemCoordinates.bottom - this.node.getStyle('height').toInt();
if((delta - scrollTop) > 0){
this.node.scrollTop = delta;
}
}else{
var top = focusedItemCoordinates.top;
if(scrollTop && scrollTop > top){
this.node.scrollTop = top;
}
}
},
getItemFromEvent: function(e){
var target = e.target;
while(target && target.tagName != 'LI'){
if(target === this.node) return null;
target = target.parentNode;
}
return $(target);
},
render: function(){
var node = new Element('div', {'class': this.options.classes.container});
if(node.bgiframe) node.bgiframe({top: 0, left: 0});
this.list = new Element('ul').inject(node);
$(document.body).grab(node);
return node;
},
positionNextTo: function(fieldNode){
var width = this.options.width, listNode = this.node;
var elPosition = fieldNode.getCoordinates();
listNode.setStyle('width', width == 'field' ? fieldNode.getWidth().toInt() - listNode.getStyle('border-left-width').toInt() - listNode.getStyle('border-right-width').toInt() : width);
listNode.setPosition({x: elPosition.left, y: elPosition.bottom});
},
show: function(){
this.node.scrollTop = 0;
this.node.setStyle('visibility', 'visible');
this.showing = true;
},
hide: function(){
this.showing = false;
this.node.setStyle('visibility', 'hidden');
}
});
Meio.Autocomplete.Filter = {
filters: {},
get: function(options){
var type = options.type, keys = (options.path || '').split('.');
var filters = (type && this.filters[type]) ? this.filters[type](this, keys) : options;
return $merge(this.defaults(keys), filters);
},
define: function(name, options){
this.filters[name] = options;
},
defaults: function(keys){
var self = this;
return {
filter: function(text, data){
return text ? self._getValueFromKeys(data, keys).test(new RegExp(text.escapeRegExp(), 'i')) : true;
},
formatMatch: function(text, data){
return self._getValueFromKeys(data, keys);
},
formatItem: function(text, data, i){
return text ? self._getValueFromKeys(data, keys).replace(new RegExp('(' + text.escapeRegExp() + ')', 'gi'), '<strong>$1</strong>') : self._getValueFromKeys(data, keys);
}
};
},
_getValueFromKeys: function(obj, keys){
var key, value = obj;
for(var i = 0; key = keys[i++];) value = value[key];
return value;
}
};
Meio.Autocomplete.Filter.define('contains', function(self, keys){return {};});
Meio.Autocomplete.Filter.define('startswith', function(self, keys){
return {
filter: function(text, data){
return text ? self._getValueFromKeys(data, keys).test(new RegExp('^' + text.escapeRegExp(), 'i')) : true;
}
};
});
Meio.Autocomplete.Data = new Class({
Implements: [Options, Events],
initialize: function(data, cache){
this._cache = cache;
this.data = data;
this.dataString = JSON.encode(this.data);
},
get: function(){
return this.data;
},
getKey: function(){
return this.cachedKey;
},
prepare: function(text){
this.cachedKey = this.dataString + (text || '');
this.fireEvent('ready');
},
cache: function(key, data){
this._cache.set(key, data);
},
refreshKey: $empty
});
Meio.Autocomplete.Data.Request = new Class({
Extends: Meio.Autocomplete.Data,
options: {
noCache: true
},
initialize: function(url, cache, element, options, urlOptions){
this.setOptions(options);
this.rawUrl = url;
this._cache = cache;
this.element = element;
this.urlOptions = urlOptions;
this.refreshKey();
this.createRequest();
},
prepare: function(text){
this.cachedKey = this.url.evaluate(text);
if(this._cache.has(this.cachedKey)){
this.fireEvent('ready');
}else{
this.request.send({url: this.cachedKey});
}
},
createRequest: function(){
var self = this;
this.request = new Request.JSON(this.options);
this.request.addEvents({
request: function(){
self.element.addLoadingClass();
},
complete: function(){
self.element.removeLoadingClass();
},
success: function(jsonResponse){
self.data = jsonResponse;
self.fireEvent('ready');
}
});
},
refreshKey: function(urlOptions){
urlOptions = $merge(this.urlOptions, {url: this.rawUrl}, urlOptions || {});
this.url = new Meio.Autocomplete.Data.Request.URL(urlOptions.url, urlOptions);
}
});
Meio.Autocomplete.Data.Request.URL = new Class({
Implements: [Options],
options: {
extraParams: null,
max: 20
},
initialize: function(url, options){
this.setOptions(options);
this.rawUrl = url;
this.url = url;
this.url += this.url.contains('?') ? '&' : '?';
this.dynamicExtraParams = [];
var params = $splat(this.options.extraParams);
for(var i = params.length; i--;){
this.addParameter(params[i]);
}
if(this.options.max) this.addParameter('limit=' + this.options.max);
},
evaluate: function(text){
text = text || '';
var params = this.dynamicExtraParams, url = [];
url.push('q=' + encodeURIComponent(text));
for(var i = params.length; i--;){
url.push(encodeURIComponent(params[i].name) + '=' + encodeURIComponent($lambda(params[i].value)()));
}
return this.url + url.join('&');
},
addParameter: function(param){
if(isFinite(param.nodeType) || $type(param.value) == 'function'){
this.dynamicExtraParams.push(param);
}else{
this.url += (($type(param) == 'string') ? param : encodeURIComponent(param.name) + '=' + encodeURIComponent(param.value)) + '&';
}
},
removeParameter: function(param){
this.dynamicExtraParams.erase(param);
}
});
Meio.Autocomplete.Cache = new Class({
initialize: function(maxLength){
this.refresh();
this.setMaxLength(maxLength);
},
set: function(key, value){
if(!this.cache[key]){
if(this.getLength() >= this.maxLength){
var keyToRemove = this.pos.shift();
this.cache[keyToRemove] = null;
delete this.cache[keyToRemove];
}
this.cache[key] = value;
this.pos.push(key);
}
return this;
},
get: function(key){
return this.cache[key || ''] || null;
},
has: function(key){
return !!this.get(key);
},
getLength: function(){
return this.pos.length;
},
refresh: function(){
this.cache = {};
this.pos = [];
},
setMaxLength: function(maxLength){
this.maxLength = Math.max(maxLength, 1);
}
});
globalCache = new Meio.Autocomplete.Cache();
if($defined(global.Meio)) $extend(global.Meio, Meio);
else global.Meio = Meio;
})(this);
var NXC = NXC || {};
NXC.Paginator = NXC.Paginator || {};
NXC.Paginator.Base = new Class( {
Implements: [Options, Events],
options: {
'navigationBlocks': [ 'paginator' ],
'quantityBlocks': [ 'paginator-quantity-top', 'paginator-quantity-bottom' ],
'possbileQuantities': [ 5, 10, 25, 50 ],
'defaultQuantity': 10,
'currentQuantityCSSClass': 'paginator-quantity-current',
'otherQuantityCSSClass': 'paginator-quantity-other',
'currentLinkCSSClass': 'paginator-current',
'otherLinkCSSClass': 'paginator-other',
'disabledLinkCSSClass': 'paginator-disabled',
'prevLinkTitle': '&laquo;Previous',
'nextLinkTitle': 'Next&raquo;',
'prevLinkCSSClass': 'paginator-prev',
'nextLinkCSSClass': 'paginator-next',
'currentURL': true
},
itemsPerPage: 10,
pagesCount: 0,
currentPage: 1,
quantityBlocks: [],
navigationBlocks: [],
initialize: function( options ) {
this.setOptions( options );
this.itemsPerPage = this.options.defaultQuantity;
},
build: function() {
this.parseURL();
this.pagesCount = this.getPagesCount();
if ( this.pagesCount > 1 ) {
this.installPagesNavigation();
this.installQuantityNavigatoion();
}
this.showPage();
},
parseURL: function() {
if( this.options.currentURL ) {
var uri = new URI();
if( uri.get( 'fragment' ) ) {
var quantity = this.itemsPerPage;
var parts = uri.get( 'fragment' ).split( '/' );
parts.each( function( part ) {
var partElements = part.split( '=' );
if( partElements.length == 2 ) {
switch( partElements[0] ) {
case 'quatity':
quantity = partElements[1].toInt();
break;
case 'page':
this.currentPage = partElements[1].toInt();
break;
}
}
}.bind( this ) );
if( this.options.possbileQuantities.contains( quantity ) ) {
this.setItemsPerPage( quantity );
}
}
}
},
installPagesNavigation: function() {
this.options.navigationBlocks.each( function( el ) {
var navigationBlock = document.id( el );
if( $type( navigationBlock ) == 'element' ) {
this.navigationBlocks.include( navigationBlock );
}
}.bind( this ) );
this.navigationBlocks.each( function( navigationBlock ) {
navigationBlock.empty();
this.buildPagesNavigationLink( this.options.prevLinkTitle, this.options.prevLinkCSSClass )
.inject( navigationBlock )
.addEvent( 'click', function() {
if( this.currentPage == 1 ) {
return false;
}
this.currentPage--;
this.showPage();
}.bind( this ) );
if( this.pagesCount > 1 ) {
var pageNumber = 1;
while ( pageNumber <= this.pagesCount ) {
this.buildNavigationLink( pageNumber, navigationBlock );
pageNumber++;
}
}
this.buildPagesNavigationLink( this.options.nextLinkTitle, this.options.nextLinkCSSClass )
.inject( navigationBlock )
.addEvent( 'click', function() {
if( this.currentPage == this.pagesCount ) {
return false;
}
this.currentPage++;
this.showPage();
}.bind( this ) );
}.bind( this ) );
},
buildPagesNavigationLink: function( html, cssClass ) {
return new Element( 'a', {
'html': html,
'href': '#',
'class': cssClass,
'events': {
'click': function( e ){ e.stop(); }
}
} );
},
buildNavigationLink: function( pageNumber, container ) {
var el = this.buildPagesNavigationLink(
pageNumber,
( pageNumber == this.currentPage ) ? this.options.currentLinkCSSClass : this.options.otherLinkCSSClass
).inject( container ).store( 'page', pageNumber );
el.addEvent( 'click', function() {
this.currentPage = el.retrieve( 'page' );
this.showPage();
}.bind( this ) );
},
installQuantityNavigatoion: function() {
this.options.quantityBlocks.each( function( el ) {
var quantityBlock = document.id( el );
if( quantityBlock ) {
this.quantityBlocks.include( quantityBlock );
}
}.bind( this ) );
this.quantityBlocks.each( function( quantityBlock ) {
quantityBlock.empty();
this.options.possbileQuantities.each( function( quantity ) {
if( $type( quantity ) == 'number' ) {
new Element( 'a', {
'href': '#',
'html': quantity,
'class': ( quantity == this.itemsPerPage ) ? this.options.currentQuantityCSSClass : this.options.otherQuantityCSSClass,
'events': {
'click': function( e ){ e.stop(); }
}
} )
.inject( quantityBlock )
.store( 'quantity', quantity )
.addEvent( 'click', this.setItemsPerPage.bind( this, quantity ) )
}
}.bind( this ) );
}.bind( this ) );
},
setItemsPerPage: function( itemsCount ) {
var otherClass   = this.options.otherQuantityCSSClass;
var currentClass = this.options.currentQuantityCSSClass;
this.quantityBlocks.each( function( quantityBlock ) {
quantityBlock.getElements( 'a.' + otherClass ).extend(
quantityBlock.getElements( 'a.' + currentClass )
).each( function( el ) {
el.removeClass( otherClass );
el.removeClass( currentClass );
if( el.retrieve( 'quantity' ) == itemsCount ) {
el.addClass( currentClass );
} else {
el.addClass( otherClass );
}
} );
}.bind( this ) );
this.itemsPerPage = itemsCount;
this.pagesCount = this.getPagesCount();
if( this.currentPage > this.pagesCount ) {
this.currentPage = this.pagesCount;
}
this.installPagesNavigation();
this.showPage();
},
showPage: function() {
var linkClassCurrent  = this.options.currentLinkCSSClass;
var linkClassOther    = this.options.otherLinkCSSClass;
var linkClassDisabled = this.options.disabledLinkCSSClass;
this.navigationBlocks.each( function( navigationBlock ) {
if( this.pagesCount > 1 ) {
navigationBlock.getElements( 'a.' + linkClassOther ).extend(
navigationBlock.getElements( 'a.' + linkClassCurrent )
).each( function( el ) {
el.removeClass( linkClassOther );
el.removeClass( linkClassCurrent );
if( el.retrieve( 'page' ) == this.currentPage ) {
el.addClass( linkClassCurrent );
} else {
el.addClass( linkClassOther );
}
}.bind( this ) );
}
var prevLink = navigationBlock.getElement( 'a.' + this.options.prevLinkCSSClass );
var nextLink = navigationBlock.getElement( 'a.' + this.options.nextLinkCSSClass );
prevLink.removeClass( linkClassDisabled );
nextLink.removeClass( linkClassDisabled );
if( this.currentPage == 1 ) {
prevLink.addClass( linkClassDisabled );
}
if( this.currentPage == this.pagesCount ) {
nextLink.addClass( linkClassDisabled );
}
}.bind( this ) );
this.showItems();
this.updateCurrentURI();
},
updateCurrentURI: function() {
if( this.options.currentURL != false ) {
var uri = new URI();
uri.set( 'fragment', 'page=' + this.currentPage + '/quatity=' + this.itemsPerPage );
window.location = uri.toString();
}
},
calculatePagesCount: function() {},
showItems: function() {}
} );
NXC.Paginator.Simple = new Class( {
Extends: NXC.Paginator.Base,
Implements: [Options, Events],
options: {
'onShowPage': $empty()
},
initialize: function( blocksCSSPath, options ) {
this.blocks = document.getElements( blocksCSSPath );
this.setOptions( options );
this.parent( options );
},
getPagesCount: function() {
return Math.ceil( this.blocks.length / this.itemsPerPage );
},
showItems: function() {
var minBlock = ( this.currentPage - 1 ) * this.itemsPerPage;
var maxBlock = this.currentPage * this.itemsPerPage;
var displayItems = [];
var tag = ( this.blocks[0] ) ? this.blocks[0].get( 'tag' ) : false;
var displayStyle = 'block';
if( tag == 'tr' && !Browser.Engine.trident ) {
displayStyle = 'table-row';
} else if ( tag == 'li' ) {
displayStyle = 'list-item';
}
this.blocks.each( function( block, index ) {
if( index >= minBlock && index < maxBlock ) {
block.setStyle( 'display', displayStyle );
displayItems.include( block );
} else {
block.setStyle( 'display', 'none' );
}
} );
new Fx.Scroll( window ).toElement( this.blocks[0] );
this.fireEvent( 'pageShow', [ displayItems ] );
}
} );
NXC.Paginator.AJAX = new Class( {
Extends: NXC.Paginator.Base,
Implements: [Options, Events],
options: {
'onStartShowPage': $empty(),
'onCompleteShowPage': $empty()
},
ajaxURL: '',
itemsContainer: false,
itemsCount: 0,
initialize: function( ajaxURL, itemsContainer, itemsCount, options ) {
this.ajaxURL        = ajaxURL;
this.itemsContainer = document.id( itemsContainer );
this.itemsCount     = itemsCount;
this.setOptions( options );
this.parent( options );
},
getPagesCount: function() {
return Math.ceil( this.itemsCount / this.itemsPerPage );
},
showItems: function() {
this.fireEvent( 'startShowPage' );
this.itemsContainer.empty();
new Request.HTML( {
'url': this.ajaxURL.replace( '%offset%', ( this.currentPage -1 ) * this.itemsPerPage ).replace( '%limit%', this.itemsPerPage ),
'method': 'get',
'update': this.itemsContainer,
'onSuccess': function() {
new Fx.Scroll( window ).toElement( this.itemsContainer );
this.fireEvent( 'onCompleteShowPage' );
}.bind( this )
} ).send( 'offset=' + ( this.currentPage -1 ) * this.itemsPerPage  + '&limit=' + this.itemsPerPage );
}
} );
var NXC = NXC || {};
NXC.MessageStack = new Class( {
Implements: [Options, Events],
options:{
'stackBlockClass' : 'nxc-message-stack'
},
stackBlock : false,
initialize: function( options ) {
this.setOptions( options );
this.images = $$( this.options.imagesSelector );
this.createStackBlock();
},
createStackBlock: function() {
this.stackBlock = new Element( 'div', { 'class': this.options.stackBlockClass } ).inject( document.body );
},
showMessage: function( text, type, options ) {
var messageInstance = new NXC.NotifyMessage( text, type, options )
messageInstance.getMessageElement().inject( this.stackBlock );
}
} );
var NXC = NXC || {};
NXC.NotifyMessage = new Class( {
Implements : [Options, Events],
options:{
'tag'              : 'div',
'hideTimeout'      : 5000,
'hideTweenOptions' : {
'property': 'opacity',
'duration': 500
},
'closButtonClass'  : 'nxc-message-close-button',
'typesClasses'     : {
'notice'         : 'nxc-message-notice',
'warning'        : 'nxc-message-warning',
'error'          : 'nxc-message-error'
}
},
message : false,
initialize: function( text, type, options ) {
this.setOptions( options );
this.message = new Element( this.options.tag, {
'class' : $defined( this.options.typesClasses[ type ] ) ? this.options.typesClasses[ type ] : type,
'html'  : text
} );
if( this.options.hideTimeout.toInt() > 0 ) {
this.message.store(
'hideFunctionTimeout',
this.hide.delay( this.options.hideTimeout, this, [] )
);
}
var closeButton = new Element( 'a', {
'class'  : this.options.closButtonClass,
'html'   : '&nbsp',
'href'   : '#',
'events' : {
'click' : function( event ) {
event.stop();
this.hide();
}.bind( this )
}
} ).inject( this.message, 'top' );
},
hide: function() {
var hideFunctionTimeout = this.message.retrieve( 'hideFunctionTimeout', false );
if( hideFunctionTimeout !== false ) {
$clear( hideFunctionTimeout );
}
this.message.get( 'tween', this.options.hideTweenOptions ).start( 0 ).chain(
function() { this.message.setStyle( 'display', 'none' ); }.bind( this )
);
},
getMessageElement: function() {
return this.message;
}
} );
var DatePicker = new Class({
Implements: Options,
d: '',
today: '',
choice: {},
bodysize: {},
limit: {},
attachTo: null,    // selector for target inputs
picker: null,      // main datepicker container
slider: null,      // slider that contains both oldContents and newContents, used to animate between 2 different views
oldContents: null, // used in animating from-view to new-view
newContents: null, // used in animating from-view to new-view
input: null,       // original input element (used for input/output)
visual: null,      // visible input (used for rendering)
options: {
pickerClass: 'datepicker',
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
dayShort: 2,
monthShort: 3,
startDay: 1, // Sunday (0) through Saturday (6) - be aware that this may affect your layout, since the days on the right might have a different margin
timePicker: false,
timePickerOnly: false,
yearPicker: true,
yearsPerPage: 20,
format: 'd-m-Y',
allowEmpty: false,
inputOutputFormat: 'U', // default to unix timestamp
animationDuration: 400,
useFadeInOut: !Browser.Engine.trident, // dont animate fade-in/fade-out for IE
startView: 'month', // allowed values: {time, month, year, decades}
positionOffset: { x: 0, y: 0 },
minDate: null, // { date: '[date-string]', format: '[date-string-interpretation-format]' }
maxDate: null, // same as minDate
debug: false,
toggleElements: null,
onShow: $empty,   // triggered when the datepicker pops up
onClose: $empty,  // triggered after the datepicker is closed (destroyed)
onSelect: $empty  // triggered when a date is selected
},
initialize: function(attachTo, options) {
this.attachTo = attachTo;
this.setOptions(options).attach();
if (this.options.timePickerOnly) {
this.options.timePicker = true;
this.options.startView = 'time';
}
this.formatMinMaxDates();
document.addEvent('mousedown', this.close.bind(this));
},
formatMinMaxDates: function() {
if (this.options.minDate && this.options.minDate.format) {
this.options.minDate = this.unformat(this.options.minDate.date, this.options.minDate.format);
}
if (this.options.maxDate && this.options.maxDate.format) {
this.options.maxDate = this.unformat(this.options.maxDate.date, this.options.maxDate.format);
this.options.maxDate.setHours(23);
this.options.maxDate.setMinutes(59);
this.options.maxDate.setSeconds(59);
}
},
attach: function() {
if ($chk(this.options.toggleElements)) {
var togglers = $$(this.options.toggleElements);
document.addEvents({
'keydown': function(e) {
if (e.key == "tab") {
this.close(null, true);
}
}.bind(this)
});
};
$$(this.attachTo).each(function(item, index) {
if (item.retrieve('datepicker')) return;
if ($chk(item.get('value'))) {
var init_clone_val = this.format(new Date(this.unformat(item.get('value'), this.options.inputOutputFormat)), this.options.format);
} else if (!this.options.allowEmpty) {
var init_clone_val = this.format(new Date(), this.options.format);
} else {
var init_clone_val = '';
}
var display = item.getStyle('display');
var clone = item
.setStyle('display', this.options.debug ? display : 'none')
.store('datepicker', true) // to prevent double attachment...
.clone()
.store('datepicker', true) // ...even for the clone (!)
.removeProperty('name')    // secure clean (form)submission
.setStyle('display', display)
.set('value', init_clone_val)
.inject(item, 'after');
if ($chk(this.options.toggleElements)) {
togglers[index]
.setStyle('cursor', 'pointer')
.addEvents({
'click': function(e) {
this.onFocus(item, clone);
}.bind(this)
});
clone.addEvents({
'blur': function() {
if( item.get( 'readonly' ) === false ) {
item.set('value', clone.get('value'));
}
}
});
} else {
clone.addEvents({
'keydown': function(e) {
if (this.options.allowEmpty && (e.key == "delete" || e.key == "backspace")) {
item.set('value', '');
e.target.set('value', '');
this.close(null, true);
} else if (e.key == "tab") {
this.close(null, true);
} else {
e.stop();
}
}.bind(this),
'focus': function(e) {
this.onFocus(item, clone);
}.bind(this)
});
}
}.bind(this));
},
onFocus: function(original_input, visual_input) {
var init_visual_date, d = visual_input.getCoordinates();
if ($chk(original_input.get('value'))) {
init_visual_date = this.unformat(original_input.get('value'), this.options.inputOutputFormat).valueOf();
} else {
init_visual_date = new Date();
if ($chk(this.options.maxDate) && init_visual_date.valueOf() > this.options.maxDate.valueOf()) {
init_visual_date = new Date(this.options.maxDate.valueOf());
}
if ($chk(this.options.minDate) && init_visual_date.valueOf() < this.options.minDate.valueOf()) {
init_visual_date = new Date(this.options.minDate.valueOf());
}
}
this.show({ left: d.left + this.options.positionOffset.x, top: d.top + d.height + this.options.positionOffset.y }, init_visual_date);
this.input = original_input;
this.visual = visual_input;
this.options.onShow();
},
dateToObject: function(d) {
return {
year: d.getFullYear(),
month: d.getMonth(),
day: d.getDate(),
hours: d.getHours(),
minutes: d.getMinutes(),
seconds: d.getSeconds()
};
},
dateFromObject: function(values) {
var d = new Date();
d.setDate(1);
['year', 'month', 'day', 'hours', 'minutes', 'seconds'].each(function(type) {
var v = values[type];
if (!$chk(v)) return;
switch (type) {
case 'day': d.setDate(v); break;
case 'month': d.setMonth(v); break;
case 'year': d.setFullYear(v); break;
case 'hours': d.setHours(v); break;
case 'minutes': d.setMinutes(v); break;
case 'seconds': d.setSeconds(v); break;
}
});
return d;
},
show: function(position, timestamp) {
this.formatMinMaxDates();
if ($chk(timestamp)) {
this.d = new Date(timestamp);
} else {
this.d = new Date();
}
this.today = new Date();
this.choice = this.dateToObject(this.d);
this.mode = (this.options.startView == 'time' && !this.options.timePicker) ? 'month' : this.options.startView;
this.render();
this.picker.setStyles(position);
},
render: function(fx) {
if (!$chk(this.picker)) {
this.constructPicker();
} else {
var o = this.oldContents;
this.oldContents = this.newContents;
this.newContents = o;
this.newContents.empty();
}
var startDate = new Date(this.d.getTime());
this.limit = { right: false, left: false };
if (this.mode == 'decades') {
this.renderDecades();
} else if (this.mode == 'year') {
this.renderYear();
} else if (this.mode == 'time') {
this.renderTime();
this.limit = { right: true, left: true }; // no left/right in timeview
} else {
this.renderMonth();
}
this.picker.getElement('.previous').setStyle('visibility', this.limit.left ? 'hidden' : 'visible');
this.picker.getElement('.next').setStyle('visibility', this.limit.right ? 'hidden' : 'visible');
this.picker.getElement('.titleText').setStyle('cursor', this.allowZoomOut() ? 'pointer' : 'default');
this.d = startDate;
if (this.picker.getStyle('opacity') == 0) {
this.picker.tween('opacity', 0, 1);
}
if ($chk(fx)) this.fx(fx);
},
fx: function(fx) {
if (fx == 'right') {
this.oldContents.setStyles({ left: 0, opacity: 1 });
this.newContents.setStyles({ left: this.bodysize.x, opacity: 1 });
this.slider.setStyle('left', 0).tween('left', 0, -this.bodysize.x);
} else if (fx == 'left') {
this.oldContents.setStyles({ left: this.bodysize.x, opacity: 1 });
this.newContents.setStyles({ left: 0, opacity: 1 });
this.slider.setStyle('left', -this.bodysize.x).tween('left', -this.bodysize.x, 0);
} else if (fx == 'fade') {
this.slider.setStyle('left', 0);
this.oldContents.setStyle('left', 0).set('tween', { duration: this.options.animationDuration / 2 }).tween('opacity', 1, 0);
this.newContents.setStyles({ opacity: 0, left: 0}).set('tween', { duration: this.options.animationDuration }).tween('opacity', 0, 1);
}
},
constructPicker: function() {
this.picker = new Element('div', { 'class': this.options.pickerClass }).inject(document.body);
if (this.options.useFadeInOut) {
this.picker.setStyle('opacity', 0).set('tween', { duration: this.options.animationDuration });
}
var h = new Element('div', { 'class': 'header' }).inject(this.picker);
var titlecontainer = new Element('div', { 'class': 'title' }).inject(h);
new Element('div', { 'class': 'previous' }).addEvent('click', this.previous.bind(this)).set('text', '«').inject(h);
new Element('div', { 'class': 'next' }).addEvent('click', this.next.bind(this)).set('text', '»').inject(h);
new Element('div', { 'class': 'closeButton' }).addEvent('click', this.close.bindWithEvent(this, true)).set('text', 'x').inject(h);
new Element('span', { 'class': 'titleText' }).addEvent('click', this.zoomOut.bind(this)).inject(titlecontainer);
var b = new Element('div', { 'class': 'body' }).inject(this.picker);
this.bodysize = b.getSize();
this.slider = new Element('div', { styles: { position: 'absolute', top: 0, left: 0, width: 2 * this.bodysize.x, height: this.bodysize.y }})
.set('tween', { duration: this.options.animationDuration, transition: Fx.Transitions.Quad.easeInOut }).inject(b);
this.oldContents = new Element('div', { styles: { position: 'absolute', top: 0, left: this.bodysize.x, width: this.bodysize.x, height: this.bodysize.y }}).inject(this.slider);
this.newContents = new Element('div', { styles: { position: 'absolute', top: 0, left: 0, width: this.bodysize.x, height: this.bodysize.y }}).inject(this.slider);
},
renderTime: function() {
var container = new Element('div', { 'class': 'time' }).inject(this.newContents);
if (this.options.timePickerOnly) {
this.picker.getElement('.titleText').set('text', 'Select a time');
} else {
this.picker.getElement('.titleText').set('text', this.format(this.d, 'j M, Y'));
}
new Element('input', { type: 'text', 'class': 'hour' })
.set('value', this.leadZero(this.d.getHours()))
.addEvents({
mousewheel: function(e) {
var i = e.target, v = i.get('value').toInt();
i.focus();
if (e.wheel > 0) {
v = (v < 23) ? v + 1 : 0;
} else {
v = (v > 0) ? v - 1 : 23;
}
i.set('value', this.leadZero(v));
e.stop();
}.bind(this)
})
.set('maxlength', 2)
.inject(container);
new Element('input', { type: 'text', 'class': 'minutes' })
.set('value', this.leadZero(this.d.getMinutes()))
.addEvents({
mousewheel: function(e) {
var i = e.target, v = i.get('value').toInt();
i.focus();
if (e.wheel > 0) {
v = (v < 59) ? v + 1 : 0;
} else {
v = (v > 0) ? v - 1 : 59;
}
i.set('value', this.leadZero(v));
e.stop();
}.bind(this)
})
.set('maxlength', 2)
.inject(container);
new Element('div', { 'class': 'separator' }).set('text', ':').inject(container);
new Element('input', { type: 'submit', value: 'OK', 'class': 'ok' })
.addEvents({
click: function(e) {
e.stop();
this.select($merge(this.dateToObject(this.d), { hours: this.picker.getElement('.hour').get('value').toInt(), minutes: this.picker.getElement('.minutes').get('value').toInt() }));
}.bind(this)
})
.set('maxlength', 2)
.inject(container);
},
renderMonth: function() {
var month = this.d.getMonth();
this.picker.getElement('.titleText').set('text', this.options.months[month] + ' ' + this.d.getFullYear());
this.d.setDate(1);
while (this.d.getDay() != this.options.startDay) {
this.d.setDate(this.d.getDate() - 1);
}
var container = new Element('div', { 'class': 'days' }).inject(this.newContents);
var titles = new Element('div', { 'class': 'titles' }).inject(container);
var d, i, classes, e, weekcontainer;
for (d = this.options.startDay; d < (this.options.startDay + 7); d++) {
new Element('div', { 'class': 'title day day' + (d % 7) }).set('text', this.options.days[(d % 7)].substring(0,this.options.dayShort)).inject(titles);
}
var available = false;
var t = this.today.toDateString();
var currentChoice = this.dateFromObject(this.choice).toDateString();
for (i = 0; i < 42; i++) {
classes = [];
classes.push('day');
classes.push('day'+this.d.getDay());
if (this.d.toDateString() == t) classes.push('today');
if (this.d.toDateString() == currentChoice) classes.push('selected');
if (this.d.getMonth() != month) classes.push('otherMonth');
if (i % 7 == 0) {
weekcontainer = new Element('div', { 'class': 'week week'+(Math.floor(i/7)) }).inject(container);
}
e = new Element('div', { 'class': classes.join(' ') }).set('text', this.d.getDate()).inject(weekcontainer);
if (this.limited('date')) {
e.addClass('unavailable');
if (available) {
this.limit.right = true;
} else if (this.d.getMonth() == month) {
this.limit.left = true;
}
} else {
available = true;
e.addEvent('click', function(e, d) {
if (this.options.timePicker) {
this.d.setDate(d.day);
this.d.setMonth(d.month);
this.mode = 'time';
this.render('fade');
} else {
this.select($merge(d, { hours: 0, minutes: 0 }));
}
}.bindWithEvent(this, { day: this.d.getDate(), month: this.d.getMonth(), year: this.d.getFullYear() }));
}
this.d.setDate(this.d.getDate() + 1);
}
if (!available) this.limit.right = true;
},
renderYear: function() {
var month = this.today.getMonth();
var thisyear = this.d.getFullYear() == this.today.getFullYear();
var selectedyear = this.d.getFullYear() == this.choice.year;
this.picker.getElement('.titleText').set('text', this.d.getFullYear());
this.d.setMonth(0);
var i, e;
var available = false;
var container = new Element('div', { 'class': 'months' }).inject(this.newContents);
for (i = 0; i <= 11; i++) {
e = new Element('div', { 'class': 'month month'+(i+1)+(i == month && thisyear ? ' today' : '')+(i == this.choice.month && selectedyear ? ' selected' : '') })
.set('text', this.options.monthShort ? this.options.months[i].substring(0, this.options.monthShort) : this.options.months[i]).inject(container);
if (this.limited('month')) {
e.addClass('unavailable');
if (available) {
this.limit.right = true;
} else {
this.limit.left = true;
}
} else {
available = true;
e.addEvent('click', function(e, d) {
this.d.setDate(1);
this.d.setMonth(d);
this.mode = 'month';
this.render('fade');
}.bindWithEvent(this, i));
}
this.d.setMonth(i);
}
if (!available) this.limit.right = true;
},
renderDecades: function() {
while (this.d.getFullYear() % this.options.yearsPerPage > 0) {
this.d.setFullYear(this.d.getFullYear() - 1);
}
this.picker.getElement('.titleText').set('text', this.d.getFullYear() + '-' + (this.d.getFullYear() + this.options.yearsPerPage - 1));
var i, y, e;
var available = false;
var container = new Element('div', { 'class': 'years' }).inject(this.newContents);
if ($chk(this.options.minDate) && this.d.getFullYear() <= this.options.minDate.getFullYear()) {
this.limit.left = true;
}
for (i = 0; i < this.options.yearsPerPage; i++) {
y = this.d.getFullYear();
e = new Element('div', { 'class': 'year year' + i + (y == this.today.getFullYear() ? ' today' : '') + (y == this.choice.year ? ' selected' : '') }).set('text', y).inject(container);
if (this.limited('year')) {
e.addClass('unavailable');
if (available) {
this.limit.right = true;
} else {
this.limit.left = true;
}
} else {
available = true;
e.addEvent('click', function(e, d) {
this.d.setFullYear(d);
this.mode = 'year';
this.render('fade');
}.bindWithEvent(this, y));
}
this.d.setFullYear(this.d.getFullYear() + 1);
}
if (!available) {
this.limit.right = true;
}
if ($chk(this.options.maxDate) && this.d.getFullYear() >= this.options.maxDate.getFullYear()) {
this.limit.right = true;
}
},
limited: function(type) {
var cs = $chk(this.options.minDate);
var ce = $chk(this.options.maxDate);
if (!cs && !ce) return false;
switch (type) {
case 'year':
return (cs && this.d.getFullYear() < this.options.minDate.getFullYear()) || (ce && this.d.getFullYear() > this.options.maxDate.getFullYear());
case 'month':
var ms = ('' + this.d.getFullYear() + this.leadZero(this.d.getMonth())).toInt();
return cs && ms < ('' + this.options.minDate.getFullYear() + this.leadZero(this.options.minDate.getMonth())).toInt()
|| ce && ms > ('' + this.options.maxDate.getFullYear() + this.leadZero(this.options.maxDate.getMonth())).toInt()
case 'date':
return (cs && this.d < this.options.minDate) || (ce && this.d > this.options.maxDate);
}
},
allowZoomOut: function() {
if (this.mode == 'time' && this.options.timePickerOnly) return false;
if (this.mode == 'decades') return false;
if (this.mode == 'year' && !this.options.yearPicker) return false;
return true;
},
zoomOut: function() {
if (!this.allowZoomOut()) return;
if (this.mode == 'year') {
this.mode = 'decades';
} else if (this.mode == 'time') {
this.mode = 'month';
} else {
this.mode = 'year';
}
this.render('fade');
},
previous: function() {
if (this.mode == 'decades') {
this.d.setFullYear(this.d.getFullYear() - this.options.yearsPerPage);
} else if (this.mode == 'year') {
this.d.setFullYear(this.d.getFullYear() - 1);
} else if (this.mode == 'month') {
this.d.setMonth(this.d.getMonth() - 1);
}
this.render('left');
},
next: function() {
if (this.mode == 'decades') {
this.d.setFullYear(this.d.getFullYear() + this.options.yearsPerPage);
} else if (this.mode == 'year') {
this.d.setFullYear(this.d.getFullYear() + 1);
} else if (this.mode == 'month') {
this.d.setMonth(this.d.getMonth() + 1);
}
this.render('right');
},
close: function(e, force) {
if (!$(this.picker)) return;
var clickOutside = ($chk(e) && e.target != this.picker && !this.picker.hasChild(e.target) && e.target != this.visual);
if (force || clickOutside) {
if (this.options.useFadeInOut) {
this.picker.set('tween', { duration: this.options.animationDuration / 2, onComplete: this.destroy.bind(this) }).tween('opacity', 1, 0);
} else {
this.destroy();
}
}
},
destroy: function() {
this.picker.destroy();
this.picker = null;
this.options.onClose();
},
select: function(values) {
this.choice = $merge(this.choice, values);
var d = this.dateFromObject(this.choice);
this.input.set('value', this.format(d, this.options.inputOutputFormat));
this.visual.set('value', this.format(d, this.options.format));
this.options.onSelect(d);
this.close(null, true);
},
leadZero: function(v) {
return v < 10 ? '0'+v : v;
},
format: function(t, format) {
var f = '';
var h = t.getHours();
var m = t.getMonth();
for (var i = 0; i < format.length; i++) {
switch(format.charAt(i)) {
case '\\': i++; f+= format.charAt(i); break;
case 'y': f += (100 + t.getYear() + '').substring(1); break
case 'Y': f += t.getFullYear(); break;
case 'm': f += this.leadZero(m + 1); break;
case 'n': f += (m + 1); break;
case 'M': f += this.options.months[m].substring(0,this.options.monthShort); break;
case 'F': f += this.options.months[m]; break;
case 'd': f += this.leadZero(t.getDate()); break;
case 'j': f += t.getDate(); break;
case 'D': f += this.options.days[t.getDay()].substring(0,this.options.dayShort); break;
case 'l': f += this.options.days[t.getDay()]; break;
case 'G': f += h; break;
case 'H': f += this.leadZero(h); break;
case 'g': f += (h % 12 ? h % 12 : 12); break;
case 'h': f += this.leadZero(h % 12 ? h % 12 : 12); break;
case 'a': f += (h > 11 ? 'pm' : 'am'); break;
case 'A': f += (h > 11 ? 'PM' : 'AM'); break;
case 'i': f += this.leadZero(t.getMinutes()); break;
case 's': f += this.leadZero(t.getSeconds()); break;
case 'U': f += Math.floor(t.valueOf() / 1000); break;
default:  f += format.charAt(i);
}
}
return f;
},
unformat: function(t, format) {
var d = new Date();
var a = {};
var c, m;
t = t.toString();
for (var i = 0; i < format.length; i++) {
c = format.charAt(i);
switch(c) {
case '\\': r = null; i++; break;
case 'y': r = '[0-9]{2}'; break;
case 'Y': r = '[0-9]{4}'; break;
case 'm': r = '0[1-9]|1[012]'; break;
case 'n': r = '[1-9]|1[012]'; break;
case 'M': r = '[A-Za-z]{'+this.options.monthShort+'}'; break;
case 'F': r = '[A-Za-z]+'; break;
case 'd': r = '0[1-9]|[12][0-9]|3[01]'; break;
case 'j': r = '[1-9]|[12][0-9]|3[01]'; break;
case 'D': r = '[A-Za-z]{'+this.options.dayShort+'}'; break;
case 'l': r = '[A-Za-z]+'; break;
case 'G':
case 'H':
case 'g':
case 'h': r = '[0-9]{1,2}'; break;
case 'a': r = '(am|pm)'; break;
case 'A': r = '(AM|PM)'; break;
case 'i':
case 's': r = '[012345][0-9]'; break;
case 'U': r = '-?[0-9]+$'; break;
default:  r = null;
}
if ($chk(r)) {
m = t.match('^'+r);
if ($chk(m)) {
a[c] = m[0];
t = t.substring(a[c].length);
} else {
if (this.options.debug) alert("Fatal Error in DatePicker\n\nUnexpected format at: '"+t+"' expected format character '"+c+"' (pattern '"+r+"')");
return d;
}
} else {
t = t.substring(1);
}
}
for (c in a) {
var v = a[c];
switch(c) {
case 'y': d.setFullYear(v < 30 ? 2000 + v.toInt() : 1900 + v.toInt()); break; // assume between 1930 - 2029
case 'Y': d.setFullYear(v); break;
case 'm':
case 'n': d.setMonth(v - 1); break;
case 'M': v = this.options.months.filter(function(item, index) { return item.substring(0,this.options.monthShort) == v }.bind(this))[0];
case 'F': d.setMonth(this.options.months.indexOf(v)); break;
case 'd':
case 'j': d.setDate(v); break;
case 'G':
case 'H': d.setHours(v); break;
case 'g':
case 'h': if (a['a'] == 'pm' || a['A'] == 'PM') { d.setHours(v == 12 ? 0 : v.toInt() + 12); } else { d.setHours(v); } break;
case 'i': d.setMinutes(v); break;
case 's': d.setSeconds(v); break;
case 'U': d = new Date(v.toInt() * 1000);
}
};
return d;
}
});
var NXC = NXC || {};
NXC.AJAXContainer = new Class( {
Implements: [Options, Events],
container: false,
loadMore: false,
loader: false,
displayed: 0,
portion: 10,
options: {
'loaderID'  : 'nxc-ajaxcontainer-loader',
'ajaxURL'   : 'get_elements.php?offset=%displayed%&limit=%portion%',
'displayed' : 0,
'portion'   : 10,
'onLoad'    : $empty
},
initialize: function( containerID, loadMoreID, options ) {
this.setOptions( options );
this.container = document.id( containerID );
this.loadMore  = document.id( loadMoreID );
this.loader    = document.id( this.options.loaderID );
if( $type( this.loader ) == 'element' ) {
this.loader.setStyle( 'display', 'none' );
}
this.displayed = this.options.displayed;
this.portion   = this.options.portion;
this.installEvents();
if( this.displayed == 0 ) {
this.loadElements();
}
},
installEvents: function() {
this.loadMore.addEvent( 'click', function( e ) {
this.loadElements();e.stop();
}.bind( this ) );
},
loadElements: function() {
this.loadMore.setStyle( 'display', 'none' );
if( $type( this.loader ) == 'element' ) {
this.loader.setStyle( 'display', 'block' );
}
var url = this.options.ajaxURL.replace( '%displayed%', this.displayed ).replace( '%portion%', this.portion );
new Request.JSON( {
url: url,
onSuccess: function( response ) {
response = new Hash( response );
if( $type( this.loader ) == 'element' ) {
this.loader.setStyle( 'display', 'none' );
}
this.container.set( 'html', this.container.get( 'html' ) + response.get( 'html' ) );
this.displayed += this.portion;
if( response.has( 'totalObjectsCount' ) === false ) {
this.loadMore.setStyle( 'display', 'block' );
} else if( response.get( 'totalObjectsCount' ) > this.displayed ) {
this.loadMore.setStyle( 'display', 'block' );
}
this.fireEvent( 'load' );
}.bind( this )
} ).send();
}
} );
var NXC = NXC || {};
NXC.LightBox = new Class( {
Implements: [Options, Events],
options:{
'overlayOpacity' : 0.5,
'topPosition'    : 50,
'bgColor'        : '2A2A2A',
'shadow'         : true,
'outerCloser'    : true,
'closer'         : true,
'onOpen'         : $empty,
'onSetContent'   : function( el ) { el.setStyle( 'display', 'block' ) },
'onClose'        : $empty
},
opened       : false,
contentBlock : new Element( 'div' ),
initialize: function( options ) {
this.setOptions( options );
this.prepareHTML();
},
prepareHTML: function() {
this.overlay = new Element( 'div', {
'class': 'nxc-lightbox-overlay',
'styles': {
'opacity'          : 0,
'visibility'       : 'visible',
'height'           : 0,
'overflow'         : 'hidden',
'background-color' : '#' + this.options.bgColor
}
} ).inject( document.id( document.body ) );
this.overlay.get( 'tween' ).addEvent( 'onComplete', function() {
if( this.overlay.getStyle( 'opacity' ) == 0 ) {
this.overlay.setStyles( {
'height': 0,
'top': ''
} );
};
}.bindWithEvent( this ) );
window.addEvent( 'resize', function() {
if( this.overlay.getStyle( 'opacity' ) != 0 ) {
var scrollSize = document.id( window ).getScrollSize().y;
var scrollTop = document.id( window ).getScroll().y;
this.overlay.setStyles( {
'height': scrollSize + scrollTop,
'top': -scrollTop
} );
}
}.bindWithEvent(this));
this.center = new Element( 'div', {
'class': 'nxc-lightbox-center',
'styles': {
'opacity': 0
}
} ).inject( document.id( document.body ) );
if( this.options.shadow ) {
if( !Browser.Engine.trident4 ) {
var shadow = new Element( 'div', { 'class': 'nxc-lightbox-bg-wrap' } ).inject( this.center );
['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'].each( function( dir ) {
new Element( 'div', { 'class': 'nxc-lightbox-bg nxc-lightbox-bg-' + dir } ).inject( shadow );
} );
}
}
if( this.options.closer ) {
var closer = new Element('a', {
'class': 'nxc-lightbox-btn-close',
'events': { 'click': this.close.bind( this ) }
} ).inject( this.center );
}
if( this.options.outerCloser ) {
this.overlay.addEvent( 'click', function() {
this.close();
}.bind( this ) );
}
},
setContent: function( el, clone ) {
el = document.id( el );
if( el === false ) {
return false;
}
if( clone === undefined ) {
clone = true;
}
this.contentBlock.destroy();
if( clone ) {
this.contentBlock = el.clone( true, true ).cloneEvents( el );
} else {
this.contentBlock = el;
}
this.contentBlock.inject( this.center );
this.fireEvent( 'setContent', this.contentBlock );
this.setCenterPosition();
},
setCenterPosition: function() {
var width  = this.contentBlock.getStyle( 'width' ).toInt() + this.contentBlock.getStyle( 'padding-left' ).toInt() + this.contentBlock.getStyle( 'padding-right' ).toInt();
this.center.setStyles( {
'width': width + 2,
'margin-left': -1 * ( width / 2 ).toInt()
} );
},
open: function() {
this.opened = true;
this.fireEvent( 'open', this.contentBlock );
this.overlay.setStyles( {
'top': -document.id( window ).getScroll().y,
'height': document.id( window ).getScrollSize().y + document.id( window ).getScroll().y
} );
this.center.setStyle( 'top', document.id( window ).getScroll().y + this.options.topPosition );
this.center.setStyle( 'opacity', 1 );
this.overlay.setStyle( 'z-index', 99 ).tween( 'opacity', this.options.overlayOpacity );
},
close: function() {
this.opened = false;
this.fireEvent( 'close', this.contentBlock );
this.center.setStyle( 'opacity', 0 );
this.overlay.tween( 'opacity', 0 );
}
} );
var NXC = NXC || {};
NXC.ProgressBar = new Class( {
Implements: [Options, Chain],
wrapper: false,
bar: false,
image: false,
test: false,
options: {
'transitionDuration': 500,
'textPattern': 'Loading... %loadPercent%%',
'barCSSPath': 'div.nxc-progress-bar',
'imageCSSPath': 'img.nxc-progress-bar-image',
'textCSSPath': 'div.nxc-progress-bar-text'
},
initialize: function( wrapper, options ) {
this.setOptions( options );
this.wrapper = document.id( wrapper );
this.bar     = this.wrapper.getElement( this.options.barCSSPath );
this.image   = this.wrapper.getElement( this.options.imageCSSPath );
this.text    = this.wrapper.getElement( this.options.textCSSPath );
this.image.setStyle( 'margin-left', -1 * this.image.getStyle( 'width' ).toInt() );
},
progress: function( loadPercent, fx ) {
if( fx === undefined ) {
fx = true;
}
if( loadPercent <= 0 || loadPercent > 100 ) {
return false;
}
var newBarImageMargin = this.getImageOffset( loadPercent );
if( fx ) {
this.image.get( 'tween', { property: 'margin-left', duration: this.options.transitionDuration } ).start( newBarImageMargin );
} else {
this.image.setStyle( 'margin-left', newBarImageMargin );
}
this.text.set( 'html', this.options.textPattern.replace( '%loadPercent%', loadPercent.toFixed( 0 ) ) );
},
getImageOffset: function( loadPercent ) {
var barWidth          = this.bar.getStyle( 'width' ).toInt();
return ( barWidth * ( loadPercent / 100 ) ).toInt() - barWidth;
},
remove: function() {
this.wrapper.get( 'tween', { property: 'opacity', duration: this.options.transitionDuration } ).start( 0 ).chain( function() {
this.wrapper.destroy();
}.bind( this ) );
}
} );
var NXC = NXC || {};
NXC.Tabs = new Class( {
Implements: [Options, Events],
options: {
'transitionDuration': 500,
'startIndex': 0,
'selectedLinkStyle': false,
'selectedTabStyle': false,
'onStart': $empty,
'onComplete': $empty
},
tabs         : [],
links        : [],
currentIndex : 0,
initialize: function( linksSelector, tabsSelector, options ) {
this.links = document.getElements( linksSelector );
this.tabs  = document.getElements( tabsSelector );
this.setOptions( options );
var fragment = new URI().get( 'fragment' );
this.currentIndex = this.options.startIndex;
if( fragment ) {
fragment = decodeURIComponent( fragment );
this.links.each( function( link, index ) {
if( fragment == link.get( 'href' ).replace( '#', '' ) ) {
this.currentIndex = index;
}
}.bind( this ) );
}
this.showStartTab( this.currentIndex );
this.installEvents();
},
installEvents: function() {
this.links.each( function( link, index ) {
link.addEvent( 'click', function( e ) {
e.stop();
if( index !== this.currentIndex ) {
this.showTab( index );
if( link.get( 'href' ) ) {
window.location = new URI().set( 'fragment', link.get( 'href' ).replace( '#', '' ) ).toString();
}
}
}.bind( this ) );
}.bind( this ) );
},
showStartTab: function( index ) {
this.links.removeClass( this.options.selectedLinkStyle );
this.tabs.setStyle( 'display', 'none' );
this.tabs.setStyle( 'opacity', 0 );
this.tabs.removeClass( this.options.selectedTabStyle );
this.tabs[ index ].setStyles( {
'display': 'block',
'opacity': '1'
} ).getParent().setStyle(
'height', this.getContentWrapperHeight( this.tabs[ index ] )
);
if( this.options.selectedLinkStyle !== false ) {
this.links[ index ].addClass( this.options.selectedLinkStyle );
}
if( this.options.selectedTabStyle !== false ) {
this.tabs[ index ].addClass( this.options.selectedTabStyle )
}
this.currentIndex = index;
},
showTab: function( index ) {
var link       = this.links[ index ];
var showTab    = this.tabs[ index ];
var currentTab = this.tabs[ this.currentIndex ];
this.fireEvent( 'start', [ currentTab, showTab ] );
if( this.options.selectedLinkStyle !== false ) {
this.links.removeClass( this.options.selectedLinkStyle );
link.addClass( this.options.selectedLinkStyle );
}
if( this.options.selectedTabStyle !== false ) {
this.tabs.removeClass( this.options.selectedTabStyle );
showTab.addClass( this.options.selectedTabStyle );
}
currentTab.get( 'tween', { property: 'opacity', duration: this.options.transitionDuration } ).start( 0 ).chain( function() {
currentTab.setStyle( 'display', 'none' );
}.bind( this ) );
showTab.setStyle( 'display', 'block' );
showTab.get( 'tween', { property: 'opacity', duration: this.options.transitionDuration } ).start( 1 );
showTab.getParent().get( 'tween', { property: 'height', duration: this.options.transitionDuration } ).start(
this.getContentWrapperHeight( showTab )
).chain( function() {
this.fireEvent( 'complete', [ currentTab, showTab ] );
}.bind( this ) );
this.currentIndex = index;
},
getContentWrapperHeight: function( tab ) {
return tab.getStyle( 'height' ).toInt() + tab.getParent().getStyle( 'padding-top' ).toInt() + tab.getParent().getStyle( 'padding-bottom' ).toInt();
}
} );
var NXC = NXC || {};
NXC.FrontMenu = new Class( {
Implements: [Options, Events],
options:{
'slidesSelector': 'div.nxc-frontmenu-slide-item',
'navigationSelector': 'div.nxc-frontmenu-navigation-item',
'timerDelay': 3000,
'fade': true,
'fadeDuration': 500,
'slideShow': true,
'onShow': $empty,
'onHide': $empty
},
container: false,
slides: [],
navigationLinks: [],
currentSlide: 0,
timer: $empty,
initialize: function( containerID, options ) {
this.setOptions( options );
this.container       = document.id( containerID )
this.slides          = this.container.getElements( this.options.slidesSelector );
this.navigationLinks = this.container.getElements( this.options.navigationSelector );
if( this.slides.length != this.navigationLinks.length ) {
console.log( 'Slides and naviagtion links quantity dosen`t the same' );
return false;
}
this.hideAllSlides();
this.showSlide( this.currentSlide, false );
this.installEvents();
this.installSlideShow();
},
installEvents: function() {
this.navigationLinks.each( function( navigationLink, index ) {
navigationLink.addEvents( {
'mouseover': function(){
this.currentSlide = index;
this.stopTimer();
this.hideAllSlides();
this.showSlide( this.currentSlide, false );
}.bind( this ),
'mouseout': function(){
this.startTimer();
}.bind( this )
} );
}.bind( this ) );
this.slides.addEvents( {
'mouseover': function(){
this.stopTimer();
}.bind( this ),
'mouseout': function(){
this.startTimer();
}.bind( this )
} );
},
installSlideShow: function() {
if( this.options.slideShow ) {
this.startTimer();
}
},
startTimer: function() {
if( this.options.slideShow ) {
this.timer = function() {
this.showNextSlide( this.options.fade );
}.periodical( this.options.timerDelay + this.options.fadeDuration, this );
}
},
stopTimer: function() {
$clear( this.timer );
},
showNextSlide: function( fade ) {
this.hideSlide( this.getPreviousIndex(), fade);
this.showSlide( this.currentSlide, fade );
},
showPreviousSlide: function( fade ) {
var prevIndex = this.getPreviousIndex();
var showIndex = ( prevIndex == 0 ) ? this.slides.length - 1 : prevIndex - 1;
this.hideSlide( prevIndex, fade );
this.showSlide( showIndex, fade );
},
showSlide: function( index, fade ) {
var index = $defined( index ) ? index : this.currentSlide;
var fade  = $defined( fade ) ? fade : true;
var slide = this.slides[ index ];
slide.setStyle( 'display', 'block' );
if( fade ) {
slide.get( 'tween', { property: 'opacity', duration: this.options.fadeDuration } ).start( 1 ).chain(
this.fireEvent.bind( this, [ 'show', index ] )
);
} else {
slide.get( 'tween' ).cancel();
slide.setStyle( 'opacity', 1 );
this.fireEvent( 'show', index );
}
if( index == ( this.slides.length - 1 ) ) {
this.currentSlide = 0;
} else {
this.currentSlide = index + 1;
}
},
hideSlide: function( index, fade ) {
var fade  = $defined( fade ) ? fade : true;
var index = $defined( index ) ? index : this.getPreviousIndex();
var slide = this.slides[index];
if( fade ) {
slide.get( 'tween', { 'property': 'opacity', 'duration': this.options.fadeDuration } ).start( 0 ).chain(
function() {
slide.setStyle( 'display', 'none' );
this.fireEvent( 'hide', index );
}
);
} else {
slide.setStyles( {
'display': 'none',
'opacity': 0
} );
this.fireEvent( 'hide', index );
}
},
hideAllSlides: function() {
this.slides.each( function( slide, index ) {
this.hideSlide( index, false );
}.bind( this ) );
},
getPreviousIndex: function() {
return ( this.currentSlide == 0 ) ? this.slides.length - 1 : this.currentSlide - 1;
}
} );
var Cufon = (function() {
var api = function() {
return api.replace.apply(null, arguments);
};
var DOM = api.DOM = {
ready: (function() {
var complete = false, readyStatus = { loaded: 1, complete: 1 };
var queue = [], perform = function() {
if (complete) return;
complete = true;
for (var fn; fn = queue.shift(); fn());
};
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', perform, false);
window.addEventListener('pageshow', perform, false); // For cached Gecko pages
}
if (!window.opera && document.readyState) (function() {
readyStatus[document.readyState] ? perform() : setTimeout(arguments.callee, 10);
})();
if (document.readyState && document.createStyleSheet) (function() {
try {
document.body.doScroll('left');
perform();
}
catch (e) {
setTimeout(arguments.callee, 1);
}
})();
addEvent(window, 'load', perform); // Fallback
return function(listener) {
if (!arguments.length) perform();
else complete ? listener() : queue.push(listener);
};
})(),
root: function() {
return document.documentElement || document.body;
},
strict: (function() {
var doctype;
if (document.compatMode == 'BackCompat') return false;
doctype = document.doctype;
if (doctype) {
return !/frameset|transitional/i.test(doctype.publicId);
}
doctype = document.firstChild;
if (doctype.nodeType != 8 || /^DOCTYPE.+(transitional|frameset)/i.test(doctype.data)) {
return false;
}
return true;
})()
};
var CSS = api.CSS = {
Size: function(value, base) {
this.value = parseFloat(value);
this.unit = String(value).match(/[a-z%]*$/)[0] || 'px';
this.convert = function(value) {
return value / base * this.value;
};
this.convertFrom = function(value) {
return value / this.value * base;
};
this.toString = function() {
return this.value + this.unit;
};
},
addClass: function(el, className) {
var current = el.className;
el.className = current + (current && ' ') + className;
return el;
},
color: cached(function(value) {
var parsed = {};
parsed.color = value.replace(/^rgba\((.*?),\s*([\d.]+)\)/, function($0, $1, $2) {
parsed.opacity = parseFloat($2);
return 'rgb(' + $1 + ')';
});
return parsed;
}),
fontStretch: cached(function(value) {
if (typeof value == 'number') return value;
if (/%$/.test(value)) return parseFloat(value) / 100;
return {
'ultra-condensed': 0.5,
'extra-condensed': 0.625,
condensed: 0.75,
'semi-condensed': 0.875,
'semi-expanded': 1.125,
expanded: 1.25,
'extra-expanded': 1.5,
'ultra-expanded': 2
}[value] || 1;
}),
getStyle: function(el) {
var view = document.defaultView;
if (view && view.getComputedStyle) return new Style(view.getComputedStyle(el, null));
if (el.currentStyle) return new Style(el.currentStyle);
return new Style(el.style);
},
gradient: cached(function(value) {
var gradient = {
id: value,
type: value.match(/^-([a-z]+)-gradient\(/)[1],
stops: []
}, colors = value.substr(value.indexOf('(')).match(/([\d.]+=)?(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)/ig);
for (var i = 0, l = colors.length, stop; i < l; ++i) {
stop = colors[i].split('=', 2).reverse();
gradient.stops.push([ stop[1] || i / (l - 1), stop[0] ]);
}
return gradient;
}),
quotedList: cached(function(value) {
var list = [], re = /\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g, match;
while (match = re.exec(value)) list.push(match[3] || match[1]);
return list;
}),
recognizesMedia: cached(function(media) {
var el = document.createElement('style'), sheet, container, supported;
el.type = 'text/css';
el.media = media;
try { // this is cached anyway
el.appendChild(document.createTextNode('/**/'));
} catch (e) {}
container = elementsByTagName('head')[0];
container.insertBefore(el, container.firstChild);
sheet = (el.sheet || el.styleSheet);
supported = sheet && !sheet.disabled;
container.removeChild(el);
return supported;
}),
removeClass: function(el, className) {
var re = RegExp('(?:^|\\s+)' + className +  '(?=\\s|$)', 'g');
el.className = el.className.replace(re, '');
return el;
},
supports: function(property, value) {
var checker = document.createElement('span').style;
if (checker[property] === undefined) return false;
checker[property] = value;
return checker[property] === value;
},
textAlign: function(word, style, position, wordCount) {
if (style.get('textAlign') == 'right') {
if (position > 0) word = ' ' + word;
}
else if (position < wordCount - 1) word += ' ';
return word;
},
textShadow: cached(function(value) {
if (value == 'none') return null;
var shadows = [], currentShadow = {}, result, offCount = 0;
var re = /(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;
while (result = re.exec(value)) {
if (result[0] == ',') {
shadows.push(currentShadow);
currentShadow = {};
offCount = 0;
}
else if (result[1]) {
currentShadow.color = result[1];
}
else {
currentShadow[[ 'offX', 'offY', 'blur' ][offCount++]] = result[2];
}
}
shadows.push(currentShadow);
return shadows;
}),
textTransform: (function() {
var map = {
uppercase: function(s) {
return s.toUpperCase();
},
lowercase: function(s) {
return s.toLowerCase();
},
capitalize: function(s) {
return s.replace(/(?:^|\s)./g, function($0) {
return $0.toUpperCase();
});
}
};
return function(text, style) {
var transform = map[style.get('textTransform')];
return transform ? transform(text) : text;
};
})(),
whiteSpace: (function() {
var ignore = {
inline: 1,
'inline-block': 1,
'run-in': 1
};
var wsStart = /^\s+/, wsEnd = /\s+$/;
return function(text, style, node, previousElement, simple) {
if (simple) return text.replace(wsStart, '').replace(wsEnd, ''); // @fixme too simple
if (previousElement) {
if (previousElement.nodeName.toLowerCase() == 'br') {
text = text.replace(wsStart, '');
}
}
if (ignore[style.get('display')]) return text;
if (!node.previousSibling) text = text.replace(wsStart, '');
if (!node.nextSibling) text = text.replace(wsEnd, '');
return text;
};
})()
};
CSS.ready = (function() {
var complete = !CSS.recognizesMedia('all'), hasLayout = false;
var queue = [], perform = function() {
complete = true;
for (var fn; fn = queue.shift(); fn());
};
var links = elementsByTagName('link'), styles = elementsByTagName('style');
var checkTypes = {
'': 1,
'text/css': 1
};
function isContainerReady(el) {
if (!checkTypes[el.type.toLowerCase()]) return true;
return el.disabled || isSheetReady(el.sheet, el.media || 'screen');
}
function isSheetReady(sheet, media) {
if (!CSS.recognizesMedia(media || 'all')) return true;
if (!sheet || sheet.disabled) return false;
try {
var rules = sheet.cssRules, rule;
if (rules) {
search: for (var i = 0, l = rules.length; rule = rules[i], i < l; ++i) {
switch (rule.type) {
case 2: // @charset
break;
case 3: // @import
if (!isSheetReady(rule.styleSheet, rule.media.mediaText)) return false;
break;
default:
break search;
}
}
}
}
catch (e) {} // probably a style sheet from another domain
return true;
}
function allStylesLoaded() {
if (document.createStyleSheet) return true;
var el, i;
for (i = 0; el = links[i]; ++i) {
if (el.rel.toLowerCase() == 'stylesheet' && !isContainerReady(el)) return false;
}
for (i = 0; el = styles[i]; ++i) {
if (!isContainerReady(el)) return false;
}
return true;
}
DOM.ready(function() {
if (!hasLayout) hasLayout = CSS.getStyle(document.body).isUsable();
if (complete || (hasLayout && allStylesLoaded())) perform();
else setTimeout(arguments.callee, 10);
});
return function(listener) {
if (complete) listener();
else queue.push(listener);
};
})();
function Font(data) {
var face = this.face = data.face, wordSeparators = {
'\u0020': 1,
'\u00a0': 1,
'\u3000': 1
};
this.glyphs = (function(glyphs) {
var key, fallbacks = {
'\u2011': '\u002d',
'\u00ad': '\u2011'
};
for (key in fallbacks) {
if (!hasOwnProperty(fallbacks, key)) continue;
if (!glyphs[key]) glyphs[key] = glyphs[fallbacks[key]];
}
return glyphs;
})(data.glyphs);
this.w = data.w;
this.baseSize = parseInt(face['units-per-em'], 10);
this.family = face['font-family'].toLowerCase();
this.weight = face['font-weight'];
this.style = face['font-style'] || 'normal';
this.viewBox = (function () {
var parts = face.bbox.split(/\s+/);
var box = {
minX: parseInt(parts[0], 10),
minY: parseInt(parts[1], 10),
maxX: parseInt(parts[2], 10),
maxY: parseInt(parts[3], 10)
};
box.width = box.maxX - box.minX;
box.height = box.maxY - box.minY;
box.toString = function() {
return [ this.minX, this.minY, this.width, this.height ].join(' ');
};
return box;
})();
this.ascent = -parseInt(face.ascent, 10);
this.descent = -parseInt(face.descent, 10);
this.height = -this.ascent + this.descent;
this.spacing = function(chars, letterSpacing, wordSpacing) {
var glyphs = this.glyphs, glyph,
kerning, k,
jumps = [],
width = 0, w,
i = -1, j = -1, chr;
while (chr = chars[++i]) {
glyph = glyphs[chr] || this.missingGlyph;
if (!glyph) continue;
if (kerning) {
width -= k = kerning[chr] || 0;
jumps[j] -= k;
}
w = glyph.w;
if (isNaN(w)) w = +this.w; // may have been a String in old fonts
if (w > 0) {
w += letterSpacing;
if (wordSeparators[chr]) w += wordSpacing;
}
width += jumps[++j] = ~~w; // get rid of decimals
kerning = glyph.k;
}
jumps.total = width;
return jumps;
};
}
function FontFamily() {
var styles = {}, mapping = {
oblique: 'italic',
italic: 'oblique'
};
this.add = function(font) {
(styles[font.style] || (styles[font.style] = {}))[font.weight] = font;
};
this.get = function(style, weight) {
var weights = styles[style] || styles[mapping[style]]
|| styles.normal || styles.italic || styles.oblique;
if (!weights) return null;
weight = {
normal: 400,
bold: 700
}[weight] || parseInt(weight, 10);
if (weights[weight]) return weights[weight];
var up = {
1: 1,
99: 0
}[weight % 100], alts = [], min, max;
if (up === undefined) up = weight > 400;
if (weight == 500) weight = 400;
for (var alt in weights) {
if (!hasOwnProperty(weights, alt)) continue;
alt = parseInt(alt, 10);
if (!min || alt < min) min = alt;
if (!max || alt > max) max = alt;
alts.push(alt);
}
if (weight < min) weight = min;
if (weight > max) weight = max;
alts.sort(function(a, b) {
return (up
? (a >= weight && b >= weight) ? a < b : a > b
: (a <= weight && b <= weight) ? a > b : a < b) ? -1 : 1;
});
return weights[alts[0]];
};
}
function HoverHandler() {
function contains(node, anotherNode) {
try {
if (node.contains) return node.contains(anotherNode);
return node.compareDocumentPosition(anotherNode) & 16;
}
catch(e) {} // probably a XUL element such as a scrollbar
return false;
}
function onOverOut(e) {
var related = e.relatedTarget;
if (related && contains(this, related)) return;
trigger(this, e.type == 'mouseover');
}
function onEnterLeave(e) {
if (!e) e = window.event;
trigger(e.target || e.srcElement, e.type == 'mouseenter');
}
function trigger(el, hoverState) {
setTimeout(function() {
var options = sharedStorage.get(el).options;
if (hoverState) {
options = merge(options, options.hover);
options._mediatorMode = 1;
}
api.replace(el, options, true);
}, 10);
}
this.attach = function(el) {
if (el.onmouseenter === undefined) {
addEvent(el, 'mouseover', onOverOut);
addEvent(el, 'mouseout', onOverOut);
}
else {
addEvent(el, 'mouseenter', onEnterLeave);
addEvent(el, 'mouseleave', onEnterLeave);
}
};
this.detach = function(el) {
if (el.onmouseenter === undefined) {
removeEvent(el, 'mouseover', onOverOut);
removeEvent(el, 'mouseout', onOverOut);
}
else {
removeEvent(el, 'mouseenter', onEnterLeave);
removeEvent(el, 'mouseleave', onEnterLeave);
}
};
}
function ReplaceHistory() {
var list = [], map = {};
function filter(keys) {
var values = [], key;
for (var i = 0; key = keys[i]; ++i) values[i] = list[map[key]];
return values;
}
this.add = function(key, args) {
map[key] = list.push(args) - 1;
};
this.repeat = function() {
var snapshot = arguments.length ? filter(arguments) : list, args;
for (var i = 0; args = snapshot[i++];) api.replace(args[0], args[1], true);
};
}
function Storage() {
var map = {}, at = 0;
function identify(el) {
return el.cufid || (el.cufid = ++at);
}
this.get = function(el) {
var id = identify(el);
return map[id] || (map[id] = {});
};
}
function Style(style) {
var custom = {}, sizes = {};
this.extend = function(styles) {
for (var property in styles) {
if (hasOwnProperty(styles, property)) custom[property] = styles[property];
}
return this;
};
this.get = function(property) {
return custom[property] != undefined ? custom[property] : style[property];
};
this.getSize = function(property, base) {
return sizes[property] || (sizes[property] = new CSS.Size(this.get(property), base));
};
this.isUsable = function() {
return !!style;
};
}
function addEvent(el, type, listener) {
if (el.addEventListener) {
el.addEventListener(type, listener, false);
}
else if (el.attachEvent) {
el.attachEvent('on' + type, listener);
}
}
function attach(el, options) {
if (options._mediatorMode) return el;
var storage = sharedStorage.get(el);
var oldOptions = storage.options;
if (oldOptions) {
if (oldOptions === options) return el;
if (oldOptions.hover) hoverHandler.detach(el);
}
if (options.hover && options.hoverables[el.nodeName.toLowerCase()]) {
hoverHandler.attach(el);
}
storage.options = options;
return el;
}
function cached(fun) {
var cache = {};
return function(key) {
if (!hasOwnProperty(cache, key)) cache[key] = fun.apply(null, arguments);
return cache[key];
};
}
function getFont(el, style) {
var families = CSS.quotedList(style.get('fontFamily').toLowerCase()), family;
for (var i = 0; family = families[i]; ++i) {
if (fonts[family]) return fonts[family].get(style.get('fontStyle'), style.get('fontWeight'));
}
return null;
}
function elementsByTagName(query) {
return document.getElementsByTagName(query);
}
function hasOwnProperty(obj, property) {
return obj.hasOwnProperty(property);
}
function merge() {
var merged = {}, arg, key;
for (var i = 0, l = arguments.length; arg = arguments[i], i < l; ++i) {
for (key in arg) {
if (hasOwnProperty(arg, key)) merged[key] = arg[key];
}
}
return merged;
}
function process(font, text, style, options, node, el) {
var fragment = document.createDocumentFragment(), processed;
if (text === '') return fragment;
var separate = options.separate;
var parts = text.split(separators[separate]), needsAligning = (separate == 'words');
if (needsAligning && HAS_BROKEN_REGEXP) {
if (/^\s/.test(text)) parts.unshift('');
if (/\s$/.test(text)) parts.push('');
}
for (var i = 0, l = parts.length; i < l; ++i) {
processed = engines[options.engine](font,
needsAligning ? CSS.textAlign(parts[i], style, i, l) : parts[i],
style, options, node, el, i < l - 1);
if (processed) fragment.appendChild(processed);
}
return fragment;
}
function removeEvent(el, type, listener) {
if (el.removeEventListener) {
el.removeEventListener(type, listener, false);
}
else if (el.detachEvent) {
el.detachEvent('on' + type, listener);
}
}
function replaceElement(el, options) {
var name = el.nodeName.toLowerCase();
if (options.ignore[name]) return;
if (options.ignoreClass && options.ignoreClass.test(el.className)) return;
if (options.onBeforeReplace) options.onBeforeReplace(el, options);
var replace = !options.textless[name], simple = (options.trim === 'simple');
var style = CSS.getStyle(attach(el, options)).extend(options);
if (parseFloat(style.get('fontSize')) === 0) return;
var font = getFont(el, style), node, type, next, anchor, text, lastElement;
var isShy = options.softHyphens, anyShy = false, pos, shy, reShy = /\u00ad/g;
var modifyText = options.modifyText;
if (!font) return;
for (node = el.firstChild; node; node = next) {
type = node.nodeType;
next = node.nextSibling;
if (replace && type == 3) {
if (isShy && el.nodeName.toLowerCase() != TAG_SHY) {
pos = node.data.indexOf('\u00ad');
if (pos >= 0) {
node.splitText(pos);
next = node.nextSibling;
next.deleteData(0, 1);
shy = document.createElement(TAG_SHY);
shy.appendChild(document.createTextNode('\u00ad'));
el.insertBefore(shy, next);
next = shy;
anyShy = true;
}
}
if (anchor) {
anchor.appendData(node.data);
el.removeChild(node);
}
else anchor = node;
if (next) continue;
}
if (anchor) {
text = anchor.data;
if (!isShy) text = text.replace(reShy, '');
text = CSS.whiteSpace(text, style, anchor, lastElement, simple);
if (modifyText) text = modifyText(text, anchor, el, options);
el.replaceChild(process(font, text, style, options, node, el), anchor);
anchor = null;
}
if (type == 1) {
if (node.firstChild) {
if (node.nodeName.toLowerCase() == 'cufon') {
engines[options.engine](font, null, style, options, node, el);
}
else arguments.callee(node, options);
}
lastElement = node;
}
}
if (isShy && anyShy) {
updateShy(el);
if (!trackingShy) addEvent(window, 'resize', updateShyOnResize);
trackingShy = true;
}
if (options.onAfterReplace) options.onAfterReplace(el, options);
}
function updateShy(context) {
var shys, shy, parent, glue, newGlue, next, prev, i;
shys = context.getElementsByTagName(TAG_SHY);
for (i = 0; shy = shys[i]; ++i) {
shy.className = C_SHY_DISABLED;
glue = parent = shy.parentNode;
if (glue.nodeName.toLowerCase() != TAG_GLUE) {
newGlue = document.createElement(TAG_GLUE);
newGlue.appendChild(shy.previousSibling);
parent.insertBefore(newGlue, shy);
newGlue.appendChild(shy);
}
else {
glue = glue.parentNode;
if (glue.nodeName.toLowerCase() == TAG_GLUE) {
parent = glue.parentNode;
while (glue.firstChild) {
parent.insertBefore(glue.firstChild, glue);
}
parent.removeChild(glue);
}
}
}
for (i = 0; shy = shys[i]; ++i) {
shy.className = '';
glue = shy.parentNode;
parent = glue.parentNode;
next = glue.nextSibling || parent.nextSibling;
prev = (next.nodeName.toLowerCase() == TAG_GLUE) ? glue : shy.previousSibling;
if (prev.offsetTop >= next.offsetTop) {
shy.className = C_SHY_DISABLED;
if (prev.offsetTop < next.offsetTop) {
newGlue = document.createElement(TAG_GLUE);
parent.insertBefore(newGlue, glue);
newGlue.appendChild(glue);
newGlue.appendChild(next);
}
}
}
}
function updateShyOnResize() {
if (ignoreResize) return; // needed for IE
CSS.addClass(DOM.root(), C_VIEWPORT_RESIZING);
clearTimeout(shyTimer);
shyTimer = setTimeout(function() {
ignoreResize = true;
CSS.removeClass(DOM.root(), C_VIEWPORT_RESIZING);
updateShy(document);
ignoreResize = false;
}, 100);
}
var HAS_BROKEN_REGEXP = ' '.split(/\s+/).length == 0;
var TAG_GLUE = 'cufonglue';
var TAG_SHY = 'cufonshy';
var C_SHY_DISABLED = 'cufon-shy-disabled';
var C_VIEWPORT_RESIZING = 'cufon-viewport-resizing';
var sharedStorage = new Storage();
var hoverHandler = new HoverHandler();
var replaceHistory = new ReplaceHistory();
var initialized = false;
var trackingShy = false;
var shyTimer;
var ignoreResize = false;
var engines = {}, fonts = {}, defaultOptions = {
autoDetect: false,
engine: null,
forceHitArea: false,
hover: false,
hoverables: {
a: true
},
ignore: {
applet: 1,
canvas: 1,
col: 1,
colgroup: 1,
head: 1,
iframe: 1,
map: 1,
noscript: 1,
optgroup: 1,
option: 1,
script: 1,
select: 1,
style: 1,
textarea: 1,
title: 1,
pre: 1
},
ignoreClass: null,
modifyText: null,
onAfterReplace: null,
onBeforeReplace: null,
printable: true,
selector: (
window.Sizzle
||	(window.jQuery && function(query) { return jQuery(query); }) // avoid noConflict issues
||	(window.dojo && dojo.query)
||	(window.glow && glow.dom && glow.dom.get)
||	(window.Ext && Ext.query)
||	(window.YAHOO && YAHOO.util && YAHOO.util.Selector && YAHOO.util.Selector.query)
||	(window.$$ && function(query) { return $$(query); })
||	(window.$ && function(query) { return $(query); })
||	(document.querySelectorAll && function(query) { return document.querySelectorAll(query); })
||	elementsByTagName
),
separate: 'words', // 'none' and 'characters' are also accepted
softHyphens: true,
textless: {
dl: 1,
html: 1,
ol: 1,
table: 1,
tbody: 1,
thead: 1,
tfoot: 1,
tr: 1,
ul: 1
},
textShadow: 'none',
trim: 'advanced'
};
var separators = {
words: /\s/.test('\u00a0') ? /[^\S\u00a0]+/ : /\s+/,
characters: '',
none: /^/
};
api.now = function() {
DOM.ready();
return api;
};
api.refresh = function() {
replaceHistory.repeat.apply(replaceHistory, arguments);
return api;
};
api.registerEngine = function(id, engine) {
if (!engine) return api;
engines[id] = engine;
return api.set('engine', id);
};
api.registerFont = function(data) {
if (!data) return api;
var font = new Font(data), family = font.family;
if (!fonts[family]) fonts[family] = new FontFamily();
fonts[family].add(font);
return api.set('fontFamily', '"' + family + '"');
};
api.replace = function(elements, options, ignoreHistory) {
options = merge(defaultOptions, options);
if (!options.engine) return api; // there's no browser support so we'll just stop here
if (!initialized) {
CSS.addClass(DOM.root(), 'cufon-active cufon-loading');
CSS.ready(function() {
CSS.addClass(CSS.removeClass(DOM.root(), 'cufon-loading'), 'cufon-ready');
});
initialized = true;
}
if (options.hover) options.forceHitArea = true;
if (options.autoDetect) delete options.fontFamily;
if (typeof options.ignoreClass == 'string') {
options.ignoreClass = new RegExp('(?:^|\\s)(?:' + options.ignoreClass.replace(/\s+/g, '|') + ')(?:\\s|$)');
}
if (typeof options.textShadow == 'string') {
options.textShadow = CSS.textShadow(options.textShadow);
}
if (typeof options.color == 'string' && /^-/.test(options.color)) {
options.textGradient = CSS.gradient(options.color);
}
else delete options.textGradient;
if (typeof elements == 'string') {
if (!ignoreHistory) replaceHistory.add(elements, arguments);
elements = [ elements ];
}
else if (elements.nodeType) elements = [ elements ];
CSS.ready(function() {
for (var i = 0, l = elements.length; i < l; ++i) {
var el = elements[i];
if (typeof el == 'string') api.replace(options.selector(el), options, true);
else replaceElement(el, options);
}
});
return api;
};
api.set = function(option, value) {
defaultOptions[option] = value;
return api;
};
return api;
})();
Cufon.registerEngine('vml', (function() {
var ns = document.namespaces;
if (!ns) return;
ns.add('cvml', 'urn:schemas-microsoft-com:vml');
ns = null;
var check = document.createElement('cvml:shape');
check.style.behavior = 'url(#default#VML)';
if (!check.coordsize) return; // VML isn't supported
check = null;
var HAS_BROKEN_LINEHEIGHT = (document.documentMode || 0) < 8;
document.write(('<style type="text/css">' +
'cufoncanvas{text-indent:0;}' +
'@media screen{' +
'cvml\\:shape,cvml\\:rect,cvml\\:fill,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute;}' +
'cufoncanvas{position:absolute;text-align:left;}' +
'cufon{display:inline-block;position:relative;vertical-align:' +
(HAS_BROKEN_LINEHEIGHT
? 'middle'
: 'text-bottom') +
';}' +
'cufon cufontext{position:absolute;left:-10000in;font-size:1px;text-align:left;}' +
'cufonshy.cufon-shy-disabled,.cufon-viewport-resizing cufonshy{display:none;}' +
'cufonglue{white-space:nowrap;display:inline-block;}' +
'.cufon-viewport-resizing cufonglue{white-space:normal;}' +
'a cufon{cursor:pointer}' + // ignore !important here
'}' +
'@media print{' +
'cufon cufoncanvas{display:none;}' +
'}' +
'</style>').replace(/;/g, '!important;'));
function getFontSizeInPixels(el, value) {
return getSizeInPixels(el, /(?:em|ex|%)$|^[a-z-]+$/i.test(value) ? '1em' : value);
}
function getSizeInPixels(el, value) {
if (!isNaN(value) || /px$/i.test(value)) return parseFloat(value);
var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
el.runtimeStyle.left = el.currentStyle.left;
el.style.left = value.replace('%', 'em');
var result = el.style.pixelLeft;
el.style.left = style;
el.runtimeStyle.left = runtimeStyle;
return result;
}
function getSpacingValue(el, style, size, property) {
var key = 'computed' + property, value = style[key];
if (isNaN(value)) {
value = style.get(property);
style[key] = value = (value == 'normal') ? 0 : ~~size.convertFrom(getSizeInPixels(el, value));
}
return value;
}
var fills = {};
function gradientFill(gradient) {
var id = gradient.id;
if (!fills[id]) {
var stops = gradient.stops, fill = document.createElement('cvml:fill'), colors = [];
fill.type = 'gradient';
fill.angle = 180;
fill.focus = '0';
fill.method = 'none';
fill.color = stops[0][1];
for (var j = 1, k = stops.length - 1; j < k; ++j) {
colors.push(stops[j][0] * 100 + '% ' + stops[j][1]);
}
fill.colors = colors.join(',');
fill.color2 = stops[k][1];
fills[id] = fill;
}
return fills[id];
}
return function(font, text, style, options, node, el, hasNext) {
var redraw = (text === null);
if (redraw) text = node.alt;
var viewBox = font.viewBox;
var size = style.computedFontSize || (style.computedFontSize = new Cufon.CSS.Size(getFontSizeInPixels(el, style.get('fontSize')) + 'px', font.baseSize));
var wrapper, canvas;
if (redraw) {
wrapper = node;
canvas = node.firstChild;
}
else {
wrapper = document.createElement('cufon');
wrapper.className = 'cufon cufon-vml';
wrapper.alt = text;
canvas = document.createElement('cufoncanvas');
wrapper.appendChild(canvas);
if (options.printable) {
var print = document.createElement('cufontext');
print.appendChild(document.createTextNode(text));
wrapper.appendChild(print);
}
if (!hasNext) wrapper.appendChild(document.createElement('cvml:shape'));
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var height = size.convert(viewBox.height), roundedHeight = Math.ceil(height);
var roundingFactor = roundedHeight / height;
var stretchFactor = roundingFactor * Cufon.CSS.fontStretch(style.get('fontStretch'));
var minX = viewBox.minX, minY = viewBox.minY;
cStyle.height = roundedHeight;
cStyle.top = Math.round(size.convert(minY - font.ascent));
cStyle.left = Math.round(size.convert(minX));
wStyle.height = size.convert(font.height) + 'px';
var color = style.get('color');
var chars = Cufon.CSS.textTransform(text, style).split('');
var jumps = font.spacing(chars,
getSpacingValue(el, style, size, 'letterSpacing'),
getSpacingValue(el, style, size, 'wordSpacing')
);
if (!jumps.length) return null;
var width = jumps.total;
var fullWidth = -minX + width + (viewBox.width - jumps[jumps.length - 1]);
var shapeWidth = size.convert(fullWidth * stretchFactor), roundedShapeWidth = Math.round(shapeWidth);
var coordSize = fullWidth + ',' + viewBox.height, coordOrigin;
var stretch = 'r' + coordSize + 'ns';
var fill = options.textGradient && gradientFill(options.textGradient);
var glyphs = font.glyphs, offsetX = 0;
var shadows = options.textShadow;
var i = -1, j = 0, chr;
while (chr = chars[++i]) {
var glyph = glyphs[chars[i]] || font.missingGlyph, shape;
if (!glyph) continue;
if (redraw) {
shape = canvas.childNodes[j];
while (shape.firstChild) shape.removeChild(shape.firstChild); // shadow, fill
}
else {
shape = document.createElement('cvml:shape');
canvas.appendChild(shape);
}
shape.stroked = 'f';
shape.coordsize = coordSize;
shape.coordorigin = coordOrigin = (minX - offsetX) + ',' + minY;
shape.path = (glyph.d ? 'm' + glyph.d + 'xe' : '') + 'm' + coordOrigin + stretch;
shape.fillcolor = color;
if (fill) shape.appendChild(fill.cloneNode(false));
var sStyle = shape.style;
sStyle.width = roundedShapeWidth;
sStyle.height = roundedHeight;
if (shadows) {
var shadow1 = shadows[0], shadow2 = shadows[1];
var color1 = Cufon.CSS.color(shadow1.color), color2;
var shadow = document.createElement('cvml:shadow');
shadow.on = 't';
shadow.color = color1.color;
shadow.offset = shadow1.offX + ',' + shadow1.offY;
if (shadow2) {
color2 = Cufon.CSS.color(shadow2.color);
shadow.type = 'double';
shadow.color2 = color2.color;
shadow.offset2 = shadow2.offX + ',' + shadow2.offY;
}
shadow.opacity = color1.opacity || (color2 && color2.opacity) || 1;
shape.appendChild(shadow);
}
offsetX += jumps[j++];
}
var cover = shape.nextSibling, coverFill, vStyle;
if (options.forceHitArea) {
if (!cover) {
cover = document.createElement('cvml:rect');
cover.stroked = 'f';
cover.className = 'cufon-vml-cover';
coverFill = document.createElement('cvml:fill');
coverFill.opacity = 0;
cover.appendChild(coverFill);
canvas.appendChild(cover);
}
vStyle = cover.style;
vStyle.width = roundedShapeWidth;
vStyle.height = roundedHeight;
}
else if (cover) canvas.removeChild(cover);
wStyle.width = Math.max(Math.ceil(size.convert(width * stretchFactor)), 0);
if (HAS_BROKEN_LINEHEIGHT) {
var yAdjust = style.computedYAdjust;
if (yAdjust === undefined) {
var lineHeight = style.get('lineHeight');
if (lineHeight == 'normal') lineHeight = '1em';
else if (!isNaN(lineHeight)) lineHeight += 'em'; // no unit
style.computedYAdjust = yAdjust = 0.5 * (getSizeInPixels(el, lineHeight) - parseFloat(wStyle.height));
}
if (yAdjust) {
wStyle.marginTop = Math.ceil(yAdjust) + 'px';
wStyle.marginBottom = yAdjust + 'px';
}
}
return wrapper;
};
})());
Cufon.registerEngine('canvas', (function() {
var check = document.createElement('canvas');
if (!check || !check.getContext || !check.getContext.apply) return;
check = null;
var HAS_INLINE_BLOCK = Cufon.CSS.supports('display', 'inline-block');
var HAS_BROKEN_LINEHEIGHT = !HAS_INLINE_BLOCK && (document.compatMode == 'BackCompat' || /frameset|transitional/i.test(document.doctype.publicId));
var styleSheet = document.createElement('style');
styleSheet.type = 'text/css';
styleSheet.appendChild(document.createTextNode((
'cufon{text-indent:0;}' +
'@media screen,projection{' +
'cufon{display:inline;display:inline-block;position:relative;vertical-align:middle;' +
(HAS_BROKEN_LINEHEIGHT
? ''
: 'font-size:1px;line-height:1px;') +
'}cufon cufontext{display:-moz-inline-box;display:inline-block;width:0;height:0;text-align:left;text-indent:-10000in;}' +
(HAS_INLINE_BLOCK
? 'cufon canvas{position:relative;}'
: 'cufon canvas{position:absolute;}') +
'cufonshy.cufon-shy-disabled,.cufon-viewport-resizing cufonshy{display:none;}' +
'cufonglue{white-space:nowrap;display:inline-block;}' +
'.cufon-viewport-resizing cufonglue{white-space:normal;}' +
'}' +
'@media print{' +
'cufon{padding:0;}' + // Firefox 2
'cufon canvas{display:none;}' +
'}'
).replace(/;/g, '!important;')));
document.getElementsByTagName('head')[0].appendChild(styleSheet);
function generateFromVML(path, context) {
var atX = 0, atY = 0;
var code = [], re = /([mrvxe])([^a-z]*)/g, match;
generate: for (var i = 0; match = re.exec(path); ++i) {
var c = match[2].split(',');
switch (match[1]) {
case 'v':
code[i] = { m: 'bezierCurveTo', a: [ atX + ~~c[0], atY + ~~c[1], atX + ~~c[2], atY + ~~c[3], atX += ~~c[4], atY += ~~c[5] ] };
break;
case 'r':
code[i] = { m: 'lineTo', a: [ atX += ~~c[0], atY += ~~c[1] ] };
break;
case 'm':
code[i] = { m: 'moveTo', a: [ atX = ~~c[0], atY = ~~c[1] ] };
break;
case 'x':
code[i] = { m: 'closePath' };
break;
case 'e':
break generate;
}
context[code[i].m].apply(context, code[i].a);
}
return code;
}
function interpret(code, context) {
for (var i = 0, l = code.length; i < l; ++i) {
var line = code[i];
context[line.m].apply(context, line.a);
}
}
return function(font, text, style, options, node, el) {
var redraw = (text === null);
if (redraw) text = node.getAttribute('alt');
var viewBox = font.viewBox;
var size = style.getSize('fontSize', font.baseSize);
var expandTop = 0, expandRight = 0, expandBottom = 0, expandLeft = 0;
var shadows = options.textShadow, shadowOffsets = [];
if (shadows) {
for (var i = shadows.length; i--;) {
var shadow = shadows[i];
var x = size.convertFrom(parseFloat(shadow.offX));
var y = size.convertFrom(parseFloat(shadow.offY));
shadowOffsets[i] = [ x, y ];
if (y < expandTop) expandTop = y;
if (x > expandRight) expandRight = x;
if (y > expandBottom) expandBottom = y;
if (x < expandLeft) expandLeft = x;
}
}
var chars = Cufon.CSS.textTransform(text, style).split('');
var jumps = font.spacing(chars,
~~size.convertFrom(parseFloat(style.get('letterSpacing')) || 0),
~~size.convertFrom(parseFloat(style.get('wordSpacing')) || 0)
);
if (!jumps.length) return null; // there's nothing to render
var width = jumps.total;
expandRight += viewBox.width - jumps[jumps.length - 1];
expandLeft += viewBox.minX;
var wrapper, canvas;
if (redraw) {
wrapper = node;
canvas = node.firstChild;
}
else {
wrapper = document.createElement('cufon');
wrapper.className = 'cufon cufon-canvas';
wrapper.setAttribute('alt', text);
canvas = document.createElement('canvas');
wrapper.appendChild(canvas);
if (options.printable) {
var print = document.createElement('cufontext');
print.appendChild(document.createTextNode(text));
wrapper.appendChild(print);
}
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var height = size.convert(viewBox.height);
var roundedHeight = Math.ceil(height);
var roundingFactor = roundedHeight / height;
var stretchFactor = roundingFactor * Cufon.CSS.fontStretch(style.get('fontStretch'));
var stretchedWidth = width * stretchFactor;
var canvasWidth = Math.ceil(size.convert(stretchedWidth + expandRight - expandLeft));
var canvasHeight = Math.ceil(size.convert(viewBox.height - expandTop + expandBottom));
canvas.width = canvasWidth;
canvas.height = canvasHeight;
cStyle.width = canvasWidth + 'px';
cStyle.height = canvasHeight + 'px';
expandTop += viewBox.minY;
cStyle.top = Math.round(size.convert(expandTop - font.ascent)) + 'px';
cStyle.left = Math.round(size.convert(expandLeft)) + 'px';
var wrapperWidth = Math.max(Math.ceil(size.convert(stretchedWidth)), 0) + 'px';
if (HAS_INLINE_BLOCK) {
wStyle.width = wrapperWidth;
wStyle.height = size.convert(font.height) + 'px';
}
else {
wStyle.paddingLeft = wrapperWidth;
wStyle.paddingBottom = (size.convert(font.height) - 1) + 'px';
}
var g = canvas.getContext('2d'), scale = height / viewBox.height;
g.scale(scale, scale * roundingFactor);
g.translate(-expandLeft, -expandTop);
g.save();
function renderText() {
var glyphs = font.glyphs, glyph, i = -1, j = -1, chr;
g.scale(stretchFactor, 1);
while (chr = chars[++i]) {
var glyph = glyphs[chars[i]] || font.missingGlyph;
if (!glyph) continue;
if (glyph.d) {
g.beginPath();
if (glyph.code) interpret(glyph.code, g);
else glyph.code = generateFromVML('m' + glyph.d, g);
g.fill();
}
g.translate(jumps[++j], 0);
}
g.restore();
}
if (shadows) {
for (var i = shadows.length; i--;) {
var shadow = shadows[i];
g.save();
g.fillStyle = shadow.color;
g.translate.apply(g, shadowOffsets[i]);
renderText();
}
}
var gradient = options.textGradient;
if (gradient) {
var stops = gradient.stops, fill = g.createLinearGradient(0, viewBox.minY, 0, viewBox.maxY);
for (var i = 0, l = stops.length; i < l; ++i) {
fill.addColorStop.apply(fill, stops[i]);
}
g.fillStyle = fill;
}
else g.fillStyle = style.get('color');
renderText();
return wrapper;
};
})());
Cufon.registerFont({"w":218,"face":{"font-family":"Alright Sans","font-weight":400,"font-style":"italic","font-stretch":"normal","units-per-em":"360","panose-1":"0 0 5 0 0 0 0 0 0 0","ascent":"274","descent":"-86","x-height":"4","bbox":"-61 -316 397 76","underline-thickness":"18","underline-position":"-18","slope":"-10","stemh":"44","stemv":"55","unicode-range":"U+0020-U+00F8"},"glyphs":{" ":{"w":84},"A":{"d":"-13,0r133,-252r63,0r44,252r-56,0r-7,-47r-93,0r-23,47r-61,0xm92,-89r66,0r-15,-103","w":251,"k":{"-":6,"J":3,"S":5,"T":30,"U":15,"W":26,"Y":40,")":4,"]":4,"}":4,"?":27,"'":12,"\"":12,"s":2,"v":21,"w":21,"y":21,"@":18,"C":20,"G":20,"O":20,"Q":20,"\u00d8":20,"&":8,"a":10,"d":10,"g":10,"q":10,"\u00e5":10,"\u00e6":10,"f":10,"c":12,"e":12,"o":12,"\u00f8":12,"t":18,"u":8,"V":30,"X":1,"*":34,"\\":34}},"B":{"d":"6,0r44,-252r104,0v90,-5,103,104,30,123v23,8,38,24,38,52v0,49,-37,77,-105,77r-111,0xm68,-44v44,0,100,6,100,-37v0,-37,-52,-27,-88,-28xm86,-147v41,2,93,2,90,-36v4,-30,-48,-25,-79,-25","w":239,"k":{"A":2,"\u00c5":2,"\u00c6":5,"J":1,"S":2,"T":9,"U":2,"W":11,"Y":21,"Z":1,")":4,"]":4,"}":4,"?":7,"'":1,"\"":1,"s":2,"v":3,"w":3,"y":3,"z":1,"f":1,"u":1,"V":13,"X":8,"*":8,"\\":4,"x":5,"\/":16}},"C":{"d":"16,-109v0,-81,62,-147,148,-147v37,0,66,13,88,34r-32,34v-56,-52,-148,-5,-148,76v0,78,88,87,127,43r30,36v-64,64,-213,44,-213,-76","w":250,"k":{"-":10,"A":-1,"\u00c5":-1,"J":3,"S":1,"T":4,"U":5,"W":5,"Y":11,"?":2,"s":4,"v":13,"w":13,"y":13,"z":1,"@":7,"C":11,"G":11,"O":11,"Q":11,"\u00d8":11,"&":2,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"f":5,"m":2,"n":2,"p":2,"r":2,"c":10,"e":10,"o":10,"\u00f8":10,"t":9,"u":3,"V":5,"X":4,"*":3,"\\":2,"x":6,"\/":7}},"D":{"d":"5,0r45,-252r81,0v72,0,118,36,118,107v0,81,-51,145,-160,145r-84,0xm68,-44v79,9,125,-34,125,-99v0,-56,-37,-69,-95,-65","w":257,"k":{"A":3,"\u00c5":3,"\u00c6":15,"J":5,"S":5,"T":15,"U":2,"W":14,"Y":30,"Z":3,")":9,"]":9,"}":9,"?":12,"'":4,"\"":4,"v":2,"w":2,"y":2,"z":2,"V":14,"X":15,"*":8,"\\":14,"x":7,"\/":24}},"E":{"d":"5,0r45,-252r181,0r-9,48r-125,0r-10,55r112,0r-8,42r-111,0r-11,59r127,0r-8,48r-183,0","w":224,"k":{"-":4,"J":2,"S":2,"s":3,"v":4,"w":4,"y":4,"@":3,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"f":3,"c":8,"e":8,"o":8,"\u00f8":8,"t":1,"u":3,"x":2}},"F":{"d":"5,0r45,-252r178,0r-8,48r-123,0r-11,59r106,0r-8,44r-106,0r-17,101r-56,0","w":219,"k":{"-":10,"A":24,"\u00c5":24,"\u00c6":40,"J":39,"S":5,"U":1,"W":2,"Y":5,"Z":3,".":25,",":25,"?":2,"s":12,"v":6,"w":6,"y":6,"z":14,"@":13,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"&":12,":":9,";":9,"a":15,"d":15,"g":15,"q":15,"\u00e5":15,"\u00e6":15,"f":4,"m":8,"n":8,"p":8,"r":8,"c":14,"e":14,"o":14,"\u00f8":14,"t":3,"u":10,"i":2,"V":2,"X":8,"x":10,"\/":46}},"G":{"d":"16,-108v0,-82,59,-148,150,-148v36,0,69,13,90,32r-32,34v-59,-48,-152,-4,-152,79v0,62,61,85,108,58r8,-50r-55,0r6,-37r106,0r-21,117v-25,17,-57,27,-94,27v-67,0,-114,-45,-114,-112","w":259,"k":{"A":1,"\u00c5":1,"\u00c6":3,"S":1,"T":6,"W":8,"Y":13,"?":4,"'":1,"\"":1,"v":5,"w":5,"y":5,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"f":3,"c":2,"e":2,"o":2,"\u00f8":2,"t":1,"V":8,"X":6,"*":5,"\\":3,"x":4,"\/":9}},"H":{"d":"5,0r45,-252r55,0r-17,101r93,0r18,-101r56,0r-45,252r-55,0r19,-104r-94,0r-19,104r-56,0","w":252,"k":{"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1}},"I":{"d":"5,0r45,-252r55,0r-44,252r-56,0","w":102,"k":{"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1}},"J":{"d":"1,-48r41,-23v10,17,20,30,39,30v22,0,34,-15,39,-43r29,-168r55,0v-25,96,-7,258,-124,256v-37,0,-64,-21,-79,-52","w":201,"k":{"A":8,"\u00c5":8,"\u00c6":8,"J":10,"Y":1,".":5,",":5,"s":1,"c":1,"e":1,"o":1,"\u00f8":1,"X":3,"x":3,"\/":18}},"K":{"d":"5,0r45,-252r55,0r-20,113r112,-113r64,0r-96,95r55,157r-55,0r-40,-117r-53,53r-11,64r-56,0","w":244,"k":{"-":16,"J":6,"S":4,"T":4,"U":5,"W":1,"Y":1,"?":6,"s":3,"v":15,"w":15,"y":15,"z":1,"@":18,"C":18,"G":18,"O":18,"Q":18,"\u00d8":18,"&":6,"a":15,"d":15,"g":15,"q":15,"\u00e5":15,"\u00e6":15,"f":4,"m":1,"n":1,"p":1,"r":1,"c":18,"e":18,"o":18,"\u00f8":18,"t":8,"u":8,"V":2,"X":2,"*":7,"x":4}},"L":{"d":"5,0r45,-252r55,0r-36,205r122,0r-8,47r-178,0","w":212,"k":{"-":8,"J":3,"S":1,"T":37,"U":10,"W":26,"Y":41,"?":27,"'":6,"\"":6,"s":1,"v":18,"w":18,"y":18,"@":15,"C":19,"G":19,"O":19,"Q":19,"\u00d8":19,"&":2,"a":7,"d":7,"g":7,"q":7,"\u00e5":7,"\u00e6":7,"f":5,"c":9,"e":9,"o":9,"\u00f8":9,"t":15,"u":3,"V":30,"X":2,"*":28,"\\":47}},"M":{"d":"5,0r45,-252r51,0r56,107r91,-107r59,0r-45,252r-52,0r31,-174r-95,108r-57,-108r-31,174r-53,0","w":304,"k":{"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1}},"N":{"d":"5,0r45,-252r45,0r86,167r30,-167r52,0r-45,252r-46,0r-85,-167r-29,167r-53,0","w":260,"k":{"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1}},"O":{"d":"18,-108v0,-80,57,-148,146,-148v62,0,115,40,115,112v0,80,-58,148,-147,148v-63,0,-114,-40,-114,-112xm74,-111v0,45,24,69,62,69v47,0,86,-44,86,-99v0,-45,-24,-70,-61,-70v-47,0,-87,45,-87,100","w":288,"k":{"A":3,"\u00c5":3,"\u00c6":15,"J":5,"S":5,"T":15,"U":2,"W":14,"Y":30,"Z":3,")":9,"]":9,"}":9,"?":12,"'":4,"\"":4,"v":2,"w":2,"y":2,"z":2,"V":14,"X":15,"*":8,"\\":14,"x":7,"\/":24}},"P":{"d":"5,0r45,-252r101,0v58,0,87,32,87,72v0,44,-27,89,-111,89r-50,0r-16,91r-56,0xm85,-134v47,4,96,-2,96,-44v0,-37,-47,-30,-83,-30","w":238,"k":{"-":4,"A":27,"\u00c5":27,"\u00c6":36,"J":42,"S":1,"T":4,"U":1,"W":6,"Y":15,"Z":5,")":5,"]":5,"}":5,".":32,",":32,"?":8,"z":4,"@":1,"&":3,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"m":3,"n":3,"p":3,"r":3,"c":1,"e":1,"o":1,"\u00f8":1,"u":3,"V":6,"X":23,"*":2,"\\":5,"x":3,"\/":51}},"Q":{"d":"18,-108v0,-80,57,-148,146,-148v62,0,115,40,115,112v0,40,-14,76,-39,103r24,26r-29,24r-24,-26v-77,46,-193,15,-193,-91xm145,-94r27,-23r32,37v34,-42,20,-131,-43,-131v-47,0,-87,45,-87,100v0,65,60,85,106,56","w":288,"k":{".":2,"A":3,"\u00c5":3,"\u00c6":15,"J":5,"S":5,"T":15,"U":2,"W":14,"Y":30,"Z":3,")":9,"]":9,"}":9,"?":12,"'":4,"\"":4,"v":2,"w":2,"y":2,"z":2,"V":14,"X":15,"*":8,"\\":14,"x":7,"\/":24}},"R":{"d":"5,0r45,-252r106,0v105,-4,117,125,27,151r27,101r-53,0r-22,-94r-57,0r-17,94r-56,0xm85,-134v49,4,101,-1,101,-44v0,-38,-51,-29,-88,-30","w":246,"k":{"-":5,"A":4,"\u00c5":4,"J":13,"T":10,"U":3,"W":9,"Y":20,"Z":1,".":1,",":1,"?":7,"@":1,"&":4,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"c":1,"e":1,"o":1,"\u00f8":1,"u":2,"V":10,"X":6,"*":4,"\\":6}},"S":{"d":"3,-28r29,-39v26,24,113,38,113,-6v0,-19,-19,-24,-47,-33v-32,-10,-68,-24,-68,-69v0,-45,37,-81,101,-81v34,0,66,10,89,24r-26,40v-31,-21,-105,-28,-105,13v0,18,18,23,45,31v32,10,69,22,69,70v0,46,-34,82,-105,82v-38,0,-73,-15,-95,-32","w":222,"k":{"v":12,"\u00c6":5,"S":5,"T":9,"U":2,"W":10,"Y":12,"?":7,"'":5,"\"":5,"s":3,"w":12,"y":12,"z":4,"@":3,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"f":4,"c":1,"e":1,"o":1,"\u00f8":1,"t":7,"u":1,"V":8,"X":9,"*":8,"\\":7,"x":8,"\/":11}},"T":{"d":"73,0r36,-204r-82,0r8,-48r217,0r-9,48r-80,0r-35,204r-55,0","w":234,"k":{"-":23,"A":23,"\u00c5":23,"\u00c6":36,"J":41,"S":2,"Y":2,".":20,",":20,"?":1,"s":13,"v":8,"w":8,"y":8,"z":11,"@":15,"C":6,"G":6,"O":6,"Q":6,"\u00d8":6,"&":13,":":22,";":22,"a":20,"d":20,"g":20,"q":20,"\u00e5":20,"\u00e6":20,"f":5,"m":8,"n":8,"p":8,"r":8,"c":21,"e":21,"o":21,"\u00f8":21,"t":1,"u":12,"X":2,"x":8,"\/":41}},"U":{"d":"20,-76v0,-62,20,-117,29,-176r56,0r-28,151v-6,35,7,60,41,59v28,0,52,-17,59,-58r27,-152r55,0r-28,156v-12,67,-56,100,-122,100v-53,0,-89,-29,-89,-80","w":256,"k":{"A":8,"\u00c5":8,"\u00c6":8,"J":10,"Y":1,".":5,",":5,"s":1,"c":1,"e":1,"o":1,"\u00f8":1,"X":3,"x":3,"\/":18}},"V":{"d":"76,0r-44,-252r56,0r28,188r93,-188r62,0r-133,252r-62,0","w":250,"k":{"\/":45,"x":5,"X":1,"-":10,"A":21,"\u00c5":21,"\u00c6":30,"J":31,"S":2,".":22,",":22,"?":1,"s":10,"v":4,"w":4,"y":4,"z":6,"@":10,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"&":14,":":17,";":17,"a":13,"d":13,"g":13,"q":13,"\u00e5":13,"\u00e6":13,"m":8,"n":8,"p":8,"r":8,"c":12,"e":12,"o":12,"\u00f8":12,"t":1,"u":5}},"W":{"d":"66,0r-33,-252r55,0r21,173r77,-173r51,0r19,173r82,-173r59,0r-122,252r-58,0r-18,-170r-77,170r-56,0","w":378,"k":{"-":4,"A":18,"\u00c5":18,"\u00c6":27,"J":32,"S":3,"Y":1,".":17,",":17,"?":2,"s":9,"v":3,"w":3,"y":3,"z":4,"@":9,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"&":12,":":9,";":9,"a":11,"d":11,"g":11,"q":11,"\u00e5":11,"\u00e6":11,"m":9,"n":9,"p":9,"r":9,"c":12,"e":12,"o":12,"\u00f8":12,"u":4,"X":2,"x":4,"\/":37}},"X":{"d":"-10,0r108,-130r-59,-122r61,0r38,81r63,-81r70,0r-104,125r60,127r-60,0r-39,-86r-68,86r-70,0","w":254,"k":{"*":4,"x":1,"V":1,"-":15,"A":1,"\u00c5":1,"\u00c6":2,"J":9,"S":7,"T":1,"U":2,"W":1,"Y":2,")":2,"]":2,"}":2,"?":6,"s":7,"v":15,"w":15,"y":15,"z":3,"@":23,"C":17,"G":17,"O":17,"Q":17,"\u00d8":17,"&":11,"a":18,"d":18,"g":18,"q":18,"\u00e5":18,"\u00e6":18,"f":3,"m":3,"n":3,"p":3,"r":3,"c":21,"e":21,"o":21,"\u00f8":21,"t":7,"u":11}},"Y":{"d":"78,0r18,-101r-65,-151r59,0r41,96r74,-96r65,0r-119,151r-17,101r-56,0","w":248,"k":{"-":24,"A":29,"\u00c5":29,"\u00c6":39,"J":42,"S":6,"T":2,".":26,",":26,"?":4,"s":23,"v":17,"w":17,"y":17,"z":16,"@":22,"C":12,"G":12,"O":12,"Q":12,"\u00d8":12,"&":19,":":22,";":22,"a":27,"d":27,"g":27,"q":27,"\u00e5":27,"\u00e6":27,"f":9,"m":17,"n":17,"p":17,"r":17,"c":27,"e":27,"o":27,"\u00f8":27,"t":4,"u":17,"X":2,"*":1,"x":18,"\/":53}},"Z":{"d":"-2,0r7,-41r149,-162r-120,0r8,-49r196,0r-7,41r-148,162r124,0r-9,49r-200,0","w":229,"k":{"-":3,"J":3,"S":1,"?":1,"v":3,"w":3,"y":3,"@":3,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"&":3,"a":4,"d":4,"g":4,"q":4,"\u00e5":4,"\u00e6":4,"f":1,"m":1,"n":1,"p":1,"r":1,"c":6,"e":6,"o":6,"\u00f8":6,"t":1,"u":1,"*":1,"x":1}},"a":{"d":"138,-26v-40,52,-127,36,-127,-48v0,-92,87,-160,148,-100r7,-19r47,0r-26,147v0,8,5,11,14,11r-6,36v-30,1,-51,-5,-57,-27xm139,-70r12,-74v-41,-36,-89,3,-87,65v1,65,56,47,75,9","w":221,"k":{"J":-2,"T":19,"W":10,"Y":21,"?":8,"'":4,"\"":4,"c":3,"e":3,"o":3,"\u00f8":3,"j":-1,"V":12,"*":23,"\\":18,"\/":1}},"b":{"d":"4,0r48,-272r53,0r-19,103v39,-50,120,-32,120,51v0,96,-88,159,-148,97r-7,21r-47,0xm65,-51v41,40,91,-6,88,-65v-2,-62,-55,-45,-75,-8","k":{"A":1,"\u00c5":1,"\u00c6":3,"S":5,"T":27,"W":19,"Y":35,"Z":1,")":2,"]":2,"}":2,"?":26,"'":10,"\"":10,"s":1,"v":9,"w":9,"y":9,"z":4,"t":3,"V":22,"X":8,"\\":26,"x":8,"\/":10}},"c":{"d":"9,-82v0,-96,115,-150,178,-90r-29,31v-38,-33,-94,-4,-94,56v0,53,52,57,79,31r26,33v-53,46,-160,31,-160,-61","w":188,"k":{"-":3,"J":5,"T":12,"U":2,"W":12,"Y":22,"?":15,"'":1,"\"":1,"s":-1,"@":1,"&":3,"a":6,"d":6,"g":6,"q":6,"\u00e5":6,"\u00e6":6,"c":8,"e":8,"o":8,"\u00f8":8,"u":1,"V":10,"X":2,"*":7,"\\":11}},"d":{"d":"136,-27v-37,52,-125,38,-125,-48v0,-91,82,-156,146,-102r17,-95r53,0r-48,272r-43,0r0,-27xm64,-80v2,65,55,49,75,10r13,-74v-41,-36,-90,3,-88,64"},"e":{"d":"11,-80v0,-67,51,-118,117,-118v43,0,71,24,71,55v0,48,-72,59,-135,61v-3,57,60,49,92,28r19,35v-56,42,-164,27,-164,-61xm123,-160v-23,0,-43,17,-53,44v38,3,86,-8,78,-25v0,-10,-10,-19,-25,-19","w":208,"k":{"\u00c6":2,"J":10,"S":3,"T":22,"U":2,"W":21,"Y":33,".":1,",":1,"?":22,"'":1,"\"":1,"s":1,"v":6,"w":6,"y":6,"z":3,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"&":1,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"f":1,"m":1,"n":1,"p":1,"r":1,"c":3,"e":3,"o":3,"\u00f8":3,"t":1,"u":1,"i":1,"V":19,"X":5,"*":19,"\\":22,"x":7,"\/":7,"b":1,"h":1,"k":1,"l":1}},"f":{"d":"17,0r27,-154r-30,0r6,-36r30,0v5,-75,72,-103,135,-74r-18,33v-33,-12,-62,-1,-64,41r47,0r-6,36r-48,0r-27,154r-52,0","w":146,"k":{"-":5,"A":9,"\u00c5":9,"\u00c6":18,"J":26,")":-13,"]":-13,"}":-13,".":9,",":9,"?":-2,"'":-13,"\"":-13,"s":1,"@":-1,"&":2,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"f":2,"c":3,"e":3,"o":3,"\u00f8":3,"t":2,"i":-4,"*":-5,"\\":-22,"x":1,"\/":23,"b":-4,"h":-4,"k":-4,"l":-4}},"g":{"d":"80,34v34,0,47,-27,51,-61v-39,44,-120,35,-120,-51v0,-91,87,-153,148,-97r6,-18r47,0r-33,187v-9,52,-36,82,-101,82v-28,0,-58,-12,-76,-26r24,-36v15,10,34,20,54,20xm139,-73r12,-71v-40,-36,-89,2,-87,63v3,63,55,46,75,8","k":{"-":1,"\u00c6":2,"T":9,"W":9,"Y":20,"?":8,"j":-20,"V":10,"X":4,"*":5,"\\":7}},"h":{"d":"4,0r48,-272r53,0r-19,106v23,-40,117,-45,114,18v-3,52,-17,99,-24,148r-53,0r24,-140v0,-11,-5,-18,-18,-18v-17,0,-34,15,-51,39r-21,119r-53,0","w":214,"k":{"T":20,"W":13,"Y":31,")":1,"]":1,"}":1,"?":18,"'":8,"\"":8,"v":4,"w":4,"y":4,"V":16,"*":19,"\\":17}},"i":{"d":"4,0r34,-190r52,0r-33,190r-53,0xm44,-225r7,-45r53,0r-8,45r-52,0","w":96,"k":{"W":3,"Y":8,"V":3}},"j":{"d":"5,-3r34,-187r52,0r-34,192v-6,70,-67,90,-118,61r19,-35v24,11,41,5,47,-31xm44,-225r9,-45r52,0r-7,45r-54,0","w":97,"k":{"j":-14,"W":3,"Y":8,"V":3}},"k":{"d":"4,0r48,-272r53,0r-28,159r81,-80r59,0r-74,70r38,123r-52,0r-25,-85r-39,37r-8,48r-53,0","w":207,"k":{"-":8,"J":7,"T":9,"W":3,"Y":13,")":1,"]":1,"}":1,"?":3,"'":2,"\"":2,"@":3,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"&":4,"a":12,"d":12,"g":12,"q":12,"\u00e5":12,"\u00e6":12,"c":14,"e":14,"o":14,"\u00f8":14,"u":1,"V":5,"*":5}},"l":{"d":"4,0r48,-272r53,0r-48,272r-53,0","w":96},"m":{"d":"76,-120r-21,120r-52,0r34,-193r44,0r-1,30v23,-36,100,-53,113,0v21,-23,44,-34,68,-34v45,0,53,38,45,81r-21,116r-51,0r24,-140v0,-11,-5,-17,-17,-17v-15,0,-36,13,-49,37r-22,120r-51,0r24,-140v0,-10,-4,-17,-17,-17v-17,0,-34,14,-50,37","w":324,"k":{"T":20,"W":13,"Y":31,")":1,"]":1,"}":1,"?":18,"'":8,"\"":8,"v":4,"w":4,"y":4,"V":16,"*":19,"\\":17}},"n":{"d":"122,0r23,-140v0,-11,-4,-18,-17,-18v-17,0,-34,15,-51,39r-21,119r-53,0r34,-193r44,0r0,30v17,-19,38,-34,66,-34v94,0,31,130,28,197r-53,0","w":214,"k":{"T":20,"W":13,"Y":31,")":1,"]":1,"}":1,"?":18,"'":8,"\"":8,"v":4,"w":4,"y":4,"V":16,"*":19,"\\":17}},"o":{"d":"96,4v-49,0,-85,-32,-85,-86v0,-67,46,-116,111,-116v49,0,86,33,86,87v0,67,-47,115,-112,115xm100,-35v30,0,54,-37,54,-76v0,-31,-13,-47,-36,-47v-30,0,-54,37,-54,76v0,31,13,47,36,47","w":219,"k":{"A":1,"\u00c5":1,"\u00c6":3,"S":5,"T":31,"W":19,"Y":40,")":1,"]":1,"}":1,".":-1,",":-1,"?":29,"'":5,"\"":5,"s":1,"v":9,"w":9,"y":9,"z":3,"f":1,"t":3,"V":22,"X":9,"*":23,"\\":26,"x":8,"\/":10}},"p":{"d":"60,-19r-17,91r-52,0r46,-265r47,0r0,25v41,-49,122,-37,122,51v0,95,-84,156,-146,98xm65,-51v41,40,91,-6,88,-65v-3,-62,-55,-45,-75,-9","k":{"A":1,"\u00c5":1,"\u00c6":3,"S":5,"T":27,"W":19,"Y":35,"Z":1,")":2,"]":2,"}":2,"?":26,"'":10,"\"":10,"s":1,"v":9,"w":9,"y":9,"z":4,"t":3,"V":22,"X":8,"\\":26,"x":8,"\/":10}},"q":{"d":"130,-23v-39,50,-119,29,-119,-53v0,-95,88,-156,149,-98r6,-19r47,0r-47,265r-53,0xm64,-79v2,66,55,45,75,9r13,-74v-41,-36,-90,4,-88,65","k":{"-":1,"\u00c6":2,"T":9,"W":9,"Y":20,"?":8,"j":-20,"V":10,"X":4,"*":5,"\\":7}},"r":{"d":"3,0r34,-193r44,0r0,32v21,-32,50,-46,86,-33r-15,46v-37,-13,-57,8,-77,41r-19,107r-53,0","w":155,"k":{"-":4,"A":13,"\u00c5":13,"\u00c6":22,"J":27,"T":9,"W":2,"Y":6,"Z":1,".":17,",":17,"?":2,"'":-7,"\"":-7,"&":4,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"c":1,"e":1,"o":1,"\u00f8":1,"V":2,"X":10,"\\":2,"\/":23}},"s":{"d":"-3,-21r24,-33v16,11,35,18,55,18v18,0,33,-7,33,-20v0,-14,-17,-18,-36,-23v-30,-8,-54,-23,-54,-56v0,-67,102,-77,155,-42r-25,33v-24,-15,-71,-24,-78,7v0,14,17,19,37,23v30,7,53,20,53,53v0,73,-120,80,-164,40","w":179,"k":{"A":1,"\u00c5":1,"\u00c6":2,"T":15,"U":4,"W":14,"Y":27,"?":19,"'":3,"\"":3,"s":1,"v":5,"w":5,"y":5,"@":1,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"f":1,"c":1,"e":1,"o":1,"\u00f8":1,"t":3,"V":14,"X":9,"*":15,"\\":17,"x":4,"\/":3}},"t":{"d":"78,4v-83,-2,-40,-104,-33,-160r-30,0r7,-37r29,0r9,-49r53,0r-9,49r52,0r-6,37r-52,0r-18,104v0,23,30,12,41,4r17,35v-16,10,-38,17,-60,17","w":154,"k":{"-":2,"J":2,"T":7,"W":4,"Y":14,".":-3,",":-3,"?":7,"'":2,"\"":2,"@":1,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":5,"e":5,"o":5,"\u00f8":5,"V":6,"*":3,"\\":9}},"u":{"d":"207,-193r-34,193r-43,0r0,-30v-26,43,-119,50,-118,-15v2,-53,16,-99,23,-148r53,0r-24,140v0,10,5,18,18,18v17,0,35,-15,52,-40r20,-118r53,0","w":213,"k":{"-":1,"\u00c6":2,"T":9,"W":9,"Y":20,"?":8,"j":-20,"V":10,"X":4,"*":5,"\\":7}},"v":{"d":"49,0r-28,-193r48,0r17,136r64,-136r52,0r-97,193r-56,0","w":191,"k":{"-":1,"A":11,"\u00c5":11,"\u00c6":14,"J":15,"T":5,"W":2,"Y":5,".":9,",":9,"?":4,"&":1,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":3,"e":3,"o":3,"\u00f8":3,"V":2,"X":8,"\/":15}},"w":{"d":"48,0r-27,-193r48,0r17,125r55,-125r42,0r14,125r59,-125r53,0r-96,193r-47,0r-15,-119r-55,119r-48,0","w":297,"k":{"-":1,"A":11,"\u00c5":11,"\u00c6":14,"J":15,"T":5,"W":2,"Y":5,".":9,",":9,"?":4,"&":1,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":3,"e":3,"o":3,"\u00f8":3,"V":2,"X":8,"\/":15}},"x":{"d":"-12,0r78,-99r-42,-94r51,0r24,59r45,-59r58,0r-76,96r42,97r-50,0r-26,-62r-48,62r-56,0","w":192,"k":{"\\":4,"V":5,"-":6,"J":6,"T":5,"W":2,"Y":13,"?":6,"s":1,"@":2,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"&":7,"a":9,"d":9,"g":9,"q":9,"\u00e5":9,"\u00e6":9,"c":12,"e":12,"o":12,"\u00f8":12,"u":1}},"y":{"d":"-6,27v29,18,52,-4,61,-29r-35,-191r50,0r20,127r63,-127r54,0r-107,204v-34,69,-68,76,-125,53","w":195,"k":{"-":1,"A":11,"\u00c5":11,"\u00c6":14,"J":15,"T":5,"W":2,"Y":5,".":9,",":9,"?":4,"&":1,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":3,"e":3,"o":3,"\u00f8":3,"V":2,"X":8,"\/":15}},"z":{"d":"-4,0r7,-35r110,-118r-87,0r7,-40r151,0r-6,35r-109,118r92,0r-7,40r-158,0","w":185,"k":{"-":1,"T":5,"W":2,"Y":11,"?":4,"&":1,"a":4,"d":4,"g":4,"q":4,"\u00e5":4,"\u00e6":4,"c":6,"e":6,"o":6,"\u00f8":6,"V":2}},"\u00c5":{"d":"118,-248v-19,-29,4,-68,42,-68v39,0,49,49,24,70r43,246r-56,0r-7,-47r-93,0r-23,47r-61,0xm92,-89r66,0r-15,-103xm158,-297v-27,-3,-38,46,-6,45v26,3,37,-45,6,-45","w":251,"k":{"-":6,"J":3,"S":5,"T":30,"U":15,"W":26,"Y":40,")":4,"]":4,"}":4,"?":27,"'":12,"\"":12,"s":2,"v":21,"w":21,"y":21,"@":18,"C":20,"G":20,"O":20,"Q":20,"\u00d8":20,"&":8,"a":10,"d":10,"g":10,"q":10,"\u00e5":10,"\u00e6":10,"f":10,"c":12,"e":12,"o":12,"\u00f8":12,"t":18,"u":8,"V":30,"X":1,"*":34,"\\":34}},"\u00c6":{"d":"179,0r-4,-47r-97,0r-28,47r-64,0r154,-252r239,0r-9,48r-154,0r5,54r126,0r-8,44r-114,0r5,58r114,0r-8,48r-157,0xm165,-194v-23,32,-41,69,-62,103r69,0","w":372,"k":{"-":4,"J":2,"S":2,"s":3,"v":4,"w":4,"y":4,"@":3,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"f":3,"c":8,"e":8,"o":8,"\u00f8":8,"t":1,"u":3,"x":2}},"\u00d8":{"d":"41,-36v-60,-88,7,-220,123,-220v26,0,50,7,69,20r28,-30r23,20r-29,30v63,87,-7,220,-123,220v-27,0,-50,-7,-70,-21r-30,31r-21,-20xm96,-55v73,49,151,-47,119,-124xm199,-198v-72,-48,-149,47,-118,123","w":288,"k":{"A":3,"\u00c5":3,"\u00c6":15,"J":5,"S":5,"T":15,"U":2,"W":14,"Y":30,"Z":3,")":9,"]":9,"}":9,"?":12,"'":4,"\"":4,"v":2,"w":2,"y":2,"z":2,"V":14,"X":15,"*":8,"\\":14,"x":7,"\/":24}},"\u00e5":{"d":"138,-26v-40,52,-127,36,-127,-48v0,-92,87,-160,148,-100r7,-19r47,0r-26,147v0,8,5,11,14,11r-6,36v-30,1,-51,-5,-57,-27xm139,-70r12,-74v-41,-36,-89,3,-87,65v1,65,56,47,75,9xm89,-248v0,-26,21,-46,49,-46v22,0,38,16,38,37v0,26,-20,46,-49,46v-21,0,-38,-16,-38,-37xm136,-275v-26,-3,-38,45,-7,45v24,3,40,-45,7,-45","w":219,"k":{"J":-2,"T":19,"W":10,"Y":21,"?":8,"'":4,"\"":4,"c":3,"e":3,"o":3,"\u00f8":3,"j":-1,"V":12,"*":23,"\\":18,"\/":1}},"\u00e6":{"d":"158,-39v-39,61,-147,62,-147,-35v0,-69,41,-124,98,-124v28,1,55,12,74,32v32,-47,148,-42,148,23v0,45,-66,63,-134,59v-5,58,58,53,91,29r19,36v-41,31,-131,35,-149,-20xm64,-79v2,65,57,47,75,8r12,-73v-41,-36,-89,3,-87,65xm256,-160v-22,0,-44,16,-54,44v38,3,86,-8,78,-25v0,-10,-9,-19,-24,-19","w":340,"k":{"\u00c6":2,"J":10,"S":3,"T":22,"U":2,"W":21,"Y":33,".":1,",":1,"?":22,"'":1,"\"":1,"s":1,"v":6,"w":6,"y":6,"z":3,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"&":1,"a":1,"d":1,"g":1,"q":1,"\u00e5":1,"\u00e6":1,"f":1,"m":1,"n":1,"p":1,"r":1,"c":3,"e":3,"o":3,"\u00f8":3,"t":1,"u":1,"i":1,"V":19,"X":5,"*":19,"\\":22,"x":7,"\/":7,"b":1,"h":1,"k":1,"l":1}},"\u00f8":{"d":"193,-164v57,97,-54,210,-147,154r-27,29r-20,-18r28,-29v-57,-88,45,-217,147,-155r26,-28r21,19xm144,-148v-44,-35,-90,29,-78,82xm76,-44v42,31,86,-25,77,-82","w":219,"k":{"A":1,"\u00c5":1,"\u00c6":3,"S":5,"T":31,"W":19,"Y":40,")":1,"]":1,"}":1,".":-1,",":-1,"?":29,"'":5,"\"":5,"s":1,"v":9,"w":9,"y":9,"z":3,"f":1,"t":3,"V":22,"X":9,"*":23,"\\":26,"x":8,"\/":10}},"`":{"d":"130,-213r-38,-44r38,-23r33,67r-33,0","w":207},".":{"d":"-1,0r9,-55r55,0r-10,55r-54,0","w":87,"k":{"J":1,"S":5,"T":29,"U":13,"W":24,"Y":33,"?":31,"'":24,"\"":24,"s":1,"v":15,"w":15,"y":15,"C":18,"G":18,"O":18,"Q":18,"\u00d8":18,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"f":4,"c":10,"e":10,"o":10,"\u00f8":10,"t":20,"u":4,"V":31,"*":42,"8":4,"5":5,"4":1,"9":9,"1":26,"7":18,"6":15,"3":8,"0":13,"%":14}},",":{"d":"-1,0r9,-55r55,0v-9,53,-16,101,-66,112r-7,-21v19,-7,30,-18,33,-36r-24,0","w":88,"k":{"J":1,"S":5,"T":29,"U":13,"W":24,"Y":33,"?":31,"'":24,"\"":24,"s":1,"v":15,"w":15,"y":15,"C":18,"G":18,"O":18,"Q":18,"\u00d8":18,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"f":4,"c":10,"e":10,"o":10,"\u00f8":10,"t":20,"u":4,"V":31,"*":42,"8":4,"5":5,"4":1,"9":9,"1":26,"7":18,"6":15,"3":8,"0":13,"%":14}},":":{"d":"-1,0r9,-55r55,0r-10,55r-54,0xm23,-139r10,-55r54,0r-9,55r-55,0","w":87},";":{"d":"-1,0r9,-55r55,0v-9,53,-16,101,-66,112r-7,-21v19,-7,30,-18,33,-36r-24,0xm23,-139r10,-55r54,0r-9,55r-55,0","w":87},"!":{"d":"32,-78v5,-59,6,-122,18,-174r53,0v-8,64,-29,117,-44,174r-27,0xm5,0r8,-47r54,0r-9,47r-53,0","w":100},"?":{"d":"62,-78v-3,-69,84,-74,84,-110v-10,-41,-64,-26,-90,0r-29,-31v26,-24,59,-37,93,-37v41,0,81,20,81,64v0,69,-96,65,-99,114r-40,0xm42,0r8,-47r53,0r-8,47r-53,0","w":198,"k":{".":51,",":51,"?":3}},"'":{"d":"28,-174r14,-78r53,0r-34,84","w":82,"k":{"A":10,"\u00c5":10,"\u00c6":9,"J":8,".":22,",":22,"s":1,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"a":13,"d":13,"g":13,"q":13,"\u00e5":13,"\u00e6":13,"f":1,"c":5,"e":5,"o":5,"\u00f8":5,"8":1,"5":3,"4":17,"1":-5,"3":1,"0":1}},"\"":{"d":"28,-174r14,-78r53,0r-34,84xm108,-174r14,-78r54,0r-34,84","w":160,"k":{"A":10,"\u00c5":10,"\u00c6":9,"J":8,".":22,",":22,"s":1,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"a":13,"d":13,"g":13,"q":13,"\u00e5":13,"\u00e6":13,"f":1,"c":5,"e":5,"o":5,"\u00f8":5,"8":1,"5":3,"4":17,"1":-5,"3":1,"0":1}},"_":{"d":"-19,5r196,0r-8,45r-196,0","w":195,"k":{"_":1}},"\/":{"d":"-36,72r216,-344r51,0r-216,344r-51,0","w":196,"k":{"9":3,"5":2,"4":40,"3":2,"2":3,"0":10,"\/":36,"A":20,"\u00c5":20,"\u00c6":25,"J":43,"s":8,"z":1,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"a":12,"d":12,"g":12,"q":12,"\u00e5":12,"\u00e6":12,"f":-1,"c":10,"e":10,"o":10,"\u00f8":10,"t":-2}},"\\":{"d":"172,72r-49,0r-96,-344r48,0","w":196,"k":{"9":4,"8":18,"7":10,"6":31,"5":-2,"4":9,"3":-1,"2":1,"1":26,"0":29,"\\":46,"y":28,"X":4,"V":50,"A":1,"\u00c5":1,"B":5,"D":5,"E":5,"F":5,"H":5,"I":5,"K":5,"L":5,"M":5,"N":5,"P":5,"R":5,"J":8,"S":17,"T":51,"U":29,"W":45,"Y":63,"Z":-5,"s":9,"v":28,"w":28,"z":-5,"C":38,"G":38,"O":38,"Q":38,"\u00d8":38,"a":24,"d":24,"g":24,"q":24,"\u00e5":24,"\u00e6":24,"f":13,"c":25,"e":25,"o":25,"\u00f8":25,"t":20,"u":8,"i":4,"j":-45}},"|":{"d":"1,72r61,-344r49,0r-61,344r-49,0","w":113},"*":{"d":"54,-148r19,-39r-42,5r0,-36r44,6r-17,-39r31,-9r9,41r33,-25r19,28v-12,6,-27,10,-37,18r36,22r-22,27v-11,-9,-18,-23,-31,-30r-12,42","w":149,"k":{".":34,",":34}},"-":{"d":"8,-75r9,-45r109,0r-7,45r-111,0","w":136,"k":{"\u00c6":4,"J":10,"S":6,"T":23,"W":12,"Y":30,"v":2,"w":2,"y":2,"z":1,"V":16,"X":11,"x":5,"8":1,"5":1,"4":8,"1":6,"7":15,"3":10,"2":8}},"(":{"d":"58,72v-67,-99,-45,-271,51,-344r60,0v-59,49,-100,128,-100,211v0,57,20,101,41,133r-52,0","w":145,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":8,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":7,"d":7,"g":7,"q":7,"\u00e5":7,"\u00e6":7,"c":6,"e":6,"o":6,"\u00f8":6,"(":11,"[":11,"{":11,"X":2,"4":10,"1":6,"6":3,"0":4,"2":2}},")":{"d":"127,-134v0,78,-33,156,-92,206r-59,0v59,-50,100,-127,100,-211v0,-57,-20,-101,-41,-133r53,0v20,32,39,80,39,138","w":145,"k":{")":11,"]":11,"}":11,"*":2}},"[":{"d":"111,35r-7,37r-109,0r61,-344r109,0r-7,37r-55,0r-48,270r56,0","w":154,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":8,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":7,"d":7,"g":7,"q":7,"\u00e5":7,"\u00e6":7,"c":6,"e":6,"o":6,"\u00f8":6,"(":11,"[":11,"{":11,"X":2,"4":10,"1":6,"6":3,"0":4,"2":2}},"]":{"d":"-6,35r55,0r48,-270r-56,0r7,-37r108,0r-60,344r-109,0","w":154,"k":{")":11,"]":11,"}":11,"*":2}},"{":{"d":"132,35r-7,37v-57,3,-99,-10,-89,-66r11,-65v2,-18,-22,-18,-41,-17r8,-46v30,1,45,0,50,-31v9,-62,13,-127,91,-119r31,0r-7,38v-27,-1,-48,-1,-52,24v-8,47,-5,105,-56,112v51,17,20,71,17,117v-1,19,25,16,44,16","w":174,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":8,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":7,"d":7,"g":7,"q":7,"\u00e5":7,"\u00e6":7,"c":6,"e":6,"o":6,"\u00f8":6,"(":11,"[":11,"{":11,"X":2,"4":10,"1":6,"6":3,"0":4,"2":2}},"}":{"d":"42,-234r7,-38v57,-3,102,10,90,66v-4,22,-10,41,-12,66v-2,20,21,18,41,18r-8,46v-30,-1,-45,0,-50,30v-9,61,-13,125,-91,118r-31,0r7,-37v27,1,48,0,52,-25v8,-47,6,-103,56,-110v-52,-18,-20,-73,-17,-119v1,-19,-26,-15,-44,-15","w":174,"k":{")":11,"]":11,"}":11,"*":2}},"@":{"d":"22,-102v0,-72,59,-131,131,-131v70,0,123,52,123,119v0,57,-41,84,-73,84v-23,0,-36,-11,-41,-24v-23,31,-84,23,-81,-30v-8,-52,61,-118,101,-70r7,-13r31,0r-24,85v-6,20,1,30,15,30v20,0,44,-21,44,-62v0,-55,-44,-97,-102,-97v-60,0,-109,49,-109,109v0,83,98,138,170,90r12,17v-83,60,-204,-6,-204,-107xm117,-86v3,35,36,26,45,-3r13,-44v-27,-25,-61,16,-58,47","w":294,"k":{"A":3,"\u00c5":3,"\u00c6":6,"J":8,"S":6,"T":33,"U":3,"W":27,"Y":45,"Z":4,"v":12,"w":12,"y":12,"z":1,"f":4,"t":1,"V":31,"X":16,"x":9,"5":5,"4":8,"1":9,"7":16,"3":16,"2":6}},"&":{"d":"7,-65v0,-38,27,-67,62,-82v-32,-50,4,-109,65,-109v34,0,58,16,73,34r-35,27v-17,-24,-64,-29,-66,7v9,44,47,66,74,98v8,-14,13,-30,16,-47r48,0v-5,29,-16,55,-31,77r37,31r-33,32v-12,-9,-23,-20,-35,-30v-47,47,-175,41,-175,-38xm150,-56v-21,-20,-41,-40,-59,-61v-39,14,-54,78,6,79v20,0,38,-7,53,-18","w":264,"k":{"J":5,"S":3,"T":31,"U":6,"W":31,"Y":45,"Z":1,"?":8,"v":4,"w":4,"y":4,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"f":1,"c":4,"e":4,"o":4,"\u00f8":4,"t":3,"u":2,"V":27,"X":9,"x":1,"8":4,"5":8,"4":2,"9":5,"1":9,"7":16,"6":5,"3":15,"0":5}},"0":{"d":"103,4v-50,0,-90,-33,-90,-90v0,-72,56,-121,123,-121v50,0,90,33,90,91v0,72,-56,120,-123,120xm131,-164v-57,0,-95,125,-22,125v33,0,61,-36,61,-76v0,-30,-13,-49,-39,-49","w":239,"k":{"$":1,"8":1,"7":13,"5":3,"4":4,"3":13,"2":3,"1":5,"*":29,"\\":29,"\/":13,")":2,"]":2,"}":2,"?":29,"'":5,"\"":5,"&":-1}},"1":{"d":"102,0r-54,0r26,-152r-41,16r-17,-41v39,-11,68,-32,123,-28","w":155,"k":{"9":1,"8":1,"7":2,"6":1,"5":3,"4":2,"3":4,"0":1,"*":5,"\\":9,"-":4,"?":9,"'":2,"\"":2,"@":4}},"2":{"d":"4,0v-3,-115,151,-105,152,-143v0,-14,-12,-23,-36,-23v-23,0,-48,10,-71,26r-23,-36v48,-42,184,-46,183,31v0,72,-129,66,-143,103r123,0r-8,42r-177,0","w":217,"k":{"9":-2,"8":4,"7":7,"5":4,"4":4,"3":4,"2":3,"*":12,"\\":10,"-":1,"?":14,"@":-2,"&":1}},"3":{"d":"-9,30r24,-36v35,27,123,27,123,-25v0,-33,-45,-29,-80,-29r6,-39v41,3,87,-3,84,-37v-6,-45,-74,-29,-102,-6r-20,-37v49,-41,177,-40,177,38v0,31,-17,50,-45,61v24,10,34,29,34,52v3,84,-139,103,-201,58","w":215,"k":{"8":3,"7":4,"5":1,"4":4,"3":4,"1":1,"*":17,"\\":19,"\/":-1,".":-1,",":-1,"?":18,"'":1,"\"":1,"@":1}},"4":{"d":"13,0r-12,-40r157,-163r55,0r-28,163r31,0r-7,40r-32,0r-8,50r-52,0r9,-50r-113,0xm54,-40r79,0r18,-104","w":236,"k":{"9":1,"8":2,"7":5,"6":2,"3":3,"1":2,"0":1,"*":14,"\\":13,"\/":-2,"-":8,".":-1,",":-1,"?":16,"'":6,"\"":6,"@":9,"&":1}},"5":{"d":"-10,29r24,-36v38,28,119,21,119,-33v0,-42,-51,-37,-83,-22r-27,-19r26,-122r151,0r-6,40r-104,0r-12,59v51,-23,111,0,111,60v0,96,-131,122,-199,73","w":212,"k":{"9":1,"8":5,"7":6,"6":2,"5":3,"4":2,"3":4,"2":1,"1":3,"0":5,"*":7,"\\":11,"-":4,"?":18,"'":4,"\"":4,"@":8,"&":2}},"6":{"d":"15,-100v0,-123,108,-191,206,-137r-24,34v-51,-30,-115,0,-122,61v45,-39,135,-25,135,48v0,54,-42,98,-107,98v-59,0,-88,-44,-88,-104xm123,-127v-23,0,-53,10,-54,39v0,27,12,51,39,51v52,0,71,-90,15,-90","w":225,"k":{"$":2,"9":3,"7":8,"6":2,"5":6,"4":3,"3":14,"2":4,"1":6,"*":8,"\\":4,"\/":8,"?":11,"'":5,"\"":5,"@":1}},"7":{"d":"15,49r130,-209r-121,0r7,-43r177,0r-6,38r-127,214r-60,0","w":203,"k":{"$":3,"9":3,"8":4,"5":1,"4":19,"3":3,"2":5,"0":2,"\\":1,"\/":14,"-":6,".":11,",":11,"?":4,"&":4}},"8":{"d":"8,-60v0,-37,30,-61,67,-73v-20,-10,-36,-25,-36,-50v0,-45,44,-73,105,-73v49,0,85,24,85,62v0,32,-23,54,-54,65v26,10,43,28,43,56v0,49,-48,77,-115,77v-58,0,-95,-24,-95,-64xm121,-111v-56,2,-86,74,-13,76v63,4,75,-70,13,-76xm127,-150v49,-1,71,-65,12,-67v-50,-3,-65,62,-12,67","w":239,"k":{"$":4,"9":2,"7":8,"5":3,"4":5,"3":15,"2":5,"1":1,"0":2,"*":5,"\\":6,"\/":5,"-":1,"?":10,"@":2}},"9":{"d":"149,-60v-46,38,-135,24,-135,-49v0,-54,40,-98,104,-98v60,0,91,44,91,104v0,126,-111,195,-208,135r26,-33v48,33,115,2,122,-59xm67,-111v-2,51,67,36,86,12v5,-33,-5,-67,-37,-67v-32,0,-49,28,-49,55","w":225,"k":{"7":10,"5":2,"4":1,"3":10,"2":5,"1":4,"*":20,"\\":27,"?":23,"'":4,"\"":4,"@":2}},"#":{"d":"24,-122r7,-37r44,0r15,-44r43,0r-15,44r40,0r16,-44r42,0r-14,44r37,0r-6,37r-44,0r-14,42r40,0r-7,36r-45,0r-15,44r-43,0r15,-44r-41,0r-15,44r-43,0r15,-44r-37,0r7,-36r42,0r14,-42r-38,0xm105,-122r-14,42r41,0r14,-42r-41,0","w":239},"$":{"d":"0,-23r28,-33v15,10,34,18,54,20r8,-46v-31,-8,-67,-19,-67,-59v0,-40,32,-64,86,-66r5,-31r25,0r-5,32v22,3,43,11,57,19r-26,34v-13,-6,-28,-12,-42,-14r-7,45v30,8,65,20,65,59v0,39,-27,64,-85,67r-7,44r-25,0r8,-45v-29,-3,-55,-13,-72,-26xm74,-145v0,10,10,14,24,18r7,-40v-19,1,-31,11,-31,22xm100,-36v34,-2,41,-35,8,-41","w":201,"k":{"9":6,"8":2,"7":12,"5":7,"4":6,"3":9,"2":3,"1":4}},"+":{"d":"9,-75r8,-44r71,0r14,-75r47,0r-13,75r71,0r-8,44r-71,0r-13,75r-48,0r13,-75r-71,0","w":217},"=":{"d":"1,-31r8,-43r190,0r-7,43r-191,0xm17,-120r8,-43r190,0r-8,43r-190,0","w":217},"<":{"d":"177,0r-168,-73r8,-48r194,-73r-9,55r-127,44r111,44","w":212},">":{"d":"34,-194r169,74r-8,47r-195,73r10,-54r127,-45r-111,-44","w":212},"%":{"d":"216,-203r37,0r-175,203r-37,0xm16,-145v0,-35,29,-62,68,-62v30,0,51,20,51,49v0,36,-30,62,-69,62v-30,0,-50,-20,-50,-49xm80,-179v-30,-3,-44,54,-9,56v29,3,45,-55,9,-56xm159,-45v0,-36,29,-62,68,-62v30,0,51,19,51,48v0,36,-30,63,-69,63v-30,0,-50,-20,-50,-49xm223,-79v-29,-4,-45,53,-10,55v30,4,46,-53,10,-55","w":294},"~":{"d":"17,-68v0,-37,16,-67,52,-67v30,0,44,27,65,27v11,0,15,-8,17,-21r34,0v0,39,-15,66,-52,66v-29,0,-44,-27,-64,-27v-11,0,-17,10,-18,22r-34,0","w":203},"^":{"d":"48,-202r62,-67r51,0r38,67r-40,0r-26,-32r-38,32r-47,0","w":209},"\u00a0":{"w":84}}});
Cufon.registerFont({"w":221,"face":{"font-family":"Alright Sans","font-weight":400,"font-stretch":"normal","units-per-em":"360","panose-1":"0 0 5 0 0 0 0 0 0 0","ascent":"274","descent":"-86","x-height":"4","bbox":"-27 -316 378 76","underline-thickness":"18","underline-position":"-18","stemh":"44","stemv":"55","unicode-range":"U+0020-U+00F8"},"glyphs":{" ":{"w":86},"A":{"d":"6,0r91,-252r62,0r91,252r-58,0r-16,-47r-96,0r-15,47r-59,0xm128,-192v-14,32,-22,69,-34,103r68,0","w":256,"k":{"-":4,"J":2,"S":3,"T":27,"U":9,"W":17,"Y":32,"a":1,"\u00e5":1,"\u00e6":1,"&":1,"g":1,"c":5,"e":5,"o":5,"\u00f8":5,")":4,"]":4,"}":4,"?":22,"'":1,"\"":1,"s":1,"v":14,"w":14,"y":14,"C":10,"G":10,"O":10,"Q":10,"\u00d8":10,"@":5,"d":3,"q":3,"f":10,"t":13,"u":6,"V":23,"X":1,"*":31,"\\":23,"x":1}},"B":{"d":"24,0r0,-252r106,0v95,-7,117,92,51,121v85,31,49,131,-46,131r-111,0xm78,-44v41,-1,96,9,96,-33v0,-41,-56,-31,-96,-32r0,65xm78,-147v37,1,87,5,87,-31v0,-35,-50,-31,-87,-30r0,61","w":243,"k":{"A":5,"\u00c5":5,"\u00c6":10,"J":5,"S":3,"T":8,"U":1,"W":4,"Y":12,"Z":1,"a":2,"\u00e5":2,"\u00e6":2,"g":3,")":3,"]":3,"}":3,"?":4,"s":2,"z":1,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"f":1,"t":1,"u":1,"V":4,"X":10,"*":4,"\\":2,"x":4,"\/":16}},"C":{"d":"15,-127v0,-114,141,-168,223,-97r-30,37v-50,-46,-138,-19,-138,60v0,83,92,110,140,59r32,35v-78,77,-227,27,-227,-94","w":253,"k":{"-":10,"A":1,"\u00c5":1,"\u00c6":6,"J":4,"S":1,"T":2,"U":1,"W":2,"Y":5,"a":3,"\u00e5":3,"\u00e6":3,"g":4,"c":9,"e":9,"o":9,"\u00f8":9,"s":4,"v":8,"w":8,"y":8,"z":1,"C":9,"G":9,"O":9,"Q":9,"\u00d8":9,"@":2,"d":6,"q":6,"f":5,"m":2,"n":2,"p":2,"r":2,"t":4,"u":3,"V":3,"X":5,"*":1,"x":6,"\/":9}},"D":{"d":"24,0r0,-252r83,0v90,0,139,47,139,125v0,80,-46,127,-139,127r-83,0xm79,-44v70,7,112,-20,112,-83v0,-61,-43,-88,-112,-81r0,164","w":260,"k":{"A":10,"\u00c5":10,"\u00c6":19,"J":12,"S":4,"T":9,"W":9,"Y":20,"Z":5,"a":3,"\u00e5":3,"\u00e6":3,")":8,"]":8,"}":8,".":9,",":9,"?":6,"z":1,"V":8,"X":15,"*":3,"\\":6,"x":4,"\/":28}},"E":{"d":"24,0r0,-252r184,0r0,48r-129,0r0,55r115,0r0,42r-115,0r0,59r131,0r0,48r-186,0","w":228,"k":{"-":4,"J":3,"S":1,"Y":1,"a":3,"\u00e5":3,"\u00e6":3,"g":1,"c":5,"e":5,"o":5,"\u00f8":5,"s":3,"v":4,"w":4,"y":4,"z":1,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"d":2,"q":2,"f":3,"m":1,"n":1,"p":1,"r":1,"t":1,"u":3,"V":1,"x":2}},"F":{"d":"24,0r0,-252r181,0r0,48r-126,0r0,59r109,0r0,44r-109,0r0,101r-55,0","w":223,"k":{"-":10,"A":27,"\u00c5":27,"\u00c6":46,"J":38,"S":5,"U":1,"W":2,"Y":5,"Z":3,"a":15,"\u00e5":15,"\u00e6":15,"&":11,"g":15,"c":17,"e":17,"o":17,"\u00f8":17,".":28,",":28,"?":2,"s":12,"v":6,"w":6,"y":6,"z":14,"C":6,"G":6,"O":6,"Q":6,"\u00d8":6,"@":14,":":9,";":9,"d":14,"q":14,"f":4,"m":8,"n":8,"p":8,"r":8,"t":1,"u":10,"i":5,"V":2,"X":8,"x":10,"\/":46}},"G":{"d":"15,-127v0,-73,51,-129,131,-129v38,0,67,12,93,31r-28,36v-53,-43,-141,-16,-141,62v0,70,65,104,122,74r0,-50r-57,0r0,-37r106,0r0,115v-25,18,-58,29,-95,29v-80,0,-131,-54,-131,-131","w":263,"k":{"A":1,"\u00c5":1,"\u00c6":4,"T":4,"W":3,"Y":6,"a":3,"\u00e5":3,"\u00e6":3,"g":4,"?":3,"v":3,"w":3,"y":3,"f":3,"t":1,"V":4,"X":5,"*":2,"x":4,"\/":11}},"H":{"d":"24,0r0,-252r55,0r0,101r98,0r0,-101r55,0r0,252r-55,0r0,-104r-98,0r0,104r-55,0","w":256},"I":{"d":"24,0r0,-252r55,0r0,252r-55,0","w":103},"J":{"d":"12,-45r41,-27v15,38,75,40,75,-12r0,-168r55,0r0,169v7,103,-136,113,-171,38","w":205,"k":{"A":9,"\u00c5":9,"\u00c6":14,"J":9,"Y":1,"Z":1,"a":3,"\u00e5":3,"\u00e6":3,"g":3,".":8,",":8,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"X":1,"x":3,"\/":18}},"K":{"d":"24,0r0,-252r55,0r0,118r96,-118r60,0r-79,94r87,158r-62,0r-60,-116r-42,50r0,66r-55,0","w":249,"k":{"-":13,"J":4,"S":4,"T":4,"U":5,"W":1,"Y":1,"Z":1,"a":4,"\u00e5":4,"\u00e6":4,"&":2,"g":3,"c":10,"e":10,"o":10,"\u00f8":10,"?":6,"s":3,"v":6,"w":6,"y":6,"z":1,"C":14,"G":14,"O":14,"Q":14,"\u00d8":14,"@":11,"d":7,"q":7,"f":4,"m":1,"n":1,"p":1,"r":1,"t":4,"u":7,"V":2,"X":2,"*":7,"x":4}},"L":{"d":"24,0r0,-252r55,0r0,205r125,0r0,47r-180,0","w":216,"k":{"-":6,"J":2,"S":1,"T":32,"U":5,"W":20,"Y":34,"a":1,"\u00e5":1,"\u00e6":1,"g":1,"c":3,"e":3,"o":3,"\u00f8":3,"?":21,"'":3,"\"":3,"s":1,"v":10,"w":10,"y":10,"z":1,"C":9,"G":9,"O":9,"Q":9,"\u00d8":9,"@":3,"d":2,"q":2,"f":3,"t":9,"u":3,"V":22,"X":2,"*":15,"\\":19,"x":1}},"M":{"d":"24,0r0,-252r55,0r76,108r76,-108r54,0r0,252r-51,0r0,-174r-79,108r-79,-108r0,174r-52,0","w":309},"N":{"d":"24,0r0,-252r52,0r113,166r0,-166r51,0r0,252r-51,0r-113,-165r0,165r-52,0","w":264},"O":{"d":"15,-127v0,-76,54,-129,130,-129v77,0,131,53,131,129v0,76,-54,131,-131,131v-76,0,-130,-55,-130,-131xm70,-127v0,51,31,85,75,85v44,0,76,-34,76,-85v0,-50,-31,-84,-76,-84v-44,0,-75,34,-75,84","w":290,"k":{"A":10,"\u00c5":10,"\u00c6":19,"J":12,"S":4,"T":9,"W":9,"Y":20,"Z":5,"a":3,"\u00e5":3,"\u00e6":3,")":8,"]":8,"}":8,".":9,",":9,"?":6,"z":1,"V":8,"X":15,"*":3,"\\":6,"x":4,"\/":28}},"P":{"d":"24,0r0,-252r106,0v72,0,97,40,97,80v0,40,-25,81,-97,81r-51,0r0,91r-55,0xm79,-134v42,2,99,3,94,-37v4,-41,-51,-39,-94,-37r0,74","w":243,"k":{"-":12,"A":28,"\u00c5":28,"\u00c6":45,"J":42,"S":3,"T":2,"U":1,"W":5,"Y":10,"Z":5,"a":7,"\u00e5":7,"\u00e6":7,"&":10,"g":9,"c":9,"e":9,"o":9,"\u00f8":9,")":4,"]":4,"}":4,".":40,",":40,"?":5,"s":4,"z":3,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"@":8,"d":6,"q":6,"m":3,"n":3,"p":3,"r":3,"u":3,"V":3,"X":17,"\\":2,"x":3,"\/":59}},"Q":{"d":"15,-127v0,-76,54,-129,130,-129v111,0,167,128,105,211r28,24r-27,30r-30,-27v-86,56,-206,-2,-206,-109xm145,-86r25,-28r40,36v29,-55,-1,-133,-65,-133v-44,0,-75,34,-75,84v0,67,59,104,114,75","w":292,"k":{".":9,"A":10,"\u00c5":10,"\u00c6":19,"J":12,"S":4,"T":9,"W":9,"Y":20,"Z":5,"a":3,"\u00e5":3,"\u00e6":3,")":8,"]":8,"}":8,",":9,"?":6,"z":1,"V":8,"X":15,"*":3,"\\":6,"x":4,"\/":28}},"R":{"d":"24,0r0,-252r111,0v114,-2,125,113,51,149r48,103r-58,0r-39,-94r-58,0r0,94r-55,0xm79,-134v43,1,98,5,98,-37v0,-43,-54,-38,-98,-37r0,74","w":252,"k":{"-":9,"A":4,"\u00c5":4,"J":12,"S":2,"T":3,"U":2,"W":6,"Y":13,"a":3,"\u00e5":3,"\u00e6":3,"&":2,"g":2,"c":5,"e":5,"o":5,"\u00f8":5,"?":3,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"@":5,"d":3,"q":3,"u":3,"V":3,"X":5,"*":1,"\\":4}},"S":{"d":"14,-23r26,-43v22,13,49,23,74,23v27,0,41,-12,41,-28v0,-47,-136,-15,-136,-110v0,-41,34,-75,92,-75v33,0,63,8,91,21r-20,43v-32,-18,-107,-30,-107,10v0,46,136,14,136,111v0,42,-32,75,-97,75v-38,0,-76,-12,-100,-27","w":227,"k":{"v":8,"A":5,"\u00c5":5,"\u00c6":8,"S":3,"T":5,"W":4,"Y":6,"a":4,"\u00e5":4,"\u00e6":4,"g":2,".":1,",":1,"?":4,"s":3,"w":8,"y":8,"z":4,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"f":3,"t":3,"u":2,"V":4,"X":8,"*":5,"\\":2,"x":7,"\/":15}},"T":{"d":"93,0r0,-204r-84,0r0,-48r221,0r0,48r-83,0r0,204r-54,0","w":239,"k":{"-":24,"A":27,"\u00c5":27,"\u00c6":44,"J":40,"S":2,"Y":2,"a":17,"\u00e5":17,"\u00e6":17,"&":10,"g":21,"c":24,"e":24,"o":24,"\u00f8":24,".":27,",":27,"?":1,"s":17,"v":12,"w":12,"y":12,"z":14,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"@":21,":":22,";":22,"d":18,"q":18,"f":4,"m":12,"n":12,"p":12,"r":12,"t":5,"u":16,"X":2,"x":12,"\/":43}},"U":{"d":"23,-96r0,-156r55,0r0,156v0,34,21,54,52,54v30,0,51,-20,51,-54r0,-156r55,0r0,156v0,67,-44,100,-106,100v-62,0,-107,-33,-107,-100","w":259,"k":{"A":9,"\u00c5":9,"\u00c6":14,"J":9,"Y":1,"Z":1,"a":3,"\u00e5":3,"\u00e6":3,"g":3,".":8,",":8,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"X":1,"x":3,"\/":18}},"V":{"d":"96,0r-90,-252r59,0r63,189r62,-189r59,0r-91,252r-62,0","w":254,"k":{"\/":48,"x":6,"X":1,"-":12,"A":23,"\u00c5":23,"\u00c6":36,"J":32,"S":6,"Z":1,"a":15,"\u00e5":15,"\u00e6":15,"&":13,"g":19,"c":15,"e":15,"o":15,"\u00f8":15,".":28,",":28,"?":1,"s":14,"v":5,"w":5,"y":5,"z":8,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"@":19,":":17,";":17,"d":11,"q":11,"f":1,"m":8,"n":8,"p":8,"r":8,"u":8}},"W":{"d":"87,0r-79,-252r57,0r53,174r50,-174r50,0r51,174r52,-174r57,0r-80,252r-55,0r-50,-171r-50,171r-56,0","w":385,"k":{"-":8,"A":17,"\u00c5":17,"\u00c6":34,"J":34,"S":5,"a":15,"\u00e5":15,"\u00e6":15,"&":14,"g":16,"c":16,"e":16,"o":16,"\u00f8":16,".":22,",":22,"?":1,"s":13,"v":4,"w":4,"y":4,"z":6,"C":9,"G":9,"O":9,"Q":9,"\u00d8":9,"@":16,":":9,";":9,"d":10,"q":10,"f":1,"m":9,"n":9,"p":9,"r":9,"u":6,"X":1,"x":5,"\/":39}},"X":{"d":"9,0r86,-129r-83,-123r66,0r53,81r53,-81r64,0r-83,123r86,129r-66,0r-56,-86r-56,86r-64,0","w":259,"k":{"*":5,"x":1,"V":1,"-":13,"A":1,"\u00c5":1,"\u00c6":2,"J":9,"S":7,"T":2,"U":1,"W":1,"Y":2,"a":7,"\u00e5":7,"\u00e6":7,"&":4,"g":1,"c":14,"e":14,"o":14,"\u00f8":14,")":2,"]":2,"}":2,"?":9,"s":6,"v":15,"w":15,"y":15,"z":3,"C":15,"G":15,"O":15,"Q":15,"\u00d8":15,"@":18,"d":11,"q":11,"f":3,"m":3,"n":3,"p":3,"r":3,"t":5,"u":11}},"Y":{"d":"99,0r0,-101r-94,-151r63,0r59,97r59,-97r62,0r-94,151r0,101r-55,0","w":253,"k":{"-":25,"A":32,"\u00c5":32,"\u00c6":47,"J":43,"S":12,"T":2,"U":1,"Z":1,"a":23,"\u00e5":23,"\u00e6":23,"&":24,"g":32,"c":31,"e":31,"o":31,"\u00f8":31,".":33,",":33,"?":4,"s":24,"v":19,"w":19,"y":19,"z":17,"C":20,"G":20,"O":20,"Q":20,"\u00d8":20,"@":36,":":22,";":22,"d":25,"q":25,"f":9,"m":18,"n":18,"p":18,"r":18,"t":6,"u":18,"X":2,"*":2,"x":20,"\/":53}},"Z":{"d":"17,0r0,-41r127,-162r-127,0r0,-49r199,0r0,41r-127,162r131,0r0,49r-203,0","w":234,"k":{"-":2,"\u00c6":1,"J":2,"S":1,"U":1,"Y":1,"a":1,"\u00e5":1,"\u00e6":1,"&":1,"g":2,"c":2,"e":2,"o":2,"\u00f8":2,"s":3,"v":3,"w":3,"y":3,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"@":3,"f":1,"m":1,"n":1,"p":1,"r":1,"t":1,"u":1,"V":1,"*":1,"x":1}},"a":{"d":"14,-47v0,-42,40,-64,112,-69v2,-24,-1,-40,-27,-40v-18,0,-38,7,-62,19r-18,-39v55,-35,159,-31,159,45r0,81v0,10,6,15,16,15r0,36v-36,0,-51,-6,-62,-24v-28,41,-118,36,-118,-24xm67,-53v1,31,49,20,59,3r0,-37v-30,2,-59,10,-59,34","w":203,"k":{"T":17,"W":13,"Y":27,"g":1,"c":1,"e":1,"o":1,"\u00f8":1,"?":14,"'":1,"\"":1,"v":6,"w":6,"y":6,"f":1,"t":1,"u":1,"V":14,"*":14,"\\":9}},"b":{"d":"23,0r0,-272r53,0r0,100v50,-53,130,-22,130,73v0,101,-82,130,-133,76r-4,23r-46,0xm76,-55v32,37,77,18,77,-44v0,-62,-47,-73,-77,-38r0,82","w":219,"k":{"A":3,"\u00c5":3,"T":18,"W":10,"Y":25,"a":1,"\u00e5":1,"\u00e6":1,".":1,",":1,"?":14,"'":1,"\"":1,"v":3,"w":3,"y":3,"z":5,"V":11,"X":11,"\\":5,"x":6,"\/":5}},"c":{"d":"13,-98v0,-92,101,-128,167,-76r-27,34v-33,-29,-87,-16,-87,42v0,60,53,75,87,44r29,31v-62,57,-169,21,-169,-75","w":189,"k":{"-":1,"J":1,"T":10,"W":5,"Y":12,"g":1,"c":6,"e":6,"o":6,"\u00f8":6,"?":5,"z":1,"d":3,"q":3,"u":1,"V":5,"X":2,"x":1}},"d":{"d":"147,-23v-50,53,-134,26,-134,-76v0,-94,80,-126,131,-73r0,-100r53,0r0,272r-47,0xm66,-99v0,63,45,81,78,44r0,-82v-30,-35,-78,-25,-78,38","w":218,"k":{"g":1}},"e":{"d":"13,-98v0,-62,43,-100,97,-100v63,0,95,48,84,112r-127,0v1,59,65,57,101,32r22,33v-68,52,-177,25,-177,-77xm112,-160v-22,0,-39,15,-44,43r78,0v0,-24,-9,-43,-34,-43","w":210,"k":{"A":3,"\u00c5":3,"\u00c6":2,"J":1,"T":15,"W":13,"Y":26,"a":3,"\u00e5":3,"\u00e6":3,"g":1,"?":5,"v":3,"w":3,"y":3,"z":3,"V":12,"X":8,"*":6,"\\":7,"x":9,"\/":5}},"f":{"d":"36,0r0,-153r-30,0r0,-37r30,0v-8,-79,63,-99,124,-76r-13,36v-30,-12,-67,-3,-58,40r49,0r0,37r-49,0r0,153r-53,0","w":149,"k":{"-":5,"A":9,"\u00c5":9,"\u00c6":18,"J":23,"a":4,"\u00e5":4,"\u00e6":4,"&":1,"g":4,"c":12,"e":12,"o":12,"\u00f8":12,")":-7,"]":-7,"}":-7,".":14,",":14,"?":-2,"'":-15,"\"":-15,"s":1,"z":1,"@":4,"d":8,"q":8,"u":1,"i":-4,"*":-5,"\\":-26,"x":1,"\/":22,"b":-4,"h":-4,"k":-4,"l":-4}},"g":{"d":"103,76v-88,0,-128,-54,-69,-91v-20,-18,-13,-47,8,-58v-56,-38,-21,-125,56,-125v22,0,41,7,55,17v13,-10,29,-17,54,-17r0,35v-13,0,-24,1,-34,4v30,63,-33,119,-105,99v-5,2,-7,5,-7,10v0,9,11,14,52,15v57,2,89,17,89,54v0,35,-32,57,-99,57xm98,-91v20,0,33,-14,33,-36v0,-22,-13,-36,-33,-36v-19,0,-33,14,-33,36v0,22,14,36,33,36xm107,6v-15,0,-28,-2,-39,-5v-24,22,-16,42,34,42v35,0,51,-6,51,-18v0,-13,-10,-18,-46,-19","w":214,"k":{"-":4,"\u00c6":2,"J":13,"T":7,"W":4,"Y":5,"a":4,"\u00e5":4,"\u00e6":4,"&":3,"c":9,"e":9,"o":9,"\u00f8":9,".":2,",":2,"?":3,"'":-3,"\"":-3,"s":4,"@":4,"f":-2,"t":-2,"u":1,"j":-21,"V":2,"X":4,"\\":2}},"h":{"d":"23,0r0,-272r53,0r0,101v34,-44,119,-34,119,43r0,128r-53,0r0,-129v1,-41,-50,-33,-66,-7r0,136r-53,0","w":215,"k":{"T":10,"W":12,"Y":27,")":1,"]":1,"}":1,"?":10,"'":1,"\"":1,"v":4,"w":4,"y":4,"V":9,"*":8,"\\":5}},"i":{"d":"23,0r0,-190r53,0r0,190r-53,0xm23,-225r0,-45r53,0r0,45r-53,0","w":97,"k":{"T":9,"Y":2,"g":1,"j":-9,"V":2}},"j":{"d":"27,5r0,-195r53,0r0,192v5,68,-56,86,-107,66r12,-38v21,6,42,6,42,-25xm27,-224r0,-46r53,0r0,46r-53,0","w":102,"k":{"T":9,"Y":2,"g":1,"j":-9,"V":2}},"k":{"d":"23,0r0,-272r53,0r0,163r70,-84r56,0r-60,68r64,125r-59,0r-40,-85r-31,36r0,49r-53,0","w":210,"k":{"-":5,"J":1,"T":10,"U":1,"W":2,"Y":5,"a":3,"\u00e5":3,"\u00e6":3,"g":1,"c":12,"e":12,"o":12,"\u00f8":12,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"@":3,"d":6,"q":6,"V":2}},"l":{"d":"23,0r0,-272r53,0r0,272r-53,0","w":98,"k":{"g":1}},"m":{"d":"22,0r0,-193r50,0r2,21v26,-30,91,-38,108,2v40,-46,123,-36,123,41r0,129r-52,0r0,-130v0,-40,-45,-32,-63,-8r0,138r-52,0r0,-130v0,-41,-48,-31,-63,-6r0,136r-53,0","w":326,"k":{"T":10,"W":12,"Y":27,")":1,"]":1,"}":1,"?":10,"'":1,"\"":1,"v":4,"w":4,"y":4,"V":9,"*":8,"\\":5}},"n":{"d":"22,0r0,-193r50,0r2,22v34,-44,120,-34,120,43r0,128r-53,0r0,-129v1,-41,-50,-33,-66,-7r0,136r-53,0","w":214,"k":{"T":10,"W":12,"Y":27,")":1,"]":1,"}":1,"?":10,"'":1,"\"":1,"v":4,"w":4,"y":4,"V":9,"*":8,"\\":5}},"o":{"d":"13,-99v0,-60,42,-99,98,-99v55,0,96,39,96,99v0,64,-38,103,-96,103v-58,0,-98,-39,-98,-103xm67,-98v0,38,16,63,44,63v27,0,43,-25,43,-63v0,-36,-17,-60,-43,-60v-27,0,-44,24,-44,60","k":{"z":6,"A":4,"\u00c5":4,"\u00c6":4,"J":1,"T":24,"W":15,"Y":31,"a":4,"\u00e5":4,"\u00e6":4,"g":1,")":3,"]":3,"}":3,".":1,",":1,"?":19,"v":5,"w":5,"y":5,"t":1,"V":15,"X":14,"*":12,"\\":8,"x":10,"\/":9}},"p":{"d":"75,-21r0,93r-53,0r0,-265r48,0r4,23v49,-56,131,-25,131,71v0,99,-78,129,-130,78xm75,-55v32,37,78,18,78,-44v0,-62,-48,-73,-78,-38r0,82","w":218,"k":{"A":3,"\u00c5":3,"T":18,"W":10,"Y":25,"a":1,"\u00e5":1,"\u00e6":1,".":1,",":1,"?":14,"'":1,"\"":1,"v":3,"w":3,"y":3,"z":5,"V":11,"X":11,"\\":5,"x":6,"\/":5}},"q":{"d":"66,-99v0,63,45,81,78,44r0,-82v-29,-35,-78,-25,-78,38xm144,-21v-52,50,-131,22,-131,-78v0,-96,83,-127,132,-71r4,-23r48,0r0,265r-53,0r0,-93","w":218,"k":{"T":10,"W":3,"Y":5,"g":1,"?":3,"V":2}},"r":{"d":"22,0r0,-193r49,0r3,30v19,-33,44,-42,79,-32r-8,48v-32,-11,-56,1,-70,31r0,116r-53,0","w":159,"k":{"-":9,"A":13,"\u00c5":13,"\u00c6":23,"J":29,"T":10,"W":2,"Y":2,"Z":2,"a":5,"\u00e5":5,"\u00e6":5,"&":3,"g":6,"c":10,"e":10,"o":10,"\u00f8":10,".":21,",":21,"?":2,"s":6,"@":3,"d":6,"q":6,"V":2,"X":7,"\/":23}},"s":{"d":"11,-17r20,-36v19,10,40,17,60,17v18,0,29,-5,29,-18v0,-33,-105,-12,-105,-84v0,-66,91,-74,149,-43r-19,37v-18,-9,-39,-14,-52,-14v-16,0,-26,6,-26,18v0,32,104,10,104,83v0,72,-111,72,-160,40","w":183,"k":{"A":2,"\u00c5":2,"\u00c6":2,"T":12,"W":5,"Y":14,"g":2,"c":1,"e":1,"o":1,"\u00f8":1,"?":13,"s":1,"@":1,"u":1,"V":7,"X":8,"*":6,"\\":1,"x":2,"\/":4}},"t":{"d":"96,4v-77,0,-58,-90,-60,-160r-30,0r0,-37r30,0r0,-49r53,0r0,49r53,0r0,37r-53,0r0,96v-2,28,29,25,44,13r20,32v-15,12,-36,19,-57,19","w":157,"k":{"-":2,"T":9,"W":4,"Y":4,"g":3,"c":6,"e":6,"o":6,"\u00f8":6,"?":3,"@":1,"d":3,"q":3,"V":5,"*":1}},"u":{"d":"82,4v-89,3,-54,-118,-61,-197r53,0r0,129v-2,41,52,33,67,7r0,-136r53,0r0,193r-49,0r-4,-22v-14,14,-35,26,-59,26","w":215,"k":{"T":10,"W":3,"Y":5,"g":1,"?":3,"V":2}},"v":{"d":"69,0r-64,-193r52,0r42,136r41,-136r50,0r-64,193r-57,0","w":195,"k":{"-":2,"A":13,"\u00c5":13,"\u00c6":13,"J":18,"T":5,"W":2,"Y":2,"a":3,"\u00e5":3,"\u00e6":3,"&":1,"g":7,"c":5,"e":5,"o":5,"\u00f8":5,".":14,",":14,"?":2,"s":2,"@":1,"d":3,"q":3,"V":2,"X":4,"\/":19}},"w":{"d":"68,0r-63,-193r52,0r39,125r35,-125r43,0r36,125r38,-125r51,0r-63,193r-48,0r-36,-119r-36,119r-48,0","w":304,"k":{"-":2,"A":13,"\u00c5":13,"\u00c6":13,"J":18,"T":5,"W":2,"Y":2,"a":3,"\u00e5":3,"\u00e6":3,"&":1,"g":7,"c":5,"e":5,"o":5,"\u00f8":5,".":14,",":14,"?":2,"s":2,"@":1,"d":3,"q":3,"V":2,"X":4,"\/":19}},"x":{"d":"6,0r62,-98r-60,-95r55,0r36,60r35,-60r55,0r-59,95r60,98r-54,0r-38,-62r-38,62r-54,0","w":196,"k":{"\\":4,"V":2,"-":6,"A":1,"\u00c5":1,"J":4,"T":5,"W":2,"Y":12,"a":3,"\u00e5":3,"\u00e6":3,"&":4,"g":1,"c":10,"e":10,"o":10,"\u00f8":10,"?":3,"s":2,"C":1,"G":1,"O":1,"Q":1,"\u00d8":1,"@":7,"d":6,"q":6,"u":3}},"y":{"d":"18,27v21,7,44,13,51,-13r7,-16r-71,-191r53,0r44,127r42,-127r51,0r-72,204v-24,70,-62,73,-120,57","w":200,"k":{"-":2,"A":13,"\u00c5":13,"\u00c6":13,"J":18,"T":5,"W":2,"Y":2,"a":3,"\u00e5":3,"\u00e6":3,"&":1,"g":7,"c":5,"e":5,"o":5,"\u00f8":5,".":14,",":14,"?":2,"s":2,"@":1,"d":3,"q":3,"V":2,"X":4,"\/":19}},"z":{"d":"15,0r0,-35r92,-118r-89,0r0,-40r153,0r0,35r-90,118r94,0r0,40r-160,0","w":187,"k":{"-":1,"T":5,"W":2,"Y":9,"&":1,"c":4,"e":4,"o":4,"\u00f8":4,"?":4,"V":2,"b":1,"h":1,"k":1,"l":1}},"\u00c5":{"d":"6,0r89,-247v-23,-25,-3,-69,33,-69v36,0,56,44,33,69r89,247r-58,0r-16,-47r-96,0r-15,47r-59,0xm128,-192v-14,32,-22,69,-34,103r68,0xm106,-274v0,13,9,23,24,22v12,-1,20,-10,20,-22v0,-13,-9,-23,-22,-23v-12,0,-22,10,-22,23","w":256,"k":{"-":4,"J":2,"S":3,"T":27,"U":9,"W":17,"Y":32,"a":1,"\u00e5":1,"\u00e6":1,"&":1,"g":1,"c":5,"e":5,"o":5,"\u00f8":5,")":4,"]":4,"}":4,"?":22,"'":1,"\"":1,"s":1,"v":14,"w":14,"y":14,"C":10,"G":10,"O":10,"Q":10,"\u00d8":10,"@":5,"d":3,"q":3,"f":10,"t":13,"u":6,"V":23,"X":1,"*":31,"\\":23,"x":1}},"\u00c6":{"d":"4,0r114,-252r243,0r0,48r-157,0r15,54r128,0r0,44r-116,0r17,58r115,0r0,48r-161,0r-12,-47r-104,0r-20,47r-62,0xm151,-201r-46,110r74,0","w":381,"k":{"-":4,"J":3,"S":1,"Y":1,"a":3,"\u00e5":3,"\u00e6":3,"g":1,"c":5,"e":5,"o":5,"\u00f8":5,"s":3,"v":4,"w":4,"y":4,"z":1,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"d":2,"q":2,"f":3,"m":1,"n":1,"p":1,"r":1,"t":1,"u":3,"V":1,"x":2}},"\u00d8":{"d":"15,-127v0,-104,114,-161,202,-110r22,-28r22,18r-22,27v23,23,37,55,37,93v0,103,-113,163,-202,113r-22,27r-22,-17r22,-28v-24,-23,-37,-56,-37,-95xm145,-42v65,0,97,-89,60,-139r-102,127v12,8,26,12,42,12xm145,-211v-66,0,-96,89,-59,140r102,-127v-12,-8,-27,-13,-43,-13","w":290,"k":{"A":10,"\u00c5":10,"\u00c6":19,"J":12,"S":4,"T":9,"W":9,"Y":20,"Z":5,"a":3,"\u00e5":3,"\u00e6":3,")":8,"]":8,"}":8,".":9,",":9,"?":6,"z":1,"V":8,"X":15,"*":3,"\\":6,"x":4,"\/":28}},"\u00e5":{"d":"14,-47v0,-42,40,-64,112,-69v2,-24,-1,-40,-27,-40v-18,0,-38,7,-62,19r-18,-39v55,-35,159,-31,159,45r0,81v0,10,6,15,16,15r0,36v-36,0,-51,-6,-62,-24v-28,41,-118,36,-118,-24xm67,-53v1,31,49,20,59,3r0,-37v-30,2,-59,10,-59,34xm103,-211v-24,0,-43,-17,-43,-41v0,-24,19,-42,43,-42v24,0,43,18,43,42v0,24,-19,41,-43,41xm103,-230v12,0,22,-10,22,-22v0,-13,-10,-23,-22,-23v-13,0,-22,10,-22,23v0,12,9,22,22,22","w":203,"k":{"T":17,"W":13,"Y":27,"g":1,"c":1,"e":1,"o":1,"\u00f8":1,"?":14,"'":1,"\"":1,"v":6,"w":6,"y":6,"f":1,"t":1,"u":1,"V":14,"*":14,"\\":9}},"\u00e6":{"d":"147,-30v-25,43,-134,53,-133,-16v0,-42,40,-64,112,-69v1,-24,0,-41,-26,-41v-18,0,-38,7,-63,19r-18,-39v43,-24,118,-35,141,4v15,-16,36,-26,63,-26v63,-1,96,50,83,112r-127,0v-1,58,65,58,101,32r22,33v-47,37,-122,35,-155,-9xm180,-117r78,0v0,-24,-9,-43,-34,-43v-22,0,-39,15,-44,43xm67,-53v0,34,54,19,64,-4v-3,-9,-4,-18,-5,-29v-30,1,-59,8,-59,33","w":321,"k":{"A":3,"\u00c5":3,"\u00c6":2,"J":1,"T":15,"W":13,"Y":26,"a":3,"\u00e5":3,"\u00e6":3,"g":1,"?":5,"v":3,"w":3,"y":3,"z":3,"V":12,"X":8,"*":6,"\\":7,"x":9,"\/":5}},"\u00f8":{"d":"13,-99v0,-79,81,-122,148,-86r19,-25r23,17r-20,25v15,17,24,41,24,69v0,85,-80,126,-149,90r-22,28r-23,-17r24,-29v-15,-18,-24,-42,-24,-72xm111,-35v37,0,52,-56,38,-94r-65,84v7,6,16,10,27,10xm135,-149v-46,-34,-82,32,-64,82","k":{"A":4,"\u00c5":4,"\u00c6":4,"J":1,"T":24,"W":15,"Y":31,"a":4,"\u00e5":4,"\u00e6":4,"g":1,")":3,"]":3,"}":3,".":1,",":1,"?":19,"v":5,"w":5,"y":5,"z":6,"t":1,"V":15,"X":14,"*":12,"\\":8,"x":10,"\/":9}},"`":{"d":"114,-213r-48,-44r35,-23r46,67r-33,0","w":211},".":{"d":"17,0r0,-55r55,0r0,55r-55,0","w":88,"k":{"S":3,"T":27,"U":8,"W":22,"Y":33,"c":2,"e":2,"o":2,"\u00f8":2,"?":30,"'":8,"\"":8,"v":14,"w":14,"y":14,"C":9,"G":9,"O":9,"Q":9,"\u00d8":9,"d":1,"q":1,"f":2,"t":7,"V":28,"*":37,"8":1,"5":3,"9":4,"1":15,"7":6,"6":3,"3":5,"0":5}},",":{"d":"17,0r0,-55r55,0v3,56,-2,98,-47,109r-11,-20v17,-6,27,-19,27,-34r-24,0","w":88,"k":{"S":3,"T":27,"U":8,"W":22,"Y":33,"c":2,"e":2,"o":2,"\u00f8":2,"?":30,"'":8,"\"":8,"v":14,"w":14,"y":14,"C":9,"G":9,"O":9,"Q":9,"\u00d8":9,"d":1,"q":1,"f":2,"t":7,"V":28,"*":37,"8":1,"5":3,"9":4,"1":15,"7":6,"6":3,"3":5,"0":5}},":":{"d":"17,0r0,-55r55,0r0,55r-55,0xm17,-139r0,-55r55,0r0,55r-55,0","w":88},";":{"d":"17,0r0,-55r55,0v3,56,-2,98,-47,109r-11,-20v17,-6,27,-19,27,-34r-24,0xm17,-139r0,-55r55,0r0,55r-55,0","w":88},"!":{"d":"36,-78v-5,-57,-15,-110,-13,-174r54,0v2,65,-9,117,-14,174r-27,0xm23,0r0,-47r54,0r0,47r-54,0","w":100},"?":{"d":"71,-78v-16,-66,63,-69,63,-107v0,-41,-67,-32,-90,-4r-32,-29v39,-56,176,-51,174,29v-1,68,-78,61,-76,111r-39,0xm63,0r0,-47r54,0r0,47r-54,0","w":201,"k":{".":51,",":51,"?":3}},"'":{"d":"15,-145r0,-107r55,0r-25,107r-30,0","w":83,"k":{"A":5,"\u00c5":5,"\u00c6":21,"J":17,"S":3,"a":4,"\u00e5":4,"\u00e6":4,"g":8,"c":6,"e":6,"o":6,"\u00f8":6,".":19,",":19,"s":5,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"d":5,"q":5,"8":2,"5":4,"9":3,"1":-3,"6":2,"3":6,"0":9,"4":22,"2":2}},"\"":{"d":"15,-145r0,-107r55,0r-25,107r-30,0xm94,-145r0,-107r55,0r-25,107r-30,0","w":163,"k":{"A":5,"\u00c5":5,"\u00c6":21,"J":17,"S":3,"a":4,"\u00e5":4,"\u00e6":4,"g":8,"c":6,"e":6,"o":6,"\u00f8":6,".":19,",":19,"s":5,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"d":5,"q":5,"8":2,"5":4,"9":3,"1":-3,"6":2,"3":6,"0":9,"4":22,"2":2}},"_":{"d":"0,5r200,0r0,44r-200,0r0,-44","w":199,"k":{"_":1}},"\/":{"d":"-4,72r158,-344r50,0r-158,344r-50,0","w":200,"k":{"9":3,"5":2,"4":38,"3":2,"2":4,"1":1,"0":13,"\/":40,"A":23,"\u00c5":23,"\u00c6":25,"J":43,"S":2,"a":8,"\u00e5":8,"\u00e6":8,"g":15,"c":9,"e":9,"o":9,"\u00f8":9,"s":9,"C":6,"G":6,"O":6,"Q":6,"\u00d8":6,"d":4,"q":4,"f":-1}},"\\":{"d":"46,-272r158,344r-50,0r-158,-344r50,0","w":200,"k":{"9":-2,"8":7,"7":4,"6":19,"5":-2,"4":1,"3":-2,"1":14,"0":16,"\\":40,"y":19,"V":48,"J":6,"S":3,"T":43,"U":19,"W":39,"Y":53,"Z":-4,"a":5,"\u00e5":5,"\u00e6":5,"c":9,"e":9,"o":9,"\u00f8":9,"v":19,"w":19,"z":-4,"C":29,"G":29,"O":29,"Q":29,"\u00d8":29,"d":6,"q":6,"f":5,"t":8,"u":5,"i":4,"j":-29}},"|":{"d":"33,72r0,-344r49,0r0,344r-49,0","w":115},"*":{"d":"39,-148v5,-13,16,-28,18,-39r-42,5r1,-36r43,6r-17,-39r31,-9v4,13,4,30,10,41r32,-25r20,28v-12,6,-27,10,-37,18r36,22r-22,27v-11,-10,-19,-21,-31,-30r-12,42","w":152,"k":{".":36,",":36}},"-":{"d":"13,-75r0,-44r112,0r0,44r-112,0","w":138,"k":{"A":4,"\u00c5":4,"\u00c6":4,"J":7,"S":4,"T":24,"W":8,"Y":25,"v":2,"w":2,"y":2,"z":1,"V":12,"X":13,"x":6,"8":2,"5":1,"1":4,"7":10,"3":9,"4":8,"2":11}},"(":{"d":"19,-100v0,-75,28,-131,61,-172r57,0v-34,37,-67,95,-67,172v0,76,33,135,67,172r-56,0v-33,-40,-62,-97,-62,-172","w":147,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":7,"S":1,"a":1,"\u00e5":1,"\u00e6":1,"c":3,"e":3,"o":3,"\u00f8":3,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"d":1,"q":1,"(":11,"[":11,"{":11,"X":2,"1":5,"6":3,"0":2,"4":11,"2":2}},")":{"d":"129,-100v0,75,-29,132,-62,172r-56,0v34,-37,67,-96,67,-172v0,-77,-33,-135,-67,-172r57,0v33,41,61,97,61,172","w":147,"k":{")":11,"]":11,"}":11,"*":2}},"[":{"d":"80,35r56,0r0,37r-109,0r0,-344r109,0r0,37r-56,0r0,270","w":156,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":7,"S":1,"a":1,"\u00e5":1,"\u00e6":1,"c":3,"e":3,"o":3,"\u00f8":3,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"d":1,"q":1,"(":11,"[":11,"{":11,"X":2,"1":5,"6":3,"0":2,"4":11,"2":2}},"]":{"d":"20,35r56,0r0,-270r-56,0r0,-37r109,0r0,344r-109,0r0,-37","w":156,"k":{")":11,"]":11,"}":11,"*":2}},"{":{"d":"109,10v0,27,23,26,49,25r0,37v-59,4,-101,-12,-101,-62v0,-42,17,-99,-46,-86r0,-46v26,1,48,0,46,-27v-4,-71,-4,-127,75,-123r26,0r0,38v-26,-1,-49,-3,-49,25v0,51,10,99,-37,110v47,12,37,57,37,109","w":178,"k":{"A":4,"\u00c5":4,"\u00c6":8,"J":7,"S":1,"a":1,"\u00e5":1,"\u00e6":1,"c":3,"e":3,"o":3,"\u00f8":3,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"d":1,"q":1,"(":11,"[":11,"{":11,"X":2,"1":5,"6":3,"0":2,"4":11,"2":2}},"}":{"d":"20,35v26,1,49,3,49,-25v0,-51,-10,-97,37,-109v-47,-11,-37,-59,-37,-110v0,-27,-23,-26,-49,-25r0,-38v60,-4,102,12,102,62v0,42,-19,101,45,88r0,46v-26,-1,-48,0,-45,27v8,82,-8,132,-102,121r0,-37","w":178,"k":{")":11,"]":11,"}":11,"*":2}},"@":{"d":"22,-102v0,-72,58,-131,130,-131v70,0,123,52,123,119v0,57,-40,84,-72,84v-23,0,-36,-11,-41,-24v-23,31,-82,23,-82,-30v0,-53,61,-118,102,-70r6,-13r32,0r-25,85v-6,20,1,30,15,30v20,0,44,-21,44,-62v0,-55,-43,-97,-101,-97v-60,0,-109,49,-109,109v0,83,98,138,169,90r13,17v-84,59,-204,-6,-204,-107xm117,-86v3,35,37,26,45,-3r12,-44v-27,-25,-60,16,-57,47","w":297,"k":{"A":5,"\u00c5":5,"\u00c6":16,"J":14,"S":3,"T":21,"W":16,"Y":36,"Z":3,"v":1,"w":1,"y":1,"V":18,"X":19,"x":6,"5":4,"7":10,"3":12,"4":10,"2":4}},"&":{"d":"105,4v-104,3,-119,-114,-43,-148v-37,-45,-9,-112,58,-112v31,0,55,14,74,34r-33,28v-17,-24,-62,-31,-66,3v12,46,61,71,91,100v6,-14,9,-29,9,-46r47,0v0,26,-8,51,-20,73v14,10,28,21,43,31r-28,36v-14,-10,-29,-20,-43,-31v-23,20,-54,32,-89,32xm158,-55v-25,-20,-49,-40,-71,-62v-37,19,-33,82,22,79v19,0,35,-7,49,-17","w":270,"k":{"J":4,"S":1,"T":23,"U":4,"W":13,"Y":30,"Z":1,"?":8,"v":1,"w":1,"y":1,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"u":1,"V":17,"X":1,"8":1,"5":7,"9":3,"1":4,"7":10,"6":2,"3":12,"0":4}},"0":{"d":"17,-102v0,-65,47,-105,105,-105v58,0,106,40,106,105v0,66,-48,106,-106,106v-58,0,-105,-40,-105,-106xm72,-102v0,37,19,62,50,62v30,0,51,-25,51,-62v0,-36,-21,-61,-51,-61v-31,0,-50,25,-50,61","w":244,"k":{"$":1,"7":9,"4":7,"3":10,"2":4,"1":2,"*":15,"\\":13,"\/":16,"&":-1,")":2,"]":2,"}":2,".":5,",":5,"?":19}},"1":{"d":"114,0r-55,0r0,-153r-38,14r-17,-38v35,-12,59,-34,110,-29r0,206","w":143,"k":{"9":2,"8":1,"7":3,"6":2,"5":3,"3":5,"1":1,"0":1,"\\":5,"-":4,"?":5}},"2":{"d":"202,0r-180,0v-12,-109,128,-101,129,-141v-8,-41,-82,-22,-106,2r-25,-36v45,-46,185,-45,185,31v0,68,-111,68,-125,102r122,0r0,42","k":{"$":1,"9":1,"8":4,"7":4,"5":1,"4":3,"3":2,"2":1,"*":4,"-":3,"?":4}},"3":{"d":"13,32r20,-38v35,23,123,27,124,-21v1,-36,-49,-34,-88,-33r0,-40v38,1,82,3,79,-34v-3,-43,-80,-35,-106,-9r-25,-35v48,-46,186,-39,186,39v0,27,-15,43,-37,54v30,12,45,32,45,61v0,82,-134,96,-198,56","k":{"8":3,"7":3,"5":1,"4":1,"3":2,"*":4,"\\":4,"\/":-1,"?":4,"@":1}},"4":{"d":"30,0r-17,-40r131,-163r53,0r0,162r32,0r0,41r-32,0r0,49r-52,0r0,-49r-115,0xm65,-41r80,0r0,-104","w":239,"k":{"9":1,"8":1,"7":4,"6":3,"3":2,"*":7,"\\":4,"\/":-2,"-":8,"?":13,"@":1}},"5":{"d":"13,32r21,-40v36,24,116,28,116,-25v1,-42,-53,-47,-88,-29r-32,-19r6,-122r153,0r0,40r-105,0r-2,59v55,-24,122,2,122,69v0,90,-124,109,-191,67","w":216,"k":{"9":1,"8":2,"7":3,"6":2,"5":1,"3":3,"2":1,"0":2,"*":4,"-":4,"?":5,"@":1}},"6":{"d":"17,-119v0,-129,97,-162,187,-119r-20,36v-51,-26,-110,-11,-112,60v49,-43,143,-21,143,59v0,47,-37,87,-97,87v-71,0,-101,-55,-101,-123xm72,-105v1,41,16,68,47,68v26,0,42,-20,42,-45v0,-53,-64,-53,-89,-23","w":230,"k":{"$":2,"9":3,"8":1,"7":6,"6":2,"5":6,"4":10,"3":14,"2":9,"1":4,"*":4,"\\":-2,"\/":8,".":1,",":1,"?":7}},"7":{"d":"42,49r97,-208r-125,0r0,-44r180,0r0,38r-94,214r-58,0","w":207,"k":{"$":3,"9":3,"8":3,"6":1,"5":1,"4":23,"3":2,"2":4,"1":1,"0":4,"\/":14,"-":13,"&":5,".":15,",":15,"?":4,"@":3}},"8":{"d":"17,-67v0,-31,24,-54,54,-64v-82,-34,-39,-125,51,-125v54,0,95,26,95,70v0,26,-21,46,-44,55v30,10,54,33,54,64v0,46,-44,71,-105,71v-61,0,-105,-25,-105,-71xm71,-70v0,22,21,35,51,35v29,0,51,-13,51,-35v0,-22,-23,-37,-51,-41v-29,4,-51,19,-51,41xm122,-150v51,-2,53,-68,0,-67v-57,0,-51,64,0,67","w":243,"k":{"$":4,"9":4,"7":5,"6":1,"5":2,"4":5,"3":14,"2":5,"1":3,"*":2,"\/":6,"-":2,".":1,",":1,"?":5}},"9":{"d":"23,33r23,-36v46,31,113,14,112,-57v-49,42,-143,18,-143,-60v0,-47,36,-87,96,-87v72,0,103,55,103,123v-2,132,-102,165,-191,117xm68,-120v0,52,66,52,90,22v-1,-42,-17,-68,-48,-68v-26,0,-42,21,-42,46","w":230,"k":{"$":1,"7":8,"5":1,"3":10,"2":4,"1":2,"*":8,"\\":11,"?":14}},"#":{"d":"22,-123r0,-36r47,0r7,-44r41,0r-8,44r44,0r7,-44r41,0r-8,44r41,0r0,36r-46,0r-7,43r41,0r0,36r-47,0r-7,44r-41,0r7,-44r-44,0r-7,44r-40,0r7,-44r-40,0r0,-36r46,0r7,-43r-41,0xm103,-123r-7,43r44,0r7,-43r-44,0","w":244},"$":{"d":"15,-19r23,-37v17,10,38,19,58,20r0,-47v-35,-8,-78,-18,-78,-62v0,-33,27,-58,75,-62r0,-31r25,0r0,31v23,1,45,8,65,17r-20,37v-15,-7,-34,-12,-49,-14r0,45v35,8,76,18,76,64v0,32,-23,58,-72,62r0,44r-25,0r0,-44v-30,-2,-57,-10,-78,-23xm142,-57v0,-12,-12,-16,-28,-21r0,42v20,-2,28,-11,28,-21xm67,-148v0,12,12,18,29,22r0,-41v-20,1,-29,9,-29,19","w":205,"k":{"9":4,"8":2,"7":6,"5":6,"4":6,"3":9,"2":3,"1":3}},"+":{"d":"14,-75r0,-44r73,0r0,-75r48,0r0,75r73,0r0,44r-73,0r0,75r-48,0r0,-75r-73,0"},"=":{"d":"14,-120r0,-43r194,0r0,43r-194,0xm14,-31r0,-43r194,0r0,43r-194,0"},"<":{"d":"199,-52r0,52r-186,-74r0,-47r186,-73r0,53r-124,44","w":216},">":{"d":"18,0r0,-52r123,-45r-123,-44r0,-53r186,73r0,47","w":216},"%":{"d":"207,-203r33,0r-155,203r-34,0xm15,-152v0,-32,26,-55,59,-55v33,0,58,23,58,55v0,33,-24,56,-58,56v-34,0,-59,-23,-59,-56xm48,-152v0,17,11,29,26,29v16,0,25,-12,25,-29v0,-15,-10,-27,-25,-27v-15,0,-26,12,-26,27xm159,-53v0,-32,26,-54,59,-54v33,0,59,22,59,54v0,33,-25,56,-59,56v-34,0,-59,-23,-59,-56xm192,-53v0,17,10,29,26,29v15,0,26,-12,26,-29v0,-15,-11,-27,-26,-27v-15,0,-26,12,-26,27","w":291},"~":{"d":"23,-68v-2,-38,13,-67,47,-67v30,0,45,27,66,27v11,0,14,-8,14,-21r34,0v2,38,-12,66,-46,66v-30,0,-45,-27,-66,-27v-12,0,-15,9,-14,22r-35,0","w":207},"^":{"d":"31,-202r51,-67r50,0r51,67r-43,0r-33,-32r-34,32r-42,0","w":213},"\u00a0":{"w":86}}});
Cufon.registerFont({"w":226,"face":{"font-family":"Alright Sans","font-weight":450,"font-style":"italic","font-stretch":"normal","units-per-em":"360","panose-1":"0 0 5 0 0 0 0 0 0 0","ascent":"274","descent":"-86","x-height":"5","bbox":"-65 -322 422 76","underline-thickness":"18","underline-position":"-18","slope":"-10","stemh":"63","stemv":"81","unicode-range":"U+0020-U+00F8"},"glyphs":{" ":{"w":80},"A":{"d":"-16,0r127,-252r90,0r38,252r-82,0r-3,-31r-66,0r-13,31r-91,0xm143,-157v-12,20,-19,46,-30,68r36,0","w":253,"k":{"-":5,"J":2,"S":1,"T":28,"U":16,"W":30,"Y":40,")":4,"]":4,"}":4,"?":30,"v":26,"w":26,"y":26,"@":20,"C":23,"G":23,"O":23,"Q":23,"\u00d8":23,"&":11,"a":11,"d":11,"g":11,"q":11,"\u00e5":11,"\u00e6":11,"c":13,"e":13,"o":13,"\u00f8":13,"t":21,"u":7,"f":8,"'":7,"\"":7,"V":30,"*":35,"\\":36}},"B":{"d":"2,0r44,-252r115,0v91,-7,113,101,36,124v22,8,36,24,36,52v0,50,-39,76,-110,76r-121,0xm93,-61v0,0,64,5,64,-25v0,-24,-34,-17,-57,-18xm108,-151v26,0,54,4,54,-24v1,-19,-26,-16,-46,-16","w":240,"k":{"\u00c6":4,"T":4,"U":2,"W":10,"Y":19,")":5,"]":5,"}":5,"?":10,"v":4,"w":4,"y":4,"f":1,"V":11,"*":6,"\\":4,"X":8,"\/":22,"x":5}},"C":{"d":"14,-114v0,-77,59,-143,145,-143v42,0,77,16,101,41r-47,47v-38,-42,-116,-15,-116,52v0,67,72,65,101,32r42,51v-21,19,-53,39,-102,39v-69,0,-124,-41,-124,-119","w":248,"k":{"-":8,"A":-2,"\u00c5":-2,"J":1,"T":3,"U":6,"W":4,"Y":11,"?":4,"v":10,"w":10,"y":10,"@":12,"C":12,"G":12,"O":12,"Q":12,"\u00d8":12,"&":4,"a":11,"d":11,"g":11,"q":11,"\u00e5":11,"\u00e6":11,"m":2,"n":2,"p":2,"r":2,"c":13,"e":13,"o":13,"\u00f8":13,"t":11,"f":3,"V":4,"*":4,"\\":4,"X":2,"\/":14,"x":2}},"D":{"d":"2,0r44,-252r90,0v75,0,124,35,124,111v0,82,-52,141,-165,141r-93,0xm94,-63v54,7,82,-30,83,-78v1,-40,-21,-51,-60,-48","w":261,"k":{"A":5,"\u00c5":5,"\u00c6":16,"J":4,"S":5,"T":13,"U":1,"W":16,"Y":34,"Z":1,")":10,"]":10,"}":10,"?":15,"v":4,"w":4,"y":4,"z":1,"V":17,"*":9,"\\":17,"X":18,"\/":28,"x":11}},"E":{"d":"2,0r44,-252r191,0r-12,69r-109,0r-5,26r96,0r-11,59r-96,0r-5,29r111,0r-12,69r-192,0","w":222,"k":{"S":1,"s":2,"@":5,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"c":7,"e":7,"o":7,"\u00f8":7,"x":1}},"F":{"d":"2,0r44,-252r189,0r-13,69r-106,0r-6,31r92,0r-12,64r-91,0r-16,88r-81,0","w":218,"k":{"-":8,"A":21,"\u00c5":21,"\u00c6":36,"J":33,".":19,",":19,"s":7,"z":4,"@":9,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"&":10,":":9,";":9,"a":12,"d":12,"g":12,"q":12,"\u00e5":12,"\u00e6":12,"m":2,"n":2,"p":2,"r":2,"c":11,"e":11,"o":11,"\u00f8":11,"u":2,"i":3,"\/":45}},"G":{"d":"14,-111v0,-79,55,-146,149,-146v44,0,79,20,101,41r-48,46v-40,-39,-119,-15,-119,54v0,44,37,66,74,48r5,-30r-41,0r9,-49r113,0r-22,123v-24,17,-57,29,-98,29v-76,0,-123,-50,-123,-116","w":261,"k":{"A":1,"\u00c5":1,"\u00c6":4,"S":2,"T":8,"W":12,"Y":18,"?":3,"v":6,"w":6,"y":6,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":2,"e":2,"o":2,"\u00f8":2,"f":1,"V":11,"*":4,"\\":5,"X":7,"\/":13,"x":6}},"H":{"d":"2,0r44,-252r82,0r-16,91r59,0r16,-91r82,0r-45,252r-82,0r17,-94r-59,0r-16,94r-82,0","w":255,"k":{"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2}},"I":{"d":"2,0r44,-252r82,0r-44,252r-82,0","w":115,"k":{"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2}},"J":{"d":"-6,-48r60,-36v10,20,38,28,43,2r30,-170r82,0r-30,170v-9,100,-145,115,-185,34","w":195,"k":{"A":10,"\u00c5":10,"\u00c6":10,"J":9,".":2,",":2,"s":2,"\/":19,"x":3}},"K":{"d":"2,0r44,-252r82,0r-15,88r79,-88r93,0r-89,92r45,160r-82,0r-25,-96r-41,42r-9,54r-82,0","w":253,"k":{"-":15,"J":3,"S":2,"U":1,"?":5,"s":2,"v":16,"w":16,"y":16,"@":19,"C":16,"G":16,"O":16,"Q":16,"\u00d8":16,"&":6,"a":17,"d":17,"g":17,"q":17,"\u00e5":17,"\u00e6":17,"c":18,"e":18,"o":18,"\u00f8":18,"t":9,"u":4,"f":2,"*":7}},"L":{"d":"2,0r44,-252r82,0r-32,184r101,0r-12,68r-183,0","w":207,"k":{"T":28,"U":5,"W":26,"Y":40,"?":25,"v":19,"w":19,"y":19,"@":10,"C":14,"G":14,"O":14,"Q":14,"\u00d8":14,"a":5,"d":5,"g":5,"q":5,"\u00e5":5,"\u00e6":5,"c":7,"e":7,"o":7,"\u00f8":7,"t":15,"f":4,"V":26,"*":29,"\\":42}},"M":{"d":"2,0r44,-252r75,0r44,83r69,-83r86,0r-44,252r-76,0r25,-141r-76,84r-46,-84r-25,141r-76,0","w":307,"k":{"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2}},"N":{"d":"2,0r44,-252r66,0r64,129r23,-129r76,0r-45,252r-67,0r-63,-129r-22,129r-76,0","w":262,"k":{"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2}},"O":{"d":"17,-116v0,-71,49,-141,146,-141v69,0,122,45,122,121v0,71,-49,141,-146,141v-69,0,-122,-45,-122,-121xm159,-190v-62,-6,-86,128,-16,128v62,6,86,-128,16,-128","w":287,"k":{"A":5,"\u00c5":5,"\u00c6":16,"J":4,"S":5,"T":13,"U":1,"W":16,"Y":34,"Z":1,")":10,"]":10,"}":10,"?":15,"v":4,"w":4,"y":4,"z":1,"V":17,"*":9,"\\":17,"X":18,"\/":28,"x":11}},"P":{"d":"2,0r44,-252r106,0v65,0,99,32,99,78v0,47,-27,93,-121,93r-32,0r-14,81r-82,0xm109,-141v29,1,58,2,58,-28v0,-26,-26,-22,-50,-22","w":244,"k":{"A":29,"\u00c5":29,"\u00c6":33,"J":45,"W":10,"Y":21,"Z":2,")":5,"]":5,"}":5,".":30,",":30,"?":11,"z":1,"&":4,"m":2,"n":2,"p":2,"r":2,"u":2,"V":8,"*":4,"\\":9,"X":26,"\/":53,"x":3}},"Q":{"d":"17,-116v0,-71,49,-141,146,-141v69,0,122,45,122,121v0,37,-13,74,-40,101r16,18r-40,31r-18,-22v-85,37,-186,-7,-186,-108xm131,-96r34,-29r26,31v21,-34,13,-101,-32,-96v-62,-6,-86,128,-16,128v5,0,11,0,16,-2","w":287,"k":{".":3,"A":5,"\u00c5":5,"\u00c6":16,"J":4,"S":5,"T":13,"U":1,"W":16,"Y":34,"Z":1,")":10,"]":10,"}":10,"?":15,"v":4,"w":4,"y":4,"z":1,"V":17,"*":9,"\\":17,"X":18,"\/":28,"x":11}},"R":{"d":"2,0r44,-252r108,0v62,0,99,30,99,79v0,25,-7,60,-53,77r21,96r-77,0r-14,-86r-31,0r-15,86r-82,0xm109,-141v31,1,60,3,60,-29v0,-27,-28,-20,-52,-21","w":249,"k":{"A":4,"\u00c5":4,"J":14,"T":6,"U":2,"W":12,"Y":23,"Z":2,".":2,",":2,"?":8,"&":5,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"c":2,"e":2,"o":2,"\u00f8":2,"u":1,"V":11,"*":5,"\\":11,"X":7}},"S":{"d":"-1,-31r43,-56v20,13,45,22,66,22v12,0,20,-4,20,-11v0,-10,-17,-14,-37,-21v-30,-11,-65,-25,-65,-74v0,-48,39,-86,105,-86v36,0,71,12,97,28r-36,58v-22,-12,-43,-17,-61,-17v-13,0,-18,5,-18,12v0,9,17,13,35,19v30,10,66,23,66,74v0,50,-35,88,-109,88v-40,0,-83,-17,-106,-36","w":224,"k":{"v":18,"A":1,"\u00c5":1,"\u00c6":4,"S":4,"T":11,"U":3,"W":15,"Y":17,"?":10,"s":4,"w":18,"y":18,"z":2,"@":5,"C":6,"G":6,"O":6,"Q":6,"\u00d8":6,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"c":1,"e":1,"o":1,"\u00f8":1,"t":11,"f":5,"'":6,"\"":6,"V":11,"*":11,"\\":13,"X":10,"\/":19,"x":8}},"T":{"d":"66,0r32,-181r-75,0r13,-71r224,0r-12,71r-69,0r-32,181r-81,0","w":237,"k":{"-":24,"A":22,"\u00c5":22,"\u00c6":40,"J":40,".":21,",":21,"?":1,"s":5,"z":2,"@":6,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"&":13,":":22,";":22,"a":13,"d":13,"g":13,"q":13,"\u00e5":13,"\u00e6":13,"m":3,"n":3,"p":3,"r":3,"c":14,"e":14,"o":14,"\u00f8":14,"u":1,"X":2,"\/":45}},"U":{"d":"17,-79v0,-60,20,-116,29,-173r82,0r-29,164v0,16,9,25,26,25v21,0,32,-13,38,-45r25,-144r82,0r-27,153v-13,73,-57,104,-130,104v-58,0,-96,-32,-96,-84","w":257,"k":{"A":10,"\u00c5":10,"\u00c6":10,"J":9,".":2,",":2,"s":2,"\/":19,"x":3}},"V":{"d":"67,0r-39,-252r84,0r14,155r66,-155r91,0r-127,252r-89,0","w":252,"k":{"\/":46,"x":5,"-":8,"A":22,"\u00c5":22,"\u00c6":37,"J":34,".":21,",":21,"s":12,"v":5,"w":5,"y":5,"z":6,"@":13,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"&":16,":":17,";":17,"a":16,"d":16,"g":16,"q":16,"\u00e5":16,"\u00e6":16,"m":6,"n":6,"p":6,"r":6,"c":13,"e":13,"o":13,"\u00f8":13,"t":1,"u":6}},"W":{"d":"63,0r-33,-252r81,0r15,133r60,-133r72,0r15,133r61,-133r88,0r-122,252r-80,0r-16,-138r-63,138r-78,0","w":394,"k":{"-":3,"A":24,"\u00c5":24,"\u00c6":35,"J":33,"S":2,".":15,",":15,"s":10,"v":4,"w":4,"y":4,"z":4,"@":8,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"&":14,":":9,";":9,"a":16,"d":16,"g":16,"q":16,"\u00e5":16,"\u00e6":16,"m":9,"n":9,"p":9,"r":9,"c":15,"e":15,"o":15,"\u00f8":15,"u":3,"\/":42,"x":4}},"X":{"d":"-13,0r99,-129r-54,-123r92,0r23,60r41,-60r102,0r-98,124r54,128r-90,0r-24,-65r-45,65r-100,0","w":260,"k":{"-":17,"J":6,"S":6,"U":3,")":2,"]":2,"}":2,"?":3,"s":6,"v":14,"w":14,"y":14,"@":22,"C":15,"G":15,"O":15,"Q":15,"\u00d8":15,"&":12,"a":20,"d":20,"g":20,"q":20,"\u00e5":20,"\u00e6":20,"m":2,"n":2,"p":2,"r":2,"c":24,"e":24,"o":24,"\u00f8":24,"t":9,"u":9,"f":2}},"Y":{"d":"72,0r18,-100r-64,-152r87,0v10,23,17,49,28,70r52,-70r97,0r-118,152r-17,100r-83,0","w":257,"k":{"-":24,"A":32,"\u00c5":32,"\u00c6":45,"J":43,"S":6,".":27,",":27,"?":4,"s":27,"v":16,"w":16,"y":16,"z":16,"@":25,"C":12,"G":12,"O":12,"Q":12,"\u00d8":12,"&":14,":":22,";":22,"a":30,"d":30,"g":30,"q":30,"\u00e5":30,"\u00e6":30,"m":18,"n":18,"p":18,"r":18,"c":29,"e":29,"o":29,"\u00f8":29,"t":3,"u":15,"f":10,"\/":61,"x":15}},"Z":{"d":"-3,0r10,-58r114,-122r-93,0r12,-72r207,0r-10,59r-114,122r97,0r-13,71r-210,0","w":229,"k":{"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"c":1,"e":1,"o":1,"\u00f8":1}},"a":{"d":"136,-22v-41,46,-125,31,-125,-53v0,-95,80,-164,145,-107r7,-17r71,0r-25,142v0,6,5,8,11,8r-9,50v-33,5,-63,2,-75,-23xm108,-54v32,-2,30,-57,37,-87v-32,-20,-56,15,-56,57v0,22,9,30,19,30","w":229,"k":{"J":-10,"T":2,"W":7,"Y":18,"?":7,"j":-4,"V":7,"*":22,"\\":12,"\/":4}},"b":{"d":"-1,0r49,-272r78,0r-16,90v40,-41,112,-21,112,58v0,104,-81,162,-145,105r-6,19r-72,0xm88,-59v32,21,56,-15,56,-57v0,-41,-32,-37,-44,-11","k":{"A":4,"\u00c5":4,"\u00c6":6,"S":10,"T":20,"W":20,"Y":38,"Z":3,")":5,"]":5,"}":5,"?":32,"s":3,"v":14,"w":14,"y":14,"z":7,"t":5,"'":4,"\"":4,"V":24,"\\":27,"X":11,"\/":14,"x":10}},"c":{"d":"8,-89v0,-100,127,-149,193,-87r-43,45v-29,-27,-70,-6,-70,42v0,37,40,38,59,21r37,47v-61,47,-176,33,-176,-68","w":191,"k":{"-":3,"J":2,"U":4,"W":14,"Y":27,"?":19,"s":-4,"@":2,"&":4,"a":9,"d":9,"g":9,"q":9,"\u00e5":9,"\u00e6":9,"c":10,"e":10,"o":10,"\u00f8":10,"V":9,"*":7,"\\":14}},"d":{"d":"131,-22v-38,47,-120,28,-120,-54v0,-93,73,-161,141,-109r15,-87r79,0r-48,272r-66,0xm89,-84v0,41,31,37,43,11r12,-68v-32,-20,-55,15,-55,57"},"e":{"d":"12,-84v0,-75,59,-120,123,-120v48,0,82,24,82,62v0,46,-59,65,-126,61v4,40,53,22,77,9r26,51v-58,45,-182,31,-182,-63xm129,-152v-17,0,-28,14,-34,35v28,2,55,-8,50,-20v0,-8,-6,-15,-16,-15","w":217,"k":{"J":9,"S":4,"T":16,"U":2,"W":24,"Y":37,".":4,",":4,"?":27,"v":4,"w":4,"y":4,"&":2,"V":20,"*":23,"\\":27,"X":4,"\/":11,"x":2}},"f":{"d":"12,0r26,-145r-26,0r8,-50v9,-2,26,5,27,-5v6,-78,93,-91,154,-61r-25,46v-20,-11,-52,-9,-51,20r43,0r-9,50r-43,0r-25,145r-79,0","w":155,"k":{"-":2,"A":11,"\u00c5":11,"\u00c6":22,"J":29,")":-25,"]":-25,"}":-25,".":11,",":11,"?":-4,"@":-3,"&":2,"a":2,"d":2,"g":2,"q":2,"\u00e5":2,"\u00e6":2,"i":-7,"'":-16,"\"":-16,"*":-8,"\\":-23,"\/":24,"b":-7,"h":-7,"k":-7,"l":-7}},"g":{"d":"32,1v30,17,96,26,92,-24v-44,30,-110,18,-112,-59v-3,-86,79,-156,144,-102r6,-15r71,0r-32,184v-12,67,-48,91,-118,91v-30,0,-61,-10,-79,-21xm109,-60v31,-2,29,-55,36,-84v-32,-18,-55,15,-55,55v0,21,9,29,19,29","w":227,"k":{"W":5,"Y":17,"?":2,"j":-30,"V":7,"\\":4}},"h":{"d":"0,0r48,-272r78,0r-16,92v27,-35,116,-33,110,28v-5,51,-17,103,-25,152r-78,0r23,-136v0,-7,-4,-11,-11,-11v-10,0,-21,10,-29,24r-22,123r-78,0","w":222,"k":{"T":12,"W":17,"Y":32,")":2,"]":2,"}":2,"?":18,"v":5,"w":5,"y":5,"V":18,"*":16,"\\":23}},"i":{"d":"0,0r34,-195r79,0r-35,195r-78,0xm38,-215r10,-57r78,0r-9,57r-79,0","w":106,"k":{"W":5,"Y":13,"V":6}},"j":{"d":"3,-12r32,-183r78,0r-33,187v-5,86,-88,100,-145,67r25,-50v20,11,38,9,43,-21xm38,-215r10,-57r79,0r-10,57r-79,0","w":107,"k":{"j":-27,"W":5,"Y":13,"V":6}},"k":{"d":"0,0r48,-272r78,0r-25,143r68,-70r83,0r-77,75r33,124r-78,0r-15,-65r-30,29r-7,36r-78,0","k":{"-":8,"J":7,"Y":5,"@":4,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"&":5,"a":13,"d":13,"g":13,"q":13,"\u00e5":13,"\u00e6":13,"c":15,"e":15,"o":15,"\u00f8":15}},"l":{"d":"0,0r48,-272r78,0r-48,272r-78,0","w":106},"m":{"d":"99,-126r-23,126r-76,0r35,-199r66,0r1,23v27,-28,90,-49,109,3v22,-23,43,-31,65,-31v90,0,27,138,24,204r-75,0r23,-135v-6,-22,-28,-7,-38,8r-23,127r-74,0r23,-135v0,-7,-3,-11,-10,-11v-10,0,-19,8,-27,20","w":328,"k":{"T":12,"W":17,"Y":32,")":2,"]":2,"}":2,"?":18,"v":5,"w":5,"y":5,"V":18,"*":16,"\\":23}},"n":{"d":"117,0r23,-136v-9,-23,-29,-6,-40,13r-22,123r-78,0r35,-199r67,0r2,22v28,-38,121,-38,116,25v-4,51,-17,103,-25,152r-78,0","w":222,"k":{"T":12,"W":17,"Y":32,")":2,"]":2,"}":2,"?":18,"v":5,"w":5,"y":5,"V":18,"*":16,"\\":23}},"o":{"d":"105,5v-53,0,-93,-34,-93,-93v0,-69,46,-116,117,-116v53,0,93,34,93,93v0,69,-46,116,-117,116xm110,-50v20,0,33,-33,33,-64v0,-24,-6,-35,-19,-35v-19,0,-33,33,-33,64v0,24,6,35,19,35","w":227,"k":{"A":1,"\u00c5":1,"\u00c6":4,"S":6,"T":27,"W":18,"Y":43,")":2,"]":2,"}":2,".":-2,",":-2,"?":36,"s":4,"v":11,"w":11,"y":11,"z":4,"t":4,"f":1,"V":21,"*":23,"\\":28,"X":10,"\/":14,"x":10}},"p":{"d":"81,-17r-16,89r-79,0r49,-271r69,0r2,20v43,-42,116,-32,116,57v0,98,-78,160,-141,105xm88,-59v32,21,56,-15,56,-57v0,-41,-32,-37,-44,-11","k":{"A":4,"\u00c5":4,"\u00c6":6,"S":10,"T":20,"W":20,"Y":38,"Z":3,")":5,"]":5,"}":5,"?":32,"s":3,"v":14,"w":14,"y":14,"z":7,"t":5,"'":4,"\"":4,"V":24,"\\":27,"X":11,"\/":14,"x":10}},"q":{"d":"123,-15v-44,40,-112,16,-112,-63v0,-95,81,-160,145,-104r7,-17r70,0r-47,271r-79,0xm89,-84v0,42,32,37,44,11r12,-68v-32,-20,-56,15,-56,57","k":{"W":5,"Y":17,"?":2,"j":-30,"V":7,"\\":4}},"r":{"d":"-1,0r36,-199r66,0r3,27v24,-34,46,-38,83,-31r-20,69v-34,-12,-57,5,-72,35r-17,99r-79,0","w":167,"k":{"A":18,"\u00c5":18,"\u00c6":32,"J":32,"Y":5,".":18,",":18,"@":-4,"&":3,"'":-11,"\"":-11,"\\":4,"X":13,"\/":27}},"s":{"d":"-5,-22r32,-47v20,11,39,17,57,17v12,0,16,-3,16,-8v0,-8,-12,-11,-28,-16v-31,-9,-55,-25,-55,-59v0,-78,111,-85,172,-45r-32,45v-18,-9,-35,-14,-47,-14v-10,0,-15,4,-15,9v0,9,14,11,30,15v31,8,52,21,52,55v0,85,-128,92,-182,48","w":186,"k":{"\u00c6":4,"T":10,"U":7,"W":19,"Y":32,"?":22,"s":1,"v":9,"w":9,"y":9,"C":5,"G":5,"O":5,"Q":5,"\u00d8":5,"a":3,"d":3,"g":3,"q":3,"\u00e5":3,"\u00e6":3,"c":1,"e":1,"o":1,"\u00f8":1,"t":6,"f":2,"'":4,"\"":4,"V":17,"*":17,"\\":24,"X":12,"\/":6,"x":5}},"t":{"d":"25,-50v1,-32,10,-68,15,-99r-26,0r9,-50r27,0r7,-43r79,0r-8,43r52,0r-10,50r-51,0r-14,81v0,19,26,9,33,3r22,48v-39,31,-137,35,-135,-33","w":169,"k":{"-":2,"W":6,"Y":18,".":-4,",":-4,"?":7,"@":2,"a":6,"d":6,"g":6,"q":6,"\u00e5":6,"\u00e6":6,"c":7,"e":7,"o":7,"\u00f8":7,"V":7,"\\":14}},"u":{"d":"228,-199r-36,199r-64,0r-2,-23v-27,41,-123,37,-118,-25v4,-53,17,-102,24,-151r78,0r-24,137v0,7,4,11,11,11v10,0,21,-10,30,-27r22,-121r79,0","w":221,"k":{"W":5,"Y":17,"?":2,"j":-30,"V":7,"\\":4}},"v":{"d":"45,0r-24,-199r71,0r7,115r49,-115r73,0r-96,199r-80,0","w":200,"k":{"A":18,"\u00c5":18,"\u00c6":22,"J":18,"Y":4,".":8,",":8,"&":2,"a":6,"d":6,"g":6,"q":6,"\u00e5":6,"\u00e6":6,"c":6,"e":6,"o":6,"\u00f8":6,"X":5,"\/":21}},"w":{"d":"44,0r-23,-199r71,0r8,98r41,-98r56,0r8,98r42,-98r75,0r-94,199r-65,0r-10,-91r-40,91r-69,0","w":303,"k":{"A":18,"\u00c5":18,"\u00c6":22,"J":18,"Y":4,".":8,",":8,"&":2,"a":6,"d":6,"g":6,"q":6,"\u00e5":6,"\u00e6":6,"c":6,"e":6,"o":6,"\u00f8":6,"X":5,"\/":21}},"x":{"d":"-15,0r75,-102r-39,-97r73,0r15,45r32,-45r82,0r-75,98r39,101r-70,0r-18,-49r-35,49r-79,0","w":201,"k":{"\\":4,"-":5,"J":5,"Y":15,"@":3,"&":8,"a":11,"d":11,"g":11,"q":11,"\u00e5":11,"\u00e6":11,"c":9,"e":9,"o":9,"\u00f8":9}},"y":{"d":"4,9v19,10,45,10,51,-13r-35,-195r73,0r13,105r49,-105r77,0r-93,182v-39,75,-62,93,-110,93v-19,0,-40,-6,-52,-14","w":213,"k":{"A":18,"\u00c5":18,"\u00c6":22,"J":18,"Y":4,".":8,",":8,"&":2,"a":6,"d":6,"g":6,"q":6,"\u00e5":6,"\u00e6":6,"c":6,"e":6,"o":6,"\u00f8":6,"X":5,"\/":21}},"z":{"d":"-4,0r9,-49r91,-95r-72,0r10,-55r164,0r-9,51r-88,92r75,0r-10,56r-170,0","w":191,"k":{"Y":14,"a":4,"d":4,"g":4,"q":4,"\u00e5":4,"\u00e6":4,"c":5,"e":5,"o":5,"\u00f8":5}},"\u00c5":{"d":"114,-252v-15,-36,13,-70,51,-70v38,0,54,44,32,70r4,0r38,252r-82,0r-3,-31r-66,0r-13,31r-91,0r127,-252r3,0xm163,-300v-29,-2,-42,47,-9,48v30,2,42,-47,9,-48xm143,-157v-12,20,-19,46,-30,68r36,0","w":253,"k":{"-":5,"J":2,"S":1,"T":28,"U":16,"W":30,"Y":40,")":4,"]":4,"}":4,"?":30,"v":26,"w":26,"y":26,"@":20,"C":23,"G":23,"O":23,"Q":23,"\u00d8":23,"&":11,"a":11,"d":11,"g":11,"q":11,"\u00e5":11,"\u00e6":11,"c":13,"e":13,"o":13,"\u00f8":13,"t":21,"u":7,"f":8,"'":7,"\"":7,"V":30,"*":35,"\\":36}},"\u00c6":{"d":"-17,0r150,-252r256,0r-12,69r-136,0r2,25r116,0r-11,61r-101,0r2,28r108,0r-11,69r-176,0r-1,-31r-74,0r-16,31r-96,0xm165,-158v-14,20,-23,44,-36,65r38,0","w":374,"k":{"S":1,"s":2,"@":5,"C":3,"G":3,"O":3,"Q":3,"\u00d8":3,"a":8,"d":8,"g":8,"q":8,"\u00e5":8,"\u00e6":8,"c":7,"e":7,"o":7,"\u00f8":7,"x":1}},"\u00d8":{"d":"40,-40v-57,-88,-5,-219,123,-217v27,0,53,8,73,22r31,-32r25,23r-31,31v59,88,7,220,-122,218v-28,0,-54,-8,-75,-22r-32,31r-24,-23xm114,-71v51,32,101,-30,86,-86xm186,-182v-50,-29,-96,29,-85,84","w":287,"k":{"A":5,"\u00c5":5,"\u00c6":16,"J":4,"S":5,"T":13,"U":1,"W":16,"Y":34,"Z":1,")":10,"]":10,"}":10,"?":15,"v":4,"w":4,"y":4,"z":1,"V":17,"*":9,"\\":17,"X":18,"\/":28,"x":11}},"\u00e5":{"d":"136,-22v-41,46,-125,31,-125,-53v0,-95,80,-164,145,-107r7,-17r71,0r-25,142v0,6,5,8,11,8r-9,50v-33,5,-63,2,-75,-23xm95,-259v0,-28,23,-51,55,-51v25,0,42,18,42,41v0,28,-23,51,-55,51v-25,0,-42,-18,-42,-41xm108,-54v32,-2,30,-57,37,-87v-32,-20,-56,15,-56,57v0,22,9,30,19,30xm148,-288v-30,-2,-42,47,-9,48v29,2,40,-46,9,-48","w":229,"k":{"J":-10,"T":2,"W":7,"Y":18,"?":7,"j":-4,"V":7,"*":22,"\\":12,"\/":4}},"\u00e6":{"d":"161,-34v-39,59,-150,53,-150,-41v0,-71,39,-129,100,-129v28,0,55,12,74,27v42,-44,160,-34,160,35v0,47,-63,63,-126,62v4,39,53,21,77,8r25,51v-40,32,-137,39,-160,-13xm89,-84v0,41,32,36,44,11r12,-68v-33,-20,-56,15,-56,57xm256,-152v-13,0,-28,10,-34,35v28,2,55,-8,50,-20v0,-8,-6,-15,-16,-15","w":344,"k":{"J":9,"S":4,"T":16,"U":2,"W":24,"Y":37,".":4,",":4,"?":27,"v":4,"w":4,"y":4,"&":2,"V":20,"*":23,"\\":27,"X":4,"\/":11,"x":2}},"\u00f8":{"d":"222,-111v0,88,-90,143,-169,102r-25,29r-24,-21r26,-28v-48,-73,5,-175,99,-175v19,0,37,5,52,14r26,-29r24,22r-27,28v11,15,18,35,18,58xm124,-149v-19,0,-32,30,-33,60r48,-50v-3,-6,-8,-10,-15,-10xm110,-50v19,0,32,-30,33,-60r-48,51v3,6,9,9,15,9","w":227,"k":{"A":1,"\u00c5":1,"\u00c6":4,"S":6,"T":27,"W":18,"Y":43,")":2,"]":2,"}":2,".":-2,",":-2,"?":36,"s":4,"v":11,"w":11,"y":11,"z":4,"t":4,"f":1,"V":21,"*":23,"\\":28,"X":10,"\/":14,"x":10}},"`":{"d":"113,-220r-32,-39r54,-29r22,68r-44,0","w":182},".":{"d":"0,0r13,-72r72,0r-13,72r-72,0","w":100,"k":{"S":4,"T":27,"U":9,"W":21,"Y":30,"?":29,"s":1,"v":14,"w":14,"y":14,"C":16,"G":16,"O":16,"Q":16,"\u00d8":16,"a":5,"d":5,"g":5,"q":5,"\u00e5":5,"\u00e6":5,"c":9,"e":9,"o":9,"\u00f8":9,"t":16,"f":3,"'":18,"\"":18,"V":28,"*":43,"5":3,"1":24,"7":18,"6":11,"3":4,"0":9,"4":2,"9":8}},",":{"d":"0,0r13,-72r72,0v-9,64,-22,125,-85,134r-8,-28v22,-5,35,-19,38,-34r-30,0","w":100,"k":{"S":4,"T":27,"U":9,"W":21,"Y":30,"?":29,"s":1,"v":14,"w":14,"y":14,"C":16,"G":16,"O":16,"Q":16,"\u00d8":16,"a":5,"d":5,"g":5,"q":5,"\u00e5":5,"\u00e6":5,"c":9,"e":9,"o":9,"\u00f8":9,"t":16,"f":3,"'":18,"\"":18,"V":28,"*":43,"5":3,"1":24,"7":18,"6":11,"3":4,"0":9,"4":2,"9":8}},":":{"d":"0,0r13,-72r72,0r-13,72r-72,0xm23,-130r13,-71r72,0r-13,71r-72,0","w":100},";":{"d":"0,0r13,-72r72,0v-9,64,-22,125,-85,134r-8,-28v22,-5,35,-19,38,-34r-30,0xm23,-130r13,-71r72,0r-13,71r-72,0","w":100},"!":{"d":"31,-84v1,-59,-2,-121,11,-168r78,0v-10,63,-32,113,-50,168r-39,0xm0,0r10,-59r71,0r-10,59r-71,0","w":104},"?":{"d":"70,-84v-10,-62,72,-76,73,-101v0,-9,-10,-12,-19,-12v-18,0,-36,8,-56,25r-40,-43v30,-27,66,-42,106,-42v40,0,88,18,88,68v0,70,-93,64,-97,105r-55,0xm48,0r10,-59r71,0r-11,59r-70,0","w":210,"k":{".":47,",":47,"?":3}},"'":{"d":"27,-175r14,-77r75,0r-39,86","w":94,"k":{"A":11,"\u00c5":11,"\u00c6":18,"J":9,".":18,",":18,"s":4,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"a":12,"d":12,"g":12,"q":12,"\u00e5":12,"\u00e6":12,"c":9,"e":9,"o":9,"\u00f8":9,"f":2,"5":4,"1":-4,"3":2,"0":4,"4":18,"8":1}},"\"":{"d":"27,-175r14,-77r75,0r-39,86xm122,-175r14,-77r75,0r-40,86","w":188,"k":{"A":11,"\u00c5":11,"\u00c6":18,"J":9,".":18,",":18,"s":4,"C":2,"G":2,"O":2,"Q":2,"\u00d8":2,"a":12,"d":12,"g":12,"q":12,"\u00e5":12,"\u00e6":12,"c":9,"e":9,"o":9,"\u00f8":9,"f":2,"5":4,"1":-4,"3":2,"0":4,"4":18,"8":1}},"_":{"d":"-16,5r195,0r-11,64r-195,0","w":194,"k":{"_":1}},"\/":{"d":"-33,72r215,-344r71,0r-214,344r-72,0","w":213,"k":{"9":5,"5":3,"4":44,"3":2,"2":5,"0":12,"\/":40,"A":25,"\u00c5":25,"\u00c6":29,"J":43,"s":10,"C":4,"G":4,"O":4,"Q":4,"\u00d8":4,"a":20,"d":20,"g":20,"q":20,"\u00e5":20,"\u00e6":20,"c":13,"e":13,"o":13,"\u00f8":13,"f":4}},"\\":{"d":"195,72r-68,0r-97,-344r66,0","w":213,"k":{"9":7,"8":22,"7":4,"6":32,"4":12,"1":31,"0":30,"\\":40,"y":32,"X":7,"V":54,"J":9,"S":20,"T":51,"U":35,"W":57,"Y":74,"Z":-11,"s":9,"v":32,"w":32,"z":-11,"C":39,"G":39,"O":39,"Q":39,"\u00d8":39,"a":31,"d":31,"g":31,"q":31,"\u00e5":31,"\u00e6":31,"c":30,"e":30,"o":30,"\u00f8":30,"t":27,"u":6,"f":16,"i":7,"j":-57}},"|":{"d":"-1,72r60,-344r71,0r-61,344r-70,0","w":122},"*":{"d":"50,-148r16,-34r-35,5r0,-45v12,1,27,6,37,4r-14,-33r40,-11v4,11,3,27,9,35r27,-21r24,35v-9,6,-23,7,-29,16r28,18r-27,33v-10,-7,-16,-18,-27,-24r-11,35","w":146,"k":{".":36,",":36}},"-":{"d":"8,-69r11,-63r113,0r-10,63r-114,0","w":133,"k":{"\u00c6":4,"J":9,"S":4,"T":24,"W":12,"Y":31,"v":2,"w":2,"y":2,"V":13,"X":9,"x":6,"5":1,"1":4,"7":6,"3":9,"4":3,"2":5}},"(":{"d":"58,72v-62,-103,-46,-270,50,-343r83,0v-92,74,-130,233,-58,343r-75,0","w":153,"k":{"A":4,"\u00c5":4,"\u00c6":11,"J":6,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":10,"d":10,"g":10,"q":10,"\u00e5":10,"\u00e6":10,"c":10,"e":10,"o":10,"\u00f8":10,"(":11,"[":11,"{":11,"X":2,"1":9,"6":3,"0":4,"4":13,"2":2}},")":{"d":"102,-271v63,103,45,270,-51,343r-83,0v92,-75,132,-231,59,-343r75,0","w":153,"k":{")":11,"]":11,"}":11}},"[":{"d":"136,20r-10,52r-134,0r60,-344r136,0r-9,52r-57,0r-42,240r56,0","w":168,"k":{"A":4,"\u00c5":4,"\u00c6":11,"J":6,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":10,"d":10,"g":10,"q":10,"\u00e5":10,"\u00e6":10,"c":10,"e":10,"o":10,"\u00f8":10,"(":11,"[":11,"{":11,"X":2,"1":9,"6":3,"0":4,"4":13,"2":2}},"]":{"d":"-6,20r56,0r42,-240r-56,0r9,-52r135,0r-61,344r-135,0","w":168,"k":{")":11,"]":11,"}":11}},"{":{"d":"150,19r-10,53v-71,4,-123,-11,-107,-76v7,-27,26,-72,-28,-62r12,-68v28,0,39,3,44,-29v9,-63,21,-116,99,-109r42,0r-10,53v-21,1,-41,-6,-45,17v-8,49,-3,94,-61,103v57,18,27,59,25,107v-1,17,24,9,39,11","w":183,"k":{"A":4,"\u00c5":4,"\u00c6":11,"J":6,"S":1,"s":1,"C":8,"G":8,"O":8,"Q":8,"\u00d8":8,"a":10,"d":10,"g":10,"q":10,"\u00e5":10,"\u00e6":10,"c":10,"e":10,"o":10,"\u00f8":10,"(":11,"[":11,"{":11,"X":2,"1":9,"6":3,"0":4,"4":13,"2":2}},"}":{"d":"40,-219r9,-53v71,-3,124,11,108,76v-7,27,-26,71,27,62r-12,68v-27,0,-38,-4,-43,28v-9,63,-21,117,-99,110r-42,0r9,-53v20,-2,42,7,45,-16v8,-49,5,-93,62,-105v-56,-17,-29,-60,-25,-106v1,-17,-24,-9,-39,-11","w":183,"k":{")":11,"]":11,"}":11}},"@":{"d":"20,-104v0,-72,58,-130,130,-130v68,0,124,54,124,120v1,81,-87,105,-121,61v-24,30,-78,19,-78,-33v0,-37,20,-85,64,-85v15,0,26,8,32,18r7,-15r44,0r-24,85v-5,18,0,26,13,26v16,0,41,-17,41,-57v0,-54,-46,-98,-102,-98v-60,0,-108,48,-108,108v0,84,99,140,170,90r12,18v-83,60,-204,-7,-204,-108xm125,-89v1,24,24,18,27,0v2,-15,21,-44,-3,-44v-15,0,-24,26,-24,44","w":281,"k":{"A":2,"\u00c5":2,"\u00c6":4,"J":3,"S":6,"T":26,"W":24,"Y":48,"Z":2,"v":13,"w":13,"y":13,"f":4,"V":29,"X":11,"x":10,"5":6,"1":11,"7":15,"3":17,"4":6,"2":6}},"&":{"d":"7,-67v0,-35,24,-63,58,-77v-35,-52,6,-113,66,-113v40,0,66,21,82,40r-48,36v-8,-13,-39,-30,-44,-7v8,31,38,51,59,75v5,-10,8,-21,10,-33r69,0v-5,30,-15,56,-30,79r29,26r-47,45v-9,-8,-19,-15,-29,-24v-53,43,-175,30,-175,-47xm136,-63v-14,-13,-27,-27,-39,-41v-26,9,-28,51,8,49v11,0,21,-2,31,-8","w":264,"k":{"T":25,"U":2,"W":31,"Y":44,"?":8,"u":1,"V":24,"X":8,"5":5,"1":4,"7":8,"6":2,"3":10,"0":4}},"0":{"d":"112,5v-56,0,-100,-36,-100,-98v0,-76,56,-122,127,-122v56,0,100,36,100,98v0,76,-56,122,-127,122xm134,-153v-25,0,-40,31,-40,61v0,22,8,35,24,35v25,0,39,-31,39,-61v0,-22,-8,-35,-23,-35","w":244,"k":{"8":1,"7":9,"5":5,"4":3,"3":16,"2":3,"1":5,"*":33,"\\":30,"\/":19,")":2,"]":2,"}":2,"?":38}},"1":{"d":"129,0r-82,0r24,-134r-35,11r-22,-56r93,-31r59,0","w":168,"k":{"6":3,"5":5,"4":4,"3":5,"*":4,"\\":6,"?":7,"@":7}},"2":{"d":"3,0r1,-17v12,-114,141,-100,141,-128v0,-8,-7,-13,-23,-13v-22,0,-47,9,-72,23r-27,-52v58,-38,198,-44,198,40v0,73,-113,65,-128,90r108,0r-11,57r-187,0","w":217,"k":{"9":-7,"3":1,"*":7,"\\":14,"?":14,"@":-4,"&":2}},"3":{"d":"-13,19r34,-49v27,20,100,34,104,-7v3,-27,-46,-19,-74,-20r9,-54v31,1,78,2,74,-25v-5,-35,-55,-15,-82,-4r-24,-54v26,-11,57,-20,97,-20v94,0,123,100,49,128v19,12,30,33,30,53v3,95,-158,98,-217,52","w":220,"k":{"8":1,"7":2,"4":5,"3":2,"1":2,"*":18,"\\":22,"?":25,"@":2,"'":1,"\"":1}},"4":{"d":"21,0r-17,-55r157,-155r75,0r-28,155r24,0r-10,55r-23,0r-7,43r-77,0r8,-43r-102,0xm75,-55r58,0r12,-68","w":246,"k":{"7":2,"6":2,"1":4,"0":2,"*":14,"\\":12,"-":6,"?":18,"@":13,"'":7,"\"":7}},"5":{"d":"-10,17r37,-50v29,21,96,33,96,-11v0,-30,-37,-24,-57,-13r-42,-27r25,-126r162,0r-9,54r-90,0r-9,42v51,-18,100,5,102,63v1,108,-146,119,-215,68","w":220,"k":{"9":2,"8":4,"7":7,"6":2,"5":3,"4":4,"3":2,"1":5,"0":6,"*":11,"\\":18,"?":25,"@":14,"&":4,"'":8,"\"":8}},"6":{"d":"13,-104v0,-133,121,-191,217,-127r-36,45v-10,-7,-26,-14,-42,-14v-32,0,-47,25,-52,49v45,-31,121,-11,121,55v0,57,-43,101,-109,101v-64,0,-99,-46,-99,-109xm125,-117v-16,2,-32,5,-32,27v0,16,4,38,22,38v29,0,43,-62,10,-65","w":227,"k":{"$":2,"9":3,"7":5,"5":6,"3":12,"1":9,"*":7,"\\":7,"\/":11,"?":13,"@":2,"'":4,"\"":4}},"7":{"d":"9,42r117,-191r-103,0r11,-61r182,0r-10,56r-110,196r-87,0","w":202,"k":{"8":2,"5":1,"4":16,"\/":14,".":9,",":9,"&":5}},"8":{"d":"7,-62v0,-32,23,-58,62,-72v-70,-47,-18,-123,78,-123v54,0,97,25,97,65v0,31,-23,52,-51,63v27,13,40,29,40,56v0,50,-52,78,-118,78v-66,0,-108,-25,-108,-67xm91,-69v0,11,9,21,26,21v39,1,47,-46,9,-55v-19,5,-35,20,-35,34xm135,-158v29,-4,41,-42,7,-45v-31,-2,-34,40,-7,45","w":245,"k":{"$":2,"7":6,"5":5,"4":4,"3":14,"2":5,"0":3,"*":4,"\\":5,"\/":10,"?":11,"@":4}},"9":{"d":"132,-58v-44,33,-121,13,-121,-54v0,-57,43,-101,109,-101v64,0,99,45,99,109v0,135,-119,188,-217,127r36,-46v10,7,27,14,43,14v32,0,46,-26,51,-49xm107,-92v15,-2,33,-5,33,-27v0,-16,-5,-38,-23,-38v-28,0,-42,61,-10,65","w":228,"k":{"7":12,"5":4,"4":1,"3":9,"2":6,"1":6,"*":22,"\\":33,"?":32,"@":4}},"#":{"d":"23,-120r9,-49r41,0r13,-41r58,0r-14,41r30,0r14,-41r57,0r-14,41r32,0r-9,49r-39,0r-10,30r34,0r-9,49r-41,0r-14,41r-58,0r14,-41r-30,0r-13,41r-57,0r13,-41r-31,0r9,-49r38,0r10,-30r-33,0xm114,-120r-10,30r30,0r9,-30r-29,0","w":241},"$":{"d":"-4,-24r39,-47v18,10,37,17,56,19r4,-26v-31,-8,-76,-17,-76,-65v0,-43,38,-70,95,-72r5,-27r29,0r-5,29v24,4,45,12,61,21r-37,49v-13,-7,-28,-12,-40,-15r-4,25v31,7,75,16,75,64v0,43,-34,73,-94,74r-8,43r-28,0r8,-45v-32,-4,-62,-14,-80,-27xm110,-160v-22,0,-22,19,-4,22xm108,-51v21,0,22,-18,4,-23","w":208,"k":{"9":6,"8":2,"7":17,"5":8,"4":4,"3":10,"2":5,"1":9}},"+":{"d":"8,-70r11,-61r64,0r12,-69r70,0r-13,69r64,0r-11,61r-64,0r-12,70r-70,0r13,-70r-64,0","w":215},"=":{"d":"0,-24r11,-61r196,0r-10,61r-197,0xm16,-116r11,-61r197,0r-11,61r-197,0","w":215},"<":{"d":"169,0r-159,-66r12,-70r182,-64r-14,79r-82,23r74,23","w":195},">":{"d":"34,-200r159,66r-12,70r-182,64r14,-79r82,-24r-74,-23","w":195},"%":{"d":"232,-210r49,0r-180,210r-49,0xm13,-146v0,-39,32,-67,77,-67v37,0,58,22,58,54v0,39,-33,67,-78,67v-37,0,-57,-21,-57,-54xm85,-178v-26,-4,-36,49,-9,51v26,4,37,-49,9,-51xm185,-50v0,-39,32,-67,77,-67v37,0,59,21,59,53v0,39,-34,68,-79,68v-37,0,-57,-21,-57,-54xm258,-82v-27,-4,-37,48,-10,50v26,4,38,-48,10,-50","w":325},"~":{"d":"15,-62v-1,-48,17,-79,58,-79v31,0,48,20,67,20v8,0,13,-5,14,-15r46,0v1,48,-15,78,-58,78v-29,0,-48,-20,-66,-20v-9,0,-14,6,-15,16r-46,0","w":208},"^":{"d":"46,-202r65,-70r78,0r41,70r-68,0r-15,-25r-24,25r-77,0","w":229},"\u00a0":{"w":80}}});
var ingr=false;
window.addEvent( 'domready', function () {
var options = { 'initialCSSClass': 'dd-noscript',
'activeCSSClass': 'active',
'fadeDuration': 300
};
var topMenu = new NXC.DDMenu( 'topmenu', options );
});
function doClear(theText){ if (theText.value == theText.defaultValue) { theText.value = "" } }
function doDefault(theText) { if (theText.value == "") { theText.value = theText.defaultValue } }
window.addEvent('domready', function() {
if(document.id( 'animations-banners' )){
if(document.id( 'animations-banners' ).getElement('.billboard-item')){
var item = document.id( 'animations-banners' );
new fadeGallery(item, {
steps					: 1,
autoplay				: false,
speed					: 1000,
duration				: 2000,
holder					: '.billboard-holder',
elementsParent	: '.billboard-items',
elements				: '.billboard-item',
disableClass		: 'disabled',
nextItem				: '.next-item',
prevItem				: '.prev-item',
mode					: "line"
});
}
}
});
window.addEvent( 'domready', function() {
var options={'className':'tooltip_buble'};
var myTips = new Tips( 'a.tooltip', options );
} );
window.installBasketMove = function() {
var basketContainer = document.id( 'basket-wrapper' );
var basketItems     = document.id( 'basket-scroll' );
getMaxMargin = function() {
bcHeight = basketContainer.getStyle( 'padding-top' ).toInt() + basketContainer.getStyle( 'height' ).toInt() + basketContainer.getStyle( 'padding-bottom' ).toInt();
biHeight = basketItems.getStyle( 'padding-top' ).toInt() + basketItems.getStyle( 'height' ).toInt() + basketItems.getStyle( 'padding-bottom' ).toInt();
var maxMargin = 0;
if( bcHeight < biHeight ) {
maxMargin = bcHeight - biHeight;
}
return maxMargin;
}
if ( $type( basketItems ) == 'element' ){
var minMargin = 0;
bMoveFx = new Fx.Tween( basketItems, {
'duration'  : 1000,
'property'  : 'margin-top',
'transition': Fx.Transitions.linear
} );
}
if ( $type( document.id('arr-dn') ) == 'element' ){
document.id( 'arr-dn' ).addEvent( 'mousedown', function( e ){
e.stop();
bMoveFx.start( getMaxMargin() );
} );
document.id( 'arr-dn' ).addEvent( 'mouseup', function( e ){
e.stop();
bMoveFx.cancel();
} );
document.id( 'arr-dn' ).addEvent( 'click', function( e ){
e.stop();
} );
}
if ( $type( document.id('arr-up') ) == 'element' ){
document.id( 'arr-up' ).addEvent( 'mousedown', function( e ){
e.stop();
bMoveFx.start( minMargin );
} );
document.id( 'arr-up' ).addEvent( 'mouseup', function( e ){
e.stop();
bMoveFx.cancel();
} );
document.id( 'arr-up' ).addEvent( 'click', function( e ){
e.stop();
} );
}
};
window.addEvent( 'domready', window.installBasketMove );
window.addEvent( 'domready', function() {
var topOffset    = 10;
var backetBlock  = document.id( 'basket-position' );
if( $type( backetBlock ) == 'element' ){
if ( !backetBlock.getParent().hasClass('col-right') ) {
var parentOffset = backetBlock.getParent().getPosition().y.toInt();
window.AddEvent( window, 'scroll', function() {
var windowOffset = document.id( window ).getScroll().y.toInt();
var top = ( windowOffset >= parentOffset ) ? windowOffset + topOffset : parentOffset;
backetBlock.tween( 'top', top );
} );
}
}
} );
window.addEvent( 'domready', function() {
var slideBlocks = document.getElements( 'div.profile-block' );
var slides = Array();
var options = { duration: 100,
onComplete: function(){
if(this.wrapper.getStyle('height') != "0px"){
this.wrapper.setStyle('height', 'auto');
}
}
};
slideBlocks.each( function( slideBlock, i ) {
slides[i] = new Fx.Slide( slideBlock.getElement( 'div.slide-block' ), options );
if( slideBlock.hasClass( 'pb-closed' ) ) {
slides[i].hide();
};
slideBlock.getElement( 'h4 a' ).addEvent( 'click', function( e ){
e.stop();
this.getParent('h4').toggleClass('bsh-open').toggleClass('bsh-closed');
slides[i].toggle().chain( function(){
slideBlock.toggleClass('pb-open').toggleClass('pb-closed');
});
} );
} );
} );
window.addEvent( 'domready', function() {
var xslideBlocks = document.getElements( 'div.extra-block' );
var xslides = Array();
xslideBlocks.each( function( xslideBlock, i ) {
xslides[i] = new Fx.Slide( xslideBlock.getElement( 'div.slide-block' ), { duration: 100 } );
if( xslideBlock.hasClass( 'pb-closed' ) ) {
xslides[i].hide();
};
xslideBlock.getElement( 'h4 a' ).addEvent( 'click', function( e ){
e.stop();
this.getParent('h4').toggleClass('bsh-open').toggleClass('bsh-closed');
xslides[i].toggle().chain( function(){
xslideBlock.toggleClass('pb-open').toggleClass('pb-closed');
}
);
} );
} );
} );
window.addEvent( 'domready', function() {
document.getElements( 'a.no-link' ).addEvent( 'click', function( e ){
e.stop()
});
});
window.addEvent( 'domready', function() {
var toplinksDiv = document.id( 'toplinks' );
var toplinks = toplinksDiv.getElements( 'a.top-links-toggler' );
toplinks.each( function( toplink ) {
toplink.addEvent( 'click', function( e ){
e.stop();
toplinksDiv.toggleClass('top-links-na').toggleClass('top-links-ac');
} );
} );
} );
window.installRemoveFromBasket = function() {
document.getElements( 'div#basket-scroll a.remove-item' ).each( function( el ) {
el.addEvent( 'click', function( e ) {
e.stop();
new Fx.Tween( this.getParent() ).start( 'opacity', 0 ).chain( function() {
var href = new String(el.get('href'));
if(href.match(/^\/shop\/basket\/removeextra\//)) {
href = href.replace(/^\/shop\/basket\/removeextra\//,'');
var id = href.replace(/\/\d+/,'');
var ingredient = href.replace(/\d+\//,'');
xajax_nxcRemoveIngrItem( id, ingredient );
} else {
xajax_nxcRemoveBasketItem( el.getParent().get( 'id' ).replace( 'basket-item-', '' ) );
}
this.subject.destroy();
} );
} );
} );
}
window.addEvent( 'domready', installRemoveFromBasket );
window.highlightBasketItem = function( id ) {
el = document.id( id );
if( $type( el ) == 'element' ){
el.setStyle( 'background-color', '#41A726' );
var basketWrapper         = document.id( 'basket-wrapper' );
var basketItemsContainger = document.id( 'basket-scroll' );
basketItemsContainger.get( 'tween', { property: 'margin-top', duration: 500 } ).start(
basketWrapper.getStyle( 'height' ).toInt() - basketItemsContainger.getStyle( 'height' ).toInt()
);
( function() {
el.get( 'tween', { property: 'background-color', duration: 'long'} ).start( '#FFFFFF' );
} ).delay( 500 );
}
}
var NXC = NXC || {};
NXC.DDMenu = new Class({
Implements: [Chain, Options],
options: {
'menuCSSPath': 'ul',
'itemCSSPath': 'li',
'initialCSSClass': 'nxc-noscript',
'activeCSSClass': 'nxc-active',
'fadeDuration': 500
},
initialize: function( wrapperCSSPath, options ) {
this.setOptions( options );
this.menuWrapper  = document.id( wrapperCSSPath );
this.items        = this.menuWrapper.getElement( this.options.menuCSSPath ).getElements( this.options.itemCSSPath );
this.onInit();
this.run();
},
onInit: function() {
if( this.menuWrapper.hasClass( this.options.initialCSSClass ) ) {
this.menuWrapper.removeClass( this.options.initialCSSClass );
}
this.hideAllSubMenuFast();
},
showSubMenu: function( subMenu ) {
subMenu.setStyle( 'display', 'block' );
},
hideSubMenu: function( subMenu ) {
subMenu.setStyle( 'display', 'none' );
},
itemOver: function( e, item ) {
item.addClass( this.options.activeCSSClass );
this.hideAllSubMenu();
},
itemLeave: function( e, item ) {
item.removeClass( this.options.activeCSSClass );
},
itemWSubOver: function( e, item, subMenu ) {
item.addClass( this.options.activeCSSClass );
this.showSubMenu( subMenu );
subMenu.get( 'tween', { property: 'opacity', duration: this.options.fadeDuration } ).start( 1 );
},
itemWSubLeave: function( e, item, subMenu ) {
item.removeClass( this.options.activeCSSClass );
subMenu.get( 'tween', { 'property': 'opacity', duration: this.options.fadeDuration } ).start( 0 ).chain(
function() {
this.hideSubMenu( subMenu );
}.bind( this )
);
},
subLeave: function( e, subMenu ) {
subMenu.get( 'tween', { 'property': 'opacity', duration: this.options.fadeDuration } ).start( 0 ).chain(
function() {
this.hideSubMenu( subMenu );
}.bind( this )
);
},
run: function() {
this.items.each( function( item ) {
var subMenu = item.getElement( this.options.menuCSSPath );
if( $type( subMenu ) == 'element' ) {
item.addEvent( 'mouseover', function( e ) {
this.itemWSubOver( e, item, subMenu );
}.bind( this ) );
item.addEvent( 'mouseleave', function( e ) {
this.itemWSubLeave( e, item, subMenu );
}.bind( this ) );
subMenu.addEvent( 'mouseleave', function( e ) {
this.subLeave( e, subMenu );
}.bind( this ) );
} else {
item.addEvent( 'mouseover', function( e ) {
this.itemOver( e, item, subMenu );
}.bind( this ) );
item.addEvent( 'mouseleave', function( e ) {
this.itemLeave( e, item, subMenu );
}.bind( this ) );
}
}, this );
},
hideAllSubMenu: function() {
this.items.each( function( item ) {
var subMenu = item.getElement( this.options.menuCSSPath );
if( $type( subMenu ) == 'element' ) {
subMenu.get( 'tween', { 'property': 'opacity', duration: this.options.fadeDuration } ).start( 0 ).chain(
function() {
this.hideSubMenu( subMenu );
}.bind( this )
);
}
}.bind( this ) );
},
hideAllSubMenuFast: function() {
this.items.each( function( item ) {
var subMenu = item.getElement( this.options.menuCSSPath );
if( $type( subMenu ) == 'element' ) {
this.hideSubMenu( subMenu );
}
}.bind( this ) );
}
} );
var NXC = NXC || {};
NXC.Tabs = new Class( {
Implements: [Options],
options: {
'transitionDuration': 500,
'startIndex':         0,
'selectedLinkStyle':  false,
'selectedTabStyle':   false
},
tabs         : [],
links        : [],
currentIndex : 0,
initialize: function( linktabsSelector, tabsSelector, options ) {
this.linktabs = document.getElements( linktabsSelector );
this.links    = document.getElements( linktabsSelector + ' a' );
this.tabs     = document.getElements( tabsSelector );
if (this.links.lenght!=this.tabs.lenght){
alert('Links and tabs qty are not the same');
return false;
};
this.setMaxWrapperHeight();
this.setOptions( options );
var anchor_name=window.location.toString().split('#')[1];
var anchor_selector = 'a[name='+anchor_name+']';
var selIndex = false;
this.tabs.each( function( tab, index ) {
if( tab.getElement( anchor_selector ) ){
selIndex = index;
tab.getElement( anchor_selector ).addClass('aaa');
}
}.bind( this ) );
this.currentIndex = ( selIndex ? selIndex : this.options.startIndex );
this.install();
},
install: function() {
this.showStartTab( this.currentIndex );
this.links.each( function( link, index ) {
link.addEvent( 'click', function( e ) {
e.stop();
if( index !== this.currentIndex ) {
this.showTab( index );
}
}.bind( this ) );
}.bind( this ) );
},
showStartTab: function( index ) {
this.linktabs.removeClass( this.options.selectedLinkStyle );
this.tabs.setStyle( 'display', 'none' );
this.tabs.setStyle( 'opacity', 0 );
this.tabs.removeClass( this.options.selectedTabStyle );
this.tabs[ index ].setStyles( {
'display': 'block',
'opacity': '1'
} );
if( this.options.selectedLinkStyle !== false ) {
this.linktabs[ index ].addClass( this.options.selectedLinkStyle );
}
if( this.options.selectedTabStyle !== false ) {
this.tabs[ index ].addClass( this.options.selectedTabStyle );
}
this.currentIndex = index;
},
showTab: function( index ) {
var linktab    = this.linktabs[ index ];
var showTab    = this.tabs[ index ];
var currentTab = this.tabs[ this.currentIndex ];
if( this.options.selectedLinkStyle !== false ) {
this.linktabs.removeClass( this.options.selectedLinkStyle );
linktab.addClass( this.options.selectedLinkStyle );
}
if( this.options.selectedTabStyle !== false ) {
this.tabs.removeClass( this.options.selectedTabStyle );
showTab.addClass( this.options.selectedTabStyle );
}
currentTab.get( 'tween', { property: 'opacity', duration: this.options.transitionDuration } ).start( 0 ).chain( function() {
currentTab.setStyle( 'display', 'none' );
}.bind( this ) );
showTab.setStyle( 'display', 'block' );
showTab.get( 'tween', { property: 'opacity', duration: this.options.transitionDuration } ).start( 1 );
this.currentIndex = index;
},
setMaxWrapperHeight: function() {
var maxHeight=0;
var height=0;
this.tabs.each( function( tab ) {
height = tab.getStyle( 'height' ).toInt() + tab.getStyle( 'padding-top' ).toInt() + tab.getStyle( 'padding-bottom' ).toInt() + tab.getStyle( 'margin-top' ).toInt() + tab.getStyle( 'margin-bottom' ).toInt();
if( maxHeight < height ) {
maxHeight = height;
}
}.bind( this ) );
this.tabs[0].getParent().setStyle( 'height', maxHeight );
}
} );
var slideGallery = new Class({
Version: "1.2.1",
Implements: [Options],
options: {
holder: ".holder",
elementsParent: "ul",
elements: "li",
nextItem: ".next",
prevItem: ".prev",
stop: ".stop",
start: ".start",
speed: 600,
duration: 4000,
steps: 1,
current: 0,
transition: Fx.Transitions.linear,
direction: "horizontal",
mode: "callback",
disableClass: "disable",
currentClass: "current",
paging: false,
autoplay: false,
onStart: function(current, visible, length) {},
onPlay: function(current, visible, length) {}
},
initialize: function(gallery, options) {
this.gallery = gallery;
this.setOptions(options);
this.holder = this.gallery.getElement(this.options.holder);
this.itemsParent = this.holder.getElement(this.options.elementsParent);
this.items = this.itemsParent.getElements(this.options.elements);
this.next = this.gallery.getElement(this.options.nextItem);
this.next.cl = this.next.className;
this.prev = this.gallery.getElement(this.options.prevItem);
this.prev.cl = this.prev.className;
this.stop = this.gallery.getElement(this.options.stop);
this.start = this.gallery.getElement(this.options.start);
this.current = this.options.current;
this.bound = { rotate: this.rotate.bind(this) }
if(this.options.direction == "horizontal") {
this.direction = "margin-left";
this.size = this.items[0].getWidth();
this.visible = Math.round(this.holder.getWidth()/this.size);
}
else {
this.direction = "margin-top";
this.size = this.items[0].getHeight();
this.visible = Math.round(this.holder.getHeight()/this.size);
}
if(this.next == null) this.next = new Element("a").injectInside(this.gallery);
if(this.prev == null) this.prev = new Element("a").injectInside(this.gallery);
if(this.visible < this.items.length) {
this.options.steps = this.options.steps > this.visible ? this.visible : this.options.steps;
this.options.duration = this.options.duration < 1000 ? 1000 : this.options.duration;
if(this.options.mode != "circle") {
for(var i=0; i<this.items.length; i++) {
if(this.items[i].hasClass(this.options.currentClass)) this.current = i;
}
if(this.visible+this.current >= this.items.length) {
this.margin = (this.items.length-this.visible)*this.size;
this.current = this.items.length-this.visible;
}
else this.margin = this.current*this.size;
if(this.options.paging) {
this.paging = new Element("ul").injectInside(this.gallery).addClass("paging");
for(var i=0; i<Math.ceil((this.items.length-this.visible)/this.options.steps)+1; i++) {
this.paging.innerHTML += '<li><a href="#">' + parseInt(i+1) + '</a></li>';
}
this.paging = this.paging.getElements("a");
this.paging.each(function(el, i) {
el.addEvent("click", function() {
if(i*this.options.steps+this.visible >= this.items.length) {
this.margin = (this.items.length-this.visible)*this.size;
this.current = this.items.length-this.visible;
}
else this.current = i*this.options.steps;
this.margin = this.current*this.size;
this.play(this.options.speed);
return false;
}.bind(this));
}.bind(this));
}
this.play(0);
}
else {
for(; this.items.length < this.options.steps+this.visible;) {
this.items.clone().inject(this.itemsParent, "bottom");
this.items = this.itemsParent.getElements(this.options.elements);
}
this.current = 0;
this.options.paging = false;
}
this.next.addEvent("click", function() {
this.nextFun();
return false;
}.bind(this));
this.prev.addEvent("click", function() {
this.prevFun();
return false;
}.bind(this));
if(this.options.autoplay || this.start || this.stop) {
if(!this.options.autoplay) this.gallery.addClass("stopped");
this.timer = this.bound.rotate.delay(this.options.duration);
this.gallery.addEvent("mouseenter", function() {
this.options.autoplay = false;
$clear(this.timer);
}.bind(this));
this.gallery.addEvent("mouseleave", function() {
if(!this.gallery.hasClass("stopped")) {
$clear(this.timer);
this.options.autoplay = true;
this.timer = this.bound.rotate.delay(this.options.duration);
}
}.bind(this));
}
if(this.stop) {
this.stop.addEvent("click", function() {
this.gallery.addClass("stopped").fireEvent("mouseenter");
return false;
}.bind(this));
}
if(this.start) {
this.start.addEvent("click", function() {
this.gallery.removeClass("stopped").fireEvent("mouseenter");
return false;
}.bind(this));
}
}
else {
this.next.addClass(this.next.cl + "-" + this.options.disableClass);
this.prev.addClass(this.prev.cl + "-" + this.options.disableClass);
this.next.addEvent("click", function() {return false;}.bind(this));
this.prev.addEvent("click", function() {return false;}.bind(this));
if(this.stop) this.stop.addEvent("click", function() {return false;}.bind(this));
if(this.start) this.start.addEvent("click", function() {return false;}.bind(this));
this.gallery.addClass("stopped");
}
this.options.onStart(this.current, this.visible, this.items.length);
},
play: function(speed) {
if(this.options.mode == "line") {
this.next.removeClass(this.next.cl + "-" + this.options.disableClass);
this.prev.removeClass(this.prev.cl + "-" + this.options.disableClass);
if(this.visible+this.current >= this.items.length) this.next.addClass(this.next.cl + "-" + this.options.disableClass);
else if(this.current==0) this.prev.addClass(this.prev.cl + "-" + this.options.disableClass);
}
this.itemsParent.set("tween", {
duration: speed,
transition: this.options.transition
});
this.itemsParent.tween(this.direction, -this.margin);
if(this.options.paging) {
this.paging.removeClass("active");
this.paging[Math.ceil(this.current/this.options.steps)].addClass("active");
}
this.options.onPlay(this.current, this.visible, this.items.length);
},
rotate: function() {
if(this.options.autoplay) {
this.next.fireEvent("click");
this.timer = this.bound.rotate.delay(this.options.duration);
}
},
nextFun: function() {
if(this.options.mode != "circle") {
if(this.visible+this.current >= this.items.length) {
if(this.options.mode == "callback") {
this.margin = 0;
this.current = 0;
}
}
else if(this.visible+this.current+this.options.steps >= this.items.length) {
this.margin = (this.items.length-this.visible)*this.size;
this.current = this.items.length-this.visible;
}
else	{
this.current = this.current+this.options.steps;
this.margin = this.current*this.size;
}
this.play(this.options.speed);
}
else {
var _this = this;
this.margin = this.size*this.options.steps;
this.itemsParent.set("tween", {
duration: this.options.speed,
transition: this.options.transition,
property: this.direction,
onComplete: function()	{
for(var i=0; i<_this.options.steps; i++) {
if(_this.current >= _this.items.length) _this.current = 0;
_this.current++;
_this.items[_this.current-1].inject(_this.itemsParent, "bottom");
}
this.set(0);
},
onCancel: function() {	this.onComplete(); }
});
this.itemsParent.tween(-this.margin);
}
},
prevFun: function() {
if(this.options.mode != "circle") {
if(this.current <= 0) {
if(this.options.mode == "callback") {
this.margin = (this.items.length-this.visible)*this.size;
this.current = this.items.length-this.visible;
}
}
else if(this.current-this.options.steps <= 0) {
this.margin = 0;
this.current = 0;
}
else	{
this.current = this.current-this.options.steps;
this.margin = this.current*this.size;
}
this.play(this.options.speed);
}
else {
for(var i=0; i<this.options.steps; i++) {
if(this.current-1 < 0) this.current = this.items.length;
--this.current;
this.items[this.current].inject(this.itemsParent, "top");
}
this.itemsParent.setStyle(this.direction, -this.size*this.options.steps + "px");
this.margin = 0;
this.play(this.options.speed);
}
}
});
var fadeGallery = new Class({
Extends: slideGallery,
initialize: function(gallery, options) {
this.previous = null;
this.parent(gallery, options);
this.visible = 1;
this.options.steps = 1;
},
play: function(speed) {
if(this.options.mode == "line") {
this.next.removeClass(this.next.cl + "-" + this.options.disableClass);
this.prev.removeClass(this.prev.cl + "-" + this.options.disableClass);
if(this.visible+this.current >= this.items.length) this.next.addClass(this.next.cl + "-" + this.options.disableClass);
else if(this.current==0) this.prev.addClass(this.prev.cl + "-" + this.options.disableClass);
}
if(this.previous == null) this.previous = this.items;
this.previous.set("tween", {
duration: speed,
transition: this.options.transition
});
this.previous.tween("opacity", 0);
this.items[this.current].set("tween", {
duration: speed,
transition: this.options.transition
});
this.items[this.current].tween("opacity", 1);
if(this.options.paging) {
this.paging.removeClass("active");
this.paging[Math.ceil(this.current/this.options.steps)].addClass("active");
}
this.previous = this.items[this.current];
this.options.onPlay(this.current, this.visible, this.items.length);
}
});
function changeStatusById(id){
relCheckbox=document.id(id);
item=document.getElement('a[id|='+id+']');
if(item){
group=item.get('id').split('-')[2]?item.get('id').split('-')[2]:false;
type=item.get('id').split('-')[0];
itemClass="";
if(type=="rb")itemClass="r_";
else if(type=="rc")itemClass="rc_";
if(relCheckbox.checked){
item.removeClass(itemClass+"unchecked");
item.addClass(itemClass+"checked");
if(group)
document.id( document.body ).getElements('.'+group).each(function(groupItem,index){
if(groupItem!=item){
groupItem.removeClass(itemClass+"checked");
groupItem.addClass(itemClass+"unchecked");
}
});
}else{
item.removeClass(itemClass+"checked");
item.addClass(itemClass+"unchecked");
}
}
};
window.addEvent('domready', function() {
document.id( document.body ).getElements('.checkbox').each(function(item,index){
relatedID=false;
if(item.get('id'))relatedID=item.get('id').split('-')[1]?item.get('id').split('-')[1]:false;
if(relatedID){
relCheckbox=document.id( relatedID )?document.id( relatedID ):false;
if(relCheckbox){
if(relCheckbox.checked){
item.removeClass("unchecked");
item.addClass("checked");
}else{
item.removeClass("checked");
item.addClass("unchecked");
}
if(relCheckbox.disabled){
item.addClass("disabled");
}else{
item.removeClass("disabled");
}
item.store('relCheckbox',relCheckbox);
item.addEvent('click',function(e){
e.stop();
relCheckbox=item.retrieve('relCheckbox', false);
if(relCheckbox && !relCheckbox.disabled){
relCheckbox.click();
if(relCheckbox.checked){
item.removeClass("unchecked");
item.addClass("checked");
}else{
item.removeClass("checked");
item.addClass("unchecked");
}
}
});
}
}
});
document.id( document.body ).getElements('.radio-button').each(function(item,index){
relatedID=false;
if(item.get('id'))
{
relatedID=item.get('id').split('-')[1]?item.get('id').split('-')[1]:false;
group=item.get('id').split('-')[2]?item.get('id').split('-')[2]:false;
}
if(relatedID){
relRadio=document.id( relatedID );
if(relRadio){
if(relRadio.checked){
item.removeClass("r_unchecked");
item.addClass("r_checked");
}else{
item.removeClass("r_checked");
item.addClass("r_unchecked");
}
if(relRadio.disabled){
item.addClass("r_disabled");
}else{
item.removeClass("r_disabled");
}
item.store('relRadio',relRadio);
item.store('group',group);
item.addEvent('click',function(e){
e.stop();
relRadio=item.retrieve('relRadio', false);
group=item.retrieve('group', false);
if(relRadio && !relRadio.checked){
relRadio.click();
if(relRadio.checked){
item.removeClass("r_unchecked");
item.addClass("r_checked");
if(group)
document.id( document.body ).getElements('.'+group).each(function(groupItem,index){
if(groupItem!=item){
groupItem.removeClass("r_checked");
groupItem.addClass("r_unchecked");
}
});
}
}
});
}
}
});
document.id( document.body ).getElements('.rc_checkbox').each(function(item,index){
relatedID=false;
if(item.get('id'))
{
relatedID=item.get('id').split('-')[1]?item.get('id').split('-')[1]:false;
group=item.get('id').split('-')[2]?item.get('id').split('-')[2]:false;
}
if(relatedID){
relRadio=document.id( relatedID );
if(relRadio){
if(relRadio.checked){
item.removeClass("rc_unchecked");
item.addClass("rc_checked");
}else{
item.removeClass("rc_checked");
item.addClass("rc_unchecked");
}
if(relRadio.disabled){
item.addClass("rc_disabled");
}else{
item.removeClass("rc_disabled");
}
item.store('relRadio',relRadio);
item.store('group',group);
item.addEvent('click',function(e){
e.stop();
relRadio=item.retrieve('relRadio', false);
group=item.retrieve('group', false);
if(relRadio && !relRadio.checked){
relRadio.click();
if(relRadio.checked){
item.removeClass("rc_unchecked");
item.addClass("rc_checked");
if(group)
document.id( document.body ).getElements('.'+group).each(function(groupItem,index){
if(groupItem!=item){
groupItem.removeClass("rc_checked");
groupItem.addClass("rc_unchecked");
}
});
}
}
});
}
}
});
});
Array.prototype.containsValue=function(valueToCheck){for(var i=0;i<this.length;i++){if(this[i]==valueToCheck)return true;}
return false;}
function Xajax(){this.DebugMessage=function(text){if(text.length > 1000)text=text.substr(0,1000)+"...\n[long response]\n...";try{if(this.debugWindow==undefined||this.debugWindow.closed==true){this.debugWindow=window.open('about:blank','xajax-debug','width=800,height=600,scrollbars=1,resizable,status');this.debugWindow.document.write('<html><head><title>Xajax debug output</title></head><body><h2>Xajax debug output</h2><div id="debugTag"></div></body></html>');}
text=text.replace(/&/g,"&amp;")
text=text.replace(/</g,"&lt;")
text=text.replace(/>/g,"&gt;")
debugTag=this.debugWindow.document.getElementById('debugTag');debugTag.innerHTML=('<b>'+(new Date()).toString()+'</b>: '+text+'<hr/>')+debugTag.innerHTML;}catch(e){alert("Xajax Debug:\n "+text);}
};this.workId='xajaxWork'+new Date().getTime();this.depth=0;this.responseErrorsForAlert=["400","401","402","403","404","500","501","502","503"];this.getRequestObject=function(){if(xajaxDebug)this.DebugMessage("Initializing Request Object..");var req=null;if(typeof XMLHttpRequest!="undefined")
req=new XMLHttpRequest();if(!req&&typeof ActiveXObject!="undefined"){try{req=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e2){try{req=new ActiveXObject("Msxml2.XMLHTTP.4.0");}
catch(e3){req=null;}
}
}
}
if(!req&&window.createRequest)
req=window.createRequest();if(!req)this.DebugMessage("Request Object Instantiation failed.");return req;}
this.$=function(sId){if(!sId){return null;}
var returnObj=document.getElementById(sId);if(!returnObj&&document.all){returnObj=document.all[sId];}
if(xajaxDebug&&!returnObj&&sId!=this.workId){this.DebugMessage("Element with the id \""+sId+"\" not found.");}
return returnObj;}
this.include=function(sFileName){var objHead=document.getElementsByTagName('head');var objScript=document.createElement('script');objScript.type='text/javascript';objScript.src=sFileName;objHead[0].appendChild(objScript);}
this.stripOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')==0){sEventName=sEventName.replace(/on/,'');}
return sEventName;}
this.addOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')!=0){sEventName='on'+sEventName;}
return sEventName;}
this.addHandler=function(sElementId,sEvent,sFunctionName){if(window.addEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').addEventListener('"+sEvent+"',"+sFunctionName+",false);");}
else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"').attachEvent('"+sAltEvent+"',"+sFunctionName+",false);");}
}
this.removeHandler=function(sElementId,sEvent,sFunctionName){if(window.addEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').removeEventListener('"+sEvent+"',"+sFunctionName+",false);");}
else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"').detachEvent('"+sAltEvent+"',"+sFunctionName+",false);");}
}
this.create=function(sParentId,sTag,sId){var objParent=this.$(sParentId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);if(objParent)
objParent.appendChild(objElement);}
this.insert=function(sBeforeId,sTag,sId){var objSibling=this.$(sBeforeId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling);}
this.insertAfter=function(sAfterId,sTag,sId){var objSibling=this.$(sAfterId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
this.getInput=function(sType,sName,sId){var Obj;if(!window.addEventListener){Obj=document.createElement('<input type="'+sType+'" id="'+sId+'" name="'+sName+'">');}
else{Obj=document.createElement('input');Obj.setAttribute('type',sType);Obj.setAttribute('name',sName);Obj.setAttribute('id',sId);}
return Obj;}
this.createInput=function(sParentId,sType,sName,sId){var objParent=this.$(sParentId);var objElement=this.getInput(sType,sName,sId);if(objParent&&objElement)
objParent.appendChild(objElement);}
this.insertInput=function(sBeforeId,sType,sName,sId){var objSibling=this.$(sBeforeId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode)
objSibling.parentNode.insertBefore(objElement,objSibling);}
this.insertInputAfter=function(sAfterId,sType,sName,sId){var objSibling=this.$(sAfterId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode){objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
}
this.remove=function(sId){objElement=this.$(sId);if(objElement&&objElement.parentNode&&objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement);}
}
this.replace=function(sId,sAttribute,sSearch,sReplace){var bFunction=false;if(sAttribute=="innerHTML")
sSearch=this.getBrowserHTML(sSearch);eval("var txt=this.$('"+sId+"')."+sAttribute);if(typeof txt=="function"){txt=txt.toString();bFunction=true;}
if(txt.indexOf(sSearch)>-1){var newTxt='';while(txt.indexOf(sSearch)>-1){x=txt.indexOf(sSearch)+sSearch.length+1;newTxt+=txt.substr(0,x).replace(sSearch,sReplace);txt=txt.substr(x,txt.length-x);}
newTxt+=txt;if(bFunction){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
else if(this.willChange(sId,sAttribute,newTxt)){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
}
}
this.getFormValues=function(frm){var objForm;var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true)
submitDisabledElements=true;var prefix="";if(arguments.length > 2)
prefix=arguments[2];if(typeof(frm)=="string")
objForm=this.$(frm);else
objForm=frm;var sXml="<xjxquery><q>";if(objForm&&objForm.tagName=='FORM'){var formElements=objForm.elements;for(var i=0;i < formElements.length;i++){if(!formElements[i].name)
continue;if(formElements[i].name.substring(0,prefix.length)!=prefix)
continue;if(formElements[i].type&&(formElements[i].type=='radio'||formElements[i].type=='checkbox')&&formElements[i].checked==false)
continue;if(formElements[i].disabled&&formElements[i].disabled==true&&submitDisabledElements==false)
continue;var name=formElements[i].name;if(name){if(sXml!='<xjxquery><q>')
sXml+='&';if(formElements[i].type=='select-multiple'){for(var j=0;j < formElements[i].length;j++){if(formElements[i].options[j].selected==true)
sXml+=name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";}
}
else{sXml+=name+"="+encodeURIComponent(formElements[i].value);}
}
}
}
sXml+="</q></xjxquery>";return sXml;}
this.objectToXML=function(obj){var sXml="<xjxobj>";for(i in obj){try{if(i=='constructor')
continue;if(obj[i]&&typeof(obj[i])=='function')
continue;var key=i;var value=obj[i];if(value&&typeof(value)=="object"&&this.depth <=50){this.depth++;value=this.objectToXML(value);this.depth--;}
sXml+="<e><k>"+key+"</k><v>"+value+"</v></e>";}
catch(e){if(xajaxDebug)this.DebugMessage(e.name+": "+e.message);}
}
sXml+="</xjxobj>";return sXml;}
this._nodeToObject=function(node){if(node.nodeName=='#cdata-section'){var data="";for(var j=0;j<node.parentNode.childNodes.length;j++){data+=node.parentNode.childNodes[j].data;}
return data;}
else if(node.nodeName=='xjxobj'){var data=new Array();for(var j=0;j<node.childNodes.length;j++){var child=node.childNodes[j];var key;var value;if(child.nodeName=='e'){for(var k=0;k<child.childNodes.length;k++){if(child.childNodes[k].nodeName=='k'){key=child.childNodes[k].firstChild.data;}
else if(child.childNodes[k].nodeName=='v'){value=this._nodeToObject(child.childNodes[k].firstChild);}
}
if(key!=null&&value!=null){data[key]=value;key=value=null;}
}
}
return data;}
}
this.loadingFunction=function(){};this.doneLoadingFunction=function(){};var loadingTimeout;this.call=function(sFunction,aArgs,sRequestType){var i,r,postData;if(document.body&&xajaxWaitCursor)
document.body.style.cursor='wait';if(xajaxStatusMessages==true)window.status='Sending Request...';clearTimeout(loadingTimeout);loadingTimeout=setTimeout("xajax.loadingFunction();",400);if(xajaxDebug)this.DebugMessage("Starting xajax...");if(sRequestType==null){var xajaxRequestType=xajaxDefinedPost;}
else{var xajaxRequestType=sRequestType;}
var uri=xajaxRequestUri;var value;switch(xajaxRequestType){case xajaxDefinedGet:{var uriGet=uri.indexOf("?")==-1?"?xajax="+encodeURIComponent(sFunction):"&xajax="+encodeURIComponent(sFunction);if(aArgs){for(i=0;i<aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object")
value=this.objectToXML(value);uriGet+="&xajaxargs[]="+encodeURIComponent(value);}
}
uriGet+="&xajaxr="+new Date().getTime();uri+=uriGet;postData=null;}break;case xajaxDefinedPost:{postData="xajax="+encodeURIComponent(sFunction);postData+="&xajaxr="+new Date().getTime();if(aArgs){for(i=0;i <aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object")
value=this.objectToXML(value);postData=postData+"&xajaxargs[]="+encodeURIComponent(value);}
}
}break;default:
alert("Illegal request type: "+xajaxRequestType);return false;break;}
r=this.getRequestObject();if(!r)return false;r.open(xajaxRequestType==xajaxDefinedGet?"GET":"POST",uri,true);if(xajaxRequestType==xajaxDefinedPost){try{r.setRequestHeader("Method","POST "+uri+" HTTP/1.1");r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
catch(e){alert("Your browser does not appear to  support asynchronous requests using POST.");return false;}
}
r.onreadystatechange=function(){if(r.readyState!=4)
return;if(r.status==200){if(xajaxDebug)xajax.DebugMessage("Received:\n"+r.responseText);if(r.responseXML&&r.responseXML.documentElement)
xajax.processResponse(r.responseXML);else{var errorString="Error: the XML response that was returned from the server is invalid.";errorString+="\nReceived:\n"+r.responseText;trimmedResponseText=r.responseText.replace(/^\s+/g,"");trimmedResponseText=trimmedResponseText.replace(/\s+$/g,"");if(trimmedResponseText!=r.responseText)
errorString+="\nYou have whitespace in your response.";alert(errorString);document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Invalid XML response error';}
}
else{if(xajax.responseErrorsForAlert.containsValue(r.status)){var errorString="Error: the server returned the following HTTP status: "+r.status;errorString+="\nReceived:\n"+r.responseText;alert(errorString);}
document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Invalid XML response error';}
delete r;r=null;}
if(xajaxDebug)this.DebugMessage("Calling "+sFunction+" uri="+uri+" (post:"+postData+")");r.send(postData);if(xajaxStatusMessages==true)window.status='Waiting for data...';delete r;return true;}
this.getBrowserHTML=function(html){tmpXajax=this.$(this.workId);if(!tmpXajax){tmpXajax=document.createElement("div");tmpXajax.setAttribute('id',this.workId);tmpXajax.style.display="none";tmpXajax.style.visibility="hidden";document.body.appendChild(tmpXajax);}
tmpXajax.innerHTML=html;var browserHTML=tmpXajax.innerHTML;tmpXajax.innerHTML='';return browserHTML;}
this.willChange=function(element,attribute,newData){if(!document.body){return true;}
if(attribute=="innerHTML"){newData=this.getBrowserHTML(newData);}
elementObject=this.$(element);if(elementObject){var oldData;eval("oldData=this.$('"+element+"')."+attribute);if(newData!==oldData)
return true;}
return false;}
this.viewSource=function(){return "<html>"+document.getElementsByTagName("HTML")[0].innerHTML+"</html>";}
this.processResponse=function(xml){clearTimeout(loadingTimeout);this.doneLoadingFunction();if(xajaxStatusMessages==true)window.status='Processing...';var tmpXajax=null;xml=xml.documentElement;if(xml==null)
return;var skipCommands=0;for(var i=0;i<xml.childNodes.length;i++){if(skipCommands > 0){skipCommands--;continue;}
if(xml.childNodes[i].nodeName=="cmd"){var cmd;var id;var property;var data;var search;var type;var before;var objElement=null;for(var j=0;j<xml.childNodes[i].attributes.length;j++){if(xml.childNodes[i].attributes[j].name=="n"){cmd=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="t"){id=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="p"){property=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="c"){type=xml.childNodes[i].attributes[j].value;}
}
if(xml.childNodes[i].childNodes.length > 1&&xml.childNodes[i].firstChild.nodeName=="#cdata-section"){data="";for(var j=0;j<xml.childNodes[i].childNodes.length;j++){data+=xml.childNodes[i].childNodes[j].data;}
}
else if(xml.childNodes[i].firstChild&&xml.childNodes[i].firstChild.nodeName=='xjxobj'){data=this._nodeToObject(xml.childNodes[i].firstChild);objElement="XJX_SKIP";}
else if(xml.childNodes[i].childNodes.length > 1){for(var j=0;j<xml.childNodes[i].childNodes.length;j++){if(xml.childNodes[i].childNodes[j].childNodes.length > 1&&xml.childNodes[i].childNodes[j].firstChild.nodeName=="#cdata-section"){var internalData="";for(var k=0;k<xml.childNodes[i].childNodes[j].childNodes.length;k++){internalData+=xml.childNodes[i].childNodes[j].childNodes[k].nodeValue;}
}else{var internalData=xml.childNodes[i].childNodes[j].firstChild.nodeValue;}
if(xml.childNodes[i].childNodes[j].nodeName=="s"){search=internalData;}
if(xml.childNodes[i].childNodes[j].nodeName=="r"){data=internalData;}
}
}
else if(xml.childNodes[i].firstChild)
data=xml.childNodes[i].firstChild.nodeValue;else
data="";if(objElement!="XJX_SKIP")objElement=this.$(id);var cmdFullname;try{if(cmd=="cc"){cmdFullname="addConfirmCommands";var confirmResult=confirm(data);if(!confirmResult){skipCommands=id;}
}
if(cmd=="al"){cmdFullname="addAlert";alert(data);}
else if(cmd=="js"){cmdFullname="addScript/addRedirect";eval(data);}
else if(cmd=="jc"){cmdFullname="addScriptCall";var scr=id+'(';if(data[0]!=null){scr+='data[0]';for(var l=1;l<data.length;l++){scr+=',data['+l+']';}
}
scr+=');';eval(scr);}
else if(cmd=="in"){cmdFullname="addIncludeScript";this.include(data);}
else if(cmd=="as"){cmdFullname="addAssign/addClear";if(this.willChange(id,property,data)){eval("objElement."+property+"=data;");}
}
else if(cmd=="ap"){cmdFullname="addAppend";eval("objElement."+property+"+=data;");}
else if(cmd=="pp"){cmdFullname="addPrepend";eval("objElement."+property+"=data+objElement."+property);}
else if(cmd=="rp"){cmdFullname="addReplace";this.replace(id,property,search,data)
}
else if(cmd=="rm"){cmdFullname="addRemove";this.remove(id);}
else if(cmd=="ce"){cmdFullname="addCreate";this.create(id,data,property);}
else if(cmd=="ie"){cmdFullname="addInsert";this.insert(id,data,property);}
else if(cmd=="ia"){cmdFullname="addInsertAfter";this.insertAfter(id,data,property);}
else if(cmd=="ci"){cmdFullname="addCreateInput";this.createInput(id,type,data,property);}
else if(cmd=="ii"){cmdFullname="addInsertInput";this.insertInput(id,type,data,property);}
else if(cmd=="iia"){cmdFullname="addInsertInputAfter";this.insertInputAfter(id,type,data,property);}
else if(cmd=="ev"){cmdFullname="addEvent";property=this.addOnPrefix(property);eval("this.$('"+id+"')."+property+"= function(){"+data+";}");}
else if(cmd=="ah"){cmdFullname="addHandler";this.addHandler(id,property,data);}
else if(cmd=="rh"){cmdFullname="addRemoveHandler";this.removeHandler(id,property,data);}
}
catch(e){if(xajaxDebug)
alert("While trying to '"+cmdFullname+"' (command number "+i+"), the following error occured:\n"
+e.name+": "+e.message+"\n"
+(id&&!objElement?"Object with id='"+id+"' wasn't found.\n":""));}
delete objElement;delete cmd;delete cmdFullname;delete id;delete property;delete search;delete data;delete type;delete before;delete internalData;delete j;delete k;}
}
delete xml;delete i;document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Done';}
}
var xajax=new Xajax();xajaxLoaded=true;
function updateFirma() {
var togglePrivat = document.getElementById("togglePrivat");
var takeaway = document.getElementById("takeaway");
var delivery = document.getElementById("delivery");
if(takeaway.checked) {
hideElement( "takeawayCaption", false );
hideElement( "deliveryCaption", true );
hideElement( "timeCaption", false );
hideElement( "takeawayTime", false );
hideElement( "deliveryTime", true );
}
if(delivery.checked) {
hideElement( "takeawayCaption", true );
hideElement( "deliveryCaption", false );
hideElement( "timeCaption", false );
hideElement( "takeawayTime", true );
hideElement( "deliveryTime", false );
}
}
function hideElement( idElement, status ) {
var elm = document.getElementById(idElement);
if(elm == null) {
alert('Det finnes ikke noe element med ID lik \''+idElement+'\'');
} else {
if (status == true) {
elm.style.display = 'none';
}else{
elm.style.display = '';
}
}
}
function disableElement( idElement, status ) {
var elm = document.getElementById(idElement);
if(elm == null) {
alert('Det finnes ikke noe element med ID lik \''+idElement+'\'');
} else {
if (status == true) {
elm.disabled = 'true';
}else{
elm.disabled = '';
}
}
}
function hider(group){
switch(group) {
case 'days31':
hideElement( 'days31', false);
hideElement( 'days30', true);
hideElement( 'days29', true);
hideElement( 'days28', true);
break
case 'days30':
hideElement( 'days31', true);
hideElement( 'days30', false);
hideElement( 'days29', true);
hideElement( 'days28', true);
break
case 'days29':
hideElement( 'days31', true);
hideElement( 'days30', true);
hideElement( 'days29', false);
hideElement( 'days28', true);
break
case 'days28':
hideElement( 'days31', true);
hideElement( 'days30', true);
hideElement( 'days29', true);
hideElement( 'days28', false);
break
case 'creditcard':
hideElement( 'creditcardCaption', false);
hideElement( 'cashCaption', true);
hideElement( 'invoiceCaption', true);
hideElement( 'spesialavtaleCaption', false);
hideElement( 'bonuspoints', window.hasSpesialavtale);
break
case 'cash':
hideElement( 'creditcardCaption', true);
hideElement( 'cashCaption', false);
hideElement( 'invoiceCaption', true);
hideElement( 'spesialavtaleCaption', false);
hideElement( 'bonuspoints', window.hasSpesialavtale);
break
case 'invoice':
hideElement( 'creditcardCaption', true);
hideElement( 'cashCaption', true);
hideElement( 'invoiceCaption', false);
hideElement( 'spesialavtaleCaption', true);
hideElement( 'bonuspoints', true);
break
case 'reg1':
hideElement( 'region1', false);
hideElement( 'region2', true);
hideElement( 'region3', true);
break
case 'reg2':
hideElement( 'region1', true);
hideElement( 'region2', false);
hideElement( 'region3', true);
break
case 'reg3':
hideElement( 'region1', true);
hideElement( 'region2', true);
hideElement( 'region3', false);
break
default:
}
}
function disabler(group, disable){
switch(group) {
case 'time_selectors':
disableElement( 'hour_picker', disable);
disableElement( 'minute_picker', disable);
disableElement( 'month_picker', disable);
disableElement( 'days28', disable);
disableElement( 'days29', disable);
disableElement( 'days30', disable);
disableElement( 'days31', disable);
break
case 'address_selectors':
disableElement( 'home_street', disable);
disableElement( 'home_street_no', disable);
disableElement( 'home_zip_code', disable);
disableElement( 'home_select', disable);
disableElement( 'home_city', disable);
disableElement( 'home_directions', disable);
break
default:
}
}
function monthselector(month){
switch(month){
case '2':
hider('days28')
break
case '4':
hider('days30')
break
case '6':
hider('days30')
break
case '9':
hider('days30')
break
case '11':
hider('days30')
break
default:
hider('days31')
}
}
function dateSelected(d){
self.document.accountinfo.day.value=d;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
var zXml = {
useActiveX: (typeof ActiveXObject != "undefined"),
useDom: document.implementation && document.implementation.createDocument,
useXmlHttp: (typeof XMLHttpRequest != "undefined")
};
zXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.5.0", "MSXML2.XmlHttp.4.0",
"MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp",
"Microsoft.XmlHttp"];
zXml.ARR_DOM_VERS = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0",
"MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument",
"Microsoft.XmlDom"];
function zXmlHttp() {
}
zXmlHttp.createRequest = function ()/*:XMLHttp*/ {
if (zXml.useXmlHttp) {
return new XMLHttpRequest();
} else if (zXml.useActiveX) {
if (!zXml.XMLHTTP_VER) {
for (var i=0; i < zXml.ARR_XMLHTTP_VERS.length; i++) {
try {
new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
zXml.XMLHTTP_VER = zXml.ARR_XMLHTTP_VERS[i];
break;
} catch (oError) {
}
}
}
if (zXml.XMLHTTP_VER) {
return new ActiveXObject(zXml.XMLHTTP_VER);
} else {
throw new Error("Could not create XML HTTP Request.");
}
} else {
throw new Error("Your browser doesn't support an XML HTTP Request.");
}
};
zXmlHttp.isSupported = function ()/*:Boolean*/ {
return zXml.useXmlHttp || zXml.useActiveX;
};
function zXmlDom() {
}
zXmlDom.createDocument = function (){
if (zXml.useDom) {
var oXmlDom = document.implementation.createDocument("","",null);
oXmlDom.parseError = {
valueOf: function () { return this.errorCode; },
toString: function () { return this.errorCode.toString() }
};
oXmlDom.__initError__();
oXmlDom.addEventListener("load", function () {
this.__checkForErrors__();
this.__changeReadyState__(4);
}, false);
return oXmlDom;
} else if (zXml.useActiveX) {
if (!zXml.DOM_VER) {
for (var i=0; i < zXml.ARR_DOM_VERS.length; i++) {
try {
new ActiveXObject(zXml.ARR_DOM_VERS[i]);
zXml.DOM_VER = zXml.ARR_DOM_VERS[i];
break;
} catch (oError) {
}
}
}
if (zXml.DOM_VER) {
return new ActiveXObject(zXml.DOM_VER);
} else {
throw new Error("Could not create XML DOM document.");
}
} else {
throw new Error("Your browser doesn't support an XML DOM document.");
}
};
zXmlDom.isSupported = function ()/*:Boolean*/ {
return zXml.useDom || zXml.useActiveX;
};
var oMozDocument = null;
if (typeof XMLDocument != "undefined") {
oMozDocument = XMLDocument;
} else if (typeof Document != "undefined") {
oMozDocument = Document;
}
if (oMozDocument && !window.opera) {
oMozDocument.prototype.onreadystatechange = null;
oMozDocument.prototype.__changeReadyState__ = function (iReadyState) {
this.readyState = iReadyState;
if (typeof this.onreadystatechange == "function") {
this.onreadystatechange();
}
};
oMozDocument.prototype.__initError__ = function () {
this.parseError.errorCode = 0;
this.parseError.filepos = -1;
this.parseError.line = -1;
this.parseError.linepos = -1;
this.parseError.reason = null;
this.parseError.srcText = null;
this.parseError.url = null;
};
oMozDocument.prototype.__checkForErrors__ = function () {
if (this.documentElement.tagName == "parsererror") {
var reError = />([\s\S]*?)Location:([\s\S]*?)Line Number (\d+), Column (\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;
reError.test(this.xml);
this.parseError.errorCode = -999999;
this.parseError.reason = RegExp.$1;
this.parseError.url = RegExp.$2;
this.parseError.line = parseInt(RegExp.$3);
this.parseError.linepos = parseInt(RegExp.$4);
this.parseError.srcText = RegExp.$5;
}
};
oMozDocument.prototype.loadXML = function (sXml) {
this.__initError__();
this.__changeReadyState__(1);
var oParser = new DOMParser();
var oXmlDom = oParser.parseFromString(sXml, "text/xml");
while (this.firstChild) {
this.removeChild(this.firstChild);
}
for (var i=0; i < oXmlDom.childNodes.length; i++) {
var oNewNode = this.importNode(oXmlDom.childNodes[i], true);
this.appendChild(oNewNode);
}
this.__checkForErrors__();
this.__changeReadyState__(4);
};
oMozDocument.prototype.__load__ = oMozDocument.prototype.load;
oMozDocument.prototype.load = function (sURL) {
this.__initError__();
this.__changeReadyState__(1);
this.__load__(sURL);
};
if( typeof( Node ) !== 'undefined' && Node.prototype.__defineGetter__ ) {
Node.prototype.__defineGetter__("xml", function () {
var oSerializer = new XMLSerializer();
return oSerializer.serializeToString(this, "text/xml");
});
Node.prototype.__defineGetter__("text", function () {
var sText = "";
for (var i = 0; i < this.childNodes.length; i++) {
if (this.childNodes[i].hasChildNodes()) {
sText += this.childNodes[i].text;
} else {
sText += this.childNodes[i].nodeValue;
}
}
return sText;
});
}
}
function zXslt() {
}
zXslt.transformToText = function (oXml, oXslt)/*:String*/ {
if (typeof XSLTProcessor != "undefined") {
var oProcessor = new XSLTProcessor();
oProcessor.importStylesheet(oXslt);
var oResultDom = oProcessor.transformToDocument(oXml);
var sResult = oResultDom.xml;
if (sResult.indexOf("<transformiix:result") > -1) {
sResult = sResult.substring(sResult.indexOf(">") + 1,
sResult.lastIndexOf("<"));
}
return sResult;
} else if (zXml.useActiveX) {
return oXml.transformNode(oXslt);
} else {
throw new Error("No XSLT engine found.");
}
};
function zXPath() {
}
zXPath.selectNodes = function (oRefNode, sXPath, oXmlNs) {
if (typeof XPathEvaluator != "undefined") {
oXmlNs = oXmlNs || {};
var nsResolver = function (sPrefix) {
return oXmlNs[sPrefix];
};
var oEvaluator = new XPathEvaluator();
var oResult = oEvaluator.evaluate(sXPath, oRefNode, nsResolver,
XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null);
var aNodes = new Array;
if (oResult != null) {
var oElement = oResult.iterateNext();
while(oElement) {
aNodes.push(oElement);
oElement = oResult.iterateNext();
}
}
return aNodes;
} else if (zXml.useActiveX) {
if (oXmlNs) {
var sXmlNs = "";
for (var sProp in oXmlNs) {
sXmlNs += "xmlns:" + sProp + "=" + oXmlNs[sProp] + " ";
}
oRefNode.ownerDocument.setProperty("SelectionNamespaces", sXmlNs);
}
return oRefNode.selectNodes(sXPath);
} else {
throw new Error("No XPath engine found.");
}
};
zXPath.selectSingleNode = function (oRefNode, sXPath, oXmlNs) {
if (typeof XPathEvaluator != "undefined") {
oXmlNs = oXmlNs || {};
var nsResolver = function (sPrefix) {
return oXmlNs[sPrefix];
};
var oEvaluator = new XPathEvaluator();
var oResult = oEvaluator.evaluate(sXPath, oRefNode, nsResolver,
XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (oResult != null) {
return oResult.singleNodeValue;
} else {
return null;
}
} else if (zXml.useActiveX) {
if (oXmlNs) {
var sXmlNs = "";
for (var sProp in oXmlNs) {
sXmlNs += "xmlns:" + sProp + "=" + oXmlNs[sProp] + " ";
}
oRefNode.ownerDocument.setProperty("SelectionNamespaces", sXmlNs);
}
return oRefNode.selectSingleNode(sXPath);
} else {
throw new Error("No XPath engine found.")
}
};
function zXMLSerializer() {
}
zXMLSerializer.prototype.serializeToString = function (oNode)/*:String*/ {
var sXml = "";
switch (oNode.nodeType) {
case 1: //element
sXml = "<" + oNode.tagName;
for (var i=0; i < oNode.attributes.length; i++) {
sXml += " " + oNode.attributes[i].name + "=\"" + oNode.attributes[i].value + "\"";
}
sXml += ">";
for (var i=0; i < oNode.childNodes.length; i++){
sXml += this.serializeToString(oNode.childNodes[i]);
}
sXml += "</" + oNode.tagName + ">";
break;
case 3: //text node
sXml = oNode.nodeValue;
break;
case 4: //cdata
sXml = "<![CDATA[" + oNode.nodeValue + "]]>";
break;
case 7: //processing instruction
sXml = "<?" + oNode.nodevalue + "?>";
break;
case 8: //comment
sXml = "<!--" + oNode.nodevalue + "-->";
break;
case 9: //document
for (var i=0; i < oNode.childNodes.length; i++){
sXml += this.serializeToString(oNode.childNodes[i]);
}
break;
}
return sXml;
};
var Url = {
encode : function (string) {
return escape(this._utf8_encode(string));
},
decode : function (string) {
return this._utf8_decode(unescape(string));
},
_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;
},
_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;
}
}
function updateAddress(data) {
adr = data.options[data.selectedIndex].value.split('|');
self.document.accountinfo.adresse1.value = adr[0];
self.document.accountinfo.adresse3.value = adr[2];
self.document.accountinfo.poststed.value = adr[3];
document.getElementById(type+'adresse2').focus();
}
function setMyAddress(data,type) {
adr = data.options[data.selectedIndex].value.split('|');
document.getElementById(type+'street').value = adr[0];
document.getElementById(type+'zip_code').value = adr[2];
document.getElementById(type+'city').value = adr[3];
document.getElementById(type+'street_no').focus();
}
function getValue(node) {
while(node != null) {
if(node.nodeType == 3) {
return node.nodeValue;
}
node = node.firstChild;
}
return null;
}
var validateTimer = null;
function requestValidation(e,type,id) {
var characterCode;
if(window.event) {
e = window.event;
characterCode = e.keyCode;
} else if(e && e.which){
e = e;
characterCode = e.which;
} else if(KeyboardEvent && e instanceof KeyboardEvent) {
characterCode = e.keyCode;
} else {
e = window.event;
characterCode = e.keyCode;
}
switch(characterCode) {
case 8:
case 46:
clearTimeout(window.validateTimer);
return;
case 40:
case 37:
case 39:
case 38:
case 9:
case 16:
case 20:
case 36:
case 35:
return;
}
validateAddress(type,id);
}
function validateAddress(type,id,run) {
if(run == null) {
clearTimeout(window.validateTimer);
window.validateTimer = setTimeout('validateAddress(\''+type+'\',\''+id+'\',true);',500);
return;
}
if(document.getElementById(id).value == '') {
document.getElementById(id).userchanged=false;
} else {
document.getElementById(id).userchanged=true;
}
var validatator = document.getElementById('validator');
var city = document.getElementById(type+'city');
if(true) {
var url = validatator.value + '?type='+type+'&field='+escape(id);
if(document.getElementById(type+'street').userchanged) {
var street = document.getElementById(type+'street');
url = url + '&street=' + Url.encode(street.value);
}
if(document.getElementById(type+'street_no').userchanged) {
var street_no = document.getElementById(type+'street_no');
url = url + '&street_no=' + escape(street_no.value)
}
if(document.getElementById(type+'zip_code').userchanged) {
var zip_code = document.getElementById(type+'zip_code');
url = url + '&zip_code=' + escape(zip_code.value);
}
http = zXmlHttp.createRequest();
http.onreadystatechange=function() {
var antall = 0;
if(http.readyState==4) {
if(http.status==200) {
var street = '';
var street_no = '';
var zip_code = '';
var city = '';
var status = 4;
var type = '';
var field = '';
var nodes = http.responseXML.firstChild;
while(nodes != null) {
if(nodes.nodeType == 1) {
switch(nodes.tagName) {
case 'validation':
nodes = nodes.firstChild;
break;
case 'status':
status = getValue(nodes);
nodes = nodes.nextSibling;
break;
case 'field':
field = getValue(nodes);
nodes = nodes.nextSibling;
break;
case 'type':
type = getValue(nodes);
nodes = nodes.nextSibling;
break;
case 'addresses':
antall++;
select = document.getElementById(type+'select');
select.innerHTML = '';
nodes = nodes.firstChild;
break;
case 'address':
select = document.getElementById(type+'select');
data = nodes.firstChild;
while(data != null) {
if(data.nodeType == 1) {
switch(data.tagName) {
case 'street':
street = getValue(data);
break;
case 'streetno':
street_no = getValue(data);
break;
case 'zipcode':
zip_code = getValue(data);
break;
case 'city':
city = getValue(data);
break;
}
}
data = data.nextSibling;
}
if(nodes.firstChild != null) {
var option = document.createElement('option');
option.value = street+'||'+zip_code+'|'+city;
option.appendChild( document.createTextNode(street+' nr. '+street_no+', '+zip_code+' '+city) );
select.appendChild(option);
}
nodes = nodes.nextSibling;
break;
default:
alert('Tag:\t' + nodes.tagName);
nodes = nodes.nextSibling;
}
} else {
nodes = nodes.nextSibling;
}
}
if(select.innerHTML == '') {
var option = document.createElement('option');
option.value = '|||';
option.appendChild( document.createTextNode( 'Ingen adresser matcher dine kriterier...' ) );
select.appendChild(option);
if(document.getElementById(type+'street').userchanged) {
var option = document.createElement('option');
option.value = '|||';
option.appendChild( document.createTextNode( 'Gate: '+document.getElementById(type+'street').value ) );
select.appendChild(option);
}
if(document.getElementById(type+'street_no').userchanged) {
var option = document.createElement('option');
option.value = '|||';
option.appendChild( document.createTextNode( 'Husnummer: '+document.getElementById(type+'street_no').value ) );
select.appendChild(option);
}
if(document.getElementById(type+'zip_code').userchanged) {
var option = document.createElement('option');
option.value = '|||';
option.appendChild( document.createTextNode( 'Postnummer: '+document.getElementById(type+'zip_code').value ) );
select.appendChild(option);
}
}
if(type != '') {
var vis = false;
if(document.getElementById(type+'street').value != '') vis = true;
if(document.getElementById(type+'street_no').value != '') vis = true;
if(document.getElementById(type+'zip_code').value != '') vis = true;
if(vis) {
var alt = document.getElementById(type+'alt');
alt.className = '';
} else {
var alt = document.getElementById(type+'alt');
alt.className = 'hide';
}
}
}
else {
alert('En feil oppstod ved tilkobling til serveren (HTTP Feilkode: ' + http.status + ')');
}
if(antall == 1 && (status == 2 || status == 1)) {
if(field != '') {
var textbox = document.getElementById(field);
if(textbox != null) {
if(textbox.createTextRange || textbox.setSelectionRange) {
var text = '';
if(field == type+'street') {
text = street;
} else if(field == type+'zip_code') {
text = zip_code;
} else if(field == type+'city') {
text = city;
}
if(text != '') {
var iLen = textbox.value.length;
textbox.value = text;
if (textbox.createTextRange) {
var range = textbox.createTextRange();
range.moveStart("character", iLen);
range.moveEnd("character", text.length - textbox.value.length);
range.select();
} else if (textbox.setSelectionRange) {
textbox.setSelectionRange(iLen, text.length);
}
textbox.focus();
}
}
}
}
if(field != type+'street') {
document.getElementById(type+'street').value = street;
}
if(field != type+'zip_code') {
document.getElementById(type+'zip_code').value = zip_code;
}
if(field != type+'city') {
document.getElementById(type+'city').value = city;
}
var alt = document.getElementById(type+'alt');
alt.className = 'hide';
}
}
}
http.open("get",url,true);
http.send(null);
} else {
var alt = document.getElementById(type+'alt');
alt.className = 'hide';
}
}
function setRequired(type){
var street = document.getElementById(type+'street');
var street_no = document.getElementById(type+'street_no');
var zip_code = document.getElementById(type+'zip_code');
var city = document.getElementById(type+'city');
if(street.value != '' || street_no.value != '' || zip_code.value != '' || city.value != '') {
document.getElementById(type+'table').className = 'req';
} else {
document.getElementById(type+'table').className = '';
}
}
function setAddress(street,no,zip,city,desc) {
document.getElementById('home_street').value = street;
document.getElementById('home_street_no').value = no;
document.getElementById('home_zip_code').value = zip;
document.getElementById('home_city').value = city;
document.getElementById('home_directions').value = desc;
}
function hsRestaurantVelger(type) {
if(type==4) {
document.getElementById('restaurantVelger').className = '';
document.getElementById('gateVelger').className = 'hide';
document.getElementById('postnrVelger').className = 'hide';
document.getElementById('tbl-rutebeskrivelse').className = 'hide';
} else {
document.getElementById('restaurantVelger').className = 'hide';
document.getElementById('gateVelger').className = '';
document.getElementById('postnrVelger').className = '';
document.getElementById('tbl-rutebeskrivelse').className = '';
}
}
function velgRegion(region) {
var e = document.getElementById(region);
if(e.style.display == 'none') {
e.style.display = '';
}
else {
e.style.display = 'none';
}
}
function velgRestaurant(storeCode,element) {
var valgtRestaurant = document.getElementById('valgtRestaurant');
valgtRestaurant.value = element.innerHTML;
var takeawayRestaurant = document.getElementById('takeawayRestaurant');
takeawayRestaurant.value = storeCode;
var regioner = document.getElementById('regioner');
hideDivTree(regioner,false);
}
function hideDivTree(node,hideFirst) {
if(node.nodeType == 1) {
if(node.tagName == 'DIV' && hideFirst) {
node.style.display = 'none';
}
var node = node.firstChild;
while(node != null) {
if(node.nodeType == 1) {
hideDivTree(node,true);
}
node = node.nextSibling;
}
}
}
function setMyAddressOnKeyPress(elm,e,type) {
var characterCode = 0;
if(window.event) {
e = window.event;
characterCode = e.keyCode;
} else if(e && e.which){
e = e;
characterCode = e.which;
} else if(e instanceof KeyboardEvent) {
characterCode = e.keyCode;
}
if((characterCode == 13 || characterCode == 32) && elm.options.length > 0) {
setMyAddress(elm,type);
}
}
function isSpaceOrEnter(e) {
var characterCode = 0;
if(window.event) {
e = window.event;
characterCode = e.keyCode;
} else if(e && e.which){
e = e;
characterCode = e.which;
} else if(e instanceof KeyboardEvent) {
characterCode = e.keyCode;
}
if(characterCode == 13 || characterCode == 32) {
return true;
} else {
return false;
}
}
function setCreditCard(name,nums,id){
var ccno=document.getElementById(id+'creditcard_no');
ccno.value=(ccno.value).substr(0,nums);ccno.maxLength=nums;
var ccname=document.getElementById(id+'ccname');
ccname.innerHTML=name+' kortnummer: ';
var divel=document.getElementById(id+'CreditCardNumber');
divel.className='visible';
return false;
}
function serializeFormVariables(form) {
var data = Array();
var teller = 0;
var navn = '';
for(var i=0;i<form.elements.length;i++) {
if(form.elements[i].tagName == 'INPUT') {
if(form.elements[i].type == 'text' || form.elements[i].type == 'hidden') {
data[teller] = escape(form.elements[i].name)+'='+escape(form.elements[i].value);
teller = teller + 1;
} else if((form.elements[i].type == 'radio' || form.elements[i].type == 'checkbox') && form.elements[i].checked) {
data[teller] = escape(form.elements[i].name)+'='+escape(form.elements[i].value);
teller = teller + 1;
}
} else if(form.elements[i].tagName == 'SELECT') {
var options = form.elements[i].options;
for(var j=0;j<options.length;j++) {
if(options[j].selected) {
navn = form.elements[i].name;
if(form.elements[i].multiple) {
if(navn.substring(-1) == ']') {
data[teller] = escape(navn)+'='+escape(form.elements[i].value);
} else {
data[teller] = escape(navn)+'[]='+escape(form.elements[i].value);
}
teller = teller + 1;
} else {
data[teller] = escape(navn)+'='+escape(form.elements[i].value);
teller = teller + 1;
break;
}
}
}
}
}
return data.join('&');
}
var xajaxRequestUri="/shop/xajax/call";
var xajaxDebug=false;
var xajaxStatusMessages=false;
var xajaxWaitCursor=true;
var xajaxDefinedGet=0;
var xajaxDefinedPost=1;
var xajaxLoaded=false;
function xajax_nxcUpdateBasket(){return xajax.call("nxcUpdateBasket", arguments, 1);}
function xajax_nxcUpdateBasketOnCompensationCardChange(){return xajax.call("nxcUpdateBasketOnCompensationCardChange", arguments, 1);}
function xajax_nxcAddToBasket(){return xajax.call("nxcAddToBasket", arguments, 1);}
function xajax_nxcConfirmDiscountAgreement(){return xajax.call("nxcConfirmDiscountAgreement", arguments, 1);}
function xajax_nxcRemoveBasketItem(){return xajax.call("nxcRemoveBasketItem", arguments, 1);}
function xajax_nxcRemoveIngrItem(){return xajax.call("nxcRemoveIngrItem", arguments, 1);}
function xajax_nxcAddExtraIngr(){return xajax.call("nxcAddExtraIngr", arguments, 1);}
function xajax_nxcUpdateNavimportStatus(){return xajax.call("nxcUpdateNavimportStatus", arguments, 1);}
function xajax_nxcSetAcceptMail(){return xajax.call("nxcSetAcceptMail", arguments, 1);}
function showAlert(title,message) {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
document.getElementById('alertTitle').innerHTML = title;
document.getElementById('alertMessage').innerHTML = message;
document.getElementById('alert').style.display = 'block';
document.getElementById('fixeddiv').style['left'] = ( (myWidth / 2) - 260) +'px';
document.getElementById('alertOkButton').className = '';
document.getElementById('alertJaButton').className = 'hide';
document.getElementById('alertNeiButton').className = 'hide';
}
function showAlertJaNei(title,message,confirm,cancel) {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
document.getElementById('fixeddiv').style['left'] = ( (myWidth / 2) - 260) +'px';
document.getElementById('jaLink').onclick = confirm;
document.getElementById('neiLink').onclick = cancel;
document.getElementById('alertTitle').innerHTML = title;
document.getElementById('alertMessage').innerHTML = message;
document.getElementById('alert').style.display = 'block';
document.getElementById('alertOkButton').className = 'hide';
document.getElementById('alertJaButton').className = '';
document.getElementById('alertNeiButton').className = '';
}
function closeAlert(){
document.getElementById('alert').style.display = 'none';
document.getElementById('alertOkButton').className = '';
}
function valg_ing(obj,side) {
window.mayOrderStatus = true;
var RegExp = /^[0-9]+$/;
var antall = 0;
var maxantall = (document.getElementById(side + '-num')).value;;
var startnode = document.getElementById(side + '-legg-til');
var els = startnode.getElementsByTagName('input');
var elsLen = els.length;
for (i = 0, j = 0; i < elsLen; i++) {
if( els[i].type == 'text' && els[i].value.match(RegExp) ) {
antall = eval(antall + parseInt(els[i].value));
}
}
if(antall > 0) {
window.mayOrderStatus = true;
} else {
window.mayOrderStatus = false;
}
if(antall > maxantall) {
showAlert("Du kan ikke velge flere enn " + maxantall + " ingredienser på denne pizzaen.","");
var newValue = parseInt(parseInt(obj.value) - parseInt(antall - maxantall));
if(newValue == 0) {
obj.value = '';
} else {
obj.value = newValue;
}
selectAllText(obj);
nxcUpdateBasket();
return false;
} else {
nxcUpdateBasket();
return true;
}
}
function DoEvent(event) {
event = event || window.event;
var handlers = this.events[event.type];
for (var i in handlers) {
this.$$handleEvent = handlers[i];
this.$$handleEvent(event);
}
};
function AddEvent(element, type, handler) {
if (!handler.$$guid) handler.$$guid = AddEvent.guid++;
if (!element.events) element.events = {};
var handlers = element.events[type];
if (!handlers) {
handlers = element.events[type] = {};
if (element["on" + type]) {
handlers[0] = element["on" + type];
}
}
handlers[handler.$$guid] = handler;
element["on" + type] = DoEvent;
};
AddEvent.prototype.guid = 1;
function RemoveEvent(element, type, handler) {
if (element.events && element.events[type]) {
delete element.events[type][handler.$$guid];
}
};
var flashDiv = null;
var flashStarted = false;
function hideFlashVideo() {
if(window.flashDiv != null && window.flashStarted == false) {
window.flashDiv.innerHTML = '';
window.flashDiv.style.display = 'none';
RemoveEvent(document.body,'click',this);
}
}
function showFlashVideo(width,height,flv) {
window.flashStarted = true;
setTimeout('window.flashStarted = false;',1000);
var object = '<object' +
' type=application/x-shockwave-flash' +
' wmode=window' +
' width=' + width +
' height=' + height +
' data=/extension/dolly/design/dolly/images/video/player_flv.swf' +
'>\n' +
'<param' +
' name="movie"' +
' value="/extension/dolly/design/dolly/images/video/player_flv.swf"' +
'/>\n' +
'<param' +
' name="wmode"' +
' value="window"' +
'/>\n' +
'<param' +
' name="FlashVars"' +
' value="flv='+flv+'&amp;width='+width+'&amp;height='+height+'&amp;autoplay=1"' +
'/>' +
'</object>';
if(window.flashDiv == null) {
window.flashDiv = document.createElement('div');
window.flashDiv.setAttribute('id','flashdiv');
document.body.appendChild(window.flashDiv);
}
var amountOfHorizontalScroll = 150;
if(window.pageYOffset) {
amountOfHorizontalScroll = window.pageYOffset;
} else if (document.documentElement) {
amountOfHorizontalScroll = document.documentElement.scrollTop;
} else if(document.body.scrollTop) {
amountOfHorizontalScroll = document.body.scrollTop;
}
var clientWidth = 0;
if( typeof( window.innerWidth ) == 'number' ) {
clientWidth = window.innerWidth;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
clientWidth = document.documentElement.clientWidth;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
clientWidth = document.body.clientWidth;
}
window.flashDiv.style.left = ((clientWidth / 2) - (width / 2)) + 'px';
window.flashDiv.style.top = (250 + amountOfHorizontalScroll) + 'px';
window.flashDiv.style.display = 'block';
window.flashDiv.innerHTML = object;
AddEvent(document.body,'click',hideFlashVideo);
}
function OnClickAddAdditionalIngredients(event) {
var target;
if (event.target) target = event.target;
else if (event.srcElement) target = event.srcElement;
if (target.nodeType == 3) {
target = target.parentNode;
}
if(target.value == '' || target.value == '0') {
target.value = 1;
nxcUpdateBasket();
}
if(target.value != '') {
if (target.createTextRange) {
var range = target.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", 1);
range.select();
} else if (target.setSelectionRange) {
target.setSelectionRange(0, 1);
}
target.focus();
}
}
function OnClickAddTradedIngredients(event) {
var target;
if (event.target) target = event.target;
else if (event.srcElement) target = event.srcElement;
if (target.nodeType == 3) {
target = target.parentNode;
}
if(target.value == '' || target.value == '0') {
target.value = 1;
}
if(target.value != '') {
if (target.createTextRange) {
var range = target.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", 1);
range.select();
} else if (target.setSelectionRange) {
target.setSelectionRange(0, 1);
}
target.focus();
}
}
function OnKeyUpAddAdditionalIngredients(event){
var characterCode;
if(window.event) {
event = window.event;
characterCode = event.keyCode;
} else if(event && event.which){
event = event;
characterCode = event.which;
} else if(KeyboardEvent && event instanceof KeyboardEvent) {
characterCode = event.keyCode;
} else {
event = window.event;
characterCode = event.keyCode;
}
if(characterCode != 9 && characterCode != 37 && characterCode != 38 && characterCode != 39 && characterCode != 40) {
nxcUpdateBasket();
}
}
function bekreftSpesialavtale() {
var callOK = xajax_nxcConfirmDiscountAgreement(document.getElementById('passord_spesialavtale').value);
if(!callOK) {
return true;
}
return false;
}
var antallMangler = 0;
function finnAntallValgte(startNodeId,klasseNavn) {
var re = /^[0-9]+$/;
var antall = 0;
var startnode = document.getElementById(startNodeId + '_add_remove');
var els = startnode.getElementsByTagName('input');
var elsLen = els.length;
var className = "";
var classNameRegExp = new RegExp(new String(klasseNavn),"i");
for (i = 0, j = 0; i < elsLen; i++) {
if( els[i].className.match(classNameRegExp) ) {
if(els[i].type == 'checkbox' && els[i].checked ) {
antall++;
if(els[i].disabled == true) antallMangler = 0;
} else if(els[i].type == 'text' && els[i].value.match(re) ) {
antall = eval(antall + parseInt(els[i].value));
}
}
}
if(klasseNavn == 'tabort') antall = antall + antallMangler;
return antall;
}
var confirmTaBortOstId = '';
function confirmTaBortOst() {
var id = window.confirmTaBortOstId;
document.getElementById(id+'tbvare10087').checked = true;
changeStatusById(id+'tbvare10087');
visLeggTil(id);
nxcUpdateBasket();
}
function cancelTaBortOst() {
}
function vedTaBort(id,obj) {
var productno = new String(obj.name);
productno = productno.replace(/^.*\[/,'');
productno = productno.replace(/\]$/,'');
if(productno == 10087 && obj.checked) {
obj.checked = false;
window.confirmTaBortOstId = id;
showAlertJaNei("Ta bort Dolly`s Osteblanding","Er du sikker på at du vil fjerne osten fra pizzaen?",confirmTaBortOst,cancelTaBortOst);
} else {
var antUt  = finnAntallValgte(id,'tabort');
var antInn = finnAntallValgte(id,'leggtil edititem-count');
if(antUt < antInn) {
obj.checked = true;
showAlert('Beklager, du kan ikke velge mer enn du har valgt å ta bort.','');
}
else visLeggTil(id);
obj.blur();
}
}
function visLeggTil(id) {
var startnode = document.getElementById('leggTil' + id);
var antall = finnAntallValgte(id,'tabort');
if(antall == 0) {
startnode.className = "hide";
} else {
startnode.className = "show";
}
}
function vedLeggTil(id,obj) {
var antUt  = finnAntallValgte(id,'tabort');
var antInn = finnAntallValgte(id,'leggtil edititem-count');
if(antUt < antInn) {
var verdi = parseInt(antInn) - parseInt(obj.value);
var nyverdi = parseInt(antUt) - verdi;
if(nyverdi == 0) {
obj.value = '';
} else {
obj.value = nyverdi;
}
showAlert('Beklager, du kan ikke velge mer enn du har valgt å ta bort.','');
obj.blur();
} else {
nxcUpdateBasket();
}
}
function selectAllText(element) {
if (element.createTextRange) {
var range = element.createTextRange();
range.moveStart("character", 0);
range.moveEnd("character", element.value.length);
range.select();
} else if (element.setSelectionRange) {
element.setSelectionRange(0,element.value.length);
}
}
function addDollyWoodPizzaToBasket(itemNodeID,pizza,basketItemIndex) {
if(pizza == null) pizza = false;
var addok=true;
var mangler=manglerIngredienser(itemNodeID);
if (mangler!=false) {
addok=false;
if(pizza) {
addok=confirm("Beklager, vi er tom for "+mangler+" på denne pizzaen.\n\nVelg OK hvis du ønsker pizza.\nVelg Avbryt hvis du ønsker annen pizza.");
} else {
alert("Butikken er tom for "+mangler+", så dette kan ikke bestilles til dette tidspunktet.");
}
}
if (addok) {
var url= '/basket/edititem/' + basketItemIndex + '/selectpizza/both/'+itemNodeID;
var field = document.getElementById('add_item_contentnodeid');
field.parentNode.action = url;
field.name = 'dw_pizzaType';
field.value = itemNodeID;
document.getElementById("add_item_submit").click();
}
}
function erTomFor(varenr) {
if( typeof( varenummer) != 'undefined' ) {
for(var i=0;i < varenummer.length;i++) {
if(varenummer[i] == varenr) {
if(tomfor[i] != null) return tomfor[i].toLowerCase();
else return false;
}
}
}
return false;
}
function manglerIngredienser(node) {
if(ingr[node] != null) {
var mangler = false;
var result = false;
var tekst = ''
for(var i=0;i < ingr[node].length;i++) {
result = erTomFor(ingr[node][i])
if(result != false) {
if(mangler) tekst = tekst +', ' + result;
else tekst = result;
mangler = true;
}
}
if(mangler) {
var lio = tekst.lastIndexOf(', ');
if(lio != -1) {
tekst = tekst.substring(0,lio) + ' og ' + tekst.substring(lio+2,tekst.length);
}
return tekst;
}
else return false;
} else {
return false;
}
}
function addFavorittItemToBasket(itemNodeID,pizza,type) {
if(type == null) type = 1;
if(pizza == null) pizza = false;
var addok=true;
var mangler=manglerIngredienser('fav'+itemNodeID);
if (mangler!=false) {
addok=false;
if(pizza) {
addok=confirm("Beklager, vi er tom for "+mangler+" på denne pizzaen.\n\nVelg OK hvis du ønsker pizza.\nVelg Avbryt hvis du ønsker annen pizza.");
} else {
alert("Butikken er tom for "+mangler+", så dette kan ikke bestilles til dette tidspunktet.");
}
}
if (addok) {
document.getElementById("add_favoritt_item_submit").value = type;
document.getElementById("add_item_contentnodeid").value=itemNodeID;
xajax_nxcAddToBasket(serializeFormVariables(document.forms[0])+'&OrderFavorittButton='+type);
}
}
function addItemToBasket(itemNodeID,pizza,useAJAX) {
if(useAJAX == null) useAJAX = true;
if(pizza == null) pizza = false;
var addok=true;
var mangler=manglerIngredienser(itemNodeID);
if (mangler!=false) {
addok=false;
if(pizza) {
addok=confirm("Beklager, vi er tom for "+mangler+" på denne pizzaen.\n\nVelg OK hvis du ønsker pizza.\nVelg Avbryt hvis du ønsker annen pizza.");
} else {
alert("Butikken er tom for "+mangler+", så dette kan ikke bestilles til dette tidspunktet.");
}
}
if (addok) {
document.getElementById("add_item_contentnodeid").value=itemNodeID;
if(useAJAX) {
xajax_nxcAddToBasket(serializeFormVariables(document.forms[0])+'&OrderButton=inserted');
} else {
document.getElementById("add_item_submit").click();
}
}
}
function hidePizza(size,klasseNavnTil) {
var klasseNavn = "size" + size;
var pc = document.getElementById('pizzaCollection');
if(pc == null) return;
var pizzas = pc.getElementsByTagName('div');
var antall = pizzas.length;
for(var i=0;i < antall;i++) {
if(pizzas[i].className == klasseNavn) pizzas[i].className = klasseNavnTil;
}
}
function buffetid(node) {
var element = document.getElementById('buffetid' + node);
if(element != null) {
if(element.style.display == 'none') {
element.style.display = 'block';
} else {
element.style.display = 'none';
}
}
}

