﻿/// <reference name="MicrosoftAjax.debug.js" />
/// <reference name="AjaxControlToolkit.Compat.Timer.Timer.js" assembly="AjaxControlToolkit" />
Type.registerNamespace('Pacem.UI');

/*  ======================================
ENUMS & CONSTS 
=====================================   */
Pacem.UI.TweenStatus = function() { };
Pacem.UI.TweenStatus.prototype = {
    playing: 0,
    paused: 1,
    stopped: 2,
    finished: 3
}
Pacem.UI.TweenStatus.registerEnum("Pacem.UI.TweenStatus");

Pacem.UI.TweenFinishedBehavior = function() { };
Pacem.UI.TweenFinishedBehavior.prototype = {
    none: 0,
    yoyo: 1,
    loop: 2
}
Pacem.UI.TweenFinishedBehavior.registerEnum("Pacem.UI.TweenFinishedBehavior");

Pacem.UI.TweenType = function() { };
Pacem.UI.TweenType.prototype = {
    double: 0,
    int: 1,
    color: 2
}
Pacem.UI.TweenType.registerEnum("Pacem.UI.TweenType");

//Pacem.UI.Unit = function() { };
Pacem.UI.Unit/*.prototype*/ = {
    pixels: 'px',
    points: 'pt',
    picas: 'pc',
    percentage: '%',
    centimeters: 'cm',
    millimeters: 'mm',
    inches: 'in',
    emSpace: 'em',
    xSpace: 'ex',
    none: ''
}
//Pacem.UI.Unit.registerClass("Pacem.UI.Unit");
/*  ======================================
TWEENER 
=====================================   */
// tweener
Pacem.UI.Tween = function(element) {
    Pacem.UI.Tween.initializeBase(this, [element]);
    //
    this._obj = null;
    this._prop = null;
    this._start = null;
    this._finish = null;
    this._easingFunc = null;
    this._duration = 1.0;
    this._delay = .0;
    this._fps = 1.0 / 25;
    this._unit = null;
    this._type = null;
    this._finishedBehavior = Pacem.UI.TweenFinishedBehavior.none;
    // private/readonly
    this._status = Pacem.UI.TweenStatus.playing;
    this._started = false;
    this._elapsed = .0;
    this._current = null;
    this._tickHandler = null;
    this._timer = null;
    this._isCssProperty = false;
    this._autoPlay = true;
}
Pacem.UI.Tween.prototype = {
    initialize: function() {
        Pacem.UI.Tween.callBaseMethod(this, 'initialize');
        //
        this._obj = this._isCssProperty ? this.get_element()["style"] : this.get_element();
        if (this._easingFunc == null)
            this._easingFunc = Pacem.UI.Easing.Linear.easeNone;
        if (this._unit == null)
            this._unit = Pacem.UI.Unit.none;
        if (this._type == null)
            this._type = Pacem.UI.TweenType.double;
        // register tween
        this._tickHandler = Function.createDelegate(this, this._onTick);
        this._timer = new Sys.Timer();
        this._timer.add_tick(this._tickHandler);
        if (!this._autoPlay)
            this._status = Pacem.UI.TweenStatus.stopped;
        //
        this._refreshTicker();
    },

    dispose: function() {
        this._stopTicker();
        this._timer.remove_tick(this._tickHandler);
        this._timer.dispose();

        // unregister tween
        Pacem.UI.Tween.callBaseMethod(this, 'dispose');
    },

    // properties
    get_object: function() {
        return this._obj;
    },
    get_property: function() {
        return this._prop;
    },
    set_property: function(v) {
        this._prop = v;
    },
    get_isCssProperty: function() {
        return this._isCssProperty;
    },
    set_isCssProperty: function(v) {
        this._isCssProperty = v;
    },
    get_autoPlay: function() {
        return this._autoPlay;
    },
    set_autoPlay: function(v) {
        this._autoPlay = v;
    },
    get_start: function() {
        return this._start;
    },
    set_start: function(v) {
        this._start = this._parseNumericValue(v);
    },
    get_finish: function() {
        return this._finish;
    },
    set_finish: function(v) {
        this._finish = this._parseNumericValue(v);
    },
    get_finishedBehavior: function() {
        return this._finishedBehavior;
    },
    set_finishedBehavior: function(v) {
        this._finishedBehavior = v;
    },
    get_duration: function() {
        return this._duration;
    },
    set_duration: function(v) {
        this._duration = v;
    },
    get_fps: function() {
        return this._fps;
    },
    set_fps: function(v) {
        this._fps = v;
    },
    get_delay: function() {
        return this._delay;
    },
    set_delay: function(v) {
        this._delay = v;
    },
    get_easingFunc: function() {
        return this._easingFunc;
    },
    set_easingFunc: function(v) {
        if (typeof (v) != "function")
            v = eval(v);
        this._easingFunc = v;
    },
    get_unit: function() {
        return this._unit;
    },
    set_unit: function(v) {
        this._unit = v;
    },
    get_type: function() {
        return this._type;
    },
    set_type: function(v) {
        this._type = v;
    },
    get_status: function() {
        return this._status;
    },
    // methods
    _parseNumericValue: function(v) {
        if (typeof (v) !== "number") {
            var sv = v.toString();
            if (sv.startsWith("#"))
                sv = "0x" + sv.substr(1);
            v = Number.parseInvariant(sv);
        }
        return v;
    },
    _refreshTicker: function() {
        if (this._status !== Pacem.UI.TweenStatus.playing) return;
        //this._status = Pacem.UI.TweenStatus.playing;
        var interval = parseInt(this._fps * 1000);
        this._timer.set_interval(interval);
        this._timer.set_enabled(true);
    },
    _stopTicker: function() {
        this._timer.set_enabled(false);
    },
    _checkFinishedBehavior: function() {
        switch (this._finishedBehavior) {
            case Pacem.UI.TweenFinishedBehavior.yoyo:
                var st = this._start;
                this._start = this._finish;
                this._finish = st;
                this._delay =
                this._elapsed = .0;
                this._status = Pacem.UI.TweenStatus.playing;
                this._refreshTicker();
                break;
            case Pacem.UI.TweenFinishedBehavior.loop:
                this._delay =
                this._elapsed = .0;
                this._status = Pacem.UI.TweenStatus.playing;
                this._refreshTicker();
                break;
        }
    },
    _onTick: function() {
        //alert(name);
        var tween = this;
        if (!tween._obj || tween._obj[tween._prop] == 'undefined') throw new Error("Object and/or its property cannot be resolved.");
        if (tween._status != Pacem.UI.TweenStatus.playing) return;
        tween._elapsed += tween._fps;
        if (tween._elapsed >= tween._duration + tween._delay) {
            tween._current = tween._finish;
            tween._obj[tween._prop] = tween._unit != Pacem.UI.Unit.none ? String.format("{0}{1}", tween._finish, tween._unit) : tween._finish;
            var eArgs = new Pacem.UI.MotionChangedEventArgs(tween._finish, tween._duration);
            tween.raiseMotionChanged(eArgs);
            tween._stopTicker();
            tween._status = Pacem.UI.TweenStatus.finished;
            tween._started = false;
            tween.raiseMotionFinished(Sys.EventArgs.Empty);
            tween._checkFinishedBehavior();
        } else if (tween._elapsed >= tween._delay) {
            if (!tween._started) {
                tween._started = true;
                tween.raiseMotionStarted(Sys.EventArgs.Empty);
            }
            var t = tween._elapsed - tween._delay;
            var d = tween._duration;
            if (tween._type == Pacem.UI.TweenType.color) {
                var rgb1 = tween._start;
                var rgb2 = tween._finish;
                var r1, g1, b1, r2, g2, b2;
                r1 = rgb1 >> 16 & 0xff; g1 = rgb1 >> 8 & 0xff; b1 = rgb1 & 0xff;
                r2 = rgb2 >> 16 & 0xff; g2 = rgb2 >> 8 & 0xff; b2 = rgb2 & 0xff;
                var cr = r2 - r1; var cb = b2 - b1; var cg = g2 - g1;
                var r = parseInt(tween._easingFunc(t, r1, cr, d));
                var g = parseInt(tween._easingFunc(t, g1, cg, d));
                var b = parseInt(tween._easingFunc(t, b1, cb, d));
                r = (r < 0 || isNaN(r)) ? 0 : ((r > 255) ? 255 : r);
                g = (g < 0 || isNaN(g)) ? 0 : ((g > 255) ? 255 : g);
                b = (b < 0 || isNaN(b)) ? 0 : ((b > 255) ? 255 : b);
                var red = r.toString(16);
                if (red.length < 2) red = "0" + red;
                var green = g.toString(16);
                if (green.length < 2) green = "0" + green;
                var blue = b.toString(16);
                if (blue.length < 2) blue = "0" + blue;
                var clr = parseInt("0x" + red + green + blue, 16);
                var clrV = "#" + red + green + blue;
                tween._current = clr;
                tween._obj[tween._prop] = clrV;
            } else {
                var b = tween._start;
                var c = tween._finish - tween._start;
                var val = tween._easingFunc(1.0 * t, 1.0 * b, 1.0 * c, 1.0 * d);
                if (tween._type == Pacem.UI.TweenType.int) val = parseInt(val);
                tween._current = val;
                tween._obj[tween._prop] = tween._unit != Pacem.UI.Unit.none ? String.format("{0}{1}", tween._current, tween._unit) : tween._current;
            }
            var eArgs = new Pacem.UI.MotionChangedEventArgs(tween._current, tween._elapsed);
            tween.raiseMotionChanged(eArgs);
            tween._refreshTicker();
        } else {
            tween._refreshTicker();
        }
    },
    stop: function() {
        this._stopTicker();
        this._status = Pacem.UI.TweenStatus.stopped;
        this._started = false;
        this.raiseMotionFinished(Sys.EventArgs.Empty);
    },
    pause: function() {
        this._stopTicker();
        this._status = Pacem.UI.TweenStatus.paused;
    },
    resume: function() {
        if (this._status == Pacem.UI.TweenStatus.stopped)
            this._delay =
            this._elapsed = .0;
        else if (this._status != Pacem.UI.TweenStatus.paused) return;
        this._status = Pacem.UI.TweenStatus.playing;
        this._refreshTicker();
    },
    play: function() {
        this._stopTicker();
        this._status = Pacem.UI.TweenStatus.playing;
        this._elapsed = .0;
        this._refreshTicker();
    },
    rewind: function() {
        this._stopTicker();
        this._status = Pacem.UI.TweenStatus.playing;
        this._finish = this._start;
        this._start = this._current;
        this._delay =
        this._elapsed = .0;
        this._refreshTicker();
    },
    // events
    add_motionChanged: function(handler) {
        /// <summary>
        /// Add an event handler for the motionChanged event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().addHandler('motionChanged', handler);
    },
    remove_motionChanged: function(handler) {
        /// <summary>
        /// Remove an event handler from the motionChanged event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().removeHandler('motionChanged', handler);
    },
    raiseMotionChanged: function(eventArgs) {
        /// <summary>
        /// Raise the itemOut event
        /// </summary>
        /// <param name="eventArgs" type="Pacem.UI.MotionChangedEventArgs" mayBeNull="false">
        /// Event arguments for the motionChanged event
        /// </param>
        /// <returns />
        var handler = this.get_events().getHandler('motionChanged');
        if (handler) {
            handler(this, eventArgs);
        }
    },
    add_motionFinished: function(handler) {
        /// <summary>
        /// Add an event handler for the motionFinished event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().addHandler('motionFinished', handler);
    },
    remove_motionFinished: function(handler) {
        /// <summary>
        /// Remove an event handler from the motionFinished event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().removeHandler('motionFinished', handler);
    },
    raiseMotionFinished: function(eventArgs) {
        /// <summary>
        /// Raise the itemOut event
        /// </summary>
        /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false">
        /// Event arguments for the motionFinished event
        /// </param>
        /// <returns />
        var handler = this.get_events().getHandler('motionFinished');
        if (handler) {
            handler(this, eventArgs);
        }
    },
    add_motionStarted: function(handler) {
        /// <summary>
        /// Add an event handler for the motionStarted event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().addHandler('motionStarted', handler);
    },
    remove_motionStarted: function(handler) {
        /// <summary>
        /// Remove an event handler from the motionStarted event
        /// </summary>
        /// <param name="handler" type="Function" mayBeNull="false">
        /// Event handler
        /// </param>
        /// <returns />
        this.get_events().removeHandler('motionStarted', handler);
    },
    raiseMotionStarted: function(eventArgs) {
        /// <summary>
        /// Raise the itemOut event
        /// </summary>
        /// <param name="eventArgs" type="Sys.EventArgs" mayBeNull="false">
        /// Event arguments for the motionStarted event
        /// </param>
        /// <returns />
        var handler = this.get_events().getHandler('motionStarted');
        if (handler) {
            handler(this, eventArgs);
        }
    }
}
Pacem.UI.Tween.registerClass('Pacem.UI.Tween', /*AjaxControlToolkit.BehaviorBase*/ Sys.UI.Behavior);
/*  ======================================
EVENTARGS 
=====================================   */
Pacem.UI.MotionChangedEventArgs = function(currentPosition, elapsed) {
    /// <summary>
    /// Event arguments used when the motion of a Tween has changed.
    /// </summary>
    /// <param name="currentPosition" type="Object" mayBeNull="true">
    /// current position for a property.
    /// </param>
    /// <param name="elapsed" type="Object" mayBeNull="true">
    /// elapsed time (in seconds).
    /// </param>
    Pacem.UI.MotionChangedEventArgs.initializeBase(this);
    this._currentPosition = currentPosition;
    this._elapsed = elapsed;
}
Pacem.UI.MotionChangedEventArgs.prototype = {
    get_currentPosition: function() {
        /// <value type="Object" DomElement="false" mayBeNull="true">
        /// current value for the tweened property.
        /// </value>
        return this._currentPosition;
    },
    get_elapsed: function() {
        /// <value type="Object" DomElement="false" mayBeNull="true">
        /// elapsed time (in secs).
        /// </value>
        return this._elapsed;
    }
}
Pacem.UI.MotionChangedEventArgs.registerClass('Pacem.UI.MotionChangedEventArgs', Sys.EventArgs);
/*  ======================================
EASING 
=====================================   */
Type.registerNamespace("Pacem.UI.Easing");
// easing functions
function Pacem$UI$Easing$checkArguments(args) {
    if (args == null) throw new Error("Arguments cannot be null.");
    if (args.Length < 4) throw new Error("Arguments array must be at least of length 4.");
}
// ** linear
Pacem.UI.Easing.Linear = function() { }
Pacem.UI.Easing.Linear.easeNone = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * t / d + b;
}
Pacem.UI.Easing.Linear.registerClass('Pacem.UI.Easing.Linear');
// ** quad
Pacem.UI.Easing.Quad = function() { }
Pacem.UI.Easing.Quad.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * (t /= d) * t + b;
}
Pacem.UI.Easing.Quad.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return -c * (t /= d) * (t - 2) + b;
}
Pacem.UI.Easing.Quad.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d / 2) < 1) return c / 2 * t * t + b;
    return -c / 2 * ((--t) * (t - 2) - 1) + b;
}
Pacem.UI.Easing.Quad.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Quad.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Quad.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Quad.registerClass('Pacem.UI.Easing.Quad');
// ** cubic
Pacem.UI.Easing.Cubic = function() { }
Pacem.UI.Easing.Cubic.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * (t /= d) * t * t + b;
}
Pacem.UI.Easing.Cubic.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * ((t = t / d - 1) * t * t + 1) + b;
}
Pacem.UI.Easing.Cubic.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
    return c / 2 * ((t -= 2) * t * t + 2) + b;
}
Pacem.UI.Easing.Cubic.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t, b, c, d;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Cubic.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Cubic.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Cubic.registerClass('Pacem.UI.Easing.Cubic');
// ** quart
Pacem.UI.Easing.Quart = function() { }
Pacem.UI.Easing.Quart.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * (t /= d) * t * t * t + b;
}
Pacem.UI.Easing.Quart.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return -c * ((t = t / d - 1) * t * t * t - 1) + b;
}
Pacem.UI.Easing.Quart.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
    return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
}
Pacem.UI.Easing.Quart.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Quart.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Quart.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Quart.registerClass('Pacem.UI.Easing.Quart');
// ** quint
Pacem.UI.Easing.Quint = function() { }
Pacem.UI.Easing.Quint.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * (t /= d) * t * t * t * t + b;
}
Pacem.UI.Easing.Quint.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
}
Pacem.UI.Easing.Quint.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
    return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
}
Pacem.UI.Easing.Quint.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Quint.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Quint.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Quint.registerClass('Pacem.UI.Easing.Quint');
// ** sine
Pacem.UI.Easing.Sine = function() { }
Pacem.UI.Easing.Sine.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
}
Pacem.UI.Easing.Sine.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * Math.sin(t / d * (Math.PI / 2)) + b;
}
Pacem.UI.Easing.Sine.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
}
Pacem.UI.Easing.Sine.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Sine.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Sine.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Sine.registerClass('Pacem.UI.Easing.Sine');
// ** expo
Pacem.UI.Easing.Expo = function() { }
Pacem.UI.Easing.Expo.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b - c * 0.001;
}
Pacem.UI.Easing.Expo.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return (t == d) ? b + c : c * 1.001 * (-Math.pow(2, -10 * t / d) + 1) + b;
}
Pacem.UI.Easing.Expo.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t == 0) return b;
    if (t == d) return b + c;
    if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b - c * 0.0005;
    return c / 2 * 1.0005 * (-Math.pow(2, -10 * --t) + 2) + b;
}
Pacem.UI.Easing.Expo.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Expo.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Expo.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Expo.registerClass('Pacem.UI.Easing.Expo');
// ** circ
Pacem.UI.Easing.Circ = function() { }
Pacem.UI.Easing.Circ.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
}
Pacem.UI.Easing.Circ.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
}
Pacem.UI.Easing.Circ.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
    return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
}
Pacem.UI.Easing.Circ.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Circ.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Circ.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Circ.registerClass('Pacem.UI.Easing.Circ');
// ** elastic
Pacem.UI.Easing.Elastic = function() { }
Pacem.UI.Easing.Elastic.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var a; var p; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; a = ((arguments.length < 5) ? 0 : arguments[4]); p = ((arguments.length < 6) ? 0 : arguments[5]);
    if (t == 0) return b;
    if ((t /= d) == 1) return b + c;
    if (p == 0) p = d * .3;
    if (a == 0 || a < Math.abs(c)) { a = c; s = p / 4; }
    else s = p / (2 * Math.PI) * Math.asin(c / a);
    return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
}
Pacem.UI.Easing.Elastic.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var a; var p; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; a = ((arguments.length < 5) ? 0 : arguments[4]); p = ((arguments.length < 6) ? 0 : arguments[5]);
    if (t == 0) return b; if ((t /= d) == 1) return b + c; if (p == 0) p = d * .3;
    if (a == 0 || a < Math.abs(c)) { a = c; s = p / 4; }
    else s = p / (2 * Math.PI) * Math.asin(c / a);
    return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
}
Pacem.UI.Easing.Elastic.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var a; var p; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; a = ((arguments.length < 5) ? 0 : arguments[4]); p = ((arguments.length < 6) ? 0 : arguments[5]);
    if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (p == 0) p = d * (.3 * 1.5);
    if (a == 0 || a < Math.abs(c)) { a = c; s = p / 4; }
    else s = p / (2 * Math.PI) * Math.asin(c / a);
    if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
}
Pacem.UI.Easing.Elastic.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var a; var p; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; a = ((arguments.length < 5) ? 0 : arguments[4]); p = ((arguments.length < 6) ? 0 : arguments[5]);
    if (t < d / 2) return Pacem.UI.Easing.Elastic.easeOut(t * 2, b, c / 2, d, a, p);
    return Pacem.UI.Easing.Elastic.easeIn((t * 2) - d, b + c / 2, c / 2, d, a, p);
}
Pacem.UI.Easing.Elastic.registerClass('Pacem.UI.Easing.Elastic');
// ** back
Pacem.UI.Easing.Back = function() { }
Pacem.UI.Easing.Back.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; s = ((arguments.length < 5) ? 0 : arguments[4]);
    if (s == 0) s = 1.70158;
    return c * (t /= d) * t * ((s + 1) * t - s) + b;
}
Pacem.UI.Easing.Back.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; s = ((arguments.length < 5) ? 0 : arguments[4]);
    if (s == 0) s = 1.70158;
    return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
}
Pacem.UI.Easing.Back.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; s = ((arguments.length < 5) ? 0 : arguments[4]);
    if (s == 0) s = 1.70158;
    if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
    return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
}
Pacem.UI.Easing.Back.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t; var b; var c; var d; var s;
    t = arguments[0]; b = arguments[1]; c = arguments[2]; d = arguments[3]; s = ((arguments.length < 5) ? 0 : arguments[4]);
    if (t < d / 2) return Pacem.UI.Easing.Back.easeOut(t * 2, b, c / 2, d, s);
    return Pacem.UI.Easing.Back.easeIn((t * 2) - d, b + c / 2, c / 2, d, s);
}
Pacem.UI.Easing.Back.registerClass('Pacem.UI.Easing.Back');
// ** bounce
Pacem.UI.Easing.Bounce = function() { }
Pacem.UI.Easing.Bounce.easeIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    return c - Pacem.UI.Easing.Bounce.easeOut(d - t, 0, c, d) + b;
}
Pacem.UI.Easing.Bounce.easeOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if ((t /= d) < (1 / 2.75)) {
        return c * (7.5625 * t * t) + b;
    }
    else if (t < (2 / 2.75)) {
        return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
    }
    else if (t < (2.5 / 2.75)) {
        return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
    }
    else {
        return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
    }
}
Pacem.UI.Easing.Bounce.easeInOut = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
    else return Pacem.UI.Easing.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
}
Pacem.UI.Easing.Bounce.easeOutIn = function() {
    Pacem$UI$Easing$checkArguments(arguments);
    var t = arguments[0]; var b = arguments[1]; var c = arguments[2]; var d = arguments[3];
    if (t < d / 2) return Pacem.UI.Easing.Bounce.easeOut(t * 2, b, c / 2, d);
    return Pacem.UI.Easing.Bounce.easeIn((t * 2) - d, b + c / 2, c / 2, d);
}
Pacem.UI.Easing.Bounce.registerClass('Pacem.UI.Easing.Bounce');

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();