﻿/*
* qTip2 - Pretty powerful tooltips
* http://craigsworks.com/projects/qtip2/
*
* Version: nightly
* Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
*
* Dual licensed under MIT or GPLv2 licenses
*   http://en.wikipedia.org/wiki/MIT_License
*   http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Mon Apr 11 17:35:09 PDT 2011
*/
"use strict", function (a, b, c) { function v(b) { var c = this, f = b.elements.tooltip, g = b.options.content.ajax, h = ".qtip-ajax", i = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, j = d; b.checks.ajax = { "^content.ajax": function (a, b, d) { b === "ajax" && (g = d), b === "once" ? (f.unbind(h), d && f.bind("tooltipshow" + h, c.load)) : g && g.url ? c.load() : f.unbind(h) } }, a.extend(c, { init: function () { g && g.url && f.bind("tooltipshow" + h, c.load); return c }, load: function (d, h) { function p(a, c, d) { b.set("content.text", c + ": " + d), n() } function o(c) { l && (c = a("<div/>").append(c.replace(i, "")).find(l)), b.set("content.text", c), n() } function n() { m && (f.css("visibility", ""), h = e) } if (d.isDefaultPrevented()) return c; var j = g.url.indexOf(" "), k = g.url, l, m = g.once && !g.loading && h; m && f.css("visibility", "hidden"), j > -1 && (l = k.substr(j), k = k.substr(0, j)), a.ajax(a.extend({ success: o, error: p, context: b }, g, { url: k })); return c } }), c.init() } function u(b, c) { var i, j, k, l, m = a(this), n = a(document.body), o = this === document ? n : m, p = m.metadata ? m.metadata(c.metadata) : f, u = c.metadata.type === "html5" && p ? p[c.metadata.name] : f, v = m.data(c.metadata.name || "qtipopts"); try { v = typeof v === "string" ? (new Function("return " + v))() : v } catch (w) { r("Unable to parse HTML5 attribute data: " + v) } l = a.extend(d, {}, g.defaults, c, typeof v === "object" ? s(v) : f, s(u || p)), p && a.removeData(this, "metadata"), j = l.position, l.id = b; if ("boolean" === typeof l.content.text) { k = m.attr(l.content.attr); if (l.content.attr !== e && k) l.content.text = k; else return e } j.container === e && (j.container = n), j.target === e && (j.target = o), l.show.target === e && (l.show.target = o), l.show.solo === d && (l.show.solo = n), l.hide.target === e && (l.hide.target = o), l.position.viewport === d && (l.position.viewport = j.container), j.at = new h.Corner(j.at), j.my = new h.Corner(j.my); if (a.data(this, "qtip")) if (l.overwrite) m.qtip("destroy"); else if (l.overwrite === e) return e; a.attr(this, "title") && (a.attr(this, q, a.attr(this, "title")), this.removeAttribute("title")), i = new t(m, l, b, !!k), a.data(this, "qtip", i), m.bind("remove.qtip", function () { i.destroy() }); return i } function t(c, o, p, r) { function K(c, d, e, f) { f = parseInt(f, 10) !== 0; var g = ".qtip-" + p, h = { show: c && o.show.target[0], hide: d && o.hide.target[0], tooltip: e && t.rendered && z.tooltip[0], content: e && t.rendered && z.content[0], container: f && o.position.container[0] === u ? document : o.position.container[0], window: f && b }; t.rendered ? a([]).pushStack(a.grep([h.show, h.hide, h.tooltip, h.container, h.content, h.window], function (a) { return typeof a === "object" })).unbind(g) : c && o.show.target.unbind(g + "-create") } function J(d, f, h, j) { function B(a) { y.is(":visible") && t.reposition(a) } function A(a) { if (y.hasClass(l)) return e; clearTimeout(t.timers.inactive), t.timers.inactive = setTimeout(function () { t.hide(a) }, o.hide.inactive) } function x(b) { if (y.hasClass(l)) return e; var c = a(b.relatedTarget || b.target), d = c.closest(m)[0] === y[0], f = c[0] === q.show[0]; clearTimeout(t.timers.show), clearTimeout(t.timers.hide); if (n.target === "mouse" && d || o.hide.fixed && (/mouse(out|leave|move)/.test(b.type) && (d || f))) { b.stopPropagation(), b.preventDefault(); return e } o.hide.delay > 0 ? t.timers.hide = setTimeout(function () { t.hide(b) }, o.hide.delay) : t.hide(b) } function w(a) { if (y.hasClass(l)) return e; q.show.trigger("qtip-" + p + "-inactive"), clearTimeout(t.timers.show), clearTimeout(t.timers.hide); var b = function () { t.show(a) }; o.show.delay > 0 ? t.timers.show = setTimeout(b, o.show.delay) : b() } var k = ".qtip-" + p, n = o.position, q = { show: o.show.target, hide: o.hide.target, container: n.container[0] === u ? a(document) : n.container, doc: a(document) }, r = { show: a.trim("" + o.show.event).split(" "), hide: a.trim("" + o.hide.event).split(" ") }, s = a.browser.msie && parseInt(a.browser.version, 10) === 6, v; h && (o.hide.fixed && (q.hide = q.hide.add(y), y.bind("mouseover" + k, function () { y.hasClass(l) || clearTimeout(t.timers.hide) })), n.target === "mouse" && n.adjust.mouse && o.hide.event && y.bind("mouseleave" + k, function (a) { (a.relatedTarget || a.target) !== q.show[0] && t.hide(a) }), y.bind("mouseenter" + k + " mouseleave" + k, function (a) { t[a.type === "mouseenter" ? "focus" : "blur"](a) })), f && ("number" === typeof o.hide.inactive && (q.show.bind("qtip-" + p + "-inactive", A), a.each(g.inactiveEvents, function (a, b) { q.hide.add(z.tooltip).bind(b + k + "-inactive", A) })), a.each(r.hide, function (b, c) { var d = a.inArray(c, r.show), e = a(q.hide); d > -1 && e.add(q.show).length === e.length || c === "unfocus" ? (q.show.bind(c + k, function (a) { y.is(":visible") ? x(a) : w(a) }), delete r.show[d]) : q.hide.bind(c + k, x) })), d && a.each(r.show, function (a, b) { q.show.bind(b + k, w) }), j && ((n.adjust.resize || n.viewport) && a(a.event.special.resize ? n.viewport : b).bind("resize" + k, B), (n.viewport || s && y.css("position") === "fixed") && a(n.viewport).bind("scroll" + k, B), /unfocus/i.test(o.hide.event) && q.doc.bind("mousedown" + k, function (b) { var d = a(b.target); d.parents(m).length === 0 && d.add(c).length > 1 && y.is(":visible") && !y.hasClass(l) && t.hide(b) }), o.hide.leave && /mouseleave|mouseout/i.test(o.hide.event) && a(b).bind("blur" + k + " mouse" + (o.hide.leave.indexOf("frame") > -1 ? "out" : "leave") + k, function (a) { a.relatedTarget || t.hide(a) }), n.target === "mouse" && q.doc.bind("mousemove" + k, function (a) { n.adjust.mouse && !y.hasClass(l) && y.is(":visible") && t.reposition(a || i) })) } function I(b, d) { function g(a) { function c(c) { (b = b.not(this)).length === 0 && (t.redraw(), t.reposition(A.event), a()) } var b; if ((b = f.find("img:not([height]):not([width])")).length === 0) return c.call(b); b.each(function (a, b) { (function d() { var e = t.timers.img; if (b.height && b.width) { clearTimeout(e[a]); return c.call(b) } e[a] = setTimeout(d, 20) })() }) } var f = z.content; if (!t.rendered || !b) return e; a.isFunction(b) && (b = b.call(c, t) || ""), b.jquery && b.length > 0 ? f.empty().append(b.css({ display: "block" })) : f.html(b), t.rendered < 0 ? y.queue("fx", g) : (x = 0, g(a.noop)); return t } function H(b) { var d = z.title; if (!t.rendered || !b) return e; a.isFunction(b) && (b = b.call(c, t) || ""), b.jquery && b.length > 0 ? d.empty().append(b.css({ display: "block" })) : d.html(b), t.redraw(), t.rendered && y.is(":visible") && t.reposition(A.event) } function G(a) { var b = z.button, c = z.title; if (!t.rendered) return e; a ? (c || F(), E()) : b.remove() } function F() { var b = v + "-title"; z.titlebar && D(), z.titlebar = a("<div />", { "class": j + "-titlebar " + (o.style.widget ? "ui-widget-header" : "") }).append(z.title = a("<div />", { id: b, "class": j + "-title", "aria-atomic": d })).insertBefore(z.content), o.content.title.button ? E() : t.rendered && t.redraw() } function E() { var b = o.content.title.button, c = typeof b === "string", d = c ? b : "Close tooltip"; z.button && z.button.remove(), b.jquery ? z.button = b : z.button = a("<a />", { "class": "ui-state-default " + (o.style.widget ? "" : j + "-icon"), title: d, "aria-label": d }).prepend(a("<span />", { "class": "ui-icon ui-icon-close", html: "&times;" })), z.button.appendTo(z.titlebar).attr("role", "button").hover(function (b) { a(this).toggleClass("ui-state-hover", b.type === "mouseenter") }).click(function (a) { y.hasClass(l) || t.hide(a); return e }).bind("mousedown keydown mouseup keyup mouseout", function (b) { a(this).toggleClass("ui-state-active ui-state-focus", b.type.substr(-4) === "down") }), t.redraw() } function D() { z.title && (z.titlebar.remove(), z.titlebar = z.title = z.button = f, t.reposition()) } function C() { var a = o.style.widget; y.toggleClass(k, a), z.content.toggleClass(k + "-content", a), z.titlebar && z.titlebar.toggleClass(k + "-header", a), z.button && z.button.toggleClass(j + "-icon", !a) } function B(a) { var b = 0, c, d = o, e = a.split("."); while (d = d[e[b++]]) b < e.length && (c = d); return [c || o, e.pop()] } var t = this, u = document.body, v = j + "-" + p, w = 0, x = 0, y = a(), z, A; t.id = p, t.rendered = e, t.elements = z = { target: c }, t.timers = { img: [] }, t.options = o, t.checks = {}, t.plugins = {}, t.cache = A = { event: {}, target: f, disabled: e, attr: r }, t.checks.builtin = { "^id$": function (b, c, f) { var h = f === d ? g.nextid : f, i = j + "-" + h; h !== e && h.length > 0 && !a("#" + i).length && (y[0].id = i, z.content[0].id = i + "-content", z.title[0].id = i + "-title") }, "^content.text$": function (a, b, c) { I(c) }, "^content.title.text$": function (a, b, c) { if (!c) return D(); !z.title && c && F(), H(c) }, "^content.title.button$": function (a, b, c) { G(c) }, "^position.(my|at)$": function (a, b, c) { "string" === typeof c && (a[b] = new h.Corner(c)) }, "^position.container$": function (a, b, c) { t.rendered && y.appendTo(c) }, "^(show|hide).(event|target|fixed|delay|inactive)$": function (a, b, c, d, e) { var f = [1, 0, 0]; f[e[1] === "show" ? "push" : "unshift"](0), K.apply(t, f), J.apply(t, [1, 1, 0, 0]) }, "^show.ready$": function () { t.rendered ? t.show() : t.render(1) }, "^style.classes$": function (b, c, d) { a.attr(y[0], "class", j + " qtip ui-helper-reset " + d) }, "^style.widget|content.title": C, "^events.(render|show|move|hide|focus|blur)$": function (b, c, d) { y[(a.isFunction(d) ? "" : "un") + "bind"]("tooltip" + c, d) } }, a.extend(t, { render: function (b) { if (t.rendered) return t; var f = o.content.text, g = o.content.title.text, i = a.Event("tooltiprender"); a.attr(c[0], "aria-describedby", v), y = z.tooltip = a("<div/>").attr({ id: v, "class": j + " qtip ui-helper-reset " + o.style.classes, role: "alert", "aria-live": "polite", "aria-atomic": e, "aria-describedby": v + "-content", "aria-hidden": d }).toggleClass(l, A.disabled).data("qtip", t).appendTo(o.position.container).append(z.content = a("<div />", { "class": j + "-content", id: v + "-content", "aria-atomic": d })), t.rendered = -1, x = 1, g && (F(), H(g)), I(f), t.rendered = d, C(), a.each(o.events, function (b, c) { a.isFunction(c) && y.bind(b === "toggle" ? "tooltipshow tooltiphide" : "tooltip" + b, c) }), a.each(h, function () { this.initialize === "render" && this(t) }), J(1, 1, 1, 1), y.queue("fx", function (a) { i.originalEvent = A.event, y.trigger(i, [t]), x = 0, t.redraw(), (o.show.ready || b) && t.show(A.event), a() }); return t }, get: function (a) { var b, c; switch (a.toLowerCase()) { case "dimensions": b = { height: y.outerHeight(), width: y.outerWidth() }; break; case "offset": b = h.offset(y, o.position.container); break; default: c = B(a.toLowerCase()), b = c[0][c[1]], b = b.precedance ? b.string() : b } return b }, set: function (b, c) { function l(a, b) { var c, d, e; for (c in j) for (d in j[c]) if (e = (new RegExp(d, "i")).exec(a)) b.push(e), j[c][d].apply(t, b) } var f = /^position\.(my|at|adjust|target|container)|style|content|show\.ready/i, g = /^content\.(title|attr)|style/i, h = e, i = e, j = t.checks, k; "string" === typeof b ? (k = b, b = {}, b[k] = c) : b = a.extend(d, {}, b), a.each(b, function (c, d) { var e = B(c.toLowerCase()), j; j = e[0][e[1]], e[0][e[1]] = "object" === typeof d && d.nodeType ? a(d) : d, b[c] = [e[0], e[1], d, j], h = f.test(c) || h, i = g.test(c) || i }), s(o), w = x = 1, a.each(b, l), w = x = 0, y.is(":visible") && t.rendered && (h && t.reposition(), i && t.redraw()); return t }, toggle: function (b, c) { function j() { b ? (a.browser.msie && y[0].style.removeAttribute("filter"), y.css("overflow", "")) : y.css({ display: "", visibility: "", width: "", opacity: "", left: "", top: "" }) } if (!t.rendered) if (b) t.render(1); else return t; var d = b ? "show" : "hide", g = o[d], h = y.is(":visible"), i; (typeof b).search("boolean|number") && (b = !h); if (h === b) return t; if (c) { if (/over|enter/.test(c.type) && /out|leave/.test(A.event.type) && c.target === o.show.target[0] && y.has(c.relatedTarget).length) return t; A.event = a.extend({}, c) } i = a.Event("tooltip" + d), i.originalEvent = c ? A.event : f, y.trigger(i, [t, 90]); if (i.isDefaultPrevented()) return t; a.attr(y[0], "aria-hidden", !b), b ? (t.focus(c), t.reposition(c), g.solo && a(m, g.solo).not(y).qtip("hide", i)) : (clearTimeout(t.timers.show), t.blur(c)), y.stop(0, 1), a.isFunction(g.effect) ? (g.effect.call(y, t), y.queue("fx", function (a) { j(), a() })) : g.effect === e ? (y[d](), j.call(y)) : y.fadeTo(90, b ? 1 : 0, j), b && g.target.trigger("qtip-" + p + "-inactive"); return t }, show: function (a) { return t.toggle(d, a) }, hide: function (a) { return t.toggle(e, a) }, focus: function (b) { if (!t.rendered) return t; var c = a(m), d = parseInt(y[0].style.zIndex, 10), e = g.zindex + c.length, f = a.extend({}, b), h, i; y.hasClass(n) || (d !== e && (c.each(function () { this.style.zIndex > d && (this.style.zIndex = this.style.zIndex - 1) }), c.filter("." + n).qtip("blur", f)), i = a.Event("tooltipfocus"), i.originalEvent = f, y.trigger(i, [t, e]), i.isDefaultPrevented() || (y.addClass(n)[0].style.zIndex = e)); return t }, blur: function (b) { var c = a.extend({}, b), d; y.removeClass(n), d = a.Event("tooltipblur"), d.originalEvent = c, y.trigger(d, [t]); return t }, reposition: function (c, d) { if (!t.rendered || w) return t; w = 1; var f = o.position.target, g = o.position, k = g.my, l = g.at, m = g.adjust, n = m.method, p = y.outerWidth(), q = y.outerHeight(), r = 0, s = 0, v = a.Event("tooltipmove"), x = y.css("position") === "fixed", z = g.viewport.jquery ? g.viewport : a(b), B = { left: 0, top: 0 }, C = (t.plugins.tip || {}).corner, D = { method: n.substr(0, 5), horizontal: n.length < 6 || n.indexOf("horizontal") > -1, vertical: n.length < 6 || n.indexOf("vertical") > -1, left: function (a) { if (!D.horizontal) return 0; var b = z.scrollLeft, c = k.x === "left" ? p : k.x === "right" ? -p : -p / 2, d = l.x === "left" ? r : l.x === "right" ? -r : -r / 2, e = C && C.precedance === "x" ? o.style.tip.width : 0, f = b - a - e, g = a + p - z.width - b + e, h = c - (k.precedance === "x" || k.x === k.y ? d : 0), i = k.x === "center"; D.method === "shift" ? B.left += f > 0 ? f - e : g > 0 ? -g + e : 0 : (f > 0 && (k.x !== "left" || g > 0) ? B.left -= h + (i ? 0 : 2 * m.x) : g > 0 && (k.x !== "right" || f > 0) && (B.left -= i ? -h : h + 2 * m.x), B.left !== a && i && (B.left -= m.x)), B.left < 0 && -B.left > g && (B.left = a); return B.left - a }, top: function (a) { if (!D.vertical) return 0; var b = z.scrollTop, c = k.y === "top" ? q : k.y === "bottom" ? -q : -q / 2, d = l.y === "top" ? s : l.y === "bottom" ? -s : -s / 2, e = C && C.precedance === "y" ? o.style.tip.height : 0, f = b - a - e, g = a + q - z.height - b + e, h = c - (k.precedance === "y" || k.x === k.y ? d : 0), i = k.y === "center"; D.method === "shift" ? B.top += f - e > 0 ? f : g > 0 ? -g + e : 0 : (f > 0 && (k.y !== "top" || g > 0) ? B.top -= h + (i ? 0 : 2 * m.y) : g > 0 && (k.y !== "bottom" || f > 0) && (B.top -= i ? -h : h + 2 * m.y), B.top !== a && i && (B.top -= m.y)), B.top < 0 && -B.top > g && (B.top = a); return B.top - a } }; z = z ? { elem: z, height: z[(z[0] === b ? "h" : "outerH") + "eight"](), width: z[(z[0] === b ? "w" : "outerW") + "idth"](), scrollLeft: z.scrollLeft(), scrollTop: z.scrollTop()} : e; if (f === "mouse") l = { x: "left", y: "top" }, c = c && (c.type === "resize" || c.type === "scroll") ? A.event : m.mouse || !c || !c.pageX ? a.extend({}, i) : c, B = { top: c.pageY, left: c.pageX }; else { f === "event" && (c && c.target && c.type !== "scroll" && c.type !== "resize" ? f = A.target = a(c.target) : f = A.target), f = a(f).eq(0); if (f.length === 0) return t; f[0] === document || f[0] === b ? (r = f.width(), s = f.height(), f[0] === b && (B = { top: x ? 0 : z.scrollTop, left: x ? 0 : z.scrollLeft })) : f.is("area") && h.imagemap ? B = h.imagemap(f, l) : f[0].namespaceURI == "http://www.w3.org/2000/svg" && h.svg ? B = h.svg(f, l) : (r = f.outerWidth(), s = f.outerHeight(), B = h.offset(f, g.container)), B.offset && (r = B.width, s = B.height, B = B.offset), B.left += l.x === "right" ? r : l.x === "center" ? r / 2 : 0, B.top += l.y === "bottom" ? s : l.y === "center" ? s / 2 : 0 } B.left += m.x + (k.x === "right" ? -p : k.x === "center" ? -p / 2 : 0), B.top += m.y + (k.y === "bottom" ? -q : k.y === "center" ? -q / 2 : 0), g.viewport.jquery && f[0] !== b && f[0] !== u ? B.adjusted = { left: D.left(B.left), top: D.top(B.top)} : B.adjusted = { left: 0, top: 0 }, y.attr("class", function (b, c) { return a.attr(this, "class").replace(/ui-tooltip-pos-\w+/i, "") }).addClass(j + "-pos-" + k.abbreviation()), v.originalEvent = a.extend({}, c), y.trigger(v, [t, B, z.elem]); if (v.isDefaultPrevented()) return t; delete B.adjusted, d === e || isNaN(B.left) || isNaN(B.top) || !a.isFunction(g.effect) ? y.css(B) : a.isFunction(g.effect) && (g.effect.call(y, t, a.extend({}, B)), y.queue(function (b) { a(this).css({ opacity: "", height: "" }), a.browser.msie && this.style.removeAttribute("filter"), b() })), w = 0; return t }, redraw: function () { if (t.rendered < 1 || x) return t; var b = j + "-fluid", c, d, e; x = 1, y.css("width", ""), y.css("width") === "auto" && (y.addClass(b), c = y.width() + (a.browser.mozilla ? 1 : 0), d = parseInt(y.css("max-width"), 10) || 0, e = parseInt(y.css("min-width"), 10) || 0, c = d + e ? Math.min(Math.max(c, e), d) : c, y.css("width", c).removeClass(b)), x = 0; return t }, disable: function (b) { var c = l; "boolean" !== typeof b && (b = !y.hasClass(c) && !A.disabled), t.rendered ? (y.toggleClass(c, b), a.attr(y[0], "aria-disabled", b)) : A.disabled = !!b; return t }, enable: function () { return t.disable(e) }, destroy: function () { var b = c[0], d = a.attr(b, q); t.rendered && (y.remove(), a.each(t.plugins, function () { this.destroy && this.destroy() })), clearTimeout(t.timers.show), clearTimeout(t.timers.hide), K(1, 1, 1, 1), a.removeData(b, "qtip"), d && (a.attr(b, "title", d), c.removeAttr(q)), c.removeAttr("aria-describedby").unbind(".qtip"); return c } }) } function s(b) { var c; if (!b || "object" !== typeof b) return e; "object" !== typeof b.metadata && (b.metadata = { type: b.metadata }); if ("content" in b) { if ("object" !== typeof b.content || b.content.jquery) b.content = { text: b.content }; c = b.content.text || e, !a.isFunction(c) && (!c && !c.attr || c.length < 1 || "object" === typeof c && !c.jquery) && (b.content.text = e), "title" in b.content && ("object" !== typeof b.content.title && (b.content.title = { text: b.content.title }), c = b.content.title.text || e, !a.isFunction(c) && (!c && !c.attr || c.length < 1 || "object" === typeof c && !c.jquery) && (b.content.title.text = e)) } "position" in b && ("object" !== typeof b.position && (b.position = { my: b.position, at: b.position }), "adjust" in b.position && (/flip|shift( horizontal| vertical)*/i.test(b.position.adjust.method) || delete b.position.adjust.method)), "show" in b && ("object" !== typeof b.show && (b.show.jquery ? b.show = { target: b.show} : b.show = { event: b.show })), "hide" in b && ("object" !== typeof b.hide && (b.hide.jquery ? b.hide = { target: b.hide} : b.hide = { event: b.hide })), "style" in b && ("object" !== typeof b.style && (b.style = { classes: b.style })), a.each(h, function () { this.sanitize && this.sanitize(b) }); return b } function r() { var c = b.console; return c && (c.error || c.log || a.noop).apply(c, arguments) } var d = !0, e = !1, f = null, g, h, i, j = "ui-tooltip", k = "ui-widget", l = "ui-state-disabled", m = "div.qtip." + j, n = j + "-focus", o = "-31000px", p = "_replacedByqTip", q = "oldtitle"; g = a.fn.qtip = function (b, h, i) { var j = ("" + b).toLowerCase(), k = f, l = j === "disable" ? [d] : a.makeArray(arguments).slice(1, 10), m = l[l.length - 1], n = this[0] ? a.data(this[0], "qtip") : f; if (!arguments.length && n || j === "api") return n; if ("string" === typeof b) { this.each(function () { var b = a.data(this, "qtip"); if (!b) return d; m && m.timeStamp && (b.cache.event = m); if (j !== "option" && j !== "options" || !h) b[j] && b[j].apply(b[j], l); else if (a.isPlainObject(h) || i !== c) b.set(h, i); else { k = b.get(h); return e } }); return k !== f ? k : this } if ("object" === typeof b || !arguments.length) { n = s(a.extend(d, {}, b)); return g.bind.call(this, n, m) } }, g.bind = function (b, c) { return this.each(function (f) { function p(b) { function c() { o.render(typeof b === "object" || i.show.ready), k.show.unbind(l.show), k.hide.unbind(l.hide) } if (o.cache.disabled) return e; o.cache.event = a.extend({}, b), i.show.delay > 0 ? (clearTimeout(o.timers.show), o.timers.show = setTimeout(c, i.show.delay), l.show !== l.hide && k.hide.bind(l.hide, function () { clearTimeout(o.timers.show) })) : c() } var i, k, l, m = !b.id || b.id === e || b.id.length < 1 || a("#" + j + "-" + b.id).length ? g.nextid++ : b.id, n = ".qtip-" + m + "-create", o = u.call(this, m, b); if (o === e) return d; i = o.options, a.each(h, function () { this.initialize === "initialize" && this(o) }), k = { show: i.show.target, hide: i.hide.target }, l = { show: a.trim("" + i.show.event).replace(/ /g, n + " ") + n, hide: a.trim("" + i.hide.event).replace(/ /g, n + " ") + n }, i.hide.event === "unfocus" && (l.hide = "mouseleave" + n), k.show.bind(l.show, p), (i.show.ready || i.prerender) && p(c) }) }, h = g.plugins = { Corner: function (a) { a = ("" + a).replace(/([A-Z])/, " $1").replace(/middle/gi, "center").toLowerCase(), this.x = (a.match(/left|right/i) || a.match(/center/) || ["inherit"])[0].toLowerCase(), this.y = (a.match(/top|bottom|center/i) || ["inherit"])[0].toLowerCase(), this.precedance = a.charAt(0).search(/^(t|b)/) > -1 ? "y" : "x", this.string = function () { return this.precedance === "y" ? this.y + this.x : this.x + this.y }, this.abbreviation = function () { var a = this.x.substr(0, 1), b = this.y.substr(0, 1); return a === b ? a : a === "c" || a !== "c" && b !== "c" ? b + a : a + b } }, offset: function (c, d) { function k(a, b) { e.left += b * a.scrollLeft(), e.top += b * a.scrollTop() } var e = c.offset(), f = d, g = 0, i = document.body, j; if (f) { do { if (f[0] === i) break; f.css("position") !== "static" && (j = f.position(), e.left -= j.left + (parseInt(f.css("borderLeftWidth"), 10) || 0), e.top -= j.top + (parseInt(f.css("borderTopWidth"), 10) || 0), g++) } while (f = f.offsetParent()); (d[0] !== i || g > 1) && k(d, 1), h.iOS && k(a(b), -1) } return e }, iOS: parseFloat(("" + (/CPU.*OS ([0-9_]{2,3})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, "4_2"])[1]).replace("undefined", "3_2").replace("_", ".")) < 4.1, fn: { attr: function (b, c) { if (this.length) { var d = this[0], e = "title", f = a.data(d, "qtip"); if (b === e) { if (arguments.length < 2) return a.attr(d, q); if (typeof f === "object") { f && f.rendered && f.options.content.attr === e && f.cache.attr && f.set("content.text", c), a.fn["attr" + p].apply(this, arguments), a.attr(d, q, a.attr(d, e)); return this.removeAttr(e) } } } }, clone: function (b) { var c = a([]), d = "title", e; e = a.fn["clone" + p].apply(this, arguments).filter("[oldtitle]").each(function () { a.attr(this, d, a.attr(this, q)), this.removeAttribute(q) }).end(); return e }, remove: a.ui ? f : function (b, c) { a(this).each(function () { c || (!b || a.filter(b, [this]).length) && a("*", this).add(this).each(function () { a(this).triggerHandler("remove") }) }) } } }, a.each(h.fn, function (b, c) { if (!c) return d; var e = a.fn[b + p] = a.fn[b]; a.fn[b] = function () { return c.apply(this, arguments) || e.apply(this, arguments) } }), a(document).bind("mousemove.qtip", function (a) { i = { pageX: a.pageX, pageY: a.pageY, type: "mousemove"} }), g.version = "nightly", g.nextid = 0, g.inactiveEvents = "click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "), g.zindex = 15e3, g.defaults = { prerender: e, id: e, overwrite: d, content: { text: d, attr: "title", title: { text: e, button: e} }, position: { my: "top left", at: "bottom right", target: e, container: e, viewport: e, adjust: { x: 0, y: 0, mouse: d, resize: d, method: "flip" }, effect: d }, show: { target: e, event: "mouseenter", effect: d, delay: 90, solo: e, ready: e }, hide: { target: e, event: "mouseleave", effect: d, delay: 0, fixed: e, inactive: e, leave: "window" }, style: { classes: "", widget: e }, events: { render: f, move: f, show: f, hide: f, toggle: f, focus: f, blur: f} }, h.ajax = function (a) { var b = a.plugins.ajax; return "object" === typeof b ? b : a.plugins.ajax = new v(a) }, h.ajax.initialize = "render", h.ajax.sanitize = function (a) { var b = a.content, c; b && "ajax" in b && (c = b.ajax, typeof c !== "object" && (c = a.content.ajax = { url: c }), "boolean" !== typeof c.once && c.once && (c.once = !!c.once)) }, a.extend(d, g.defaults, { content: { ajax: { loading: d, once: d}} }) } (jQuery, window)



// ok our home brew below
// namespacing howto for the most part from a good read at http://msdn.microsoft.com/en-us/magazine/cc163419.aspx
var Centergy = {};
Centergy.JaxStatus = function () {
    this.currentMsg = "Test...";
    this.containerHtml = '<div id="cJaxStatusContainer" class="ui-corner-bottom" style="display:none">TEST</div>';
    $("body").append(this.containerHtml);
    this.container = $("body div#cJaxStatusContainer")

    this.SetStatus = function (txt) {
        this.currentMsg = txt;
        this.container.html(this.currentMsg);
        this.container.show();
        //alert(this.container.html());
    }

    this.ClearStatus = function () {
        this.container.hide();
        this.container.html("");
    }

    this.ClearWithSizzle = function (goodbyeTxt, duration) {
        // clear background url noise
        //var oldbackgroundUrl = this.container.css("background-image");

        //this.container.css("background-image", "none");
        this.currentMsg = goodbyeTxt;
        this.container.html(goodbyeTxt);
        this.container.delay(duration).slideUp('fast');

        // put background image back in
        //this.container.css("background-image", oldbackgroundUrl);
    }
}

var cJaxStatus = new Centergy.JaxStatus(); // to try and get intellisense instead visual studio
// init when DOM is ready
$(document).ready(function () {
    cJaxStatus = new Centergy.JaxStatus();
});

// standard ajax tooltip loader
$(document).ready(function () {
    $(".helpIcon").qtip(
    {
        show: {
            event: "mouseover"
        },
        hide: {
            event: "mouseout"
        },
        position: {
            viewport: $(window),
            at: "top right",
            my: "bottom left"
        },
        style: {
            tip: "bottomLeft",
            classes: "ui-tooltip-light centergy-help-box"
        }
    });

    $(".tooltipTrigger").each(function () {
        //alert($(this).attr('href'));
        $(this).qtip(
                {
                    content: {
                        text: "loading... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...",
                        ajax: {
                            url: $(this).attr('href')
                        },
                        title: {
                            text: $(this).attr('title') + ' - ' + $(this).text(), // Give the tooltip a title using each elements text
                            button: true
                        }
                    },
                    show: {
                        solo: true,
                        event: "click"
                    },
                    hide: {
                        event: "click"
                    },
                    position: {
                        at: "top center",
                        my: "bottom center",
                        adjust: { screen: true} // Keep the tooltip on-screen at all times
                    },
                    style: {
                        tip: "bottomMiddle",
                        classes: "ui-tooltip-light centergy-ajax-box"
                    }
                })

        // turn off href if we get this far
        .click(function () { return false; });
    });

        });


// standard datepicker init
$(document).ready(function () {
    $(".date-picker").datepicker();
}); 
