Skip to content

Instantly share code, notes, and snippets.

@mkorostoff
Created April 25, 2012 03:50
Show Gist options
  • Save mkorostoff/2486114 to your computer and use it in GitHub Desktop.
Save mkorostoff/2486114 to your computer and use it in GitHub Desktop.
var Prototype = {
Version: "1.6.1",
Browser: (function () {
var b = navigator.userAgent;
var a = Object.prototype.toString.call(window.opera) == "[object Opera]";
return {
IE: !! window.attachEvent && !a,
Opera: a,
WebKit: b.indexOf("AppleWebKit/") > -1,
Gecko: b.indexOf("Gecko") > -1 && b.indexOf("KHTML") === -1,
MobileSafari: /Apple.*Mobile.*Safari/.test(b)
}
})(),
BrowserFeatures: {
XPath: !! document.evaluate,
SelectorsAPI: !! document.querySelector,
ElementExtensions: (function () {
var a = window.Element || window.HTMLElement;
return !!(a && a.prototype)
})(),
SpecificElementExtensions: (function () {
if (typeof window.HTMLDivElement !== "undefined") {
return true
}
var c = document.createElement("div");
var b = document.createElement("form");
var a = false;
if (c.__proto__ && (c.__proto__ !== b.__proto__)) {
a = true
}
c = b = null;
return a
})()
},
ScriptFragment: "<script[^>]*>([\\S\\s]*?)<\/script>",
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function () {},
K: function (a) {
return a
}
};
if (Prototype.Browser.MobileSafari) {
Prototype.BrowserFeatures.SpecificElementExtensions = false
}
var Abstract = {};
var Try = {
these: function () {
var c;
for (var b = 0, d = arguments.length; b < d; b++) {
var a = arguments[b];
try {
c = a();
break
} catch (f) {}
}
return c
}
};
var Class = (function () {
function a() {}
function b() {
var h = null,
g = $A(arguments);
if (Object.isFunction(g[0])) {
h = g.shift()
}
function d() {
this.initialize.apply(this, arguments)
}
Object.extend(d, Class.Methods);
d.superclass = h;
d.subclasses = [];
if (h) {
a.prototype = h.prototype;
d.prototype = new a;
h.subclasses.push(d)
}
for (var f = 0; f < g.length; f++) {
d.addMethods(g[f])
}
if (!d.prototype.initialize) {
d.prototype.initialize = Prototype.emptyFunction
}
d.prototype.constructor = d;
return d
}
function c(l) {
var g = this.superclass && this.superclass.prototype;
var f = Object.keys(l);
if (!Object.keys({
toString: true
}).length) {
if (l.toString != Object.prototype.toString) {
f.push("toString")
}
if (l.valueOf != Object.prototype.valueOf) {
f.push("valueOf")
}
}
for (var d = 0, h = f.length; d < h; d++) {
var k = f[d],
j = l[k];
if (g && Object.isFunction(j) && j.argumentNames().first() == "$super") {
var m = j;
j = (function (n) {
return function () {
return g[n].apply(this, arguments)
}
})(k).wrap(m);
j.valueOf = m.valueOf.bind(m);
j.toString = m.toString.bind(m)
}
this.prototype[k] = j
}
return this
}
return {
create: b,
Methods: {
addMethods: c
}
}
})();
(function () {
var d = Object.prototype.toString;
function k(t, v) {
for (var u in v) {
t[u] = v[u]
}
return t
}
function n(t) {
try {
if (f(t)) {
return "undefined"
}
if (t === null) {
return "null"
}
return t.inspect ? t.inspect() : String(t)
} catch (u) {
if (u instanceof RangeError) {
return "..."
}
throw u
}
}
function m(t) {
var v = typeof t;
switch (v) {
case "undefined":
case "function":
case "unknown":
return;
case "boolean":
return t.toString()
}
if (t === null) {
return "null"
}
if (t.toJSON) {
return t.toJSON()
}
if (j(t)) {
return
}
var u = [];
for (var x in t) {
var w = m(t[x]);
if (!f(w)) {
u.push(x.toJSON() + ": " + w)
}
}
return "{" + u.join(", ") + "}"
}
function c(t) {
return $H(t).toQueryString()
}
function g(t) {
return t && t.toHTML ? t.toHTML() : String.interpret(t)
}
function q(t) {
var u = [];
for (var v in t) {
u.push(v)
}
return u
}
function o(t) {
var u = [];
for (var v in t) {
u.push(t[v])
}
return u
}
function l(t) {
return k({}, t)
}
function j(t) {
return !!(t && t.nodeType == 1)
}
function h(t) {
return d.call(t) == "[object Array]"
}
function r(t) {
return t instanceof Hash
}
function b(t) {
return typeof t === "function"
}
function a(t) {
return d.call(t) == "[object String]"
}
function p(t) {
return d.call(t) == "[object Number]"
}
function f(t) {
return typeof t === "undefined"
}
k(Object, {
extend: k,
inspect: n,
toJSON: m,
toQueryString: c,
toHTML: g,
keys: q,
values: o,
clone: l,
isElement: j,
isArray: h,
isHash: r,
isFunction: b,
isString: a,
isNumber: p,
isUndefined: f
})
})();
Object.extend(Function.prototype, (function () {
var m = Array.prototype.slice;
function d(q, n) {
var p = q.length,
o = n.length;
while (o--) {
q[p + o] = n[o]
}
return q
}
function k(o, n) {
o = m.call(o, 0);
return d(o, n)
}
function h() {
var n = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, "").replace(/\s+/g, "").split(",");
return n.length == 1 && !n[0] ? [] : n
}
function j(p) {
if (arguments.length < 2 && Object.isUndefined(arguments[0])) {
return this
}
var n = this,
o = m.call(arguments, 1);
return function () {
var q = k(o, arguments);
return n.apply(p, q)
}
}
function g(p) {
var n = this,
o = m.call(arguments, 1);
return function (r) {
var q = d([r || window.event], o);
return n.apply(p, q)
}
}
function l() {
if (!arguments.length) {
return this
}
var n = this,
o = m.call(arguments, 0);
return function () {
var p = k(o, arguments);
return n.apply(this, p)
}
}
function f(p) {
var n = this,
o = m.call(arguments, 1);
p = p * 1000;
return window.setTimeout(function () {
return n.apply(n, o)
}, p)
}
function a() {
var n = d([0.01], arguments);
return this.delay.apply(this, n)
}
function c(o) {
var n = this;
return function () {
var p = d([n.bind(this)], arguments);
return o.apply(this, p)
}
}
function b() {
if (this._methodized) {
return this._methodized
}
var n = this;
return this._methodized = function () {
var o = d([this], arguments);
return n.apply(null, o)
}
}
return {
argumentNames: h,
bind: j,
bindAsEventListener: g,
curry: l,
delay: f,
defer: a,
wrap: c,
methodize: b
}
})());
Date.prototype.toJSON = function () {
return '"' + this.getUTCFullYear() + "-" + (this.getUTCMonth() + 1).toPaddedString(2) + "-" + this.getUTCDate().toPaddedString(2) + "T" + this.getUTCHours().toPaddedString(2) + ":" + this.getUTCMinutes().toPaddedString(2) + ":" + this.getUTCSeconds().toPaddedString(2) + 'Z"'
};
RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function (a) {
return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1")
};
var PeriodicalExecuter = Class.create({
initialize: function (b, a) {
this.callback = b;
this.frequency = a;
this.currentlyExecuting = false;
this.registerCallback()
},
registerCallback: function () {
this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000)
},
execute: function () {
this.callback(this)
},
stop: function () {
if (!this.timer) {
return
}
clearInterval(this.timer);
this.timer = null
},
onTimerEvent: function () {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.execute();
this.currentlyExecuting = false
} catch (a) {
this.currentlyExecuting = false;
throw a
}
}
}
});
Object.extend(String, {
interpret: function (a) {
return a == null ? "" : String(a)
},
specialChar: {
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
"\\": "\\\\"
}
});
Object.extend(String.prototype, (function () {
function prepareReplacement(replacement) {
if (Object.isFunction(replacement)) {
return replacement
}
var template = new Template(replacement);
return function (match) {
return template.evaluate(match)
}
}
function gsub(pattern, replacement) {
var result = "",
source = this,
match;
replacement = prepareReplacement(replacement);
if (Object.isString(pattern)) {
pattern = RegExp.escape(pattern)
}
if (!(pattern.length || pattern.source)) {
replacement = replacement("");
return replacement + source.split("").join(replacement) + replacement
}
while (source.length > 0) {
if (match = source.match(pattern)) {
result += source.slice(0, match.index);
result += String.interpret(replacement(match));
source = source.slice(match.index + match[0].length)
} else {
result += source, source = ""
}
}
return result
}
function sub(pattern, replacement, count) {
replacement = prepareReplacement(replacement);
count = Object.isUndefined(count) ? 1 : count;
return this.gsub(pattern, function (match) {
if (--count < 0) {
return match[0]
}
return replacement(match)
})
}
function scan(pattern, iterator) {
this.gsub(pattern, iterator);
return String(this)
}
function truncate(length, truncation) {
length = length || 30;
truncation = Object.isUndefined(truncation) ? "..." : truncation;
return this.length > length ? this.slice(0, length - truncation.length) + truncation : String(this)
}
function strip() {
return this.replace(/^\s+/, "").replace(/\s+$/, "")
}
function stripTags() {
return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, "")
}
function stripScripts() {
return this.replace(new RegExp(Prototype.ScriptFragment, "img"), "")
}
function extractScripts() {
var matchAll = new RegExp(Prototype.ScriptFragment, "img");
var matchOne = new RegExp(Prototype.ScriptFragment, "im");
return (this.match(matchAll) || []).map(function (scriptTag) {
return (scriptTag.match(matchOne) || ["", ""])[1]
})
}
function evalScripts() {
return this.extractScripts().map(function (script) {
return eval(script)
})
}
function escapeHTML() {
return this.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
}
function unescapeHTML() {
return this.stripTags().replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&")
}
function toQueryParams(separator) {
var match = this.strip().match(/([^?#]*)(#.*)?$/);
if (!match) {
return {}
}
return match[1].split(separator || "&").inject({}, function (hash, pair) {
if ((pair = pair.split("="))[0]) {
var key = decodeURIComponent(pair.shift());
var value = pair.length > 1 ? pair.join("=") : pair[0];
if (value != undefined) {
value = decodeURIComponent(value)
}
if (key in hash) {
if (!Object.isArray(hash[key])) {
hash[key] = [hash[key]]
}
hash[key].push(value)
} else {
hash[key] = value
}
}
return hash
})
}
function toArray() {
return this.split("")
}
function succ() {
return this.slice(0, this.length - 1) + String.fromCharCode(this.charCodeAt(this.length - 1) + 1)
}
function times(count) {
return count < 1 ? "" : new Array(count + 1).join(this)
}
function camelize() {
var parts = this.split("-"),
len = parts.length;
if (len == 1) {
return parts[0]
}
var camelized = this.charAt(0) == "-" ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) : parts[0];
for (var i = 1; i < len; i++) {
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1)
}
return camelized
}
function capitalize() {
return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase()
}
function underscore() {
return this.replace(/::/g, "/").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/-/g, "_").toLowerCase()
}
function dasherize() {
return this.replace(/_/g, "-")
}
function inspect(useDoubleQuotes) {
var escapedString = this.replace(/[\x00-\x1f\\]/g, function (character) {
if (character in String.specialChar) {
return String.specialChar[character]
}
return "\\u00" + character.charCodeAt().toPaddedString(2, 16)
});
if (useDoubleQuotes) {
return '"' + escapedString.replace(/"/g, '\\"') + '"'
}
return "'" + escapedString.replace(/'/g, "\\'") + "'"
}
function toJSON() {
return this.inspect(true)
}
function unfilterJSON(filter) {
return this.replace(filter || Prototype.JSONFilter, "$1")
}
function isJSON() {
var str = this;
if (str.blank()) {
return false
}
str = this.replace(/\\./g, "@").replace(/"[^"\\\n\r]*"/g, "");
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str)
}
function evalJSON(sanitize) {
var json = this.unfilterJSON();
try {
if (!sanitize || json.isJSON()) {
return eval("(" + json + ")")
}
} catch (e) {}
throw new SyntaxError("Badly formed JSON string: " + this.inspect())
}
function include(pattern) {
return this.indexOf(pattern) > -1
}
function startsWith(pattern) {
return this.indexOf(pattern) === 0
}
function endsWith(pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d
}
function empty() {
return this == ""
}
function blank() {
return /^\s*$/.test(this)
}
function interpolate(object, pattern) {
return new Template(this, pattern).evaluate(object)
}
return {
gsub: gsub,
sub: sub,
scan: scan,
truncate: truncate,
strip: String.prototype.trim ? String.prototype.trim : strip,
stripTags: stripTags,
stripScripts: stripScripts,
extractScripts: extractScripts,
evalScripts: evalScripts,
escapeHTML: escapeHTML,
unescapeHTML: unescapeHTML,
toQueryParams: toQueryParams,
parseQuery: toQueryParams,
toArray: toArray,
succ: succ,
times: times,
camelize: camelize,
capitalize: capitalize,
underscore: underscore,
dasherize: dasherize,
inspect: inspect,
toJSON: toJSON,
unfilterJSON: unfilterJSON,
isJSON: isJSON,
evalJSON: evalJSON,
include: include,
startsWith: startsWith,
endsWith: endsWith,
empty: empty,
blank: blank,
interpolate: interpolate
}
})());
var Template = Class.create({
initialize: function (a, b) {
this.template = a.toString();
this.pattern = b || Template.Pattern
},
evaluate: function (a) {
if (a && Object.isFunction(a.toTemplateReplacements)) {
a = a.toTemplateReplacements()
}
return this.template.gsub(this.pattern, function (d) {
if (a == null) {
return (d[1] + "")
}
var g = d[1] || "";
if (g == "\\") {
return d[2]
}
var b = a,
h = d[3];
var f = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
d = f.exec(h);
if (d == null) {
return g
}
while (d != null) {
var c = d[1].startsWith("[") ? d[2].replace(/\\\\]/g, "]") : d[1];
b = b[c];
if (null == b || "" == d[3]) {
break
}
h = h.substring("[" == d[3] ? d[1].length : d[0].length);
d = f.exec(h)
}
return g + String.interpret(b)
})
}
});
Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
var $break = {};
var Enumerable = (function () {
function c(B, A) {
var z = 0;
try {
this._each(function (D) {
B.call(A, D, z++)
})
} catch (C) {
if (C != $break) {
throw C
}
}
return this
}
function u(C, B, A) {
var z = -C,
D = [],
E = this.toArray();
if (C < 1) {
return E
}
while ((z += C) < E.length) {
D.push(E.slice(z, z + C))
}
return D.collect(B, A)
}
function b(B, A) {
B = B || Prototype.K;
var z = true;
this.each(function (D, C) {
z = z && !! B.call(A, D, C);
if (!z) {
throw $break
}
});
return z
}
function k(B, A) {
B = B || Prototype.K;
var z = false;
this.each(function (D, C) {
if (z = !! B.call(A, D, C)) {
throw $break
}
});
return z
}
function l(B, A) {
B = B || Prototype.K;
var z = [];
this.each(function (D, C) {
z.push(B.call(A, D, C))
});
return z
}
function w(B, A) {
var z;
this.each(function (D, C) {
if (B.call(A, D, C)) {
z = D;
throw $break
}
});
return z
}
function j(B, A) {
var z = [];
this.each(function (D, C) {
if (B.call(A, D, C)) {
z.push(D)
}
});
return z
}
function h(C, B, A) {
B = B || Prototype.K;
var z = [];
if (Object.isString(C)) {
C = new RegExp(RegExp.escape(C))
}
this.each(function (E, D) {
if (C.match(E)) {
z.push(B.call(A, E, D))
}
});
return z
}
function a(z) {
if (Object.isFunction(this.indexOf)) {
if (this.indexOf(z) != -1) {
return true
}
}
var A = false;
this.each(function (B) {
if (B == z) {
A = true;
throw $break
}
});
return A
}
function t(A, z) {
z = Object.isUndefined(z) ? null : z;
return this.eachSlice(A, function (B) {
while (B.length < A) {
B.push(z)
}
return B
})
}
function n(z, B, A) {
this.each(function (D, C) {
z = B.call(A, z, D, C)
});
return z
}
function y(A) {
var z = $A(arguments).slice(1);
return this.map(function (B) {
return B[A].apply(B, z)
})
}
function r(B, A) {
B = B || Prototype.K;
var z;
this.each(function (D, C) {
D = B.call(A, D, C);
if (z == null || D >= z) {
z = D
}
});
return z
}
function p(B, A) {
B = B || Prototype.K;
var z;
this.each(function (D, C) {
D = B.call(A, D, C);
if (z == null || D < z) {
z = D
}
});
return z
}
function f(C, A) {
C = C || Prototype.K;
var B = [],
z = [];
this.each(function (E, D) {
(C.call(A, E, D) ? B : z).push(E)
});
return [B, z]
}
function g(A) {
var z = [];
this.each(function (B) {
z.push(B[A])
});
return z
}
function d(B, A) {
var z = [];
this.each(function (D, C) {
if (!B.call(A, D, C)) {
z.push(D)
}
});
return z
}
function o(A, z) {
return this.map(function (C, B) {
return {
value: C,
criteria: A.call(z, C, B)
}
}).sort(function (E, D) {
var C = E.criteria,
B = D.criteria;
return C < B ? -1 : C > B ? 1 : 0
}).pluck("value")
}
function q() {
return this.map()
}
function v() {
var A = Prototype.K,
z = $A(arguments);
if (Object.isFunction(z.last())) {
A = z.pop()
}
var B = [this].concat(z).map($A);
return this.map(function (D, C) {
return A(B.pluck(C))
})
}
function m() {
return this.toArray().length
}
function x() {
return "#<Enumerable:" + this.toArray().inspect() + ">"
}
return {
each: c,
eachSlice: u,
all: b,
every: b,
any: k,
some: k,
collect: l,
map: l,
detect: w,
findAll: j,
select: j,
filter: j,
grep: h,
include: a,
member: a,
inGroupsOf: t,
inject: n,
invoke: y,
max: r,
min: p,
partition: f,
pluck: g,
reject: d,
sortBy: o,
toArray: q,
entries: q,
zip: v,
size: m,
inspect: x,
find: w
}
})();
function $A(c) {
if (!c) {
return []
}
if ("toArray" in Object(c)) {
return c.toArray()
}
var b = c.length || 0,
a = new Array(b);
while (b--) {
a[b] = c[b]
}
return a
}
function $w(a) {
if (!Object.isString(a)) {
return []
}
a = a.strip();
return a ? a.split(/\s+/) : []
}
Array.from = $A;
(function () {
var v = Array.prototype,
o = v.slice,
q = v.forEach;
function b(z) {
for (var y = 0, A = this.length; y < A; y++) {
z(this[y])
}
}
if (!q) {
q = b
}
function n() {
this.length = 0;
return this
}
function d() {
return this[0]
}
function h() {
return this[this.length - 1]
}
function k() {
return this.select(function (y) {
return y != null
})
}
function x() {
return this.inject([], function (z, y) {
if (Object.isArray(y)) {
return z.concat(y.flatten())
}
z.push(y);
return z
})
}
function j() {
var y = o.call(arguments, 0);
return this.select(function (z) {
return !y.include(z)
})
}
function g(y) {
return (y !== false ? this : this.toArray())._reverse()
}
function m(y) {
return this.inject([], function (B, A, z) {
if (0 == z || (y ? B.last() != A : !B.include(A))) {
B.push(A)
}
return B
})
}
function r(y) {
return this.uniq().findAll(function (z) {
return y.detect(function (A) {
return z === A
})
})
}
function t() {
return o.call(this, 0)
}
function l() {
return this.length
}
function w() {
return "[" + this.map(Object.inspect).join(", ") + "]"
}
function u() {
var y = [];
this.each(function (z) {
var A = Object.toJSON(z);
if (!Object.isUndefined(A)) {
y.push(A)
}
});
return "[" + y.join(", ") + "]"
}
function a(A, y) {
y || (y = 0);
var z = this.length;
if (y < 0) {
y = z + y
}
for (; y < z; y++) {
if (this[y] === A) {
return y
}
}
return -1
}
function p(z, y) {
y = isNaN(y) ? this.length : (y < 0 ? this.length + y : y) + 1;
var A = this.slice(0, y).reverse().indexOf(z);
return (A < 0) ? A : y - A - 1
}
function c() {
var D = o.call(this, 0),
B;
for (var z = 0, A = arguments.length; z < A; z++) {
B = arguments[z];
if (Object.isArray(B) && !("callee" in B)) {
for (var y = 0, C = B.length; y < C; y++) {
D.push(B[y])
}
} else {
D.push(B)
}
}
return D
}
Object.extend(v, Enumerable);
if (!v._reverse) {
v._reverse = v.reverse
}
Object.extend(v, {
_each: q,
clear: n,
first: d,
last: h,
compact: k,
flatten: x,
without: j,
reverse: g,
uniq: m,
intersect: r,
clone: t,
toArray: t,
size: l,
inspect: w,
toJSON: u
});
var f = (function () {
return [].concat(arguments)[0][0] !== 1
})(1, 2);
if (f) {
v.concat = c
}
if (!v.indexOf) {
v.indexOf = a
}
if (!v.lastIndexOf) {
v.lastIndexOf = p
}
})();
function $H(a) {
return new Hash(a)
}
var Hash = Class.create(Enumerable, (function () {
function f(t) {
this._object = Object.isHash(t) ? t.toObject() : Object.clone(t)
}
function g(u) {
for (var t in this._object) {
var v = this._object[t],
w = [t, v];
w.key = t;
w.value = v;
u(w)
}
}
function m(t, u) {
return this._object[t] = u
}
function c(t) {
if (this._object[t] !== Object.prototype[t]) {
return this._object[t]
}
}
function p(t) {
var u = this._object[t];
delete this._object[t];
return u
}
function r() {
return Object.clone(this._object)
}
function q() {
return this.pluck("key")
}
function o() {
return this.pluck("value")
}
function h(u) {
var t = this.detect(function (v) {
return v.value === u
});
return t && t.key
}
function k(t) {
return this.clone().update(t)
}
function d(t) {
return new Hash(t).inject(this, function (u, v) {
u.set(v.key, v.value);
return u
})
}
function b(t, u) {
if (Object.isUndefined(u)) {
return t
}
return t + "=" + encodeURIComponent(String.interpret(u))
}
function a() {
return this.inject([], function (v, w) {
var u = encodeURIComponent(w.key),
t = w.value;
if (t && typeof t == "object") {
if (Object.isArray(t)) {
return v.concat(t.map(b.curry(u)))
}
} else {
v.push(b(u, t))
}
return v
}).join("&")
}
function n() {
return "#<Hash:{" + this.map(function (t) {
return t.map(Object.inspect).join(": ")
}).join(", ") + "}>"
}
function l() {
return Object.toJSON(this.toObject())
}
function j() {
return new Hash(this)
}
return {
initialize: f,
_each: g,
set: m,
get: c,
unset: p,
toObject: r,
toTemplateReplacements: r,
keys: q,
values: o,
index: h,
merge: k,
update: d,
toQueryString: a,
inspect: n,
toJSON: l,
clone: j
}
})());
Hash.from = $H;
Object.extend(Number.prototype, (function () {
function d() {
return this.toPaddedString(2, 16)
}
function f() {
return this + 1
}
function a(m, l) {
$R(0, this, true).each(m, l);
return this
}
function b(n, m) {
var l = this.toString(m || 10);
return "0".times(n - l.length) + l
}
function g() {
return isFinite(this) ? this.toString() : "null"
}
function k() {
return Math.abs(this)
}
function j() {
return Math.round(this)
}
function h() {
return Math.ceil(this)
}
function c() {
return Math.floor(this)
}
return {
toColorPart: d,
succ: f,
times: a,
toPaddedString: b,
toJSON: g,
abs: k,
round: j,
ceil: h,
floor: c
}
})());
function $R(c, a, b) {
return new ObjectRange(c, a, b)
}
var ObjectRange = Class.create(Enumerable, (function () {
function b(g, d, f) {
this.start = g;
this.end = d;
this.exclusive = f
}
function c(d) {
var f = this.start;
while (this.include(f)) {
d(f);
f = f.succ()
}
}
function a(d) {
if (d < this.start) {
return false
}
if (this.exclusive) {
return d < this.end
}
return d <= this.end
}
return {
initialize: b,
_each: c,
include: a
}
})());
var Ajax = {
getTransport: function () {
return Try.these(function () {
return new XMLHttpRequest()
}, function () {
return new ActiveXObject("Msxml2.XMLHTTP")
}, function () {
return new ActiveXObject("Microsoft.XMLHTTP")
}) || false
},
activeRequestCount: 0
};
Ajax.Responders = {
responders: [],
_each: function (a) {
this.responders._each(a)
},
register: function (a) {
if (!this.include(a)) {
this.responders.push(a)
}
},
unregister: function (a) {
this.responders = this.responders.without(a)
},
dispatch: function (d, b, c, a) {
this.each(function (f) {
if (Object.isFunction(f[d])) {
try {
f[d].apply(f, [b, c, a])
} catch (g) {}
}
})
}
};
Object.extend(Ajax.Responders, Enumerable);
Ajax.Responders.register({
onCreate: function () {
Ajax.activeRequestCount++
},
onComplete: function () {
Ajax.activeRequestCount--
}
});
Ajax.Base = Class.create({
initialize: function (a) {
this.options = {
method: "post",
asynchronous: true,
contentType: "application/x-www-form-urlencoded",
encoding: "UTF-8",
parameters: "",
evalJSON: true,
evalJS: true
};
Object.extend(this.options, a || {});
this.options.method = this.options.method.toLowerCase();
if (Object.isString(this.options.parameters)) {
this.options.parameters = this.options.parameters.toQueryParams()
} else {
if (Object.isHash(this.options.parameters)) {
this.options.parameters = this.options.parameters.toObject()
}
}
}
});
Ajax.Request = Class.create(Ajax.Base, {
_complete: false,
initialize: function ($super, b, a) {
$super(a);
this.transport = Ajax.getTransport();
this.request(b)
},
request: function (b) {
this.url = b;
this.method = this.options.method;
var d = Object.clone(this.options.parameters);
if (!["get", "post"].include(this.method)) {
d._method = this.method;
this.method = "post"
}
this.parameters = d;
if (d = Object.toQueryString(d)) {
if (this.method == "get") {
this.url += (this.url.include("?") ? "&" : "?") + d
} else {
if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
d += "&_="
}
}
}
try {
var a = new Ajax.Response(this);
if (this.options.onCreate) {
this.options.onCreate(a)
}
Ajax.Responders.dispatch("onCreate", this, a);
this.transport.open(this.method.toUpperCase(), this.url, this.options.asynchronous);
if (this.options.asynchronous) {
this.respondToReadyState.bind(this).defer(1)
}
this.transport.onreadystatechange = this.onStateChange.bind(this);
this.setRequestHeaders();
this.body = this.method == "post" ? (this.options.postBody || d) : null;
this.transport.send(this.body);
if (!this.options.asynchronous && this.transport.overrideMimeType) {
this.onStateChange()
}
} catch (c) {
this.dispatchException(c)
}
},
onStateChange: function () {
var a = this.transport.readyState;
if (a > 1 && !((a == 4) && this._complete)) {
this.respondToReadyState(this.transport.readyState)
}
},
setRequestHeaders: function () {
var f = {
"X-Requested-With": "XMLHttpRequest",
"X-Prototype-Version": Prototype.Version,
Accept: "text/javascript, text/html, application/xml, text/xml, */*"
};
if (this.method == "post") {
f["Content-type"] = this.options.contentType + (this.options.encoding ? "; charset=" + this.options.encoding : "");
if (this.transport.overrideMimeType && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0, 2005])[1] < 2005) {
f.Connection = "close"
}
}
if (typeof this.options.requestHeaders == "object") {
var c = this.options.requestHeaders;
if (Object.isFunction(c.push)) {
for (var b = 0, d = c.length; b < d; b += 2) {
f[c[b]] = c[b + 1]
}
} else {
$H(c).each(function (g) {
f[g.key] = g.value
})
}
}
for (var a in f) {
this.transport.setRequestHeader(a, f[a])
}
},
success: function () {
var a = this.getStatus();
return !a || (a >= 200 && a < 300)
},
getStatus: function () {
try {
return this.transport.status || 0
} catch (a) {
return 0
}
},
respondToReadyState: function (a) {
var c = Ajax.Request.Events[a],
b = new Ajax.Response(this);
if (c == "Complete") {
try {
this._complete = true;
(this.options["on" + b.status] || this.options["on" + (this.success() ? "Success" : "Failure")] || Prototype.emptyFunction)(b, b.headerJSON)
} catch (d) {
this.dispatchException(d)
}
var f = b.getHeader("Content-type");
if (this.options.evalJS == "force" || (this.options.evalJS && this.isSameOrigin() && f && f.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) {
this.evalResponse()
}
}
try {
(this.options["on" + c] || Prototype.emptyFunction)(b, b.headerJSON);
Ajax.Responders.dispatch("on" + c, this, b, b.headerJSON)
} catch (d) {
this.dispatchException(d)
}
if (c == "Complete") {
this.transport.onreadystatechange = Prototype.emptyFunction
}
},
isSameOrigin: function () {
var a = this.url.match(/^\s*https?:\/\/[^\/]*/);
return !a || (a[0] == "#{protocol}//#{domain}#{port}".interpolate({
protocol: location.protocol,
domain: document.domain,
port: location.port ? ":" + location.port : ""
}))
},
getHeader: function (a) {
try {
return this.transport.getResponseHeader(a) || null
} catch (b) {
return null
}
},
evalResponse: function () {
try {
return eval((this.transport.responseText || "").unfilterJSON())
} catch (e) {
this.dispatchException(e)
}
},
dispatchException: function (a) {
(this.options.onException || Prototype.emptyFunction)(this, a);
Ajax.Responders.dispatch("onException", this, a)
}
});
Ajax.Request.Events = ["Uninitialized", "Loading", "Loaded", "Interactive", "Complete"];
Ajax.Response = Class.create({
initialize: function (c) {
this.request = c;
var d = this.transport = c.transport,
a = this.readyState = d.readyState;
if ((a > 2 && !Prototype.Browser.IE) || a == 4) {
this.status = this.getStatus();
this.statusText = this.getStatusText();
this.responseText = String.interpret(d.responseText);
this.headerJSON = this._getHeaderJSON()
}
if (a == 4) {
var b = d.responseXML;
this.responseXML = Object.isUndefined(b) ? null : b;
this.responseJSON = this._getResponseJSON()
}
},
status: 0,
statusText: "",
getStatus: Ajax.Request.prototype.getStatus,
getStatusText: function () {
try {
return this.transport.statusText || ""
} catch (a) {
return ""
}
},
getHeader: Ajax.Request.prototype.getHeader,
getAllHeaders: function () {
try {
return this.getAllResponseHeaders()
} catch (a) {
return null
}
},
getResponseHeader: function (a) {
return this.transport.getResponseHeader(a)
},
getAllResponseHeaders: function () {
return this.transport.getAllResponseHeaders()
},
_getHeaderJSON: function () {
var a = this.getHeader("X-JSON");
if (!a) {
return null
}
a = decodeURIComponent(escape(a));
try {
return a.evalJSON(this.request.options.sanitizeJSON || !this.request.isSameOrigin())
} catch (b) {
this.request.dispatchException(b)
}
},
_getResponseJSON: function () {
var a = this.request.options;
if (!a.evalJSON || (a.evalJSON != "force" && !(this.getHeader("Content-type") || "").include("application/json")) || this.responseText.blank()) {
return null
}
try {
return this.responseText.evalJSON(a.sanitizeJSON || !this.request.isSameOrigin())
} catch (b) {
this.request.dispatchException(b)
}
}
});
Ajax.Updater = Class.create(Ajax.Request, {
initialize: function ($super, a, c, b) {
this.container = {
success: (a.success || a),
failure: (a.failure || (a.success ? null : a))
};
b = Object.clone(b);
var d = b.onComplete;
b.onComplete = (function (f, g) {
this.updateContent(f.responseText);
if (Object.isFunction(d)) {
d(f, g)
}
}).bind(this);
$super(c, b)
},
updateContent: function (d) {
var c = this.container[this.success() ? "success" : "failure"],
a = this.options;
if (!a.evalScripts) {
d = d.stripScripts()
}
if (c = $(c)) {
if (a.insertion) {
if (Object.isString(a.insertion)) {
var b = {};
b[a.insertion] = d;
c.insert(b)
} else {
a.insertion(c, d)
}
} else {
c.update(d)
}
}
}
});
Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function ($super, a, c, b) {
$super(b);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = {};
this.container = a;
this.url = c;
this.start()
},
start: function () {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent()
},
stop: function () {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments)
},
updateComplete: function (a) {
if (this.options.decay) {
this.decay = (a.responseText == this.lastText ? this.decay * this.options.decay : 1);
this.lastText = a.responseText
}
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency)
},
onTimerEvent: function () {
this.updater = new Ajax.Updater(this.container, this.url, this.options)
}
});
function $(b) {
if (arguments.length > 1) {
for (var a = 0, d = [], c = arguments.length; a < c; a++) {
d.push($(arguments[a]))
}
return d
}
if (Object.isString(b)) {
b = document.getElementById(b)
}
return Element.extend(b)
}
if (Prototype.BrowserFeatures.XPath) {
document._getElementsByXPath = function (g, a) {
var c = [];
var f = document.evaluate(g, $(a) || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var b = 0, d = f.snapshotLength; b < d; b++) {
c.push(Element.extend(f.snapshotItem(b)))
}
return c
}
}
if (!window.Node) {
var Node = {}
}
if (!Node.ELEMENT_NODE) {
Object.extend(Node, {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
})
}(function (c) {
var b = (function () {
var g = document.createElement("form");
var f = document.createElement("input");
var d = document.documentElement;
f.setAttribute("name", "test");
g.appendChild(f);
d.appendChild(g);
var h = g.elements ? (typeof g.elements.test == "undefined") : null;
d.removeChild(g);
g = f = null;
return h
})();
var a = c.Element;
c.Element = function (g, f) {
f = f || {};
g = g.toLowerCase();
var d = Element.cache;
if (b && f.name) {
g = "<" + g + ' name="' + f.name + '">';
delete f.name;
return Element.writeAttribute(document.createElement(g), f)
}
if (!d[g]) {
d[g] = Element.extend(document.createElement(g))
}
return Element.writeAttribute(d[g].cloneNode(false), f)
};
Object.extend(c.Element, a || {});
if (a) {
c.Element.prototype = a.prototype
}
})(this);
Element.cache = {};
Element.idCounter = 1;
Element.Methods = {
visible: function (a) {
return $(a).style.display != "none"
},
toggle: function (a) {
a = $(a);
Element[Element.visible(a) ? "hide" : "show"](a);
return a
},
hide: function (a) {
a = $(a);
a.style.display = "none";
return a
},
show: function (a) {
a = $(a);
a.style.display = "";
return a
},
remove: function (a) {
a = $(a);
a.parentNode.removeChild(a);
return a
},
update: (function () {
var b = (function () {
var f = document.createElement("select"),
g = true;
f.innerHTML = '<option value="test">test</option>';
if (f.options && f.options[0]) {
g = f.options[0].nodeName.toUpperCase() !== "OPTION"
}
f = null;
return g
})();
var a = (function () {
try {
var f = document.createElement("table");
if (f && f.tBodies) {
f.innerHTML = "<tbody><tr><td>test</td></tr></tbody>";
var h = typeof f.tBodies[0] == "undefined";
f = null;
return h
}
} catch (g) {
return true
}
})();
var d = (function () {
var f = document.createElement("script"),
h = false;
try {
f.appendChild(document.createTextNode(""));
h = !f.firstChild || f.firstChild && f.firstChild.nodeType !== 3
} catch (g) {
h = true
}
f = null;
return h
})();
function c(g, h) {
g = $(g);
if (h && h.toElement) {
h = h.toElement()
}
if (Object.isElement(h)) {
return g.update().insert(h)
}
h = Object.toHTML(h);
var f = g.tagName.toUpperCase();
if (f === "SCRIPT" && d) {
g.text = h;
return g
}
if (b || a) {
if (f in Element._insertionTranslations.tags) {
while (g.firstChild) {
g.removeChild(g.firstChild)
}
Element._getContentFromAnonymousElement(f, h.stripScripts()).each(function (j) {
g.appendChild(j)
})
} else {
g.innerHTML = h.stripScripts()
}
} else {
g.innerHTML = h.stripScripts()
}
h.evalScripts.bind(h).defer();
return g
}
return c
})(),
replace: function (b, c) {
b = $(b);
if (c && c.toElement) {
c = c.toElement()
} else {
if (!Object.isElement(c)) {
c = Object.toHTML(c);
var a = b.ownerDocument.createRange();
a.selectNode(b);
c.evalScripts.bind(c).defer();
c = a.createContextualFragment(c.stripScripts())
}
}
b.parentNode.replaceChild(c, b);
return b
},
insert: function (c, f) {
c = $(c);
if (Object.isString(f) || Object.isNumber(f) || Object.isElement(f) || (f && (f.toElement || f.toHTML))) {
f = {
bottom: f
}
}
var d, g, b, h;
for (var a in f) {
d = f[a];
a = a.toLowerCase();
g = Element._insertionTranslations[a];
if (d && d.toElement) {
d = d.toElement()
}
if (Object.isElement(d)) {
g(c, d);
continue
}
d = Object.toHTML(d);
b = ((a == "before" || a == "after") ? c.parentNode : c).tagName.toUpperCase();
h = Element._getContentFromAnonymousElement(b, d.stripScripts());
if (a == "top" || a == "after") {
h.reverse()
}
h.each(g.curry(c));
d.evalScripts.bind(d).defer()
}
return c
},
wrap: function (b, c, a) {
b = $(b);
if (Object.isElement(c)) {
$(c).writeAttribute(a || {})
} else {
if (Object.isString(c)) {
c = new Element(c, a)
} else {
c = new Element("div", c)
}
}
if (b.parentNode) {
b.parentNode.replaceChild(c, b)
}
c.appendChild(b);
return c
},
inspect: function (b) {
b = $(b);
var a = "<" + b.tagName.toLowerCase();
$H({
id: "id",
className: "class"
}).each(function (g) {
var f = g.first(),
c = g.last();
var d = (b[f] || "").toString();
if (d) {
a += " " + c + "=" + d.inspect(true)
}
});
return a + ">"
},
recursivelyCollect: function (a, c) {
a = $(a);
var b = [];
while (a = a[c]) {
if (a.nodeType == 1) {
b.push(Element.extend(a))
}
}
return b
},
ancestors: function (a) {
return Element.recursivelyCollect(a, "parentNode")
},
descendants: function (a) {
return Element.select(a, "*")
},
firstDescendant: function (a) {
a = $(a).firstChild;
while (a && a.nodeType != 1) {
a = a.nextSibling
}
return $(a)
},
immediateDescendants: function (a) {
if (!(a = $(a).firstChild)) {
return []
}
while (a && a.nodeType != 1) {
a = a.nextSibling
}
if (a) {
return [a].concat($(a).nextSiblings())
}
return []
},
previousSiblings: function (a) {
return Element.recursivelyCollect(a, "previousSibling")
},
nextSiblings: function (a) {
return Element.recursivelyCollect(a, "nextSibling")
},
siblings: function (a) {
a = $(a);
return Element.previousSiblings(a).reverse().concat(Element.nextSiblings(a))
},
match: function (b, a) {
if (Object.isString(a)) {
a = new Selector(a)
}
return a.match($(b))
},
up: function (b, d, a) {
b = $(b);
if (arguments.length == 1) {
return $(b.parentNode)
}
var c = Element.ancestors(b);
return Object.isNumber(d) ? c[d] : Selector.findElement(c, d, a)
},
down: function (b, c, a) {
b = $(b);
if (arguments.length == 1) {
return Element.firstDescendant(b)
}
return Object.isNumber(c) ? Element.descendants(b)[c] : Element.select(b, c)[a || 0]
},
previous: function (b, d, a) {
b = $(b);
if (arguments.length == 1) {
return $(Selector.handlers.previousElementSibling(b))
}
var c = Element.previousSiblings(b);
return Object.isNumber(d) ? c[d] : Selector.findElement(c, d, a)
},
next: function (c, d, b) {
c = $(c);
if (arguments.length == 1) {
return $(Selector.handlers.nextElementSibling(c))
}
var a = Element.nextSiblings(c);
return Object.isNumber(d) ? a[d] : Selector.findElement(a, d, b)
},
select: function (b) {
var a = Array.prototype.slice.call(arguments, 1);
return Selector.findChildElements(b, a)
},
adjacent: function (b) {
var a = Array.prototype.slice.call(arguments, 1);
return Selector.findChildElements(b.parentNode, a).without(b)
},
identify: function (a) {
a = $(a);
var b = Element.readAttribute(a, "id");
if (b) {
return b
}
do {
b = "anonymous_element_" + Element.idCounter++
} while ($(b));
Element.writeAttribute(a, "id", b);
return b
},
readAttribute: function (c, a) {
c = $(c);
if (Prototype.Browser.IE) {
var b = Element._attributeTranslations.read;
if (b.values[a]) {
return b.values[a](c, a)
}
if (b.names[a]) {
a = b.names[a]
}
if (a.include(":")) {
return (!c.attributes || !c.attributes[a]) ? null : c.attributes[a].value
}
}
return c.getAttribute(a)
},
writeAttribute: function (f, c, g) {
f = $(f);
var b = {},
d = Element._attributeTranslations.write;
if (typeof c == "object") {
b = c
} else {
b[c] = Object.isUndefined(g) ? true : g
}
for (var a in b) {
c = d.names[a] || a;
g = b[a];
if (d.values[a]) {
c = d.values[a](f, g)
}
if (g === false || g === null) {
f.removeAttribute(c)
} else {
if (g === true) {
f.setAttribute(c, c)
} else {
f.setAttribute(c, g)
}
}
}
return f
},
getHeight: function (a) {
return Element.getDimensions(a).height
},
getWidth: function (a) {
return Element.getDimensions(a).width
},
classNames: function (a) {
return new Element.ClassNames(a)
},
hasClassName: function (a, b) {
if (!(a = $(a))) {
return
}
var c = a.className;
return (c.length > 0 && (c == b || new RegExp("(^|\\s)" + b + "(\\s|$)").test(c)))
},
addClassName: function (a, b) {
if (!(a = $(a))) {
return
}
if (!Element.hasClassName(a, b)) {
a.className += (a.className ? " " : "") + b
}
return a
},
removeClassName: function (a, b) {
if (!(a = $(a))) {
return
}
a.className = a.className.replace(new RegExp("(^|\\s+)" + b + "(\\s+|$)"), " ").strip();
return a
},
toggleClassName: function (a, b) {
if (!(a = $(a))) {
return
}
return Element[Element.hasClassName(a, b) ? "removeClassName" : "addClassName"](a, b)
},
cleanWhitespace: function (b) {
b = $(b);
var c = b.firstChild;
while (c) {
var a = c.nextSibling;
if (c.nodeType == 3 && !/\S/.test(c.nodeValue)) {
b.removeChild(c)
}
c = a
}
return b
},
empty: function (a) {
return $(a).innerHTML.blank()
},
descendantOf: function (b, a) {
b = $(b), a = $(a);
if (b.compareDocumentPosition) {
return (b.compareDocumentPosition(a) & 8) === 8
}
if (a.contains) {
return a.contains(b) && a !== b
}
while (b = b.parentNode) {
if (b == a) {
return true
}
}
return false
},
scrollTo: function (a) {
a = $(a);
var b = Element.cumulativeOffset(a);
window.scrollTo(b[0], b[1]);
return a
},
getStyle: function (b, c) {
b = $(b);
c = c == "float" ? "cssFloat" : c.camelize();
var d = b.style[c];
if (!d || d == "auto") {
var a = document.defaultView.getComputedStyle(b, null);
d = a ? a[c] : null
}
if (c == "opacity") {
return d ? parseFloat(d) : 1
}
return d == "auto" ? null : d
},
getOpacity: function (a) {
return $(a).getStyle("opacity")
},
setStyle: function (b, c) {
b = $(b);
var f = b.style,
a;
if (Object.isString(c)) {
b.style.cssText += ";" + c;
return c.include("opacity") ? b.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]) : b
}
for (var d in c) {
if (d == "opacity") {
b.setOpacity(c[d])
} else {
f[(d == "float" || d == "cssFloat") ? (Object.isUndefined(f.styleFloat) ? "cssFloat" : "styleFloat") : d] = c[d]
}
}
return b
},
setOpacity: function (a, b) {
a = $(a);
a.style.opacity = (b == 1 || b === "") ? "" : (b < 0.00001) ? 0 : b;
return a
},
getDimensions: function (c) {
c = $(c);
var h = Element.getStyle(c, "display");
if (h != "none" && h != null) {
return {
width: c.offsetWidth,
height: c.offsetHeight
}
}
var b = c.style;
var g = b.visibility;
var d = b.position;
var a = b.display;
b.visibility = "hidden";
if (d != "fixed") {
b.position = "absolute"
}
b.display = "block";
var j = c.clientWidth;
var f = c.clientHeight;
b.display = a;
b.position = d;
b.visibility = g;
return {
width: j,
height: f
}
},
makePositioned: function (a) {
a = $(a);
var b = Element.getStyle(a, "position");
if (b == "static" || !b) {
a._madePositioned = true;
a.style.position = "relative";
if (Prototype.Browser.Opera) {
a.style.top = 0;
a.style.left = 0
}
}
return a
},
undoPositioned: function (a) {
a = $(a);
if (a._madePositioned) {
a._madePositioned = undefined;
a.style.position = a.style.top = a.style.left = a.style.bottom = a.style.right = ""
}
return a
},
makeClipping: function (a) {
a = $(a);
if (a._overflow) {
return a
}
a._overflow = Element.getStyle(a, "overflow") || "auto";
if (a._overflow !== "hidden") {
a.style.overflow = "hidden"
}
return a
},
undoClipping: function (a) {
a = $(a);
if (!a._overflow) {
return a
}
a.style.overflow = a._overflow == "auto" ? "" : a._overflow;
a._overflow = null;
return a
},
cumulativeOffset: function (b) {
var a = 0,
c = 0;
do {
a += b.offsetTop || 0;
c += b.offsetLeft || 0;
b = b.offsetParent
} while (b);
return Element._returnOffset(c, a)
},
positionedOffset: function (b) {
var a = 0,
d = 0;
do {
a += b.offsetTop || 0;
d += b.offsetLeft || 0;
b = b.offsetParent;
if (b) {
if (b.tagName.toUpperCase() == "BODY") {
break
}
var c = Element.getStyle(b, "position");
if (c !== "static") {
break
}
}
} while (b);
return Element._returnOffset(d, a)
},
absolutize: function (b) {
b = $(b);
if (Element.getStyle(b, "position") == "absolute") {
return b
}
var d = Element.positionedOffset(b);
var g = d[1];
var f = d[0];
var c = b.clientWidth;
var a = b.clientHeight;
b._originalLeft = f - parseFloat(b.style.left || 0);
b._originalTop = g - parseFloat(b.style.top || 0);
b._originalWidth = b.style.width;
b._originalHeight = b.style.height;
b.style.position = "absolute";
b.style.top = g + "px";
b.style.left = f + "px";
b.style.width = c + "px";
b.style.height = a + "px";
return b
},
relativize: function (a) {
a = $(a);
if (Element.getStyle(a, "position") == "relative") {
return a
}
a.style.position = "relative";
var c = parseFloat(a.style.top || 0) - (a._originalTop || 0);
var b = parseFloat(a.style.left || 0) - (a._originalLeft || 0);
a.style.top = c + "px";
a.style.left = b + "px";
a.style.height = a._originalHeight;
a.style.width = a._originalWidth;
return a
},
cumulativeScrollOffset: function (b) {
var a = 0,
c = 0;
do {
a += b.scrollTop || 0;
c += b.scrollLeft || 0;
b = b.parentNode
} while (b);
return Element._returnOffset(c, a)
},
getOffsetParent: function (a) {
if (a.offsetParent) {
return $(a.offsetParent)
}
if (a == document.body) {
return $(a)
}
while ((a = a.parentNode) && a != document.body) {
if (Element.getStyle(a, "position") != "static") {
return $(a)
}
}
return $(document.body)
},
viewportOffset: function (d) {
var a = 0,
c = 0;
var b = d;
do {
a += b.offsetTop || 0;
c += b.offsetLeft || 0;
if (b.offsetParent == document.body && Element.getStyle(b, "position") == "absolute") {
break
}
} while (b = b.offsetParent);
b = d;
do {
if (!Prototype.Browser.Opera || (b.tagName && (b.tagName.toUpperCase() == "BODY"))) {
a -= b.scrollTop || 0;
c -= b.scrollLeft || 0
}
} while (b = b.parentNode);
return Element._returnOffset(c, a)
},
clonePosition: function (b, d) {
var a = Object.extend({
setLeft: true,
setTop: true,
setWidth: true,
setHeight: true,
offsetTop: 0,
offsetLeft: 0
}, arguments[2] || {});
d = $(d);
var f = Element.viewportOffset(d);
b = $(b);
var g = [0, 0];
var c = null;
if (Element.getStyle(b, "position") == "absolute") {
c = Element.getOffsetParent(b);
g = Element.viewportOffset(c)
}
if (c == document.body) {
g[0] -= document.body.offsetLeft;
g[1] -= document.body.offsetTop
}
if (a.setLeft) {
b.style.left = (f[0] - g[0] + a.offsetLeft) + "px"
}
if (a.setTop) {
b.style.top = (f[1] - g[1] + a.offsetTop) + "px"
}
if (a.setWidth) {
b.style.width = d.offsetWidth + "px"
}
if (a.setHeight) {
b.style.height = d.offsetHeight + "px"
}
return b
}
};
Object.extend(Element.Methods, {
getElementsBySelector: Element.Methods.select,
childElements: Element.Methods.immediateDescendants
});
Element._attributeTranslations = {
write: {
names: {
className: "class",
htmlFor: "for"
},
values: {}
}
};
if (Prototype.Browser.Opera) {
Element.Methods.getStyle = Element.Methods.getStyle.wrap(function (d, b, c) {
switch (c) {
case "left":
case "top":
case "right":
case "bottom":
if (d(b, "position") === "static") {
return null
}
case "height":
case "width":
if (!Element.visible(b)) {
return null
}
var f = parseInt(d(b, c), 10);
if (f !== b["offset" + c.capitalize()]) {
return f + "px"
}
var a;
if (c === "height") {
a = ["border-top-width", "padding-top", "padding-bottom", "border-bottom-width"]
} else {
a = ["border-left-width", "padding-left", "padding-right", "border-right-width"]
}
return a.inject(f, function (g, h) {
var j = d(b, h);
return j === null ? g : g - parseInt(j, 10)
}) + "px";
default:
return d(b, c)
}
});
Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(function (c, a, b) {
if (b === "title") {
return a.title
}
return c(a, b)
})
} else {
if (Prototype.Browser.IE) {
Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(function (c, b) {
b = $(b);
try {
b.offsetParent
} catch (f) {
return $(document.body)
}
var a = b.getStyle("position");
if (a !== "static") {
return c(b)
}
b.setStyle({
position: "relative"
});
var d = c(b);
b.setStyle({
position: a
});
return d
});
$w("positionedOffset viewportOffset").each(function (a) {
Element.Methods[a] = Element.Methods[a].wrap(function (f, c) {
c = $(c);
try {
c.offsetParent
} catch (h) {
return Element._returnOffset(0, 0)
}
var b = c.getStyle("position");
if (b !== "static") {
return f(c)
}
var d = c.getOffsetParent();
if (d && d.getStyle("position") === "fixed") {
d.setStyle({
zoom: 1
})
}
c.setStyle({
position: "relative"
});
var g = f(c);
c.setStyle({
position: b
});
return g
})
});
Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(function (b, a) {
try {
a.offsetParent
} catch (c) {
return Element._returnOffset(0, 0)
}
return b(a)
});
Element.Methods.getStyle = function (a, b) {
a = $(a);
b = (b == "float" || b == "cssFloat") ? "styleFloat" : b.camelize();
var c = a.style[b];
if (!c && a.currentStyle) {
c = a.currentStyle[b]
}
if (b == "opacity") {
if (c = (a.getStyle("filter") || "").match(/alpha\(opacity=(.*)\)/)) {
if (c[1]) {
return parseFloat(c[1]) / 100
}
}
return 1
}
if (c == "auto") {
if ((b == "width" || b == "height") && (a.getStyle("display") != "none")) {
return a["offset" + b.capitalize()] + "px"
}
return null
}
return c
};
Element.Methods.setOpacity = function (b, f) {
function g(h) {
return h.replace(/alpha\([^\)]*\)/gi, "")
}
b = $(b);
var a = b.currentStyle;
if ((a && !a.hasLayout) || (!a && b.style.zoom == "normal")) {
b.style.zoom = 1
}
var d = b.getStyle("filter"),
c = b.style;
if (f == 1 || f === "") {
(d = g(d)) ? c.filter = d : c.removeAttribute("filter");
return b
} else {
if (f < 0.00001) {
f = 0
}
}
c.filter = g(d) + "alpha(opacity=" + (f * 100) + ")";
return b
};
Element._attributeTranslations = (function () {
var b = "className";
var a = "for";
var c = document.createElement("div");
c.setAttribute(b, "x");
if (c.className !== "x") {
c.setAttribute("class", "x");
if (c.className === "x") {
b = "class"
}
}
c = null;
c = document.createElement("label");
c.setAttribute(a, "x");
if (c.htmlFor !== "x") {
c.setAttribute("htmlFor", "x");
if (c.htmlFor === "x") {
a = "htmlFor"
}
}
c = null;
return {
read: {
names: {
"class": b,
className: b,
"for": a,
htmlFor: a
},
values: {
_getAttr: function (d, f) {
return d.getAttribute(f)
},
_getAttr2: function (d, f) {
return d.getAttribute(f, 2)
},
_getAttrNode: function (d, g) {
var f = d.getAttributeNode(g);
return f ? f.value : ""
},
_getEv: (function () {
var d = document.createElement("div");
d.onclick = Prototype.emptyFunction;
var h = d.getAttribute("onclick");
var g;
if (String(h).indexOf("{") > -1) {
g = function (f, j) {
j = f.getAttribute(j);
if (!j) {
return null
}
j = j.toString();
j = j.split("{")[1];
j = j.split("}")[0];
return j.strip()
}
} else {
if (h === "") {
g = function (f, j) {
j = f.getAttribute(j);
if (!j) {
return null
}
return j.strip()
}
}
}
d = null;
return g
})(),
_flag: function (d, f) {
return $(d).hasAttribute(f) ? f : null
},
style: function (d) {
return d.style.cssText.toLowerCase()
},
title: function (d) {
return d.title
}
}
}
}
})();
Element._attributeTranslations.write = {
names: Object.extend({
cellpadding: "cellPadding",
cellspacing: "cellSpacing"
}, Element._attributeTranslations.read.names),
values: {
checked: function (a, b) {
a.checked = !! b
},
style: function (a, b) {
a.style.cssText = b ? b : ""
}
}
};
Element._attributeTranslations.has = {};
$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder").each(function (a) {
Element._attributeTranslations.write.names[a.toLowerCase()] = a;
Element._attributeTranslations.has[a.toLowerCase()] = a
});
(function (a) {
Object.extend(a, {
href: a._getAttr2,
src: a._getAttr2,
type: a._getAttr,
action: a._getAttrNode,
disabled: a._flag,
checked: a._flag,
readonly: a._flag,
multiple: a._flag,
onload: a._getEv,
onunload: a._getEv,
onclick: a._getEv,
ondblclick: a._getEv,
onmousedown: a._getEv,
onmouseup: a._getEv,
onmouseover: a._getEv,
onmousemove: a._getEv,
onmouseout: a._getEv,
onfocus: a._getEv,
onblur: a._getEv,
onkeypress: a._getEv,
onkeydown: a._getEv,
onkeyup: a._getEv,
onsubmit: a._getEv,
onreset: a._getEv,
onselect: a._getEv,
onchange: a._getEv
})
})(Element._attributeTranslations.read.values);
if (Prototype.BrowserFeatures.ElementExtensions) {
(function () {
function a(f) {
var b = f.getElementsByTagName("*"),
d = [];
for (var c = 0, g; g = b[c]; c++) {
if (g.tagName !== "!") {
d.push(g)
}
}
return d
}
Element.Methods.down = function (c, d, b) {
c = $(c);
if (arguments.length == 1) {
return c.firstDescendant()
}
return Object.isNumber(d) ? a(c)[d] : Element.select(c, d)[b || 0]
}
})()
}
} else {
if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
Element.Methods.setOpacity = function (a, b) {
a = $(a);
a.style.opacity = (b == 1) ? 0.999999 : (b === "") ? "" : (b < 0.00001) ? 0 : b;
return a
}
} else {
if (Prototype.Browser.WebKit) {
Element.Methods.setOpacity = function (a, b) {
a = $(a);
a.style.opacity = (b == 1 || b === "") ? "" : (b < 0.00001) ? 0 : b;
if (b == 1) {
if (a.tagName.toUpperCase() == "IMG" && a.width) {
a.width++;
a.width--
} else {
try {
var d = document.createTextNode(" ");
a.appendChild(d);
a.removeChild(d)
} catch (c) {}
}
}
return a
};
Element.Methods.cumulativeOffset = function (b) {
var a = 0,
c = 0;
do {
a += b.offsetTop || 0;
c += b.offsetLeft || 0;
if (b.offsetParent == document.body) {
if (Element.getStyle(b, "position") == "absolute") {
break
}
}
b = b.offsetParent
} while (b);
return Element._returnOffset(c, a)
}
}
}
}
}
if ("outerHTML" in document.documentElement) {
Element.Methods.replace = function (c, f) {
c = $(c);
if (f && f.toElement) {
f = f.toElement()
}
if (Object.isElement(f)) {
c.parentNode.replaceChild(f, c);
return c
}
f = Object.toHTML(f);
var d = c.parentNode,
b = d.tagName.toUpperCase();
if (Element._insertionTranslations.tags[b]) {
var g = c.next();
var a = Element._getContentFromAnonymousElement(b, f.stripScripts());
d.removeChild(c);
if (g) {
a.each(function (h) {
d.insertBefore(h, g)
})
} else {
a.each(function (h) {
d.appendChild(h)
})
}
} else {
c.outerHTML = f.stripScripts()
}
f.evalScripts.bind(f).defer();
return c
}
}
Element._returnOffset = function (b, c) {
var a = [b, c];
a.left = b;
a.top = c;
return a
};
Element._getContentFromAnonymousElement = function (c, b) {
var d = new Element("div"),
a = Element._insertionTranslations.tags[c];
if (a) {
d.innerHTML = a[0] + b + a[1];
a[2].times(function () {
d = d.firstChild
})
} else {
d.innerHTML = b
}
return $A(d.childNodes)
};
Element._insertionTranslations = {
before: function (a, b) {
a.parentNode.insertBefore(b, a)
},
top: function (a, b) {
a.insertBefore(b, a.firstChild)
},
bottom: function (a, b) {
a.appendChild(b)
},
after: function (a, b) {
a.parentNode.insertBefore(b, a.nextSibling)
},
tags: {
TABLE: ["<table>", "</table>", 1],
TBODY: ["<table><tbody>", "</tbody></table>", 2],
TR: ["<table><tbody><tr>", "</tr></tbody></table>", 3],
TD: ["<table><tbody><tr><td>", "</td></tr></tbody></table>", 4],
SELECT: ["<select>", "</select>", 1]
}
};
(function () {
var a = Element._insertionTranslations.tags;
Object.extend(a, {
THEAD: a.TBODY,
TFOOT: a.TBODY,
TH: a.TD
})
})();
Element.Methods.Simulated = {
hasAttribute: function (a, c) {
c = Element._attributeTranslations.has[c] || c;
var b = $(a).getAttributeNode(c);
return !!(b && b.specified)
}
};
Element.Methods.ByTag = {};
Object.extend(Element, Element.Methods);
(function (a) {
if (!Prototype.BrowserFeatures.ElementExtensions && a.__proto__) {
window.HTMLElement = {};
window.HTMLElement.prototype = a.__proto__;
Prototype.BrowserFeatures.ElementExtensions = true
}
a = null
})(document.createElement("div"));
Element.extend = (function () {
function c(h) {
if (typeof window.Element != "undefined") {
var k = window.Element.prototype;
if (k) {
var m = "_" + (Math.random() + "").slice(2);
var j = document.createElement(h);
k[m] = "x";
var l = (j[m] !== "x");
delete k[m];
j = null;
return l
}
}
return false
}
function b(j, h) {
for (var l in h) {
var k = h[l];
if (Object.isFunction(k) && !(l in j)) {
j[l] = k.methodize()
}
}
}
var d = c("object");
if (Prototype.BrowserFeatures.SpecificElementExtensions) {
if (d) {
return function (j) {
if (j && typeof j._extendedByPrototype == "undefined") {
var h = j.tagName;
if (h && (/^(?:object|applet|embed)$/i.test(h))) {
b(j, Element.Methods);
b(j, Element.Methods.Simulated);
b(j, Element.Methods.ByTag[h.toUpperCase()])
}
}
return j
}
}
return Prototype.K
}
var a = {},
f = Element.Methods.ByTag;
var g = Object.extend(function (k) {
if (!k || typeof k._extendedByPrototype != "undefined" || k.nodeType != 1 || k == window) {
return k
}
var h = Object.clone(a),
j = k.tagName.toUpperCase();
if (f[j]) {
Object.extend(h, f[j])
}
b(k, h);
k._extendedByPrototype = Prototype.emptyFunction;
return k
}, {
refresh: function () {
if (!Prototype.BrowserFeatures.ElementExtensions) {
Object.extend(a, Element.Methods);
Object.extend(a, Element.Methods.Simulated)
}
}
});
g.refresh();
return g
})();
Element.hasAttribute = function (a, b) {
if (a.hasAttribute) {
return a.hasAttribute(b)
}
return Element.Methods.Simulated.hasAttribute(a, b)
};
Element.addMethods = function (c) {
var k = Prototype.BrowserFeatures,
d = Element.Methods.ByTag;
if (!c) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
FORM: Object.clone(Form.Methods),
INPUT: Object.clone(Form.Element.Methods),
SELECT: Object.clone(Form.Element.Methods),
TEXTAREA: Object.clone(Form.Element.Methods)
})
}
if (arguments.length == 2) {
var b = c;
c = arguments[1]
}
if (!b) {
Object.extend(Element.Methods, c || {})
} else {
if (Object.isArray(b)) {
b.each(h)
} else {
h(b)
}
}
function h(m) {
m = m.toUpperCase();
if (!Element.Methods.ByTag[m]) {
Element.Methods.ByTag[m] = {}
}
Object.extend(Element.Methods.ByTag[m], c)
}
function a(o, n, m) {
m = m || false;
for (var q in o) {
var p = o[q];
if (!Object.isFunction(p)) {
continue
}
if (!m || !(q in n)) {
n[q] = p.methodize()
}
}
}
function f(p) {
var m;
var o = {
OPTGROUP: "OptGroup",
TEXTAREA: "TextArea",
P: "Paragraph",
FIELDSET: "FieldSet",
UL: "UList",
OL: "OList",
DL: "DList",
DIR: "Directory",
H1: "Heading",
H2: "Heading",
H3: "Heading",
H4: "Heading",
H5: "Heading",
H6: "Heading",
Q: "Quote",
INS: "Mod",
DEL: "Mod",
A: "Anchor",
IMG: "Image",
CAPTION: "TableCaption",
COL: "TableCol",
COLGROUP: "TableCol",
THEAD: "TableSection",
TFOOT: "TableSection",
TBODY: "TableSection",
TR: "TableRow",
TH: "TableCell",
TD: "TableCell",
FRAMESET: "FrameSet",
IFRAME: "IFrame"
};
if (o[p]) {
m = "HTML" + o[p] + "Element"
}
if (window[m]) {
return window[m]
}
m = "HTML" + p + "Element";
if (window[m]) {
return window[m]
}
m = "HTML" + p.capitalize() + "Element";
if (window[m]) {
return window[m]
}
var n = document.createElement(p);
var q = n.__proto__ || n.constructor.prototype;
n = null;
return q
}
var j = window.HTMLElement ? HTMLElement.prototype : Element.prototype;
if (k.ElementExtensions) {
a(Element.Methods, j);
a(Element.Methods.Simulated, j, true)
}
if (k.SpecificElementExtensions) {
for (var l in Element.Methods.ByTag) {
var g = f(l);
if (Object.isUndefined(g)) {
continue
}
a(d[l], g.prototype)
}
}
Object.extend(Element, Element.Methods);
delete Element.ByTag;
if (Element.extend.refresh) {
Element.extend.refresh()
}
Element.cache = {}
};
document.viewport = {
getDimensions: function () {
return {
width: this.getWidth(),
height: this.getHeight()
}
},
getScrollOffsets: function () {
return Element._returnOffset(window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop)
}
};
(function (b) {
var h = Prototype.Browser,
f = document,
c, d = {};
function a() {
if (h.WebKit && !f.evaluate) {
return document
}
if (h.Opera && window.parseFloat(window.opera.version()) < 9.5) {
return document.body
}
return document.documentElement
}
function g(j) {
if (!c) {
c = a()
}
d[j] = "client" + j;
b["get" + j] = function () {
return c[d[j]]
};
return b["get" + j]()
}
b.getWidth = g.curry("Width");
b.getHeight = g.curry("Height")
})(document.viewport);
Element.Storage = {
UID: 1
};
Element.addMethods({
getStorage: function (b) {
if (!(b = $(b))) {
return
}
var a;
if (b === window) {
a = 0
} else {
if (typeof b._prototypeUID === "undefined") {
b._prototypeUID = [Element.Storage.UID++]
}
a = b._prototypeUID[0]
}
if (!Element.Storage[a]) {
Element.Storage[a] = $H()
}
return Element.Storage[a]
},
store: function (b, a, c) {
if (!(b = $(b))) {
return
}
if (arguments.length === 2) {
Element.getStorage(b).update(a)
} else {
Element.getStorage(b).set(a, c)
}
return b
},
retrieve: function (c, b, a) {
if (!(c = $(c))) {
return
}
var f = Element.getStorage(c),
d = f.get(b);
if (Object.isUndefined(d)) {
f.set(b, a);
d = a
}
return d
},
clone: function (c, a) {
if (!(c = $(c))) {
return
}
var f = c.cloneNode(a);
f._prototypeUID = void 0;
if (a) {
var d = Element.select(f, "*"),
b = d.length;
while (b--) {
d[b]._prototypeUID = void 0
}
}
return Element.extend(f)
}
});
var Selector = Class.create({
initialize: function (a) {
this.expression = a.strip();
if (this.shouldUseSelectorsAPI()) {
this.mode = "selectorsAPI"
} else {
if (this.shouldUseXPath()) {
this.mode = "xpath";
this.compileXPathMatcher()
} else {
this.mode = "normal";
this.compileMatcher()
}
}
},
shouldUseXPath: (function () {
var a = (function () {
var f = false;
if (document.evaluate && window.XPathResult) {
var d = document.createElement("div");
d.innerHTML = "<ul><li></li></ul><div><ul><li></li></ul></div>";
var c = ".//*[local-name()='ul' or local-name()='UL']//*[local-name()='li' or local-name()='LI']";
var b = document.evaluate(c, d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
f = (b.snapshotLength !== 2);
d = null
}
return f
})();
return function () {
if (!Prototype.BrowserFeatures.XPath) {
return false
}
var b = this.expression;
if (Prototype.Browser.WebKit && (b.include("-of-type") || b.include(":empty"))) {
return false
}
if ((/(\[[\w-]*?:|:checked)/).test(b)) {
return false
}
if (a) {
return false
}
return true
}
})(),
shouldUseSelectorsAPI: function () {
if (!Prototype.BrowserFeatures.SelectorsAPI) {
return false
}
if (Selector.CASE_INSENSITIVE_CLASS_NAMES) {
return false
}
if (!Selector._div) {
Selector._div = new Element("div")
}
try {
Selector._div.querySelector(this.expression)
} catch (a) {
return false
}
return true
},
compileMatcher: function () {
var e = this.expression,
ps = Selector.patterns,
h = Selector.handlers,
c = Selector.criteria,
le, p, m, len = ps.length,
name;
if (Selector._cache[e]) {
this.matcher = Selector._cache[e];
return
}
this.matcher = ["this.matcher = function(root) {", "var r = root, h = Selector.handlers, c = false, n;"];
while (e && le != e && (/\S/).test(e)) {
le = e;
for (var i = 0; i < len; i++) {
p = ps[i].re;
name = ps[i].name;
if (m = e.match(p)) {
this.matcher.push(Object.isFunction(c[name]) ? c[name](m) : new Template(c[name]).evaluate(m));
e = e.replace(m[0], "");
break
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join("\n"));
Selector._cache[this.expression] = this.matcher
},
compileXPathMatcher: function () {
var h = this.expression,
j = Selector.patterns,
c = Selector.xpath,
g, b, a = j.length,
d;
if (Selector._cache[h]) {
this.xpath = Selector._cache[h];
return
}
this.matcher = [".//*"];
while (h && g != h && (/\S/).test(h)) {
g = h;
for (var f = 0; f < a; f++) {
d = j[f].name;
if (b = h.match(j[f].re)) {
this.matcher.push(Object.isFunction(c[d]) ? c[d](b) : new Template(c[d]).evaluate(b));
h = h.replace(b[0], "");
break
}
}
}
this.xpath = this.matcher.join("");
Selector._cache[this.expression] = this.xpath
},
findElements: function (a) {
a = a || document;
var c = this.expression,
b;
switch (this.mode) {
case "selectorsAPI":
if (a !== document) {
var d = a.id,
f = $(a).identify();
f = f.replace(/([\.:])/g, "\\$1");
c = "#" + f + " " + c
}
b = $A(a.querySelectorAll(c)).map(Element.extend);
a.id = d;
return b;
case "xpath":
return document._getElementsByXPath(this.xpath, a);
default:
return this.matcher(a)
}
},
match: function (k) {
this.tokens = [];
var q = this.expression,
a = Selector.patterns,
f = Selector.assertions;
var b, d, g, o = a.length,
c;
while (q && b !== q && (/\S/).test(q)) {
b = q;
for (var j = 0; j < o; j++) {
d = a[j].re;
c = a[j].name;
if (g = q.match(d)) {
if (f[c]) {
this.tokens.push([c, Object.clone(g)]);
q = q.replace(g[0], "")
} else {
return this.findElements(document).include(k)
}
}
}
}
var n = true,
c, l;
for (var j = 0, h; h = this.tokens[j]; j++) {
c = h[0], l = h[1];
if (!Selector.assertions[c](k, l)) {
n = false;
break
}
}
return n
},
toString: function () {
return this.expression
},
inspect: function () {
return "#<Selector:" + this.expression.inspect() + ">"
}
});
if (Prototype.BrowserFeatures.SelectorsAPI && document.compatMode === "BackCompat") {
Selector.CASE_INSENSITIVE_CLASS_NAMES = (function () {
var c = document.createElement("div"),
a = document.createElement("span");
c.id = "prototype_test_id";
a.className = "Test";
c.appendChild(a);
var b = (c.querySelector("#prototype_test_id .test") !== null);
c = a = null;
return b
})()
}
Object.extend(Selector, {
_cache: {},
xpath: {
descendant: "//*",
child: "/*",
adjacent: "/following-sibling::*[1]",
laterSibling: "/following-sibling::*",
tagName: function (a) {
if (a[1] == "*") {
return ""
}
return "[local-name()='" + a[1].toLowerCase() + "' or local-name()='" + a[1].toUpperCase() + "']"
},
className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
id: "[@id='#{1}']",
attrPresence: function (a) {
a[1] = a[1].toLowerCase();
return new Template("[@#{1}]").evaluate(a)
},
attr: function (a) {
a[1] = a[1].toLowerCase();
a[3] = a[5] || a[6];
return new Template(Selector.xpath.operators[a[2]]).evaluate(a)
},
pseudo: function (a) {
var b = Selector.xpath.pseudos[a[1]];
if (!b) {
return ""
}
if (Object.isFunction(b)) {
return b(a)
}
return new Template(Selector.xpath.pseudos[a[1]]).evaluate(a)
},
operators: {
"=": "[@#{1}='#{3}']",
"!=": "[@#{1}!='#{3}']",
"^=": "[starts-with(@#{1}, '#{3}')]",
"$=": "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
"*=": "[contains(@#{1}, '#{3}')]",
"~=": "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
"|=": "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
},
pseudos: {
"first-child": "[not(preceding-sibling::*)]",
"last-child": "[not(following-sibling::*)]",
"only-child": "[not(preceding-sibling::* or following-sibling::*)]",
empty: "[count(*) = 0 and (count(text()) = 0)]",
checked: "[@checked]",
disabled: "[(@disabled) and (@type!='hidden')]",
enabled: "[not(@disabled) and (@type!='hidden')]",
not: function (f) {
var j = f[6],
c = Selector.patterns,
k = Selector.xpath,
a, l, h = c.length,
b;
var d = [];
while (j && a != j && (/\S/).test(j)) {
a = j;
for (var g = 0; g < h; g++) {
b = c[g].name;
if (f = j.match(c[g].re)) {
l = Object.isFunction(k[b]) ? k[b](f) : new Template(k[b]).evaluate(f);
d.push("(" + l.substring(1, l.length - 1) + ")");
j = j.replace(f[0], "");
break
}
}
}
return "[not(" + d.join(" and ") + ")]"
},
"nth-child": function (a) {
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", a)
},
"nth-last-child": function (a) {
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", a)
},
"nth-of-type": function (a) {
return Selector.xpath.pseudos.nth("position() ", a)
},
"nth-last-of-type": function (a) {
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", a)
},
"first-of-type": function (a) {
a[6] = "1";
return Selector.xpath.pseudos["nth-of-type"](a)
},
"last-of-type": function (a) {
a[6] = "1";
return Selector.xpath.pseudos["nth-last-of-type"](a)
},
"only-of-type": function (a) {
var b = Selector.xpath.pseudos;
return b["first-of-type"](a) + b["last-of-type"](a)
},
nth: function (h, f) {
var j, k = f[6],
d;
if (k == "even") {
k = "2n+0"
}
if (k == "odd") {
k = "2n+1"
}
if (j = k.match(/^(\d+)$/)) {
return "[" + h + "= " + j[1] + "]"
}
if (j = k.match(/^(-?\d*)?n(([+-])(\d+))?/)) {
if (j[1] == "-") {
j[1] = -1
}
var g = j[1] ? Number(j[1]) : 1;
var c = j[2] ? Number(j[2]) : 0;
d = "[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(d).evaluate({
fragment: h,
a: g,
b: c
})
}
}
}
},
criteria: {
tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
className: 'n = h.className(n, r, "#{1}", c); c = false;',
id: 'n = h.id(n, r, "#{1}", c); c = false;',
attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
attr: function (a) {
a[3] = (a[5] || a[6]);
return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(a)
},
pseudo: function (a) {
if (a[6]) {
a[6] = a[6].replace(/"/g, '\\"')
}
return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(a)
},
descendant: 'c = "descendant";',
child: 'c = "child";',
adjacent: 'c = "adjacent";',
laterSibling: 'c = "laterSibling";'
},
patterns: [{
name: "laterSibling",
re: /^\s*~\s*/
}, {
name: "child",
re: /^\s*>\s*/
}, {
name: "adjacent",
re: /^\s*\+\s*/
}, {
name: "descendant",
re: /^\s/
}, {
name: "tagName",
re: /^\s*(\*|[\w\-]+)(\b|$)?/
}, {
name: "id",
re: /^#([\w\-\*]+)(\b|$)/
}, {
name: "className",
re: /^\.([\w\-\*]+)(\b|$)/
}, {
name: "pseudo",
re: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/
}, {
name: "attrPresence",
re: /^\[((?:[\w-]+:)?[\w-]+)\]/
}, {
name: "attr",
re: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
}],
assertions: {
tagName: function (a, b) {
return b[1].toUpperCase() == a.tagName.toUpperCase()
},
className: function (a, b) {
return Element.hasClassName(a, b[1])
},
id: function (a, b) {
return a.id === b[1]
},
attrPresence: function (a, b) {
return Element.hasAttribute(a, b[1])
},
attr: function (b, c) {
var a = Element.readAttribute(b, c[1]);
return a && Selector.operators[c[2]](a, c[5] || c[6])
}
},
handlers: {
concat: function (d, c) {
for (var f = 0, g; g = c[f]; f++) {
d.push(g)
}
return d
},
mark: function (a) {
var d = Prototype.emptyFunction;
for (var b = 0, c; c = a[b]; b++) {
c._countedByPrototype = d
}
return a
},
unmark: (function () {
var a = (function () {
var b = document.createElement("div"),
f = false,
d = "_countedByPrototype",
c = "x";
b[d] = c;
f = (b.getAttribute(d) === c);
b = null;
return f
})();
return a ?
function (b) {
for (var c = 0, d; d = b[c]; c++) {
d.removeAttribute("_countedByPrototype")
}
return b
} : function (b) {
for (var c = 0, d; d = b[c]; c++) {
d._countedByPrototype = void 0
}
return b
}
})(),
index: function (a, d, h) {
a._countedByPrototype = Prototype.emptyFunction;
if (d) {
for (var b = a.childNodes, f = b.length - 1, c = 1; f >= 0; f--) {
var g = b[f];
if (g.nodeType == 1 && (!h || g._countedByPrototype)) {
g.nodeIndex = c++
}
}
} else {
for (var f = 0, c = 1, b = a.childNodes; g = b[f]; f++) {
if (g.nodeType == 1 && (!h || g._countedByPrototype)) {
g.nodeIndex = c++
}
}
}
},
unique: function (b) {
if (b.length == 0) {
return b
}
var d = [],
f;
for (var c = 0, a = b.length; c < a; c++) {
if (typeof (f = b[c])._countedByPrototype == "undefined") {
f._countedByPrototype = Prototype.emptyFunction;
d.push(Element.extend(f))
}
}
return Selector.handlers.unmark(d)
},
descendant: function (a) {
var d = Selector.handlers;
for (var c = 0, b = [], f; f = a[c]; c++) {
d.concat(b, f.getElementsByTagName("*"))
}
return b
},
child: function (a) {
var f = Selector.handlers;
for (var d = 0, c = [], g; g = a[d]; d++) {
for (var b = 0, k; k = g.childNodes[b]; b++) {
if (k.nodeType == 1 && k.tagName != "!") {
c.push(k)
}
}
}
return c
},
adjacent: function (a) {
for (var c = 0, b = [], f; f = a[c]; c++) {
var d = this.nextElementSibling(f);
if (d) {
b.push(d)
}
}
return b
},
laterSibling: function (a) {
var d = Selector.handlers;
for (var c = 0, b = [], f; f = a[c]; c++) {
d.concat(b, Element.nextSiblings(f))
}
return b
},
nextElementSibling: function (a) {
while (a = a.nextSibling) {
if (a.nodeType == 1) {
return a
}
}
return null
},
previousElementSibling: function (a) {
while (a = a.previousSibling) {
if (a.nodeType == 1) {
return a
}
}
return null
},
tagName: function (a, k, c, b) {
var l = c.toUpperCase();
var f = [],
j = Selector.handlers;
if (a) {
if (b) {
if (b == "descendant") {
for (var g = 0, d; d = a[g]; g++) {
j.concat(f, d.getElementsByTagName(c))
}
return f
} else {
a = this[b](a)
}
if (c == "*") {
return a
}
}
for (var g = 0, d; d = a[g]; g++) {
if (d.tagName.toUpperCase() === l) {
f.push(d)
}
}
return f
} else {
return k.getElementsByTagName(c)
}
},
id: function (a, m, b, c) {
var l = $(b),
k = Selector.handlers;
if (m == document) {
if (!l) {
return []
}
if (!a) {
return [l]
}
} else {
if (!m.sourceIndex || m.sourceIndex < 1) {
var a = m.getElementsByTagName("*");
for (var f = 0, d; d = a[f]; f++) {
if (d.id === b) {
return [d]
}
}
}
}
if (a) {
if (c) {
if (c == "child") {
for (var g = 0, d; d = a[g]; g++) {
if (l.parentNode == d) {
return [l]
}
}
} else {
if (c == "descendant") {
for (var g = 0, d; d = a[g]; g++) {
if (Element.descendantOf(l, d)) {
return [l]
}
}
} else {
if (c == "adjacent") {
for (var g = 0, d; d = a[g]; g++) {
if (Selector.handlers.previousElementSibling(l) == d) {
return [l]
}
}
} else {
a = k[c](a)
}
}
}
}
for (var g = 0, d; d = a[g]; g++) {
if (d == l) {
return [l]
}
}
return []
}
return (l && Element.descendantOf(l, m)) ? [l] : []
},
className: function (b, a, c, d) {
if (b && d) {
b = this[d](b)
}
return Selector.handlers.byClassName(b, a, c)
},
byClassName: function (c, b, g) {
if (!c) {
c = Selector.handlers.descendant([b])
}
var j = " " + g + " ";
for (var f = 0, d = [], h, a; h = c[f]; f++) {
a = h.className;
if (a.length == 0) {
continue
}
if (a == g || (" " + a + " ").include(j)) {
d.push(h)
}
}
return d
},
attrPresence: function (c, b, a, h) {
if (!c) {
c = b.getElementsByTagName("*")
}
if (c && h) {
c = this[h](c)
}
var f = [];
for (var d = 0, g; g = c[d]; d++) {
if (Element.hasAttribute(g, a)) {
f.push(g)
}
}
return f
},
attr: function (a, k, j, l, c, b) {
if (!a) {
a = k.getElementsByTagName("*")
}
if (a && b) {
a = this[b](a)
}
var m = Selector.operators[c],
g = [];
for (var f = 0, d; d = a[f]; f++) {
var h = Element.readAttribute(d, j);
if (h === null) {
continue
}
if (m(h, l)) {
g.push(d)
}
}
return g
},
pseudo: function (b, c, f, a, d) {
if (b && d) {
b = this[d](b)
}
if (!b) {
b = a.getElementsByTagName("*")
}
return Selector.pseudos[c](b, f, a)
}
},
pseudos: {
"first-child": function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (Selector.handlers.previousElementSibling(f)) {
continue
}
c.push(f)
}
return c
},
"last-child": function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (Selector.handlers.nextElementSibling(f)) {
continue
}
c.push(f)
}
return c
},
"only-child": function (b, j, a) {
var f = Selector.handlers;
for (var d = 0, c = [], g; g = b[d]; d++) {
if (!f.previousElementSibling(g) && !f.nextElementSibling(g)) {
c.push(g)
}
}
return c
},
"nth-child": function (b, c, a) {
return Selector.pseudos.nth(b, c, a)
},
"nth-last-child": function (b, c, a) {
return Selector.pseudos.nth(b, c, a, true)
},
"nth-of-type": function (b, c, a) {
return Selector.pseudos.nth(b, c, a, false, true)
},
"nth-last-of-type": function (b, c, a) {
return Selector.pseudos.nth(b, c, a, true, true)
},
"first-of-type": function (b, c, a) {
return Selector.pseudos.nth(b, "1", a, false, true)
},
"last-of-type": function (b, c, a) {
return Selector.pseudos.nth(b, "1", a, true, true)
},
"only-of-type": function (b, d, a) {
var c = Selector.pseudos;
return c["last-of-type"](c["first-of-type"](b, d, a), d, a)
},
getIndices: function (d, c, f) {
if (d == 0) {
return c > 0 ? [c] : []
}
return $R(1, f).inject([], function (a, b) {
if (0 == (b - c) % d && (b - c) / d >= 0) {
a.push(b)
}
return a
})
},
nth: function (c, u, w, t, f) {
if (c.length == 0) {
return []
}
if (u == "even") {
u = "2n+0"
}
if (u == "odd") {
u = "2n+1"
}
var r = Selector.handlers,
q = [],
d = [],
k;
r.mark(c);
for (var p = 0, g; g = c[p]; p++) {
if (!g.parentNode._countedByPrototype) {
r.index(g.parentNode, t, f);
d.push(g.parentNode)
}
}
if (u.match(/^\d+$/)) {
u = Number(u);
for (var p = 0, g; g = c[p]; p++) {
if (g.nodeIndex == u) {
q.push(g)
}
}
} else {
if (k = u.match(/^(-?\d*)?n(([+-])(\d+))?/)) {
if (k[1] == "-") {
k[1] = -1
}
var x = k[1] ? Number(k[1]) : 1;
var v = k[2] ? Number(k[2]) : 0;
var y = Selector.pseudos.getIndices(x, v, c.length);
for (var p = 0, g, n = y.length; g = c[p]; p++) {
for (var o = 0; o < n; o++) {
if (g.nodeIndex == y[o]) {
q.push(g)
}
}
}
}
}
r.unmark(c);
r.unmark(d);
return q
},
empty: function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (f.tagName == "!" || f.firstChild) {
continue
}
c.push(f)
}
return c
},
not: function (a, d, l) {
var j = Selector.handlers,
n, c;
var k = new Selector(d).findElements(l);
j.mark(k);
for (var g = 0, f = [], b; b = a[g]; g++) {
if (!b._countedByPrototype) {
f.push(b)
}
}
j.unmark(k);
return f
},
enabled: function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (!f.disabled && (!f.type || f.type !== "hidden")) {
c.push(f)
}
}
return c
},
disabled: function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (f.disabled) {
c.push(f)
}
}
return c
},
checked: function (b, g, a) {
for (var d = 0, c = [], f; f = b[d]; d++) {
if (f.checked) {
c.push(f)
}
}
return c
}
},
operators: {
"=": function (b, a) {
return b == a
},
"!=": function (b, a) {
return b != a
},
"^=": function (b, a) {
return b == a || b && b.startsWith(a)
},
"$=": function (b, a) {
return b == a || b && b.endsWith(a)
},
"*=": function (b, a) {
return b == a || b && b.include(a)
},
"~=": function (b, a) {
return (" " + b + " ").include(" " + a + " ")
},
"|=": function (b, a) {
return ("-" + (b || "").toUpperCase() + "-").include("-" + (a || "").toUpperCase() + "-")
}
},
split: function (b) {
var a = [];
b.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function (c) {
a.push(c[1].strip())
});
return a
},
matchElements: function (g, j) {
var f = $$(j),
d = Selector.handlers;
d.mark(f);
for (var c = 0, b = [], a; a = g[c]; c++) {
if (a._countedByPrototype) {
b.push(a)
}
}
d.unmark(f);
return b
},
findElement: function (b, c, a) {
if (Object.isNumber(c)) {
a = c;
c = false
}
return Selector.matchElements(b, c || "*")[a || 0]
},
findChildElements: function (f, j) {
j = Selector.split(j.join(","));
var d = [],
g = Selector.handlers;
for (var c = 0, b = j.length, a; c < b; c++) {
a = new Selector(j[c].strip());
g.concat(d, a.findElements(f))
}
return (b > 1) ? g.unique(d) : d
}
});
if (Prototype.Browser.IE) {
Object.extend(Selector.handlers, {
concat: function (d, c) {
for (var f = 0, g; g = c[f]; f++) {
if (g.tagName !== "!") {
d.push(g)
}
}
return d
}
})
}
function $$() {
return Selector.findChildElements(document, $A(arguments))
}
var Form = {
reset: function (a) {
a = $(a);
a.reset();
return a
},
serializeElements: function (h, b) {
if (typeof b != "object") {
b = {
hash: !! b
}
} else {
if (Object.isUndefined(b.hash)) {
b.hash = true
}
}
var c, g, a = false,
f = b.submit;
var d = h.inject({}, function (j, k) {
if (!k.disabled && k.name) {
c = k.name;
g = $(k).getValue();
if (g != null && k.type != "file" && (k.type != "submit" || (!a && f !== false && (!f || c == f) && (a = true)))) {
if (c in j) {
if (!Object.isArray(j[c])) {
j[c] = [j[c]]
}
j[c].push(g)
} else {
j[c] = g
}
}
}
return j
});
return b.hash ? d : Object.toQueryString(d)
}
};
Form.Methods = {
serialize: function (b, a) {
return Form.serializeElements(Form.getElements(b), a)
},
getElements: function (f) {
var g = $(f).getElementsByTagName("*"),
d, a = [],
c = Form.Element.Serializers;
for (var b = 0; d = g[b]; b++) {
a.push(d)
}
return a.inject([], function (h, j) {
if (c[j.tagName.toLowerCase()]) {
h.push(Element.extend(j))
}
return h
})
},
getInputs: function (h, c, d) {
h = $(h);
var a = h.getElementsByTagName("input");
if (!c && !d) {
return $A(a).map(Element.extend)
}
for (var f = 0, j = [], g = a.length; f < g; f++) {
var b = a[f];
if ((c && b.type != c) || (d && b.name != d)) {
continue
}
j.push(Element.extend(b))
}
return j
},
disable: function (a) {
a = $(a);
Form.getElements(a).invoke("disable");
return a
},
enable: function (a) {
a = $(a);
Form.getElements(a).invoke("enable");
return a
},
findFirstElement: function (b) {
var c = $(b).getElements().findAll(function (d) {
return "hidden" != d.type && !d.disabled
});
var a = c.findAll(function (d) {
return d.hasAttribute("tabIndex") && d.tabIndex >= 0
}).sortBy(function (d) {
return d.tabIndex
}).first();
return a ? a : c.find(function (d) {
return /^(?:input|select|textarea)$/i.test(d.tagName)
})
},
focusFirstElement: function (a) {
a = $(a);
a.findFirstElement().activate();
return a
},
request: function (b, a) {
b = $(b), a = Object.clone(a || {});
var d = a.parameters,
c = b.readAttribute("action") || "";
if (c.blank()) {
c = window.location.href
}
a.parameters = b.serialize(true);
if (d) {
if (Object.isString(d)) {
d = d.toQueryParams()
}
Object.extend(a.parameters, d)
}
if (b.hasAttribute("method") && !a.method) {
a.method = b.method
}
return new Ajax.Request(c, a)
}
};
Form.Element = {
focus: function (a) {
$(a).focus();
return a
},
select: function (a) {
$(a).select();
return a
}
};
Form.Element.Methods = {
serialize: function (a) {
a = $(a);
if (!a.disabled && a.name) {
var b = a.getValue();
if (b != undefined) {
var c = {};
c[a.name] = b;
return Object.toQueryString(c)
}
}
return ""
},
getValue: function (a) {
a = $(a);
var b = a.tagName.toLowerCase();
return Form.Element.Serializers[b](a)
},
setValue: function (a, b) {
a = $(a);
var c = a.tagName.toLowerCase();
Form.Element.Serializers[c](a, b);
return a
},
clear: function (a) {
$(a).value = "";
return a
},
present: function (a) {
return $(a).value != ""
},
activate: function (a) {
a = $(a);
try {
a.focus();
if (a.select && (a.tagName.toLowerCase() != "input" || !(/^(?:button|reset|submit)$/i.test(a.type)))) {
a.select()
}
} catch (b) {}
return a
},
disable: function (a) {
a = $(a);
a.disabled = true;
return a
},
enable: function (a) {
a = $(a);
a.disabled = false;
return a
}
};
var Field = Form.Element;
var $F = Form.Element.Methods.getValue;
Form.Element.Serializers = {
input: function (a, b) {
switch (a.type.toLowerCase()) {
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(a, b);
default:
return Form.Element.Serializers.textarea(a, b)
}
},
inputSelector: function (a, b) {
if (Object.isUndefined(b)) {
return a.checked ? a.value : null
} else {
a.checked = !! b
}
},
textarea: function (a, b) {
if (Object.isUndefined(b)) {
return a.value
} else {
a.value = b
}
},
select: function (c, g) {
if (Object.isUndefined(g)) {
return this[c.type == "select-one" ? "selectOne" : "selectMany"](c)
} else {
var b, d, h = !Object.isArray(g);
for (var a = 0, f = c.length; a < f; a++) {
b = c.options[a];
d = this.optionValue(b);
if (h) {
if (d == g) {
b.selected = true;
return
}
} else {
b.selected = g.include(d)
}
}
}
},
selectOne: function (b) {
var a = b.selectedIndex;
return a >= 0 ? this.optionValue(b.options[a]) : null
},
selectMany: function (d) {
var a, f = d.length;
if (!f) {
return null
}
for (var c = 0, a = []; c < f; c++) {
var b = d.options[c];
if (b.selected) {
a.push(this.optionValue(b))
}
}
return a
},
optionValue: function (a) {
return Element.extend(a).hasAttribute("value") ? a.value : a.text
}
};
Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
initialize: function ($super, a, b, c) {
$super(c, b);
this.element = $(a);
this.lastValue = this.getValue()
},
execute: function () {
var a = this.getValue();
if (Object.isString(this.lastValue) && Object.isString(a) ? this.lastValue != a : String(this.lastValue) != String(a)) {
this.callback(this.element, a);
this.lastValue = a
}
}
});
Form.Element.Observer = Class.create(Abstract.TimedObserver, {
getValue: function () {
return Form.Element.getValue(this.element)
}
});
Form.Observer = Class.create(Abstract.TimedObserver, {
getValue: function () {
return Form.serialize(this.element)
}
});
Abstract.EventObserver = Class.create({
initialize: function (a, b) {
this.element = $(a);
this.callback = b;
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == "form") {
this.registerFormCallbacks()
} else {
this.registerCallback(this.element)
}
},
onElementEvent: function () {
var a = this.getValue();
if (this.lastValue != a) {
this.callback(this.element, a);
this.lastValue = a
}
},
registerFormCallbacks: function () {
Form.getElements(this.element).each(this.registerCallback, this)
},
registerCallback: function (a) {
if (a.type) {
switch (a.type.toLowerCase()) {
case "checkbox":
case "radio":
Event.observe(a, "click", this.onElementEvent.bind(this));
break;
default:
Event.observe(a, "change", this.onElementEvent.bind(this));
break
}
}
}
});
Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function () {
return Form.Element.getValue(this.element)
}
});
Form.EventObserver = Class.create(Abstract.EventObserver, {
getValue: function () {
return Form.serialize(this.element)
}
});
(function () {
var y = {
KEY_BACKSPACE: 8,
KEY_TAB: 9,
KEY_RETURN: 13,
KEY_ESC: 27,
KEY_LEFT: 37,
KEY_UP: 38,
KEY_RIGHT: 39,
KEY_DOWN: 40,
KEY_DELETE: 46,
KEY_HOME: 36,
KEY_END: 35,
KEY_PAGEUP: 33,
KEY_PAGEDOWN: 34,
KEY_INSERT: 45,
cache: {}
};
var f = document.documentElement;
var z = "onmouseenter" in f && "onmouseleave" in f;
var q;
if (Prototype.Browser.IE) {
var j = {
0: 1,
1: 4,
2: 2
};
q = function (B, A) {
return B.button === j[A]
}
} else {
if (Prototype.Browser.WebKit) {
q = function (B, A) {
switch (A) {
case 0:
return B.which == 1 && !B.metaKey;
case 1:
return B.which == 1 && B.metaKey;
default:
return false
}
}
} else {
q = function (B, A) {
return B.which ? (B.which === A + 1) : (B.button === A)
}
}
}
function u(A) {
return q(A, 0)
}
function t(A) {
return q(A, 1)
}
function m(A) {
return q(A, 2)
}
function c(C) {
C = y.extend(C);
var B = C.target,
A = C.type,
D = C.currentTarget;
if (D && D.tagName) {
if (A === "load" || A === "error" || (A === "click" && D.tagName.toLowerCase() === "input" && D.type === "radio")) {
B = D
}
}
if (B.nodeType == Node.TEXT_NODE) {
B = B.parentNode
}
return Element.extend(B)
}
function o(B, D) {
var A = y.element(B);
if (!D) {
return A
}
var C = [A].concat(A.ancestors());
return Selector.findElement(C, D, 0)
}
function r(A) {
return {
x: b(A),
y: a(A)
}
}
function b(C) {
var B = document.documentElement,
A = document.body || {
scrollLeft: 0
};
return C.pageX || (C.clientX + (B.scrollLeft || A.scrollLeft) - (B.clientLeft || 0))
}
function a(C) {
var B = document.documentElement,
A = document.body || {
scrollTop: 0
};
return C.pageY || (C.clientY + (B.scrollTop || A.scrollTop) - (B.clientTop || 0))
}
function p(A) {
y.extend(A);
A.preventDefault();
A.stopPropagation();
A.stopped = true
}
y.Methods = {
isLeftClick: u,
isMiddleClick: t,
isRightClick: m,
element: c,
findElement: o,
pointer: r,
pointerX: b,
pointerY: a,
stop: p
};
var w = Object.keys(y.Methods).inject({}, function (A, B) {
A[B] = y.Methods[B].methodize();
return A
});
if (Prototype.Browser.IE) {
function h(B) {
var A;
switch (B.type) {
case "mouseover":
A = B.fromElement;
break;
case "mouseout":
A = B.toElement;
break;
default:
return null
}
return Element.extend(A)
}
Object.extend(w, {
stopPropagation: function () {
this.cancelBubble = true
},
preventDefault: function () {
this.returnValue = false
},
inspect: function () {
return "[object Event]"
}
});
y.extend = function (B, A) {
if (!B) {
return false
}
if (B._extendedByPrototype) {
return B
}
B._extendedByPrototype = Prototype.emptyFunction;
var C = y.pointer(B);
Object.extend(B, {
target: B.srcElement || A,
relatedTarget: h(B),
pageX: C.x,
pageY: C.y
});
return Object.extend(B, w)
}
} else {
y.prototype = window.Event.prototype || document.createEvent("HTMLEvents").__proto__;
Object.extend(y.prototype, w);
y.extend = Prototype.K
}
function n(E, D, F) {
var C = Element.retrieve(E, "prototype_event_registry");
if (Object.isUndefined(C)) {
d.push(E);
C = Element.retrieve(E, "prototype_event_registry", $H())
}
var A = C.get(D);
if (Object.isUndefined(A)) {
A = [];
C.set(D, A)
}
if (A.pluck("handler").include(F)) {
return false
}
var B;
if (D.include(":")) {
B = function (G) {
if (Object.isUndefined(G.eventName)) {
return false
}
if (G.eventName !== D) {
return false
}
y.extend(G, E);
F.call(E, G)
}
} else {
if (!z && (D === "mouseenter" || D === "mouseleave")) {
if (D === "mouseenter" || D === "mouseleave") {
B = function (H) {
y.extend(H, E);
var G = H.relatedTarget;
while (G && G !== E) {
try {
G = G.parentNode
} catch (I) {
G = E
}
}
if (G === E) {
return
}
F.call(E, H)
}
}
} else {
B = function (G) {
y.extend(G, E);
F.call(E, G)
}
}
}
B.handler = F;
A.push(B);
return B
}
function g() {
for (var A = 0, B = d.length; A < B; A++) {
y.stopObserving(d[A]);
d[A] = null
}
}
var d = [];
if (Prototype.Browser.IE) {
window.attachEvent("onunload", g)
}
if (Prototype.Browser.WebKit) {
window.addEventListener("unload", Prototype.emptyFunction, false)
}
var l = Prototype.K;
if (!z) {
l = function (B) {
var A = {
mouseenter: "mouseover",
mouseleave: "mouseout"
};
return B in A ? A[B] : B
}
}
function v(D, C, E) {
D = $(D);
var B = n(D, C, E);
if (!B) {
return D
}
if (C.include(":")) {
if (D.addEventListener) {
D.addEventListener("dataavailable", B, false)
} else {
D.attachEvent("ondataavailable", B);
D.attachEvent("onfilterchange", B)
}
} else {
var A = l(C);
if (D.addEventListener) {
D.addEventListener(A, B, false)
} else {
D.attachEvent("on" + A, B)
}
}
return D
}
function k(F, D, G) {
F = $(F);
var C = Element.retrieve(F, "prototype_event_registry");
if (Object.isUndefined(C)) {
return F
}
if (D && !G) {
var E = C.get(D);
if (Object.isUndefined(E)) {
return F
}
E.each(function (H) {
Element.stopObserving(F, D, H.handler)
});
return F
} else {
if (!D) {
C.each(function (J) {
var H = J.key,
I = J.value;
I.each(function (K) {
Element.stopObserving(F, H, K.handler)
})
});
return F
}
}
var E = C.get(D);
if (!E) {
return
}
var B = E.find(function (H) {
return H.handler === G
});
if (!B) {
return F
}
var A = l(D);
if (D.include(":")) {
if (F.removeEventListener) {
F.removeEventListener("dataavailable", B, false)
} else {
F.detachEvent("ondataavailable", B);
F.detachEvent("onfilterchange", B)
}
} else {
if (F.removeEventListener) {
F.removeEventListener(A, B, false)
} else {
F.detachEvent("on" + A, B)
}
}
C.set(D, E.without(B));
return F
}
function x(D, C, B, A) {
D = $(D);
if (Object.isUndefined(A)) {
A = true
}
if (D == document && document.createEvent && !D.dispatchEvent) {
D = document.documentElement
}
var E;
if (document.createEvent) {
E = document.createEvent("HTMLEvents");
E.initEvent("dataavailable", true, true)
} else {
E = document.createEventObject();
E.eventType = A ? "ondataavailable" : "onfilterchange"
}
E.eventName = C;
E.memo = B || {};
if (document.createEvent) {
D.dispatchEvent(E)
} else {
D.fireEvent(E.eventType, E)
}
return y.extend(E)
}
Object.extend(y, y.Methods);
Object.extend(y, {
fire: x,
observe: v,
stopObserving: k
});
Element.addMethods({
fire: x,
observe: v,
stopObserving: k
});
Object.extend(document, {
fire: x.methodize(),
observe: v.methodize(),
stopObserving: k.methodize(),
loaded: false
});
if (window.Event) {
Object.extend(window.Event, y)
} else {
window.Event = y
}
})();
(function () {
var d;
function a() {
if (document.loaded) {
return
}
if (d) {
window.clearTimeout(d)
}
document.loaded = true;
document.fire("dom:loaded")
}
function c() {
if (document.readyState === "complete") {
document.stopObserving("readystatechange", c);
a()
}
}
function b() {
try {
document.documentElement.doScroll("left")
} catch (f) {
d = b.defer();
return
}
a()
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", a, false)
} else {
document.observe("readystatechange", c);
if (window == top) {
d = b.defer()
}
}
Event.observe(window, "load", a)
})();
Element.addMethods();
Hash.toQueryString = Object.toQueryString;
var Toggle = {
display: Element.toggle
};
Element.Methods.childOf = Element.Methods.descendantOf;
var Insertion = {
Before: function (a, b) {
return Element.insert(a, {
before: b
})
},
Top: function (a, b) {
return Element.insert(a, {
top: b
})
},
Bottom: function (a, b) {
return Element.insert(a, {
bottom: b
})
},
After: function (a, b) {
return Element.insert(a, {
after: b
})
}
};
var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
var Position = {
includeScrollOffsets: false,
prepare: function () {
this.deltaX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
},
within: function (b, a, c) {
if (this.includeScrollOffsets) {
return this.withinIncludingScrolloffsets(b, a, c)
}
this.xcomp = a;
this.ycomp = c;
this.offset = Element.cumulativeOffset(b);
return (c >= this.offset[1] && c < this.offset[1] + b.offsetHeight && a >= this.offset[0] && a < this.offset[0] + b.offsetWidth)
},
withinIncludingScrolloffsets: function (b, a, d) {
var c = Element.cumulativeScrollOffset(b);
this.xcomp = a + c[0] - this.deltaX;
this.ycomp = d + c[1] - this.deltaY;
this.offset = Element.cumulativeOffset(b);
return (this.ycomp >= this.offset[1] && this.ycomp < this.offset[1] + b.offsetHeight && this.xcomp >= this.offset[0] && this.xcomp < this.offset[0] + b.offsetWidth)
},
overlap: function (b, a) {
if (!b) {
return 0
}
if (b == "vertical") {
return ((this.offset[1] + a.offsetHeight) - this.ycomp) / a.offsetHeight
}
if (b == "horizontal") {
return ((this.offset[0] + a.offsetWidth) - this.xcomp) / a.offsetWidth
}
},
cumulativeOffset: Element.Methods.cumulativeOffset,
positionedOffset: Element.Methods.positionedOffset,
absolutize: function (a) {
Position.prepare();
return Element.absolutize(a)
},
relativize: function (a) {
Position.prepare();
return Element.relativize(a)
},
realOffset: Element.Methods.cumulativeScrollOffset,
offsetParent: Element.Methods.getOffsetParent,
page: Element.Methods.viewportOffset,
clone: function (b, c, a) {
a = a || {};
return Element.clonePosition(c, b, a)
}
};
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (b) {
function a(c) {
return c.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + c + " ')]"
}
b.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
function (c, f) {
f = f.toString().strip();
var d = /\s/.test(f) ? $w(f).map(a).join("") : a(f);
return d ? document._getElementsByXPath(".//*" + d, c) : []
} : function (f, g) {
g = g.toString().strip();
var h = [],
j = (/\s/.test(g) ? $w(g) : null);
if (!j && !g) {
return h
}
var c = $(f).getElementsByTagName("*");
g = " " + g + " ";
for (var d = 0, l, k; l = c[d]; d++) {
if (l.className && (k = " " + l.className + " ") && (k.include(g) || (j && j.all(function (m) {
return !m.toString().blank() && k.include(" " + m + " ")
})))) {
h.push(Element.extend(l))
}
}
return h
};
return function (d, c) {
return $(c || document.body).getElementsByClassName(d)
}
}(Element.Methods)
}
Element.ClassNames = Class.create();
Element.ClassNames.prototype = {
initialize: function (a) {
this.element = $(a)
},
_each: function (a) {
this.element.className.split(/\s+/).select(function (b) {
return b.length > 0
})._each(a)
},
set: function (a) {
this.element.className = a
},
add: function (a) {
if (this.include(a)) {
return
}
this.set($A(this).concat(a).join(" "))
},
remove: function (a) {
if (!this.include(a)) {
return
}
this.set($A(this).without(a).join(" "))
},
toString: function () {
return $A(this).join(" ")
}
};
Object.extend(Element.ClassNames.prototype, Enumerable);
var FastInit = {
onload: function () {
if (FastInit.done) {
return
}
FastInit.done = true;
for (var a = 0, b = FastInit.f.length; a < b; a++) {
FastInit.f[a]()
}
},
addOnLoad: function () {
var c = arguments;
for (var b = 0, d = c.length; b < d; b++) {
if (typeof c[b] === "function") {
if (FastInit.done) {
c[b]()
} else {
FastInit.f.push(c[b])
}
}
}
},
listen: function () {
if (/WebKit|khtml/i.test(navigator.userAgent)) {
FastInit.timer = setInterval(function () {
if (/loaded|complete/.test(document.readyState)) {
clearInterval(FastInit.timer);
delete FastInit.timer;
FastInit.onload()
}
}, 10)
} else {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", FastInit.onload, false)
} else {
if (!FastInit.iew32) {
if (window.addEventListener) {
window.addEventListener("load", FastInit.onload, false)
} else {
if (window.attachEvent) {
return window.attachEvent("onload", FastInit.onload)
}
}
}
}
}
},
f: [],
done: false,
timer: null,
iew32: false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
if (typeof (Control) == "undefined") {
Control = {}
}
var $proc = function (a) {
return typeof (a) == "function" ? a : function () {
return a
}
};
var $value = function (a) {
return typeof (a) == "function" ? a() : a
};
Object.Event = {
extend: function (a) {
a._objectEventSetup = function (b) {
this._observers = this._observers || {};
this._observers[b] = this._observers[b] || []
};
a.observe = function (d, b) {
if (typeof (d) == "string" && typeof (b) != "undefined") {
this._objectEventSetup(d);
if (!this._observers[d].include(b)) {
this._observers[d].push(b)
}
} else {
for (var c in d) {
this.observe(c, d[c])
}
}
};
a.stopObserving = function (c, b) {
this._objectEventSetup(c);
if (c && b) {
this._observers[c] = this._observers[c].without(b)
} else {
if (c) {
this._observers[c] = []
} else {
this._observers = {}
}
}
};
a.observeOnce = function (d, c) {
var b = function () {
c.apply(this, arguments);
this.stopObserving(d, b)
}.bind(this);
this._objectEventSetup(d);
this._observers[d].push(b)
};
a.notify = function (g) {
this._objectEventSetup(g);
var d = [];
var b = $A(arguments).slice(1);
try {
for (var c = 0; c < this._observers[g].length; ++c) {
d.push(this._observers[g][c].apply(this._observers[g][c], b) || null)
}
} catch (f) {
if (f == $break) {
return false
} else {
throw f
}
}
return d
};
if (a.prototype) {
a.prototype._objectEventSetup = a._objectEventSetup;
a.prototype.observe = a.observe;
a.prototype.stopObserving = a.stopObserving;
a.prototype.observeOnce = a.observeOnce;
a.prototype.notify = function (g) {
if (a.notify) {
var b = $A(arguments).slice(1);
b.unshift(this);
b.unshift(g);
a.notify.apply(a, b)
}
this._objectEventSetup(g);
var b = $A(arguments).slice(1);
var d = [];
try {
if (this.options && this.options[g] && typeof (this.options[g]) == "function") {
d.push(this.options[g].apply(this, b) || null)
}
for (var c = 0; c < this._observers[g].length; ++c) {
d.push(this._observers[g][c].apply(this._observers[g][c], b) || null)
}
} catch (f) {
if (f == $break) {
return false
} else {
throw f
}
}
return d
}
}
}
};
Element.addMethods({
observeOnce: function (c, d, b) {
var a = function () {
b.apply(this, arguments);
Element.stopObserving(c, d, a)
};
Element.observe(c, d, a)
}
});
Object.extend(Event, (function () {
var b = Event.cache;
function c(l) {
if (l._prototypeEventID) {
return l._prototypeEventID[0]
}
arguments.callee.id = arguments.callee.id || 1;
return l._prototypeEventID = [++arguments.callee.id]
}
function h(l) {
if (l && l.include(":")) {
return "dataavailable"
}
if (!Prototype.Browser.IE) {
l = {
mouseenter: "mouseover",
mouseleave: "mouseout"
}[l] || l
}
return l
}
function a(l) {
return b[l] = b[l] || {}
}
function g(n, l) {
var m = a(n);
return m[l] = m[l] || []
}
function j(m, l, n) {
var q = c(m);
var p = g(q, l);
if (p.pluck("handler").include(n)) {
return false
}
var o = function (r) {
if (!Event || !Event.extend || (r.eventName && r.eventName != l)) {
return false
}
Event.extend(r);
n.call(m, r)
};
if (!(Prototype.Browser.IE) && ["mouseenter", "mouseleave"].include(l)) {
o = o.wrap(function (u, t) {
var r = t.relatedTarget;
var v = t.currentTarget;
if (r && r.nodeType == Node.TEXT_NODE) {
r = r.parentNode
}
if (r && r != v && !r.descendantOf(v)) {
return u(t)
}
})
}
o.handler = n;
p.push(o);
return o
}
function k(o, l, m) {
var n = g(o, l);
return n.find(function (p) {
return p.handler == m
})
}
function d(o, l, m) {
var n = a(o);
if (!n[l]) {
return false
}
n[l] = n[l].without(k(o, l, m))
}
function f() {
for (var m in b) {
for (var l in b[m]) {
b[m][l] = null
}
}
}
if (window.attachEvent) {
window.attachEvent("onunload", f)
}
return {
observe: function (n, l, o) {
n = $(n);
var m = h(l);
var p = j(n, l, o);
if (!p) {
return n
}
if (n.addEventListener) {
n.addEventListener(m, p, false)
} else {
n.attachEvent("on" + m, p)
}
return n
},
stopObserving: function (n, l, o) {
n = $(n);
var q = c(n),
m = h(l);
if (!o && l) {
g(q, l).each(function (r) {
n.stopObserving(l, r.handler)
});
return n
} else {
if (!l) {
Object.keys(a(q)).each(function (r) {
n.stopObserving(r)
});
return n
}
}
var p = k(q, l, o);
if (!p) {
return n
}
if (n.removeEventListener) {
n.removeEventListener(m, p, false)
} else {
n.detachEvent("on" + m, p)
}
d(q, l, o);
return n
},
fire: function (n, m, l) {
n = $(n);
if (n == document && document.createEvent && !n.dispatchEvent) {
n = document.documentElement
}
var o;
if (document.createEvent) {
o = document.createEvent("HTMLEvents");
o.initEvent("dataavailable", true, true)
} else {
o = document.createEventObject();
o.eventType = "ondataavailable"
}
o.eventName = m;
o.memo = l || {};
if (document.createEvent) {
n.dispatchEvent(o)
} else {
n.fireEvent(o.eventType, o)
}
return Event.extend(o)
}
}
})());
Object.extend(Event, Event.Methods);
Element.addMethods({
fire: Event.fire,
observe: Event.observe,
stopObserving: Event.stopObserving
});
Object.extend(document, {
fire: Element.Methods.fire.methodize(),
observe: Element.Methods.observe.methodize(),
stopObserving: Element.Methods.stopObserving.methodize()
});
(function () {
function a(c) {
var d;
if (c.wheelDelta) {
d = c.wheelDelta / 120
} else {
if (c.detail) {
d = -c.detail / 3
}
}
if (!d) {
return
}
var b = Event.element(c).fire("mouse:wheel", {
delta: d
});
if (b.stopped) {
Event.stop(c);
return false
}
}
document.observe("mousewheel", a);
document.observe("DOMMouseScroll", a)
})();
var IframeShim = Class.create({
initialize: function () {
this.element = new Element("iframe", {
style: "position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none",
src: "javascript:void(0);",
frameborder: 0
});
$(document.body).insert(this.element)
},
hide: function () {
this.element.hide();
return this
},
show: function () {
this.element.show();
return this
},
positionUnder: function (a) {
var a = $(a);
var c = a.cumulativeOffset();
var b = a.getDimensions();
this.element.setStyle({
left: c[0] + "px",
top: c[1] + "px",
width: b.width + "px",
height: b.height + "px",
zIndex: a.getStyle("zIndex") - 1
}).show();
return this
},
setBounds: function (a) {
for (prop in a) {
a[prop] += "px"
}
this.element.setStyle(a);
return this
},
destroy: function () {
if (this.element) {
this.element.remove()
}
return this
}
});
if (typeof (Draggable) != "undefined") {
Draggable.prototype.draw = function (l) {
var k = Position.cumulativeOffset(this.element);
if (this.options.ghosting) {
var a = Position.realOffset(this.element);
k[0] += a[0] - Position.deltaX;
k[1] += a[1] - Position.deltaY
}
var j = this.currentDelta();
k[0] -= j[0];
k[1] -= j[1];
if (this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
k[0] -= this.options.scroll.scrollLeft - this.originalScrollLeft;
k[1] -= this.options.scroll.scrollTop - this.originalScrollTop
}
var c = [0, 1].map(function (d) {
return (l[d] - k[d] - this.offset[d])
}.bind(this));
if (this.options.snap) {
if (typeof this.options.snap == "function") {
c = this.options.snap(c[0], c[1], this)
} else {
if (this.options.snap instanceof Array) {
c = c.map(function (d, o) {
return Math.round(d / this.options.snap[o]) * this.options.snap[o]
}.bind(this))
} else {
c = c.map(function (d) {
return Math.round(d / this.options.snap) * this.options.snap
}.bind(this))
}
}
}
if (this.options.onDraw) {
this.options.onDraw.bind(this)(c)
} else {
var b = this.element.style;
if (this.options.constrainToViewport) {
var n = document.viewport.getDimensions();
var g = this.element.getDimensions();
var h = parseInt(this.element.getStyle("margin-top"));
var m = parseInt(this.element.getStyle("margin-left"));
var f = [
[0 - m, 0 - h],
[(n.width - g.width) - m, (n.height - g.height) - h]
];
if ((!this.options.constraint) || (this.options.constraint == "horizontal")) {
if ((c[0] >= f[0][0]) && (c[0] <= f[1][0])) {
this.element.style.left = c[0] + "px"
} else {
this.element.style.left = ((c[0] < f[0][0]) ? f[0][0] : f[1][0]) + "px"
}
}
if ((!this.options.constraint) || (this.options.constraint == "vertical")) {
if ((c[1] >= f[0][1]) && (c[1] <= f[1][1])) {
this.element.style.top = c[1] + "px"
} else {
this.element.style.top = ((c[1] <= f[0][1]) ? f[0][1] : f[1][1]) + "px"
}
}
} else {
if ((!this.options.constraint) || (this.options.constraint == "horizontal")) {
b.left = c[0] + "px"
}
if ((!this.options.constraint) || (this.options.constraint == "vertical")) {
b.top = c[1] + "px"
}
}
if (b.visibility == "hidden") {
b.visibility = ""
}
}
}
}
if (typeof (Prototype) == "undefined") {
throw "Control.Window requires Prototype to be loaded."
}
if (typeof (IframeShim) == "undefined") {
throw "Control.Window requires IframeShim to be loaded."
}
if (typeof (Object.Event) == "undefined") {
throw "Control.Window requires Object.Event to be loaded."
}
Control.Window = Class.create({
initialize: function (b, c) {
Control.Window.windows.push(this);
this.container = false;
this.isOpen = false;
this.href = false;
this.sourceContainer = false;
this.ajaxRequest = false;
this.remoteContentLoaded = false;
this.numberInSequence = Control.Window.windows.length + 1;
this.indicator = false;
this.effects = {
fade: false,
appear: false
};
this.indicatorEffects = {
fade: false,
appear: false
};
this.options = Object.extend({
beforeOpen: Prototype.emptyFunction,
afterOpen: Prototype.emptyFunction,
beforeClose: Prototype.emptyFunction,
afterClose: Prototype.emptyFunction,
height: null,
width: null,
className: false,
position: "center",
offsetLeft: 0,
offsetTop: 0,
iframe: false,
hover: false,
indicator: false,
closeOnClick: false,
iframeshim: true,
fade: false,
fadeDuration: 0.75,
draggable: false,
onDrag: Prototype.emptyFunction,
resizable: false,
minHeight: false,
minWidth: false,
maxHeight: false,
maxWidth: false,
onResize: Prototype.emptyFunction,
constrainToViewport: false,
method: "post",
parameters: {},
onComplete: Prototype.emptyFunction,
onSuccess: Prototype.emptyFunction,
onFailure: Prototype.emptyFunction,
onException: Prototype.emptyFunction,
onRemoteContentLoaded: Prototype.emptyFunction,
insertRemoteContentAt: false
}, c || {});
this.indicator = this.options.indicator ? $(this.options.indicator) : false;
if (b) {
if (typeof (b) == "string" && b.match(Control.Window.uriRegex)) {
this.href = b
} else {
this.container = $(b);
this.createDefaultContainer(b);
if (this.container && ((this.container.readAttribute("href") && this.container.readAttribute("href") != "") || (this.options.hover && this.options.hover !== true))) {
if (this.options.hover && this.options.hover !== true) {
this.sourceContainer = $(this.options.hover)
} else {
this.sourceContainer = this.container;
this.href = this.container.readAttribute("href");
var a = this.href.match(/^#(.+)$/);
if (a && a[1]) {
this.container = $(a[1]);
this.href = false
} else {
this.container = false
}
}
this.sourceContainerOpenHandler = function (f) {
this.open(f);
f.stop();
return false
}.bindAsEventListener(this);
this.sourceContainerCloseHandler = function (f) {
this.close(f)
}.bindAsEventListener(this);
this.sourceContainerMouseMoveHandler = function (f) {
this.position(f)
}.bindAsEventListener(this);
if (this.options.hover) {
this.sourceContainer.observe("mouseenter", this.sourceContainerOpenHandler);
this.sourceContainer.observe("mouseleave", this.sourceContainerCloseHandler);
if (this.options.position == "mouse") {
this.sourceContainer.observe("mousemove", this.sourceContainerMouseMoveHandler)
}
} else {
this.sourceContainer.observe("click", this.sourceContainerOpenHandler)
}
}
}
}
this.createDefaultContainer(b);
if (this.options.insertRemoteContentAt === false) {
this.options.insertRemoteContentAt = this.container
}
var d = {
margin: 0,
position: "absolute",
zIndex: Control.Window.initialZIndexForWindow()
};
if (this.options.width) {
d.width = $value(this.options.width) + "px"
}
if (this.options.height) {
d.height = $value(this.options.height) + "px"
}
this.container.setStyle(d);
if (this.options.className) {
this.container.addClassName(this.options.className)
}
this.positionHandler = this.position.bindAsEventListener(this);
this.outOfBoundsPositionHandler = this.ensureInBounds.bindAsEventListener(this);
this.bringToFrontHandler = this.bringToFront.bindAsEventListener(this);
this.container.observe("mousedown", this.bringToFrontHandler);
this.container.hide();
this.closeHandler = this.close.bindAsEventListener(this);
if (this.options.iframeshim) {
this.iFrameShim = new IframeShim();
this.iFrameShim.hide()
}
this.applyResizable();
this.applyDraggable();
Event.observe(window, "resize", this.outOfBoundsPositionHandler);
this.notify("afterInitialize")
},
open: function (c) {
if (this.isOpen) {
this.bringToFront();
return false
}
if (this.notify("beforeOpen") === false) {
return false
}
if (this.options.closeOnClick) {
if (this.options.closeOnClick === true) {
this.closeOnClickContainer = $(document.body)
} else {
if (this.options.closeOnClick == "container") {
this.closeOnClickContainer = this.container
} else {
if (this.options.closeOnClick == "overlay") {
Control.Overlay.load();
this.closeOnClickContainer = Control.Overlay.container
} else {
this.closeOnClickContainer = $(this.options.closeOnClick)
}
}
}
this.closeOnClickContainer.observe("click", this.closeHandler)
}
if (this.href && !this.options.iframe && !this.remoteContentLoaded) {
this.remoteContentLoaded = true;
if (this.href.match(/\.(jpe?g|gif|png|tiff?)$/i)) {
var a = new Element("img");
a.observe("load", function (d) {
this.getRemoteContentInsertionTarget().insert(d);
this.position();
if (this.notify("onRemoteContentLoaded") !== false) {
if (this.options.indicator) {
this.hideIndicator()
}
this.finishOpen()
}
}.bind(this, a));
a.writeAttribute("src", this.href)
} else {
if (!this.ajaxRequest) {
if (this.options.indicator) {
this.showIndicator()
}
this.ajaxRequest = new Ajax.Request(this.href, {
method: this.options.method,
parameters: this.options.parameters,
onComplete: function (d) {
this.notify("onComplete", d);
this.ajaxRequest = false
}.bind(this),
onSuccess: function (d) {
this.getRemoteContentInsertionTarget().insert(d.responseText);
this.notify("onSuccess", d);
if (this.notify("onRemoteContentLoaded") !== false) {
if (this.options.indicator) {
this.hideIndicator()
}
this.finishOpen()
}
}.bind(this),
onFailure: function (d) {
this.notify("onFailure", d);
if (this.options.indicator) {
this.hideIndicator()
}
}.bind(this),
onException: function (d, f) {
this.notify("onException", d, f);
if (this.options.indicator) {
this.hideIndicator()
}
}.bind(this)
})
}
}
return true
} else {
if (this.options.iframe && !this.remoteContentLoaded) {
this.remoteContentLoaded = true;
if (this.options.indicator) {
this.showIndicator()
}
this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({
href: this.href
}));
var b = this.container.down("iframe");
b.onload = function () {
this.notify("onRemoteContentLoaded");
if (this.options.indicator) {
this.hideIndicator()
}
b.onload = null
}.bind(this)
}
}
this.finishOpen(c);
return true
},
close: function (a) {
if (!this.isOpen || this.notify("beforeClose", a) === false) {
return false
}
if (this.options.closeOnClick) {
this.closeOnClickContainer.stopObserving("click", this.closeHandler)
}
if (this.options.fade) {
this.effects.fade = new Effect.Fade(this.container, {
queue: {
position: "front",
scope: "Control.Window" + this.numberInSequence
},
from: 1,
to: 0,
duration: this.options.fadeDuration / 2,
afterFinish: function () {
if (this.iFrameShim) {
this.iFrameShim.hide()
}
this.isOpen = false;
this.notify("afterClose")
}.bind(this)
})
} else {
this.container.hide();
if (this.iFrameShim) {
this.iFrameShim.hide()
}
}
if (this.ajaxRequest) {
this.ajaxRequest.transport.abort()
}
if (!(this.options.draggable || this.options.resizable) && this.options.position == "center") {
Event.stopObserving(window, "resize", this.positionHandler)
}
if (!this.options.draggable && this.options.position == "center") {
Event.stopObserving(window, "scroll", this.positionHandler)
}
if (this.options.indicator) {
this.hideIndicator()
}
if (!this.options.fade) {
this.isOpen = false;
this.notify("afterClose")
}
return true
},
position: function (d) {
if (this.options.position == "mouse") {
var h = [Event.pointerX(d), Event.pointerY(d)];
this.container.setStyle({
top: h[1] + $value(this.options.offsetTop) + "px",
left: h[0] + $value(this.options.offsetLeft) + "px"
});
return
}
var j = this.container.getDimensions();
var c = document.viewport.getDimensions();
Position.prepare();
var b = (Position.deltaX + Math.floor((c.width - j.width) / 2));
var a = (Position.deltaY + ((c.height > j.height) ? Math.floor((c.height - j.height) / 2) : 0));
if (this.options.position == "center") {
this.container.setStyle({
top: (j.height <= c.height) ? ((a != null && a > 0) ? a : 0) + "px" : 0,
left: (j.width <= c.width) ? ((b != null && b > 0) ? b : 0) + "px" : 0
})
} else {
if (this.options.position == "relative") {
var h = this.sourceContainer.cumulativeOffset();
var g = h[1] + $value(this.options.offsetTop);
var f = h[0] + $value(this.options.offsetLeft);
this.container.setStyle({
top: (j.height <= c.height) ? (this.options.constrainToViewport ? Math.max(0, Math.min(c.height - (j.height), g)) : g) + "px" : 0,
left: (j.width <= c.width) ? (this.options.constrainToViewport ? Math.max(0, Math.min(c.width - (j.width), f)) : f) + "px" : 0
})
} else {
if (this.options.position.length) {
var g = $value(this.options.position[1]) + $value(this.options.offsetTop);
var f = $value(this.options.position[0]) + $value(this.options.offsetLeft);
this.container.setStyle({
top: (j.height <= c.height) ? (this.options.constrainToViewport ? Math.max(0, Math.min(c.height - (j.height), g)) : g) + "px" : 0,
left: (j.width <= c.width) ? (this.options.constrainToViewport ? Math.max(0, Math.min(c.width - (j.width), f)) : f) + "px" : 0
})
}
}
}
if (this.iFrameShim) {
this.updateIFrameShimZIndex()
}
},
ensureInBounds: function () {
if (!this.isOpen) {
return
}
var a = document.viewport.getDimensions();
var c = this.container.cumulativeOffset();
var b = this.container.getDimensions();
if (c.left + b.width > a.width) {
this.container.setStyle({
left: (Math.max(0, a.width - b.width)) + "px"
})
}
if (c.top + b.height > a.height) {
this.container.setStyle({
top: (Math.max(0, a.height - b.height)) + "px"
})
}
},
bringToFront: function () {
Control.Window.bringToFront(this);
this.notify("bringToFront")
},
destroy: function () {
this.container.stopObserving("mousedown", this.bringToFrontHandler);
if (this.draggable) {
Draggables.removeObserver(this.container);
this.draggable.handle.stopObserving("mousedown", this.bringToFrontHandler);
this.draggable.destroy()
}
if (this.resizable) {
Resizables.removeObserver(this.container);
this.resizable.handle.stopObserving("mousedown", this.bringToFrontHandler);
this.resizable.destroy()
}
if (this.container && !this.sourceContainer) {
this.container.remove()
}
if (this.sourceContainer) {
if (this.options.hover) {
this.sourceContainer.stopObserving("mouseenter", this.sourceContainerOpenHandler);
this.sourceContainer.stopObserving("mouseleave", this.sourceContainerCloseHandler);
if (this.options.position == "mouse") {
this.sourceContainer.stopObserving("mousemove", this.sourceContainerMouseMoveHandler)
}
} else {
this.sourceContainer.stopObserving("click", this.sourceContainerOpenHandler)
}
}
if (this.iFrameShim) {
this.iFrameShim.destroy()
}
Event.stopObserving(window, "resize", this.outOfBoundsPositionHandler);
Control.Window.windows = Control.Window.windows.without(this);
this.notify("afterDestroy")
},
applyResizable: function () {
if (this.options.resizable) {
if (typeof (Resizable) == "undefined") {
throw "Control.Window requires resizable.js to be loaded."
}
var a = null;
if (this.options.resizable === true) {
a = new Element("div", {
className: "resizable_handle"
});
this.container.insert(a)
} else {
a = $(this.options.resziable)
}
this.resizable = new Resizable(this.container, {
handle: a,
minHeight: this.options.minHeight,
minWidth: this.options.minWidth,
maxHeight: this.options.constrainToViewport ?
function (b) {
return (document.viewport.getDimensions().height - parseInt(b.style.top || 0)) - (b.getHeight() - parseInt(b.style.height || 0))
} : this.options.maxHeight,
maxWidth: this.options.constrainToViewport ?
function (b) {
return (document.viewport.getDimensions().width - parseInt(b.style.left || 0)) - (b.getWidth() - parseInt(b.style.width || 0))
} : this.options.maxWidth
});
this.resizable.handle.observe("mousedown", this.bringToFrontHandler);
Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this, function () {
if (this.iFrameShim) {
this.updateIFrameShimZIndex()
}
this.notify("onResize")
}.bind(this)))
}
},
applyDraggable: function () {
if (this.options.draggable) {
if (typeof (Draggables) == "undefined") {
throw "Control.Window requires dragdrop.js to be loaded."
}
var a = null;
if (this.options.draggable === true) {
a = new Element("div", {
className: "draggable_handle"
});
this.container.insert(a)
} else {
a = $(this.options.draggable)
}
this.draggable = new Draggable(this.container, {
handle: a,
constrainToViewport: this.options.constrainToViewport,
zindex: this.container.getStyle("z-index"),
starteffect: function () {
if (Prototype.Browser.IE) {
this.old_onselectstart = document.onselectstart;
document.onselectstart = function () {
return false
}
}
}.bind(this),
endeffect: function () {
document.onselectstart = this.old_onselectstart
}.bind(this)
});
this.draggable.handle.observe("mousedown", this.bringToFrontHandler);
Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this, function () {
if (this.iFrameShim) {
this.updateIFrameShimZIndex()
}
this.notify("onDrag")
}.bind(this)))
}
},
createDefaultContainer: function (a) {
if (!this.container) {
this.container = new Element("div", {
id: "control_window_" + this.numberInSequence
});
$(document.body).insert(this.container);
if (typeof (a) == "string" && $(a) == null && !a.match(/^#(.+)$/) && !a.match(Control.Window.uriRegex)) {
this.container.update(a)
}
}
},
finishOpen: function (a) {
this.bringToFront();
if (this.options.fade) {
if (typeof (Effect) == "undefined") {
throw "Control.Window requires effects.js to be loaded."
}
if (this.effects.fade) {
this.effects.fade.cancel()
}
this.effects.appear = new Effect.Appear(this.container, {
queue: {
position: "end",
scope: "Control.Window." + this.numberInSequence
},
from: 0,
to: 1,
duration: this.options.fadeDuration / 2,
afterFinish: function () {
if (this.iFrameShim) {
this.updateIFrameShimZIndex()
}
this.isOpen = true;
this.notify("afterOpen")
}.bind(this)
})
} else {
this.container.show()
}
this.position(a);
if (!(this.options.draggable || this.options.resizable) && this.options.position == "center") {
Event.observe(window, "resize", this.positionHandler, false)
}
if (!this.options.draggable && this.options.position == "center") {
Event.observe(window, "scroll", this.positionHandler, false)
}
if (!this.options.fade) {
this.isOpen = true;
this.notify("afterOpen")
}
return true
},
showIndicator: function () {
this.showIndicatorTimeout = window.setTimeout(function () {
if (this.options.fade) {
this.indicatorEffects.appear = new Effect.Appear(this.indicator, {
queue: {
position: "front",
scope: "Control.Window.indicator." + this.numberInSequence
},
from: 0,
to: 1,
duration: this.options.fadeDuration / 2
})
} else {
this.indicator.show()
}
}.bind(this), Control.Window.indicatorTimeout)
},
hideIndicator: function () {
if (this.showIndicatorTimeout) {
window.clearTimeout(this.showIndicatorTimeout)
}
this.indicator.hide()
},
getRemoteContentInsertionTarget: function () {
return typeof (this.options.insertRemoteContentAt) == "string" ? this.container.down(this.options.insertRemoteContentAt) : $(this.options.insertRemoteContentAt)
},
updateIFrameShimZIndex: function () {
if (this.iFrameShim) {
this.iFrameShim.positionUnder(this.container)
}
}
});
Object.extend(Control.Window, {
windows: [],
baseZIndex: 9999,
indicatorTimeout: 250,
iframeTemplate: new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),
uriRegex: /^(\/|\#|https?\:\/\/|[\w]+\/)/,
bringToFront: function (a) {
Control.Window.windows = Control.Window.windows.without(a);
Control.Window.windows.push(a);
Control.Window.windows.each(function (c, d) {
var b = Control.Window.baseZIndex + d;
c.container.setStyle({
zIndex: b
});
if (c.isOpen) {
if (c.iFrameShim) {
c.updateIFrameShimZIndex()
}
}
if (c.options.draggable) {
c.draggable.options.zindex = b
}
})
},
open: function (b, c) {
var a = new Control.Window(b, c);
a.open();
return a
},
initialZIndexForWindow: function (a) {
return Control.Window.baseZIndex + (Control.Window.windows.length - 1)
}
});
Object.Event.extend(Control.Window);
Control.Window.LayoutUpdateObserver = Class.create({
initialize: function (a, b) {
this.w = a;
this.element = $(a.container);
this.observer = b
},
onStart: Prototype.emptyFunction,
onEnd: function (b, a) {
if (a.element == this.element && this.iFrameShim) {
this.w.updateIFrameShimZIndex()
}
},
onResize: function (b, a) {
if (a.element == this.element) {
this.observer(this.element)
}
},
onDrag: function (b, a) {
if (a.element == this.element) {
this.observer(this.element)
}
}
});
Control.Overlay = {
id: "control_overlay",
loaded: false,
container: false,
lastOpacity: 0,
styles: {
position: "fixed",
top: 0,
left: 0,
width: "100%",
height: "100%",
zIndex: 9998
},
ieStyles: {
position: "absolute",
top: 0,
left: 0,
zIndex: 9998
},
effects: {
fade: false,
appear: false
},
load: function () {
if (Control.Overlay.loaded) {
return false
}
Control.Overlay.loaded = true;
Control.Overlay.container = new Element("div", {
id: Control.Overlay.id
});
$(document.body).insert(Control.Overlay.container);
if (Prototype.Browser.IE) {
Control.Overlay.container.setStyle(Control.Overlay.ieStyles);
Event.observe(window, "scroll", Control.Overlay.positionOverlay);
Event.observe(window, "resize", Control.Overlay.positionOverlay);
Control.Overlay.observe("beforeShow", Control.Overlay.positionOverlay)
} else {
Control.Overlay.container.setStyle(Control.Overlay.styles)
}
Control.Overlay.iFrameShim = new IframeShim();
Control.Overlay.iFrameShim.hide();
Event.observe(window, "resize", Control.Overlay.positionIFrameShim);
Control.Overlay.container.hide();
return true
},
unload: function () {
if (!Control.Overlay.loaded) {
return false
}
Event.stopObserving(window, "resize", Control.Overlay.positionOverlay);
Control.Overlay.stopObserving("beforeShow", Control.Overlay.positionOverlay);
Event.stopObserving(window, "resize", Control.Overlay.positionIFrameShim);
Control.Overlay.iFrameShim.destroy();
Control.Overlay.container.remove();
Control.Overlay.loaded = false;
return true
},
show: function (a, b) {
if (Control.Overlay.notify("beforeShow") === false) {
return false
}
Control.Overlay.lastOpacity = a;
Control.Overlay.positionIFrameShim();
Control.Overlay.iFrameShim.show();
if (b) {
if (typeof (Effect) == "undefined") {
throw "Control.Window requires effects.js to be loaded."
}
if (Control.Overlay.effects.fade) {
Control.Overlay.effects.fade.cancel()
}
Control.Overlay.effects.appear = new Effect.Appear(Control.Overlay.container, {
queue: {
position: "end",
scope: "Control.Overlay"
},
afterFinish: function () {
Control.Overlay.notify("afterShow")
},
from: 0,
to: Control.Overlay.lastOpacity,
duration: (b === true ? 0.75 : b) / 2
})
} else {
Control.Overlay.container.setStyle({
opacity: a || 1
});
Control.Overlay.container.show();
Control.Overlay.notify("afterShow")
}
return true
},
hide: function (a) {
if (Control.Overlay.notify("beforeHide") === false) {
return false
}
if (Control.Overlay.effects.appear) {
Control.Overlay.effects.appear.cancel()
}
Control.Overlay.iFrameShim.hide();
if (a) {
Control.Overlay.effects.fade = new Effect.Fade(Control.Overlay.container, {
queue: {
position: "front",
scope: "Control.Overlay"
},
afterFinish: function () {
Control.Overlay.notify("afterHide")
},
from: Control.Overlay.lastOpacity,
to: 0,
duration: (a === true ? 0.75 : a) / 2
})
} else {
Control.Overlay.container.hide();
Control.Overlay.notify("afterHide")
}
return true
},
positionIFrameShim: function () {
if (Control.Overlay.container.visible()) {
Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container)
}
},
positionOverlay: function () {
Control.Overlay.container.setStyle({
width: document.body.clientWidth + "px",
height: document.body.clientHeight + "px"
})
}
};
Object.Event.extend(Control.Overlay);
Control.ToolTip = Class.create(Control.Window, {
initialize: function ($super, a, c, b) {
$super(c, Object.extend(Object.extend(Object.clone(Control.ToolTip.defaultOptions), b || {}), {
position: "mouse",
hover: a
}))
}
});
Object.extend(Control.ToolTip, {
defaultOptions: {
offsetLeft: 10
}
});
Control.Modal = Class.create(Control.Window, {
initialize: function ($super, a, b) {
Control.Modal.InstanceMethods.beforeInitialize.bind(this)();
$super(a, Object.extend(Object.clone(Control.Modal.defaultOptions), b || {}))
}
});
Object.extend(Control.Modal, {
defaultOptions: {
overlayOpacity: 0.5,
closeOnClick: "overlay"
},
current: false,
open: function (a, b) {
var c = new Control.Modal(a, b);
c.open();
return c
},
close: function () {
if (Control.Modal.current) {
Control.Modal.current.close()
}
},
InstanceMethods: {
beforeInitialize: function () {
Control.Overlay.load();
this.overlayFinishedOpening = false;
this.observe("beforeOpen", Control.Modal.Observers.beforeOpen.bind(this));
this.observe("afterOpen", Control.Modal.Observers.afterOpen.bind(this));
this.observe("afterClose", Control.Modal.Observers.afterClose.bind(this))
}
},
Observers: {
beforeOpen: function () {
if (!this.overlayFinishedOpening) {
Control.Overlay.observeOnce("afterShow", function () {
this.overlayFinishedOpening = true;
this.open()
}.bind(this));
Control.Overlay.show(this.options.overlayOpacity, this.options.fade ? this.options.fadeDuration : false);
throw $break
} else {
Control.Window.windows.without(this).invoke("close")
}
},
afterOpen: function () {
Control.Modal.current = this
},
afterClose: function () {
Control.Overlay.hide(this.options.fade ? this.options.fadeDuration : false);
Control.Modal.current = false;
this.overlayFinishedOpening = false
}
}
});
Control.LightBox = Class.create(Control.Window, {
initialize: function ($super, a, b) {
this.allImagesLoaded = false;
if (b.modal) {
var b = Object.extend(Object.clone(Control.LightBox.defaultOptions), b || {});
b = Object.extend(Object.clone(Control.Modal.defaultOptions), b);
b = Control.Modal.InstanceMethods.beforeInitialize.bind(this)(b);
$super(a, b)
} else {
$super(a, Object.extend(Object.clone(Control.LightBox.defaultOptions), b || {}))
}
this.hasRemoteContent = this.href && !this.options.iframe;
if (this.hasRemoteContent) {
this.observe("onRemoteContentLoaded", Control.LightBox.Observers.onRemoteContentLoaded.bind(this))
} else {
this.applyImageObservers()
}
this.observe("beforeOpen", Control.LightBox.Observers.beforeOpen.bind(this))
},
applyImageObservers: function () {
var a = this.getImages();
this.numberImagesToLoad = a.length;
this.numberofImagesLoaded = 0;
a.each(function (b) {
b.observe("load", function (c) {
++this.numberofImagesLoaded;
if (this.numberImagesToLoad == this.numberofImagesLoaded) {
this.allImagesLoaded = true;
this.onAllImagesLoaded()
}
}.bind(this, b));
b.hide()
}.bind(this))
},
onAllImagesLoaded: function () {
this.getImages().each(function (a) {
this.showImage(a)
}.bind(this));
if (this.hasRemoteContent) {
if (this.options.indicator) {
this.hideIndicator()
}
this.finishOpen()
} else {
this.open()
}
},
getImages: function () {
return this.container.select(Control.LightBox.imageSelector)
},
showImage: function (a) {
a.show()
}
});
Object.extend(Control.LightBox, {
imageSelector: "img",
defaultOptions: {},
Observers: {
beforeOpen: function () {
if (!this.hasRemoteContent && !this.allImagesLoaded) {
throw $break
}
},
onRemoteContentLoaded: function () {
this.applyImageObservers();
if (!this.allImagesLoaded) {
throw $break
}
}
}
});
function OXH() {
this._ox = OX();
this._contentTopics = {};
this._customVariables = {};
this._adsFetched = false;
this.addContentTopic = function (b, a) {
this._contentTopics[b] = a;
this._ox.addContentTopic(b)
};
this.addVariable = function (b, a) {
this._customVariables[b] = a;
this._ox.addVariable(b, a)
};
this.contentTopics = function () {
return this._contentTopics
};
this.customVariables = function () {
return this._customVariables
};
this.addGroups = function (a) {
$A(a).each(function (b) {
this._ox.addPage(b)
}.bind(this))
};
this.addUnits = function (a) {
$A(a).each(function (b) {
this._ox.addAdUnit(b)
}.bind(this))
};
this.showAd = function (a) {
if (this._adsFetched) {
this._ox.showAdUnit(a)
}
};
this.fetchAds = function () {
this._ox.fetchAds();
this._adsFetched = true
}
}
String.prototype.parseColor = function () {
var a = "#";
if (this.slice(0, 4) == "rgb(") {
var c = this.slice(4, this.length - 1).split(",");
var b = 0;
do {
a += parseInt(c[b]).toColorPart()
} while (++b < 3)
} else {
if (this.slice(0, 1) == "#") {
if (this.length == 4) {
for (var b = 1; b < 4; b++) {
a += (this.charAt(b) + this.charAt(b)).toLowerCase()
}
}
if (this.length == 7) {
a = this.toLowerCase()
}
}
}
return (a.length == 7 ? a : (arguments[0] || this))
};
Element.collectTextNodes = function (a) {
return $A($(a).childNodes).collect(function (b) {
return (b.nodeType == 3 ? b.nodeValue : (b.hasChildNodes() ? Element.collectTextNodes(b) : ""))
}).flatten().join("")
};
Element.collectTextNodesIgnoreClass = function (a, b) {
return $A($(a).childNodes).collect(function (c) {
return (c.nodeType == 3 ? c.nodeValue : ((c.hasChildNodes() && !Element.hasClassName(c, b)) ? Element.collectTextNodesIgnoreClass(c, b) : ""))
}).flatten().join("")
};
Element.setContentZoom = function (a, b) {
a = $(a);
a.setStyle({
fontSize: (b / 100) + "em"
});
if (Prototype.Browser.WebKit) {
window.scrollBy(0, 0)
}
return a
};
Element.getInlineOpacity = function (a) {
return $(a).style.opacity || ""
};
Element.forceRerendering = function (a) {
try {
a = $(a);
var c = document.createTextNode(" ");
a.appendChild(c);
a.removeChild(c)
} catch (b) {}
};
var Effect = {
_elementDoesNotExistError: {
name: "ElementDoesNotExistError",
message: "The specified DOM element does not exist, but is required for this effect to operate"
},
Transitions: {
linear: Prototype.K,
sinoidal: function (a) {
return (-Math.cos(a * Math.PI) / 2) + 0.5
},
reverse: function (a) {
return 1 - a
},
flicker: function (a) {
var a = ((-Math.cos(a * Math.PI) / 4) + 0.75) + Math.random() / 4;
return a > 1 ? 1 : a
},
wobble: function (a) {
return (-Math.cos(a * Math.PI * (9 * a)) / 2) + 0.5
},
pulse: function (b, a) {
return (-Math.cos((b * ((a || 5) - 0.5) * 2) * Math.PI) / 2) + 0.5
},
spring: function (a) {
return 1 - (Math.cos(a * 4.5 * Math.PI) * Math.exp(-a * 6))
},
none: function (a) {
return 0
},
full: function (a) {
return 1
}
},
DefaultOptions: {
duration: 1,
fps: 100,
sync: false,
from: 0,
to: 1,
delay: 0,
queue: "parallel"
},
tagifyText: function (a) {
var b = "position:relative";
if (Prototype.Browser.IE) {
b += ";zoom:1"
}
a = $(a);
$A(a.childNodes).each(function (c) {
if (c.nodeType == 3) {
c.nodeValue.toArray().each(function (d) {
a.insertBefore(new Element("span", {
style: b
}).update(d == " " ? String.fromCharCode(160) : d), c)
});
Element.remove(c)
}
})
},
multiple: function (b, c) {
var f;
if (((typeof b == "object") || Object.isFunction(b)) && (b.length)) {
f = b
} else {
f = $(b).childNodes
}
var a = Object.extend({
speed: 0.1,
delay: 0
}, arguments[2] || {});
var d = a.delay;
$A(f).each(function (h, g) {
new c(h, Object.extend(a, {
delay: g * a.speed + d
}))
})
},
PAIRS: {
slide: ["SlideDown", "SlideUp"],
blind: ["BlindDown", "BlindUp"],
appear: ["Appear", "Fade"]
},
toggle: function (b, c, a) {
b = $(b);
c = (c || "appear").toLowerCase();
return Effect[Effect.PAIRS[c][b.visible() ? 1 : 0]](b, Object.extend({
queue: {
position: "end",
scope: (b.id || "global"),
limit: 1
}
}, a || {}))
}
};
Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;
Effect.ScopedQueue = Class.create(Enumerable, {
initialize: function () {
this.effects = [];
this.interval = null
},
_each: function (a) {
this.effects._each(a)
},
add: function (b) {
var c = new Date().getTime();
var a = Object.isString(b.options.queue) ? b.options.queue : b.options.queue.position;
switch (a) {
case "front":
this.effects.findAll(function (d) {
return d.state == "idle"
}).each(function (d) {
d.startOn += b.finishOn;
d.finishOn += b.finishOn
});
break;
case "with-last":
c = this.effects.pluck("startOn").max() || c;
break;
case "end":
c = this.effects.pluck("finishOn").max() || c;
break
}
b.startOn += c;
b.finishOn += c;
if (!b.options.queue.limit || (this.effects.length < b.options.queue.limit)) {
this.effects.push(b)
}
if (!this.interval) {
this.interval = setInterval(this.loop.bind(this), 15)
}
},
remove: function (a) {
this.effects = this.effects.reject(function (b) {
return b == a
});
if (this.effects.length == 0) {
clearInterval(this.interval);
this.interval = null
}
},
loop: function () {
var c = new Date().getTime();
for (var b = 0, a = this.effects.length; b < a; b++) {
this.effects[b] && this.effects[b].loop(c)
}
}
});
Effect.Queues = {
instances: $H(),
get: function (a) {
if (!Object.isString(a)) {
return a
}
return this.instances.get(a) || this.instances.set(a, new Effect.ScopedQueue())
}
};
Effect.Queue = Effect.Queues.get("global");
Effect.Base = Class.create({
position: null,
start: function (a) {
if (a && a.transition === false) {
a.transition = Effect.Transitions.linear
}
this.options = Object.extend(Object.extend({}, Effect.DefaultOptions), a || {});
this.currentFrame = 0;
this.state = "idle";
this.startOn = this.options.delay * 1000;
this.finishOn = this.startOn + (this.options.duration * 1000);
this.fromToDelta = this.options.to - this.options.from;
this.totalTime = this.finishOn - this.startOn;
this.totalFrames = this.options.fps * this.options.duration;
this.render = (function () {
function b(d, c) {
if (d.options[c + "Internal"]) {
d.options[c + "Internal"](d)
}
if (d.options[c]) {
d.options[c](d)
}
}
return function (c) {
if (this.state === "idle") {
this.state = "running";
b(this, "beforeSetup");
if (this.setup) {
this.setup()
}
b(this, "afterSetup")
}
if (this.state === "running") {
c = (this.options.transition(c) * this.fromToDelta) + this.options.from;
this.position = c;
b(this, "beforeUpdate");
if (this.update) {
this.update(c)
}
b(this, "afterUpdate")
}
}
})();
this.event("beforeStart");
if (!this.options.sync) {
Effect.Queues.get(Object.isString(this.options.queue) ? "global" : this.options.queue.scope).add(this)
}
},
loop: function (c) {
if (c >= this.startOn) {
if (c >= this.finishOn) {
this.render(1);
this.cancel();
this.event("beforeFinish");
if (this.finish) {
this.finish()
}
this.event("afterFinish");
return
}
var b = (c - this.startOn) / this.totalTime,
a = (b * this.totalFrames).round();
if (a > this.currentFrame) {
this.render(b);
this.currentFrame = a
}
}
},
cancel: function () {
if (!this.options.sync) {
Effect.Queues.get(Object.isString(this.options.queue) ? "global" : this.options.queue.scope).remove(this)
}
this.state = "finished"
},
event: function (a) {
if (this.options[a + "Internal"]) {
this.options[a + "Internal"](this)
}
if (this.options[a]) {
this.options[a](this)
}
},
inspect: function () {
var a = $H();
for (property in this) {
if (!Object.isFunction(this[property])) {
a.set(property, this[property])
}
}
return "#<Effect:" + a.inspect() + ",options:" + $H(this.options).inspect() + ">"
}
});
Effect.Parallel = Class.create(Effect.Base, {
initialize: function (a) {
this.effects = a || [];
this.start(arguments[1])
},
update: function (a) {
this.effects.invoke("render", a)
},
finish: function (a) {
this.effects.each(function (b) {
b.render(1);
b.cancel();
b.event("beforeFinish");
if (b.finish) {
b.finish(a)
}
b.event("afterFinish")
})
}
});
Effect.Tween = Class.create(Effect.Base, {
initialize: function (c, g, f) {
c = Object.isString(c) ? $(c) : c;
var b = $A(arguments),
d = b.last(),
a = b.length == 5 ? b[3] : null;
this.method = Object.isFunction(d) ? d.bind(c) : Object.isFunction(c[d]) ? c[d].bind(c) : function (h) {
c[d] = h
};
this.start(Object.extend({
from: g,
to: f
}, a || {}))
},
update: function (a) {
this.method(a)
}
});
Effect.Event = Class.create(Effect.Base, {
initialize: function () {
this.start(Object.extend({
duration: 0
}, arguments[0] || {}))
},
update: Prototype.emptyFunction
});
Effect.Opacity = Class.create(Effect.Base, {
initialize: function (b) {
this.element = $(b);
if (!this.element) {
throw (Effect._elementDoesNotExistError)
}
if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) {
this.element.setStyle({
zoom: 1
})
}
var a = Object.extend({
from: this.element.getOpacity() || 0,
to: 1
}, arguments[1] || {});
this.start(a)
},
update: function (a) {
this.element.setOpacity(a)
}
});
Effect.Move = Class.create(Effect.Base, {
initialize: function (b) {
this.element = $(b);
if (!this.element) {
throw (Effect._elementDoesNotExistError)
}
var a = Object.extend({
x: 0,
y: 0,
mode: "relative"
}, arguments[1] || {});
this.start(a)
},
setup: function () {
this.element.makePositioned();
this.originalLeft = parseFloat(this.element.getStyle("left") || "0");
this.originalTop = parseFloat(this.element.getStyle("top") || "0");
if (this.options.mode == "absolute") {
this.options.x = this.options.x - this.originalLeft;
this.options.y = this.options.y - this.originalTop
}
},
update: function (a) {
this.element.setStyle({
left: (this.options.x * a + this.originalLeft).round() + "px",
top: (this.options.y * a + this.originalTop).round() + "px"
})
}
});
Effect.MoveBy = function (b, a, c) {
return new Effect.Move(b, Object.extend({
x: c,
y: a
}, arguments[3] || {}))
};
Effect.Scale = Class.create(Effect.Base, {
initialize: function (b, c) {
this.element = $(b);
if (!this.element) {
throw (Effect._elementDoesNotExistError)
}
var a = Object.extend({
scaleX: true,
scaleY: true,
scaleContent: true,
scaleFromCenter: false,
scaleMode: "box",
scaleFrom: 100,
scaleTo: c
}, arguments[2] || {});
this.start(a)
},
setup: function () {
this.restoreAfterFinish = this.options.restoreAfterFinish || false;
this.elementPositioning = this.element.getStyle("position");
this.originalStyle = {};
["top", "left", "width", "height", "fontSize"].each(function (b) {
this.originalStyle[b] = this.element.style[b]
}.bind(this));
this.originalTop = this.element.offsetTop;
this.originalLeft = this.element.offsetLeft;
var a = this.element.getStyle("font-size") || "100%";
["em", "px", "%", "pt"].each(function (b) {
if (a.indexOf(b) > 0) {
this.fontSize = parseFloat(a);
this.fontSizeType = b
}
}.bind(this));
this.factor = (this.options.scaleTo - this.options.scaleFrom) / 100;
this.dims = null;
if (this.options.scaleMode == "box") {
this.dims = [this.element.offsetHeight, this.element.offsetWidth]
}
if (/^content/.test(this.options.scaleMode)) {
this.dims = [this.element.scrollHeight, this.element.scrollWidth]
}
if (!this.dims) {
this.dims = [this.options.scaleMode.originalHeight, this.options.scaleMode.originalWidth]
}
},
update: function (a) {
var b = (this.options.scaleFrom / 100) + (this.factor * a);
if (this.options.scaleContent && this.fontSize) {
this.element.setStyle({
fontSize: this.fontSize * b + this.fontSizeType
})
}
this.setDimensions(this.dims[0] * b, this.dims[1] * b)
},
finish: function (a) {
if (this.restoreAfterFinish) {
this.element.setStyle(this.originalStyle)
}
},
setDimensions: function (a, f) {
var g = {};
if (this.options.scaleX) {
g.width = f.round() + "px"
}
if (this.options.scaleY) {
g.height = a.round() + "px"
}
if (this.options.scaleFromCenter) {
var c = (a - this.dims[0]) / 2;
var b = (f - this.dims[1]) / 2;
if (this.elementPositioning == "absolute") {
if (this.options.scaleY) {
g.top = this.originalTop - c + "px"
}
if (this.options.scaleX) {
g.left = this.originalLeft - b + "px"
}
} else {
if (this.options.scaleY) {
g.top = -c + "px"
}
if (this.options.scaleX) {
g.left = -b + "px"
}
}
}
this.element.setStyle(g)
}
});
Effect.Highlight = Class.create(Effect.Base, {
initialize: function (b) {
this.element = $(b);
if (!this.element) {
throw (Effect._elementDoesNotExistError)
}
var a = Object.extend({
startcolor: "#ffff99"
}, arguments[1] || {});
this.start(a)
},
setup: function () {
if (this.element.getStyle("display") == "none") {
this.cancel();
return
}
this.oldStyle = {};
if (!this.options.keepBackgroundImage) {
this.oldStyle.backgroundImage = this.element.getStyle("background-image");
this.element.setStyle({
backgroundImage: "none"
})
}
if (!this.options.endcolor) {
this.options.endcolor = this.element.getStyle("background-color").parseColor("#ffffff")
}
if (!this.options.restorecolor) {
this.options.restorecolor = this.element.getStyle("background-color")
}
this._base = $R(0, 2).map(function (a) {
return parseInt(this.options.startcolor.slice(a * 2 + 1, a * 2 + 3), 16)
}.bind(this));
this._delta = $R(0, 2).map(function (a) {
return parseInt(this.options.endcolor.slice(a * 2 + 1, a * 2 + 3), 16) - this._base[a]
}.bind(this))
},
update: function (a) {
this.element.setStyle({
backgroundColor: $R(0, 2).inject("#", function (b, c, d) {
return b + ((this._base[d] + (this._delta[d] * a)).round().toColorPart())
}.bind(this))
})
},
finish: function () {
this.element.setStyle(Object.extend(this.oldStyle, {
backgroundColor: this.options.restorecolor
}))
}
});
Effect.ScrollTo = function (c) {
var b = arguments[1] || {},
a = document.viewport.getScrollOffsets(),
d = $(c).cumulativeOffset();
if (b.offset) {
d[1] += b.offset
}
return new Effect.Tween(null, a.top, d[1], b, function (f) {
scrollTo(a.left, f.round())
})
};
Effect.Fade = function (c) {
c = $(c);
var a = c.getInlineOpacity();
var b = Object.extend({
from: c.getOpacity() || 1,
to: 0,
afterFinishInternal: function (d) {
if (d.options.to != 0) {
return
}
d.element.hide().setStyle({
opacity: a
})
}
}, arguments[1] || {});
return new Effect.Opacity(c, b)
};
Effect.Appear = function (b) {
b = $(b);
var a = Object.extend({
from: (b.getStyle("display") == "none" ? 0 : b.getOpacity() || 0),
to: 1,
afterFinishInternal: function (c) {
c.element.forceRerendering()
},
beforeSetup: function (c) {
c.element.setOpacity(c.options.from).show()
}
}, arguments[1] || {});
return new Effect.Opacity(b, a)
};
Effect.Puff = function (b) {
b = $(b);
var a = {
opacity: b.getInlineOpacity(),
position: b.getStyle("position"),
top: b.style.top,
left: b.style.left,
width: b.style.width,
height: b.style.height
};
return new Effect.Parallel([new Effect.Scale(b, 200, {
sync: true,
scaleFromCenter: true,
scaleContent: true,
restoreAfterFinish: true
}), new Effect.Opacity(b, {
sync: true,
to: 0
})], Object.extend({
duration: 1,
beforeSetupInternal: function (c) {
Position.absolutize(c.effects[0].element)
},
afterFinishInternal: function (c) {
c.effects[0].element.hide().setStyle(a)
}
}, arguments[1] || {}))
};
Effect.BlindUp = function (a) {
a = $(a);
a.makeClipping();
return new Effect.Scale(a, 0, Object.extend({
scaleContent: false,
scaleX: false,
restoreAfterFinish: true,
afterFinishInternal: function (b) {
b.element.hide().undoClipping()
}
}, arguments[1] || {}))
};
Effect.BlindDown = function (b) {
b = $(b);
var a = b.getDimensions();
return new Effect.Scale(b, 100, Object.extend({
scaleContent: false,
scaleX: false,
scaleFrom: 0,
scaleMode: {
originalHeight: a.height,
originalWidth: a.width
},
restoreAfterFinish: true,
afterSetup: function (c) {
c.element.makeClipping().setStyle({
height: "0px"
}).show()
},
afterFinishInternal: function (c) {
c.element.undoClipping()
}
}, arguments[1] || {}))
};
Effect.SwitchOff = function (b) {
b = $(b);
var a = b.getInlineOpacity();
return new Effect.Appear(b, Object.extend({
duration: 0.4,
from: 0,
transition: Effect.Transitions.flicker,
afterFinishInternal: function (c) {
new Effect.Scale(c.element, 1, {
duration: 0.3,
scaleFromCenter: true,
scaleX: false,
scaleContent: false,
restoreAfterFinish: true,
beforeSetup: function (d) {
d.element.makePositioned().makeClipping()
},
afterFinishInternal: function (d) {
d.element.hide().undoClipping().undoPositioned().setStyle({
opacity: a
})
}
})
}
}, arguments[1] || {}))
};
Effect.DropOut = function (b) {
b = $(b);
var a = {
top: b.getStyle("top"),
left: b.getStyle("left"),
opacity: b.getInlineOpacity()
};
return new Effect.Parallel([new Effect.Move(b, {
x: 0,
y: 100,
sync: true
}), new Effect.Opacity(b, {
sync: true,
to: 0
})], Object.extend({
duration: 0.5,
beforeSetup: function (c) {
c.effects[0].element.makePositioned()
},
afterFinishInternal: function (c) {
c.effects[0].element.hide().undoPositioned().setStyle(a)
}
}, arguments[1] || {}))
};
Effect.Shake = function (d) {
d = $(d);
var b = Object.extend({
distance: 20,
duration: 0.5
}, arguments[1] || {});
var f = parseFloat(b.distance);
var c = parseFloat(b.duration) / 10;
var a = {
top: d.getStyle("top"),
left: d.getStyle("left")
};
return new Effect.Move(d, {
x: f,
y: 0,
duration: c,
afterFinishInternal: function (g) {
new Effect.Move(g.element, {
x: -f * 2,
y: 0,
duration: c * 2,
afterFinishInternal: function (h) {
new Effect.Move(h.element, {
x: f * 2,
y: 0,
duration: c * 2,
afterFinishInternal: function (j) {
new Effect.Move(j.element, {
x: -f * 2,
y: 0,
duration: c * 2,
afterFinishInternal: function (k) {
new Effect.Move(k.element, {
x: f * 2,
y: 0,
duration: c * 2,
afterFinishInternal: function (l) {
new Effect.Move(l.element, {
x: -f,
y: 0,
duration: c,
afterFinishInternal: function (m) {
m.element.undoPositioned().setStyle(a)
}
})
}
})
}
})
}
})
}
})
}
})
};
Effect.SlideDown = function (c) {
c = $(c).cleanWhitespace();
var a = c.down().getStyle("bottom");
var b = c.getDimensions();
return new Effect.Scale(c, 100, Object.extend({
scaleContent: false,
scaleX: false,
scaleFrom: window.opera ? 0 : 1,
scaleMode: {
originalHeight: b.height,
originalWidth: b.width
},
restoreAfterFinish: true,
afterSetup: function (d) {
d.element.makePositioned();
d.element.down().makePositioned();
if (window.opera) {
d.element.setStyle({
top: ""
})
}
d.element.makeClipping().setStyle({
height: "0px"
}).show()
},
afterUpdateInternal: function (d) {
d.element.down().setStyle({
bottom: (d.dims[0] - d.element.clientHeight) + "px"
})
},
afterFinishInternal: function (d) {
d.element.undoClipping().undoPositioned();
d.element.down().undoPositioned().setStyle({
bottom: a
})
}
}, arguments[1] || {}))
};
Effect.SlideUp = function (c) {
c = $(c).cleanWhitespace();
var a = c.down().getStyle("bottom");
var b = c.getDimensions();
return new Effect.Scale(c, window.opera ? 0 : 1, Object.extend({
scaleContent: false,
scaleX: false,
scaleMode: "box",
scaleFrom: 100,
scaleMode: {
originalHeight: b.height,
originalWidth: b.width
},
restoreAfterFinish: true,
afterSetup: function (d) {
d.element.makePositioned();
d.element.down().makePositioned();
if (window.opera) {
d.element.setStyle({
top: ""
})
}
d.element.makeClipping().show()
},
afterUpdateInternal: function (d) {
d.element.down().setStyle({
bottom: (d.dims[0] - d.element.clientHeight) + "px"
})
},
afterFinishInternal: function (d) {
d.element.hide().undoClipping().undoPositioned();
d.element.down().undoPositioned().setStyle({
bottom: a
})
}
}, arguments[1] || {}))
};
Effect.Squish = function (a) {
return new Effect.Scale(a, window.opera ? 1 : 0, {
restoreAfterFinish: true,
beforeSetup: function (b) {
b.element.makeClipping()
},
afterFinishInternal: function (b) {
b.element.hide().undoClipping()
}
})
};
Effect.Grow = function (c) {
c = $(c);
var b = Object.extend({
direction: "center",
moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.full
}, arguments[1] || {});
var a = {
top: c.style.top,
left: c.style.left,
height: c.style.height,
width: c.style.width,
opacity: c.getInlineOpacity()
};
var h = c.getDimensions();
var j, g;
var f, d;
switch (b.direction) {
case "top-left":
j = g = f = d = 0;
break;
case "top-right":
j = h.width;
g = d = 0;
f = -h.width;
break;
case "bottom-left":
j = f = 0;
g = h.height;
d = -h.height;
break;
case "bottom-right":
j = h.width;
g = h.height;
f = -h.width;
d = -h.height;
break;
case "center":
j = h.width / 2;
g = h.height / 2;
f = -h.width / 2;
d = -h.height / 2;
break
}
return new Effect.Move(c, {
x: j,
y: g,
duration: 0.01,
beforeSetup: function (k) {
k.element.hide().makeClipping().makePositioned()
},
afterFinishInternal: function (k) {
new Effect.Parallel([new Effect.Opacity(k.element, {
sync: true,
to: 1,
from: 0,
transition: b.opacityTransition
}), new Effect.Move(k.element, {
x: f,
y: d,
sync: true,
transition: b.moveTransition
}), new Effect.Scale(k.element, 100, {
scaleMode: {
originalHeight: h.height,
originalWidth: h.width
},
sync: true,
scaleFrom: window.opera ? 1 : 0,
transition: b.scaleTransition,
restoreAfterFinish: true
})], Object.extend({
beforeSetup: function (l) {
l.effects[0].element.setStyle({
height: "0px"
}).show()
},
afterFinishInternal: function (l) {
l.effects[0].element.undoClipping().undoPositioned().setStyle(a)
}
}, b))
}
})
};
Effect.Shrink = function (c) {
c = $(c);
var b = Object.extend({
direction: "center",
moveTransition: Effect.Transitions.sinoidal,
scaleTransition: Effect.Transitions.sinoidal,
opacityTransition: Effect.Transitions.none
}, arguments[1] || {});
var a = {
top: c.style.top,
left: c.style.left,
height: c.style.height,
width: c.style.width,
opacity: c.getInlineOpacity()
};
var g = c.getDimensions();
var f, d;
switch (b.direction) {
case "top-left":
f = d = 0;
break;
case "top-right":
f = g.width;
d = 0;
break;
case "bottom-left":
f = 0;
d = g.height;
break;
case "bottom-right":
f = g.width;
d = g.height;
break;
case "center":
f = g.width / 2;
d = g.height / 2;
break
}
return new Effect.Parallel([new Effect.Opacity(c, {
sync: true,
to: 0,
from: 1,
transition: b.opacityTransition
}), new Effect.Scale(c, window.opera ? 1 : 0, {
sync: true,
transition: b.scaleTransition,
restoreAfterFinish: true
}), new Effect.Move(c, {
x: f,
y: d,
sync: true,
transition: b.moveTransition
})], Object.extend({
beforeStartInternal: function (h) {
h.effects[0].element.makePositioned().makeClipping()
},
afterFinishInternal: function (h) {
h.effects[0].element.hide().undoClipping().undoPositioned().setStyle(a)
}
}, b))
};
Effect.Pulsate = function (c) {
c = $(c);
var b = arguments[1] || {},
a = c.getInlineOpacity(),
f = b.transition || Effect.Transitions.linear,
d = function (g) {
return 1 - f((-Math.cos((g * (b.pulses || 5) * 2) * Math.PI) / 2) + 0.5)
};
return new Effect.Opacity(c, Object.extend(Object.extend({
duration: 2,
from: 0,
afterFinishInternal: function (g) {
g.element.setStyle({
opacity: a
})
}
}, b), {
transition: d
}))
};
Effect.Fold = function (b) {
b = $(b);
var a = {
top: b.style.top,
left: b.style.left,
width: b.style.width,
height: b.style.height
};
b.makeClipping();
return new Effect.Scale(b, 5, Object.extend({
scaleContent: false,
scaleX: false,
afterFinishInternal: function (c) {
new Effect.Scale(b, 1, {
scaleContent: false,
scaleY: false,
afterFinishInternal: function (d) {
d.element.hide().undoClipping().setStyle(a)
}
})
}
}, arguments[1] || {}))
};
Effect.Morph = Class.create(Effect.Base, {
initialize: function (c) {
this.element = $(c);
if (!this.element) {
throw (Effect._elementDoesNotExistError)
}
var a = Object.extend({
style: {}
}, arguments[1] || {});
if (!Object.isString(a.style)) {
this.style = $H(a.style)
} else {
if (a.style.include(":")) {
this.style = a.style.parseStyle()
} else {
this.element.addClassName(a.style);
this.style = $H(this.element.getStyles());
this.element.removeClassName(a.style);
var b = this.element.getStyles();
this.style = this.style.reject(function (d) {
return d.value == b[d.key]
});
a.afterFinishInternal = function (d) {
d.element.addClassName(d.options.style);
d.transforms.each(function (f) {
d.element.style[f.style] = ""
})
}
}
}
this.start(a)
},
setup: function () {
function a(b) {
if (!b || ["rgba(0, 0, 0, 0)", "transparent"].include(b)) {
b = "#ffffff"
}
b = b.parseColor();
return $R(0, 2).map(function (c) {
return parseInt(b.slice(c * 2 + 1, c * 2 + 3), 16)
})
}
this.transforms = this.style.map(function (h) {
var g = h[0],
f = h[1],
d = null;
if (f.parseColor("#zzzzzz") != "#zzzzzz") {
f = f.parseColor();
d = "color"
} else {
if (g == "opacity") {
f = parseFloat(f);
if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) {
this.element.setStyle({
zoom: 1
})
}
} else {
if (Element.CSS_LENGTH.test(f)) {
var c = f.match(/^([\+\-]?[0-9\.]+)(.*)$/);
f = parseFloat(c[1]);
d = (c.length == 3) ? c[2] : null
}
}
}
var b = this.element.getStyle(g);
return {
style: g.camelize(),
originalValue: d == "color" ? a(b) : parseFloat(b || 0),
targetValue: d == "color" ? a(f) : f,
unit: d
}
}.bind(this)).reject(function (b) {
return ((b.originalValue == b.targetValue) || (b.unit != "color" && (isNaN(b.originalValue) || isNaN(b.targetValue))))
})
},
update: function (a) {
var d = {},
b, c = this.transforms.length;
while (c--) {
d[(b = this.transforms[c]).style] = b.unit == "color" ? "#" + (Math.round(b.originalValue[0] + (b.targetValue[0] - b.originalValue[0]) * a)).toColorPart() + (Math.round(b.originalValue[1] + (b.targetValue[1] - b.originalValue[1]) * a)).toColorPart() + (Math.round(b.originalValue[2] + (b.targetValue[2] - b.originalValue[2]) * a)).toColorPart() : (b.originalValue + (b.targetValue - b.originalValue) * a).toFixed(3) + (b.unit === null ? "" : b.unit)
}
this.element.setStyle(d, true)
}
});
Effect.Transform = Class.create({
initialize: function (a) {
this.tracks = [];
this.options = arguments[1] || {};
this.addTracks(a)
},
addTracks: function (a) {
a.each(function (b) {
b = $H(b);
var c = b.values().first();
this.tracks.push($H({
ids: b.keys().first(),
effect: Effect.Morph,
options: {
style: c
}
}))
}.bind(this));
return this
},
play: function () {
return new Effect.Parallel(this.tracks.map(function (a) {
var d = a.get("ids"),
c = a.get("effect"),
b = a.get("options");
var f = [$(d) || $$(d)].flatten();
return f.map(function (g) {
return new c(g, Object.extend({
sync: true
}, b))
})
}).flatten(), this.options)
}
});
Element.CSS_PROPERTIES = $w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");
Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
String.__parseStyleElement = document.createElement("div");
String.prototype.parseStyle = function () {
var b, a = $H();
if (Prototype.Browser.WebKit) {
b = new Element("div", {
style: this
}).style
} else {
String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>';
b = String.__parseStyleElement.childNodes[0].style
}
Element.CSS_PROPERTIES.each(function (c) {
if (b[c]) {
a.set(c, b[c])
}
});
if (Prototype.Browser.IE && this.include("opacity")) {
a.set("opacity", this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1])
}
return a
};
if (document.defaultView && document.defaultView.getComputedStyle) {
Element.getStyles = function (b) {
var a = document.defaultView.getComputedStyle($(b), null);
return Element.CSS_PROPERTIES.inject({}, function (c, d) {
c[d] = a[d];
return c
})
}
} else {
Element.getStyles = function (b) {
b = $(b);
var a = b.currentStyle,
c;
c = Element.CSS_PROPERTIES.inject({}, function (d, f) {
d[f] = a[f];
return d
});
if (!c.opacity) {
c.opacity = b.getOpacity()
}
return c
}
}
Effect.Methods = {
morph: function (a, b) {
a = $(a);
new Effect.Morph(a, Object.extend({
style: b
}, arguments[2] || {}));
return a
},
visualEffect: function (c, f, b) {
c = $(c);
var d = f.dasherize().camelize(),
a = d.charAt(0).toUpperCase() + d.substring(1);
new Effect[a](c, b);
return c
},
highlight: function (b, a) {
b = $(b);
new Effect.Highlight(b, a);
return b
}
};
$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function (a) {
Effect.Methods[a] = function (c, b) {
c = $(c);
Effect[a.charAt(0).toUpperCase() + a.substring(1)](c, b);
return c
}
});
$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function (a) {
Effect.Methods[a] = Element[a]
});
Element.addMethods(Effect.Methods);
if (typeof Effect == "undefined") {
throw ("controls.js requires including script.aculo.us' effects.js library")
}
var Autocompleter = {};
Autocompleter.Base = Class.create({
baseInitialize: function (b, c, a) {
b = $(b);
this.element = b;
this.update = $(c);
this.hasFocus = false;
this.changed = false;
this.active = false;
this.index = 0;
this.entryCount = 0;
this.oldElementValue = this.element.value;
if (this.setOptions) {
this.setOptions(a)
} else {
this.options = a || {}
}
this.options.scrollIntoView = this.options.scrollIntoView || true;
this.options.paramName = this.options.paramName || this.element.name;
this.options.tokens = this.options.tokens || [];
this.options.frequency = this.options.frequency || 0.4;
this.options.minChars = this.options.minChars || 1;
this.options.onShow = this.options.onShow ||
function (d, f) {
if (!f.style.position || f.style.position == "absolute") {
f.style.position = "absolute";
Position.clone(d, f, {
setHeight: false,
offsetTop: d.offsetHeight
})
}
Effect.Appear(f, {
duration: 0.15
})
};
this.options.onHide = this.options.onHide ||
function (d, f) {
new Effect.Fade(f, {
duration: 0.15
})
};
if (typeof (this.options.tokens) == "string") {
this.options.tokens = new Array(this.options.tokens)
}
if (!this.options.tokens.include("\n")) {
this.options.tokens.push("\n")
}
this.observer = null;
this.element.setAttribute("autocomplete", "off");
Element.hide(this.update);
Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
Event.observe(this.element, "keydown", this.onKeyPress.bindAsEventListener(this))
},
show: function () {
if (Element.getStyle(this.update, "display") == "none") {
this.options.onShow(this.element, this.update)
}
if (!this.iefix && (Prototype.Browser.IE) && (Element.getStyle(this.update, "position") == "absolute")) {
new Insertion.After(this.update, '<iframe id="' + this.update.id + '_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix = $(this.update.id + "_iefix")
}
if (this.iefix) {
setTimeout(this.fixIEOverlapping.bind(this), 50)
}
},
fixIEOverlapping: function () {
Position.clone(this.update, this.iefix, {
setTop: (!this.update.style.height)
});
this.iefix.style.zIndex = 1;
this.update.style.zIndex = 2;
Element.show(this.iefix)
},
hide: function () {
this.stopIndicator();
if (Element.getStyle(this.update, "display") != "none") {
this.options.onHide(this.element, this.update)
}
if (this.iefix) {
Element.hide(this.iefix)
}
},
startIndicator: function () {
if (this.options.indicator) {
Element.show(this.options.indicator)
}
},
stopIndicator: function () {
if (this.options.indicator) {
Element.hide(this.options.indicator)
}
},
onKeyPress: function (a) {
if (this.active) {
switch (a.keyCode) {
case Event.KEY_TAB:
case Event.KEY_RETURN:
this.selectEntry();
Event.stop(a);
case Event.KEY_ESC:
this.hide();
this.active = false;
Event.stop(a);
return;
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
return;
case Event.KEY_UP:
this.markPrevious();
this.render();
Event.stop(a);
return;
case Event.KEY_DOWN:
this.markNext();
this.render();
Event.stop(a);
return
}
} else {
if (a.keyCode == Event.KEY_TAB || a.keyCode == Event.KEY_RETURN || (Prototype.Browser.WebKit > 0 && a.keyCode == 0)) {
return
}
}
this.changed = true;
this.hasFocus = true;
if (this.observer) {
clearTimeout(this.observer)
}
this.observer = setTimeout(this.onObserverEvent.bind(this), this.options.frequency * 1000)
},
activate: function () {
this.changed = false;
this.hasFocus = true;
this.getUpdatedChoices()
},
onHover: function (b) {
var a = Event.findElement(b, "LI");
if (this.index != a.autocompleteIndex) {
this.index = a.autocompleteIndex;
this.render()
}
Event.stop(b)
},
onClick: function (b) {
var a = Event.findElement(b, "LI");
this.index = a.autocompleteIndex;
this.selectEntry();
this.hide()
},
onBlur: function (a) {
setTimeout(this.hide.bind(this), 250);
this.hasFocus = false;
this.active = false
},
render: function () {
if (this.entryCount > 0) {
for (var a = 0; a < this.entryCount; a++) {
this.index == a ? Element.addClassName(this.getEntry(a), "selected") : Element.removeClassName(this.getEntry(a), "selected")
}
if (this.hasFocus) {
this.show();
this.active = true
}
} else {
this.active = false;
this.hide()
}
},
markPrevious: function () {
if (this.index > 0) {
this.index--
} else {
this.index = this.entryCount - 1
}
},
markNext: function () {
if (this.index < this.entryCount - 1) {
this.index++
} else {
this.index = 0
}
},
getEntry: function (a) {
return this.update.firstChild.childNodes[a]
},
getCurrentEntry: function () {
return this.getEntry(this.index)
},
selectEntry: function () {
this.active = false;
this.updateElement(this.getCurrentEntry())
},
updateElement: function (g) {
if (this.options.updateElement) {
this.options.updateElement(g);
return
}
var d = "";
if (this.options.select) {
var a = $(g).select("." + this.options.select) || [];
if (a.length > 0) {
d = Element.collectTextNodes(a[0], this.options.select)
}
} else {
d = Element.collectTextNodesIgnoreClass(g, "informal")
}
var c = this.getTokenBounds();
if (c[0] != -1) {
var f = this.element.value.substr(0, c[0]);
var b = this.element.value.substr(c[0]).match(/^\s+/);
if (b) {
f += b[0]
}
this.element.value = f + d + this.element.value.substr(c[1])
} else {
this.element.value = d
}
this.oldElementValue = this.element.value;
this.element.focus();
if (this.options.afterUpdateElement) {
this.options.afterUpdateElement(this.element, g)
}
},
updateChoices: function (c) {
if (!this.changed && this.hasFocus) {
this.update.innerHTML = c;
Element.cleanWhitespace(this.update);
Element.cleanWhitespace(this.update.down());
if (this.update.firstChild && this.update.down().childNodes) {
this.entryCount = this.update.down().childNodes.length;
for (var a = 0; a < this.entryCount; a++) {
var b = this.getEntry(a);
b.autocompleteIndex = a;
this.addObservers(b)
}
} else {
this.entryCount = 0
}
this.stopIndicator();
this.index = 0;
if (this.entryCount == 1 && this.options.autoSelect) {
this.selectEntry();
this.hide()
} else {
this.render()
}
}
},
addObservers: function (a) {
Event.observe(a, "mouseover", this.onHover.bindAsEventListener(this));
Event.observe(a, "click", this.onClick.bindAsEventListener(this))
},
onObserverEvent: function () {
this.changed = false;
this.tokenBounds = null;
if (this.getToken().length >= this.options.minChars) {
this.getUpdatedChoices()
} else {
this.active = false;
this.hide()
}
this.oldElementValue = this.element.value
},
getToken: function () {
var a = this.getTokenBounds();
return this.element.value.substring(a[0], a[1]).strip()
},
getTokenBounds: function () {
if (null != this.tokenBounds) {
return this.tokenBounds
}
var f = this.element.value;
if (f.strip().empty()) {
return [-1, 0]
}
var g = arguments.callee.getFirstDifferencePos(f, this.oldElementValue);
var j = (g == this.oldElementValue.length ? 1 : 0);
var d = -1,
c = f.length;
var h;
for (var b = 0, a = this.options.tokens.length; b < a; ++b) {
h = f.lastIndexOf(this.options.tokens[b], g + j - 1);
if (h > d) {
d = h
}
h = f.indexOf(this.options.tokens[b], g + j);
if (-1 != h && h < c) {
c = h
}
}
return (this.tokenBounds = [d + 1, c])
}
});
Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function (c, a) {
var d = Math.min(c.length, a.length);
for (var b = 0; b < d; ++b) {
if (c[b] != a[b]) {
return b
}
}
return d
};
Ajax.Autocompleter = Class.create(Autocompleter.Base, {
initialize: function (c, d, b, a) {
this.baseInitialize(c, d, a);
this.options.asynchronous = true;
this.options.onComplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
this.url = b
},
getUpdatedChoices: function () {
this.startIndicator();
var a = encodeURIComponent(this.options.paramName) + "=" + encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ? this.options.callback(this.element, a) : a;
if (this.options.defaultParams) {
this.options.parameters += "&" + this.options.defaultParams
}
new Ajax.Request(this.url, this.options)
},
onComplete: function (a) {
this.updateChoices(a.responseText)
}
});
Autocompleter.Local = Class.create(Autocompleter.Base, {
initialize: function (b, d, c, a) {
this.baseInitialize(b, d, a);
this.options.array = c
},
getUpdatedChoices: function () {
this.updateChoices(this.options.selector(this))
},
setOptions: function (a) {
this.options = Object.extend({
choices: 10,
partialSearch: true,
partialChars: 2,
ignoreCase: true,
fullSearch: false,
selector: function (b) {
var d = [];
var c = [];
var j = b.getToken();
var h = 0;
for (var f = 0; f < b.options.array.length && d.length < b.options.choices; f++) {
var g = b.options.array[f];
var k = b.options.ignoreCase ? g.toLowerCase().indexOf(j.toLowerCase()) : g.indexOf(j);
while (k != -1) {
if (k == 0 && g.length != j.length) {
d.push("<li><strong>" + g.substr(0, j.length) + "</strong>" + g.substr(j.length) + "</li>");
break
} else {
if (j.length >= b.options.partialChars && b.options.partialSearch && k != -1) {
if (b.options.fullSearch || /\s/.test(g.substr(k - 1, 1))) {
c.push("<li>" + g.substr(0, k) + "<strong>" + g.substr(k, j.length) + "</strong>" + g.substr(k + j.length) + "</li>");
break
}
}
}
k = b.options.ignoreCase ? g.toLowerCase().indexOf(j.toLowerCase(), k + 1) : g.indexOf(j, k + 1)
}
}
if (c.length) {
d = d.concat(c.slice(0, b.options.choices - d.length))
}
return "<ul>" + d.join("") + "</ul>"
}
}, a || {})
}
});
Field.scrollFreeActivate = function (a) {
setTimeout(function () {
Field.activate(a)
}, 1)
};
Ajax.InPlaceEditor = Class.create({
initialize: function (c, b, a) {
this.url = b;
this.element = c = $(c);
this.prepareOptions();
this._controls = {};
arguments.callee.dealWithDeprecatedOptions(a);
Object.extend(this.options, a || {});
if (!this.options.formId && this.element.id) {
this.options.formId = this.element.id + "-inplaceeditor";
if ($(this.options.formId)) {
this.options.formId = ""
}
}
if (this.options.externalControl) {
this.options.externalControl = $(this.options.externalControl)
}
if (!this.options.externalControl) {
this.options.externalControlOnly = false
}
this._originalBackground = this.element.getStyle("background-color") || "transparent";
this.element.title = this.options.clickToEditText;
this._boundCancelHandler = this.handleFormCancellation.bind(this);
this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
this._boundFailureHandler = this.handleAJAXFailure.bind(this);
this._boundSubmitHandler = this.handleFormSubmission.bind(this);
this._boundWrapperHandler = this.wrapUp.bind(this);
this.registerListeners()
},
checkForEscapeOrReturn: function (a) {
if (!this._editing || a.ctrlKey || a.altKey || a.shiftKey) {
return
}
if (Event.KEY_ESC == a.keyCode) {
this.handleFormCancellation(a)
} else {
if (Event.KEY_RETURN == a.keyCode) {
this.handleFormSubmission(a)
}
}
},
createControl: function (h, c, b) {
var f = this.options[h + "Control"];
var g = this.options[h + "Text"];
if ("button" == f) {
var a = document.createElement("input");
a.type = "submit";
a.value = g;
a.className = "editor_" + h + "_button";
if ("cancel" == h) {
a.onclick = this._boundCancelHandler
}
this._form.appendChild(a);
this._controls[h] = a
} else {
if ("link" == f) {
var d = document.createElement("a");
d.href = "#";
d.appendChild(document.createTextNode(g));
d.onclick = "cancel" == h ? this._boundCancelHandler : this._boundSubmitHandler;
d.className = "editor_" + h + "_link";
if (b) {
d.className += " " + b
}
this._form.appendChild(d);
this._controls[h] = d
}
}
},
createEditField: function () {
var c = (this.options.loadTextURL ? this.options.loadingText : this.getText());
var b;
if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
b = document.createElement("input");
b.type = "text";
var a = this.options.size || this.options.cols || 0;
if (0 < a) {
b.size = a
}
} else {
b = document.createElement("textarea");
b.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
b.cols = this.options.cols || 40
}
b.name = this.options.paramName;
b.value = c;
b.className = "editor_field";
if (this.options.submitOnBlur) {
b.onblur = this._boundSubmitHandler
}
this._controls.editor = b;
if (this.options.loadTextURL) {
this.loadExternalText()
}
this._form.appendChild(this._controls.editor)
},
createForm: function () {
var b = this;
function a(d, f) {
var c = b.options["text" + d + "Controls"];
if (!c || f === false) {
return
}
b._form.appendChild(document.createTextNode(c))
}
this._form = $(document.createElement("form"));
this._form.id = this.options.formId;
this._form.addClassName(this.options.formClassName);
this._form.onsubmit = this._boundSubmitHandler;
this.createEditField();
if ("textarea" == this._controls.editor.tagName.toLowerCase()) {
this._form.appendChild(document.createElement("br"))
}
if (this.options.onFormCustomization) {
this.options.onFormCustomization(this, this._form)
}
a("Before", this.options.okControl || this.options.cancelControl);
this.createControl("ok", this._boundSubmitHandler);
a("Between", this.options.okControl && this.options.cancelControl);
this.createControl("cancel", this._boundCancelHandler, "editor_cancel");
a("After", this.options.okControl || this.options.cancelControl)
},
destroy: function () {
if (this._oldInnerHTML) {
this.element.innerHTML = this._oldInnerHTML
}
this.leaveEditMode();
this.unregisterListeners()
},
enterEditMode: function (a) {
if (this._saving || this._editing) {
return
}
this._editing = true;
this.triggerCallback("onEnterEditMode");
if (this.options.externalControl) {
this.options.externalControl.hide()
}
this.element.hide();
this.createForm();
this.element.parentNode.insertBefore(this._form, this.element);
if (!this.options.loadTextURL) {
this.postProcessEditField()
}
if (a) {
Event.stop(a)
}
},
enterHover: function (a) {
if (this.options.hoverClassName) {
this.element.addClassName(this.options.hoverClassName)
}
if (this._saving) {
return
}
this.triggerCallback("onEnterHover")
},
getText: function () {
return this.element.innerHTML.unescapeHTML()
},
handleAJAXFailure: function (a) {
this.triggerCallback("onFailure", a);
if (this._oldInnerHTML) {
this.element.innerHTML = this._oldInnerHTML;
this._oldInnerHTML = null
}
},
handleFormCancellation: function (a) {
this.wrapUp();
if (a) {
Event.stop(a)
}
},
handleFormSubmission: function (d) {
var b = this._form;
var c = $F(this._controls.editor);
this.prepareSubmission();
var f = this.options.callback(b, c) || "";
if (Object.isString(f)) {
f = f.toQueryParams()
}
f.editorId = this.element.id;
if (this.options.htmlResponse) {
var a = Object.extend({
evalScripts: true
}, this.options.ajaxOptions);
Object.extend(a, {
parameters: f,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Updater({
success: this.element
}, this.url, a)
} else {
var a = Object.extend({
method: "get"
}, this.options.ajaxOptions);
Object.extend(a, {
parameters: f,
onComplete: this._boundWrapperHandler,
onFailure: this._boundFailureHandler
});
new Ajax.Request(this.url, a)
}
if (d) {
Event.stop(d)
}
},
leaveEditMode: function () {
this.element.removeClassName(this.options.savingClassName);
this.removeForm();
this.leaveHover();
this.element.style.backgroundColor = this._originalBackground;
this.element.show();
if (this.options.externalControl) {
this.options.externalControl.show()
}
this._saving = false;
this._editing = false;
this._oldInnerHTML = null;
this.triggerCallback("onLeaveEditMode")
},
leaveHover: function (a) {
if (this.options.hoverClassName) {
this.element.removeClassName(this.options.hoverClassName)
}
if (this._saving) {
return
}
this.triggerCallback("onLeaveHover")
},
loadExternalText: function () {
this._form.addClassName(this.options.loadingClassName);
this._controls.editor.disabled = true;
var a = Object.extend({
method: "get"
}, this.options.ajaxOptions);
Object.extend(a, {
parameters: "editorId=" + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function (c) {
this._form.removeClassName(this.options.loadingClassName);
var b = c.responseText;
if (this.options.stripLoadedTextTags) {
b = b.stripTags()
}
this._controls.editor.value = b;
this._controls.editor.disabled = false;
this.postProcessEditField()
}.bind(this),
onFailure: this._boundFailureHandler
});
new Ajax.Request(this.options.loadTextURL, a)
},
postProcessEditField: function () {
var a = this.options.fieldPostCreation;
if (a) {
$(this._controls.editor)["focus" == a ? "focus" : "activate"]()
}
},
prepareOptions: function () {
this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
[this._extraDefaultOptions].flatten().compact().each(function (a) {
Object.extend(this.options, a)
}.bind(this))
},
prepareSubmission: function () {
this._saving = true;
this.removeForm();
this.leaveHover();
this.showSaving()
},
registerListeners: function () {
this._listeners = {};
var a;
$H(Ajax.InPlaceEditor.Listeners).each(function (b) {
a = this[b.value].bind(this);
this._listeners[b.key] = a;
if (!this.options.externalControlOnly) {
this.element.observe(b.key, a)
}
if (this.options.externalControl) {
this.options.externalControl.observe(b.key, a)
}
}.bind(this))
},
removeForm: function () {
if (!this._form) {
return
}
this._form.remove();
this._form = null;
this._controls = {}
},
showSaving: function () {
this._oldInnerHTML = this.element.innerHTML;
this.element.innerHTML = this.options.savingText;
this.element.addClassName(this.options.savingClassName);
this.element.style.backgroundColor = this._originalBackground;
this.element.show()
},
triggerCallback: function (b, a) {
if ("function" == typeof this.options[b]) {
this.options[b](this, a)
}
},
unregisterListeners: function () {
$H(this._listeners).each(function (a) {
if (!this.options.externalControlOnly) {
this.element.stopObserving(a.key, a.value)
}
if (this.options.externalControl) {
this.options.externalControl.stopObserving(a.key, a.value)
}
}.bind(this))
},
wrapUp: function (a) {
this.leaveEditMode();
this._boundComplete(a, this.element)
}
});
Object.extend(Ajax.InPlaceEditor.prototype, {
dispose: Ajax.InPlaceEditor.prototype.destroy
});
Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
initialize: function ($super, c, b, a) {
this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
$super(c, b, a)
},
createEditField: function () {
var a = document.createElement("select");
a.name = this.options.paramName;
a.size = 1;
this._controls.editor = a;
this._collection = this.options.collection || [];
if (this.options.loadCollectionURL) {
this.loadCollection()
} else {
this.checkForExternalText()
}
this._form.appendChild(this._controls.editor)
},
loadCollection: function () {
this._form.addClassName(this.options.loadingClassName);
this.showLoadingText(this.options.loadingCollectionText);
var options = Object.extend({
method: "get"
}, this.options.ajaxOptions);
Object.extend(options, {
parameters: "editorId=" + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function (transport) {
var js = transport.responseText.strip();
if (!/^\[.*\]$/.test(js)) {
throw ("Server returned an invalid collection representation.")
}
this._collection = eval(js);
this.checkForExternalText()
}.bind(this),
onFailure: this.onFailure
});
new Ajax.Request(this.options.loadCollectionURL, options)
},
showLoadingText: function (b) {
this._controls.editor.disabled = true;
var a = this._controls.editor.firstChild;
if (!a) {
a = document.createElement("option");
a.value = "";
this._controls.editor.appendChild(a);
a.selected = true
}
a.update((b || "").stripScripts().stripTags())
},
checkForExternalText: function () {
this._text = this.getText();
if (this.options.loadTextURL) {
this.loadExternalText()
} else {
this.buildOptionList()
}
},
loadExternalText: function () {
this.showLoadingText(this.options.loadingText);
var a = Object.extend({
method: "get"
}, this.options.ajaxOptions);
Object.extend(a, {
parameters: "editorId=" + encodeURIComponent(this.element.id),
onComplete: Prototype.emptyFunction,
onSuccess: function (b) {
this._text = b.responseText.strip();
this.buildOptionList()
}.bind(this),
onFailure: this.onFailure
});
new Ajax.Request(this.options.loadTextURL, a)
},
buildOptionList: function () {
this._form.removeClassName(this.options.loadingClassName);
this._collection = this._collection.map(function (d) {
return 2 === d.length ? d : [d, d].flatten()
});
var b = ("value" in this.options) ? this.options.value : this._text;
var a = this._collection.any(function (d) {
return d[0] == b
}.bind(this));
this._controls.editor.update("");
var c;
this._collection.each(function (f, d) {
c = document.createElement("option");
c.value = f[0];
c.selected = a ? f[0] == b : 0 == d;
c.appendChild(document.createTextNode(f[1]));
this._controls.editor.appendChild(c)
}.bind(this));
this._controls.editor.disabled = false;
Field.scrollFreeActivate(this._controls.editor)
}
});
Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function (a) {
if (!a) {
return
}
function b(c, d) {
if (c in a || d === undefined) {
return
}
a[c] = d
}
b("cancelControl", (a.cancelLink ? "link" : (a.cancelButton ? "button" : a.cancelLink == a.cancelButton == false ? false : undefined)));
b("okControl", (a.okLink ? "link" : (a.okButton ? "button" : a.okLink == a.okButton == false ? false : undefined)));
b("highlightColor", a.highlightcolor);
b("highlightEndColor", a.highlightendcolor)
};
Object.extend(Ajax.InPlaceEditor, {
DefaultOptions: {
ajaxOptions: {},
autoRows: 3,
cancelControl: "link",
cancelText: "cancel",
clickToEditText: "Click to edit",
externalControl: null,
externalControlOnly: false,
fieldPostCreation: "activate",
formClassName: "inplaceeditor-form",
formId: null,
highlightColor: "#ffff99",
highlightEndColor: "#ffffff",
hoverClassName: "",
htmlResponse: true,
loadingClassName: "inplaceeditor-loading",
loadingText: "Loading...",
okControl: "button",
okText: "ok",
paramName: "value",
rows: 1,
savingClassName: "inplaceeditor-saving",
savingText: "Saving...",
size: 0,
stripLoadedTextTags: false,
submitOnBlur: false,
textAfterControls: "",
textBeforeControls: "",
textBetweenControls: ""
},
DefaultCallbacks: {
callback: function (a) {
return Form.serialize(a)
},
onComplete: function (b, a) {
new Effect.Highlight(a, {
startcolor: this.options.highlightColor,
keepBackgroundImage: true
})
},
onEnterEditMode: null,
onEnterHover: function (a) {
a.element.style.backgroundColor = a.options.highlightColor;
if (a._effect) {
a._effect.cancel()
}
},
onFailure: function (b, a) {
alert("Error communication with the server: " + b.responseText.stripTags())
},
onFormCustomization: null,
onLeaveEditMode: null,
onLeaveHover: function (a) {
a._effect = new Effect.Highlight(a.element, {
startcolor: a.options.highlightColor,
endcolor: a.options.highlightEndColor,
restorecolor: a._originalBackground,
keepBackgroundImage: true
})
}
},
Listeners: {
click: "enterEditMode",
keydown: "checkForEscapeOrReturn",
mouseover: "enterHover",
mouseout: "leaveHover"
}
});
Ajax.InPlaceCollectionEditor.DefaultOptions = {
loadingCollectionText: "Loading options..."
};
Form.Element.DelayedObserver = Class.create({
initialize: function (b, a, c) {
this.delay = a || 0.5;
this.element = $(b);
this.callback = c;
this.timer = null;
this.lastValue = $F(this.element);
Event.observe(this.element, "keyup", this.delayedListener.bindAsEventListener(this))
},
delayedListener: function (a) {
if (this.lastValue == $F(this.element)) {
return
}
if (this.timer) {
clearTimeout(this.timer)
}
this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
this.lastValue = $F(this.element)
},
onTimerEvent: function () {
this.timer = null;
this.callback(this.element, $F(this.element))
}
});
if (typeof (SBN) == "undefined") {
SBN = new Object()
}
if (SBN.Admin == undefined) {
SBN.Admin = new Object()
}
if (SBN.Special == undefined) {
SBN.Special = new Object()
}
if (SBN.Yahoo == undefined) {
SBN.Yahoo = new Object()
}
if (SBN.Analytics == undefined) {
SBN.Analytics = new Object()
}
SBN.CurrentContext = new Object();
SBN.Yahoo.referringUrl = null;
SBN.Yahoo.goBack = function () {
if (SBN.Yahoo.referringUrl) {
location.href = SBN.Yahoo.referringUrl
} else {
location.href = "http://sports.yahoo.com/"
}
};
SBN.Yahoo.isYahooReferral = function (a) {
if (SBN.Yahoo.referringUrl == null) {
if (document.referrer != undefined && document.referrer.match(a)) {
SBN.Yahoo.referringUrl = document.referrer
} else {
SBN.Yahoo.referringUrl = SBN.readCookie("referred_from_yahoo")
}
}
if (SBN.Yahoo.referringUrl) {
SBN.createCookie("referred_from_yahoo", SBN.Yahoo.referringUrl, 1);
return true
} else {
return false
}
};
SBN.blogLayouts = $A(["narrow_layout", "wide_layout"]);
SBN.changeBlogLayout = function (b) {
var a = $(document.body);
SBN.blogLayouts.each(function (c) {
a.removeClassName(c)
});
a.addClassName(b);
new Ajax.Request("/communities/change_layout/?layout=" + encodeURI(b), {
asynchronous: true,
evalScripts: true
})
};
SBN.formatTime = function (f) {
var b = f.getHours();
var c = f.getMinutes();
var a = (b < 12) ? "AM" : "PM";
if (b == 0) {
b = 12
} else {
if (b > 12) {
b = b - 12
}
}
if (c < 10) {
c = "0" + c
}
return b + ":" + c + " " + a
};
SBN.createCookie = function (c, d, f) {
if (f) {
var b = new Date();
b.setTime(b.getTime() + (f * 24 * 60 * 60 * 1000));
var a = "; expires=" + b.toGMTString()
} else {
a = ""
}
document.cookie = c + "=" + d + a + "; path=/"
};
SBN.readCookie = function (b) {
var f = b + "=";
var a = document.cookie.split(";");
for (var d = 0; d < a.length; d++) {
var g = a[d];
while (g.charAt(0) == " ") {
g = g.substring(1, g.length)
}
if (g.indexOf(f) == 0) {
return g.substring(f.length, g.length)
}
}
return null
};
SBN.ajaxSuccess = function (a) {
return !a.status || (a.status >= 200 && a.status < 300)
};
SBN.hideSpinner = function (a) {
if (a == undefined) {
var a = "spinner"
}
if ($(a)) {
$(a).hide()
}
};
SBN.showSpinner = function (a) {
if (a == undefined) {
var a = "spinner"
}
if ($(a)) {
$(a).show()
}
};
SBN.toggleSubmit = function (b) {
var a = $(b);
a.disabled = !a.disabled;
a.value = a.disabled ? "Saving..." : "Save Changes"
};
SBN.clearChildren = function (a) {
$(a).childElements().each(function (b) {
b.remove()
});
a.innerHTML = ""
};
SBN.appendUrlParam = function (a, b) {
if (a.include("?")) {
return a + "&" + b
} else {
return a + "?" + b
}
};
SBN.openWindow = function (a) {
window.open(a, "", "height=500,width=800,menubar=no,status=no,scrollbars=yes,resizable=yes")
};
SBN.openModal = function (c, b) {
var a = SBN.openModalWithContents('<div class="modal-loading" style="padding:10px">Loading<blink>...</blink></div>', b);
new Ajax.Request(c, {
onComplete: function (d) {
a.container.innerHTML = d.responseText;
SBN.alignModal(a)
}
});
return a
};
SBN.alignModal = function (a) {
a.position();
a.position();
a.position()
};
SBN.openIframeModal = function (f, d) {
var c = null;
var b = {
iframe: true,
width: 700,
height: 400,
includeCloseLink: false
};
d = Object.extend(b, d || {});
var g = Control.Window.iframeTemplate;
if (d.includeCloseLink) {
Control.Window.iframeTemplate = new Template('<div class="modal-topbar"></div><div id="modal-close"><a href="#" onclick="Control.Modal.close();return false">X</a></div><iframe src="#{href}" width="100%" height="' + (d.height - 24) + '" frameborder="0" scrolling="auto" style="overflow-x: hidden; overflow-y: scroll;" id="modal_iframe"></iframe>')
} else {
Control.Window.iframeTemplate = new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0" scrolling="auto" style="overflow-x: hidden; overflow-y: scroll;" id="modal_iframe"></iframe>')
}
var a = new Control.Modal(f, d);
a.open();
Control.Window.iframeTemplate = g;
return a
};
SBN.openCloseableModalWithContents = function (c, b) {
SBN.initModalContainer('<div id="modal-close"><a href="#" onclick="Control.Modal.close();return false">X</a></div><div class="modal-content">' + c + "</div>");
var a = new Control.Modal(this.modalContainer, b);
a.open();
return a
};
SBN.openModalWithContents = function (c, b) {
SBN.initModalContainer('<div class="modal-content" style="text-align:center">' + c + "</div>", b);
var a = new Control.Modal(this.modalContainer, b);
a.open();
return a
};
SBN.initModalContainer = function (b, a) {
if (!this.modalContainer) {
this.modalContainer = $(document.createElement("div"));
this.modalContainer.id = typeof a != "undefined" && a.id ? a.id : "modal_container";
this.modalContainer.hide();
$(document.body).appendChild(this.modalContainer)
}
this.modalContainer.innerHTML = b
};
SBN.activateRedStarMenus = function () {
$$(".blog-hover-link").each(function (a) {
new HoverMenu(a.id)
})
};
SBN.equalizeColumnHeights = function () {
if ($("col-side-1") && $("entries")) {
var b = $("col-side-1").getHeight();
var a = $("entries").getHeight();
if (a < b) {
padding = b - a;
$("entries").setStyle({
paddingBottom: padding + "px"
})
}
}
};
SBN.callOnParent = function (a) {
setTimeout(a, 100)
};
SBN.submitForm = function (a) {
if ($(a).onsubmit()) {
$(a).submit()
}
};
SBN.NetworkBar = function () {};
SBN.NetworkBar.toggleLogin = function () {
Effect.toggle("network_bar_login", "blind", {
duration: 0.5
})
};
SBN.NetworkBar.toggleOpenId = function () {
var c = $("openid_login");
if (c.visible()) {
var b = "openid_login";
var a = "standard_login"
} else {
var b = "standard_login";
var a = "openid_login"
}
Effect.toggle(b, "slide", {
duration: 0.3
});
Effect.toggle(a, "slide", {
delay: 0.3,
duration: 0.3
})
};
SBN.UserFlags = {
create: function (a) {
this.updateFlag(a, "create")
},
destroy: function (a) {
this.updateFlag(a, "destroy")
},
updateFlag: function (c, a) {
var b = $H({
name: c
}).toQueryString();
new Ajax.Request("/user_flags/" + a, {
parameters: b,
asynchronous: true,
evalScripts: true
})
}
};
SBN.Assets = function () {};
SBN.Assets.addUploadField = function () {
var b = $("asset_list");
var a = $("initial_asset_field").innerHTML;
new Insertion.Bottom(b, a)
};
function rate(a, b, c) {
new Ajax.Updater("options", "/posts/rate/" + a + "/" + b + "/" + c, {
asynchronous: true,
evalScripts: true
})
}
var openModal = function (a) {
SBN.openModal(a)
};
SBN.Blogroll = function () {};
SBN.Blogroll.toggleLeague = function (a) {
var b = $(a);
var c = $(a + "_head");
if (b.visible()) {
Effect.BlindUp(b, {
duration: 0.5
});
c.removeClassName("expanded")
} else {
Effect.BlindDown(b, {
duration: 0.5
});
c.addClassName("expanded")
}
};
SBN.Links = {};
SBN.Links.disable = function (b) {
var a = $(b);
if (!a.oldOnclick) {
a.oldOnclick = a.getAttribute("onclick");
a.setAttribute("onclick", "return false;");
a.addClassName("disabled_link")
}
};
SBN.Links.enable = function (b) {
var a = $(b);
if (a.oldOnclick) {
a.setAttribute("onclick", a.oldOnclick);
a.oldOnclick = null;
a.removeClassName("disabled_link")
}
};
SBN.Ads = {
showOnLoad: function (a, b) {
document.observe("dom:loaded", this.show.bind(this, a, b));
Event.observe(window, "load", function () {
setTimeout(function () {
SBN.Ads.show(a, b)
}, 1500)
})
},
show: function (b, c) {
b = $(b);
if (b) {
var a = b.getHeight();
if (!(a != null && a < c)) {
b.show()
}
}
}
};
SBN.Tables = function () {};
SBN.Tables.zebra = function (a) {
Selector.findChildElements(a, ["tr"]).findAll(function (c, b) {
return b % 2 == 0
}).invoke("addClassName", "even")
};
SBN.disableSelection = function (a) {
a.onselectstart = function () {
return false
};
a.unselectable = "on";
a.style.MozUserSelect = "none";
a.style.cursor = "default"
};
FastInit.addOnLoad(function () {
$$("table.zebra tbody").each(function (a) {
SBN.Tables.zebra(a)
})
});
function resetField(c, b) {
var a = c.defaultValue;
if (c.value == (b ? "" : a)) {
c.value = (b ? a : "")
}
}
SBN.adjustCalendarTime = function (a, b) {
if ((a.getMinutes() % b) != 0) {
a.setMinutes(0)
}
$$(".cds_buttons a").each(function (c) {
if (c.innerHTML == "Now") {
c.hide()
}
})
};
SBN.preventFutureDate = function (b) {
var a = new Date();
if (b.selected_date > a) {
b.today(true)
}
};
SBN.Dates = {};
SBN.Dates.lastDateValues = {};
SBN.Dates.updateDate = function (d) {
var c = $F(d + "_freeform");
if (c == "") {
$(d + "_english").innerHTML = "";
$(d).value = ""
} else {
if (c != this.lastDateValues[d]) {
var b = null;
var a = Date.parse(c);
if (a) {
b = a.toString("ddd, MMM d, yyyy");
$(d).value = a.toISOString().replace(/"/g, "")
} else {
b = "Enter a valid date."
}
$(d + "_english").innerHTML = b;
this.lastDateValues[d] = c
}
}
};
SBN.AjaxOverlay = {
apply: function (c) {
var a = $(c);
var d = a.cumulativeOffset();
var b = "top: " + d[1] + "px; left:" + d[0] + "px; width: " + a.offsetWidth + "px; height: " + a.offsetHeight + "px;";
Element.insert(document.body, '<div class="ajax_overlay" style="position: absolute; ' + b + '"></div>')
},
remove: function () {
$$(".ajax_overlay").each(function (a) {
$(a).up().removeChild(a)
})
}
};
SBN.Page = {};
SBN.Page.getDimensions = function () {
var d, a;
if (window.innerHeight && window.scrollMaxY) {
d = window.innerWidth + window.scrollMaxX;
a = window.innerHeight + window.scrollMaxY
} else {
if (document.body.scrollHeight > document.body.offsetHeight) {
d = document.body.scrollWidth;
a = document.body.scrollHeight
} else {
d = document.body.offsetWidth;
a = document.body.offsetHeight
}
}
var c, f;
if (self.innerHeight) {
if (document.documentElement.clientWidth) {
c = document.documentElement.clientWidth
} else {
c = self.innerWidth
}
f = self.innerHeight
} else {
if (document.documentElement && document.documentElement.clientHeight) {
c = document.documentElement.clientWidth;
f = document.documentElement.clientHeight
} else {
if (document.body) {
c = document.body.clientWidth;
f = document.body.clientHeight
}
}
}
if (a < f) {
pageHeight = f
} else {
pageHeight = a
}
if (d < c) {
pageWidth = d
} else {
pageWidth = c
}
var b = {};
b.width = pageWidth;
b.height = pageHeight;
b.windowWidth = c;
b.windowHeight = f;
return b
};
function $RF(b, a) {
if ($(b).type && $(b).type.toLowerCase() == "radio") {
var a = $(b).name;
var b = $(b).form
} else {
if ($(b).tagName.toLowerCase() != "form") {
return false
}
}
var c = $(b).getInputs("radio", a).find(function (d) {
return d.checked
});
return (c) ? $F(c) : null
}
function resetField(c, b) {
var a = c.defaultValue;
if (c.value == (b ? "" : a)) {
c.value = (b ? a : "")
}
}
var addthis_config = {
data_use_flash: false
};
SBN.CDC = {
hub_host: "/",
listenerLoaded: function (a, b) {
SBN.CDC.hub_host = "http://" + a;
arg_pos = b.indexOf("?");
args = undefined;
command = b;
if (arg_pos > 0) {
command = b.substring(0, arg_pos);
args = b.substring(arg_pos + 1)
}
if (SBN.CDC[command] != undefined) {
SBN.CDC[command].call(SBN.CDC, args)
}
},
authenticate: function (a) {
url = SBN.CDC.hub_host + "/account/authenticate_facebook_id?" + a;
window.location.href = url
},
logout: function () {
window.location.href = SBN.CDC.hub_host + "/account/logout"
},
cancel: function () {
Control.Modal.close()
},
facebookModalInitialized: function () {
SBN.Facebook.Connect.displayModal()
}
};
SBN.Util = {
stripNewLines: function (a) {
var b = /\r?\n/gi;
s = new String(a);
s = s.replace(b, "");
return s
}
};
SBN.ContentModule = {
looper: function (a, c) {
options = {
loops: 2,
display: 3
};
Object.extend(options, c || {});
var b = 0;
var d = new PeriodicalExecuter(function () {
var h = $$(a);
if (h.length <= options.display) {
return
}
if (b == ((options.loops * h.length) - 1)) {
d.stop()
}
var f = options.display;
var g = h[0];
var j = h[f];
new Effect.Parallel([new Effect.SlideUp(g, {
sync: true
}), new Effect.BlindDown(j, {
sync: true,
afterFinish: function () {
var k = $(g.parentNode);
g = g.remove();
k.insert(g, {
position: "bottom"
});
g.hide()
}
})], {
duration: 0.8
});
b += 1
}, 5);
return d
}
};
SBN.PopUp = (function () {
return function (a) {
var b = {
init: function (c) {
this.cookieName = c.cookiePrefix + "-pop-up-1";
this.popUp = $(c.wrapperId);
this.centerIt = (c.center || false);
this.closeEl = this.popUp.down((c.closeClass || ".campaigns-pop-up-close"));
if (this.closeEl) {
this.closeEl.observe("click", this.hide.bind(this))
}
this.preview = (c.preview || false);
this.slideOpts = {
duration: (c.duration || 1)
};
this.startSec = (c.startIn || 15);
this.hideSec = (c.hideAfter || 15);
this.componentTrackerInstaller = c.componentTrackerInstaller;
this.trackingImages = (c.trackingImages || []);
this.trackImagesEl = this.popUp.down(".tracking-images");
this.pendingTimeouts = [];
Event.observe(window, "resize", this.resizeHandler.bind(this));
this.hide();
this.resizeTimeout = false
},
resizeHandler: function (c) {
if (!this.resizeTimeout) {
this.resizeTimeout = setTimeout(this.resize.bind(this), 100)
}
},
resize: function () {
var c = this.position();
this.popUp.setStyle({
left: c.x + "px",
top: c.y + "px"
});
this.resizeTimeout = false
},
position: function () {
var c = document.viewport.getDimensions().width;
var d = this.popUp.getWidth();
if (c == d || d > c) {
return
}
var h = c - d;
var f = h / 2;
if (this.state == "hide") {
var g = document.viewport.getHeight() + this.popUp.getHeight();
return {
x: f,
y: g
}
} else {
var g = document.viewport.getHeight() - this.popUp.getHeight();
return {
x: f,
y: g
}
}
},
hide: function (c) {
this.state = "hide";
var d = this.position();
new Effect.Move(this.popUp, {
x: d.x,
y: d.y,
mode: "absolute"
});
this.pendingTimeouts.each(function (f) {
clearTimeout(f)
});
this.pendingTimeouts.clear();
if (c) {
c.stop()
}
return false
},
showPopUp: function () {
var c = document.cookie.split(";").invoke("strip").invoke("split", "=", 2).find(function (d) {
return d[0] == this.cookieName
}.bind(this));
if (c != undefined && c.length > 0) {
if (window.location.search.parseQuery().resetPopUp != undefined) {
return this.resetCookie()
}
if (this.preview || window.location.search.parseQuery().firePopUp != undefined) {
return true
}
return false
}
this.setCookie();
return true
},
resetCookie: function () {
document.cookie = this.cookieName + "=true; expires=" + new Date(new Date().getTime() - 86400000).toGMTString() + "; path=/";
return true
},
setCookie: function () {
document.cookie = this.cookieName + "=true; expires=" + new Date(new Date().getTime() + 14400000).toGMTString() + "; path=/"
},
insertTrackingImages: function () {
if (this.componentTrackerInstaller) {
this.componentTrackerInstaller()
}
this.trackingImages.each(function (d) {
var c = new Image();
c.height = "1";
c.width = "1";
c.src = d;
this.trackImagesEl.insert(c)
}.bind(this))
},
show: function () {
this.state = "show";
var d = this.position();
var c = Object.extend({
x: d.x,
y: d.y,
mode: "absolute",
afterFinish: this.hideAfter.bind(this)
}, this.slideOpts);
this.insertTrackingImages();
this.popUp.show();
new Effect.Move(this.popUp, c)
},
start: function () {
if (!this.showPopUp()) {
return
}
this.pendingTimeouts.push(setTimeout(this.show.bind(this), this.startSec * 1000))
},
hideAfter: function () {
this.pendingTimeouts.push(setTimeout(this.hide.bind(this), this.hideSec * 1000))
}
};
b.init(a);
return b
}
})();
SBN.DraftPicker = (function (d) {
var d = d;
var f = $("draft-pick-form");
var c = $("valvoline-registration");
var g = d.players.map(function (h) {
return {
name: h.name,
id: h.id
}
});
var a = function (h) {};
var b = {
init: function (h) {
this.options = h;
if (this.options.isEmail) {
c.observe("blur", this.validateEmail.bind(this))
}
f.observe("submit", this.submit.bind(this));
this.setupPlayerPicks()
},
getPickEl: function (h) {
if (h.tagName == "li" || h.tagName == "LI") {
return h
} else {
return h.up("li")
}
},
pickClicked: function (k) {
var j = this.getPickEl(k.element());
if (!j) {
return
} else {
this.pickEl = j
}
var h = "player-select-" + j.id;
j.childElements().invoke("remove");
j.update('<span><input type="text" id="' + h + '" /></span>');
this.autocompleter = new Autocompleter.Local(h, "player-autocomplete", g, {
choices: 30,
selector: this.selector.bind(this),
updateElement: this.updateElement.bind(this),
scrollIntoView: false,
onShow: function (l, m) {
if (!m.style.position || m.style.position == "absolute") {
m.style.position = "absolute";
Position.clone(l, m, {
setHeight: false,
setWidth: false,
offsetTop: l.offsetHeight
})
}
Effect.Appear(m, {
duration: 0.15
})
}
});
$(h).observe("blur", this.pickBlurred.bind(this));
$(h).focus()
},
updateElement: function (j) {
var l = j.getAttribute("data-player-id");
var k = this.options.players.detect(function (m) {
if (m.id == l) {
m.selected = true;
return true
} else {
return false
}
});
if (!this.pickEl) {
return
}
if (k) {
this.pickEl.removeClassName("pick-error");
this.pickEl.setAttribute("data-player-id", k.id);
this.pickEl.addClassName("player-picked")
}
try {
this.pickEl.childElements().invoke("remove");
this.pickEl.update("<span class='pick-player'><strong>" + k.name + "</strong></span>&nbsp;<span class='edit-link pick-player'>Edit</span>")
} catch (h) {}
this.setupPlayerPicks();
this.pickEl = null
},
pickBlurred: function (k) {
this.removePlayerPickListener();
var h = this.getPickEl(k.element());
h.childElements().invoke("remove");
if (h.getAttribute("data-player-id")) {
var l = h.getAttribute("data-player-id");
var j = this.options.players.detect(function (m) {
return l == m.id
});
h.update("<span class='pick-player'><strong>" + j.name + "</strong></span>&nbsp;<span class='edit-link pick-player'>Edit</span>")
} else {
h.update('<span class="pick-player">Pick a player</span>')
}
this.setupPlayerPicks();
k.stop();
return false
},
removePlayerPickListener: function () {
if (this.pickListener) {
$$(".pick-player").each(function (h) {
h.stopObserving("click", this.pickListener)
}.bind(this))
}
},
setupPlayerPicks: function () {
this.removePlayerPickListener();
this.pickListener = this.pickClicked.bindAsEventListener(this);
$$(".pick-player").each(function (h) {
h.observe("click", this.pickListener)
}.bind(this))
},
validateEmail: function (j) {
var k = "^[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+.[-!#$%&'*+\\./0-9=?A-Z^_`a-z{|}~]+$";
var h = c.getValue();
$("error-email").hide();
if (!new RegExp(k).test(h)) {
$("error-email").show();
j.stop();
return false
}
return true
},
validatePlayers: function (j) {
if ($("missing-players")) {
$("missing-players").hide()
}
var k = false;
ids = [];
var h = $$("li.pick-player");
h.each(function (m) {
var l = parseInt(m.id.replace("pick-", ""));
m.removeClassName("pick-error");
if (!m.getAttribute("data-player-id")) {
m.addClassName("pick-error");
if ($("missing-players")) {
$("missing-players").show()
}
k = true
} else {
ids[l] = m.getAttribute("data-player-id")
}
}.bind(this));
if (k) {
return false
} else {
return ids
}
},
submit: function (l) {
var n, k, j;
$("dp-errors").hide();
k = this.validatePlayers();
if (this.options.isEmail) {
j = this.validateEmail(l)
} else {
j = true
}
if (this.options.isEmail && $("valvoline-name").getValue().strip().empty()) {
var h = false;
$("error-name").show()
} else {
var h = true;
if ($("error-name")) {
$("error-name").hide()
}
}
if (!j || !k || !h) {
l.stop();
return false
}
if (this.options.editToken) {
n = this.options.editToken
}
var k = this.validatePlayers();
if (!k) {
l.stop();
return false
} else {
$("player_ids").value = k.join(",")
}
var m = f.serialize();
if (n) {
m = m + "&edit_token=" + n
}
$("dp-loading").show();
new Ajax.Request("/partners/valvoline-nfl-draft-picker/save", {
method: "POST",
parameters: m,
onSuccess: function (p) {
var o = p.responseJSON;
if (!o.success) {
$("dp-loading").hide();
$("dp-errors").update(o.errorMsg);
$("dp-errors").show();
return false
} else {
window.location = o.redirectURL
}
}
});
l.stop();
return false
},
selector: function (q) {
var n = [];
var o = [];
var p = q.getToken();
var m = 0;
var l = $$(".pick-player").map(function (u) {
return u.getAttribute("data-player-id")
});
for (var k = 0; k < this.options.players.length && n.length < this.options.players.length; k++) {
var h = this.options.players[k];
if (l.indexOf(h.id) > -1) {
continue
}
var j = h.name;
var r = " data-player-id='" + h.id + "' ";
var t = q.options.ignoreCase ? j.toLowerCase().indexOf(p.toLowerCase()) : j.indexOf(p);
while (t != -1) {
if (t == 0 && j.length != p.length) {
n.push("<li" + r + "><strong>" + j.substr(0, p.length) + "</strong>" + j.substr(p.length) + "</li>");
break
} else {
if (p.length >= q.options.partialChars && q.options.partialSearch && t != -1) {
if (q.options.fullSearch || /\s/.test(j.substr(t - 1, 1))) {
o.push("<li " + r + ">" + j.substr(0, t) + "<strong>" + j.substr(t, p.length) + "</strong>" + j.substr(t + p.length) + "</li>");
break
}
}
}
t = q.options.ignoreCase ? j.toLowerCase().indexOf(p.toLowerCase(), t + 1) : j.indexOf(p, t + 1)
}
}
if (o.length) {
n = n.concat(o.slice(0, q.options.choices - n.length))
}
return "<ul>" + n.join("") + "</ul>"
}
};
b.init(d);
return b
});
SBN.loadScriptAsync = function (a) {
var c = document.createElement("SCRIPT"),
b = document.getElementsByTagName("SCRIPT")[0];
c.type = "text/javascript";
c.async = true;
c.src = a;
b.parentNode.insertBefore(c, b)
};
document.observe("dom:loaded", function () {
$$(".youtube_channel").each(function (h) {
var d = h.select(".yt-player")[0],
c = h.select(".yt-video"),
j = h.select(".yt-video.active")[0],
g = h.select(".yt-previous, .yt-next"),
b = h.select(".yt-scrollpane div")[0],
f = 0,
a = Math.ceil(c.length / 3) - 1;
g.invoke("observe", "click", function (l) {
l.stop();
var k = f + (this.hasClassName("yt-previous") ? -1 : 1);
if (k < 0 || k > a) {
return false
}
g.invoke("removeClassName", "inactive");
if (k == 0) {
g[0].addClassName("inactive")
}
if (k == a) {
g[1].addClassName("inactive")
}
new Effect.Move(b, {
mode: "absolute",
x: (-252 * k),
duration: 0.5
});
f = k
});
c.invoke("observe", "click", function (k) {
k.stop();
_gaq.push(["_trackEvent", "SBN YouTube Integration", "Right Rail Thumbnails"]);
if (this.hasClassName("active")) {
return false
}
d.writeAttribute({
src: "http://www.youtube.com/embed/" + this.readAttribute("data-embed-id") + "?autoplay=1",
height: this.readAttribute("data-embed-height")
});
this.addClassName("active");
j.removeClassName("active");
j = this
})
})
});
__bind = function (a, b) {
return function () {
return a.apply(b, arguments)
}
};
SBN.Pick6 = {};
SBN.Pick6.CountdownTimer = {
timeout: 0,
render: function () {
$$(".pick6-countdown .hours")[0].update(SBN.Pick6.CountdownTimer.padTwo(SBN.Pick6.CountdownTimer.hours()));
$$(".pick6-countdown .minutes")[0].update(SBN.Pick6.CountdownTimer.padTwo(SBN.Pick6.CountdownTimer.minutes() % 60))
},
start: function () {
return SBN.Pick6.CountdownTimer.timeout = setTimeout(SBN.Pick6.CountdownTimer.tick, 1000)
},
stop: function () {
return clearTimeout(SBN.Pick6.CountdownTimer.timeout)
},
tick: function () {
SBN.Pick6.time_left = parseInt(SBN.Pick6.time_left) - 1;
if (SBN.Pick6.time_left <= 0) {
SBN.Pick6.CountdownTimer.boom()
}
if (SBN.Pick6.time_left > 0) {
SBN.Pick6.CountdownTimer.timeout = setTimeout(SBN.Pick6.CountdownTimer.tick, 1000);
SBN.Pick6.CountdownTimer.render()
}
},
seconds: function () {
return parseInt(SBN.Pick6.time_left)
},
minutes: function () {
return parseInt(SBN.Pick6.CountdownTimer.seconds() / 60)
},
hours: function () {
return parseInt(SBN.Pick6.CountdownTimer.minutes() / 60)
},
days: function () {
return parseInt(SBN.Pick6.CountdownTimer.hours() / 24)
},
boom: function () {
SBN.Pick6.CountdownTimer.stop()
},
padTwo: function (a) {
if (a < 10) {
return "0" + a
} else {
return a
}
}
};
if (typeof (SBN) == "undefined") {
SBN = {}
}
if (SBN.Campaigns == undefined) {
SBN.Campaigns = {}
}
SBN.Campaigns.Components = {
clickUrls: {},
queuedClicks: {},
activatedComponents: $A(),
componentProperties: $A(["campaign_id", "component_id", "component_type"]),
callbacks: {},
installTracker: function (b, a, d) {
var f = this.callbackName(d);
this.callbacks[f] = function (g) {
this.completeInstallTracker(d, g)
}.bind(this);
var c = function () {
var g = document.createElement("script");
g.type = "text/javascript";
g.src = "http://" + b + "/w/1.0/arj?auid=" + encodeURIComponent(a) + "&c.component_tracker_id=" + encodeURIComponent(d) + "&jsonp=" + encodeURIComponent("SBN.Campaigns.Components.callbacks." + f);
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(g)
}.bind(this);
$(document).observe("dom:loaded", c)
},
callbackName: function (b) {
var a = "cb" + b;
a = a.replace(new RegExp("-|_", "g"), "");
return a
},
completeInstallTracker: function (c, f) {
if (f.ads["ad"][0]) {
var b = f.ads["ad"][0];
var h = b.html;
var d = b.creative[0]["tracking"]["click"];
var g = $(document.createElement("div"));
g.id = c + "-container";
g.innerHTML = h;
var a = document.getElementsByTagName("body")[0];
a.appendChild(g);
this.clickUrls[c] = d;
setTimeout(function () {
if (this.queuedClicks[c]) {
var j = this.queuedClicks[c];
this.queuedClicks[c] = null;
this.click(c, this.queuedClicks[c].opts)
}
}.bind(this), 1000)
}
},
click: function (c, b) {
b = Object.extend({
newWindowName: null
}, b || {});
var a = this.clickUrls[c];
if (a) {
if (b.newWindowName != null) {
window.open(a, b.newWindowName)
} else {
window.location = a
}
} else {
this.queuedClicks[c] = {
opts: b
}
}
},
logActivation: function (c, a, b) {
this.activatedComponents.push({
component_id: c,
campaign_id: a,
component_type: b
})
},
activeComponentContext: function () {
var a = $H();
this.componentProperties.each(function (c) {
var b = this.activatedComponents.collect(function (d) {
return d[c]
}.bind(this)).uniq();
if (b.size() > 0) {
a.set(c, b)
}
}.bind(this));
return a
}
};
SBN.AccessNotifier = Class.create({
initialize: function (a, b) {
if (Object.isUndefined(arguments[0]) || Object.isUndefined(arguments[1])) {
throw "name and callback are required arguments!"
}
if (!Object.isString(arguments[0])) {
throw "name must be a string!"
}
if (!Object.isFunction(arguments[1])) {
throw "callback must be a function!"
}
var a = a.strip();
if (a == "") {
throw "name can't be empty!"
}
this.name = a;
this.url = "/accesses/#{name}".interpolate({
name: this.name
});
this.callback = b;
this.request = null;
this.currentUsers = [];
this.executer = new PeriodicalExecuter(this.onExecute.bind(this), 5);
Event.observe(window, "beforeunload", this.onUnload.bind(this));
this.start()
},
onExecute: function () {
this.notify()
},
onUnload: function () {
this.stop()
},
start: function () {
this.executer.stop();
this.executer.onTimerEvent();
this.executer.registerCallback()
},
stop: function () {
this.executer.stop();
if (this.request) {
this.request.transport.abort();
this.request = null
}
new Ajax.Request(this.url, {
method: "delete"
})
},
notify: function () {
this.request = new Ajax.Request(this.url, {
method: "post",
onSuccess: this.onNotifySuccess.bind(this),
onFailure: this.onNotifyFailure.bind(this)
})
},
onNotifySuccess: function (c) {
var b = this.currentUsers;
var a = $A(c.responseJSON || []);
var d = this._buildUserChangeSet(b, a);
this.currentUsers = a;
if (d.hasChanges) {
this.callback(d)
}
},
onNotifyFailure: function (a) {
console.log("SBN.AccessNotifier unable to notify server")
},
_buildUserChangeSet: function (h, d) {
var c = function (l, k) {
l[k.id] = k;
return l
};
var j = h.inject({}, c);
var g = d.inject({}, c);
var b = h.findAll(function (k) {
return !g[k.id]
});
var f = d.findAll(function (k) {
return !j[k.id]
});
var a = (b.length > 0) || (f.length > 0);
return {
all: d,
added: f,
removed: b,
hasChanges: a
}
}
});
if (!VERGE) {
var VERGE = {}
}
VERGE.func = {};
VERGE.func.inViewport = function (a) {
var b = a.getBoundingClientRect();
return (b.top >= 0 && b.left >= 0 && b.bottom <= window.innerHeight && b.right <= window.innerWidth)
};
VERGE.func.triggerScroll = function (b) {
var c = c || b.offset().top - window.innerHeight;
var a = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
return (a >= c)
};
VERGE.func.commentLazyLoad = function (a) {
if (VERGE.func.triggerScroll(a)) {
a.text("LOADING...").trigger("click");
$j(window).unbind("scroll.commentLazyLoad")
}
};
VERGE.flash = {};
VERGE.flash.obj = "#network-bar-flash";
VERGE.flash.show = function (a) {
$j(VERGE.flash.obj).html(a).fadeIn(500)
};
VERGE.flash.hide = function () {
$j(VERGE.flash.obj).fadeOut(500);
VERGE.flash.reset()
};
VERGE.flash.reset = function () {
$j(VERGE.flash.obj).html("")
};
(function (h) {
function l(f) {
function a(d) {
var n = new RegExp(h.map(d, encodeURIComponent).join("|"), "ig");
return function (c) {
return c.replace(n, decodeURIComponent)
}
}
function b(c) {
if (c === true) {
return function (d) {
return d
}
}
if (typeof c == "string" && (c = a(c.split(""))) || typeof c == "function") {
return function (d) {
return c(encodeURIComponent(d))
}
}
return encodeURIComponent
}
f = h.extend({
unescape: false
}, f || {});
g.encoder = b(f.unescape)
}
var g = {
put: function (d, c) {
(c || window).location.hash = this.encoder(d)
},
get: function (a) {
var n = (a || window).location.hash.replace(/^#/, "");
try {
return h.browser.mozilla ? n : decodeURIComponent(n)
} catch (f) {
return n
}
},
encoder: encodeURIComponent
};
var m = {
id: "__jQuery_history",
init: function () {
var a = '<iframe id="' + this.id + '" style="display:none" src="javascript:false;" />';
h("body").prepend(a);
return this
},
_document: function () {
return h("#" + this.id)[0].contentWindow.document
},
put: function (b) {
var d = this._document();
d.open();
d.close();
g.put(b, d)
},
get: function () {
return g.get(this._document())
}
};
var k = {};
k.base = {
callback: undefined,
type: undefined,
check: function () {},
load: function (b) {},
init: function (d, c) {
l(c);
j.callback = d;
j._options = c;
j._init()
},
_init: function () {},
_options: {}
};
k.timer = {
_appState: undefined,
_init: function () {
var b = g.get();
j._appState = b;
j.callback(b);
setInterval(j.check, 100)
},
check: function () {
var b = g.get();
if (b != j._appState) {
j._appState = b;
j.callback(b)
}
},
load: function (b) {
if (b != j._appState) {
g.put(b);
j._appState = b;
j.callback(b)
}
}
};
k.iframeTimer = {
_appState: undefined,
_init: function () {
var b = g.get();
j._appState = b;
m.init().put(b);
j.callback(b);
setInterval(j.check, 100)
},
check: function () {
var b = m.get(),
c = g.get();
if (c != b) {
if (c == j._appState) {
j._appState = b;
g.put(b);
j.callback(b)
} else {
j._appState = c;
m.put(c);
j.callback(c)
}
}
},
load: function (b) {
if (b != j._appState) {
g.put(b);
m.put(b);
j._appState = b;
j.callback(b)
}
}
};
k.hashchangeEvent = {
_init: function () {
j.callback(g.get());
h(window).bind("hashchange", j.check)
},
check: function () {
j.callback(g.get())
},
load: function (b) {
g.put(b)
}
};
var j = h.extend({}, k.base);
if (h.browser.msie && (h.browser.version < 8 || document.documentMode < 8)) {
j.type = "iframeTimer"
} else {
if ("onhashchange" in window) {
j.type = "hashchangeEvent"
} else {
j.type = "timer"
}
}
h.extend(j, k[j.type]);
h.history = j
})(jQuery);
(function (a) {
a.fn.gallery = function (b) {
var p = {
mainSelector: "#gallery-pic",
thumbsObj: ".gallery-nav",
thumbSelector: ".gallery-thumb",
picNavPrev: ".gallery-pic-prev",
picNavNext: ".gallery-pic-next",
galleryTitle: ".gallery-title",
galleryBody: ".gallery-body",
picTitle: ".gallery-pic-title",
picBody: ".gallery-pic-body",
permalinks: true,
inline: false
};
var c, g, f, m, n, k, j, l, o;
var h = {
init: function (q) {
return this.each(function () {
if (q) {
a.extend(p, q)
}
c = a(this);
p.thumbsObj = a(p.thumbsObj);
g = c.find(p.thumbSelector);
f = c.find(p.mainSelector);
m = c.find(p.picNavPrev);
n = c.find(p.picNavNext);
k = c.find(p.galleryTitle);
j = c.find(p.galleryBody);
l = c.find(p.picTitle);
o = c.find(p.picBody);
g.bind("click", d.updateMainPic);
m.bind("click", d.prevPicture).addClass("disabled");
n.bind("click", d.nextPicture).addClass("enabled");
if (p.inline) {
f.bind("click", d.nextPicture).addClass("enabled")
}
if (p.permalinks) {
a.history.init(d.processHash)
} else {
g.filter(":first").trigger("click")
}
})
}
};
var d = {
processHash: function (q) {
if (q) {
g.filter('[data-id="' + q + '"]').trigger("click")
} else {
g.filter(":first").trigger("click")
}
},
prevPicture: function () {
if (a(this).hasClass("enabled")) {
g.filter(".selected").prev().trigger("click")
}
return false
},
nextPicture: function () {
if (a(this).hasClass("enabled")) {
g.filter(".selected").next().trigger("click")
}
return false
},
resetControls: function () {
m.removeClass("disabled").addClass("enabled");
n.removeClass("disabled").addClass("enabled");
if (p.inline) {
f.removeClass("disabled").addClass("enabled")
}
index = g.index(g.filter(".selected"));
if (index == 0) {
m.addClass("disabled").removeClass("enabled")
} else {
if (index == g.length - 1) {
n.addClass("disabled").removeClass("enabled");
if (p.inline) {
f.addClass("disabled").removeClass("enabled")
}
}
}
currentPane = p.thumbsObj.data("page").on;
thumbsPerPane = p.thumbsObj.data("options").sectionsPerPage;
index += 1;
showPane = Math.ceil(index / thumbsPerPane);
if (currentPane < showPane) {
p.thumbsObj.data("page").on = showPane - 1;
p.thumbsObj.find(p.thumbsObj.data("options").nextSelector).trigger("click")
} else {
if (currentPane > showPane) {
p.thumbsObj.data("page").on = showPane + 1;
p.thumbsObj.find(p.thumbsObj.data("options").prevSelector).trigger("click")
}
}
},
figureSize: function () {
a("<img/>").attr("src", f.attr("src")).load(function () {
var r = this.height;
var q = parseInt(f.css("max-height").replace("px", ""));
var t = q - r;
if (t > 0) {
f.css("margin-top", t / 2 + "px")
} else {
f.css("margin-top", "0")
}
})
},
updateMainPic: function () {
g.removeClass("selected");
$thumb = g.filter(this);
newPicUrl = $thumb.data("src");
if (c.data("first-load") && p.permalinks) {
if (document.location.href.indexOf("#") != -1) {
a.history.load($thumb.data("id"))
}
} else {
if (p.permalinks) {
c.data("first-load", true);
document.location.hash = $thumb.data("id")
}
}
$thumb.addClass("selected");
f.attr("src", newPicUrl);
l.text((($thumb.find("h3").text()) ? $thumb.find("h3").text() : k.text()));
o.text((($thumb.find("p").text()) ? $thumb.find("p").text() : j.text()));
d.resetControls();
d.figureSize()
}
};
if (h[b] && b.toLowerCase() != "init") {
return h[b].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof b === "object" || !b) {
return h.init.apply(this, arguments)
} else {
$.error('Method "' + b + '" does not exist in the gallery plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.scrollPane = function (b) {
var n = {
easing: "easeInQuad",
speed: 400,
prevSelector: ".prev",
nextSelector: ".next",
paneSelector: ".pane",
sliderSelector: ".slider",
sectionSelector: ".section",
sectionsPerPage: 5,
enabledClass: "enabled",
disabledClass: "disabled"
};
var c, g, j, d, m, k, l;
var h = {
init: function (o) {
return this.each(function () {
if (o) {
a.extend(n, o)
}
c = a(this);
c.data("options", n);
g = c.find(n.prevSelector);
j = c.find(n.nextSelector);
d = c.find(n.paneSelector);
m = c.find(n.sliderSelector);
k = c.find(n.sectionSelector);
var r = k.length % n.sectionsPerPage;
var q = k.length / n.sectionsPerPage;
var p = (r > 0) ? Math.ceil(q) : Math.floor(q);
c.data("page", {
on: 1,
count: p
});
f.activateControls();
l = f.calculatePaneWidth();
f.setSliderWidth();
if (!c.data("reference")) {
c.data("reference", {
target: c
})
}
c.find(g).bind("click", f.moveSlider);
c.find(j).bind("click", f.moveSlider);
c.bind("resetSlider", f.reset)
})
}
};
var f = {
moveSlider: function () {
var p = a(this);
if (p.hasClass(n.enabledClass) && !p.data("freeze")) {
p.data("freeze", true);
var q = p.is(j) ? n.sectionsPerPage * c.data("page").on : n.sectionsPerPage * (c.data("page").on - 2);
var o = k.eq(q).position().left * -1;
m.animate({
left: o
}, n.speed, n.easing, function () {
var t = c.data("page").on;
var r = (p.is(j)) ? t + 1 : t - 1;
c.data("page").on = r;
f.activateControls();
p.removeData("freeze")
})
}
return false
},
activateControls: function () {
var o = c.data("page");
o.count > o.on ? j.addClass(n.enabledClass).removeClass(n.disabledClass) : j.removeClass(n.enabledClass).addClass(n.disabledClass);
o.on > 1 ? g.addClass(n.enabledClass).removeClass(n.disabledClass) : g.removeClass(n.enabledClass).addClass(n.disabledClass)
},
calculatePaneWidth: function () {
return c.find(d).width()
},
setSliderWidth: function () {
var o = 0;
k.each(function () {
o += a(this).outerWidth()
});
m.width(o)
},
reset: function () {
m.css("left", "0");
g.addClass(n.disabledClass).removeClass(n.enabledClass);
j.removeClass(n.disabledClass).addClass(n.enabledClass)
}
};
if (h[b] && b.toLowerCase() != "init") {
return h[b].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof b === "object" || !b) {
return h.init.apply(this, arguments)
} else {
$.error('Method "' + b + '" does not exist in the scrollPane plugin!')
}
}
}
})(jQuery);
(function ($j) {
$j.fn.greatToggler = function (method) {
var $obj, toggleData;
var methods = {
init: function (config) {
return this.each(function () {
$obj = $j(this);
toggleData = $obj.data("great-toggler");
if (typeof (toggleData) == "object") {
if (typeof (toggleData.custom) == "undefined") {
$obj.bind("click", helpers.hideAndToggle)
} else {
eval("$obj.bind('click',custom." + toggleData.custom + ");")
}
} else {
$obj.bind("click", helpers.justToggle)
}
})
}
};
var helpers = {
justToggle: function () {
$j(toggleData).toggle();
$obj.toggleClass("toggled");
return false
},
hideAndToggle: function () {
$j(toggleData.hide).hide();
$j(toggleData.show).show();
return false
}
};
var custom = {
toggleAndRestHeroOverlay: function () {
$overlayToOpen = $j(toggleData.hero);
$activeOverlay = $j(".hero-overlay:visible");
$activeOverlay.trigger("resetSlider").hide();
if ($activeOverlay.attr("id") !== $overlayToOpen.attr("id")) {
$overlayToOpen.show()
}
$j(this).toggleClass("open");
return false
},
speedReadingSlide: function () {
$obj.hide();
$j(toggleData.swapMe).show();
$j(toggleData.slideMe).slideToggle(400);
return false
}
};
if (methods[method] && method.toLowerCase() != "init") {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof method === "object" || !method) {
return methods.init.apply(this, arguments)
} else {
$.error('Method "' + method + '" does not exist in the Great Toggler plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.tabinate = function (j) {
var f = {
tabSelector: ".tab",
paneSelector: ".pane",
activeClass: "active",
startingTab: 0
};
var h, b, d;
var c = {
init: function (k) {
return this.each(function () {
if (k) {
a.extend(f, k)
}
h = a(this);
b = h.find(f.tabSelector);
d = h.find(f.paneSelector);
d.hide();
g.bindTabs()
})
}
};
var g = {
bindTabs: function () {
var k = f.startingTab;
b.each(function () {
var m = a(this);
if (m.hasClass(f.activeClass)) {
k = b.index(m)
}
m.removeClass(f.activeClass);
var l = m.data("tab-for");
if (l && l == window.location.hash) {
k = b.index(m)
}
m.bind("click", function () {
b.removeClass(f.activeClass);
var n = b.index(a(this));
if (a(this).data("tab-for")) {
d.hide();
a(a(this).data("tab-for")).show()
} else {
d.hide().eq(n).show()
}
a(this).addClass(f.activeClass);
return false
})
});
g.showTab(k)
},
showTab: function (k) {
if (typeof k == "string") {
a(k).trigger("click")
} else {
b.eq(k).trigger("click")
}
}
};
if (c[j] && j.toLowerCase() != "init") {
return c[j].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof j === "object" || !j) {
return c.init.apply(this, arguments)
} else {
$.error('Method "' + j + '" does not exist in the tabinate plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.inputate = function (h) {
var c = {};
var g, f;
var b = {
init: function (j) {
return this.each(function () {
if (j) {
a.extend(c, j)
}
g = a(this);
f = g.data("inputate");
g.val(f);
g.bind("focus", d.focus);
g.bind("blur", d.blur);
g.bind("submit", d.focus)
})
}
};
var d = {
focus: function () {
if (g.val() == f) {
g.val("")
}
},
blur: function () {
if (a.trim(g.val()) == "") {
g.val(f)
}
}
};
if (b[h] && h.toLowerCase() != "init") {
return b[h].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof h === "object" || !h) {
return b.init.apply(this, arguments)
} else {
$.error('Method "' + h + '" does not exist in the tabinate plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.compare = function (g) {
var c = {};
var f;
var b = {
init: function (h) {
return this.each(function () {
if (h) {
a.extend(c, h)
}
f = a(this)
})
}
};
var d = {};
if (b[g] && g.toLowerCase() != "init") {
return b[g].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof g === "object" || !g) {
return b.init.apply(this, arguments)
} else {
$.error('Method "' + g + '" does not exist in the tabinate plugin!')
}
}
}
})(jQuery);
jQuery.cookie = function (d, f, b) {
if (arguments.length > 1 && String(f) !== "[object Object]") {
b = jQuery.extend({}, b);
if (f === null || f === undefined) {
b.expires = -1
}
if (typeof b.expires === "number") {
var h = b.expires,
c = b.expires = new Date();
c.setDate(c.getDate() + h)
}
f = String(f);
return (document.cookie = [encodeURIComponent(d), "=", b.raw ? f : encodeURIComponent(f), b.expires ? "; expires=" + b.expires.toUTCString() : "", b.path ? "; path=" + b.path : "", b.domain ? "; domain=" + b.domain : "", b.secure ? "; secure" : ""].join(""))
}
b = f || {};
var a, g = b.raw ?
function (j) {
return j
} : decodeURIComponent;
return (a = new RegExp("(?:^|; )" + encodeURIComponent(d) + "=([^;]*)").exec(document.cookie)) ? g(a[1]) : null
};
(function ($) {
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g,
meta = {
"\b": "\\b",
"\t": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
'"': '\\"',
"\\": "\\\\"
};
$.toJSON = typeof JSON === "object" && JSON.stringify ? JSON.stringify : function (o) {
if (o === null) {
return "null"
}
var type = typeof o;
if (type === "undefined") {
return undefined
}
if (type === "number" || type === "boolean") {
return "" + o
}
if (type === "string") {
return $.quoteString(o)
}
if (type === "object") {
if (typeof o.toJSON === "function") {
return $.toJSON(o.toJSON())
}
if (o.constructor === Date) {
var month = o.getUTCMonth() + 1,
day = o.getUTCDate(),
year = o.getUTCFullYear(),
hours = o.getUTCHours(),
minutes = o.getUTCMinutes(),
seconds = o.getUTCSeconds(),
milli = o.getUTCMilliseconds();
if (month < 10) {
month = "0" + month
}
if (day < 10) {
day = "0" + day
}
if (hours < 10) {
hours = "0" + hours
}
if (minutes < 10) {
minutes = "0" + minutes
}
if (seconds < 10) {
seconds = "0" + seconds
}
if (milli < 100) {
milli = "0" + milli
}
if (milli < 10) {
milli = "0" + milli
}
return '"' + year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "." + milli + 'Z"'
}
if (o.constructor === Array) {
var ret = [];
for (var i = 0; i < o.length; i++) {
ret.push($.toJSON(o[i]) || "null")
}
return "[" + ret.join(",") + "]"
}
var name, val, pairs = [];
for (var k in o) {
type = typeof k;
if (type === "number") {
name = '"' + k + '"'
} else {
if (type === "string") {
name = $.quoteString(k)
} else {
continue
}
}
type = typeof o[k];
if (type === "function" || type === "undefined") {
continue
}
val = $.toJSON(o[k]);
pairs.push(name + ":" + val)
}
return "{" + pairs.join(",") + "}"
}
};
$.evalJSON = typeof JSON === "object" && JSON.parse ? JSON.parse : function (src) {
return eval("(" + src + ")")
};
$.secureEvalJSON = typeof JSON === "object" && JSON.parse ? JSON.parse : function (src) {
var filtered = src.replace(/\\["\\\/bfnrtu]/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, "");
if (/^[\],:{}\s]*$/.test(filtered)) {
return eval("(" + src + ")")
} else {
throw new SyntaxError("Error parsing JSON, source is not valid.")
}
};
$.quoteString = function (string) {
if (string.match(escapeable)) {
return '"' + string.replace(escapeable, function (a) {
var c = meta[a];
if (typeof c === "string") {
return c
}
c = a.charCodeAt();
return "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16)
}) + '"'
}
return '"' + string + '"'
}
})(jQuery);
(function (a) {
a.fn.networkBar = function (j) {
var d = {
compareIndicator: "#network-compare",
backToTopButton: "#back-to-top",
compareBuffer: "39px",
buttonTop: "6px"
};
var h, g, b;
var c = {
init: function (k) {
return this.each(function () {
if (k) {
a.extend(d, k)
}
h = a(this);
a(window).bind("scroll", f.scrollCheck);
g = a(d.compareIndicator);
b = a(d.backToTopButton);
b.bind("click", f.backToTop);
var l = {
sensitivity: 7,
interval: 300,
over: f.showCompareReset,
timeout: 300,
out: f.hideCompareReset
};
g.hoverIntent(l)
})
}
};
var f = {
scrollCheck: function () {
var k = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
if (k > 0) {
!h.data("backToTop") ? f.showBackToButton() : null
} else {
if (k <= 0) {
h.data("backToTop") ? f.hideBackToButton() : null
}
}
},
backToTop: function () {
a("html,body").animate({
scrollTop: 0
}, 400);
return false
},
showBackToButton: function () {
g.animate({
right: d.compareBuffer
}, 300, "easeInOutQuart", function () {
b.stop().animate({
top: d.buttonTop
}, 300, "easeInOutQuart")
});
h.data("backToTop", true)
},
hideBackToButton: function () {
b.animate({
top: "-25px"
}, 200, "easeInOutQuart", function () {
g.stop().delay(100).animate({
right: 0
}, 300, "easeInOutBack")
});
h.removeData("backToTop")
},
showCompareReset: function () {
g.stop().animate({
height: "70px"
}, 300, "easeInOutQuart")
},
hideCompareReset: function () {
g.stop().animate({
height: "30px"
}, 300, "easeInOutQuart")
}
};
if (c[j] && j.toLowerCase() != "init") {
return c[j].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof j === "object" || !j) {
return c.init.apply(this, arguments)
} else {
$.error('Method "' + j + '" does not exist in this plugin!')
}
}
}
})(jQuery);
jQuery.easing.jswing = jQuery.easing.swing;
jQuery.extend(jQuery.easing, {
def: "easeOutQuad",
swing: function (f, g, a, j, h) {
return jQuery.easing[jQuery.easing.def](f, g, a, j, h)
},
easeInQuad: function (f, g, a, j, h) {
return j * (g /= h) * g + a
},
easeOutQuad: function (f, g, a, j, h) {
return -j * (g /= h) * (g - 2) + a
},
easeInOutQuad: function (f, g, a, j, h) {
if ((g /= h / 2) < 1) {
return j / 2 * g * g + a
}
return -j / 2 * ((--g) * (g - 2) - 1) + a
},
easeInCubic: function (f, g, a, j, h) {
return j * (g /= h) * g * g + a
},
easeOutCubic: function (f, g, a, j, h) {
return j * ((g = g / h - 1) * g * g + 1) + a
},
easeInOutCubic: function (f, g, a, j, h) {
if ((g /= h / 2) < 1) {
return j / 2 * g * g * g + a
}
return j / 2 * ((g -= 2) * g * g + 2) + a
},
easeInQuart: function (f, g, a, j, h) {
return j * (g /= h) * g * g * g + a
},
easeOutQuart: function (f, g, a, j, h) {
return -j * ((g = g / h - 1) * g * g * g - 1) + a
},
easeInOutQuart: function (f, g, a, j, h) {
if ((g /= h / 2) < 1) {
return j / 2 * g * g * g * g + a
}
return -j / 2 * ((g -= 2) * g * g * g - 2) + a
},
easeInQuint: function (f, g, a, j, h) {
return j * (g /= h) * g * g * g * g + a
},
easeOutQuint: function (f, g, a, j, h) {
return j * ((g = g / h - 1) * g * g * g * g + 1) + a
},
easeInOutQuint: function (f, g, a, j, h) {
if ((g /= h / 2) < 1) {
return j / 2 * g * g * g * g * g + a
}
return j / 2 * ((g -= 2) * g * g * g * g + 2) + a
},
easeInSine: function (f, g, a, j, h) {
return -j * Math.cos(g / h * (Math.PI / 2)) + j + a
},
easeOutSine: function (f, g, a, j, h) {
return j * Math.sin(g / h * (Math.PI / 2)) + a
},
easeInOutSine: function (f, g, a, j, h) {
return -j / 2 * (Math.cos(Math.PI * g / h) - 1) + a
},
easeInExpo: function (f, g, a, j, h) {
return (g == 0) ? a : j * Math.pow(2, 10 * (g / h - 1)) + a
},
easeOutExpo: function (f, g, a, j, h) {
return (g == h) ? a + j : j * (-Math.pow(2, -10 * g / h) + 1) + a
},
easeInOutExpo: function (f, g, a, j, h) {
if (g == 0) {
return a
}
if (g == h) {
return a + j
}
if ((g /= h / 2) < 1) {
return j / 2 * Math.pow(2, 10 * (g - 1)) + a
}
return j / 2 * (-Math.pow(2, -10 * --g) + 2) + a
},
easeInCirc: function (f, g, a, j, h) {
return -j * (Math.sqrt(1 - (g /= h) * g) - 1) + a
},
easeOutCirc: function (f, g, a, j, h) {
return j * Math.sqrt(1 - (g = g / h - 1) * g) + a
},
easeInOutCirc: function (f, g, a, j, h) {
if ((g /= h / 2) < 1) {
return -j / 2 * (Math.sqrt(1 - g * g) - 1) + a
}
return j / 2 * (Math.sqrt(1 - (g -= 2) * g) + 1) + a
},
easeInElastic: function (g, j, f, n, m) {
var k = 1.70158;
var l = 0;
var h = n;
if (j == 0) {
return f
}
if ((j /= m) == 1) {
return f + n
}
if (!l) {
l = m * 0.3
}
if (h < Math.abs(n)) {
h = n;
var k = l / 4
} else {
var k = l / (2 * Math.PI) * Math.asin(n / h)
}
return -(h * Math.pow(2, 10 * (j -= 1)) * Math.sin((j * m - k) * (2 * Math.PI) / l)) + f
},
easeOutElastic: function (g, j, f, n, m) {
var k = 1.70158;
var l = 0;
var h = n;
if (j == 0) {
return f
}
if ((j /= m) == 1) {
return f + n
}
if (!l) {
l = m * 0.3
}
if (h < Math.abs(n)) {
h = n;
var k = l / 4
} else {
var k = l / (2 * Math.PI) * Math.asin(n / h)
}
return h * Math.pow(2, -10 * j) * Math.sin((j * m - k) * (2 * Math.PI) / l) + n + f
},
easeInOutElastic: function (g, j, f, n, m) {
var k = 1.70158;
var l = 0;
var h = n;
if (j == 0) {
return f
}
if ((j /= m / 2) == 2) {
return f + n
}
if (!l) {
l = m * (0.3 * 1.5)
}
if (h < Math.abs(n)) {
h = n;
var k = l / 4
} else {
var k = l / (2 * Math.PI) * Math.asin(n / h)
}
if (j < 1) {
return -0.5 * (h * Math.pow(2, 10 * (j -= 1)) * Math.sin((j * m - k) * (2 * Math.PI) / l)) + f
}
return h * Math.pow(2, -10 * (j -= 1)) * Math.sin((j * m - k) * (2 * Math.PI) / l) * 0.5 + n + f
},
easeInBack: function (f, g, a, k, j, h) {
if (h == undefined) {
h = 1.70158
}
return k * (g /= j) * g * ((h + 1) * g - h) + a
},
easeOutBack: function (f, g, a, k, j, h) {
if (h == undefined) {
h = 1.70158
}
return k * ((g = g / j - 1) * g * ((h + 1) * g + h) + 1) + a
},
easeInOutBack: function (f, g, a, k, j, h) {
if (h == undefined) {
h = 1.70158
}
if ((g /= j / 2) < 1) {
return k / 2 * (g * g * (((h *= (1.525)) + 1) * g - h)) + a
}
return k / 2 * ((g -= 2) * g * (((h *= (1.525)) + 1) * g + h) + 2) + a
},
easeInBounce: function (f, g, a, j, h) {
return j - jQuery.easing.easeOutBounce(f, h - g, 0, j, h) + a
},
easeOutBounce: function (f, g, a, j, h) {
if ((g /= h) < (1 / 2.75)) {
return j * (7.5625 * g * g) + a
} else {
if (g < (2 / 2.75)) {
return j * (7.5625 * (g -= (1.5 / 2.75)) * g + 0.75) + a
} else {
if (g < (2.5 / 2.75)) {
return j * (7.5625 * (g -= (2.25 / 2.75)) * g + 0.9375) + a
} else {
return j * (7.5625 * (g -= (2.625 / 2.75)) * g + 0.984375) + a
}
}
}
},
easeInOutBounce: function (f, g, a, j, h) {
if (g < h / 2) {
return jQuery.easing.easeInBounce(f, g * 2, 0, j, h) * 0.5 + a
}
return jQuery.easing.easeOutBounce(f, g * 2 - h, 0, j, h) * 0.5 + j * 0.5 + a
}
});
(function (a) {
a.fn.hoverIntent = function (m, l) {
var n = {
sensitivity: 7,
interval: 100,
timeout: 0
};
n = a.extend(n, l ? {
over: m,
out: l
} : m);
var p, o, j, d;
var h = function (f) {
p = f.pageX;
o = f.pageY
};
var c = function (g, f) {
f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
if ((Math.abs(j - p) + Math.abs(d - o)) < n.sensitivity) {
a(f).unbind("mousemove", h);
f.hoverIntent_s = 1;
return n.over.apply(f, [g])
} else {
j = p;
d = o;
f.hoverIntent_t = setTimeout(function () {
c(g, f)
}, n.interval)
}
};
var k = function (g, f) {
f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
f.hoverIntent_s = 0;
return n.out.apply(f, [g])
};
var b = function (q) {
var g = jQuery.extend({}, q);
var f = this;
if (f.hoverIntent_t) {
f.hoverIntent_t = clearTimeout(f.hoverIntent_t)
}
if (q.type == "mouseenter") {
j = g.pageX;
d = g.pageY;
a(f).bind("mousemove", h);
if (f.hoverIntent_s != 1) {
f.hoverIntent_t = setTimeout(function () {
c(g, f)
}, n.interval)
}
} else {
a(f).unbind("mousemove", h);
if (f.hoverIntent_s == 1) {
f.hoverIntent_t = setTimeout(function () {
k(g, f)
}, n.timeout)
}
}
};
return this.bind("mouseenter", b).bind("mouseleave", b)
}
})(jQuery);
(function (a) {
a.fn.navDropdown = function (j) {
var d = {
leftBox: ".primary",
rightBox: ".secondary",
activeClass: "active",
parentTabClass: ".nav-tab"
};
var h, f, b;
var c = {
init: function (k) {
return this.each(function () {
if (k) {
a.extend(d, k)
}
h = a(this);
f = h.find(d.leftBox);
b = h.find(d.rightBox);
f.find("li").bind("mouseover", g.showRightContent);
a(d.parentTabClass).bind("mouseenter", g.resetView);
g.resetView
})
}
};
var g = {
showRightContent: function () {
var l = a(this);
var k = l.data("flip");
b.hide().filter('[data-flip="' + k + '"]').show();
f.find("li").removeClass(d.activeClass).filter(l).addClass(d.activeClass)
},
resetView: function () {
b.hide().eq(0).show();
f.find("li").removeClass(d.activeClass).eq(0).addClass(d.activeClass)
}
};
if (c[j] && j.toLowerCase() != "init") {
return c[j].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof j === "object" || !j) {
return c.init.apply(this, arguments)
} else {
$.error('Method "' + j + '" does not exist in the Nav Dropdown plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.textResizer = function (f) {
var d;
var b = {
init: function () {
return this.each(function () {
d = a(this);
c.resizeText()
})
}
};
var c = {
resizeText: function () {
d.wrapInner(a("<div />"));
var h = d.find("div").eq(0);
var g = d.height();
while (h.height() > g) {
h.css("font-size", "-=1").delay(1)
}
if (g > h.height()) {
d.height(h.height())
}
}
};
if (b[f] && f.toLowerCase() != "init") {
return b[f].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof f === "object" || !f) {
return b.init.apply(this, arguments)
} else {
$.error('Method "' + f + '" does not exist in the Text Resizer plugin!')
}
}
}
})(jQuery);
(function (a) {
a.fn.stickyMenu = function (b) {
var o = {
stopElement: ".stop",
topBuffer: 100,
jumpLinks: true,
sections: ".section",
scrollSpeed: 400,
isMenu: true,
scrollable: true,
showPosition: false,
linksPerMenuPage: 8,
extraScrollPadding: 0
};
var c, j, m, l, f, l, n, k, h;
var g = {
init: function (p) {
return this.each(function () {
if (p) {
a.extend(o, p)
}
c = a(this);
m = c.offset().top - o.topBuffer;
if (o.isMenu) {
j = a(o.stopElement);
f = c.height() + o.topBuffer;
l = j.offset().top;
n = l - f;
a(window).bind("scroll", d.scrollCheck);
if (o.jumpLinks) {
c.find("#jump-links li a").bind("click", d.smoothScroll)
}
if (c.find("#jump-links li").length > o.linksPerMenuPage && o.scrollable == true) {
d.scrollableMenuInit();
c.find(".menu-control").bind("click", d.scrollMenu)
} else {
c.find(".menu-control").hide();
c.find(".pane").height(c.find("#jump-links").height())
}
} else {
if ((navigator.platform.indexOf("iPhone") === -1) && (navigator.platform.indexOf("iPod") === -1)) {
h = a("#compare-table-fixed-buffer");
h.height(c.height());
m = c.offset().top - o.topBuffer;
c.data("drawer-height", 0);
a(window).bind("scroll", d.tableScrollCheck)
}
}
})
}
};
var d = {
scrollCheck: function () {
var p = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
f = c.height() + o.topBuffer;
l = j.offset().top;
n = l - f;
if (p >= m) {
c.addClass("fixed");
if (p > n) {
newBuffer = o.topBuffer - (p - n);
c.css("top", newBuffer)
} else {
c.css("top", o.topBuffer)
}
if (o.showPosition) {
d.positionCheck(p)
}
} else {
c.removeClass("fixed").css("top", "auto")
}
},
positionCheck: function (p) {
lastElementPos = a(o.sections).last().offset().top - (o.extraScrollPadding + 1);
idx = 0;
a(o.sections).each(function (q, r) {
elementPosition = a(this).offset().top - (o.extraScrollPadding + 1);
if (p > elementPosition) {
idx = q
}
});
if (!c.find("li:eq(" + idx + ")").hasClass("selected")) {
c.find("li.selected").removeClass("selected");
c.find("li:eq(" + idx + ")").addClass("selected")
}
},
tableScrollCheck: function () {
var p = a("#product_compare_search_results").outerHeight();
if (c.data("drawer-height") !== p) {
drawerData = (typeof c.data("drawer-height") == "undefined") ? 0 : c.data("drawer-height");
m = (m + p) - drawerData;
c.data("drawer-height", p)
}
var q = (window.scrollY) ? window.scrollY : document.documentElement.scrollTop;
if (q >= m) {
c.addClass("fixed");
h.show()
} else {
c.removeClass("fixed");
h.hide()
}
},
smoothScroll: function () {
var p = c.find("li a").index(a(this));
var q = a(o.sections).eq(p).offset().top;
if (!o.showPosition) {
c.find("li.selected").removeClass("selected");
a(this).parent().addClass("selected")
}
a("html,body").animate({
scrollTop: q - o.extraScrollPadding
}, o.scrollSpeed);
return false
},
scrollableMenuInit: function () {
var p = 0;
var u = c.find("#jump-links li").length;
for (i = 0; i < o.linksPerMenuPage; i++) {
p += c.find("#jump-links li").eq(i).height()
}
c.find(".pane").height(p - 2);
var t = u % o.linksPerMenuPage;
var r = u / o.linksPerMenuPage;
var q = (t > 0) ? Math.ceil(r) : Math.floor(r);
c.data("page", {
on: 1,
count: q
});
d.activateMenuButtons()
},
scrollMenu: function () {
var r = a(this);
if (r.hasClass("active") && !r.data("freeze")) {
r.data("freeze", true);
var q = c.find("#jump-links");
var u = c.find(".pane").eq(0);
var t = r.hasClass("menu-down") ? o.linksPerMenuPage * c.data("page").on : o.linksPerMenuPage * (c.data("page").on - 2);
var p = q.find("li").eq(t).position().top * -1;
q.animate({
top: p
}, 400, "easeInQuad", function () {
var w = c.data("page").on;
var v = (r.hasClass("menu-down")) ? w + 1 : w - 1;
c.data("page").on = v;
d.activateMenuButtons();
d.resizeMenuPane();
r.removeData("freeze")
})
}
return false
},
resizeMenuPane: function () {
var p = 0;
var q = o.linksPerMenuPage * (c.data("page").on - 1);
var r = o.linksPerMenuPage * c.data("page").on;
for (i = q; i < r; i++) {
p += c.find("#jump-links li").eq(i).height()
}
c.find(".pane").height(p - 1)
},
activateMenuButtons: function () {
var q = c.data("page");
var r = c.find(".menu-up");
var p = c.find(".menu-down");
q.count > q.on ? p.addClass("active") : p.removeClass("active");
q.on > 1 ? r.addClass("active") : r.removeClass("active")
}
};
if (g[b] && b.toLowerCase() != "init") {
return g[b].apply(this, Array.prototype.slice.call(arguments, 1))
} else {
if (typeof b === "object" || !b) {
return g.init.apply(this, arguments)
} else {
$.error('Method "' + b + '" does not exist in the Sticky Menu plugin!')
}
}
}
})(jQuery);
function tortyPlayer(d, a) {
var b = d.attr("src");
var c = d.attr("id");
d.after('<div id="' + c + '-flash"></div>');
d.remove();
$f(c + "-flash", a.swfPlayer, {
plugins: {
controls: {
url: a.swfControl,
fullscreen: false,
height: 30,
autoHide: false
},
audio: {
url: a.swfAudio
}
},
clip: {
url: b,
autoPlay: false,
onBeforeBegin: function () {
$f("player").close()
}
}
})
}(function () {
function w(a) {
console.log("$f.fireEvent", [].slice.call(a))
}
function r(a) {
if (!a || typeof a != "object") {
return a
}
var c = new a.constructor();
for (var b in a) {
if (a.hasOwnProperty(b)) {
c[b] = r(a[b])
}
}
return c
}
function p(a, d) {
if (!a) {
return
}
var g, f = 0,
c = a.length;
if (c === undefined) {
for (g in a) {
if (d.call(a[g], g, a[g]) === false) {
break
}
}
} else {
for (var b = a[0]; f < c && d.call(b, f, b) !== false; b = a[++f]) {}
}
return a
}
function A(a) {
return document.getElementById(a)
}
function u(a, b, c) {
if (typeof b != "object") {
return a
}
if (a && b) {
p(b, function (f, d) {
if (!c || typeof d != "function") {
a[f] = d
}
})
}
return a
}
function o(a) {
var c = a.indexOf(".");
if (c != -1) {
var d = a.slice(0, c) || "*";
var f = a.slice(c + 1, a.length);
var b = [];
p(document.getElementsByTagName(d), function () {
if (this.className && this.className.indexOf(f) != -1) {
b.push(this)
}
});
return b
}
}
function x(a) {
a = a || window.event;
if (a.preventDefault) {
a.stopPropagation();
a.preventDefault()
} else {
a.returnValue = false;
a.cancelBubble = true
}
return false
}
function t(a, c, b) {
a[c] = a[c] || [];
a[c].push(b)
}
function y() {
return "_" + ("" + Math.random()).slice(2, 10)
}
var v = function (b, d, c) {
var f = this,
g = {},
a = {};
f.index = d;
if (typeof b == "string") {
b = {
url: b
}
}
u(this, b, true);
p(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","), function () {
var k = "on" + this;
if (k.indexOf("*") != -1) {
k = k.slice(0, k.length - 1);
var j = "onBefore" + k.slice(2);
f[j] = function (l) {
t(a, j, l);
return f
}
}
f[k] = function (l) {
t(a, k, l);
return f
};
if (d == -1) {
if (f[j]) {
c[j] = f[j]
}
if (f[k]) {
c[k] = f[k]
}
}
});
u(this, {
onCuepoint: function (j, k) {
if (arguments.length == 1) {
g.embedded = [null, j];
return f
}
if (typeof j == "number") {
j = [j]
}
var l = y();
g[l] = [j, k];
if (c.isLoaded()) {
c._api().fp_addCuepoints(j, d, l)
}
return f
},
update: function (k) {
u(f, k);
if (c.isLoaded()) {
c._api().fp_updateClip(k, d)
}
var l = c.getConfig();
var j = (d == -1) ? l.clip : l.playlist[d];
u(j, k, true)
},
_fireEvent: function (m, D, l, k) {
if (m == "onLoad") {
p(g, function (F, E) {
if (E[0]) {
c._api().fp_addCuepoints(E[0], d, F)
}
});
return false
}
k = k || f;
if (m == "onCuepoint") {
var n = g[D];
if (n) {
return n[1].call(c, k, l)
}
}
if (D && "onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(m) != -1) {
u(k, D);
if (D.metaData) {
if (!k.duration) {
k.duration = D.metaData.duration
} else {
k.fullDuration = D.metaData.duration
}
}
}
var j = true;
p(a[m], function () {
j = this.call(c, k, D, l)
});
return j
}
});
if (b.onCuepoint) {
var h = b.onCuepoint;
f.onCuepoint.apply(f, typeof h == "function" ? [h] : h);
delete b.onCuepoint
}
p(b, function (k, j) {
if (typeof j == "function") {
t(a, k, j);
delete b[k]
}
});
if (d == -1) {
c.onCuepoint = this.onCuepoint
}
};
var q = function (g, d, f, b) {
var h = this,
c = {},
a = false;
if (b) {
u(c, b)
}
p(d, function (k, j) {
if (typeof j == "function") {
c[k] = j;
delete d[k]
}
});
u(this, {
animate: function (n, m, j) {
if (!n) {
return h
}
if (typeof m == "function") {
j = m;
m = 500
}
if (typeof n == "string") {
var k = n;
n = {};
n[k] = m;
m = 500
}
if (j) {
var l = y();
c[l] = j
}
if (m === undefined) {
m = 500
}
d = f._api().fp_animate(g, n, m, l);
return h
},
css: function (k, j) {
if (j !== undefined) {
var l = {};
l[k] = j;
k = l
}
d = f._api().fp_css(g, k);
u(h, d);
return h
},
show: function () {
this.display = "block";
f._api().fp_showPlugin(g);
return h
},
hide: function () {
this.display = "none";
f._api().fp_hidePlugin(g);
return h
},
toggle: function () {
this.display = f._api().fp_togglePlugin(g);
return h
},
fadeTo: function (m, j, k) {
if (typeof j == "function") {
k = j;
j = 500
}
if (k) {
var l = y();
c[l] = k
}
this.display = f._api().fp_fadeTo(g, m, j, l);
this.opacity = m;
return h
},
fadeIn: function (j, k) {
return h.fadeTo(1, j, k)
},
fadeOut: function (j, k) {
return h.fadeTo(0, j, k)
},
getName: function () {
return g
},
getPlayer: function () {
return f
},
_fireEvent: function (l, m, k) {
if (l == "onUpdate") {
var n = f._api().fp_getPlugin(g);
if (!n) {
return
}
u(h, n);
delete h.methods;
if (!a) {
p(n.methods, function () {
var E = "" + this;
h[E] = function () {
var G = [].slice.call(arguments);
var F = f._api().fp_invoke(g, E, G);
return F === "undefined" || F === undefined ? h : F
}
});
a = true
}
}
var j = c[l];
if (j) {
var D = j.apply(h, m);
if (l.slice(0, 1) == "_") {
delete c[l]
}
return D
}
return h
}
})
};
function B(K, f, l) {
var d = this,
g = null,
n = false,
j, m, h = [],
b = {},
c = {},
k, I, M, H, N, L;
u(d, {
id: function () {
return k
},
isLoaded: function () {
return (g !== null && g.fp_play !== undefined && !n)
},
getParent: function () {
return K
},
hide: function (D) {
if (D) {
K.style.height = "0px"
}
if (d.isLoaded()) {
g.style.height = "0px"
}
return d
},
show: function () {
K.style.height = L + "px";
if (d.isLoaded()) {
g.style.height = N + "px"
}
return d
},
isHidden: function () {
return d.isLoaded() && parseInt(g.style.height, 10) === 0
},
load: function (D) {
if (!d.isLoaded() && d._fireEvent("onBeforeLoad") !== false) {
var F = function () {
j = K.innerHTML;
if (j && !flashembed.isSupported(f.version)) {
K.innerHTML = ""
}
if (D) {
D.cached = true;
t(c, "onLoad", D)
}
flashembed(K, f, {
config: l
})
};
var E = 0;
p(C, function () {
this.unload(function (G) {
if (++E == C.length) {
F()
}
})
})
}
return d
},
unload: function (D) {
if (this.isFullscreen() && /WebKit/i.test(navigator.userAgent)) {
if (D) {
D(false)
}
return d
}
if (j.replace(/\s/g, "") !== "") {
if (d._fireEvent("onBeforeUnload") === false) {
if (D) {
D(false)
}
return d
}
n = true;
try {
if (g) {
g.fp_close();
d._fireEvent("onUnload")
}
} catch (F) {}
var E = function () {
g = null;
K.innerHTML = j;
n = false;
if (D) {
D(true)
}
};
setTimeout(E, 50)
} else {
if (D) {
D(false)
}
}
return d
},
getClip: function (D) {
if (D === undefined) {
D = H
}
return h[D]
},
getCommonClip: function () {
return m
},
getPlaylist: function () {
return h
},
getPlugin: function (F) {
var D = b[F];
if (!D && d.isLoaded()) {
var E = d._api().fp_getPlugin(F);
if (E) {
D = new q(F, E, d);
b[F] = D
}
}
return D
},
getScreen: function () {
return d.getPlugin("screen")
},
getControls: function () {
return d.getPlugin("controls")._fireEvent("onUpdate")
},
getLogo: function () {
try {
return d.getPlugin("logo")._fireEvent("onUpdate")
} catch (D) {}
},
getPlay: function () {
return d.getPlugin("play")._fireEvent("onUpdate")
},
getConfig: function (D) {
return D ? r(l) : l
},
getFlashParams: function () {
return f
},
loadPlugin: function (E, F, Q, D) {
if (typeof Q == "function") {
D = Q;
Q = {}
}
var G = D ? y() : "_";
d._api().fp_loadPlugin(E, F, Q, G);
var O = {};
O[G] = D;
var P = new q(E, null, d, O);
b[E] = P;
return P
},
getState: function () {
return d.isLoaded() ? g.fp_getState() : -1
},
play: function (E, F) {
var D = function () {
if (E !== undefined) {
d._api().fp_play(E, F)
} else {
d._api().fp_play()
}
};
if (d.isLoaded()) {
D()
} else {
if (n) {
setTimeout(function () {
d.play(E, F)
}, 50)
} else {
d.load(function () {
D()
})
}
}
return d
},
getVersion: function () {
var D = "flowplayer.js 3.2.6";
if (d.isLoaded()) {
var E = g.fp_getVersion();
E.push(D);
return E
}
return D
},
_api: function () {
if (!d.isLoaded()) {
throw "Flowplayer " + d.id() + " not loaded when calling an API method"
}
return g
},
setClip: function (D) {
d.setPlaylist([D]);
return d
},
getIndex: function () {
return M
},
_swfHeight: function () {
return g.clientHeight
}
});
p(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","), function () {
var E = "on" + this;
if (E.indexOf("*") != -1) {
E = E.slice(0, E.length - 1);
var D = "onBefore" + E.slice(2);
d[D] = function (F) {
t(c, D, F);
return d
}
}
d[E] = function (F) {
t(c, E, F);
return d
}
});
p(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","), function () {
var D = this;
d[D] = function (F, G) {
if (!d.isLoaded()) {
return d
}
var E = null;
if (F !== undefined && G !== undefined) {
E = g["fp_" + D](F, G)
} else {
E = (F === undefined) ? g["fp_" + D]() : g["fp_" + D](F)
}
return E === "undefined" || E === undefined ? d : E
}
});
d._fireEvent = function (E) {
if (typeof E == "string") {
E = [E]
}
var D = E[0],
G = E[1],
T = E[2],
U = E[3],
V = 0;
if (l.debug) {
w(E)
}
if (!d.isLoaded() && D == "onLoad" && G == "player") {
g = g || A(I);
N = d._swfHeight();
p(h, function () {
this._fireEvent("onLoad")
});
p(b, function (P, O) {
O._fireEvent("onUpdate")
});
m._fireEvent("onLoad")
}
if (D == "onLoad" && G != "player") {
return
}
if (D == "onError") {
if (typeof G == "string" || (typeof G == "number" && typeof T == "number")) {
G = T;
T = U
}
}
if (D == "onContextMenu") {
p(l.contextMenu[G], function (P, O) {
O.call(d)
});
return
}
if (D == "onPluginEvent" || D == "onBeforePluginEvent") {
var Y = G.name || G;
var X = b[Y];
if (X) {
X._fireEvent("onUpdate", G);
return X._fireEvent(T, E.slice(3))
}
return
}
if (D == "onPlaylistReplace") {
h = [];
var S = 0;
p(G, function () {
h.push(new v(this, S++, d))
})
}
if (D == "onClipAdd") {
if (G.isInStream) {
return
}
G = new v(G, T, d);
h.splice(T, 0, G);
for (V = T + 1; V < h.length; V++) {
h[V].index++
}
}
var F = true;
if (typeof G == "number" && G < h.length) {
H = G;
var W = h[G];
if (W) {
F = W._fireEvent(D, T, U)
}
if (!W || F !== false) {
F = m._fireEvent(D, T, U, W)
}
}
p(c[D], function () {
F = this.call(d, G, T);
if (this.cached) {
c[D].splice(V, 1)
}
if (F === false) {
return false
}
V++
});
return F
};
function J() {
if ($f(K)) {
$f(K).getParent().innerHTML = "";
M = $f(K).getIndex();
C[M] = d
} else {
C.push(d);
M = C.length - 1
}
L = parseInt(K.style.height, 10) || K.clientHeight;
k = K.id || "fp" + y();
I = f.id || k + "_api";
f.id = I;
l.playerId = k;
if (typeof l == "string") {
l = {
clip: {
url: l
}
}
}
if (typeof l.clip == "string") {
l.clip = {
url: l.clip
}
}
l.clip = l.clip || {};
if (K.getAttribute("href", 2) && !l.clip.url) {
l.clip.url = K.getAttribute("href", 2)
}
m = new v(l.clip, -1, d);
l.playlist = l.playlist || [l.clip];
var E = 0;
p(l.playlist, function () {
var G = this;
if (typeof G == "object" && G.length) {
G = {
url: "" + G
}
}
p(l.clip, function (O, P) {
if (P !== undefined && G[O] === undefined && typeof P != "function") {
G[O] = P
}
});
l.playlist[E] = G;
G = new v(G, E, d);
h.push(G);
E++
});
p(l, function (O, G) {
if (typeof G == "function") {
if (m[O]) {
m[O](G)
} else {
t(c, O, G)
}
delete l[O]
}
});
p(l.plugins, function (O, G) {
if (G) {
b[O] = new q(O, G, d)
}
});
if (!l.plugins || l.plugins.controls === undefined) {
b.controls = new q("controls", null, d)
}
b.canvas = new q("canvas", null, d);
j = K.innerHTML;
function D(G) {
var O = d.hasiPadSupport && d.hasiPadSupport();
if (/iPad|iPhone|iPod/i.test(navigator.userAgent) && !/.flv$/i.test(h[0].url) && !O) {
return true
}
if (!d.isLoaded() && d._fireEvent("onBeforeClick") !== false) {
d.load()
}
return x(G)
}
function F() {
if (j.replace(/\s/g, "") !== "") {
if (K.addEventListener) {
K.addEventListener("click", D, false)
} else {
if (K.attachEvent) {
K.attachEvent("onclick", D)
}
}
} else {
if (K.addEventListener) {
K.addEventListener("click", x, false)
}
d.load()
}
}
setTimeout(F, 0)
}
if (typeof K == "string") {
var a = A(K);
if (!a) {
throw "Flowplayer cannot access element: " + K
}
K = a;
J()
} else {
J()
}
}
var C = [];
function z(a) {
this.length = a.length;
this.each = function (b) {
p(a, b)
};
this.size = function () {
return a.length
}
}
window.flowplayer = window.$f = function () {
var f = null;
var g = arguments[0];
if (!arguments.length) {
p(C, function () {
if (this.isLoaded()) {
f = this;
return false
}
});
return f || C[0]
}
if (arguments.length == 1) {
if (typeof g == "number") {
return C[g]
} else {
if (g == "*") {
return new z(C)
}
p(C, function () {
if (this.id() == g.id || this.id() == g || this.getParent() == g) {
f = this;
return false
}
});
return f
}
}
if (arguments.length > 1) {
var a = arguments[1],
d = (arguments.length == 3) ? arguments[2] : {};
if (typeof a == "string") {
a = {
src: a
}
}
a = u({
bgcolor: "#000000",
version: [9, 0],
expressInstall: "http://static.flowplayer.org/swf/expressinstall.swf",
cachebusting: false
}, a);
if (typeof g == "string") {
if (g.indexOf(".") != -1) {
var b = [];
p(o(g), function () {
b.push(new B(this, r(a), r(d)))
});
return new z(b)
} else {
var c = A(g);
return new B(c !== null ? c : g, a, d)
}
} else {
if (g) {
return new B(g, a, d)
}
}
}
return null
};
u(window.$f, {
fireEvent: function () {
var b = [].slice.call(arguments);
var a = $f(b[0]);
return a ? a._fireEvent(b.slice(1)) : null
},
addPlugin: function (b, a) {
B.prototype[b] = a;
return $f
},
each: p,
extend: u
});
if (typeof jQuery == "function") {
jQuery.fn.flowplayer = function (a, b) {
if (!arguments.length || typeof arguments[0] == "number") {
var c = [];
this.each(function () {
var d = $f(this);
if (d) {
c.push(d)
}
});
return arguments.length ? c[arguments[0]] : new z(c)
}
return this.each(function () {
$f(this, r(a), b ? r(b) : {})
})
}
}
})();
(function () {
var p = typeof jQuery == "function";
var l = {
width: "100%",
height: "100%",
allowfullscreen: true,
allowscriptaccess: "always",
quality: "high",
version: null,
onFail: null,
expressInstall: null,
w3c: false,
cachebusting: false
};
if (p) {
jQuery.tools = jQuery.tools || {};
jQuery.tools.flashembed = {
version: "1.0.4",
conf: l
}
}
function k() {
if (r.done) {
return false
}
var a = document;
if (a && a.getElementsByTagName && a.getElementById && a.body) {
clearInterval(r.timer);
r.timer = null;
for (var b = 0; b < r.ready.length; b++) {
r.ready[b].call()
}
r.ready = null;
r.done = true
}
}
var r = p ? jQuery : function (a) {
if (r.done) {
return a()
}
if (r.timer) {
r.ready.push(a)
} else {
r.ready = [a];
r.timer = setInterval(k, 13)
}
};
function o(a, b) {
if (b) {
for (key in b) {
if (b.hasOwnProperty(key)) {
a[key] = b[key]
}
}
}
return a
}
function n(c) {
switch (m(c)) {
case "string":
c = c.replace(new RegExp('(["\\\\])', "g"), "\\$1");
c = c.replace(/^\s?(\d+)%/, "$1pct");
return '"' + c + '"';
case "array":
return "[" + t(c, function (d) {
return n(d)
}).join(",") + "]";
case "function":
return '"function()"';
case "object":
var b = [];
for (var a in c) {
if (c.hasOwnProperty(a)) {
b.push('"' + a + '":' + n(c[a]))
}
}
return "{" + b.join(",") + "}"
}
return String(c).replace(/\s/g, " ").replace(/\'/g, '"')
}
function m(a) {
if (a === null || a === undefined) {
return false
}
var b = typeof a;
return (b == "object" && a.push) ? "array" : b
}
if (window.attachEvent) {
window.attachEvent("onbeforeunload", function () {
__flash_unloadHandler = function () {};
__flash_savedUnloadHandler = function () {}
})
}
function t(c, d) {
var a = [];
for (var b in c) {
if (c.hasOwnProperty(b)) {
a[b] = d(c[b])
}
}
return a
}
function u(f, c) {
var g = o({}, f);
var d = document.all;
var j = '<object width="' + g.width + '" height="' + g.height + '"';
if (d && !g.id) {
g.id = "_" + ("" + Math.random()).substring(9)
}
if (g.id) {
j += ' id="' + g.id + '"'
}
if (g.cachebusting) {
g.src += ((g.src.indexOf("?") != -1 ? "&" : "?") + Math.random())
}
if (g.w3c || !d) {
j += ' data="' + g.src + '" type="application/x-shockwave-flash"'
} else {
j += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
}
j += ">";
if (g.w3c || d) {
j += '<param name="movie" value="' + g.src + '" />'
}
g.width = g.height = g.id = g.w3c = g.src = null;
for (var b in g) {
if (g[b] !== null) {
j += '<param name="' + b + '" value="' + g[b] + '" />'
}
}
var h = "";
if (c) {
for (var a in c) {
if (c[a] !== null) {
h += a + "=" + (typeof c[a] == "object" ? n(c[a]) : c[a]) + "&"
}
}
h = h.substring(0, h.length - 1);
j += '<param name="flashvars" value=\'' + h + "' />"
}
j += "</object>";
return j
}
function q(a, g, b) {
var c = flashembed.getVersion();
o(this, {
getContainer: function () {
return a
},
getConf: function () {
return g
},
getVersion: function () {
return c
},
getFlashvars: function () {
return b
},
getApi: function () {
return a.firstChild
},
getHTML: function () {
return u(g, b)
}
});
var f = g.version;
var d = g.expressInstall;
var h = !f || flashembed.isSupported(f);
if (h) {
g.onFail = g.version = g.expressInstall = null;
a.innerHTML = u(g, b)
} else {
if (f && d && flashembed.isSupported([6, 65])) {
o(g, {
src: d
});
b = {
MMredirectURL: location.href,
MMplayerType: "PlugIn",
MMdoctitle: document.title
};
a.innerHTML = u(g, b)
} else {
if (a.innerHTML.replace(/\s/g, "") !== "") {} else {
a.innerHTML = "<h2>Flash version " + f + " or greater is required</h2><h3>" + (c[0] > 0 ? "Your version is " + c : "You have no flash plugin installed") + "</h3>" + (a.tagName == "A" ? "<p>Click here to download latest version</p>" : "<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");
if (a.tagName == "A") {
a.onclick = function () {
location.href = "http://www.adobe.com/go/getflashplayer"
}
}
}
}
}
if (!h && g.onFail) {
var j = g.onFail.call(this);
if (typeof j == "string") {
a.innerHTML = j
}
}
if (document.all) {
window[g.id] = document.getElementById(g.id)
}
}
window.flashembed = function (b, a, c) {
if (typeof b == "string") {
var f = document.getElementById(b);
if (f) {
b = f
} else {
r(function () {
flashembed(b, a, c)
});
return
}
}
if (!b) {
return
}
if (typeof a == "string") {
a = {
src: a
}
}
var d = o({}, l);
o(d, a);
return new q(b, d, c)
};
o(window.flashembed, {
getVersion: function () {
var a = [0, 0];
if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
var b = navigator.plugins["Shockwave Flash"].description;
if (typeof b != "undefined") {
b = b.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
var j = parseInt(b.replace(/^(.*)\..*$/, "$1"), 10);
var d = /r/.test(b) ? parseInt(b.replace(/^.*r(.*)$/, "$1"), 10) : 0;
a = [j, d]
}
} else {
if (window.ActiveXObject) {
try {
var g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
} catch (f) {
try {
g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
a = [6, 0];
g.AllowScriptAccess = "always"
} catch (c) {
if (a[0] == 6) {
return a
}
}
try {
g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
} catch (h) {}
}
if (typeof g == "object") {
b = g.GetVariable("$version");
if (typeof b != "undefined") {
b = b.replace(/^\S+\s+(.*)$/, "$1").split(",");
a = [parseInt(b[0], 10), parseInt(b[2], 10)]
}
}
}
}
return a
},
isSupported: function (c) {
var a = flashembed.getVersion();
var b = (a[0] > c[0]) || (a[0] == c[0] && a[1] >= c[1]);
return b
},
domReady: r,
asString: n,
getHTML: u
});
if (p) {
jQuery.fn.flashembed = function (b, c) {
var a = null;
this.each(function () {
a = flashembed(this, b, c)
});
return b.api === false ? this : a
}
}
})();
(function (c) {
var a = window.vCookieConfig = {
prefix: "verge_",
path: "/"
};
var b = window.vCookie = {};
b.write = function (f, h, g) {
if (!g || !g.path) {
var g = typeof g == "undefined" ? new Object() : g;
g.path = a.path
}
f = f ? a.prefix + f : null;
f && h ? c.cookie(f, h, g) : d("You must specify name and data for vCookie.write()")
};
b.write.value = function (f, h, k, j) {
if (!j || !j.path) {
var j = typeof j == "undefined" ? new Object() : j;
j.path = a.path
}
f = f ? a.prefix + f : null;
if (f && h && typeof k !== "undefined") {
var g = c.cookie(f) ? c.evalJSON(c.cookie(f)) : new Object();
g[h] = k;
c.cookie(f, c.toJSON(g), j)
} else {
d("You must specify name, key, and value for vCookie.write.value()")
}
};
b.read = function (f) {
f = f ? a.prefix + f : null;
if (f) {
return c.cookie(f) ? c.cookie(f) : false
} else {
d("You must specify name for vCookie.read()")
}
};
b.read.value = function (f, g) {
f = f ? a.prefix + f : null;
g = g || false;
if (f && g) {
if (c.cookie(f)) {
cookie = c.evalJSON(c.cookie(f));
return cookie[g]
} else {
return false
}
} else {
d("You must specify name for vCookie.read.value()")
}
};
b.destroy = function (f, g) {
g = g || a.path;
f ? c.cookie(f, null, {
path: g
}) : d("You must specify name and data for vCookie.destroy()")
};
function d(f) {
console.error("TRUBBA: " + f)
}
}(jQuery));
$j(document).ready(function () {
$j("[data-scrollPanize]").each(function () {
$j(this).scrollPane($j(this).data("data-scrollPanize"))
});
$j("[data-gallerize]").each(function () {
$j(this).gallerize($j(this).data("gallerize"))
});
$j("[data-great-toggler]").each(function () {
$j(this).greatToggler()
});
$j("[data-tabinate]").each(function () {
$j(this).tabinate($j(this).data("tabinate"))
});
$j("[data-text-resizer]").each(function () {
$j(this).textResizer()
});
$j("[data-sticky-menu]").each(function () {
$j(this).stickyMenu($j(this).data("sticky-menu"))
});
$j("[data-inputate]").each(function () {
$j(this).inputate()
});
$j("[data-nav-dropdown]").each(function () {
$j(this).navDropdown()
});
$j("#network-bar").networkBar();
$j("[data-selection-group]").each(function () {
var l = $j(this);
var k = l.children();
k.each(function () {
var m = $j(this);
m.bind("click", function () {
k.removeClass("selected");
m.addClass("selected")
})
})
});
if ($j("audio#torty-player").length) {
var f = document.createElement("audio");
if (!( !! (f.canPlayType) && ("no" != f.canPlayType("audio/mpeg")) && ("" != f.canPlayType("audio/mpeg")))) {
tortyPlayer($j("#torty-player"), {
swfPlayer: "http://cdn0.sbnation.com/podcasts/flowplayer-3.2.7.swf",
swfControl: "http://cdn0.sbnation.com/podcasts/flowplayer.controls-3.2.5.swf",
swfAudio: "http://cdn0.sbnation.com/podcasts/flowplayer.audio-3.2.2.swf"
})
}
}
$j("#reviews-index-sort-field").change(function (k) {
window.location.href = $j(this).val()
});
$j("#user-reviews-sort select").change(function (k) {
window.location.href = $j(this).val()
});
$j("#user-reviews .user-review-content .toggler").click(function (m) {
m.stopPropagation();
m.preventDefault();
var l = $j(this);
var k = l.closest(".user-review-content");
if (k.hasClass("closed")) {
k.removeClass("closed");
l.find("span").html("Hide")
} else {
k.addClass("closed");
l.find("span").html("Show")
}
});
$j.each(["product-news", "product-discussion"], function (k, l) {
$j("#verge-product-details ." + l + "-link").bind("click", function (o) {
var m = $j("body");
var n = $j("#verge-product-details");
m.animate({
scrollTop: (n.offset().top - m.offset().top - 50)
}, "fast");
$j("#verge-product-details ." + l + "-tab-link").trigger("click");
return false
})
});
if ($j("#ces-schedule").length) {
var a = new Date(2012, 0, 8);
var d = new Date();
var c = 1000 * 60 * 60 * 24;
var g = Math.floor((d - a) / c);
$j("#ces-schedule .pagination a").eq(g).trigger("click")
}
if ($j("iframe[src^='http://www.youtube.com']").length) {
$j("iframe[src^='http://www.youtube.com']").each(function () {
var k = $j(this).attr("src");
$j(this).attr("src", k + "?wmode=transparent")
})
}
if ($j(".video-snippet1").length) {
$j(".video-snippet1").each(function () {
$j(this).find(".video-thumbs img").eq(0).addClass("active");
$j(this).find(".main-video embed, .main-video iframe").each(function () {
$j(this).addClass("snippet-video")
});
$j(this).find(".snippet-video").eq(0).addClass("active")
});
$j(".video-snippet1 .video-thumbs img").click(function () {
var l = $j(this).index(".video-snippet1 .video-thumbs img");
var k = $j(this).parents(".video-snippet1");
var n = k.find(".video-thumbs img");
var o = k.find(".main-video .snippet-video");
n.removeClass("active").eq(l).addClass("active");
var m = o.filter(".active");
var p = m.clone().removeClass("active").insertAfter(m);
m.remove();
o.eq(l).addClass("active")
})
}
if ($j(".feature-sticky-toc").length) {
$j("#sticky-menu").css("visibility", "visible");
$j("article.feature-entry").addClass("show-borders");
var j = $j("#sticky-menu #jump-links .clone").eq(0);
var b = $j("#sticky-menu #jump-links");
var h = $j("#sticky-menu .pane");
$j(".snippet").each(function () {
if ($j(this).find("h2").length) {
$j(this).addClass("count-me");
var k = $j(this).find("h2").text();
j.clone(true).find("a").text(k).end().removeClass("clone").insertBefore(j)
}
});
j.remove();
h.height(b.height())
}
if ($j("#comment-call-to-action").length) {
$j(window).bind("scroll.commentLazyLoad", function () {
VERGE.func.commentLazyLoad($j("#comment-call-to-action"))
})
}
});
$j(document).ready(function () {
$j("[data-adjustable-slider]").each(function () {
var b = function (f, d, c) {
f = Math.min(f, c);
f = Math.max(f, d);
return f
};
var a = function () {
var k = $j(this).closest("[data-adjustable-slider]");
var j = k.find(".slider-type").val();
var h = {
step: parseInt(k.data("step"), 10),
min: parseInt(k.data("min"), 10),
max: parseInt(k.data("max"), 10),
slide: function (n, o) {
var m = o.values[0];
var l = (o.values.length >= 2) ? o.values[1] : o.values[0];
$j(this).closest("[data-adjustable-slider]").find(".slider-fields .gt").val(m);
$j(this).closest("[data-adjustable-slider]").find(".slider-fields .lt").val(l)
}
};
var g = parseInt(k.find(".slider-fields .gt").val(), 10);
g = isNaN(g) ? h.min : b(g, h.min, h.max);
var d = parseInt(k.find(".slider-fields .lt").val(), 10);
d = isNaN(d) ? h.max : b(d, h.min, h.max);
k.find(".slider, .slider-fields").hide();
k.find(".slider").slider("destroy");
k.find(".slider-fields .gt").prop("disabled", true).hide();
k.find(".slider-fields .lt").prop("disabled", true).hide();
if (j == "gt") {
h.range = "min";
h.values = [g];
k.find(".slider").slider(h);
k.find(".slider, .slider-fields").show();
k.find(".slider-fields .gt").prop("disabled", false).show();
k.find(".slider-fields .lt").prop("disabled", true).hide()
}
if (j == "lt") {
h.range = "max";
h.values = [d];
k.find(".slider").slider(h);
k.find(".slider, .slider-fields").show();
k.find(".slider-fields .gt").prop("disabled", true).hide();
k.find(".slider-fields .lt").prop("disabled", false).show()
}
if (j == "range") {
if (g > d) {
var f = g;
var c = d;
g = c;
d = f
}
h.range = true;
h.values = [g, d];
k.find(".slider").slider(h);
k.find(".slider, .slider-fields").show();
k.find(".slider-fields .gt, .slider-fields .lt").prop("disabled", false).show()
}
k.find(".slider-fields .gt").val(g);
k.find(".slider-fields .lt").val(d)
};
$j(this).find(".slider-fields input").change(a);
$j(this).find(".slider-type").change(a);
$j(this).find(".slider-type").change()
})
});
$j(document).ready(function () {
$j("#compare-search-input").bind("keypress", function (a) {
if (a.keyCode == 13) {
$j("#compare-search-submit").trigger("click")
}
});
$j("#compare-search-submit").click(function () {
showSpinner();
if ($j("#product_compare_search_results").is(":visible")) {
closeDrawer()
}
});
$j("[data-compare]").live("click", function () {
addToCompareCookie($j(this).data("compare"), false);
return false
});
$j("#product_compare_search_results .product-grid-item, #compare-add .product-grid-item").live("click", function (a) {
addToCompareCookie($j(this).find(".compare-bug").eq(0).data("compare"), $j(this).data("product-id"));
return false
});
$j("#compare-list a .remove").live("click", function () {
removeFromCompareCookie($j(this).data("id"), false);
return false
});
$j(".compare-table #image-row .bug").click(function () {
removeFromCompareCookie($j(this).data("id"), $j(this).attr("href"));
return false
});
$j("#compare-jar #action-button").click(function () {
if (!$j(this).hasClass("ready")) {
openCompareBucket();
return false
}
});
$j("#compare-jar .ui-closer").live("click", function () {
closeCompareBucket();
return false
});
if ($j("#compare-list").length && $j.cookie("verge_compare")) {
buildCompareBucket()
}
if ($j.cookie("verge_compare")) {
flashIndicator(false)
}
$j("#compare-start-over, #clear-comparison-bucket").click(function () {
var a = "verge_compare";
if ($j(this).attr("id") == "compare-start-over" || onMyComparePage()) {
$j.cookie(a, null, {
path: "/"
});
window.location = "/products"
} else {
$j.cookie(a, null, {
path: "/"
});
flashIndicator(false);
setTimeout(buildCompareBucket(), 200)
}
return false
})
});
function onMyComparePage() {
var b = $j("#comparison-indicator");
var a = $j.cookie("verge_compare");
if (b.is(":visible") && a) {
return location.pathname == b.attr("href") ? true : false
} else {
return false
}
}
function addToCompareCookie(f, h) {
if (onMyComparePage() || h == false) {
var j = "verge_compare";
var d = $j.cookie(j);
if (!d) {
d = new Object();
d.id = new Object();
d.name = new Object();
d.image = new Object();
d.url = new Object();
d.template = f.template
} else {
d = $j.evalJSON(d)
}
var c = 1;
var g = false;
for (e in d.id) {
c++;
if (f.id == d.id[e]) {
g = true
}
}
var b = new Date().getTime();
if (c <= 6 && g == false) {
if (f.template == d.template) {
d.id[b] = f.id;
d.name[b] = f.name;
d.image[b] = f.image;
d.url[b] = f.url;
$j.cookie(j, $j.toJSON(d), {
path: "/"
});
if (!h) {
productFlash(f.id);
flashIndicator();
if ($j("#compare-jar").length) {
buildCompareBucket()
} else {
$j("#comparison-indicator em").text(c)
}
} else {
var a = window.location.pathname.split("/");
a.push(h);
window.location.pathname = a.join("/")
}
} else {
alert("You cannot compare apples to oranges. Please compare products within the same category")
}
} else {
if (c > 6) {
alert("You can only compare six products")
} else {
if (g == true) {
alert("You've already added that product to your comparison")
}
}
}
} else {
var a = window.location.pathname.split("/");
a.push(h);
window.location.pathname = a.join("/")
}
}
function removeFromCompareCookie(f, c) {
if (onMyComparePage() || c == false) {
var d = "verge_compare";
var b = $j.cookie(d);
b = $j.evalJSON(b);
if (c) {
for (e in b.id) {
f = (f == b.id[e]) ? e : f
}
}
delete b.id[f];
delete b.name[f];
delete b.image[f];
delete b.url[f];
var a = 0;
for (e in b.id) {
a++
}
if (a > 0) {
$j.cookie(d, $j.toJSON(b), {
path: "/"
});
if (!c) {
flashIndicator()
}
} else {
$j.cookie(d, null, {
path: "/"
});
flashIndicator()
}
if (!c) {
buildCompareBucket()
} else {
location.href = c
}
} else {
location.href = c
}
}
function buildCompareBucket() {
var d = "verge_compare";
var c = $j.cookie(d);
if (c) {
c = $j.evalJSON(c);
$j('[data-compare-template]:not([data-compare-template="' + c.template + '"])').hide();
var a = 0;
for (e in c.id) {
a++
}
$j("#compare-jar .ui-opener em").text(a);
a == 6 ? $j("#compare-list .empty").hide() : $j("#compare-list .empty").show();
$clone = $j("#compare-list .compare.product.clone");
$j("#compare-list .compare.product:not(.clone)").remove();
for (e in c.id) {
$product = $clone.clone().prependTo($j("#compare-list"));
$product.removeClass("clone");
$product.find("img").attr("src", c.image[e]);
$product.find(".cb-title").text(c.name[e]);
$product.find("a").attr("href", c.url[e]);
$product.find(".remove").data("id", e);
$product.show()
}
var b = new Array("/products/compare");
$j.map(c.id, function (g, f) {
b.push(g)
});
$j("#compare-jar #action-button").attr("href", b.join("/"))
} else {
$j("#compare-list .compare.product:not(.clone)").remove();
$j("#compare-jar #action-button").attr("href", "");
$j("#compare-jar #action-button").removeClass("ready");
$j("#compare-jar #action-button .compare em").empty();
$j("[data-compare-template]").show()
}
openCompareBucket()
}
function flashIndicator(a) {
if (typeof (a) === "undefined") {
a = true
}
var f = $j("#comparison-indicator");
var g = "verge_compare";
var d = $j.cookie(g);
d = $j.evalJSON(d);
if (d) {
var b = 0;
for (e in d.id) {
b++
}
f.find("em").text(b);
var c = new Array("/products/compare");
$j.map(d.id, function (j, h) {
c.push(j)
});
f.attr("href", c.join("/"));
if (!f.is(":visible")) {
showIndicator()
}
if (a) {
f.fadeOut(300, function () {
f.fadeIn(300)
})
}
} else {
if (f.is(":visible")) {
hideIndicator()
}
}
}
function productFlash(c) {
var b = $j('a[href="/products/compare/' + c + '"]').parents(".item");
b.append('<div class="added-product"><span>Added</span></div>');
var a = b.find(".added-product");
a.fadeIn(500).delay(1000).fadeOut(500, function () {
a.remove()
})
}
function openCompareBucket() {
if (!$j("#compare-jar #ui-compare-list-panel").is(":visible")) {
$j("#compare-jar #ui-compare-list-panel").slideDown(300)
}
if ($j("#compare-list .compare.product:not(.clone)").length) {
$j("#compare-jar #action-button").addClass("ready")
}
}
function closeCompareBucket() {
$j("#compare-jar #ui-compare-list-panel").slideUp(300);
$j("#compare-jar #action-button").removeClass("ready")
}
function showSpinner() {
$j("#compare-search-submit").css("backgroundColor", "#FFF");
$j("#search-box-spinner").show()
}
function hideSpinner() {
$j("#search-box-spinner").hide();
$j("#compare-search-submit").css("backgroundColor", "#FB4834")
}
function openDrawer() {
if ($j("#product_compare_search_results .product-grid li").length == 0) {
$j("#compare-nothing-found").show()
}
$j("#product_compare_search_results").slideDown(400)
}
function closeDrawer() {
$j("#product_compare_search_results").slideUp(400, function () {
if ($j("#compare-nothing-found").is(":visible")) {
$j("#compare-nothing-found").hide()
}
})
}
function showIndicator() {
var a = $j("#network-compare");
if (!a.is(":visible")) {
a.slideDown(400)
}
}
function hideIndicator() {
var a = $j("#network-compare");
if (a.is(":visible")) {
a.slideUp(400)
}
}
$j(function () {
var a = {};
$j(".form-storage").each(function () {
a[$j(this).prop("id")] = $j(this);
$j(this).remove()
});
$j("#contact-reason").change(function () {
var d = $j(this).val();
var g = $j(".contact-type-label");
var b = a[d];
var c = $j("#form-questions");
var f = "";
switch (d) {
case "tip":
f = "tip";
break;
case "broken":
f = "problem";
break;
case "question":
f = "question";
break;
case "suggest":
f = "suggestion";
break;
default:
f = "message";
break
}
if (c && b) {
c.empty().html(b.html())
}
if (g) {
g.html(f)
}
if (d == "tip") {
$j("#anonymous-checkbox").show()
} else {
$j("#anonymous-checkbox").hide()
}
if (d == "") {
$j(".form-questions-default").hide()
} else {
$j(".form-questions-default").show()
}
});
$j("#contact-reason").change()
});
SBN.Forums = {
toggleForumIndex: function () {
var b = $j("#forum-index-list");
var d = $j(".breaker-forum-list");
var a = $j("#forum-index-hide");
var c = $j("#forum-index-show");
if (SBN.Forums.showingIndex) {
b.hide();
a.hide();
c.show();
d.addClass("add-top-margin");
SBN.Forums.showingIndex = false
} else {
b.show();
a.show();
c.hide();
d.removeClass("add-top-margin");
SBN.Forums.showingIndex = true
}
},
showingIndex: true,
setup: function () {
$j("#forum-index-hide").click(function () {
SBN.Forums.toggleForumIndex()
});
$j("#forum-index-show").click(function () {
SBN.Forums.toggleForumIndex()
});
$j("#forum-index-show").hide()
}
};
$j(function () {
if ($j("#product-search-results").length) {
var b = $j("#product-search-results");
var c = $j("#product-search-sidebar");
var a = $j("#basic_search #q").val();
$j("#basic_search_query").val(a);
if (b.find("li").length) {
c.find("h1 em").text(a);
c.append(b.html());
c.show()
}
}
});
$j(document).ready(function () {
$j(".slider_input").each(function () {
var l = $j(this),
m = l.find('input[type="text"]'),
g = m.val() || null,
c = (g) ? Math.floor(g) : "",
b = $j("<div />"),
f = $j('<div class="slider_input_slider_heat_bar" />'),
a = $j('<span class="slider_input_value">' + c + "</span>");
l.append('<div class="slider_input_slider_bg" />');
l.append(f);
l.append(a);
a;
l.append(b);
var d = function () {
var n = $j(".slider_input.overall_score .ui-slider"),
o = n.slider("value"),
r = $$(".form-section.score-criteria .criteria-score-value").map(function (t) {
var u = Number($F(t));
if (!Object.isNumber(u) || isNaN(u) || u == 0) {
u = null
}
return u
}).compact();
var p = r.inject(0, function (t, u) {
return t + u
});
var q = (p / r.length).round();
console.log("scores", r);
console.log("sum", p);
console.log("avg", q);
if (q != o) {
n.slider("value", q)
}
};
var k = function () {
var n = parseInt(m.val());
f.fadeOut(200, function () {
$j(this).removeClass("heat1 heat2 heat3 heat4 heat5 heat6 heat7 heat8 heat9 heat10").addClass("heat" + n).animate({
width: (n * 10) + "%"
}, 200).fadeIn(400)
})
};
var j = function (n) {
if (m.val() == n) {
return
}
if (n.toString() == 0) {
n = ""
}
m.val(n);
a.text(n);
k();
if (!l.hasClass("overall_score")) {
d()
}
};
var h = function (o, n) {
j(n.value)
};
b.slider({
min: 0,
max: 10,
value: g || 0,
step: 1,
animate: true,
change: h,
create: k
}, "range", 0, 0)
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment