/**
 *                                                        ____   _____
 *  Dynarch Calendar -- JSCal2, version 1.0               \  /_  /   /
 *  Built at 2009/05/18 08:52 GMT                          \  / /   /
 *                                                          \/ /_  /
 *  (c) Dynarch.com 2009                                     \  / /
 *  All rights reserved.                                       / /
 *  Visit www.dynarch.com/projects/calendar for details        \/
 *
 */
Calendar = (function () {
    function v(an) {
        an = an || {};
        this.args = an = ah(an, {
            animation: !c,
            cont: null,
            bottomBar: true,
            date: new Date(1982, 1, 0), // Remember that the months start from zero in the JS Date object
            fdow: am("fdow"),
            min: null,
            max: null,
            reverseWheel: false,
            selection: [],
            selectionType: v.SEL_SINGLE,
            weekNumbers: false,
            align: "Bl/ / /T/r",
            inputField: null,
            trigger: null,
            dateFormat: "%Y-%m-%d",
            opacity: j ? 1 : 3,
            titleFormat: "%b %Y",
            disabled: Z,
            dateInfo: Z,
            onChange: Z,
            onSelect: Z
        });
        this.handlers = {};
        var D = this;

        function ao(aq) {
            var ap = an[aq];
            if (! (ap instanceof Array)) {
                ap = [ap]
            }
            D.handlers[aq] = ap
        }
        an.min = U(an.min);
        an.max = U(an.max);
        this.date = U(an.date);
        this.fdow = an.fdow;
        ao("onSelect");
        ao("onChange");
        this.selection = new v.Selection(an.selection, an.selectionType, t(M, this));
        var P = H.call(this);
        if (an.cont) {
            S(an.cont).appendChild(P)
        }
        if (an.trigger) {
            o(S(an.trigger), "click", t(this.popup, this, an.trigger, null))
        }
    }
    var N = navigator.userAgent,
        q = /opera/i.test(N),
        ae = /Konqueror|Safari|KHTML/i.test(N),
        j = /msie/i.test(N) && !q && !(/mac_powerpc/i.test(N)),
        c = j && /msie 6/i.test(N),
        u = /gecko/i.test(N) && !ae && !q && !j,
        l = v.prototype;
    v.SEL_SINGLE = 1;
    v.SEL_MULTIPLE = 2;
    v.SEL_WEEK = 3;
    v.dateToInt = R;
    v.intToDate = y;
    v.printDate = X;
    v.formatString = k;
    v.i18n = am;
    I18N = v.I18N = {};
    v.LANG = function (P, D, an) {
        I18N.__ = I18N[P] = {
            name: D,
            data: an
        }
    };
    v.setup = function (D) {
        return new v(D)
    };
    l.moveTo = function (aC, az) {
        aC = U(aC);
        var ay = ab(aC, this.date, true),
            ap, av = this.args,
            aD = av.min && ab(aC, av.min),
            aE = av.max && ab(aC, av.max);
        if (!av.animation) {
            az = false
        }
        aa(aD != null && aD <= 1, [this.els.navPrevMonth, this.els.navPrevYear], "DynarchCalendar-navDisabled");
        aa(aE != null && aE >= -1, [this.els.navNextMonth, this.els.navNextYear], "DynarchCalendar-navDisabled");
        if (aD < -1) {
            aC = av.min;
            ap = 1;
            ay = 0
        }
        if (aE > 1) {
            aC = av.max;
            ap = 2;
            ay = 0
        }
        this.date = aC;
        this.refresh( !! az);
        this.callHooks("onChange", this, aC, az);
        if (az && !(ay == 0 && az == 2)) {
            if (this._bodyAnim) {
                this._bodyAnim.stop()
            }
            var ar = this.els.body,
                at = C("div", "DynarchCalendar-animBody-" + Q[ay], ar),
                aB = ar.firstChild,
                aq = ai(aB) || 0.7,
                au = ap ? V.brakes : ay == 0 ? V.shake : V.accel_ab2,
            aA = ay * ay > 4,
            an = aA ? aB.offsetTop : aB.offsetLeft,
            ax = at.style,
            aw = aA ? ar.offsetHeight : ar.offsetWidth;
            if (ay < 0) {
                aw += an
            } else {
                if (ay > 0) {
                    aw = an - aw
                } else {
                    aw = Math.round(aw / 7);
                    if (ap == 2) {
                        aw = -aw
                    }
                }
            }
            if (!ap && ay != 0) {
                var P = at.cloneNode(true),
                    D = P.style,
                    ao = 2 * aw;
                P.appendChild(aB.cloneNode(true));
                D[aA ? "marginTop" : "marginLeft"] = aw + "px";
                ar.appendChild(P)
            }
            aB.style.visibility = "hidden";
            at.innerHTML = Y(this);
            this._bodyAnim = al({
                onUpdate: t(function (aG, aI) {
                    var aH = au(aG);
                    if (P) {
                        var aF = aI(aH, aw, ao) + "px"
                    }
                    if (ap) {
                        ax[aA ? "marginTop" : "marginLeft"] = aI(aH, aw, 0) + "px"
                    } else {
                        if (aA || ay == 0) {
                            ax.marginTop = aI(ay == 0 ? au(aG * aG) : aH, 0, aw) + "px";
                            if (ay != 0) {
                                D.marginTop = aF
                            }
                        }
                        if (!aA || ay == 0) {
                            ax.marginLeft = aI(aH, 0, aw) + "px";
                            if (ay != 0) {
                                D.marginLeft = aF
                            }
                        }
                    }
                    if (this.args.opacity > 2 && P) {
                        ai(P, 1 - aH);
                        ai(at, aH)
                    }
                },
                this),
                onStop: t(function (aF) {
                    ar.innerHTML = Y(this, aC);
                    this._bodyAnim = null
                },
                this)
            })
        }
        this._lastHoverDate = null;
        return aD >= -1 && aE <= 1
    };
    l.isDisabled = function (D) {
        var P = this.args;
        return (P.min && ab(D, P.min) < 0) || (P.max && ab(D, P.max) > 0) || P.disabled(D)
    };
    l.toggleMenu = function () {
        s(this, !this._menuVisible)
    };
    l.refresh = function (D) {
        var P = this.els;
        if (!D) {
            P.body.innerHTML = Y(this)
        }
        P.title.innerHTML = B(this);
        P.yearInput.value = this.date.getFullYear()
    };
    l.redraw = function () {
        var D = this.els;
        this.refresh();
        D.dayNames.innerHTML = h(this);
        D.menu.innerHTML = ag(this);
        if (D.bottomBar) {
            D.bottomBar.innerHTML = E(this)
        }
        r(D.menu, t(function (P) {
            if (P.className == "DynarchCalendar-menu-year") {
                o(P, this._focusEvents);
                D.yearInput = P
            }
        },
        this))
    };
    l.setLanguage = function (D) {
        var P = v.setLanguage(D);
        if (P) {
            this.fdow = P.data.fdow;
            this.redraw()
        }
    };
    v.setLanguage = function (D) {
        var P = I18N[D];
        if (P) {
            I18N.__ = P
        }
        return P
    };
    l.focus = function () {
        try {
            this.els[this._menuVisible ? "yearInput" : "focusLink"].focus()
        } catch(D) {}
        i.call(this)
    };
    l.blur = function () {
        this.els.focusLink.blur();
        this.els.yearInput.blur();
        w.call(this)
    };
    l.showAt = function (P, at, aq) {
        if (this._showAnim) {
            this._showAnim.stop()
        }
        aq = aq && this.args.animation;
        var ar = this.els.topCont,
            an = this,
            D = this.els.body.firstChild,
            ap = D.offsetHeight,
            ao = ar.style;
        ao.position = "absolute";
        ao.left = P + "px";
        ao.top = at + "px";
        ao.zIndex = 10000;
        ao.display = "";
        if (aq) {
            D.style.marginTop = -ap + "px";
            this.args.opacity > 1 && ai(ar, 0);
            this._showAnim = al({
                onUpdate: function (au, av) {
                    D.style.marginTop = -av(V.accel_b(au), ap, 0) + "px";
                    an.args.opacity > 1 && ai(ar, au)
                },
                onStop: function () {
                    an.args.opacity > 1 && ai(ar, "");
                    an._showAnim = null
                }
            })
        }
    };
    l.hide = function () {
        var ao = this.els.topCont,
            P = this,
            D = this.els.body.firstChild,
            an = D.offsetHeight,
            ap = G(ao).y;
        if (this.args.animation) {
            if (this._showAnim) {
                this._showAnim.stop()
            }
            this._showAnim = al({
                onUpdate: function (aq, ar) {
                    P.args.opacity > 1 && ai(ao, 1 - aq);
                    D.style.marginTop = -ar(V.accel_b(aq), 0, an) + "px";
                    ao.style.top = ar(V.accel_ab(aq), ap, ap - 10) + "px"
                },
                onStop: function () {
                    ao.style.display = "none";
                    D.style.marginTop = "";
                    P.args.opacity > 1 && ai(ao, "");
                    P._showAnim = null
                }
            })
        } else {
            ao.style.display = "none"
        }
    };
    l.popup = function (D, ao) {
        D = S(D);
        if (!ao) {
            ao = this.args.align
        }
        ao = ao.split(/\x2f/);
        var an = G(D),
            ar = this.els.topCont,
            au = ar.style,
            ap, at = T();
        au.visibility = "hidden";
        au.display = "";
        this.showAt(0, 0);
        document.body.appendChild(ar);
        ap = {
            x: ar.offsetWidth,
            y: ar.offsetHeight
        };

        function P(av) {
            var aw = {
                x: aq.x,
                y: aq.y
            };
            if (!av) {
                return aw
            }
            if (/B/.test(av)) {
                aw.y += D.offsetHeight
            }
            if (/b/.test(av)) {
                aw.y += D.offsetHeight - ap.y
            }
            if (/T/.test(av)) {
                aw.y -= ap.y
            }
            if (/l/.test(av)) {
                aw.x -= ap.x - D.offsetWidth
            }
            if (/L/.test(av)) {
                aw.x -= ap.x
            }
            if (/R/.test(av)) {
                aw.x += D.offsetWidth
            }
            if (/c/i.test(av)) {
                aw.x += (D.offsetWidth - ap.x) / 2
            }
            if (/m/i.test(av)) {
                aw.y += (D.offsetHeight - ap.y) / 2
            }
            return aw
        }
        var aq = an;
        aq = P(ao[0]);
        if (aq.y < at.y) {
            aq.y = an.y;
            aq = P(ao[1])
        }
        if (aq.x + ap.x > at.x + at.w) {
            aq.x = an.x;
            aq = P(ao[2])
        }
        if (aq.y + ap.y > at.y + at.h) {
            aq.y = an.y;
            aq = P(ao[3])
        }
        if (aq.x < at.x) {
            aq.x = an.x;
            aq = P(ao[4])
        }
        this.showAt(aq.x, aq.y, true);
        au.visibility = "";
        this.focus()
    };
    l.callHooks = function (an) {
        var ao = b(arguments, 1),
            D = this.handlers[an],
            P = 0;
        for (; P < D.length; ++P) {
            D[P].apply(this, ao)
        }
    };
    l.addEventListener = function (P, D) {
        this.handlers[P].push(D)
    };
    l.removeEventListener = function (ao, an) {
        var D = this.handlers[ao],
            P = D.length;
        while (--P >= 0) {
            if (D[P] === an) {
                D.splice(P, 1)
            }
        }
    };
    l._getInputYear = function () {
        var D = parseInt(this.els.yearInput.value, 10);
        if (isNaN(D)) {
            D = this.date.getFullYear()
        }
        return D
    };
    l._showTooltip = function (D) {
        var P = "",
            ao, an = this.els.tooltip;
        if (D) {
            D = y(D);
            ao = this.args.dateInfo(D);
            if (ao && ao.tooltip) {
                P = "<div class='DynarchCalendar-tooltipCont'>" + X(D, ao.tooltip) + "</div>"
            }
        }
        an.innerHTML = P
    };
    var ad = " align='center' cellspacing='0' cellpadding='0'";

    function h(D) {
        var an = ["<table", ad, "><tr>"],
            P = 0;
        if (D.args.weekNumbers) {
            an.push("<td><div class='DynarchCalendar-weekNumber'>", am("wk"), "</div></td>")
        }
        while (P < 7) {
            var ao = (P+++D.fdow) % 7;
            an.push("<td><div", am("weekend").indexOf(ao) >= 0 ? " class='DynarchCalendar-weekend'>" : ">", am("sdn")[ao], "</div></td>")
        }
        an.push("</tr></table>");
        return an.join("")
    }

    function Y(ar, aC, az) {
        aC = aC || ar.date;
        az = az || ar.fdow;
        aC = new Date(aC);
        var aE = aC.getMonth(),
            aq = [],
            aw = 0,
            D = ar.args.weekNumbers;
        aC.setDate(1);
        var av = (aC.getDay() - az) % 7;
        if (av < 0) {
            av += 7
        }
        aC.setDate(-av);
        aC.setDate(aC.getDate() + 1);
        var aA = new Date(),
            ao = aA.getDate(),
            P = aA.getMonth(),
            aF = aA.getFullYear();
        aq[aw++] = "<table class='DynarchCalendar-bodyTable'" + ad + ">";
        for (var ay = 0; ay < 6; ++ay) {
            aq[aw++] = "<tr class='DynarchCalendar-week";
            if (ay == 0) {
                aq[aw++] = " DynarchCalendar-first-row"
            }
            if (ay == 5) {
                aq[aw++] = " DynarchCalendar-last-row"
            }
            aq[aw++] = "'>";
            if (D) {
                aq[aw++] = "<td class='DynarchCalendar-first-col'><div class='DynarchCalendar-weekNumber'>" + a(aC) + "</div></td>"
            }
            for (var ax = 0; ax < 7; ++ax) {
                var aB = aC.getDate(),
                    au = aC.getMonth(),
                    ap = aC.getFullYear(),
                    an = 10000 * ap + 100 * (au + 1) + aB,
                    aD = ar.selection.isSelected(an),
                    at = ar.isDisabled(aC);
                aq[aw++] = "<td class='";
                if (ax == 0 && !D) {
                    aq[aw++] = " DynarchCalendar-first-col"
                }
                if (ax == 0 && ay == 0) {
                    ar._firstDateVisible = an
                }
                if (ax == 6) {
                    aq[aw++] = " DynarchCalendar-last-col";
                    if (ay == 5) {
                        ar._lastDateVisible = an
                    }
                }
                if (aD) {
                    aq[aw++] = " DynarchCalendar-td-selected"
                }
                aq[aw++] = "'><div dyc-type='date' unselectable='on' dyc-date='" + an + "' ";
                if (at) {
                    aq[aw++] = "disabled='1' "
                }
                aq[aw++] = "class='DynarchCalendar-day";
                if (am("weekend").indexOf(aC.getDay()) >= 0) {
                    aq[aw++] = " DynarchCalendar-weekend"
                }
                if (au != aE) {
                    aq[aw++] = " DynarchCalendar-day-othermonth"
                }
                if (aB == ao && au == P && ap == aF) {
                    aq[aw++] = " DynarchCalendar-day-today"
                }
                if (at) {
                    aq[aw++] = " DynarchCalendar-day-disabled"
                }
                if (aD) {
                    aq[aw++] = " DynarchCalendar-day-selected"
                }
                at = ar.args.dateInfo(aC);
                if (at && at.klass) {
                    aq[aw++] = " " + at.klass
                }
                aq[aw++] = "'>" + aB + "</div></td>";
                aC.setDate(aB + 1)
            }
            aq[aw++] = "</tr>"
        }
        aq[aw++] = "</table>";
        return aq.join("")
    }

    function m(D) {
        var P = ["<table class='DynarchCalendar-topCont'", ad, "><tr><td><div class='DynarchCalendar'>", !j ? "<button class='DynarchCalendar-focusLink'></button>" : "<a class='DynarchCalendar-focusLink' href='#'></a>", "<div class='DynarchCalendar-topBar'><div dyc-type='nav' dyc-btn='-Y' dyc-cls='hover-navBtn,pressed-navBtn' class='DynarchCalendar-navBtn DynarchCalendar-prevYear'><div></div></div><div dyc-type='nav' dyc-btn='+Y' dyc-cls='hover-navBtn,pressed-navBtn' class='DynarchCalendar-navBtn DynarchCalendar-nextYear'><div></div></div><div dyc-type='nav' dyc-btn='-M' dyc-cls='hover-navBtn,pressed-navBtn' class='DynarchCalendar-navBtn DynarchCalendar-prevMonth'><div></div></div><div dyc-type='nav' dyc-btn='+M' dyc-cls='hover-navBtn,pressed-navBtn' class='DynarchCalendar-navBtn DynarchCalendar-nextMonth'><div></div></div><table class='DynarchCalendar-titleCont'", ad, "><tr><td><div dyc-type='title' dyc-btn='menu' dyc-cls='hover-title,pressed-title' class='DynarchCalendar-title'>", B(D), "</div></td></tr></table><div class='DynarchCalendar-dayNames'>", h(D), "</div></div><div class='DynarchCalendar-body'></div>"];
        if (D.args.bottomBar) {
            P.push("<div class='DynarchCalendar-bottomBar'>", E(D), "</div>")
        }
        P.push("<div class='DynarchCalendar-menu' style='display: none'>", ag(D), "</div><div class='DynarchCalendar-tooltip'></div></div></td></tr></table>");
        return P.join("")
    }

    function B(D) {
        return "<div unselectable='on'>" + X(D.date, D.args.titleFormat) + "</div>"
    }

    function ag(P) {
        var ap = ["<table height='100%'", ad, "><tr><td><table style='margin-top: 1.5em'", ad, "><tr><td colspan='3'><input dyc-btn='year' class='DynarchCalendar-menu-year' size='6' value='", P.date.getFullYear(), "' /></td></tr><tr><td><div dyc-type='menubtn' dyc-cls='hover-navBtn,pressed-navBtn' dyc-btn='today'>", am("goToday"), "</div></td></tr></table><p class='DynarchCalendar-menu-sep'>&nbsp;</p><table class='DynarchCalendar-menu-mtable'", ad, ">"],
            aq = am("smn"),
            ao = 0,
            D = ap.length,
            an;
        while (ao < 12) {
            ap[D++] = "<tr>";
            for (an = 4; --an > 0;) {
                ap[D++] = "<td><div dyc-type='menubtn' dyc-cls='hover-navBtn,pressed-navBtn' dyc-btn='m" + ao + "' class='DynarchCalendar-menu-month'>" + aq[ao++] + "</div></td>"
            }
            ap[D++] = "</tr>"
        }
        ap[D++] = "</table></td></tr></table>";
        return ap.join("")
    }

    function E(D) {
        return "<table" + ad + "><tr><td><div dyc-btn='today' dyc-cls='hover-bottomBar-today,pressed-bottomBar-today' dyc-type='bottomBar-today' class='DynarchCalendar-bottomBar-today'>" + am("today") + "</div></td></tr></table>"
    }
    var p = {
        "DynarchCalendar-topCont": "topCont",
        "DynarchCalendar-focusLink": "focusLink",
        DynarchCalendar: "main",
        "DynarchCalendar-topBar": "topBar",
        "DynarchCalendar-title": "title",
        "DynarchCalendar-dayNames": "dayNames",
        "DynarchCalendar-body": "body",
        "DynarchCalendar-menu": "menu",
        "DynarchCalendar-menu-year": "yearInput",
        "DynarchCalendar-bottomBar": "bottomBar",
        "DynarchCalendar-tooltip": "tooltip",
        "DynarchCalendar-navBtn DynarchCalendar-prevYear": "navPrevYear",
        "DynarchCalendar-navBtn DynarchCalendar-nextYear": "navNextYear",
        "DynarchCalendar-navBtn DynarchCalendar-prevMonth": "navPrevMonth",
        "DynarchCalendar-navBtn DynarchCalendar-nextMonth": "navNextMonth"
    };

    function H() {
        var an = C("div"),
            P = this.els = {},
            D = {
            mousedown: t(F, this, true),
            mouseup: t(F, this, false),
            mouseover: t(O, this, true),
            mouseout: t(O, this, false),
            keypress: t(I, this)
        };
        D[u ? "DOMMouseScroll" : "mousewheel"] = t(A, this);
        if (j) {
            D.dblclick = D.mousedown;
            D.keydown = D.keypress
        }
        an.innerHTML = m(this);
        r(an.firstChild, function (ap) {
            var ao = p[ap.className];
            if (ao) {
                P[ao] = ap
            }
            if (j) {
                ap.setAttribute("unselectable", "on")
            }
        });
        o(P.main, D);
        o([P.focusLink, P.yearInput], this._focusEvents = {
            focus: t(i, this),
            blur: t(e, this)
        });
        this.moveTo(this.date, false);
        return P.topCont
    }

    function i() {
        if (this._bluringTimeout) {
            clearTimeout(this._bluringTimeout)
        }
        this.focused = true;
        J(this.els.main, "DynarchCalendar-focused")
    }

    function w() {
        this.focused = false;
        af(this.els.main, "DynarchCalendar-focused");
        if (this._menuVisible) {
            s(this, false)
        }
        if (!this.args.cont) {
            this.hide()
        }
    }

    function e() {
        this._bluringTimeout = setTimeout(t(w, this), 50)
    }
    var Q = {
        "-3": "backYear",
        "-2": "back",
        "0": "now",
        "2": "fwd",
        "3": "fwdYear"
    };

    function W(P, ao, D) {
        if (this._bodyAnim) {
            this._bodyAnim.stop()
        }
        var an;
        if (ao != 0) {
            an = new Date(P.date);
            an.setDate(1);
            switch (ao) {
            case "-Y":
            case -2:
                an.setFullYear(an.getFullYear() - 1);
                break;
            case "+Y":
            case 2:
                an.setFullYear(an.getFullYear() + 1);
                break;
            case "-M":
            case -1:
                an.setMonth(an.getMonth() - 1);
                break;
            case "+M":
            case 1:
                an.setMonth(an.getMonth() + 1);
                break
            }
        } else {
            an = new Date()
        }
        return P.moveTo(an, !D)
    }

    function s(an, P) {
        an._menuVisible = P;
        aa(P, an.els.title, "DynarchCalendar-pressed-title");
        var ao = an.els.menu;
        if (c) {
            ao.style.height = an.els.main.offsetHeight + "px"
        }
        if (!an.args.animation) {
            K(ao, P);
            if (an.focused) {
                an.focus()
            }
        } else {
            if (an._menuAnim) {
                an._menuAnim.stop()
            }
            var D = an.els.main.offsetHeight;
            if (c) {
                ao.style.width = an.els.topBar.offsetWidth + "px"
            }
            if (P) {
                ao.firstChild.style.marginTop = -D + "px";
                an.args.opacity > 0 && ai(ao, 0);
                K(ao, true)
            }
            an._menuAnim = al({
                onUpdate: function (ap, aq) {
                    ao.firstChild.style.marginTop = aq(V.accel_b(ap), -D, 0, !P) + "px";
                    an.args.opacity > 0 && ai(ao, aq(V.accel_b(ap), 0, 0.85, !P))
                },
                onStop: function () {
                    an.args.opacity > 0 && ai(ao, 0.85);
                    ao.firstChild.style.marginTop = "";
                    an._menuAnim = null;
                    if (!P) {
                        K(ao, false);
                        if (an.focused) {
                            an.focus()
                        }
                    }
                }
            })
        }
    }

    function F(au, at) {
        at = at || window.event;
        var ap = n(at);
        if (ap && !ap.getAttribute("disabled")) {
            var D = ap.getAttribute("dyc-btn"),
                aq = ap.getAttribute("dyc-date"),
                ao = this.selection,
                P, an = {
                mouseover: aj,
                mousemove: aj,
                mouseup: function (ax) {
                    var aw = ap.getAttribute("dyc-cls");
                    if (aw) {
                        af(ap, ak(aw, 1))
                    }
                    clearTimeout(P);
                    d(document, an, true);
                    an = null
                }
            };
            if (au) {
                setTimeout(t(this.focus, this), 1);
                var av = ap.getAttribute("dyc-cls");
                if (av) {
                    J(ap, ak(av, 1))
                }
                if ("menu" == D) {
                    this.toggleMenu()
                } else {
                    if (ap && /^[+-][MY]$/.test(D)) {
                        if (W(this, D)) {
                            var ar = t(function () {
                                if (W(this, D, true)) {
                                    P = setTimeout(ar, 40)
                                } else {
                                    an.mouseup();
                                    W(this, D)
                                }
                            },
                            this);
                            P = setTimeout(ar, 350);
                            o(document, an, true)
                        } else {
                            an.mouseup()
                        }
                    } else {
                        if ("year" == D) {
                            this.els.yearInput.focus();
                            this.els.yearInput.select()
                        } else {
                            if (aq) {
                                if (ao.type == v.SEL_MULTIPLE) {
                                    if (at.shiftKey && this._selRangeStart) {
                                        ao.selectRange(this._selRangeStart, aq)
                                    } else {
                                        if (!at.ctrlKey && !ao.isSelected(aq)) {
                                            ao.clear(true)
                                        }
                                        ao.set(aq, true);
                                        this._selRangeStart = aq
                                    }
                                } else {
                                    ao.set(aq);
                                    this.moveTo(y(aq), 2)
                                }
                                ap = this._getDateDiv(aq);
                                O.call(this, true, {
                                    target: ap
                                })
                            }
                            o(document, an, true)
                        }
                    }
                }
                if (j && an && /dbl/i.test(at.type)) {
                    an.mouseup()
                }
                if (/^(DynarchCalendar-(topBar|bottomBar|weekend|weekNumber|menu(-sep)?))?$/.test(ap.className) && !this.args.cont) {
                    an.mousemove = t(g, this);
                    this._mouseDiff = f(at, G(this.els.topCont));
                    o(document, an, true)
                }
            } else {
                if ("today" == D) {
                    if (!this._menuVisible && ao.type == v.SEL_SINGLE) {
                        ao.set(new Date())
                    }
                    this.moveTo(new Date(), true);
                    s(this, false)
                } else {
                    if (/^m([0-9]+)/.test(D)) {
                        var aq = new Date(this.date);
                        aq.setDate(1);
                        aq.setMonth(RegExp.$1);
                        aq.setFullYear(this._getInputYear());
                        this.moveTo(aq, true);
                        s(this, false)
                    }
                }
            }
            if (!j) {
                aj(at)
            }
        }
    }

    function g(P) {
        P = P || window.event;
        var D = this.els.topCont.style,
            an = f(P, this._mouseDiff);
        D.left = an.x + "px";
        D.top = an.y + "px"
    }

    function n(P) {
        var D = P.target || P.srcElement,
            an = D;
        while (D && D.getAttribute && !D.getAttribute("dyc-type")) {
            D = D.parentNode
        }
        return D.getAttribute && D || an
    }

    function ak(D, P) {
        return "DynarchCalendar-" + D.split(/,/)[P]
    }

    function O(ap, ao) {
        ao = ao || window.event;
        var an = n(ao);
        if (an) {
            var P = an.getAttribute("dyc-type");
            if (P && !an.getAttribute("disabled")) {
                if (!ap || !this._bodyAnim || P != "date") {
                    var D = an.getAttribute("dyc-cls");
                    D = D ? ak(D, 0) : "DynarchCalendar-hover-" + P;
                    aa(ap, an, D);
                    if (P == "date") {
                        aa(ap, an.parentNode.parentNode, "DynarchCalendar-hover-week");
                        this._showTooltip(an.getAttribute("dyc-date"))
                    }
                    af(this._getDateDiv(this._lastHoverDate), "DynarchCalendar-hover-date");
                    this._lastHoverDate = null
                }
            }
        }
        if (!ap) {
            this._showTooltip()
        }
    }

    function A(P) {
        P = P || window.event;
        var D = n(P);
        if (D) {
            var an = D.getAttribute("dyc-btn"),
                ao = P.wheelDelta ? P.wheelDelta / 120 : -P.detail / 3;
            ao = ao < 0 ? -1 : ao > 0 ? 1 : 0;
            if (this.args.reverseWheel) {
                ao = -ao
            }
            if (/Y/i.test(an)) {
                ao *= 2
            }
            W(this, -ao);
            aj(P)
        }
    }

    function M() {
        this.refresh();
        var D = S(this.args.inputField),
            P = this.selection;
        if (D) {
            var an = P.print(this.args.dateFormat);
            (/input|textarea/i.test(D.tagName)) ? D.value = an : D.innerHTML = an
        }
        this.callHooks("onSelect", this, P)
    }
    var ac = {
        37: -1,
        38: -2,
        39: 1,
        40: 2
    },
        L = {
        33: -1,
        34: 1
    };

    function I(ax) {
        if (this._menuAnim) {
            return
        }
        ax = ax || window.event;
        var an = ax.target || ax.srcElement,
            ay = an.getAttribute("dyc-btn"),
            az = ax.keyCode,
            au = ax.charCode || az,
            D = ac[az];
        if ("year" == ay && az == 13) {
            var ap = new Date(this.date);
            ap.setDate(1);
            ap.setFullYear(this._getInputYear());
            this.moveTo(ap, true);
            s(this, false);
            return aj(ax)
        }
        if (this._menuVisible) {
            if (az == 27) {
                s(this, false);
                return aj(ax)
            }
        } else {
            if (!ax.ctrlKey) {
                D = null
            }
            if (D == null && !ax.ctrlKey) {
                D = L[az]
            }
            if (az == 36) {
                D = 0
            }
            if (D != null) {
                W(this, D);
                return aj(ax)
            }
            au = String.fromCharCode(au).toLowerCase();
            var at = this.els.yearInput,
                P = this.selection;
            if (au == " ") {
                s(this, true);
                this.focus();
                at.focus();
                at.select();
                return aj(ax)
            }
            if (au >= "0" && au <= "9") {
                s(this, true);
                this.focus();
                at.value = au;
                at.focus();
                return aj(ax)
            }
            var aq = am("mn"),
                av = ax.shiftKey ? -1 : this.date.getMonth(),
            ar = 0,
            ao;
            while (++ar < 12) {
                ao = aq[(av + ar) % 12].toLowerCase();
                if (ao.indexOf(au) == 0) {
                    var ap = new Date(this.date);
                    ap.setDate(1);
                    ap.setMonth((av + ar) % 12);
                    this.moveTo(ap, true);
                    return aj(ax)
                }
            }
            if (az >= 37 && az <= 40) {
                var ap = this._lastHoverDate;
                if (!ap && !P.isEmpty()) {
                    ap = az < 39 ? P.getFirstDate() : P.getLastDate();
                    if (ap < this._firstDateVisible || ap > this._lastDateVisible) {
                        ap = null
                    }
                }
                if (!ap) {
                    ap = az < 39 ? this._lastDateVisible : this._firstDateVisible
                } else {
                    var aw = ap;
                    ap = y(ap);
                    var av = 100;
                    while (av -->
                    0) {
                        switch (az) {
                        case 37:
                            ap.setDate(ap.getDate() - 1);
                            break;
                        case 38:
                            ap.setDate(ap.getDate() - 7);
                            break;
                        case 39:
                            ap.setDate(ap.getDate() + 1);
                            break;
                        case 40:
                            ap.setDate(ap.getDate() + 7);
                            break
                        }
                        if (!this.isDisabled(ap)) {
                            break
                        }
                    }
                    ap = R(ap);
                    if (ap < this._firstDateVisible || ap > this._lastDateVisible) {
                        this.moveTo(ap)
                    }
                }
                af(this._getDateDiv(aw), J(this._getDateDiv(ap), "DynarchCalendar-hover-date"));
                this._lastHoverDate = ap;
                return aj(ax)
            }
            if (az == 13) {
                if (this._lastHoverDate) {
                    if (P.type == v.SEL_MULTIPLE && (ax.shiftKey || ax.ctrlKey)) {
                        if (ax.shiftKey && this._selRangeStart) {
                            P.clear(true);
                            P.selectRange(this._selRangeStart, this._lastHoverDate)
                        }
                        if (ax.ctrlKey) {
                            P.set(this._selRangeStart = this._lastHoverDate, true)
                        }
                    } else {
                        P.reset(this._selRangeStart = this._lastHoverDate)
                    }
                    return aj(ax)
                }
            }
            if (az == 27 && !this.args.cont) {
                this.hide()
            }
        }
    }
    l._getDateDiv = function (D) {
        var an = null;
        if (D) {
            try {
                r(this.els.body, function (ao) {
                    if (ao.getAttribute("dyc-date") == D) {
                        throw an = ao
                    }
                })
            } catch(P) {}
        }
        return an
    };

    function k(D, P) {
        return D.replace(/\$\{([^:\}]+)(:[^\}]+)?\}/g, function (aq, ap, ao) {
            var ar = P[ap],
                an;
            if (ao) {
                an = ao.substr(1).split(/\s*\|\s*/);
                ar = (ar >= an.length ? an[an.length - 1] : an[ar]).replace(/##?/g, function (at) {
                    return at.length == 2 ? "#" : ar
                })
            }
            return ar
        })
    }

    function am(an, P) {
        var D = I18N.__.data[an];
        if (P && typeof D == "string") {
            D = k(D, P)
        }
        return D
    } (v.Selection = function (an, P, D) {
        this.type = P;
        this.sel = an instanceof Array ? an : [an];
        this.onChange = D
    }).prototype = {
        get: function () {
            return this.type == v.SEL_SINGLE ? this.sel[0] : this.sel
        },
        isEmpty: function () {
            return this.sel.length == 0
        },
        set: function (P, D) {
            var an = this.type == v.SEL_SINGLE;
            if (P instanceof Array) {
                this.sel = P;
                this.normalize();
                this.onChange(this)
            } else {
                P = R(P);
                if (an || !this.isSelected(P)) {
                    an ? this.sel = [P] : this.sel.splice(this.findInsertPos(P), 0, P);
                    this.normalize();
                    this.onChange(this)
                } else {
                    if (D) {
                        this.unselect(P)
                    }
                }
            }
        },
        reset: function () {
            this.sel = [];
            this.set.apply(this, arguments)
        },
        countDays: function () {
            var aq = 0,
                D = this.sel,
                P = D.length,
                ao, ap, an;
            while (--P >= 0) {
                ao = D[P];
                if (ao instanceof Array) {
                    ap = y(ao[0]);
                    an = y(ao[1]);
                    aq += Math.round(Math.abs(an.getTime() - ap.getTime()) / 86400000)
                }++aq
            }
            return aq
        },
        unselect: function (P) {
            P = R(P);
            var at = false;
            for (var D = this.sel, ao = D.length, aq; --ao >= 0;) {
                aq = D[ao];
                if (aq instanceof Array) {
                    if (P >= aq[0] && P <= aq[1]) {
                        var an = y(P),
                            ar = an.getDate();
                        if (P == aq[0]) {
                            an.setDate(ar + 1);
                            aq[0] = R(an);
                            at = true
                        } else {
                            if (P == aq[1]) {
                                an.setDate(ar - 1);
                                aq[1] = R(an);
                                at = true
                            } else {
                                var ap = new Date(an);
                                ap.setDate(ar + 1);
                                an.setDate(ar - 1);
                                D.splice(ao + 1, 0, [R(ap), aq[1]]);
                                aq[1] = R(an);
                                at = true
                            }
                        }
                    }
                } else {
                    if (P == aq) {
                        D.splice(ao, 1);
                        at = true
                    }
                }
            }
            if (at) {
                this.normalize();
                this.onChange(this)
            }
        },
        normalize: function () {
            this.sel = this.sel.sort(function (au, at) {
                if (au instanceof Array) {
                    au = au[0]
                }
                if (at instanceof Array) {
                    at = at[0]
                }
                return au - at
            });
            for (var P = this.sel, an = P.length, aq, ap; --an >= 0;) {
                aq = P[an];
                if (aq instanceof Array) {
                    if (aq[0] > aq[1]) {
                        P.splice(an, 1);
                        continue
                    }
                    if (aq[0] == aq[1]) {
                        aq = P[an] = aq[0]
                    }
                }
                if (ap) {
                    var ao = ap,
                        ar = aq instanceof Array ? aq[1] : aq;
                    ar = y(ar);
                    ar.setDate(ar.getDate() + 1);
                    ar = R(ar);
                    if (ar >= ao) {
                        var D = P[an + 1];
                        if (aq instanceof Array && D instanceof Array) {
                            aq[1] = D[1];
                            P.splice(an + 1, 1)
                        } else {
                            if (aq instanceof Array) {
                                aq[1] = ap;
                                P.splice(an + 1, 1)
                            } else {
                                if (D instanceof Array) {
                                    D[0] = aq;
                                    P.splice(an, 1)
                                } else {
                                    P[an] = [aq, D];
                                    P.splice(an + 1, 1)
                                }
                            }
                        }
                    }
                }
                ap = aq instanceof Array ? aq[0] : aq
            }
        },
        findInsertPos: function (P) {
            for (var D = this.sel, an = D.length, ao; --an >= 0;) {
                ao = D[an];
                if (ao instanceof Array) {
                    ao = ao[0]
                }
                if (ao <= P) {
                    break
                }
            }
            return an + 1
        },
        clear: function (D) {
            this.sel = [];
            if (!D) {
                this.onChange(this)
            }
        },
        selectRange: function (an, P) {
            an = R(an);
            P = R(P);
            if (an > P) {
                var D = an;
                an = P;
                P = D
            }
            this.sel.push([an, P]);
            this.normalize();
            this.onChange(this)
        },
        isSelected: function (D) {
            for (var P = this.sel.length, an; --P >= 0;) {
                an = this.sel[P];
                if (an instanceof Array && D >= an[0] && D <= an[1] || D == an) {
                    return true
                }
            }
            return false
        },
        getFirstDate: function () {
            var D = this.sel[0];
            if (D && D instanceof Array) {
                D = D[0]
            }
            return D
        },
        getLastDate: function () {
            if (this.sel.length > 0) {
                var D = this.sel[this.sel.length - 1];
                if (D && D instanceof Array) {
                    D = D[1]
                }
                return D
            }
        },
        print: function (P, an) {
            var D = [],
                ao = 0,
                ap;
            if (!an) {
                an = " -> "
            }
            while (ao < this.sel.length) {
                ap = this.sel[ao++];
                if (ap instanceof Array) {
                    D.push(X(y(ap[0]), P) + an + X(y(ap[1]), P))
                } else {
                    D.push(X(y(ap), P))
                }
            }
            return D
        },
        getDates: function (P) {
            var D = [],
                an = 0,
                ap, ao;
            while (an < this.sel.length) {
                ao = this.sel[an++];
                if (ao instanceof Array) {
                    ap = y(ao[0]);
                    ao = ao[1];
                    while (R(ap) < ao) {
                        D.push(P ? X(ap, P) : ap);
                        ap.setDate(ap.getDate() + 1)
                    }
                } else {
                    ap = y(ao)
                }
                D.push(P ? X(ap, P) : ap)
            }
            return D
        }
    };

    function a(P) {
        P = new Date(P.getFullYear(), P.getMonth(), P.getDate(), 12, 0, 0);
        var an = P.getDay();
        P.setDate(P.getDate() - (an + 6) % 7 + 3);
        var D = P.valueOf();
        P.setMonth(0);
        P.setDate(4);
        return Math.round((D - P.valueOf()) / (7 * 86400000)) + 1
    }

    function z(D) {
        D = new Date(D.getFullYear(), D.getMonth(), D.getDate(), 0, 0, 0);
        var an = new Date(D.getFullYear(), 0, 1, 12, 0, 0);
        var P = D - an;
        return Math.floor(P / 86400000)
    }

    function R(D) {
        if (D instanceof Date) {
            return 10000 * D.getFullYear() + 100 * (D.getMonth() + 1) + D.getDate()
        }
        if (typeof D == "string") {
            return parseInt(D, 10)
        }
        return D
    }

    function y(P) {
        if (! (P instanceof Date)) {
            P = parseInt(P);
            var an = Math.floor(P / 10000);
            P = P % 10000;
            var D = Math.floor(P / 100);
            P = P % 100;
            P = new Date(an, D - 1, P, 12, 0, 0, 0)
        }
        return P
    }

    function ab(ar, ap, an) {
        var aq = ar.getFullYear(),
            au = ar.getMonth(),
            P = ar.getDate(),
            ao = ap.getFullYear(),
            at = ap.getMonth(),
            D = ap.getDate();
        return aq < ao ? -3 : aq > ao ? 3 : au < at ? -2 : au > at ? 2 : an ? 0 : P < D ? -1 : P > D ? 1 : 0
    }

    function X(D, at) {
        var P = D.getMonth(),
            ar = D.getDate(),
            au = D.getFullYear(),
            av = a(D),
            aw = D.getDay(),
            ax = D.getHours(),
            an = (ax >= 12),
            ap = (an) ? (ax - 12) : ax,
        az = z(D),
        ao = D.getMinutes(),
        aq = D.getSeconds(),
        ay = /%./g,
        aA;
        if (ap === 0) {
            ap = 12
        }
        aA = {
            "%a": am("sdn")[aw],
            "%A": am("dn")[aw],
            "%b": am("smn")[P],
            "%B": am("mn")[P],
            "%C": 1 + Math.floor(au / 100),
            "%d": ar < 10 ? "0" + ar : ar,
            "%e": ar,
            "%H": ax < 10 ? "0" + ax : ax,
            "%I": ap < 10 ? "0" + ap : ap,
            "%j": az < 10 ? "00" + az : az < 100 ? "0" + az : az,
            "%k": ax,
            "%l": ap,
            "%m": P < 9 ? "0" + (1 + P) : 1 + P,
            "%o": 1 + P,
            "%M": ao < 10 ? "0" + ao : ao,
            "%n": "\n",
            "%p": an ? "PM" : "AM",
            "%P": an ? "pm" : "am",
            "%s": Math.floor(D.getTime() / 1000),
            "%S": aq < 10 ? "0" + aq : aq,
            "%t": "\t",
            "%U": av < 10 ? "0" + av : av,
            "%W": av < 10 ? "0" + av : av,
            "%V": av < 10 ? "0" + av : av,
            "%u": aw + 1,
            "%w": aw,
            "%y": ("" + au).substr(2, 2),
            "%Y": au,
            "%%": "%"
        };
        return at.replace(ay, function (aB) {
            return aA.hasOwnProperty(aB) ? aA[aB] : aB
        })
    }

    function U(P) {
        if (P) {
            if (typeof P == "number") {
                return y(P)
            }
            if (! (P instanceof Date)) {
                var D = P.split(/-/);
                return new Date(parseInt(D[0], 10), parseInt(D[1], 10) - 1, parseInt(D[2], 10), 12, 0, 0, 0)
            }
        }
        return P
    }

    function x(an) {
        an = an.toLowerCase();

        function P(ao) {
            for (var ap = ao.length; --ap >= 0;) {
                if (ao[ap].toLowerCase().indexOf(an) == 0) {
                    return ap
                }
            }
        }
        var D = P(am("smn")) || P(am("mn"));
        if (D != null) {
            D++
        }
        return D
    }
    v.parseDate = function (ap, D, ar) {
        if (!/\S/.test(ap)) {
            return ""
        }
        ap = ap.replace(/^\s+/, "").replace(/\s+$/, "");
        ar = ar || new Date();
        var ax = null,
            P = null,
            az = null,
            aq = null,
            an = null,
            ay = null;
        var au = ap.match(/([0-9]{1,2}):([0-9]{1,2})(:[0-9]{1,2})?\s*(am|pm)?/i);
        if (au) {
            aq = parseInt(au[1], 10);
            an = parseInt(au[2], 10);
            ay = au[3] ? parseInt(au[3].substr(1), 10) : 0;
            ap = ap.substring(0, au.index) + ap.substr(au.index + au[0].length);
            if (au[4]) {
                if (au[4].toLowerCase() == "pm" && aq < 12) {
                    aq += 12
                } else {
                    if (au[4].toLowerCase() == "am" && aq >= 12) {
                        aq -= 12
                    }
                }
            }
        }
        var av = ap.split(/\W+/);
        var at = [];
        for (var ao = 0; ao < av.length; ++ao) {
            var aw = av[ao];
            if (/^[0-9]{4}$/.test(aw)) {
                ax = parseInt(aw, 10);
                if (!P && !az) {
                    D = true
                }
            } else {
                if (/^[0-9]{1,2}$/.test(aw)) {
                    aw = parseInt(aw, 10);
                    if (aw >= 60) {
                        ax = aw
                    } else {
                        if (aw >= 0 && aw <= 12) {
                            at.push(aw)
                        } else {
                            if (aw >= 1 && aw <= 31) {
                                az = aw
                            }
                        }
                    }
                } else {
                    P = x(aw)
                }
            }
        }
        if (at.length >= 2) {
            if (D) {
                if (!P) {
                    P = at.shift()
                }
                if (!az) {
                    az = at.shift()
                }
            } else {
                if (!az) {
                    az = at.shift()
                }
                if (!P) {
                    P = at.shift()
                }
            }
        } else {
            if (at.length == 1) {
                if (!az) {
                    az = at.shift()
                } else {
                    if (!P) {
                        P = at.shift()
                    }
                }
            }
        }
        if (!ax) {
            ax = at.length > 0 ? at.shift() : ar.getFullYear()
        }
        if (ax < 30) {
            ax += 2000
        } else {
            if (ax < 99) {
                ax += 1900
            }
        }
        if (!P) {
            P = ar.getMonth() + 1
        }
        return ax && P && az ? new Date(ax, P - 1, az, aq, an, ay) : null
    };

    function ah(D, ao, P, an) {
        an = {};
        for (P in ao) {
            if (ao.hasOwnProperty(P)) {
                an[P] = ao[P]
            }
        }
        for (P in D) {
            if (D.hasOwnProperty(P)) {
                an[P] = D[P]
            }
        }
        return an
    }

    function o(an, ap, ao, D) {
        if (an instanceof Array) {
            for (var P = an.length; --P >= 0;) {
                o(an[P], ap, ao, D)
            }
        } else {
            if (typeof ap == "object") {
                for (var P in ap) {
                    if (ap.hasOwnProperty(P)) {
                        o(an, P, ap[P], ao)
                    }
                }
            } else {
                if (an.addEventListener) {
                    an.addEventListener(ap, ao, j ? true : !!D)
                } else {
                    if (an.attachEvent) {
                        an.attachEvent("on" + ap, ao)
                    } else {
                        an["on" + ap] = ao
                    }
                }
            }
        }
    }

    function d(an, ap, ao, D) {
        if (an instanceof Array) {
            for (var P = an.length; --P >= 0;) {
                d(an[P], ap, ao)
            }
        } else {
            if (typeof ap == "object") {
                for (var P in ap) {
                    if (ap.hasOwnProperty(P)) {
                        d(an, P, ap[P], ao)
                    }
                }
            } else {
                if (an.removeEventListener) {
                    an.removeEventListener(ap, ao, j ? true : !!D)
                } else {
                    if (an.detachEvent) {
                        an.detachEvent("on" + ap, ao)
                    } else {
                        an["on" + ap] = null
                    }
                }
            }
        }
    }

    function aj(D) {
        D = D || window.event;
        if (j) {
            D.cancelBubble = true;
            D.returnValue = false
        } else {
            D.preventDefault();
            D.stopPropagation()
        }
        return false
    }

    function af(ap, ao, aq) {
        if (ap) {
            var D = ap.className.replace(/^\s+|\s+$/, "").split(/\x20/),
                P = [],
                an;
            for (an = D.length; an > 0;) {
                if (D[--an] != ao) {
                    P.push(D[an])
                }
            }
            if (aq) {
                P.push(aq)
            }
            ap.className = P.join(" ")
        }
        return aq
    }

    function J(P, D) {
        return af(P, D, D)
    }

    function aa(ao, an, P) {
        if (an instanceof Array) {
            for (var D = an.length; --D >= 0;) {
                aa(ao, an[D], P)
            }
        } else {
            af(an, P, ao ? P : null)
        }
        return ao
    }

    function C(ao, D, an) {
        var P = null;
        if (document.createElementNS) {
            P = document.createElementNS("http://www.w3.org/1999/xhtml", ao)
        } else {
            P = document.createElement(ao)
        }
        if (D) {
            P.className = D
        }
        if (an) {
            an.appendChild(P)
        }
        return P
    }

    function b(ap, aq) {
        if (aq == null) {
            aq = 0
        }
        var D, ao, P;
        try {
            D = Array.prototype.slice.call(ap, aq)
        } catch(an) {
            D = new Array(ap.length - aq);
            for (ao = aq, P = 0; ao < ap.length; ++ao, ++P) {
                D[P] = ap[ao]
            }
        }
        return D
    }

    function t(P, an) {
        var D = b(arguments, 2);
        return (an == undefined ?
        function () {
            return P.apply(this, D.concat(b(arguments)))
        } : function () {
            return P.apply(an, D.concat(b(arguments)))
        })
    }

    function r(P, an) {
        if (!an(P)) {
            for (var D = P.firstChild; D; D = D.nextSibling) {
                if (D.nodeType == 1) {
                    r(D, an)
                }
            }
        }
    }

    function al(D, ar, an) {
        D = ah(D, {
            fps: 50,
            len: 15,
            onUpdate: Z,
            onStop: Z
        });
        if (j) {
            D.len = Math.round(D.len / 2)
        }

        function ao(aw, av, at, au) {
            return au ? at + aw * (av - at) : av + aw * (at - av)
        }

        function aq() {
            if (ar) {
                P()
            }
            an = 0;
            ar = setInterval(ap, 1000 / D.fps)
        }

        function P() {
            if (ar) {
                clearInterval(ar);
                ar = null
            }
            D.onStop(an / D.len, ao)
        }

        function ap() {
            var at = D.len;
            D.onUpdate(an / at, ao);
            if (an == at) {
                P()
            }++an
        }
        aq();
        return {
            start: aq,
            stop: P,
            update: ap,
            args: D,
            map: ao
        }
    }
    var V = {
        elastic_b: function (D) {
            return 1 - Math.cos(-D * 5.5 * Math.PI) / Math.pow(2, 7 * D)
        },
        magnetic: function (D) {
            return 1 - Math.cos(D * D * D * 10.5 * Math.PI) / Math.exp(4 * D)
        },
        accel_b: function (D) {
            D = 1 - D;
            return 1 - D * D * D * D
        },
        accel_a: function (D) {
            return D * D * D
        },
        accel_ab: function (D) {
            D = 1 - D;
            return 1 - Math.sin(D * D * Math.PI / 2)
        },
        accel_ab2: function (D) {
            return (D /= 0.5) < 1 ? 1 / 2 * D * D : -1 / 2 * ((--D) * (D - 2) - 1)
        },
        brakes: function (D) {
            D = 1 - D;
            return 1 - Math.sin(D * D * Math.PI)
        },
        shake: function (D) {
            return D < 0.5 ? -Math.cos(D * 11 * Math.PI) * D * D : (D = 1 - D, Math.cos(D * 11 * Math.PI) * D * D)
        }
    };

    function ai(D, P) {
        if (P === "") {
            j ? D.style.filter = "" : D.style.opacity = ""
        } else {
            if (P != null) {
                j ? D.style.filter = "alpha(opacity=" + P * 100 + ")" : D.style.opacity = P
            } else {
                if (!j) {
                    P = parseFloat(D.style.opacity)
                } else {
                    if (/alpha\(opacity=([0-9.])+\)/.test(D.style.opacity)) {
                        P = parseFloat(RegExp.$1) / 100
                    }
                }
            }
        }
        return P
    }

    function K(an, D) {
        var P = an.style;
        if (D != null) {
            P.display = D ? "" : "none"
        }
        return P.display != "none"
    }

    function f(P, an) {
        var D = j ? P.clientX + document.body.scrollLeft : P.pageX;
        var ao = j ? P.clientY + document.body.scrollTop : P.pageY;
        if (an) {
            D -= an.x;
            ao -= an.y
        }
        return {
            x: D,
            y: ao
        }
    }

    function G(ap) {
        var D = 0,
            ao = 0,
            an = /^div$/i.test(ap.tagName),
            aq, P;
        if (an && ap.scrollLeft) {
            D = ap.scrollLeft
        }
        if (an && ap.scrollTop) {
            ao = ap.scrollTop
        }
        aq = {
            x: ap.offsetLeft - D,
            y: ap.offsetTop - ao
        };
        if (ap.offsetParent) {
            P = G(ap.offsetParent);
            aq.x += P.x;
            aq.y += P.y
        }
        return aq
    }

    function T() {
        var P = document.documentElement,
            D = document.body;
        return {
            x: P.scrollLeft || D.scrollLeft,
            y: P.scrollTop || D.scrollTop,
            w: P.clientWidth || window.innerWidth || D.clientWidth,
            h: P.clientHeight || window.innerHeight || D.clientHeight
        }
    }
    var Z = new Function();

    function S(D) {
        if (typeof D == "string") {
            D = document.getElementById(D)
        }
        return D
    }
    return v
})();
