
MooTools.More = {
'version': '1.3.0.1',
'build': '6dce99bed2792dffcbbbb4ddc15a1fb9a41994b5'
};


Events.Pseudos = function(pseudos, addEvent, removeEvent){
var storeKey = 'monitorEvents:';
var storageOf = function(object){
return {
store: object.store ? function(key, value){
object.store(storeKey + key, value);
} : function(key, value){
(object.$monitorEvents || (object.$monitorEvents = {}))[key] = value;
},
retrieve: object.retrieve ? function(key, dflt){
return object.retrieve(storeKey + key, dflt);
} : function(key, dflt){
if (!object.$monitorEvents) return dflt;
return object.$monitorEvents[key] || dflt;
}
};
};

var splitType = function(type){
if (type.indexOf(':') == -1) return null;
var parsed = Slick.parse(type).expressions[0][0],
parsedPseudos = parsed.pseudos;
return (pseudos && pseudos[parsedPseudos[0].key]) ? {
event: parsed.tag,
value: parsedPseudos[0].value,
pseudo: parsedPseudos[0].key,
original: type
} : null;
};

return {
addEvent: function(type, fn, internal){
var split = splitType(type);
if (!split) return addEvent.call(this, type, fn, internal);
var storage = storageOf(this),
events = storage.retrieve(type, []),
pseudoArgs = Array.from(pseudos[split.pseudo]),
proxy = pseudoArgs[1];
var self = this;
var monitor = function(){
pseudoArgs[0].call(self, split, fn, arguments, proxy);
};
events.include({event: fn, monitor: monitor});
storage.store(type, events);
var eventType = split.event;
if (proxy && proxy[eventType]) eventType = proxy[eventType].base;
addEvent.call(this, type, fn, internal);
return addEvent.call(this, eventType, monitor, internal);
},
removeEvent: function(type, fn){
var split = splitType(type);
if (!split) return removeEvent.call(this, type, fn);
var storage = storageOf(this),
events = storage.retrieve(type),
pseudoArgs = Array.from(pseudos[split.pseudo]),
proxy = pseudoArgs[1];
if (!events) return this;
var eventType = split.event;
if (proxy && proxy[eventType]) eventType = proxy[eventType].base;
removeEvent.call(this, type, fn);
events.each(function(monitor, i){
if (!fn || monitor.event == fn) removeEvent.call(this, eventType, monitor.monitor);
delete events[i];
}, this);
storage.store(type, events);
return this;
}
};
};
(function(){
var pseudos = {
once: function(split, fn, args){
fn.apply(this, args);
this.removeEvent(split.original, fn);
}
};
Events.definePseudo = function(key, fn){
pseudos[key] = fn;
};
var proto = Events.prototype;
Events.implement(Events.Pseudos(pseudos, proto.addEvent, proto.removeEvent));
})();


Class.refactor = function(original, refactors){
Object.each(refactors, function(item, name){
var origin = original.prototype[name];
if (origin && origin.$origin) origin = origin.$origin;
if (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(){
Array.from(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 && this.occluded != null)
return this.occluded = instance;
this.occluded = false;
element.store(property || this.property, this);
return this.occluded;
}
});

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){
while(l--) result += this[l];
}
return result;
},
unique: function(){
return [].combine(this);
},
shuffle: function(){
for (var i = this.length; i && --i;){
var temp = this[i], r = Math.floor(Math.random() * ( i + 1 ));
this[i] = this[r];
this[r] = temp;
}
return this;
},
reduce: function(fn, value){
var undefined;
for (var i = 0, l = this.length; i < l; i++){
if (i in this) value = value === undefined ? this[i] : fn.call(null, value, this[i], i, this);
}
return value;
},
reduceRight: function(fn, value){
var i = this.length, undefined;
while (i--){
if (i in this) value = value === undefined ? this[i] : fn.call(null, value, this[i], i, this);
}
return value;
}
});


(function(){
var defined = function(value){
return value != null;
};
Object.extend({
getFromPath: function(source, key){
var parts = key.split('.');
for (var i = 0, l = parts.length; i < l; i++){
if (source.hasOwnProperty(parts[i])) source = source[parts[i]];
else return null;
}
return source;
},
cleanValues: function(object, method){
method = method || defined;
for (key in object) if (!method(object[key])){
delete object[key];
}
return object;
},
erase: function(object, key){
if (object.hasOwnProperty(key)) delete object[key];
return object;
},
run: function(object){
var args = Array.slice(arguments, 1);
for (key in object) if (object[key].apply){
object[key].apply(object, args);
}
return object;
}
});
})();


(function(){
var special = {
'a': /[àáâãäåăą]/g,
'A': /[ÀÁÂÃÄÅĂĄ]/g,
'c': /[ćčç]/g,
'C': /[ĆČÇ]/g,
'd': /[ďđ]/g,
'D': /[ĎÐ]/g,
'e': /[èéêëěę]/g,
'E': /[ÈÉÊËĚĘ]/g,
'g': /[ğ]/g,
'G': /[Ğ]/g,
'i': /[ìíîï]/g,
'I': /[ÌÍÎÏ]/g,
'l': /[ĺľł]/g,
'L': /[ĹĽŁ]/g,
'n': /[ñňń]/g,
'N': /[ÑŇŃ]/g,
'o': /[òóôõöøő]/g,
'O': /[ÒÓÔÕÖØ]/g,
'r': /[řŕ]/g,
'R': /[ŘŔ]/g,
's': /[ššş]/g,
'S': /[ŠŞŚ]/g,
't': /[ťţ]/g,
'T': /[ŤŢ]/g,
'ue': /[ü]/g,
'UE': /[Ü]/g,
'u': /[ùúûůµ]/g,
'U': /[ÙÚÛŮ]/g,
'y': /[ÿý]/g,
'Y': /[ŸÝ]/g,
'z': /[žźż]/g,
'Z': /[ŽŹŻ]/g,
'th': /[þ]/g,
'TH': /[Þ]/g,
'dh': /[ð]/g,
'DH': /[Ð]/g,
'ss': /[ß]/g,
'oe': /[œ]/g,
'OE': /[Œ]/g,
'ae': /[æ]/g,
'AE': /[Æ]/g
},
tidy = {
' ': /[\xa0\u2002\u2003\u2009]/g,
'*': /[\xb7]/g,
'\'': /[\u2018\u2019]/g,
'"': /[\u201c\u201d]/g,
'...': /[\u2026]/g,
'-': /[\u2013]/g,
'&raquo;': /[\uFFFD]/g
};
var walk = function(string, replacements){
var result = string;
for (key in replacements) result = result.replace(replacements[key], key);
return result;
};
var getRegexForTag = function(tag, contents){
tag = tag || '';
var regstr = contents ? "<" + tag + "(?!\\w)[^>]*>([\\s\\S]*?)<\/" + tag + "(?!\\w)>" : "<\/?" + tag + "([^>]+)?>";
reg = new RegExp(regstr, "gi");
return reg;
};
String.implement({
standardize: function(){
return walk(this, special);
},
repeat: function(times){
return new Array(times + 1).join(this);
},
pad: function(length, str, direction){
if (this.length >= length) return this;
var pad = (str == null ? ' ' : '' + str)
.repeat(length - this.length)
.substr(0, length - this.length);
if (!direction || direction == 'right') return this + pad;
if (direction == '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(getRegexForTag(tag, contents)) || [];
},
stripTags: function(tag, contents){
return this.replace(getRegexForTag(tag, contents), '');
},
tidy: function(){
return walk(this, tidy);
}
});
})();


String.implement({
parseQueryString: function(decodeKeys, decodeValues){
if (decodeKeys == null) decodeKeys = true;
if (decodeValues == null) decodeValues = true;
var vars = this.split(/[&;]/),
object = {};
if (!vars.length) return object;
vars.each(function(val){
var index = val.indexOf('='),
value = val.substr(index + 1),
keys = index < 0 ? [''] : val.substr(0, index).match(/([^\]\[]+|(\B)(?=\]))/g),
obj = object;
if (decodeValues) value = decodeURIComponent(value);
keys.each(function(key, i){
if (decodeKeys) key = decodeURIComponent(key);
var current = obj[key];
if (i < keys.length - 1) obj = obj[key] = current || {};
else if (typeOf(current) == 'array') current.push(value);
else obj[key] = current != null ? [current, value] : value;
});
});
return object;
},
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.call(null, key, value) : (value || value === 0);
}).join('&');
}
});


(function(){
var toString = function(){
return this.get('value');
};
var URI = this.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 = Object.clone(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 && this.schemes[scheme.toLowerCase()] == null) 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 (!(qs || qs === 0)) return key ? null : {};
var obj = qs.parseQueryString();
return key ? obj[key] : obj;
},
setData: function(values, merge, part){
if (typeof values == 'string'){
var data = this.getData();
data[arguments[0]] = arguments[1];
values = data;
} else if (merge){
values = Object.merge(this.getData(), values);
}
return this.set(part || 'query', Object.toQueryString(values));
},
clearData: function(part){
return this.set(part || 'query', '');
},
toString: toString,
valueOf: toString
});
URI.regs = {
endSlash: /\/$/,
scheme: /^(\w+):/,
directoryDot: /\.\/|\.$/
};
URI.base = new URI(Array.from(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 (this.selectionStart != null){
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 duplicate = range.duplicate();
if (this.type == 'text'){
pos.start = 0 - duplicate.moveStart('character', -100000);
pos.end = pos.start + range.text.length;
} else {
var value = this.get('value');
var offset = value.length;
duplicate.moveToElementText(this);
duplicate.setEndPoint('StartToEnd', range);
if (duplicate.text.length) offset -= value.match(/[\n\r]*$/)[0].length;
pos.end = offset - duplicate.text.length;
duplicate.setEndPoint('StartToStart', range);
pos.start = offset - duplicate.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 (select !== false) this.selectRange(pos.start, pos.start + value.length);
else this.setCaretPosition(pos.start + value.length);
return this;
},
insertAroundCursor: function(options, select){
options = Object.append({
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 (select !== false) this.selectRange(selStart, selStart + current.length);
else this.setCaretPosition(selStart + text.length);
}
return this;
}
});


Elements.from = function(text, excludeScripts){
if (excludeScripts || excludeScripts == null) 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 pseudos = {
once: function(split, fn, args){
fn.apply(this, args);
this.removeEvent(split.original, fn);
}
};
Event.definePseudo = function(key, fn, proxy){
pseudos[key] = [fn, proxy];
};
var proto = Element.prototype;
[Element, Window, Document].invoke('implement', Events.Pseudos(pseudos, proto.addEvent, proto.removeEvent));
})();


(function(){
var keysStoreKey = '$moo:keys-pressed',
keysKeyupStoreKey = '$moo:keys-keyup';

Event.definePseudo('keys', function(split, fn, args){
var event = args[0],
keys = [],
pressed = this.retrieve(keysStoreKey, []);
keys.append(split.value.replace('++', function(){
keys.push('+');
return '';
}).split('+'));
pressed.include(event.key);
if (keys.every(function(key){
return pressed.contains(key);
})) fn.apply(this, args);
this.store(keysStoreKey, pressed);
if (!this.retrieve(keysKeyupStoreKey)){
var keyup = function(event){
(function(){
pressed = this.retrieve(keysStoreKey, []).erase(event.key);
this.store(keysStoreKey, pressed);
}).delay(0, this);
};
this.store(keysKeyupStoreKey, keyup).addEvent('keyup', keyup);
}
});
Object.append(Event.Keys, {
'shift': 16,
'control': 17,
'alt': 18,
'capslock': 20,
'pageup': 33,
'pagedown': 34,
'end': 35,
'home': 36,
'numlock': 144,
'scrolllock': 145,
';': 186,
'=': 187,
',': 188,
'-': Browser.firefox ? 109 : 189,
'.': 190,
'/': 191,
'`': 192,
'[': 219,
'\\': 220,
']': 221,
"'": 222,
'+': 107
});
})();


Event.definePseudo('relay', function(split, fn, args, proxy){
var event = args[0];
var check = proxy ? proxy.condition : null;
for (var target = event.target; target && target != this; target = target.parentNode){
var finalTarget = document.id(target);
if (Slick.match(target, split.value) && (!check || check.call(finalTarget, event))){
if (finalTarget) fn.call(finalTarget, event, finalTarget);
return;
}
}
}, {
mouseenter: {
base: 'mouseover',
condition: Element.Events.mouseenter.condition
},
mouseleave: {
base: 'mouseout',
condition: Element.Events.mouseleave.condition
}
});

(function(){
var getStylesList = function(styles, planes){
var list = [];
Object.each(planes, function(directions){
Object.each(directions, function(edge){
styles.each(function(style){
list.push(style + '-' + edge + (style == 'border' ? '-width' : ''));
});
});
});
return list;
};
var calculateEdgeSize = function(edge, styles){
var total = 0;
Object.each(styles, function(value, style){
if (style.test(edge)) total = total + value.toInt();
});
return total;
};

Element.implement({
measure: function(fn){
var visibility = function(el){
return !!(!el || el.offsetHeight || el.offsetWidth);
};
if (visibility(this)) return fn.apply(this);
var parent = this.getParent(),
restorers = [],
toMeasure = [];
while (!visibility(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 function(){};
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 = Object.merge({computeSize: false}, options);
var dim = {x: 0, y: 0};
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 {
dim = getSize(this, options);
}catch(e){}
}
return Object.append(dim, (dim.x || dim.x === 0) ? {
width: dim.x,
height: dim.y
} : {
x: dim.width,
y: dim.height
}
);
},
getComputedSize: function(options){

options = Object.merge({
styles: ['padding','border'],
planes: {
height: ['top','bottom'],
width: ['left','right']
},
mode: 'both'
}, options);
var styles = {},
size = {width: 0, height: 0};
if (options.mode == 'vertical'){
delete size.width;
delete options.planes.width;
} else if (options.mode == 'horizontal'){
delete size.height;
delete options.planes.height;
}

getStylesList(options.styles, options.planes).each(function(style){
styles[style] = this.getStyle(style).toInt();
}, this);
Object.each(options.planes, function(edges, plane){
var capitalized = plane.capitalize();
styles[plane] = this.getStyle(plane).toInt();
size['total' + capitalized] = styles[plane];
edges.each(function(edge){
var edgesize = calculateEdgeSize(edge, styles);
size['computed' + edge.capitalize()] = edgesize;
size['total' + capitalized] += edgesize;
});
}, this);
return Object.append(size, styles);
}
});
})();


(function(){
var original = Element.prototype.position;
Element.implement({
position: function(options){

if (options && (options.x != null || options.y != null)){
return original ? original.apply(this, arguments) : this;
}
Object.each(options || {}, function(v, k){
if (v == null) delete options[k];
});
options = Object.merge({


relativeTo: document.body,
position: {
x: 'center',
y: 'center'
},
offset: {x: 0, y: 0}
}, 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 (typeOf(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 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:
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:
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:
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:
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 && ((minmax == 'minimum') ? pos[lr] < val : 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.style.display != 'none';
},
toggle: function(){
return this[this.isDisplayed() ? 'hide' : 'show']();
},
hide: function(){
var d;
try {

d = this.getStyle('display');
} catch(e){}
if (d == 'none') return this;
return this.store('element:_originalDisplay', d || '').setStyle('display', 'none');
},
show: function(display){
if (!display && this.isDisplayed()) return this;
display = display || this.retrieve('element:_originalDisplay') || 'block';
return this.setStyle('display', (display == 'none') ? 'block' : display);
},
swapClass: function(remove, add){
return this.removeClass(remove).addClass(add);
}
});
Document.implement({
clearSelection: function(){
if (document.selection && document.selection.empty){
document.selection.empty();
} else if (window.getSelection){
var selection = window.getSelection();
if (selection && selection.removeAllRanges) selection.removeAllRanges();
}
}
});


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){
if (!this.elements[i]) continue;
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){
if (!this.elements[i]) continue;
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);
}
});


Fx.Move = new Class({
Extends: Fx.Morph,
options: {
relativeTo: document.body,
position: 'center',
edge: false,
offset: {x: 0, y: 0}
},
start: function(destination){
var element = this.element,
topLeft = element.getStyles('top', 'left');
if (topLeft.top == 'auto' || topLeft.left == 'auto'){
element.setPosition(element.getPosition(element.getOffsetParent()));
}
return this.parent(element.position(Object.merge(this.options, destination, {returnPos: true})));
}
});
Element.Properties.move = {
set: function(options){
this.get('move').cancel().setOptions(options);
return this;
},
get: function(){
var move = this.retrieve('move');
if (!move){
move = new Fx.Move(this, {link: 'cancel'});
this.store('move', move);
}
return move;
}
};
Element.implement({
move: function(options){
this.get('move').start(options);
return this;
}
});


(function(){
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);
if (typeOf(this.element) != 'element') this.element = document.id(this.element.getDocument().body);
if (this.options.wheelStops){
var stopper = this.element,
cancel = this.cancel.pass(false, this);
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.firefox) now = [Math.round(now[0]), Math.round(now[1])];
this.element.scrollTo(now[0] + this.options.offset.x, now[1] + this.options.offset.y);
},
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 element = this.element,
scrollSize = element.getScrollSize(),
scroll = element.getScroll(),
size = element.getSize();
values = {x: x, y: y};
for (var z in values){
if (!values[z] && values[z] !== 0) values[z] = scroll[z];
if (typeOf(values[z]) != 'number') values[z] = scrollSize[z] - size[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),
scroll = isBody(this.element) ? {x: 0, y: 0} : this.element.getScroll();
return this.start(position.x + scroll.x, position.y + scroll.y);
},
scrollIntoView: function(el, axes, offset){
axes = axes ? Array.from(axes) : ['x','y'];
el = document.id(el);
var to = {},
position = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
x: position.x + size.x,
y: position.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 (position[axis] < scroll[axis]) to[axis] = position[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 ? Array.from(axes) : ['x', 'y'];
el = document.id(el);
var to = {},
position = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize();
['x','y'].each(function(axis){
if (axes.contains(axis)){
to[axis] = position[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;
}
});
function isBody(element){
return (/^(?:body|html)$/i).test(element.tagName);
};
})();


Fx.SmoothScroll = new Class({
Extends: Fx.Scroll,
initialize: function(options, context){
context = context || document;
this.doc = context.getDocument();
this.parent(this.doc, options);
var win = context.getWindow(),
location = win.location.href.match(/^[^#]*/)[0] + '#',
links = $$(this.options.links || this.doc.links);
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);
},
useLink: function(link, anchor){
link.addEvent('click', function(event){
var el = document.id(anchor) || this.doc.getElement('a[name=' + anchor + ']');
if (!el) return;
event.preventDefault();
this.toElement(el).chain(function(){
this.fireEvent('scrolledTo', [link, el]);
}.bind(this));
}.bind(this));
return this;
}
});


var Drag = new Class({
Implements: [Events, Options],
options: {
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': Type.isObject,
'element': function(obj){
return obj != null;
}
});
this.element = document.id(params.element);
this.document = this.element.getDocument();
this.setOptions(params.options || {});
var htype = typeOf(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.ie) ? 'selectstart' : 'mousedown';

if (Browser.ie && !Drag.ondragstartFixed){
document.ondragstart = Function.from(false);
Drag.ondragstartFixed = true;
}
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: Function.from(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){
var options = this.options;
if (event.rightClick) return;
if (options.preventDefault) event.preventDefault();
if (options.stopPropagation) event.stopPropagation();
this.mouse.start = event.page;
this.fireEvent('beforeStart', this.element);
var limit = options.limit;
this.limit = {x: [], y: []};
var styles = this.element.getStyles('left', 'right', 'top', 'bottom');
this._invert = {
x: options.modifiers.x == 'left' && styles.left == 'auto' && !isNaN(styles.right.toInt()) && (options.modifiers.x = 'right'),
y: options.modifiers.y == 'top' && styles.top == 'auto' && !isNaN(styles.bottom.toInt()) && (options.modifiers.y = 'bottom')
};
var z, coordinates;
for (z in options.modifiers){
if (!options.modifiers[z]) continue;
var style = this.element.getStyle(options.modifiers[z]);

if (style && !style.match(/px$/)){
if (!coordinates) coordinates = this.element.getCoordinates(this.element.getOffsetParent());
style = coordinates[options.modifiers[z]];
}
if (options.style) this.value.now[z] = (style || 0).toInt();
else this.value.now[z] = this.element[options.modifiers[z]];
if (options.invert) this.value.now[z] *= -1;
if (this._invert[z]) this.value.now[z] *= -1;
this.mouse.pos[z] = event.page[z] - this.value.now[z];
if (limit && limit[z]){
var i = 2;
while (i--){
var limitZI = limit[z][i];
if (limitZI || limitZI === 0) this.limit[z][i] = (typeof limitZI == 'function') ? limitZI() : limitZI;
}
}
}
if (typeOf(this.options.grid) == 'number') this.options.grid = {
x: this.options.grid,
y: this.options.grid
};
var events = {
mousemove: this.bound.check,
mouseup: this.bound.cancel
};
events[this.selection] = this.bound.eventStop;
this.document.addEvents(events);
},
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){
var options = this.options;
if (options.preventDefault) event.preventDefault();
this.mouse.now = event.page;
for (var z in options.modifiers){
if (!options.modifiers[z]) continue;
this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
if (options.invert) this.value.now[z] *= -1;
if (this._invert[z]) this.value.now[z] *= -1;
if (options.limit && this.limit[z]){
if ((this.limit[z][1] || this.limit[z][1] === 0) && (this.value.now[z] > this.limit[z][1])){
this.value.now[z] = this.limit[z][1];
} else if ((this.limit[z][0] || this.limit[z][0] === 0) && (this.value.now[z] < this.limit[z][0])){
this.value.now[z] = this.limit[z][0];
}
}
if (options.grid[z]) this.value.now[z] -= ((this.value.now[z] - (this.limit[z][0]||0)) % options.grid[z]);
if (options.style) this.element.setStyle(options.modifiers[z], this.value.now[z] + options.unit);
else this.element[options.modifiers[z]] = this.value.now[z];
}
this.fireEvent('drag', [this.element, event]);
},
cancel: function(event){
this.document.removeEvents({
mousemove: this.bound.check,
mouseup: this.bound.cancel
});
if (event){
this.document.removeEvent(this.selection, this.bound.eventStop);
this.fireEvent('cancel', this.element);
}
},
stop: function(event){
var events = {
mousemove: this.bound.drag,
mouseup: this.bound.stop
};
events[this.selection] = this.bound.eventStop;
this.document.removeEvents(events);
if (event) this.fireEvent('complete', [this.element, event]);
}
});
Element.implement({
makeResizable: function(options){
var drag = new Drag(this, Object.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: {
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 && typeOf(this.container) != 'element')
this.container = document.id(this.container.getDocument().body);
if (this.options.style){
if (this.options.modifiers.x == "left" && this.options.modifiers.y == "top"){
var parentStyles,
parent = element.getOffsetParent();
var styles = element.getStyles('left', 'top');
if (parent && (styles.left == 'auto' || styles.top == 'auto')){
element.setPosition(element.getPosition(parent));
}
}
if (element.getStyle('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 element = this.element,
container = this.container,
offsetParent = document.id(element.getOffsetParent()) || document.body,
containerCoordinates = container.getCoordinates(offsetParent),
elementMargin = {},
elementBorder = {},
containerMargin = {},
containerBorder = {},
offsetParentPadding = {};
['top', 'right', 'bottom', 'left'].each(function(pad){
elementMargin[pad] = element.getStyle('margin-' + pad).toInt();
elementBorder[pad] = element.getStyle('border-' + pad).toInt();
containerMargin[pad] = container.getStyle('margin-' + pad).toInt();
containerBorder[pad] = container.getStyle('border-' + pad).toInt();
offsetParentPadding[pad] = offsetParent.getStyle('padding-' + pad).toInt();
}, this);
var width = element.offsetWidth + elementMargin.left + elementMargin.right,
height = 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 (element.getStyle('position') == 'relative'){
var coords = element.getCoordinates(offsetParent);
coords.left -= element.getStyle('left').toInt();
coords.top -= element.getStyle('top').toInt();
left -= coords.left;
top -= coords.top;
if (container.getStyle('position') != 'relative'){
left += containerBorder.left;
top += containerBorder.top;
}
right += elementMargin.left - coords.left;
bottom += elementMargin.top - coords.top;
if (container != offsetParent){
left += containerMargin.left + offsetParentPadding.left;
top += ((Browser.ie6 || Browser.ie7) ? 0 : containerMargin.top) + offsetParentPadding.top;
}
} else {
left -= elementMargin.left;
top -= elementMargin.top;
if (container != offsetParent){
left += containerCoordinates.left + containerBorder.left;
top += containerCoordinates.top + containerBorder.top;
}
}
return {
x: [left, right],
y: [top, bottom]
};
},
checkDroppables: function(){
var overed = this.droppables.filter(function(el, i){
if(el.getStyle('position') == 'fixed')
var fixed = true;

el = this.positions ? this.positions[i] : el.getCoordinates();
var now = this.mouse.now;

if(fixed){
var scrollY = window.top.getScroll().y;
el.top = el.top + scrollY;
el.bottom = el.bottom + scrollY;
}
return (now.x > el.left && now.x < el.right && now.y < el.bottom && now.y > el.top);
}, 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: 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.setRange(this.options.range);
this.knob.setStyle('position', 'relative').setStyle(this.property, - 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();
if (this.options.initialStep != null) this.set(this.options.initialStep)
},
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;
},
setRange: function(range, pos){
this.min = Array.pick([range[0], 0]);
this.max = Array.pick([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.set(Array.pick([pos, this.step]).floor(this.min).max(this.max));
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;
}
});


Request.JSONP = new Class({
Implements: [Chain, Events, Options],
options: {

onRequest: function(src){
if (this.options.log && window.console && console.log){
console.log('JSONP retrieving script with url:' + src);
}
},
onError: function(src){
if (this.options.log && window.console && console.warn){
console.warn('JSONP '+ src +' will fail in Internet Explorer, which enforces a 2083 bytes length limit on URIs');
}
},
url: '',
callbackKey: 'callback',
injectScript: document.head,
data: '',
link: 'ignore',
timeout: 0,
log: false
},
initialize: function(options){
this.setOptions(options);
},
send: function(options){
if (!Request.prototype.check.call(this, options)) return this;
this.running = true;
var type = typeOf(options);
if (type == 'string' || type == 'element') options = {data: options};
options = Object.merge(this.options, options || {});
var data = options.data;
switch (typeOf(data)){
case 'element': data = document.id(data).toQueryString(); break;
case 'object': case 'hash': data = Object.toQueryString(data);
}
var index = this.index = Request.JSONP.counter++;
var src = options.url +
(options.url.test('\\?') ? '&' :'?') +
(options.callbackKey) +
'=Request.JSONP.request_map.request_'+ index +
(data ? '&' + data : '');
if (src.length > 2083) this.fireEvent('error', src);
var script = this.getScript(src).inject(options.injectScript);
this.fireEvent('request', [script.get('src'), script]);
Request.JSONP.request_map['request_' + index] = function(){
this.success(arguments, index);
}.bind(this);
if (options.timeout){
(function(){
if (this.running) this.fireEvent('timeout', [script.get('src'), script]).fireEvent('failure').cancel();
}).delay(options.timeout, this);
}
return this;
},
getScript: function(src){
return this.script = new Element('script', {
type: 'text/javascript',
src: src
});
},
success: function(args, index){
if (!this.running) return false;
this.clear()
.fireEvent('complete', args).fireEvent('success', args)
.callChain();
},
cancel: function(){
return this.running ? this.clear().fireEvent('cancel') : this;
},
isRunning: function(){
return !!this.running;
},
clear: function(){
if (this.script) this.script.destroy();
this.running = false;
return this;
}
});
Request.JSONP.counter = 0;
Request.JSONP.request_map = {};


var Asset = {
javascript: function(source, properties){
properties = Object.append({
document: document
}, properties);
if (properties.onLoad){
properties.onload = properties.onLoad;
delete properties.onLoad;
}
var script = new Element('script', {src: source, type: 'text/javascript'});
var load = properties.onload || function(){},
doc = properties.document;
delete properties.onload;
delete properties.document;
return script.addEvents({
load: load,
readystatechange: function(){
if (['loaded', 'complete'].contains(this.readyState)) load.call(this);
}
}).set(properties).inject(doc.head);
},
css: function(source, properties){
properties = properties || {};
var onload = properties.onload || properties.onLoad;
if (onload){
properties.events = properties.events || {};
properties.events.load = onload;
delete properties.onload;
delete properties.onLoad;
}
return new Element('link', Object.merge({
rel: 'stylesheet',
media: 'screen',
type: 'text/css',
href: source
}, properties)).inject(document.head);
},
image: function(source, properties){
properties = Object.merge({
onload: function(){},
onabort: function(){},
onerror: function(){}
}, properties);
var image = new Image();
var element = document.id(image) || new Element('img');
['load', 'abort', 'error'].each(function(name){
var type = 'on' + name;
var cap = name.capitalize();
if (properties['on' + cap]){
properties[type] = properties['on' + cap];
delete properties['on' + cap];
}
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 = Object.merge({
onComplete: function(){},
onProgress: function(){},
onError: function(){},
properties: {}
}, options);
sources = Array.from(sources);
var counter = 0;
return new Elements(sources.map(function(source, index){
return Asset.image(source, Object.append(options.properties, {
onload: function(){
counter++;
options.onProgress.call(this, counter, index, source);
if (counter == sources.length) options.onComplete();
},
onerror: function(){
counter++;
options.onError.call(this, counter, index, source);
if (counter == sources.length) options.onComplete();
}
}));
}));
}
};


(function(){
var Color = this.Color = new Type('Color', 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 Object.append(color, this);
});
Color.implement({
mix: function(){
var colors = Array.slice(arguments);
var alpha = (typeOf(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;
}
});
})();


(function(){
if (this.Hash) return;
var Hash = this.Hash = new Type('Hash', function(object){
if (typeOf(object) == 'hash') object = Object.clone(object.getClean());
for (var key in object) this[key] = object[key];
return this;
});
this.$H = function(object){
return new Hash(object);
};
Hash.implement({
forEach: function(fn, bind){
Object.forEach(this, fn, bind);
},
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('each', 'forEach');
Hash.implement({
has: Object.prototype.hasOwnProperty,
keyOf: function(value){
return Object.keyOf(this, value);
},
hasValue: function(value){
return Object.contains(this, value);
},
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){
return new Hash(Object.map(this, fn, bind));
},
filter: function(fn, bind){
return new Hash(Object.filter(this, fn, bind));
},
every: function(fn, bind){
return Object.every(this, fn, bind);
},
some: function(fn, bind){
return Object.some(this, fn, bind);
},
getKeys: function(){
return Object.keys(this);
},
getValues: function(){
return Object.values(this);
},
toQueryString: function(base){
return Object.toQueryString(this, base);
}
});
Hash.alias({indexOf: 'keyOf', contains: 'hasValue'});

})();


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;
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;
});
});


(function(){
var current = null,
locales = {},
inherits = {};
var getSet = function(set){
if (instanceOf(set, Locale.Set)) return set;
else return locales[set];
};
var Locale = this.Locale = {
define: function(locale, set, key, value){
var name;
if (instanceOf(locale, Locale.Set)){
name = locale.name;
if (name) locales[name] = locale;
} else {
name = locale;
if (!locales[name]) locales[name] = new Locale.Set(name);
locale = locales[name];
}
if (set) locale.define(set, key, value);

if (!current) current = locale;
return locale;
},
use: function(locale){
locale = getSet(locale);
if (locale){
current = locale;
this.fireEvent('change', locale);

}
return this;
},
getCurrent: function(){
return current;
},
get: function(key, args){
return (current) ? current.get(key, args) : '';
},
inherit: function(locale, inherits, set){
locale = getSet(locale);
if (locale) locale.inherit(inherits, set);
return this;
},
list: function(){
return Object.keys(locales);
}
};
Object.append(Locale, new Events);
Locale.Set = new Class({
sets: {},
inherits: {
locales: [],
sets: {}
},
initialize: function(name){
this.name = name || '';
},
define: function(set, key, value){
var defineData = this.sets[set];
if (!defineData) defineData = {};
if (key){
if (typeOf(key) == 'object') defineData = Object.merge(defineData, key);
else defineData[key] = value;
}
this.sets[set] = defineData;
return this;
},
get: function(key, args, _base){
var value = Object.getFromPath(this.sets, key);
if (value != null){
var type = typeOf(value);
if (type == 'function') value = value.apply(null, Array.from(args));
else if (type == 'object') value = Object.clone(value);
return value;
}

var index = key.indexOf('.'),
set = index < 0 ? key : key.substr(0, index),
names = (this.inherits.sets[set] || []).combine(this.inherits.locales).include('en-US');
if (!_base) _base = [];
for (var i = 0, l = names.length; i < l; i++){
if (_base.contains(names[i])) continue;
_base.include(names[i]);
var locale = locales[names[i]];
if (!locale) continue;
value = locale.get(key, args, _base);
if (value != null) return value;
}
return '';
},
inherit: function(names, set){
names = Array.from(names);
if (set && !this.inherits.sets[set]) this.inherits.sets[set] = [];
var l = names.length;
while (l--) (set ? this.inherits.sets[set] : this.inherits.locales).unshift(names[l]);
return this;
}
});

})();
flowConf = {
options: {
plugins:{
controls:{
url: '/shared/widget/flow/flow.controls.320.swf',

progressColor: '#DAA808', 
bufferColor: '#ffffff',
backgroundColor: '#333333',
backgroundGradient: 'none',
height: 30,
sliderGradient: '#ffffff',
width: '96%',
bottom: 5,
left: '50%',
borderRadius: 7,
fullscreen: false,
opacity: .6,
background: '#000000',
autoHide: true,
buttonOverColor: '#333333',
buttonColor: '#DAA808',
tooltipTextColor: '#DAA808'
}
},
clip: {
scaling: 'fit',
accelerated: true
}
},
player: {
allowfullscreen: 'false',
cachebusting: true,
background: '#ffffff',
wmode: 'transparent',
src: '/shared/widget/flow/flow.321.swf'

}
};
flaudioConf = Object.merge({}, flowConf, {
options: {
plugins:{
controls:{ 
autoHide: 'never'
},
audio: { 
url: '/shared/widget/flow/flow.audio.320.swf'
} 
}
}
});
var proportions = {
scale: function(dimensions, size, axis){
var h = dimensions.height,
w = dimensions.width,
ratio = h / w;
if(axis == 'h' && dimensions.height > size){
var height = size;
var width = size / ratio;
} else if(dimensions.width > size){
var width = size;
var height = size * ratio;
}
return width && height ? {
width: Math.round(width, 0),
height: Math.round(height, 0)
} : dimensions;
},
constrain: function(dimensions, width, height){
var result;
if(width && height){
result = this.scale(dimensions, width, 'w');
if(result.height > height)
result = this.scale(dimensions, height, 'h');
}
else if(width)
result = this.scale(dimensions, width, 'w');
else if(height)
result = this.scale(dimensions, height, 'h');
return result;
},
crop: function(dimensions, width, height){
var result = this.constrain(dimensions, width);
if(result.height < height)
result = this.constrain(dimensions, false, height);
return result;
}
}
var hoverLabel = function(el, options){
options = Object.merge({
offset: {
x: 5,
y: 1
}
}, options);
var el = document.id(el),
label = $$('[for=' + el.id + ']')[0];
label.position({
relativeTo: el,
edge: 'topLeft',
position: 'topLeft',
offset: options.offset
}).addEvent('mousedown', function(){
this.close();
});
el.addEvents({
mousedown: function(){
this.focus();
},
focus: function(){
label.close();
},
blur: function(){
if(this.value == '')
label.open();
else
label.close();
}
});
if(el.value == '')
label.open();
}
var chkBox = function(el){
var el = $(el);
if(el.get('tag') == 'input'){
var input = el,
label = $$('[for=' + el.id + ']')[0];
} else if(el.get('tag') == 'label'){
var input = $(el.get('for')),
label = el;
}
label.addClass('chk-box');
input.hide();
label.addEvent('click', function(){
if(input.checked){
input.removeProperty('checked');
label.swapClass('chk-box-on', 'chk-box-off');
} else {
input.setProperty('checked', true);
label.swapClass('chk-box-off', 'chk-box-on');
}
});
if(input.checked)
label.swapClass('chk-box-off', 'chk-box-on');
else
label.swapClass('chk-box-on', 'chk-box-off');
}
var rdoBox = function(els){
var els = $$(els);
els.each(function(el){
if(el.get('tag') == 'input'){
var input = el,
label = $$('[for=' + el.id + ']').length == 1 ? $$('[for=' + el.id + ']')[0] : el.getParent('label');
} else if(el.get('tag') == 'label'){
var label = el,
input = $(el.get('for')) ? $(el.get('for')) : el.getElement('input');
}
el.store('label', label);
el.store('input', input);

label.addClass('rdo-box');
input.hide();
label.addEvent('click', function(){
els.each(function(el2){
el2.retrieve('input').removeProperty('checked');
el2.retrieve('label').swapClass('rdo-box-on', 'rdo-box-off');
});
input.setProperty('checked', true);
label.swapClass('rdo-box-off', 'rdo-box-on');
});
if(input.checked)
label.swapClass('rdo-box-off', 'rdo-box-on');
else
label.swapClass('rdo-box-on', 'rdo-box-off');
});
}
Element.Events.clickout = {
base: 'click',
condition: function(event){
event.stopPropagation();
return false;
},
onAdd: function(fn){
this.getDocument().addEvent('click', fn);
},
onRemove: function(fn){
this.getDocument().removeEvent('click', fn);
}
};
Array.implement({
eachPeriodical: function(fn, bind, periodical, endFn){
if(this.length == 0)
return;
var i = 0, fnp = (function(){
fn.call(bind, this[i], i, this);
i++;
if(i == this.length){
if(endFn)
endFn.call();
clearTimeout(fnp);
}
}).periodical(periodical, this);
},
closest: function(number) {
var closest = -1;
var prev = Math.abs(this[0] - number);
for (var i = 1; i < this.length; i++) {
var diff = Math.abs(this[i] - number);
if (diff <= prev) {
prev = diff;
closest = this[i];
}
}
return closest;
},
intersect: function(){
var thisArray = this,
flatten;
Array.from(arguments).each(function(arg){
flatten = [];
var otherArray = Array.from(arg);
for(var i = 0; i < thisArray.length; i++){
for(var j = 0; j < otherArray.length; j++){
if(thisArray[i] === otherArray[j])
flatten.push(thisArray[i]);
}
}
thisArray = flatten;
});
return flatten.unique();
},
diff: function(){
var thisArray = this,
flatten;
Array.from(arguments).each(function(arg){
flatten = [];
var otherArray = Array.from(arg),
diff = true;
for(var i = 0; i < thisArray.length; i++){
for(var j = 0; j < otherArray.length; j++){
if(thisArray[i] === otherArray[j]){
diff = false;
break;
}
}
diff ? flatten.push(thisArray[i]) : diff = true;
}
thisArray = flatten;
});
return flatten.unique();
}
});
Units = {
unitLabels: function(){
if(!Units._unitLabels)
Units._unitLabels = {
fileSize: [
{
min: 1,
unit: Locale.get('Units.filesize.b')
}, {
min: 1024,
unit: Locale.get('Units.filesize.kb')},
{
min: 1048576,
unit: Locale.get('Units.filesize.mb')
}, {
min: 1073741824,
unit: Locale.get('Units.filesize.gb')
}
],
time: [
{
min: 1,
unit: Locale.get('Units.time.s')
}, {
min: 60,
unit: Locale.get('Units.time.m')
}, {
min: 3600,
unit: Locale.get('Units.time.h')
}, {
min: 86400,
unit: Locale.get('Units.time.d')
}
]
}
return Units._unitLabels;
},
formatUnit: function(base, type, join){
var labels = Units.unitLabels()[(type == 'bps' || type == 'b') ? 'fileSize' : type];
var append = (type == 'bps') ? '/s' : '';
var i, l = labels.length, value;
if(base < 1)
return '0 ' + labels[0].unit + append;
if(type == 's'){
var units = [];
for (i = l - 1; i >= 0; i--) {
value = Math.floor(base / labels[i].min);
if (value) {
units.push(value + labels[i].unit);
base -= value * labels[i].min;
if (!base) break;
}
}
return (join === false) ? units : units.join(join || ', ');
}
for(i = l - 1; i >= 0; i--) {
value = labels[i].min;
if (base >= value) break;
}
return (base / value).toFixed(1) + ' ' + labels[i].unit + append;
}
}
var spe = {
'2': '²',
'-at-': '@',
'-': [' ','%20',':','\'','"','«','»',',','--','/','’','°','\?','!','[',']','(',')']
};
String.implement({
ucfirst: function(){
return this.substring(0,1).toUpperCase() + this.substring(1);
},
stripTags2: function(tags){
var str = this;
tags = $splat(tags);
tags.each(function(tag){
if(tag == 'script' || tag == 'style' || tag == 'textarea')
str = str.stripTags(tag, true);
});
tags.each(function(tag){
if(tag != 'script' && tag != 'style')
str = str.stripTags(tag);
});
return str;
},
each: function(fn, bind){
for(var i = 0, l = this.length; i < l; i++)
fn.call(bind, this[i], i);
},
URLify: function(){
var text = this.standardize();
text = text.replace(/\s/g, '-').replace(/€/g, 'e');
Object.each(spe, function(chs, key){
chs = typeOf(chs) == 'string' ? chs.split('') : chs;
chs.each(function(ch){
text = text.replace(new RegExp(ch.escapeRegExp(), 'g'), key);
});
});
return text.replace(/--/g, '-').replace(/-$/g, '').replace(/-$/g, '').toLowerCase();
},
parseInt: function(){
return parseInt(this.replace(/([a-z|_|\-])/gi, ''));
},
linkify: function(){
var RE = /((https?|ftp):((\/\/)|(\\\\))*[\w\d:#@%\/;$()~_?\+-=\\\.&]*)/g;
var str = this;
if(str.test(RE))
this.match(RE).each(function(match){
str = str.replace(match, '<a href="' + match + '">' + new URI(match).get('host') + '</a>')
}, this);
return str;
},
merge: function(object, regexp){
var str = this.replace(/%7B/g, '{').replace(/%7D/g, '}');
return str.replace(regexp || /\\?\{([^{}]+)\}/g, function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
substitution = eval('object.' + name);
if(typeOf(substitution) == 'function')
return substitution();
if(typeOf(substitution) == 'element'){
var tmp = new Element('div').adopt(substitution);
var result = tmp.get('html');
tmp.destroy();
return result;
}
return substitution;
});
}
});
var $defined = function(obj){
    return (obj != undefined);
};
var $chk = function(obj){
    return !!(obj || obj === 0);
};
Element.implement({
unselectable: function(){
$(this).addEvents({
mousedown: function(e){
if(['input', 'textarea'].contains($(e.target).get('tag'))){
this.selectable();
} else {
if(typeof $(this).onselectstart != 'undefined')
$(this).addEvent('selectstart', function(){ return false; });
else
this.setStyle(Browser.prefix + 'user-select', 'none');
}


}
});
},
selectable: function(){
if(typeof $(this).onselectstart != 'undefined')
$(this).addEvent('selectstart', '');
else
this.setStyle(Browser.prefix + 'user-select', 'text');
},
scale: function(size, axis){
if(this.get('tag') == 'img')
var dims = {
width: this.width,
height: this.height
};
else
var dims = this.getDimensions({
styles: ['height', 'width']
});
var ndims = proportions.scale(dims, size, axis);
return this.setStyles({
width: Math.round(ndims.width, 0),
height: Math.round(ndims.height, 0)
});
},
constrain: function(width, height){
if(this.get('tag') == 'img')
var dims = {
width: this.width,
height: this.height
};
else
var dims = this.getDimensions({
styles: ['height', 'width']
});
var ndims = proportions.constrain(dims, width, height);
if(dims.width >= ndims.width || dims.height >= ndims.height)
this.setStyles({
width: ndims.width,
height: ndims.height
});
return this;
},
crop: function(width, height){
if(this.get('tag') == 'img')
var dims = {
width: this.width,
height: this.height
};
else
var dims = this.getDimensions({
styles: ['height', 'width']
});
var ndims = proportions.crop(dims, width, height);
return this.setStyles({
width: ndims.width,
height: ndims.height
});
},
merge: function(object){
Object.each(this.attributes, function(attribute){
this.set(attribute.name, attribute.nodeValue.merge(object));
}, this);
return this.set('html', this.get('html').merge(object));
},
cloneWithEvents: function(){
var clone = this.clone();
clone.cloneEvents(this);
this.getChildren().each(function(child, i) {
clone.getChildren()[i].cloneEvents(child);
});
return clone;
},
open: function(opacity){
var opacity = opacity || 1;
if(this.getOpacity() == opacity && this.isDisplayed())
return this;
if(Browser.ies){
this.setStyles({
display: this.retrieve('original-display') || 'block',
opacity: 1
});
this.fireEvent('open');
} else {
this.setStyles({
display: this.retrieve('original-display') || 'block',
opacity: this.getOpacity()
});
var onOpen = function(){
this.fireEvent('open');
this.retrieve('tween').removeEvent('complete', onOpen);
this.setStyles({
display: this.retrieve('original-display') || 'block'
});
};
onOpen = onOpen.bind(this);
this.set('tween', {
link: 'cancel',
duration: 300,
onComplete: onOpen
});
this.fade(opacity);
}
return this;
},
close: function(opacity){
var opacity = opacity || 0;
if(this.getOpacity() == opacity)
return this;
this.store('original-display', this.getStyle('display') == 'none' ? 'block' : this.getStyle('display') || '');
if(Browser.ies){
this.setStyle('display', 'none');
this.fireEvent('close');
} else {
var onClose = function(){
this.setStyle('display', 'none');
this.fireEvent('close');
this.retrieve('tween').removeEvent('complete', onClose);
};
onClose = onClose.bind(this);
this.set('tween', {
link: 'cancel',
duration: 200,
onComplete: onClose
});
this.fade(opacity);
}
return this;
},
toggle: function() {
return this[this.isDisplayed() ? 'close' : 'open']();
},
disintegrate: function(opacity){
if(Browser.ie){
this.destroy();
} else {
var fx = new Fx.Tween(this, {
duration: 500,
onComplete: this.destroy.bind(this)
});
if(opacity) fx.start('opacity', opacity, 0);
else fx.start('opacity', 0);
}
},
popup: function(parent, options){
var options = Object.merge({
position: {
relativeTo: $(parent),
edge: 'upperLeft',
position: 'bottomLeft',
offset: (options && options.offset ? options.offset : {x: 0, y: 0})
}
}, options);
var self = this;
var fn = function(e){
var el = e.target;
while (el != document.body && el.nodeType == 1){
if (el == self || el == $(parent))return;
else el = el.parentNode;
}
document.removeEvent('mousedown', fn);
self.close();
};
if(this.getStyle('display') == 'none'){
this.open();
if($(parent))
this.position(options.position);
}
document.addEvent('mousedown', fn);
return this;
},
path: function(selector){
return this.getParents(selector).reverse();
},
bubble: function(selector){
if(this.get('tag') == 'html') return false;

return $$(selector).contains(this) ? this : this.getParent() ? this.getParent().bubble($$(selector)) : false;
},
appendHTML: function(HTML){
this.innerHTML = this.innerHTML + HTML;
return this;
},
injectTop: function(parent){
return this.inject(parent, 'top');
},
injectBefore: function(parent){
return this.inject(parent, 'before');
},
injectAfter: function(parent){
return this.inject(parent, 'after');
},
getValues: function(){
return $(this).toQueryString().parseQueryString();
}
});
Window.implement({
loadGMap: function(GKey, callback){
if(window.google != undefined && window.google.maps != undefined){
callback();
} else {
Asset.javascript('http://www.google.com/jsapi?key=' + GKey, {
onload: function(){
google.load('maps', '2', {
other_params: 'sensor=false',
callback: function(){
new Asset.javascript('/shared/js/EWindow.js', {
onload: function(){
window.G = google.maps;
callback();
}
});
}
});
}
});
}
}
});
window.addEvents({
domready: function(){
$(document.html)
.addClass(Browser.Platform.name)
.addClass(Browser.name)
.addClass(Browser.name + Browser.version);
if(Browser.safari || Browser.chrome)
$(document.html).addClass('webkit');
},
load: function(){
$(document.body).addEvent('focus:relay(a, button)', function(){
this.blur();
});
}
});
if(window.Drag && window.Drag.Move)
Drag.Move.implement({
stop: function(event){
this.checkDroppables();
if(this.overed && this.overed != null)
this.fireEvent('drop', [this.element, this.overed, event]);
else
this.fireEvent('emptydrop', [this.element, event]);
this.overed = null;
return this.parent(event);
}
});
if(window.URI)
URI.implement({
up: function(levels){
if(!levels)
var levels = 1;
var path = this.get('directory').split('/').clean().filter(function(el){
return el != ''
});
for(var i = 0; i < levels; i++)
path.pop();
return '/' + path.join('/');
}
});
Browser.prefix = function(){
if(Browser.ie)
return '-ms-';
else if(Browser.opera)
return '-o-';
else if(Browser.firefox)
return '-moz-';
else if(Browser.safari || Browser.chrome)
return '-webkit-';
else
return '';
}();
Request.implement({
options: {
url: window.location.toString()
}
});
var FileTypes = {
filetypes: {
text: ['txt', 'log', 'conf', 'sql'],
pdf: ['pdf'],
image: ['jpg', 'png', 'tif', 'tiff', 'bmp', 'gif', 'psd'],
video: ['flv', 'mpeg', 'avi', 'wmv', 'mkv', 'ogv', 'mpg', 'm4v', 'mp4', 'mov'],
audio: ['ogg', 'mp3', 'aac', 'ra', 'wma'],
t3d: ['skp', '3ds', 'kmz', 'luca', 'dae', 'fbx', 'unity3d'],
cal: ['ics', 'vcs'],
geo: ['kml', 'gxml'],
people: ['wab', 'vcf'],
multimedia: ['swf', 'swd', 'pptx', 'ppt'],
vector: ['ai', 'svg', 'cdr', 'dxf', 'dwg', 'eps', 'ps'],
richtext: ['odt', 'docx', 'doc', 'html', 'rtf'],
archive: ['7z', 'gz', 'tar', 'z', 'rar', 'zip'],
spreadsheet: ['csv', 'xlsx', 'xls', 'ods']
},
getFileType: function(filename){
filename = filename.split('?')[0];
var extension = /^.+\.([a-z|0-9]+)$/i.exec(filename),
filetype = null;
if(extension == null)
return false;
else
extension = extension[1].toLowerCase();
Object.each(this.filetypes, function(type){
if(filetype == null && type.contains(extension) && typeOf(type) == 'array')
filetype = Object.keyOf(this.filetypes, type);
}, this);
return {
type: filetype,
extension: extension
};
}
};
var JSONHash = new Class({
Implements: [Options, Events],
options: {
defaultKey: 'loc',
defaultValue: '/'
},
initialize: function(options) {
this.setOptions(options);
this.uri = new URI();
},
start: function(){
var obj = $H(),
jh = JSONHash.UrlObjDecode(this.uri.get('fragment'));
if(!self.location.hash)
obj.set(this.options.defaultKey, this.options.defaultValue);
else if(self.location.hash != '' && !self.location.hash.contains(this.options.defaultKey + '='))
obj.set(this.options.defaultKey, this.uri.get('fragment'));
else
obj = jh;
this.uri.set('hash', JSONHash.UrlObjEncode(obj));
window.location = '#' + this.uri.get('fragment');
this.fireEvent('change', [obj, obj, obj]);

this.hash = this.uri.get('fragment');
var _hashchange = function(){
if(this.hash == self.location.hash.replace('#', ''))
return;
previousObject = JSONHash.UrlObjDecode(this.hash);
currentObject = JSONHash.UrlObjDecode(self.location.hash.replace('#', ''));
this.hash = self.location.hash.replace('#', '');
var keys = $H({});
currentObject.each(function(value, key){
if((previousObject[key] && currentObject[key] != previousObject[key]) || !previousObject[key])
keys[key] = value;
});
this.fireEvent('change', [keys, currentObject, previousObject]);
};
_hashchange.bind(this)();
_hashchange.periodical(50, this);
},
get: function(key){
var urlObject = JSONHash.UrlObjDecode(this.hash);
return urlObject.get(key);
},
set: function(key, value){
var urlObject = JSONHash.UrlObjDecode(this.hash);
if(typeOf(key) == 'object')
this.uri.set('fragment', JSONHash.UrlObjEncode(urlObject.merge(key)));
else if(value == false)
this.uri.set('fragment', JSONHash.UrlObjEncode(urlObject.erase(key)));
else
this.uri.set('fragment', JSONHash.UrlObjEncode(urlObject.set(key, value)));
window.location = '#' + this.uri.get('fragment');
}
});
JSONHash.extend({
UrlObjEncode: function(obj){
var str = '';
obj.each(function(value, key){
str+= key + '=' + value + ',';
});
return str.replace(/,$/, '');
},
UrlObjDecode: function(str){
var obj =  $H();
if(str)
str.split(',').each(function(pair){
pair = pair.split('=');
obj.set(pair[0], pair[1]);
});
return obj;
}
});var VideoPlayr = new Class({
options: {
poster: false,
allowFullscreen: true,
flow: {},
extensions: /\.([mkv|webm|mpg|avi|flv|ogv|mp4|m4v|mov|rm]+)$/
},
Implements: [Events, Options],
initialize: function(element, options){
if(typeOf(element) != 'string' && typeOf(element) != 'element')
options = element;
this.setOptions(options);
this.element = document.id(element).store('video-playr', this);

this.poster = this.element.get('poster') ? this.element.get('poster') : this.setPoster();


if(!VideoPlayr.noNativeSupport){
this.element.addEventListener('timeupdate', (function(){
var time = Math.floor(this.element.currentTime);
if(time != this.previousTime)
this.fireEvent('timeupdate', [time]);
this.previousTime = time;
}).bind(this), false);

this.element.addEventListener('ended', (function(){
this.fireEvent('ended');
}).bind(this), false);

this.ready = true;
this.fireEvent('ready');

} else if(VideoPlayr.noNativeSupport){
Asset.javascript(this.options.flow.js, {
onload: (function(){
if(this.element.getElement('source[type=video/mp4]'))
var src = this.element.getElement('source[type=video/mp4]').src;
else if(this.element.getElement('source[type=video/x-flv]'))
var src = this.element.getElement('source[type=video/x-flv]').src;
var options = Object.merge({}, this.options.flow.options, {
clip: src
});
this.flowPlayer = $f(this.element, this.options.flow.player, options);
(function(){
this.flowPlayer.onLastSecond((function(){
this.fireEvent('ended');
}).bind(this));



this.fireEvent('ready');
this.ready = true;
}).delay(500, this);
}).bind(this)
});
}
VideoPlayr.instances.push(this);
},
setFlowPlayer: function(){
},
setPoster: function(){
return;
this.poster =this.options.poster ||
this.element.getElement('source').src.replace(this.options.extensions, '.jpg');
this.element.set('poster', this.poster);
return this.poster;
},
getTime: function(){
return VideoPlayr.noNativeSupport ?  this.flowPlayer.getTime() : this.element.currentTime;
},
isPlaying: function(){
return VideoPlayr.noNativeSupport ? this.flowPlayer.isPlaying() : !this.element.paused;
},
unload: function(){
if(VideoPlayr.noNativeSupport){
if(this.ready)
$f('*').each(function(){
this.stop();
this.unload();
});
} else {

this.pause();

}
},
load: function(src){
if(VideoPlayr.noNativeSupport)
return this.flowPlayer.setClip({
url: src
});
this.element.src = src;






},
play: function(){
return VideoPlayr.noNativeSupport ? this.flowPlayer.play() : this.element.play();
},
pause: function(){
return VideoPlayr.noNativeSupport ? this.flowPlayer.pause() : this.element.pause();
},
toggle: function(){
return this.isPlaying() ? this.pause() : this.play();
},
seek: function(time){
return VideoPlayr.noNativeSupport ? this.flowPlayer.seek(time) : this.element.currentTime = time;

}
});
VideoPlayr.extend({
noNativeSupport: !!document.createElement('video').canPlayType ? false : true,
instances: [],
unload: function(keep){
VideoPlayr.instances.each(function(instance){
if(instance != keep)
instance.unload();
});
},
h264: VideoPlayr.noNativeSupport ? document.createElement('video').canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"') : false,
ogg: VideoPlayr.noNativeSupport ? document.createElement('video').canPlayType('video/ogg; codecs="theora"') : false,
webm: VideoPlayr.noNativeSupport ? document.createElement('video').canPlayType('video/webm; codecs="vp8, vorbis"') : false,
active: false
});var Select = new Class({
options: {
multiple: true,
elements: '',
filter: 'input, textarea, object',
handle: '*',
selected: false,
event: 'mousedown',
cache: false,
deselectable: true
},
Implements: [Events, Options],
initialize: function(options){
this.setOptions(options);
this.context = document.id(this.options.context) || document.body;
this.getElements();
if(this.options.selected !== false)
this.select(this.options.selected);
if(this.options.event)
this.context.addEvent(this.options.event, (function(e){
if(this.inactive)
return;
if(!$(e.target).match(this.options.filter) && $(e.target).match(this.options.handle)){
if(this.isItem(e.target)){
var elements = this.getElements(),
cel = document.id(e.target).bubble(elements),
x = elements.indexOf(this.lastSelected),
x2 = elements.indexOf(cel);
if(this.options.multiple && e.control && !e.shift){
this.toggle(cel);
this.lastSelected = cel;
} else if(this.options.multiple && e.shift){
if(!e.control && this.options.multiple != 'freestyle')
this.unselectAll([this.lastSelected, cel]);
elements.map(function(el, i){
if((x < x2 && i > x && i < x2) || (x > x2 && i < x && i > x2))
this.toggle(el);
}, this);
if(this.options.multiple == 'freestyle')
this.toggle(cel);
else
this.select(cel);
} else {
if(this.options.multiple == 'freestyle'){
this.toggle(cel);
} else {
this.unselectAll(cel);
this.select(cel);
}
this.lastSelected = cel;
}
} else if(this.options.deselectable && !e.control && !e.shift && this.options.multiple != 'freestyle'){
this.unselectAll();
}
this.fireEvent('selectEnd');
}
}).bind(this));
},
add: function(selector){
this.options.elements += ', ' + selector;
this.refresh();
},
refresh: function(){
this.elements = this.context.getElements(this.options.elements);
},
getElements: function(fn){
if(!this.elements || !this.options.cache)
this.elements = this.context.getElements(this.options.elements);
if(fn)
return this.elements.map(fn);
return this.elements;
},
isSelected: function(el){
var el = typeOf(el) == 'number' ? this.getElement(el) : document.id(el);
return el.retrieve('selected') === true;
},
getElement: function(element){
var els = this.getElements();
if(typeOf(element) == 'number')
return els[element];
else if(typeOf(element) == 'string'){
var lastIndex = this.getIndex(this.lastSelected);
if(element == 'next')
dir = 1;
else if(element == 'previous')
dir = -1;

if(this.getSelection().length == 0)
i = dir == -1 ? els.length : -1;
else if(lastIndex == els.length - 1 && dir == 1)
i = -1;
else if(lastIndex == 0 && dir == -1)
i = els.length;
else
i = lastIndex;
return this.getElements()[i + dir];
}
},
getIndex: function(el){
return this.getElements().indexOf(el);
},
select: function(el, force){
if(el === false) return;
this.fireEvent('beforeselect', el);
var els;
if(el == 'all')
els = this.getElements();
else if(el == 'next' || el == 'previous' || typeOf(el) == 'number')
els = Array.from(this.getElement(el));
else if(el == 'last')
els = Array.from(this.getElement(this.getElements().length - 1));
else if(el == 'first')
els = Array.from(this.getElement(0));
else if(typeOf(el) == 'string')
els = this.getElements().filter(function(elmnt){
return elmnt.match(el);
});
else if(typeOf(el) == 'element')
els = Array.from(el);

if(!this.options.multiple && !force)
this.unselectAll(els);

this.index = this.getElements().indexOf(els[els.length - 1]);

els.each(function(el){
if(el.retrieve('selected') !== true){
this.setSelected(el);
this.fireEvent('select', el);
this.fireEvent('change', el);
}
}, this);
return this;
},
setSelected: function(el){
if(this.lastSelected)
this.lastSelected.removeClass('last-selected');
this.lastSelected = el;

el.store('selected', true).addClass('selected');
return this;
},
unselect: function(el, exclude){
if(el == 'all')
return this.unselectAll(exclude);

if(this.lastSelected)
this.lastSelected.removeClass('last-selected');

var el = $$(el);
if(el.length == 0)
return this.unselectAll();
el.store('selected', false).removeClass('selected');
return this.fireEvent('unselect', el).fireEvent('change', el);
},
unselectAll: function(exclude){
exclude = Array.from(exclude);
this.getSelection().each(function(el){
if(!exclude.contains(el))
this.unselect(el);
}, this);
this.lastSelected = false;
return this.fireEvent('unselectAll');
},
toggle: function(el){
if(el.retrieve('selected'))
this.unselect(el);
else
this.select(el);
},
isItem: function(el){
var el = document.id(el);
return el.getParents().some(function(item){
return this.getElements().contains(item);
}, this) || this.getElements().contains(el);
},
getSelection: function(property, bind){
var elements = this.getElements().filter(function(el){
return el.retrieve('selected');
}).map(function(el){
if(property == 'index')
return this.getElements().indexOf(el);
else if(typeOf(property) == 'string')
return el.get(property);
else if(typeOf(property) == 'function')
return property.call(bind || this, el);
else return el;
}, bind || this);
return elements;
},
getLastSelection: function(property, bind){
if(property)
return this.lastSelected.get(property);
return this.lastSelected;

return this.context.getElements('.last-selected').filter(function(el){
return this.isItem(el);
}, this).length > 0 ?  this.context.getElement('.last-selected') : false;
},
getUnselection: function(){
return this.getElements().filter(function(el){
return !el.retrieve('selected');
});
}
});var H, piwikTracker, menuSlct;
window.addEvents({
domready: function(){
$$('footer .news-block').show();
var hs = [],
cols = $$('.news-block .column-3');
cols.each(function(el){
hs.push(el.getDimensions().height);
});
$$('footer .news-block').setStyle('display', '');
hs.sort(function(a, b){ return b - a; });
cols.setStyle('height', hs[0]);

$('about-nav').inject($('main-header').getElement('div')).hide();
var delay = Browser.ie6 || Browser.ie7 ? 10 : 500;
H = new JSONHash({
defaultKey: 'loc',
defaultValue: 'home-holder'
});
H.addEvent('change', function(keys, obj, pobj){
keys.each(function(value, key){
if(key == 'loc'){
VideoPlayr.unload();
if(value == 'about-holder'){
$('about-nav').open.delay(999, $('about-nav'));
} else {
$('about-nav').close();
H.set('tab', false);
}


var el = $$('[href$=' + value + ']')[0];
menuSlct.select(el);
var left = el.getLeft() + el.getWidth() / 2,
target = $(value);
$('main-header').setStyle('background-position', left + 'px 0');
if(el.hasClass('ajax')){
if(value != 'project-holder')
$(document.html).swapClass('page-project', 'not-page-project');
(function(){
if(value == 'project-holder')
$(document.html).swapClass('not-page-project', 'page-project');
if(value == 'home-holder')
$(document.html).addClass('page-home');
else
$(document.html).removeClass('page-home');
if(value != 'home-holder')
homeSlct.select('none');
else if(!homeSlct.isSelected(0))
homeSlct.select(0);
if(value == 'project-holder'){
if(projectSlct.getSelection().length == 0)
projectSlct.select(0);
else
projectSlct.fireEvent('select', projectSlct.getLastSelection());
}
}).delay(delay + 300);
if(!keys.has('tab'))
(function(){
window.scrollTo(0, 0);
}).delay(delay + 500);
$('page__').setStyle('height', target.getDimensions().height + 40);
if(Browser.ie6 || Browser.ie7)
scr.set(target.getPosition($('content__')).x, 0);
else
(function(){
scr.toElement(target);
}).delay(delay + 300);
}
}
if(key == 'tab'){
if(Browser.ie6 || Browser.ie7)
return window.scrollTo(0, $(value).getTop() - 90);
scrAbout.toElement($(value));
}
});
});
$(document.html).addClass(VideoPlayr.noNativeSupport ? 'no-video' : 'video'),
$(document.body).addEvents({
'contextmenu:relay(video, [href*=/media/video/])': function(e){
e.preventDefault();
return false;
},
'mousedown:relay(video, [href*=/media/video/])': function(e){
if(Browser.firefox)
e.preventDefault();
}
});
$('video-list').addEvent('click:relay(a)', function(e){
e.preventDefault();
});

flowConf.options = Object.merge(flowConf.options, {
plugins:{
controls: {
width: '100%',
bottom: 0,
left: '0',
scrubber: true,
borderRadius: 0,
autoHide: {
enabled: true,
hideDelay: 4000,
fullscreenOnly: false,
hideDuration: 200
},
time: false
}
},
clip: {
scaling: 'scale'
}
});
flowConf.js = '/shared/widget/flow/flow.326.js';


$('video-list').addEvent('click:relay(a)', function(e){
e.preventDefault();
});

var homeSlct = new Select({
context: 'video-list',
elements: 'li',
multiple: false,
selected: -1
});

$$('.video-player').each(function(el){
var homePlayr = new VideoPlayr(el, {
flow: flowConf,
allowFullscreen: false,
onEnded: function(){
homeSlct.select('next');
}
});
});
homeSlct.addEvent('select', function(el){
var id = el.getElement('a').get('href').replace('#', '');

$$('.video-player').filter(function(vp){
vp.retrieve('video-playr').unload();
return vp.id != id;
}).hide();
$(id).show();

var playr = $(id).retrieve('video-playr');
if(playr.ready)
playr.play.delay(delay + 500, playr);

if(H.get('tab') == 'home-holder' && !homeSlct.isSelected(0))
homeSlct.select(0);
});



var aboutSlct = new Select({
context: 'about-nav',
elements: 'li',
multiple: false
});

$$('#main-menu').addEvents({
'click:relay(a.ajax)': function(e){
e.preventDefault();
},
'mouseenter:relay(a)': function(e, target){
var left = target.getLeft() + target.getWidth() / 2;
$('main-header').setStyle('background-position', left + 'px 0');
},
'mouseleave:relay(a)': function(){
var el = menuSlct.getSelection()[0];
var left = el.getLeft() + el.getWidth() / 2;
$('main-header').setStyle('background-position', left + 'px 0');
}
});
var options = {
duration: delay,
transition: Browser.ie6 || Browser.ie7 ? 'linear' : 'quart:out',
link: 'cancel'
};
var scr = new Fx.Scroll('page__', options),
scrMedia = new Fx.Scroll('projets-container', options),
diapos = $$('.project');

if(!Browser.ie6 && !Browser.ie7){
var scrAbout = new Fx.Scroll(document.html, {
transition: 'quart:out',
duration: 1000,
link: 'cancel',
offset : {
y: -46
}
});
}

menuSlct = new Select({
elements: 'a.ajax',
context: 'main-menu',
multiple: false,
onSelect: function(el){
H.set('loc', el.href.split('#')[1]);
if(window.Piwik){
piwikTracker.setDocumentTitle(el.get('text'));
piwikTracker.trackPageView();
}
}
});

$('content__').addEvent('click:relay(.ajax.loc)', function(e){
e.preventDefault();
H.set('loc', this.href.split('#')[1]);
});










var projectSlct = new Select({
context: 'project-nav',
elements: 'a',
multiple: false,
deselectable: false,
onSelect: function(el){

var index = this.getElements().indexOf(el),
el = diapos[index].getElement('a.playr');



scrMedia.toElement(diapos[index]);
var rb = $('ribon');
if(diapos[index].getElement('a.project-link')){
rb.open.delay(250, rb);
rb.href = diapos[index].getElement('a.project-link').href;
} else {
rb.close();
}
}
});



$('about-nav').addEvent('click:relay(a)', function(e){
e.preventDefault();
H.set('tab', this.href.split('#')[1]);
});
var newsTicker = new Fx.Scroll('news-mask', {
duration: 500,
transition:'quint:out',
link: 'cancel',
onComplete: function(){
newsSlct.select.delay(3999, newsSlct, 'next');
},
onStart: function(){
$$('#news-mask article p').each(function(el, index){
if(index > newsSlct.getIndex(newsSlct.lastSelected))
el.addClass('pHidden');
else
el.removeClass('pHidden');
});
}
}),
newsSlct = new Select({
dbg: true,
event: false,
context: 'news-mask',
elements: 'article',
multiple: false,
deselectable: false,
onSelect: function(el){
newsTicker.toElement(el);
}
});
newsSlct.select(0);

$('send-mail').addEvents({
mousedown: function(){
this.addClass('sending');
},
click: function(e){
e.preventDefault();
new Request.JSON({
url: $('contact-form').action,
data: $('contact-form').toQueryString(),
onSuccess: function(j){
$('send-mail').removeClass('sending');
if(j.error === 0){
$('send-mail').addClass('sent');
setTimeout(function(){
H.set('loc', 'home-holder');
}, 3000);
} else {
$('send-mail').addClass('not-sent');
}
setTimeout(function(){
$('send-mail').removeClass('not-sent');
}, 1500);
}
}).send();
},
mouseup: function(){

}
});
Asset.image('/asset/img/search-input.png', {
onload: function(){
hoverLabel('person', {
offset: { x: 8, y: 7 }
});
hoverLabel('email', {
offset: { x: 8, y: 7 }
});
hoverLabel('message', {
offset: { x: 8, y: 7 }
});
}
});

var holder = new Element('div.text-box').inject(document.body),
subHolder = new Element('div.sub-holder').inject(holder),
closeLB = function(){




holFx.start(holder.retrieve('init-pos'));
hidder.close();
holder.hide.delay(800, holder);
subHolder.set('html', '');
subHolder.hide();
},
closeBtn = new Element('button.close', {
events: {
click: closeLB
}
}).inject(holder),
hidder = new Element('div.hidder', {
events: {
click: closeLB
}
}).inject(document.body),
holFx = new Fx.Morph(holder, {
transition: 'quint:out',
duration: 800,
onComplete: function(){
subHolder.open();
}
});
$(document.body).addEvent('click:relay(.litebox)', function(e){
e.preventDefault();
var el = this,
uri = new URI(el.href);
uri.setData('tpl', 'module');
new Request({
url: uri.toString(),
onSuccess: function(r){
hidder.open();
subHolder.set('html', r);
holder.show();
var height = subHolder.getDimensions().height
subHolder.hide();
holder.hide();
var styles = Object.merge(el.getDimensions(), holder.position({
relativeTo: el,
returnPos: true
}), {
opacity: 0
});
holder.open().setStyles(styles).store('init-pos', styles);
var winScr = window.getScroll();
holFx.start({
top: (window.getHeight() - height) / 2 + winScr.y,
left: (window.getWidth() - 600) / 2 + winScr.x,
width: 600,
height: height
});
}
}).send();
});
H.start();
if(window.Piwik){
piwikTracker = Piwik.getTracker('http://piwik.ccufrance.com/piwik.php', 6);
piwikTracker.setDocumentTitle(document.title);
piwikTracker.trackPageView();
}
},
resize: function(){
if(menuSlct){
var el = menuSlct.getLastSelection(),
left = el.getLeft() + el.getWidth() / 2;
$('main-header').setStyle('background-position', left + 'px 0');
}
}
});
