Number.implement({
isMultiple: function(multiple){
if(this % multiple == 0) return true;
return false;
},
toHex: function(){
return this.toString(16);
}
});
flowConf = {
options: {
plugins:{
controls:{
url: '/shared/widget/flow/flow.controls.320.swf',
progressColor: '', 
bufferColor: '#ffffff',
backgroundColor: '',
backgroundGradient: 'none',
height: 30,
sliderGradient: '#fff',
width: '96%',
bottom: 5,
left: '50%',
borderRadius: 7,
buttonOverColor: '',
opacity: .8,
buttonColor: '',
autoHide: 'always'
}
}
},
player: {
cachebusting: true,
wmode: 'transparent',
src: '/shared/widget/flow/flow.321.swf'
}
};
flaudioConf = $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'){
var height = size;
var width = size / ratio;
} else {
var width = size;
var height = size * ratio;
}
return {
width: Math.round(width, 0),
height: Math.round(height, 0)
};
},
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;
}
}
var filetypes = $H({
text: ['txt', 'log', 'conf'],
pdf: ['pdf'],
image: ['jpg', 'png', 'tif', 'bmp', 'gif', 'psd'],
video: ['flv', 'avi', 'wmv', 'mkv', 'ogv', 'mpg', 'm4v', 'mp4'],
audio: ['mp3', 'aac', 'ra', 'wma'],
t3d: ['skp', '3ds', 'kmz', 'dxf', 'dwg'],
cal: ['ics', 'vcs'],
geo: ['kml', 'gxml'],
people: ['wab', 'vcf'],
multimedia: ['swf', 'swd'],
vector: ['ai', 'svg', 'cdr'],
richtext: ['odt', 'doc', 'html', 'rtf'],
spreadsheet: ['csv', 'xls', 'ods']
});
function getFileType(filename){
filename = filename.split('?')[0];
extension = /^.+\.([a-z|0-9]+)$/i.exec(filename)[1];
filetypes.each(function(type){
if(type.contains(extension))
filetype = filetypes.keyOf(type);
}, this);
return {
type: filetype,
extension: extension
};
}
var $N = Number;
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);
}
};
Date.defineParser('%d %b %y');
HtmlTable.Parsers.hiddenDate = {
convert: function() {
return Date.parse(this.getElement('.hidden').get('text'));
}
};
HtmlTable.Parsers.string.convert = function() {
return this.get('text').URLify();
};
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();
$clear(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;
}
});
var spe = $H({
a: 'ÀàÁáÂâÃãÄäÅåĂăĄą',
c: 'ĆćČčÇç',
d: 'ĎďĐđ',
e: 'ÈèÉéÊêËëĚěĘę',
g: 'Ğğ',
i: 'ÌìÍíÎîÏïĹĺ',
l: 'ĹĺĽľŁł',
n: 'ÑñŇňŃń',
o: 'ÒòÓóÔôõÖöØøÕő',
r: 'ŘřŔŕ',
s: 'ŠšŞşŚś',
t: 'ŤťŤťŢţ',
u: 'ÙùÚúÛûÜüŮůµ',
y: 'ŸÿÝý',
z: 'ŽžŹźŻż',
th: 'Þþ',
dh: 'Ðð',
ss: 'ß',
ae: 'Œœ',
oe: 'Ææ',
'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;
spe.each(function(chs, key){
chs.each(function(ch){
text = text.replace(new RegExp(ch.escapeRegExp(), 'g'), key);
});
});
text = text.replace(/--/g, '-');
text = text.replace(/-$/g, '');
return text.toLowerCase();
},
parseInt: function(){
return 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){
return this.replace(regexp || /\\?\{([^{}]+)\}/g, function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
substitution = eval('object.' + name);
if($type(substitution) == 'function')
return substitution();
if($type(substitution) == 'element'){
var tmp = new Element('div').adopt(substitution);
var str = tmp.get('html');
tmp.destroy();
return str;
}
return substitution;
});
}
});
Element.implement({
unselectable: function(){
this.addEvent('mousedown', function(e){
if(e.target.get('tag') == 'input' || e.target.get('tag') == 'textarea'){
this.setStyle(Browser.prefix + 'user-select', 'text');
this.onselectstart = '';
} else {
this.setStyle(Browser.prefix + 'user-select', 'none');
this.onselectstart = function(){ return false; };
}
});
},
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;
},
merge: function(object){
var tmp = new Element('div').adopt(this.clone());
var html = tmp.get('html').replace(/%7B/g, '{').replace(/%7D/g, '}');
tmp.destroy();
return this.set('html', 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) {
if(Browser.Engine.trident){
this.setStyles({
display: this.retrieve('originalDisplay') || 'block',
opacity: 1
});
this.fireEvent('open');
} else {
this.setStyles({
display: this.retrieve('originalDisplay') || 'block',
opacity: 0
});
this.set({'tween': {
duration: 300,
onComplete: (function(){
this.fireEvent('open');
}).bind(this)
}});
this.fade(opacity || 1);
}
return this;
},
close: function(opacity) {
this.store('originalDisplay', this.getStyle('display') || '')
if(Browser.Engine.trident){
this.setStyle('display', 'none');
this.fireEvent('close');
} else {
this.set({'tween': {
duration: 200,
onComplete: (function(){
this.setStyle('display', 'none');
this.fireEvent('close');
}).bind(this)
}});
this.fade(opacity || 0);
}
return this;
},
toggle: function() {
return this[this.isDisplayed() ? 'close' : 'open']();
},
disintegrate: function(opacity) {
if(Browser.Engine.trident){
this.destroy();
this.fireEvent('destroy');
} else {
this.set({'tween': {
duration: 500,
onComplete: (function(){
this.destroy();
this.fireEvent('destroy');
}).bind(this)
}});
if(opacity) this.fade(opacity, 0);
else this.fade(0);
}
},
popup: function(parent, options){
var options = $merge({
offset: {x: 0, y: 0}
}, options);
var self = this;
this.fn = function(e){
var el = e.target;
while (el != document.body && el.nodeType == 1){
if (el == self || el == parent)return false;
else el = el.parentNode;
}
document.removeEvent('mousedown', self.fn);
self.close();
self.fireEvent('close');
};
if(this.getStyle('display') == 'none'){
this.open();
if(parent){
this.position({
relativeTo: parent,
edge: 'upperLeft',
position: 'bottomLeft',
offset: options.offset
});
}
}
document.addEvent('mousedown', this.fn);
return this;
},
path: function(root) {
path = [];
var el = this;
while (el = el.getParent() !== root || document.body ? el.getParent() : false)
path.push(el);
return path.reverse();
},
bubble: function(selector){
if(this.get('tag') == 'html') return false;
return $$(selector).contains(this) ? this : this.getParent().bubble($$(selector));
},
appendHTML: function(HTML){
this.innerHTML = this.innerHTML + HTML;
return this;
},
tip: function(options){
var options = $merge({
x: -17, y: 0,
id: 'buttonTipHolder'
}, options);
this.store('tip-enabled', true);
if(!this.retrieve('title')){
this.store('title', options.msg || this.title || this.get('html'));
this.erase('title');
}
this._className = 'infoTipHolder';
if(options.dir) this._className += options.dir;
if(document.id(options.id))
var tip = document.id(options.id);
else {
var tip = new Element('div', {
'class': this._className,
id: options.id,
html: '<div class="tipTr"><div class="tipTl"><div class="tip-container"></div></div></div><div class="tipBr"><div class="tipBl"></div></div>'
}).inject(document.body);
}
if(options.dir == 'Bottom'){
this.pos = 'bottomLeft';
this.edge = 'upperLeft';
}else{
this.pos = 'upperLeft';
this.edge = 'bottomLeft';
}
var open = function(){
if(this.retrieve('tip-enabled')){
if(options.msg)
this.store('title', options.msg);
tip.getElement('.tip-container').set('html', this.retrieve('title'));
tip.position({
relativeTo: this,
position: this.pos, edge: this.edge,
offset: {x: options.x, y: options.y}
});
tip.open();
tip.set('class', this._className);
}
}
open = open.bind(this);
if(!options.persist)
this.addEvents({
mouseenter: open,
mouseleave: tip.close.bind(tip),
mousedown: tip.close.bind(tip)
});
if(options.autoClose)
this.addEvent('mousedown', function(){
this.removeEvent('mouseenter', open);
});
if(options.follow){
if(options.follow == 'x'){
this.addEvent('mousemove', function(e){
tip.setStyle('left', e.page.x + options.x);
});
} else {
options.y -= 55;
this.addEvent('mousemove', function(e){
tip.setStyles({
left: e.page.x + options.x,
top: e.page.y + options.y
});
});
}
}
if(options.persist) open();
return tip;
}
});
Window.implement({
loadGMap: function(GKey, callback){
if($defined(window.google) && $defined(window.google.maps)){
callback();
} else {
new 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();
}
});
}
});
}
});
}
}
});
Element.implement({
error: function(msg, id){
msg = '<strong style="color:red">' + msg + '</strong>';
this.store('title', msg);
return this.tip({
persist: true,
msg: msg,
id: id,
y: 6, x: -10
});
return this;
},
validate: function(validClass, invalidClass){
$$('label[for=' + this.id + ']')[0].swapClass(invalidClass, validClass);
this.removeClass('validation-failed').addClass('validation-passed');
},
unvalidate: function(validClass, invalidClass){
$$('label[for=' + this.id + ']')[0].swapClass(validClass, invalidClass);
this.removeClass('validation-passed').addClass('validation-failed');
},
nothing: function(validClass, invalidClass){
$$('label[for=' + this.id + ']')[0].removeClass(validClass).removeClass(invalidClass);
this.removeClass('validation-failed').removeClass('validation-passed');
},
toggleValidate: function(validClass, invalidClass){
if(this.hasClass('validation-failed'))
this.validate(validClass, invalidClass);
else this.unvalidate(validClass, invalidClass);
}
});
var FormValidator = Class.refactor(FormValidator, {
Implements: [Events, Options],
Binds: ['validate'],
options: {
passedClassName: 'fpassed',
failedClassName: 'ffailed',
tipID: 'default',
auto: true,
evaluateFieldsOnBlur: false
},
initialize: function(form, options){
this.previous(form, options);
this.addEvents({
onElementPass: function(el){
if(el.value == '')
$$('label[for=' + el.id + ']')[0]
.removeClass(this.options.failedClassName)
.removeClass(this.options.passedClassName);
else
el.validate(this.options.passedClassName, this.options.failedClassName);
if(document.id(this.options.tipID)) document.id(this.options.tipID).close();
},
onElementValidate: function(){
this.getFields().each(function(fel){
fel.set('disabled', false);
});
this.start();
},
onElementFail: function(el){
el.focus();
$H(this.options.messages).each(function(value, key){
if(el.id == key) el.error(value, this.options.tipID);
}, this);
el.unvalidate(this.options.passedClassName, this.options.failedClassName);
this.getFields().each(function(fel){
if(el != fel)
fel.set('disabled', true);
});
}
});
if(this.options.auto)
this.getFields().each(function(input){
input.addEvents({
keyup: (function(){
if(input.hasClass('validation-failed'))
this.validateField(input);
}).bind(this)
});
}, this);
}
});
FormValidator.addAllThese([
['validate-alpha2', {
test: function(element){
return FormValidator.getValidator('IsEmpty').test(element) ||  (/^[a-zA-ZàáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ\-\s]+$/).test(element.get('value'));
}
}],
['validate-phone', {
test: function(element){
return FormValidator.getValidator('IsEmpty').test(element) ||  (/^[0-9\.\+\-\s]+$/).test(element.get('value'));
}
}],
['validate-match', {
test: function(element, props){
var eleVal = element.get('value');
var matchVal = document.id(props.matchInput) && document.id(props.matchInput).get('value');
return eleVal && matchVal ? eleVal == matchVal : true;
}
}]
]);
window.addEvents({
load: function(){
$$('button, a').each(function(el){
el.addEvent('focus', function(){
el.blur();
});
});
}
});
function failureCallback(errorCode) {
console.error('Error loading GE Plugin');
}
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);
}
});
Fx.Scroll.implement({
set: function(){
var now = Array.flatten(arguments);
if (Browser.Engine.gecko) now = [Math.round(now[0]), Math.round(now[1])];
this.fireEvent('set', [now[0], now[1]]);
this.element.scrollTo(now[0], now[1]);
}
});
Browser.prefix = function(){
if(Browser.Engine.trident)
return '-ms-';
else if(Browser.Engine.presto)
return '-o-';
else if(Browser.Engine.gecko)
return '-moz-';
else if(Browser.Engine.webkit)
return '-webkit-';
else
return '';
}();
Request.implement({
options: {
url: window.location.toString()
}
});

