﻿// Name:        UpdateControls.debug.js
// Assembly:    nStuff.UpdateControls
// Version:     1.0.0.0
// FileVersion: 1.0.0.0
// UpdateControls.js
// Copyright (c) Nikhil Kothari, 2007
// http://www.nikhilk.net
//
// This product's copyrights are licensed under the Creative
// Commons Attribution-ShareAlike (version 2.5).B
// http://creativecommons.org/licenses/by-sa/2.5/
//
// You are free to:
// - copy, distribute, display, and perform the work 
// - make derivative works 
// - make commercial use of the work 
// Under the following conditions:
// Attribution. You must attribute the original work in your
//              product or release.
// Share Alike. If you alter, transform, or build upon this work,
//              you may distribute the resulting work only under
//              a license identical to this one.
//

////////////////////////////////////////////////////////////////////////////////
// Atlas Additions

Type.createInterface=function(name){var intf=function(){};intf.__typeName=name;intf.__interface=true;return intf;}
Type.createEnum=function(flags,name,values){var enumeration=function(){};enumeration.prototype=values;for(var field in values){enumeration[field]=values[field];} enumeration.__typeName=name;enumeration.__enum=true;if(flags){enumeration.__flags=true;} return enumeration;}
Type.prototype.createClass = Type.prototype.registerClass;
Type.prototype.constructBase = Type.prototype.initializeBase;
Type.prototype.callBase = Type.prototype.callBaseMethod;
Type.createNamespace = Type.registerNamespace;
var Delegate=function(){}
Delegate.createClass('Delegate');Delegate.Null=function(){}
Delegate._create=function(targets){var delegate=function(){if(targets.length==2){return targets[1].apply(targets[0],arguments);} else{for(var i=0;i<targets.length;i+=2){targets[i+1].apply(targets[i],arguments);} return null;}};delegate.invoke=delegate;delegate._targets=targets;return delegate;}
Delegate.create=function(object,method){if(!object){method.invoke=method;return method;} return Delegate._create([object,method]);}
Delegate.combine=function(delegate1,delegate2){if(!delegate1){if(!delegate2._targets){return Delegate.create(null,delegate2);} return delegate2;} if(!delegate2){if(!delegate1._targets){return Delegate.create(null,delegate1);} return delegate1;} var targets1=delegate1._targets?delegate1._targets:[null,delegate1];var targets2=delegate2._targets?delegate2._targets:[null,delegate2];return Delegate._create(targets1.concat(targets2));}
Delegate.remove=function(delegate1,delegate2){if(!delegate1||(delegate1===delegate2)){return null;} if(!delegate2){return delegate1;} var targets=delegate1._targets;var object=null;var method;if(delegate2._targets){object=delegate2._targets[0];method=delegate2._targets[1];} else{method=delegate2;} for(var i=0;i<targets.length;i+=2){if((targets[i]===object)&&(targets[i+1]===method)){if(targets.length==2){return null;} targets.splice(i,2);return Delegate._create(targets);}} return delegate1;}
Array.prototype.indexOf=function(item){var length=this.length;if(length){for(var index=0;index<length;index++){if(this[index]===item){return index;}}} return-1;}
Array.prototype.contains=function(item){var index=this.indexOf(item);return(index>=0);}
Array.prototype.add=function(item){this[this.length]=item;}
Array.prototype.remove=function(item){var index=this.indexOf(item);if(index>=0){this.splice(index,1);return true;} return false;}
var IArray=Type.createInterface('IArray');var IEnumerator=Type.createInterface('IEnumerator');var IEnumerable=Type.createInterface('IEnumerable');var ArrayEnumerator=function(array){this._array=array;this._index=-1;}
ArrayEnumerator.prototype={get_current:function(){return this._array[this._index];},moveNext:function(){this._index++;return(this._index<this._array.length);},reset:function(){this._index=-1;}}
ArrayEnumerator.createClass('ArrayEnumerator',null,IEnumerator);Array.__interfaces=[IArray,IEnumerable];Array.prototype.getLength=function(){return this.length;}
Array.prototype.getItem=function(index){return this[index];}
Array.prototype.getEnumerator=function(){return new ArrayEnumerator(this);}
String.Empty = '';
var $ = $get;

Type.createNamespace('nStuff');

////////////////////////////////////////////////////////////////////////////////
// nStuff.UpdateAnimationType

nStuff.UpdateAnimationType = Type.createEnum(false, 'nStuff.UpdateAnimationType', { CrossFade: 0, Highlight: 1, SlideUp: 2, SlideDown: 3, WipeLeft: 4, WipeRight: 5 });


////////////////////////////////////////////////////////////////////////////////
// nStuff.UpdateAnimation

nStuff.$create_UpdateAnimation = function nStuff_UpdateAnimation() { return {}; }


////////////////////////////////////////////////////////////////////////////////
// nStuff.UpdateHistoryOptions

nStuff.$create_UpdateHistoryOptions = function nStuff_UpdateHistoryOptions() { return {}; }


////////////////////////////////////////////////////////////////////////////////
// nStuff.AnimatedUpdatePanel

nStuff.AnimatedUpdatePanel = function nStuff_AnimatedUpdatePanel(element) {
    nStuff.AnimatedUpdatePanel.constructBase(this, [ element ]);
}
nStuff.AnimatedUpdatePanel.prototype = {
    _animation$2: null,
    _pageLoadedHandler$2: null,
    _pageLoadingHandler$2: null,
    _updatePanel$2: null,
    _oldUpdatePanel$2: null,
    
    get_animation: function nStuff_AnimatedUpdatePanel$get_animation() {
        return null;
    },
    set_animation: function nStuff_AnimatedUpdatePanel$set_animation(value) {
        this._animation$2 = value;
        return value;
    },
    
    dispose: function nStuff_AnimatedUpdatePanel$dispose() {
        if (this._pageLoadedHandler$2) {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.remove_pageLoaded(this._pageLoadedHandler$2);
            prm.remove_pageLoading(this._pageLoadingHandler$2);
            this._pageLoadedHandler$2 = null;
            this._pageLoadingHandler$2 = null;
        }
        nStuff.AnimatedUpdatePanel.callBase(this, 'dispose');
    },
    
    initialize: function nStuff_AnimatedUpdatePanel$initialize() {
        nStuff.AnimatedUpdatePanel.callBase(this, 'initialize');
        this._pageLoadedHandler$2 = Delegate.create(this, this._onPageLoaded$2);
        this._pageLoadingHandler$2 = Delegate.create(this, this._onPageLoading$2);
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_pageLoaded(this._pageLoadedHandler$2);
        prm.add_pageLoading(this._pageLoadingHandler$2);
        var element = this.get_element();
        var childNodes = element.childNodes;
        for (var i = childNodes.length - 1; i >= 0; i--) {
            if (childNodes[i].nodeType === 1) {
                this._updatePanel$2 = childNodes[i];
                element.style.width = this._updatePanel$2.offsetWidth + 'px';
                element.style.height = this._updatePanel$2.offsetHeight + 'px';
                var updatePanelStyle = this._updatePanel$2.style;
                updatePanelStyle.position = 'absolute';
                updatePanelStyle.left = '0px';
                updatePanelStyle.top = '0px';
                break;
            }
        }
    },
    
    _onPageLoaded$2: function nStuff_AnimatedUpdatePanel$_onPageLoaded$2(sender, e) {
        if (!e.get_panelsUpdated().contains(this._updatePanel$2)) {
            return;
        }
        var element = this.get_element();
        element.style.width = this._updatePanel$2.offsetWidth + 'px';
        element.style.height = this._updatePanel$2.offsetHeight + 'px';
        if (this._animation$2.type === nStuff.UpdateAnimationType.Highlight) {
            var overlay = document.createElement('div');
            overlay.className = this._animation$2.highlightCssClass;
            var overlayStyle = overlay.style;
            overlayStyle.display = 'none';
            overlayStyle.position = 'absolute';
            overlayStyle.top = '0px';
            overlayStyle.left = '0px';
            overlayStyle.width = element.offsetWidth + 'px';
            overlayStyle.height = element.offsetHeight + 'px';
            element.appendChild(overlay);
            var effect = new nStuff._updateHighlight(overlay, this._animation$2.duration);
            effect.play();
        }
        else {
            this._oldUpdatePanel$2.style.width = this._updatePanel$2.offsetWidth + 'px';
            this._oldUpdatePanel$2.style.height = this._updatePanel$2.offsetHeight + 'px';
            var updatePanelStyle = this._updatePanel$2.style;
            updatePanelStyle.position = 'absolute';
            updatePanelStyle.left = '0px';
            updatePanelStyle.top = '0px';
            if (this._animation$2.type === nStuff.UpdateAnimationType.CrossFade) {
                var effect = new nStuff._updateCrossFade(element, this._animation$2.duration);
                effect.playEffect(this._oldUpdatePanel$2, this._updatePanel$2);
            }
            else {
                var effect = new nStuff._updateWipeOrSlide(element, this._animation$2.duration);
                effect.playEffect(this._animation$2.type, this._oldUpdatePanel$2, this._updatePanel$2);
            }
        }
    },
    
    _onPageLoading$2: function nStuff_AnimatedUpdatePanel$_onPageLoading$2(sender, e) {
        if (!e.get_panelsUpdating().contains(this._updatePanel$2)) {
            return;
        }
        if (this._animation$2.type !== nStuff.UpdateAnimationType.Highlight) {
            this._oldUpdatePanel$2 = this._updatePanel$2;
            this._updatePanel$2 = document.createElement(this._oldUpdatePanel$2.tagName);
            this._updatePanel$2.className = this._oldUpdatePanel$2.className;
            this._updatePanel$2.id = this._oldUpdatePanel$2.id;
            this._updatePanel$2.style.visibility = 'hidden';
            this._oldUpdatePanel$2.id = '';
            this._oldUpdatePanel$2.style.overflow = 'hidden';
            var oldHTML = this._oldUpdatePanel$2.innerHTML;
            sender._destroyTree(this._oldUpdatePanel$2);
            this._oldUpdatePanel$2.innerHTML = oldHTML;
            this.get_element().appendChild(this._updatePanel$2);
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// nStuff._updateWipeOrSlide

nStuff._updateWipeOrSlide = function nStuff__updateWipeOrSlide(domElement, duration) {
    nStuff._updateWipeOrSlide.constructBase(this, [ domElement, duration ]);
    this.set_easingFunction(Delegate.create(null, ScriptFX.UI.TimedAnimation.easeInOut));
}
nStuff._updateWipeOrSlide.prototype = {
    _animation$2: 0,
    _oldContent$2: null,
    _newContent$2: null,
    _height$2: 0,
    _width$2: 0,
    
    performCleanup: function nStuff__updateWipeOrSlide$performCleanup() {
        this._oldContent$2.parentNode.removeChild(this._oldContent$2);
        this._newContent$2.style.top = '0px';
        this._newContent$2.style.left = '0px';
        this._newContent$2.style.height = this._height$2 + 'px';
        this._newContent$2.style.overflow = 'visible';
        this._newContent$2.style.clip = 'rect(auto auto auto auto)';
    },
    
    performSetup: function nStuff__updateWipeOrSlide$performSetup() {
        this._height$2 = this.get_domElement().offsetHeight;
        this._width$2 = this.get_domElement().offsetWidth;
        this._newContent$2.style.visibility = 'visible';
        this._newContent$2.style.overflow = 'hidden';
        switch (this._animation$2) {
            case nStuff.UpdateAnimationType.SlideUp:
                this._newContent$2.style.top = this._height$2 + 'px';
                this._newContent$2.style.height = '0px';
                break;
            case nStuff.UpdateAnimationType.SlideDown:
                this._newContent$2.style.height = this._height$2 + 'px';
                this._newContent$2.style.clip = 'rect(auto auto 0px auto)';
                break;
            case nStuff.UpdateAnimationType.WipeLeft:
                this._newContent$2.style.height = this._height$2 + 'px';
                this._newContent$2.style.clip = String.format('rect(auto auto auto {0}px)', this._width$2);
                break;
            case nStuff.UpdateAnimationType.WipeRight:
                this._newContent$2.style.height = this._height$2 + 'px';
                this._newContent$2.style.clip = 'rect(auto 0px auto auto)';
                break;
        }
    },
    
    performTweening: function nStuff__updateWipeOrSlide$performTweening(frame) {
        switch (this._animation$2) {
            case nStuff.UpdateAnimationType.SlideUp:
                var yOffset = Math.floor(this._height$2 * (1 - frame));
                this._newContent$2.style.top = yOffset + 'px';
                this._newContent$2.style.height = (this._height$2 - yOffset) + 'px';
                break;
            case nStuff.UpdateAnimationType.SlideDown:
                this._newContent$2.style.clip = String.format('rect(auto auto {0}px auto)', Math.floor(this._height$2 * frame));
                break;
            case nStuff.UpdateAnimationType.WipeLeft:
                var xOffset = Math.floor(this._width$2 * (1 - frame));
                break;
            case nStuff.UpdateAnimationType.WipeRight:
                this._newContent$2.style.clip = String.format('rect(auto {0}px auto auto)', Math.floor(this._width$2 * frame));
                break;
        }
    },
    
    playEffect: function nStuff__updateWipeOrSlide$playEffect(animation, oldContent, newContent) {
        this._animation$2 = animation;
        this._oldContent$2 = oldContent;
        this._newContent$2 = newContent;
        this.play();
    }
}


////////////////////////////////////////////////////////////////////////////////
// nStuff._updateCrossFade

nStuff._updateCrossFade = function nStuff__updateCrossFade(domElement, duration) {
    nStuff._updateCrossFade.constructBase(this, [ domElement, duration ]);
    this.set_easingFunction(Delegate.create(null, ScriptFX.UI.TimedAnimation.easeInOut));
}
nStuff._updateCrossFade.prototype = {
    _oldContent$2: null,
    _newContent$2: null,
    
    performCleanup: function nStuff__updateCrossFade$performCleanup() {
        this._oldContent$2.parentNode.removeChild(this._oldContent$2);
    },
    
    performSetup: function nStuff__updateCrossFade$performSetup() {
        this._setOpacity$2(this._newContent$2, 0);
        this._newContent$2.style.visibility = 'visible';
        this._newContent$2.style.filter = '';
    },
    
    performTweening: function nStuff__updateCrossFade$performTweening(frame) {
        this._setOpacity$2(this._newContent$2, frame);
        this._setOpacity$2(this._oldContent$2, 1 - frame);
    },
    
    playEffect: function nStuff__updateCrossFade$playEffect(oldContent, newContent) {
        this._oldContent$2 = oldContent;
        this._newContent$2 = newContent;
        this.play();
    },
    
    _setOpacity$2: function nStuff__updateCrossFade$_setOpacity$2(element, opacity) {
        if (window.navigator.userAgent.indexOf('MSIE') >= 0) {
            element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
        }
        else {
            element.style.opacity = opacity.toString();
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// nStuff._updateHighlight

nStuff._updateHighlight = function nStuff__updateHighlight(domElement, duration) {
    nStuff._updateHighlight.constructBase(this, [ domElement, duration ]);
}
nStuff._updateHighlight.prototype = {
    
    performCleanup: function nStuff__updateHighlight$performCleanup() {
        this.get_domElement().parentNode.removeChild(this.get_domElement());
    },
    
    performSetup: function nStuff__updateHighlight$performSetup() {
        this._setOpacity$2(0);
        this.get_domElement().style.display = '';
    },
    
    performTweening: function nStuff__updateHighlight$performTweening(frame) {
        this._setOpacity$2(Math.sin(frame * Math.PI) * 0.75);
    },
    
    _setOpacity$2: function nStuff__updateHighlight$_setOpacity$2(opacity) {
        if (window.navigator.userAgent.indexOf('MSIE') >= 0) {
            this.get_domElement().style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
        }
        else {
            this.get_domElement().style.opacity = opacity.toString();
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// nStuff.UpdateHistory

nStuff.UpdateHistory = function nStuff_UpdateHistory() {
    nStuff.UpdateHistory.constructBase(this);
}
nStuff.UpdateHistory.prototype = {
    _timerCookie$1: 0,
    _timerHandler$1: null,
    _iframeLoadHandler$1: null,
    _appLoadHandler$1: null,
    _endRequestHandler$1: null,
    _ignoreIFrame$1: false,
    _ignoreTimer$1: false,
    _historyFrame$1: null,
    _emptyPageURL$1: null,
    _target$1: null,
    _currentEntry$1: null,
    
    get_options: function nStuff_UpdateHistory$get_options() {
        return null;
    },
    set_options: function nStuff_UpdateHistory$set_options(value) {
        this._currentEntry$1 = (value.initialEntry) ? value.initialEntry : String.Empty;
        this._target$1 = value.target;
        return value;
    },
    
    _addEntry$1: function nStuff_UpdateHistory$_addEntry$1(entry) {
        this._ignoreTimer$1 = true;
        if (this._historyFrame$1) {
            this._ignoreIFrame$1 = true;
            this._historyFrame$1.src = this._emptyPageURL$1 + entry;
        }
        else {
            this._setEntry$1(entry);
        }
    },
    
    dispose: function nStuff_UpdateHistory$dispose() {
        if (this._historyFrame$1) {
            this._historyFrame$1.detachEvent('onload', this._iframeLoadHandler$1);
            this._historyFrame$1 = null;
        }
        if (this._timerCookie$1) {
            window.clearTimeout(this._timerCookie$1);
            this._timerCookie$1 = 0;
        }
        if (this._endRequestHandler$1) {
            Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(this._endRequestHandler$1);
            this._endRequestHandler$1 = null;
        }
        nStuff.UpdateHistory.callBase(this, 'dispose');
    },
    
    _getEntry$1: function nStuff_UpdateHistory$_getEntry$1() {
        var entry = window.location.hash;
        if ((entry.length >= 1) && (entry.charAt(0) === '#')) {
            entry = entry.substr(1);
        }
        return entry;
    },
    
    initialize: function nStuff_UpdateHistory$initialize() {
        nStuff.UpdateHistory.callBase(this, 'initialize');
        this._appLoadHandler$1 = Delegate.create(this, this._onAppLoad$1);
        Sys.Application.add_load(this._appLoadHandler$1);
    },
    
    _navigate$1: function nStuff_UpdateHistory$_navigate$1(entry) {
        __doPostBack(this._target$1, entry);
    },
    
    _onAppLoad$1: function nStuff_UpdateHistory$_onAppLoad$1(sender, e) {
        Sys.Application.remove_load(this._appLoadHandler$1);
        this._appLoadHandler$1 = null;
        var loadedEntry = this._getEntry$1();
        if (loadedEntry !== this._currentEntry$1) {
            this._navigate$1(loadedEntry);
        }
        else {
            this._endRequestHandler$1 = Delegate.create(this, this._onPageRequestManagerEndRequest$1);
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(this._endRequestHandler$1);
            if (window.navigator.userAgent.indexOf('MSIE') >= 0) {
                this._historyFrame$1 = $('__historyFrame');
                this._emptyPageURL$1 = this._historyFrame$1.src + '?';
                this._iframeLoadHandler$1 = Delegate.create(this, this._onIFrameLoad$1);
                this._historyFrame$1.attachEvent('onload', this._iframeLoadHandler$1);
            }
            this._timerHandler$1 = Delegate.create(this, this._onTick$1);
            this._timerCookie$1 = window.setTimeout(this._timerHandler$1, 100);
        }
    },
    
    _onIFrameLoad$1: function nStuff_UpdateHistory$_onIFrameLoad$1() {
        var entry = this._historyFrame$1.contentWindow.location.search;
        if ((entry.length >= 1) && (entry.charAt(0) === '?')) {
            entry = entry.substr(1);
        }
        this._setEntry$1(entry);
        if (this._ignoreIFrame$1) {
            this._ignoreIFrame$1 = false;
            return;
        }
        this._navigate$1(entry);
    },
    
    _onPageRequestManagerEndRequest$1: function nStuff_UpdateHistory$_onPageRequestManagerEndRequest$1(sender, e) {
        var entry = e.get_dataItems()[this._target$1];
        if (entry) {
            this._addEntry$1(entry);
        }
    },
    
    _onTick$1: function nStuff_UpdateHistory$_onTick$1() {
        this._timerCookie$1 = 0;
        var entry = this._getEntry$1();
        if (entry !== this._currentEntry$1) {
            if (!this._ignoreTimer$1) {
                this._currentEntry$1 = entry;
                this._navigate$1(entry);
            }
        }
        else {
            this._ignoreTimer$1 = false;
        }
        this._timerCookie$1 = window.setTimeout(this._timerHandler$1, 100);
    },
    
    _setEntry$1: function nStuff_UpdateHistory$_setEntry$1(entry) {
        this._currentEntry$1 = entry;
        window.location.hash = entry;
    }
}


Type.createNamespace('ScriptFX.UI');

////////////////////////////////////////////////////////////////////////////////
// ScriptFX.UI.AnimationStopState

ScriptFX.UI.AnimationStopState = Type.createEnum(false, 'ScriptFX.UI.AnimationStopState', { Complete: 0, Abort: 1, Revert: 2 });


////////////////////////////////////////////////////////////////////////////////
// ScriptFX.UI.Animation

ScriptFX.UI.Animation = function ScriptFX_UI_Animation(domElement) {
    if (!domElement) {
        domElement = document.documentElement;
    }
    this._domElement = domElement;
    this._repeatCount = 1;
    Sys.Application.registerDisposableObject(this);
}
ScriptFX.UI.Animation.prototype = {
    _domElement: null,
    _repeatCount: 0,
    _autoReverse: false,
    _repeatDelay: 0,
    _completed: false,
    _isPlaying: false,
    _isRepeating: false,
    _repetitions: 0,
    _repeatTimeStamp: 0,
    _reversed: false,
    
    add_repeating: function ScriptFX_UI_Animation$add_repeating(value) {
        this.__repeating = Delegate.combine(this.__repeating, value);
    },
    remove_repeating: function ScriptFX_UI_Animation$remove_repeating(value) {
        this.__repeating = Delegate.remove(this.__repeating, value);
    },
    
    __repeating: null,
    
    add_starting: function ScriptFX_UI_Animation$add_starting(value) {
        this.__starting = Delegate.combine(this.__starting, value);
    },
    remove_starting: function ScriptFX_UI_Animation$remove_starting(value) {
        this.__starting = Delegate.remove(this.__starting, value);
    },
    
    __starting: null,
    
    add_stopped: function ScriptFX_UI_Animation$add_stopped(value) {
        this.__stopped = Delegate.combine(this.__stopped, value);
    },
    remove_stopped: function ScriptFX_UI_Animation$remove_stopped(value) {
        this.__stopped = Delegate.remove(this.__stopped, value);
    },
    
    __stopped: null,
    
    get_autoReverse: function ScriptFX_UI_Animation$get_autoReverse() {
        return this._autoReverse;
    },
    set_autoReverse: function ScriptFX_UI_Animation$set_autoReverse(value) {
        this._autoReverse = value;
        return value;
    },
    
    get_completed: function ScriptFX_UI_Animation$get_completed() {
        return this._completed;
    },
    
    get_domElement: function ScriptFX_UI_Animation$get_domElement() {
        return this._domElement;
    },
    
    get_isPlaying: function ScriptFX_UI_Animation$get_isPlaying() {
        return this._isPlaying;
    },
    
    get_isReversed: function ScriptFX_UI_Animation$get_isReversed() {
        return this._reversed;
    },
    
    get_repeatCount: function ScriptFX_UI_Animation$get_repeatCount() {
        return this._repeatCount;
    },
    set_repeatCount: function ScriptFX_UI_Animation$set_repeatCount(value) {
        this._repeatCount = value;
        return value;
    },
    
    get_repeatDelay: function ScriptFX_UI_Animation$get_repeatDelay() {
        return this._repeatDelay;
    },
    set_repeatDelay: function ScriptFX_UI_Animation$set_repeatDelay(value) {
        this._repeatDelay = value;
        return value;
    },
    
    get_repetitions: function ScriptFX_UI_Animation$get_repetitions() {
        return this._repetitions;
    },
    
    dispose: function ScriptFX_UI_Animation$dispose() {
        if (this._isPlaying) {
            this.stop(ScriptFX.UI.AnimationStopState.Abort);
        }
        if (this._domElement) {
            this._domElement = null;
            Sys.Application.unregisterDisposableObject(this);
        }
    },
    
    _onPlay: function ScriptFX_UI_Animation$_onPlay(reversed) {
        if (this.__starting) {
            this.__starting.invoke(this, Sys.EventArgs.Empty);
        }
        this.performSetup();
        this._isPlaying = true;
        this._repetitions = 1;
        this._reversed = reversed;
        this.playCore();
    },
    
    _onStop: function ScriptFX_UI_Animation$_onStop(completed, stopState) {
        this.stopCore(completed, stopState);
        this._completed = completed;
        this._isPlaying = false;
        this.performCleanup();
        if (this.__stopped) {
            this.__stopped.invoke(this, Sys.EventArgs.Empty);
        }
    },
    
    _onProgress: function ScriptFX_UI_Animation$_onProgress(timeStamp) {
        if (this._isRepeating) {
            if ((this._repeatDelay) && ((this._repeatTimeStamp + this._repeatDelay) > timeStamp)) {
                return false;
            }
        }
        var completed = this.progressCore(this._isRepeating, timeStamp);
        this._isRepeating = false;
        if (completed && ((!this._repeatCount) || (this._repeatCount > this._repetitions))) {
            completed = false;
            this._repetitions++;
            if (this.__repeating) {
                var ce = new Sys.CancelEventArgs();
                this.__repeating.invoke(this, ce);
                completed = ce.get_canceled();
            }
            if (!completed) {
                this._isRepeating = true;
                if (this._autoReverse) {
                    this._reversed = !this._reversed;
                }
                this._repeatTimeStamp = timeStamp;
                this.performRepetition(this._reversed);
            }
        }
        return completed;
    },
    
    performCleanup: function ScriptFX_UI_Animation$performCleanup() {
    },
    
    performRepetition: function ScriptFX_UI_Animation$performRepetition(reversed) {
    },
    
    performSetup: function ScriptFX_UI_Animation$performSetup() {
    },
    
    play: function ScriptFX_UI_Animation$play() {
        this._completed = false;
        ScriptFX.UI.AnimationManager._play(this, this._domElement);
    },
    
    stop: function ScriptFX_UI_Animation$stop(stopState) {
        ScriptFX.UI.AnimationManager._stop(this, stopState);
    }
}


////////////////////////////////////////////////////////////////////////////////
// ScriptFX.UI.AnimationManager

ScriptFX.UI.AnimationManager = function ScriptFX_UI_AnimationManager() {
}
ScriptFX.UI.AnimationManager.get_FPS = function ScriptFX_UI_AnimationManager$get_FPS() {
    return ScriptFX.UI.AnimationManager._fps;
}
ScriptFX.UI.AnimationManager.set_FPS = function ScriptFX_UI_AnimationManager$set_FPS(value) {
    ScriptFX.UI.AnimationManager._fps = value;
    return value;
}
ScriptFX.UI.AnimationManager._onTick = function ScriptFX_UI_AnimationManager$_onTick() {
    ScriptFX.UI.AnimationManager._timerCookie = 0;
    if (!ScriptFX.UI.AnimationManager._activeAnimations.length) {
        return;
    }
    var timeStamp = (new Date()).getTime();
    var currentAnimations = ScriptFX.UI.AnimationManager._activeAnimations;
    var newAnimations = [];
    ScriptFX.UI.AnimationManager._activeAnimations = null;
    var $enum1 = currentAnimations.getEnumerator();
    while ($enum1.moveNext()) {
        var animation = $enum1.get_current();
        var completed = animation._onProgress(timeStamp);
        if (completed) {
            animation._onStop(true, ScriptFX.UI.AnimationStopState.Complete);
        }
        else {
            newAnimations.add(animation);
        }
    }
    if (newAnimations.length) {
        ScriptFX.UI.AnimationManager._activeAnimations = newAnimations;
        if (!ScriptFX.UI.AnimationManager._timerCookie) {
            ScriptFX.UI.AnimationManager._timerCookie = window.setTimeout(Delegate.create(null, ScriptFX.UI.AnimationManager._onTick), 1000 / ScriptFX.UI.AnimationManager._fps);
        }
    }
}
ScriptFX.UI.AnimationManager._play = function ScriptFX_UI_AnimationManager$_play(animation, domElement) {
    if (!ScriptFX.UI.AnimationManager._activeAnimations) {
        ScriptFX.UI.AnimationManager._activeAnimations = [];
    }
    ScriptFX.UI.AnimationManager._activeAnimations.add(animation);
    animation._onPlay(false);
    if (!ScriptFX.UI.AnimationManager._timerCookie) {
        ScriptFX.UI.AnimationManager._timerCookie = window.setTimeout(Delegate.create(null, ScriptFX.UI.AnimationManager._onTick), 1000 / ScriptFX.UI.AnimationManager._fps);
    }
}
ScriptFX.UI.AnimationManager._stop = function ScriptFX_UI_AnimationManager$_stop(animation, stopState) {
    animation._onStop(false, stopState);
    ScriptFX.UI.AnimationManager._activeAnimations.remove(animation);
}


////////////////////////////////////////////////////////////////////////////////
// ScriptFX.UI.TimedAnimation

ScriptFX.UI.TimedAnimation = function ScriptFX_UI_TimedAnimation(domElement, duration) {
    ScriptFX.UI.TimedAnimation.constructBase(this, [ domElement ]);
    this._duration$1 = duration;
}
ScriptFX.UI.TimedAnimation.easeIn = function ScriptFX_UI_TimedAnimation$easeIn(t) {
    return t * t;
}
ScriptFX.UI.TimedAnimation.easeInOut = function ScriptFX_UI_TimedAnimation$easeInOut(t) {
    t = t * 2;
    if (t < 1) {
        return t * t / 2;
    }
    return -((--t) * (t - 2) - 1) / 2;
}
ScriptFX.UI.TimedAnimation.easeOut = function ScriptFX_UI_TimedAnimation$easeOut(t) {
    return -t * (t - 2);
}
ScriptFX.UI.TimedAnimation.prototype = {
    _duration$1: 0,
    _easingFunction$1: null,
    _startTimeStamp$1: 0,
    
    get_duration: function ScriptFX_UI_TimedAnimation$get_duration() {
        return this._duration$1;
    },
    set_duration: function ScriptFX_UI_TimedAnimation$set_duration(value) {
        this._duration$1 = value;
        return value;
    },
    
    get_easingFunction: function ScriptFX_UI_TimedAnimation$get_easingFunction() {
        return this._easingFunction$1;
    },
    set_easingFunction: function ScriptFX_UI_TimedAnimation$set_easingFunction(value) {
        this._easingFunction$1 = value;
        return value;
    },
    
    playCore: function ScriptFX_UI_TimedAnimation$playCore() {
        this._startTimeStamp$1 = (new Date()).getTime();
        this.progressCore(false, this._startTimeStamp$1);
    },
    
    progressCore: function ScriptFX_UI_TimedAnimation$progressCore(startRepetition, timeStamp) {
        var frame = 0;
        var completed = false;
        if (!startRepetition) {
            frame = (timeStamp - this._startTimeStamp$1) / this._duration$1;
            if (!this.get_isReversed()) {
                completed = (frame >= 1);
                frame = Math.min(1, frame);
            }
            else {
                frame = 1 - frame;
                completed = (frame <= 0);
                frame = Math.max(0, frame);
            }
            if ((!completed) && (this._easingFunction$1)) {
                frame = this._easingFunction$1.invoke(frame);
            }
        }
        else {
            this._startTimeStamp$1 = timeStamp;
            if (this.get_isReversed()) {
                frame = 1;
            }
        }
        this.performTweening(frame);
        return completed;
    },
    
    stopCore: function ScriptFX_UI_TimedAnimation$stopCore(completed, stopState) {
        if (!completed) {
            if (stopState === ScriptFX.UI.AnimationStopState.Complete) {
                this.performTweening(1);
            }
            else if (stopState === ScriptFX.UI.AnimationStopState.Revert) {
                this.performTweening(0);
            }
        }
    }
}


ScriptFX.UI.Animation.createClass('ScriptFX.UI.Animation', null, Sys.IDisposable);
ScriptFX.UI.TimedAnimation.createClass('ScriptFX.UI.TimedAnimation', ScriptFX.UI.Animation);
nStuff.AnimatedUpdatePanel.createClass('nStuff.AnimatedUpdatePanel', Sys.UI.Control);
nStuff._updateWipeOrSlide.createClass('nStuff._updateWipeOrSlide', ScriptFX.UI.TimedAnimation);
nStuff._updateCrossFade.createClass('nStuff._updateCrossFade', ScriptFX.UI.TimedAnimation);
nStuff._updateHighlight.createClass('nStuff._updateHighlight', ScriptFX.UI.TimedAnimation);
nStuff.UpdateHistory.createClass('nStuff.UpdateHistory', Sys.Component);
ScriptFX.UI.AnimationManager.createClass('ScriptFX.UI.AnimationManager');
ScriptFX.UI.AnimationManager._fps = 100;
ScriptFX.UI.AnimationManager._activeAnimations = null;
ScriptFX.UI.AnimationManager._timerCookie = 0;

// ---- Do not remove this footer ----
// Generated using Script# v0.2.3.0 (http://projects.nikhilk.net)

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();