 
Type.registerNamespace("Ee.UI.Xaml");
Ee.UI.Xaml.scriptVersion="1.0.070606.0";
Ee.UI.Xaml.ScaleMode=function(){
    throw Error.notImplemented()
};
Ee.UI.Xaml.ScaleMode.prototype={
    none:0,zoom:1,stretch:2
};
Ee.UI.Xaml.ScaleMode.registerEnum("Ee.UI.Xaml.ScaleMode");
Ee.UI.Xaml.Control=function(a){
    Ee.UI.Xaml.Control.initializeBase(this,[a])
};
Ee.UI.Xaml.Control.prototype={
    _xamlSource:null,
    _xamlInitialized:false,
    _scaleMode:Ee.UI.Xaml.ScaleMode.none,
    _resizeDelegate:null,
    _boundEvents:null,
    add_xamlError:function(a){
        this.get_events().addHandler("xamlError",a)
    },
    remove_xamlError:function(a){
        this.get_events().removeHandler("xamlError",a)
    },
    add_resize:function(a){
        this.get_events().addHandler("resize",a)
    },
    remove_resize:function(a){
        this.get_events().removeHandler("resize",a)
    },
    add_xamlInitialized:function(a){
        this.get_events().addHandler("xamlInitialized",a)
    },
    remove_xamlInitialized:function(a){
        this.get_events().removeHandler("xamlInitialized",a)
    },
    get_scaleMode:function(){
        return this._scaleMode
    },
    set_scaleMode:function(a){
        this._scaleMode=a;
        if(this._xamlInitialized&&a!==Ee.UI.Xaml.ScaleMode.none)this._ensureTransform()
    },
    get_xamlSource:function(){
        return this._xamlSource||""
    },
    set_xamlSource:function(a){
        this._xamlSource=a
    },
    addEventListener:function(b,a,d){
        if(!this._boundEvents)this._boundEvents=[];
        var c=b.addEventListener(a,d);
        this._boundEvents[this._boundEvents.length]={
            element:b,eventName:a,token:c
        };
        return c
    },
    addEventListeners:function(f,d,c){
        var e={};
        for(var a in d){
            var b=d[a];
            if(c)
                b=Function.createDelegate(c,b);
            e[a]=this.addEventListener(f,a,b)
        }
        return e
    },
    dispose:function(){
        var a=this.get_element();
        if(a){
            if(this._resizeDelegate){
                a.content.onResize=null;
                this._resizeDelegate=null
            }
            a.OnLoad=null;
            a.OnError=null
        }
        if(this._xamlInitialized){
            this.xamlDispose();
            this._xamlInitialized=false
        }
        if(this._boundEvents){
            for(var c=0,d=this._boundEvents.length;c<d;c++){
                var b=this._boundEvents[c];
                b.element.removeEventListener(b.eventName,b.token)
            }
            this._boundEvents=null
        }
        Ee.UI.Xaml.Control.callBaseMethod(this,"dispose")
    },
    initialize:function(){
        Ee.UI.Xaml.Control.callBaseMethod(this,"initialize");
        var a=this.get_element();
        a.OnError=Function.createDelegate(this,this._xamlError);
        var b=this.get_xamlSource();
        if(b&&(typeof a.Source==="undefined"||a.Source!==b)){
            a.OnLoad=Function.createDelegate(this,this._xamlLoaded);
            a.Source=b
        }
        else 
            this._raiseXamlInitialize()
    },
    onResize:function(){},
    onXamlError:function(){},
    xamlDispose:function(){},
    xamlInitialize:function(){},
    _ensureTransform:function(){
        var b=this.get_element().content.root,a=Ee.UI.Xaml.Control._computeScale(b),c,d;
        if(this.get_scaleMode()===Ee.UI.Xaml.ScaleMode.zoom)
            c=d=Math.min(a.horizontal,a.vertical);
        else{
            c=a.horizontal;
            d=a.vertical
        }
        Ee.UI.Xaml.Control._ensureScale(b,c,d);
        if(!this._resizeDelegate){
            this._resizeDelegate=Function.createDelegate(this,this._onResize);
            b.getHost().content.onResize=this._resizeDelegate
        }
    },
    _onResize:function(){
        var c=this.get_element();
        if(c&&this.get_scaleMode()!==Ee.UI.Xaml.ScaleMode.none){
            this._ensureTransform();
            var b=Sys.EventArgs.Empty;
            this.onResize(b);
            var a=this.get_events().getHandler("resize");
            if(a)a(this,b)
        }
    },
    _raiseXamlError:function(c,a){
        this.onXamlError(a);
        if(!a.get_cancel()){
            var b=this.get_events().getHandler("xamlError");
            if(b)b(this,a)
        }
    },
    _raiseXamlInitialize:function(){
        if(this.get_scaleMode()!==Ee.UI.Xaml.ScaleMode.none)this._ensureTransform();
        this._xamlInitialized=true;
        this.xamlInitialize();
        var a=this.get_events().getHandler("xamlInitialized");
        if(a)a(this,Sys.EventArgs.Empty)
    },
    _xamlError:function(b,c){
        var a=this.get_element();
        if(a)this._raiseXamlError(b,new Ee.UI.Xaml.ErrorEventArgs(c))
    },
    _xamlLoaded:function(){
        var a=this.get_element();
        if(a){
            a.OnLoad=null;
            this._raiseXamlInitialize()
        }
    }
};

Ee.UI.Xaml.Control._computeScale=function(a){
    var c=a.width,
        b=a.height,
        d=a.getHost(),
        e=c?d.content.ActualWidth/c:0,
        f=b?d.content.ActualHeight/b:0;
    return {
        horizontal:e,vertical:f
    }
};
Ee.UI.Xaml.Control._ensureScale=function(b,c,d){
    var a=b.RenderTransform;
    if(!a)b.RenderTransform=a=b.getHost().content.createFromXaml('<ScaleTransform ScaleX="1" ScaleY="1"/>');
    a.ScaleX=c;
    a.ScaleY=d
};
Ee.UI.Xaml.Control._ensureMatrix=function(b,e,f,c,d){
    var a=b.RenderTransform;
    if(!a)
        b.RenderTransform=a=b.getHost().content.createFromXaml('<MatrixTransform Matrix="1.0,0.0, 0.0,1.0, 0.0,0.0"/>');
    else if(a.toString()!=="MatrixTransform")
        return;
    a.Matrix.M11=e;
    a.Matrix.M22=f;
    a.Matrix.OffsetX=c;
    a.Matrix.OffsetY=d
};
Ee.UI.Xaml.Control.registerClass("Ee.UI.Xaml.Control",Sys.UI.Control);
Ee.UI.Xaml.ErrorEventArgs=function(a){
this._xamlError=a;
Ee.UI.Xaml.ErrorEventArgs.initializeBase(this)};
Ee.UI.Xaml.ErrorEventArgs.prototype={
    _xamlError:null,get_error:function(){
        return this._xamlError
    }
};
Ee.UI.Xaml.ErrorEventArgs.registerClass("Ee.UI.Xaml.ErrorEventArgs",Sys.CancelEventArgs);
Type.registerNamespace("Ee.UI.Xaml.Media");
Ee.UI.Xaml.Media.PlayerElementName={
    videoWindow:"VideoWindow",
    placeholderImage:"PlaceholderImage",
    playerControls:"PlayerControls",
    playButton:"PlayButton",
    playPauseButton:"PlayPauseButton",
    playSymbol:"PlaySymbol",
    pauseSymbol:"PauseSymbol",
    stopButton:"StopButton",
    pauseButton:"PauseButton",
    nextButton:"NextButton",
    previousButton:"PreviousButton",
    muteButton:"MuteButton",
    muteOnSymbol:"MuteOnSymbol",
    muteOffSymbol:"MuteOffSymbol",
    timeSlider:"TimeSlider",
    timeThumb:"TimeThumb",
    timeCompleted:"TimeCompleted",
    volumeSlider:"VolumeSlider",
    volumeThumb:"VolumeThumb",
    volumeUpButton:"VolumeUpButton",
    volumeDownButton:"VolumeDownButton",
    totalTimeText:"TotalTimeText",
    currentTimeText:"CurrentTimeText",
    downloadSlider:"DownloadProgressSlider",
    downloadText:"DownloadProgressText",
    bufferingArea:"BufferingArea",
    bufferingText:"BufferingText",
    fullScreenButton:"FullScreenButton",
    chapterArea:"ChapterArea",
    chapterToggleButton:"ChapterToggleButton",
    chapterScroll:"ChapterScroll",
    chapterPrev:"ChapterScrollPrevious",
    chapterNext:"ChapterScrollNext",
    chapterItem:"ChapterScrollItem",
    captionText:"CaptionText",
    captionArea:"CaptionArea",
    captionToggleButton:"CaptionToggleButton",
    captionOnSymbol:"CaptionOnSymbol",
    captionOffSymbol:"CaptionOffSymbol",
    fullScreenArea:"FullScreenArea",
    fullScreenVideoWindow:"FullScreenVideoWindow",
    fullScreenCaptionText:"FullScreenCaptionText",
    fullScreenCaptionArea:"FullScreenCaptionArea"
};
Ee.UI.Xaml.Media._DomElement=function(b,a){
    this._control=b.content.findName(a);
    if(this._control){
        this.bindEvent("mouseEnter",a+"_MouseEnter");
        this.bindEvent("mouseLeave",a+"_MouseLeave");
        this._showAnimation=this._control.findName(a+"_Show");
        this._hideAnimation=this._control.findName(a+"_Hide");
        this._enableAnimation=this._control.findName(a+"_Enable");
        this._disableAnimation=this._control.findName(a+"_Disable")
    }
};
Ee.UI.Xaml.Media._DomElement.prototype={
    _control:null,
    _boundEvents:null,
    _showAnimation:null,
    _hideAnimation:null,
    _enableAnimation:null,
    _disableAnimation:null,
    _enabled:true,
    get_control:function(){
        return this._control
    },
    get_enabled:function(){
        return this._enabled
    },
    set_enabled:function(a){
        if(a!==this.get_enabled()){
            var b=a?this._enableAnimation:this._disableAnimation;
            if(b)b.begin();
            this._enabled=a
        }
    },
    bindEvent:function(d,c,a,e){
        if(c||a){
            var b=null;
            if(c)
                b=this._control.findName(c);
            if(!b&&!a)
                return;
            if(!this._boundEvents)
                this._boundEvents=[];
            if(a)
                a=Function.createDelegate(e||this,a);
            var g=this;
            function f(c,d){
                if(!g.get_enabled())
                    return;
                if(a&&!a(c,d))
                    return;
                if(b)
                    b.begin()
            }
            var h=this._control.addEventListener(d,f);
            this._boundEvents[this._boundEvents.length]={
                eventName:d,
                token:h
            }
        }
    },
    dispose:function(){
        if(this._control){
            if(this._boundEvents){
                for(var a=0,c=this._boundEvents.length;a<c;a++){
                    var b=this._boundEvents[a];
                    this._control.removeEventListener(b.eventName,b.token)
                }
                this._boundEvents=null
            }
            this._showAnimation=null;
            this._hideAnimation=null;
            this._enableAnimation=null;
            this._disableAnimation=null;
            this._control=null
        }
    },
    setVisible:function(a){
        var b=a?this._showAnimation:this._hideAnimation;
        if(b)
            b.begin();
        else if(this._control)
            this._control.visibility=a?0:1
    }
};
Ee.UI.Xaml.Media._DomElement.registerClass("Ee.UI.Xaml.Media._DomElement",null,Sys.IDisposable);
Ee.UI.Xaml.Media._Button=function(h,a,e,g,c,b,f){
    Ee.UI.Xaml.Media._Button.initializeBase(this,[h,a]);
    this._repeatInterval=e||0;
    var d=this.get_control();
    if(d){
        d.cursor="Hand";
        this.bindEvent("mouseLeftButtonDown",a+"_MouseDown",this._mouseDown);
        this.bindEvent("mouseLeftButtonUp",a+"_MouseUp",this._mouseUp);
        this.bindEvent("mouseLeave",a+"_MouseUp",this._mouseLeave)
    }
    if(b){
        this._requiresSender=!!f;
        this._clickDelegate=Function.createDelegate(b,g);
        if(c)this._doubleClickDelegate=Function.createDelegate(b,c)
    }
};
Ee.UI.Xaml.Media._Button.prototype={
    _down:false,
    _repeatInterval:0,
    _repeatTimeout:null,
    _repeatClickDelegate:null,
    _timeLastLeftButtonUp:0,
    _clickDelegate:null,
    _doubleClickDelegate:null,
    set_enabled:function(a){
        Ee.UI.Xaml.Media._Button.callBaseMethod(this,"set_enabled",[a]);
        var b=this.get_control();
        if(b)
            b.cursor=a?"Hand":"Default"
    },
    dispose:function(){
        this._cancelRepeat();
        this._clickDelegate=null;
        this._doubleClickDelegate=null;
        Ee.UI.Xaml.Media._Button.callBaseMethod(this,"dispose")
    },
    _cancelRepeat:function(){
        if(!this._repeatTimeout)return;
        window.clearTimeout(this._repeatTimeout);
        this._repeatTimeout=null;
        this._repeatClickDelegate=null
    },
    _doClick:function(a){
        if(a&&this._doubleClickDelegate)
            this._requiresSender?this._doubleClickDelegate(this):this._doubleClickDelegate();
        else if(this._clickDelegate)
            this._requiresSender?this._clickDelegate(this):this._clickDelegate()
    },
    _mouseDown:function(){
        this._down=true;
        if(this._repeatInterval&&!this._repeatTimeout){
            this._doClick(false);
            this._repeatClickDelegate=Function.createDelegate(this,this._repeatClick);
            this._repeatTimeout=window.setTimeout(this._repeatClickDelegate,this._repeatInterval)
        }
        return true
    },
    _mouseLeave:function(){
        if(!this._down)
            return false;
        this._down=false;
        this._cancelRepeat();
        return true
    },
    _mouseUp:function(){
        this._down=false;
        if(this._repeatTimeout)
            this._cancelRepeat();
        else{
            var b=(new Date).getTime(),
                c=this._timeLastLeftButtonUp;
            this._timeLastLeftButtonUp=b;
            var a=c&&b-c<300;
            if(a)
                this._timeLastLeftButtonUp=0;
            this._doClick(a)
        }
        return true
    },
    _repeatClick:function(){
        this._repeatTimeout=window.setTimeout(this._repeatClickDelegate,this._repeatInterval);
        this._doClick(false)
    }
};
Ee.UI.Xaml.Media._Button.registerClass("Ee.UI.Xaml.Media._Button",Ee.UI.Xaml.Media._DomElement);
Ee.UI.Xaml.Media.Player=function(a){
    Ee.UI.Xaml.Media.Player.initializeBase(this,[a]);
    this.set_scaleMode(Ee.UI.Xaml.ScaleMode.zoom)
};
Ee.UI.Xaml.Media.Player.prototype={
    _mediaEnded:false,
    _naturalduration:null,
    _domElements:null,
    _timerCookie:null,
    _mediaOpened:true,
    _enabledCaptionToggleButton:false,
    _autoPlay:null,
    _canSeek:true,
    _hasDuration:true,
    _caption:null,
    _chapters:null,
    _currentChapter:-1,
    _lastChapterStarted:-1,
    _nextChapterTime:-1,
    _currentChapterTime:-1,
    _enableCaptions:true,
    _toggledCaptions:true,
    _mediaMarkers:null,
    _mediaUrl:null,
    _muted:null,
    _placeholderImage:null,
    _imageElement:null,
    _volume:null,
    _chaptersActive:false,
    _bufferingProgressVisible:false,
	_bufferingProgress:null,
	_bufferingStoryboard:null,
	_bufferingText:null,
	_captionButton:null,
	_captionArea:null,
	_captionAreaFS:null,
	_chapterArea:null,
	_currentTimeText:null,
	_downloadProgress:null,
	_dragTime:null,
	_dragVolume:null,
	_mediaElement:null,
	_muteButton:null,
	_nextButton:null,
	_playPauseButton:null,
	_playButton:null,
	_pauseButton:null,
	_stopButton:null,
	_previousButton:null,
	_totalTimeText:null,
	add_chapterStarted:function(a){
        this.get_events().addHandler("chapterStarted",a)
    },
    remove_chapterStarted:function(a){
        this.get_events().removeHandler("chapterStarted",a)
    },
    add_markerReached:function(a){
        this.get_events().addHandler("markerReached",a)
    },
    remove_markerReached:function(a){
        this.get_events().removeHandler("markerReached",a)
    },
    add_mediaEnded:function(a){
        this.get_events().addHandler("mediaEnded",a)
    },
    remove_mediaEnded:function(a){
        this.get_events().removeHandler("mediaEnded",a)
    },
    add_mediaFailed:function(a){
        this.get_events().addHandler("mediaFailed",a)
    },
    remove_mediaFailed:function(a){
        this.get_events().removeHandler("mediaFailed",a)
    },
    add_mediaOpened:function(a){
        this.get_events().addHandler("mediaOpened",a)
    },
    remove_mediaOpened:function(a){
        this.get_events().removeHandler("mediaOpened",a)
    },
    add_stateChanged:function(a){
        this.get_events().addHandler("stateChanged",a)
    },
    remove_stateChanged:function(a){
        this.get_events().removeHandler("stateChanged",a)
    },
    add_volumeChanged:function(a){
        this.get_events().addHandler("volumeChanged",a)
    },
    remove_volumeChanged:function(a){
        this.get_events().removeHandler("volumeChanged",a)
    },
    get_autoPlay:function(){
        if(this._mediaElement)
            return this._mediaElement.AutoPlay;
        if(this._autoPlay!==null)
            return this._autoPlay;
        return false
    },
    set_autoPlay:function(a){
        if(this._mediaElement)
            this._mediaElement.AutoPlay=a;
        else 
            this._autoPlay=a
    },
    get_caption:function(){
        return this._caption||""
    },
    set_caption:function(a){
        this._caption=a;
        if(this._captionArea)
            this._captionArea.set_text(a);
        if(this._captionAreaFS)
            this._captionAreaFS.set_text(a)
    },
    get_chapters:function(){
        if(!this._chapters)
            return [];
        return Array.clone(this._chapters)
    },
    set_chapters:function(a){
        this._chapters=a;
        if(this._chapterArea)
            this._loadChapters(a)
    },
    get_currentChapter:function(){
        return this._currentChapter
    },
    set_currentChapter:function(a){
        var b=this.get_chapters();
        if(!b||a<0||a>=b.length)
            throw Error.argumentOutOfRange("currentChapter",a,Ee.UI.Xaml.Media.Res.invalidChapterIndex);
        var c=b[a].time;
        if(c!==-1)
            this.set_timeIndex(c)
    },
    get_enableCaptions:function(){
        return !!this._enableCaptions
    },
    set_enableCaptions:function(a){
        if(this._enableCaptions!==a){
            this._enableCaptions=a;
            this._ensureCaption()
        }
    },
    get_mediaMarkers:function(){
        if(!this._mediaMarkers)
            return [];
        return Array.clone(this._mediaMarkers)
    },
    get_mediaElement:function(){
        return this._mediaElement||null
    },
    get_mediaUrl:function(){
        if(this._mediaElement)
            return this._mediaElement.Source||"";
        return this._mediaUrl||""
    },
    set_mediaUrl:function(a){
        if(this._mediaElement){
            this._loadPlaceholderImage();
            this._loadMediaUrl(a)
        }else 
            this._mediaUrl=a
    },
    get_muted:function(){
        if(this._mediaElement)
            return this._mediaElement.IsMuted;
        return !!this._muted
    },
    set_muted:function(a){
        if(a!==this.get_muted()){
            if(this._mediaElement){
                this._mediaElement.IsMuted=a;
                this._muteButton.set_state(a?1:0)
            }else 
                this._muted=a;
            if(!this.get_isUpdating())
                this._raiseVolumeChanged(Sys.EventArgs.Empty)
        }
    },
    get_placeholderImage:function(){
        return this._placeholderImage||""
    },
    set_placeholderImage:function(a){
        this._placeholderImage=a
    },
    get_playState:function(){
        return this._mediaElement?this._mediaElement.CurrentState:"Stopped"
    },
    get_timeIndex:function(){
        return this._mediaElement?this._mediaElement.position.seconds:0
    },
    set_timeIndex:function(a){
        if(this._mediaElement&&this._canSeek){
            this._mediaEnded=false;
            this.set_caption("");
            a=Math.max(0,a);
            a=Math.min(this._naturalduration,a);
            var b=this._mediaElement.position;
            b.seconds=a;
            this._mediaElement.position=b;
            this._updateTime(a);
            this._currentChapter=this._getChapterAt(a,true);
            this._detectChapterChanged()
        }
    },
    get_volume:function(){
        if(this._volume!==null)
            return this._volume;
        if(this._mediaElement)
            return this._mediaElement.volume;
        return Ee.UI.Xaml.Media.Player._defaultVolume
    },
    set_volume:function(a){
       if(a!==this.get_volume()){
            if(this._mediaElement&&this._mediaElement.CurrentState!=="Closed")
                this._mediaElement.volume=a;
            else 
                this._volume=a;
            if(!this.get_isUpdating())
                this._raiseVolumeChanged(Sys.EventArgs.Empty)
        }
        if(this._dragVolume)
            this._dragVolume.set_value(a)
    },
    nextChapter:function(){
        if(!this._canSeek)
            return false;
        var a=this.get_chapters();
        if(a){
            var b=this.get_currentChapter();
            if(++b<a.length){
                this.set_currentChapter(b);
                return true
            }
        }
        return false
    },
    onChapterStarted:function(){},
    onMarkerReached:function(){},
    onPlayStateChanged:function(){},
    onVolumeChanged:function(){},
    pause:function(){
        if(!this._mediaElement)
            throw Error.invalidOperation(Ee.UI.Xaml.Media.Res.noMediaElement);
        if(!this._mediaOpened)
            return;
        this._mediaElement.pause()
    },
    play:function(){
        if(!this._mediaElement)
            throw Error.invalidOperation(Ee.UI.Xaml.Media.Res.noMediaElement);
        if(!this._mediaOpened)
            return;
        this.set_caption("");
        var a=this._mediaElement;
        if(this._mediaEnded){
            a.stop();
            this._mediaEnded=false;
            window.setTimeout(function(){a.play()},0)
        }else 
            a.play()
    },
    previousChapter:function(){
        if(!this._canSeek)
            return false;
        var b=this.get_chapters();
        if(b){
            var a=this.get_currentChapter();
            if(--a>=0){
                this.set_currentChapter(a);
                return true
            }
        }
        return false
    },
    stop:function(){
        if(!this._mediaElement)
            throw Error.invalidOperation(Ee.UI.Xaml.Media.Res.noMediaElement);
        if(!this._mediaOpened)
            return;
        this._mediaEnded=false;
        this._currentChapter=this._getChapterAt(0,true);
        this._mediaElement.stop();
        this.set_caption("")
    },
    toggleMuted:function(){
        var a=!this.get_muted();
        this.set_muted(a);
        return a
    },
    togglePlayPause:function(){
        this.get_playState()==="Playing"?this.pause():this.play();
        return this.get_playState()
    },
    xamlDispose:function(){
        if(this._timerCookie){
            window.clearTimeout(this._timerCookie);
            this._timerCookie=null
        }
        if(this._domElements){
            for(var a=0,c=this._domElements.length;a<c;a++)
                this._domElements[a].dispose();
            delete this._domElements
        }
        if(this._mediaElement)
            this._mediaElement.stop();
        this._mediaElement=null;
        this._bufferingText=null;
        this._bufferingStoryboard=null;
        var b=this.get_element()?this.get_element().content:null;
        if(b)
            b.onFullScreenChange=null;
        Ee.UI.Xaml.Media.Player.callBaseMethod(this,"xamlDispose")
    },
    xamlInitialize:function(){
        this._bindChildControls();
        Ee.UI.Xaml.Media.Player.callBaseMethod(this,"xamlInitialize");
        var a=this.get_chapters();
        if(a)
            this._loadChapters(a);
        if(this._mediaUrl===null){
            this._ensureSeeking(false);
            this._mediaAvailable(false)
        }
        this._loadPlaceholderImage();
        this._clearMediaCache()
    },
    _bindChildControls:function(){
        var a=Ee.UI.Xaml.Media.PlayerElementName,
            b=this.get_element(),
            c=Ee.UI.Xaml.Media._Button,
            e=Ee.UI.Xaml.Media._DomElement,
            h=Ee.UI.Xaml.Media._Slider,
            g=Ee.UI.Xaml.Media._MultiStateButton,
            f=Ee.UI.Xaml.Media._TextBlock,d;
        this._domElements=[
                            d=new c(b,a.videoWindow,null,this.togglePlayPause,this._onFullScreenME,this),
                            this._fsCanvas=new c(b,a.fullScreenArea,null,this.togglePlayPause,this._onFullScreenME,this),
                            this._fsVideoWindow=new e(b,a.fullScreenVideoWindow),
                            this._bufferingProgress=new e(b,a.bufferingArea),
                            new e(b,a.playerControls),
                            this._playButton=new c(b,a.playButton,null,this.play,null,this),
                            this._stopButton=new c(b,a.stopButton,null,this.stop,null,this),
                            this._pauseButton=new c(b,a.pauseButton,null,this.pause,null,this),
                            new c(b,a.volumeUpButton,20,this._onVolumeUp,null,this),
                            new c(b,a.volumeDownButton,20,this._onVolumeDown,null,this),
                            new c(b,a.fullScreenButton,null,this._onFullScreen,null,this),
                            this._previousButton=new c(b,a.previousButton,null,this._chapterPrevious,null,this),
                            this._nextButton=new c(b,a.nextButton,null,this._chapterNext,null,this),
                            this._playPauseButton=new g(b,a.playPauseButton,null,this.togglePlayPause,null,this,a.playSymbol,a.pauseSymbol),
                            this._muteButton=new g(b,a.muteButton,null,this.toggleMuted,null,this,a.muteOffSymbol,a.muteOnSymbol),
                            this._dragTime=new h(b,a.timeThumb,a.timeSlider,this._onTimeSliderChanged,this),
                            this._dragVolume=new h(b,a.volumeThumb,a.volumeSlider,this._onVolumeSliderChanged,this),
                            this._totalTimeText=new f(b,a.totalTimeText),
                            this._currentTimeText=new f(b,a.currentTimeText),
                            this._downloadProgress=new Ee.UI.Xaml.Media._ProgressBar(b,a.downloadSlider,a.downloadText),
                            this._chapterArea=new Ee.UI.Xaml.Media._ChapterArea(this),
                            this._captionArea=new f(b,a.captionText,a.captionArea),
                            this._captionAreaFS=new f(b,a.fullScreenCaptionText,a.fullScreenCaptionArea),
                            this._captionButton=new g(b,a.captionToggleButton,null,this._onCaptionToggle,null,this,a.captionOnSymbol,a.captionOffSymbol),
                            this._imageElement=new e(b,a.placeholderImage)
                          ];
        d.bindEvent("mediaOpened",null,this._meMediaOpened,this);
        d.bindEvent("mediaFailed",null,this._meMediaFailed,this);
        d.bindEvent("mediaEnded",null,this._meMediaEnded,this);
        d.bindEvent("downloadProgressChanged",null,this._meDownloadProgress,this);
        d.bindEvent("bufferingProgressChanged",null,this._meBufferingProgress,this);
        d.bindEvent("markerReached",null,this._meMarkerReached,this);
        d.bindEvent("currentStateChanged",null,this._meStateChanged,this);
        this._bufferingStoryboard=b.content.findName(a.bufferingArea+"_Buffering");
        this._bufferingText=b.content.findName(a.bufferingText);
        this._dragVolume.set_value(this.get_volume());
        b.content.onFullScreenChange=Function.createDelegate(this,this._fullScreenChanged);
        this._mediaElement=d.get_control();
        if(!this._mediaElement)
            throw Error.invalidOperation(Ee.UI.Xaml.Media.Res.noMediaElement);
        this._mediaElement.AutoPlay=false
    },
    _chapterNext:function(){
        var a=this.get_chapters();
        if(!a||!a.length)
            this._skipTime(1);
        else 
            this.nextChapter()
    },
    _chapterPrevious:function(){
        var b=this.get_chapters();
        if(!b||!b.length)
            this._skipTime(-1);
        else{
            var a=this._getChapterAt(this.get_timeIndex()-1);
            if(a===-1)
                this.set_timeIndex(0);
            else 
                this.set_currentChapter(a)
        }
    },
    _clearMediaCache:function(){
        if(this._muted!==null){
            this._mediaElement.IsMuted=this._muted;
            this._muteButton.set_state(this._muted?1:0);
            this._muted=null
        }
        if(this._volume!==null){
            this._mediaElement.Volume=this._volume;
            this._dragVolume.set_value(this._volume);
            this._volume=null
        }
        if(this._autoPlay!==null){
            this._mediaElement.AutoPlay=this._autoPlay;
            this._autoPlay=null
        }
        if(this._mediaUrl!==null){
            this._loadMediaUrl(this._mediaUrl);
            this._mediaUrl=null
        }
    },
    _detectChapterChanged:function(a){
        if(this._lastChapterStarted!==this._currentChapter){
            this._lastChapterStarted=this._currentChapter;
            this._raiseChapterStarted(new Ee.UI.Xaml.Media.ChapterEventArgs(this._currentChapter))
        }
        else if(this._nextChapterTime!==-1&&a>=this._nextChapterTime-.001||this._currentChapterTime!==-1&&a<this._currentChapterTime-.001){
            this._currentChapter=this._getChapterAt(a,true);
            this._lastChapterStarted=this._currentChapter;
            this._raiseChapterStarted(new Ee.UI.Xaml.Media.ChapterEventArgs(this._currentChapter))
        }
    },
    _enableBuffering:function(a,b){
        if(a){
            if(this._bufferingText){
                this._bufferingText.Visibility=0;
                this._bufferingText.Text=b.toString()
            }
            if(!this._bufferingProgressVisible){
                this._bufferingProgress.setVisible(true);
                if(this._bufferingStoryboard)
                    this._bufferingStoryboard.begin()
            }
            this._bufferingProgressVisible=true
        }
        else if(this._bufferingProgressVisible){
            if(this._bufferingText)
                this._bufferingText.Visibility=1;
            this._bufferingProgress.setVisible(false);
            if(this._bufferingStoryboard)
                this._bufferingStoryboard.stop();
            this._bufferingProgressVisible=false
        }
    },
    _ensureCaption:function(){
        var b=this._toggledCaptions&&this.get_enableCaptions();
        if(b){
            var a=this.get_caption();
            if(this._captionArea)
                this._captionArea.set_text(a);
            if(this._captionAreaFS)
                this._captionAreaFS.set_text(a)
        }
        else{
            if(this._captionArea)
                this._captionArea.setVisible(false);
            if(this._captionAreaFS)
                this._captionAreaFS.setVisible(false)
        }
    },
    _ensureChapterArea:function(){
        var a=this._canSeek;
        if(a){
            var b=this.get_chapters();
            if(b){
                a=false;
                for(var c=0,d=b.length;c<d;c++){
                    if(b[c].imageUrl){
                        a=true;
                        break
                    }
                }
            }
        }
        if(a&&!this._chaptersActive){
            this._chapterArea.activate();
            this._chaptersActive=true
        }
        else if(!a&&this._chaptersActive){
            this._chapterArea.deactivate();
            this._chapterArea.setVisible(false);
            this._chaptersActive=false
        }
    },
    _ensureSeeking:function(a){
        if(this._canSeek!==a){
        this._canSeek=a;
        this._previousButton.set_enabled(a);
        this._nextButton.set_enabled(a);
        this._ensureChapterArea();
        this._dragTime.set_enableSeeking(a)
        }
    },
    _ensureDuration:function(a){
        if(this._hasDuration!==a){
            this._hasDuration=a;
            this._totalTimeText.setVisible(a);
            this._currentTimeText.setVisible(a);
            this._dragTime.set_enabled(a)
        }
    },
    _formatTime:function(e){
        var b=Math.floor(e/(1000*60*60)),
            c=Math.floor(e/(1000*60))-b*60,
            d=Math.floor(e/1000)-b*60*60-c*60,
            a="";
        if(b>0){
            a=b<10?"0"+b:""+b;
            a+=":"
        }
        a+=c<10?"0"+c:""+c;
        a+=":";
        a+=d<10?"0"+d:""+d;
        return a
    },
    _fullScreenChanged:function(){
        var b=this._fsCanvas.get_control();
        if(!b)
            return;
        if(this.get_element().content.fullScreen){
            var d=this.get_element().content.root.RenderTransform,
                g=1,
                h=1;
            if(d&&d.toString()==="ScaleTransform"){
                g=d.ScaleX;
                h=d.ScaleY
            }
            var a=Ee.UI.Xaml.Control._computeScale(b),
                e=a.horizontal/g,
                f=a.vertical/h;
            Ee.UI.Xaml.Control._ensureScale(b,e,f);
            var c=this._fsVideoWindow.get_control();
            if(c){
                var i=Math.min(a.horizontal,a.vertical),
                    n=Math.min(a.horizontal/g,a.vertical/h),
                    j=(b.getHost().content.ActualWidth-c.width*i)/2,
                    k=(b.getHost().content.ActualHeight-c.height*i)/2;
                if(e>f)
                    Ee.UI.Xaml.Control._ensureMatrix(c,f/e,1,j/a.horizontal,k/a.vertical);
                else 
                    Ee.UI.Xaml.Control._ensureMatrix(c,1,e/f,j/a.horizontal,k/a.vertical)
            }
            b.Visibility=0
        }
        else {
            b.Visibility=1;
            this._updatePosition()
        }
    },
    _getChapterAt:function(d,e){
        var b=this.get_chapters(),
            a=-1;
        d+=.001;
        if(b){
            for(var c=0,f=b.length;c<f;c++){
                var g=b[c].time-.001;
                if(g<=d)
                    a=c;
                else 
                    break
            }
        }
        if(e){
            this._currentChapterTime=a>=0?b[a].time:-1;
            this._nextChapterTime=a<b.length-1?b[a+1].time:-1
        }
        return a
    },
    _loadChapters:function(a){
        this._ensureChapterArea();
        this._chapterArea.setChapters(a);
        this._currentChapter=this._getChapterAt(this.get_timeIndex(),true);
        this._lastChapterStarted=-1;
        this._detectChapterChanged()
    },
    _loadMediaUrl:function(a){
        this._currentChapter=-1;
        this._lastChapterStarted=-1;
        this._mediaElement.Source=a
    },
    _loadPlaceholderImage:function(){
        var b=this.get_placeholderImage();
        if(b){
            var a=this._imageElement.get_control();
            if(a){
                a.Source=b;
                this._placeholderImageShowing=true;
                this._imageElement.setVisible(true)
            }
        }
    },
    _onCaptionToggle:function(){
        this._toggledCaptions=!this._toggledCaptions;
        this._ensureCaption();
        this._captionButton.set_state(this._toggledCaptions?0:1)
    },
    _onFullScreen:function(){
        var a=this.get_element().content;
        a.fullScreen=!a.fullScreen
    },
    _onFullScreenME:function(){
        this.togglePlayPause();
        this._onFullScreen()
    },
    _onTimeSliderChanged:function(){
        this.set_timeIndex(this._dragTime.get_value()*this._naturalduration)
    },
    _onVolumeDown:function(){
        this.set_volume(Math.max(0,this.get_volume()-.02))
    },
    _onVolumeSliderChanged:function(){
        this.set_volume(this._dragVolume.get_value())
    },
    _onVolumeUp:function(){
        this.set_volume(Math.min(1,this.get_volume()+.02))
    },
    _mediaAvailable:function(a){
        if(this._mediaOpened!==a){
            this._mediaOpened=a;
            this._playPauseButton.set_enabled(a);
            this._playButton.set_enabled(a);
            this._pauseButton.set_enabled(a);
            this._stopButton.set_enabled(a);
            if(!a)
                this.set_caption("")
        }
    },
    _meBufferingProgress:function(){
        var b=this._mediaElement.bufferingProgress,a=Math.round(b*100);
        if(a>=100)
            this._enableBuffering(false);
        else 
            this._enableBuffering(true,a)
    },
    _meDownloadProgress:function(){
        this._enableBuffering(false);
        this._downloadProgress.set_value(this._mediaElement.downloadProgress)
    },
    _meMarkerReached:function(b,a){
        this._raiseMarkerReached(new Ee.UI.Xaml.Media.MarkerEventArgs(a.marker))
    },
    _meMediaEnded:function(){
        this._mediaEnded=true;
        this._raiseEvent("mediaEnded",Sys.EventArgs.Empty)
    },
    _meMediaFailed:function(){
        this._naturalduration=null;
        this._enableBuffering(false);
        this._mediaAvailable(false);
        this._ensureDuration(false);
        this._ensureSeeking(false);
        this._mediaEnded=false;
        this.set_caption("");
        this._raiseEvent("mediaFailed",Sys.EventArgs.Empty)
    },
    _meMediaOpened:function(){
        this._mediaEnded=false;
        this._clearMediaCache();
        if(this._placeholderImageShowing){
            this._imageElement.setVisible(false);
            this._placeholderImageShowing=false
        }
        this.set_caption("");
        this._markers=[];
        var d=this._mediaElement.Markers;
        for(var b=0,e=d.Count;b<e;b++)
            Array.add(this._markers,d.getItem(b));
        this._naturalduration=this._mediaElement.naturalduration.seconds;
        var a=!!this._naturalduration,
            c=a&&this._mediaElement.CanSeek;
        if(c){
            this._currentChapter=this._getChapterAt(0,true);
            this._lastChapterStarted=-1;
            this._detectChapterChanged()
        }
        if(a){
            this._totalTimeText.set_text(this._formatTime(this._naturalduration*1000));
            this._currentTimeText.set_text(this._formatTime(this.get_timeIndex()*1000));
            this._dragTime.set_value(this.get_timeIndex()/this._naturalduration)
        }
        this._mediaAvailable(true);
        this._ensureDuration(a);
        this._ensureSeeking(c);
        if(!this._timerCookie){
            this._tickTimerDelegate=Function.createDelegate(this,this._tickTimer);
            this._timerCookie=window.setTimeout(this._tickTimerDelegate,200)
        }
        this._raiseEvent("mediaOpened",Sys.EventArgs.Empty)
    },
    _meStateChanged:function(){
        var a=this.get_playState();
        if(a==="Closed"){
            this._enableBuffering(false);
            this._mediaAvailable(false);
            this._ensureSeeking(false);
            this._mediaEnded=false
        }
        else if(a==="Playing"||a==="Paused")
            this._enableBuffering(false);
        var b=this._oldState||"";
        if(a!==b){
            this._oldState=a;
            this._raisePlayStateChanged(new Ee.UI.Xaml.Media.StateChangedEventArgs("playState",b,a))
        }
    },
    _raiseChapterStarted:function(a){
        this.onChapterStarted(a);
        this._raiseEvent("chapterStarted",a);
        this.raisePropertyChanged("currentChapter")
    },
    _raiseEvent:function(c,b){
        var a=this.get_events().getHandler(c);
        if(a)
            a(this,b)
    },
    _raiseMarkerReached:function(b){
        if(this._toggledCaptions&&this.get_enableCaptions()){
            var a=b.get_marker(),
                d=a.type?a.type.toLowerCase():"";
            if(d==="caption"){
                if(!this._enabledCaptionToggleButton){
                    this._enabledCaptionToggleButton=true;
                    this._captionButton.setVisible(true)
                }
                var c=a.text?a.text:"";
                if(c.trim().length===0)
                    c="";
                this.set_caption(c);
                this.raisePropertyChanged("caption")
            }
        }
        this.onMarkerReached(b);
        this._raiseEvent("markerReached",b)
    },
    _raisePlayStateChanged:function(a){
        this._playPauseButton.set_state(a.get_currentState()==="Playing"?1:0);
        this.onPlayStateChanged(a);
        this._raiseEvent("stateChanged",a);
        this._raiseEvent("propertyChanged",a)
    },
    _raiseVolumeChanged:function(a){
        this.onVolumeChanged(a);
        this._raiseEvent("volumeChanged",a);
        this.raisePropertyChanged("volume")
    },
    _skipTime:function(b){
        var a=this._naturalduration/10;
        a=b*Math.max(5,a);
        var c=a+this.get_timeIndex();
        this.set_timeIndex(c)
    },
    _tickTimer:function(){
        this._timerCookie=window.setTimeout(this._tickTimerDelegate,200);
        if(this.get_playState()!=="Playing")
            return;
        this._updatePosition()
    },
    _updatePosition:function(){
        var a=null;
        if(!this.get_element().content.fullScreen&&this._hasDuration){
            a=this.get_timeIndex();
            if(!this._dragTime._isDragging)
                this._dragTime.set_value(a/this._naturalduration);
            this._updateTime(a)
        }
        if(this._canSeek){
            if(a===null)a=this.get_timeIndex();
            this._detectChapterChanged(a)
        }
    },
    _updateTime:function(a){
        this._currentTimeText.set_text(this._formatTime(a*1000))
    }
};
Ee.UI.Xaml.Media.Player._defaultVolume=.5;
Ee.UI.Xaml.Media.Player.registerClass("Ee.UI.Xaml.Media.Player",Ee.UI.Xaml.Control);
Ee.UI.Xaml.Media.StateChangedEventArgs=function(c,a,b){
    this._currentState=b;
    this._previousState=a;
    Ee.UI.Xaml.Media.StateChangedEventArgs.initializeBase(this,[c])
};
Ee.UI.Xaml.Media.StateChangedEventArgs.prototype={
    get_currentState:function(){
        return this._currentState||null
    },
    get_previousState:function(){
        return this._previousState||null
    }
};
Ee.UI.Xaml.Media.StateChangedEventArgs.registerClass("Ee.UI.Xaml.Media.StateChangedEventArgs",Sys.PropertyChangedEventArgs);
Ee.UI.Xaml.Media.ChapterEventArgs=function(a){
    this._chapterIndex=a;
    Ee.UI.Xaml.Media.ChapterEventArgs.initializeBase(this)
};
Ee.UI.Xaml.Media.ChapterEventArgs.prototype={
    get_chapterIndex:function(){
        return this._chapterIndex
    }
};
Ee.UI.Xaml.Media.ChapterEventArgs.registerClass("Ee.UI.Xaml.Media.ChapterEventArgs",Sys.EventArgs);
Ee.UI.Xaml.Media.MarkerEventArgs=function(a){
    this._marker=a;
    Ee.UI.Xaml.Media.MarkerEventArgs.initializeBase(this)
};
Ee.UI.Xaml.Media.MarkerEventArgs.prototype={
    get_marker:function(){
        return this._marker||null
    }
};
Ee.UI.Xaml.Media.MarkerEventArgs.registerClass("Ee.UI.Xaml.Media.MarkerEventArgs",Sys.EventArgs);
Ee.UI.Xaml.Media._TextBlock=function(e,d,c){
    Ee.UI.Xaml.Media._TextBlock.initializeBase(this,[e,d]);
    var a=this.get_control();
    if(a&&c){
        var b=a.findName(c);
        if(b){
            this._centerX=b["Canvas.Left"]+b.width/2;
            this._bottomY=b["Canvas.Top"]+b.height;
            this._background=b
        }
    }
    if(a&&!this._background){
        this._centerX=a["Canvas.Left"]+a.ActualWidth/2;
        this._bottomY=a["Canvas.Top"]+a.ActualHeight;
        this._background=a
    }
};
Ee.UI.Xaml.Media._TextBlock.prototype={
    _centerX:0,
    _bottomY:0,
    _background:null,
    get_backgroundControl:function(){
        return this._background||null
    },
    get_text:function(){
        var a=this.get_control();
        return a?a.Text||"":""
    },
    set_text:function(c){
        var b=this.get_control();
        if(b){
            b.Text=c||"";
            this.setVisible(!!c);
            var a=this.get_backgroundControl();
            if(a){
                var d=b.ActualWidth,
                    e=b.ActualHeight;
                a["Canvas.Left"]=this._centerX-d/2;
                a["Canvas.Top"]=this._bottomY-e;
                a.width=d;
                a.height=e
            }
        }
    },
    dispose:function(){
        Ee.UI.Xaml.Media._TextBlock.callBaseMethod(this,"dispose");
        this._background=null
    },
    setVisible:function(a){
        Ee.UI.Xaml.Media._TextBlock.callBaseMethod(this,"setVisible",[a]);
        var b=this.get_backgroundControl();
        if(b)
            b.visibility=a?0:1
    }
};
Ee.UI.Xaml.Media._TextBlock.registerClass("Ee.UI.Xaml.Media._TextBlock",Ee.UI.Xaml.Media._DomElement);
Ee.UI.Xaml.Media._MultiStateButton=function(k,j,f,h,g,i){
    Ee.UI.Xaml.Media._MultiStateButton.initializeBase(this,[k,j,f,h,g,i]);
    var c=arguments.length-6;
    this._animationsOn=new Array(c);
    this._animationsOff=new Array(c);
    this._controls=new Array(c);
    var e=this.get_control();
    for(var a=0;a<c;a++){
        var d=arguments[a+6],b=e?e.findName(d):null;
        this._controls[a]=b||null;
        this._animationsOn[a]=b?b.findName(d+"_Show"):null;
        this._animationsOff[a]=b?b.findName(d+"_Hide"):null
    }
};
Ee.UI.Xaml.Media._MultiStateButton.prototype={
    _state:0,
    _animationsOn:null,
    _animationsOff:null,
    _controls:null,
    get_state:function(){
        return this._state
    },
    set_state:function(b){
        if(b!==this._state){
            var a=this._animationsOff[this._state];
            if(a)
                a.begin();
            else{
                var c=this._controls[this._state];
                if(c)
                    c.visibility=1
            }
            this._state=b;
            a=this._animationsOn[this._state];
            if(a)
                a.begin();
            else{
                var d=this._controls[this._state];
                if(d)d.visibility=0
            }
        }
    },
    dispose:function(){
        Ee.UI.Xaml.Media._MultiStateButton.callBaseMethod(this,"dispose");
        this._animationsOn=null;
        this._animationsOff=null;
        this._controls=null;
        this._state=0
    }
};
Ee.UI.Xaml.Media._MultiStateButton.registerClass("Ee.UI.Xaml.Media._MultiStateButton",Ee.UI.Xaml.Media._Button);
Ee.UI.Xaml.Media._ImageList=function(d,a){
    Ee.UI.Xaml.Media._ImageList.initializeBase(this,[d,a]);
    var c=this.get_control();
    if(!c)
        return;
    c.cursor="Arrow";
    this._scrollAnimationSB=c.findName(a+"_ScrollAnimationStoryboard");
    if(this._scrollAnimationSB)
        this._scrollAnimation=c.findName(a+"_ScrollAnimation");
    var b=this._scrollAnimation?this._scrollAnimation.duration.seconds*1000:200;
    b=Math.max(b,200);
    this._scrollNext=new Ee.UI.Xaml.Media._Button(d,a+"_ScrollNext",b,this._scrollNextClick,null,this);
    this._scrollPrev=new Ee.UI.Xaml.Media._Button(d,a+"_ScrollPrevious",b,this._scrollPrevClick,null,this);
    this._findItems(a);
    this._virtualItems=[]
};
Ee.UI.Xaml.Media._ImageList.prototype={
    _items:null,
    _virtualItems:null,
    _scrollNext:null,
    _scrollPrev:null,
    _scrollAnimation:null,
    _scrollAnimationSB:null,
    _itemSize:0,
    _itemSpacing:0,
    _overflowIndex:0,
    get_items:function(){
        return this._virtualItems
    },
    set_items:function(a){
        this._virtualItems=Array.clone(a);
        this._reset();
        this._assignImages()
    },
    onItemClick:function(){},
    _assignImages:function(){
        for(var b=0,d=this._items.length;b<d;b++){
            var a=this._items[b],c=this._itemOffset+b;
            if(c<this._virtualItems.length){
                a.image.Source=this._virtualItems[c];
                a.button.get_control().visibility=0;
                a.button._virtualIndex=c
            }
            else 
                a.button.get_control().visibility=1
        }
    },
    _findItems:function(b){
        var a=this.get_control(),d=1;
        this._items=[];
        var c=b+"_ScrollItem1",
            e=b+"_ScrollItem1_Image",
            h=a.findName(c),
            g=a.findName(e);
        while(h){
            var i=new Ee.UI.Xaml.Media._Button(a.getHost(),c,null,this._itemClick,null,this,true);
            i._physicalIndex=d-1;
            this._items[this._items.length]={
                button:i,image:g
            };
            d++;
            c=b+"_ScrollItem"+d;
            e=b+"_ScrollItem"+d+"_Image";
            h=a.findName(c);
            g=a.findName(e)
        }
        if(this._items.length===0)
            throw Error.invalidOperation("ImageList needs at least one scroll item.");
        var f=this._items[0].button.get_control();
        this._itemSize=f.width;
        this._itemSpacing=f["Canvas.Left"]*2
    },
    _handleOverflow:function(c){
        var d=c===1?this._items.length-1:-1,
            b=this._itemOffset+d,
            a=this._items[this._overflowIndex];
        a.image.Source=this._virtualItems[b];
        a.button._virtualIndex=b;
        var e=a.button.get_control();
        e["Canvas.Left"]=b*(this._itemSize+this._itemSpacing)+this._itemSpacing/2;
        this._overflowIndex+=c;
        if(this._overflowIndex<0)
            this._overflowIndex=this._items.length-1;
        else if(this._overflowIndex>=this._items.length)
            this._overflowIndex=0
    },
    _itemClick:function(a){
        this.onItemClick(a._virtualIndex)
    },
    _reset:function(){
        this._itemOffset=0;
        for(var a=0,c=this._items.length;a<c;a++){
            var b=this._items[a].button;
            b._virtualIndex=a;
            b.get_control()["Canvas.Left"]=a*(this._itemSize+this._itemSpacing)+this._itemSpacing/2
        }
        this._overflowIndex=this._items.length-1;
        if(this._scrollAnimation){
            this._scrollAnimation.To="0";
            this._scrollAnimationSB.begin()
        }
    },
    _scroll:function(a){
        if(this._scrollAnimation){
            this._handleOverflow(a);
            var b=this._itemOffset;
            this._itemOffset+=a;
            this._scrollAnimation.From="-"+b*(this._itemSize+this._itemSpacing);
            this._scrollAnimation.To="-"+this._itemOffset*(this._itemSize+this._itemSpacing);
            this._scrollAnimationSB.begin()
        }else{
            this._itemOffset+=a;
            this._assignImages()
        }
    },
    _scrollNextClick:function(){
        if(this._itemOffset<this._virtualItems.length-this._items.length+1)
            this._scroll(1)
    },
    _scrollPrevClick:function(){
        if(this._itemOffset>0)
            this._scroll(-1)
    },
    dispose:function(){
        if(this._scrollNext)
            this._scrollNext.dispose();
        if(this._scrollPrev)
            this._scrollPrev.dispose();
        this._scrollNext=null;
        this._scrollPrev=null;
        if(this._items){
            for(var a=0,c=this._items.length;a<c;a++){
                var b=this._items[a].button;
                b.dispose()
            }
            this._items=null
        }
        this._virtualItems=null;
        this._itemSize=null;
        this._itemSpacing=null;
        this._scrollAnimation=null;
        this._scrollAnimationSB=null;
        Ee.UI.Xaml.Media._ImageList.callBaseMethod(this,"dispose")
    }
};
Ee.UI.Xaml.Media._ImageList.registerClass("Ee.UI.Xaml.Media._ImageList",Ee.UI.Xaml.Media._DomElement);
Ee.UI.Xaml.Media._ChapterArea=function(a){
    this._player=a;
    var b=Ee.UI.Xaml.Media.PlayerElementName;
    Ee.UI.Xaml.Media._ChapterArea.initializeBase(this,[a.get_element(),b.chapterArea]);
    var c=this.get_control();
    if(c)
        this._toggleButton=new Ee.UI.Xaml.Media._Button(a.get_element(),b.chapterToggleButton,null,this._onToggle,null,this)
};
Ee.UI.Xaml.Media._ChapterArea.prototype={
    _player:null,
    _visible:false,
    _toggleButton:null,
    activate:function(){
        var a=this.get_control();
        if(!a)
            return;
        a.visibility=0;
        this._toggleButton.setVisible(true)
    },
    deactivate:function(){
        var a=this.get_control();
        if(!a)
            return;
        a.visibility=1;
        this._toggleButton.setVisible(false)
    },
    dispose:function(){
        Ee.UI.Xaml.Media._ChapterArea.callBaseMethod(this,"dispose");
        this._player=null;
        if(this._toggleButton)
            this._toggleButton.dispose();
        this._toggleButton=null
    },
    onItemClick:function(a){
        this._player.set_currentChapter(this._imageChapters[a])
    },
    setChapters:function(c){
        if(!this.get_control())
            return;
        var b=[];
        if(c){
            this._imageChapters=[];
            for(var a=0,e=c.length;a<e;a++){
                var d=c[a];
                if(d.imageUrl){
                    this._imageChapters[this._imageChapters.length]=a;
                    b[b.length]=d.imageUrl
                }
            }
        }
        this.set_items(b)
    },
    _onToggle:function(){
        this._visible=!this._visible;
        this.setVisible(this._visible);
        var a=this.get_control();
        if(a)
            a.IsHitTestVisible=this._visible
    }
};
Ee.UI.Xaml.Media._ChapterArea.registerClass("Ee.UI.Xaml.Media._ChapterArea",Ee.UI.Xaml.Media._ImageList);
Ee.UI.Xaml.Media._Slider=function(a,e,c,d,b){
    Ee.UI.Xaml.Media._Slider.initializeBase(this,[a,c]);
    this._slider=this.get_control();
    this._thumb=new Ee.UI.Xaml.Media._DomElement(a,e);
    this._thumbControl=this._thumb.get_control();
    if(!this._thumbControl||!this._slider)
        return;
    this._highlight=new Ee.UI.Xaml.Media._DomElement(a,c+"_Highlight");
    this._highlightControl=this._highlight.get_control();
    this._slider.cursor="Hand";
    this._thumbControl.cursor="Hand";
    this._thumb.bindEvent("mouseLeftButtonDown",null,this._thumbMouseLeftButtonDown,this);
    this._thumb.bindEvent("mouseLeftButtonUp",null,this._thumbMouseLeftButtonUp,this);
    this._thumb.bindEvent("mouseMove",null,this._thumbMouseMove,this);
    this.bindEvent("mouseLeftButtonDown",null,this._sliderLeftButtonDown,this);
    this._rootToken=this._slider.getHost().content.root.addEventListener("mouseLeave",Function.createDelegate(this,this._cancelDragging));
    this._isHorizontal=this._slider.width>=this._slider.height;
    if(this._highlightControl)
        this._highlightControl[this._isHorizontal?"width":"height"]=0;
    if(b)
        this._changedHandler=Function.createDelegate(b,d)
};
Ee.UI.Xaml.Media._Slider.prototype={
    _slider:null,
    _thumb:null,
    _thumbControl:null,
    _enableSeeking:true,
    _highlight:null,
    _highlightControl:null,
    _isDragging:false,
    _isHorizontal:true,
    _rootToken:null,
    set_enabled:function(a){
        if(this.get_enabled()!==a){
            Ee.UI.Xaml.Media._Slider.callBaseMethod(this,"set_enabled",[a]);
            this._highlight.set_enabled(a);
            this._thumb.setVisible(a);
            if(this._thumbControl)
                this._thumbControl.cursor=a?"Hand":"Default";
            if(!a)
                this.set_value(0);
            if(this._slider)
                this._slider.cursor=a?"Hand":"Default"
        }
    },
    get_enableSeeking:function(){
        return !!this._enableSeeking
    },
    set_enableSeeking:function(a){
        if(this._enableSeeking!==a){
            this._enableSeeking=a;
            if(!a)
                this._cancelDragging()
        }
    },
    get_value:function(){
        if(!this._thumbControl||!this._slider)
            return 0;
        var a;
        if(this._isHorizontal){
            a=this._thumbControl["Canvas.Left"]-this._slider["Canvas.Left"];
            a=a/(this._slider.width-this._thumbControl.width)
        }else{
            a=this._thumbControl["Canvas.Top"]-this._slider["Canvas.Top"]+this._thumbControl.height/2;
            a=1-a/this._slider.height
        }
        a=Math.round(a*1000)/1000;
        return Math.min(1,Math.max(0,a))
    },
    set_value:function(a){
        a=Math.min(1,Math.max(0,a));
        this._setThumbPosition(a)
    },
    dispose:function(){
        if(this._highlight)
            this._highlight.dispose();
        if(this._thumb)
            this._thumb.dispose();
        this._changedHandler=null;
        if(this._rootToken)
            this._slider.getHost().content.root.removeEventListener("mouseLeave",this._rootToken);
        this._slider=null;
        this._thumb=null;
        this._thumbControl=null;
        this._rootToken=null;
        this._highlight=null;
        this._highlightControl=null;
        Ee.UI.Xaml.Media._Slider.callBaseMethod(this,"dispose")
    },
    _cancelDragging:function(){
        if(this._isDragging){
            this._isDragging=false;
            this._thumbControl.ReleaseMouseCapture()
        }
    },
    _setThumbPosition:function(b){
        if(this._thumbControl&&this._slider){
            var a=this._toLocation(b);
            if(this._isHorizontal){
                this._thumbControl["Canvas.Left"]=this._slider["Canvas.Left"]+a-this._thumbControl.width/2;
                if(this._highlightControl)
                    this._highlightControl.width=a+this._thumbControl.width/2
            }else{
                this._thumbControl["Canvas.Top"]=this._slider["Canvas.Top"]+a-this._thumbControl.height/2;
                if(this._highlightControl){
                    this._highlightControl["Canvas.Top"]=this._thumbControl["Canvas.Top"]+this._thumbControl.height/2;
                    this._highlightControl.height=b*(this._slider.height-this._thumbControl.height)-this._thumbControl.height/2
                }
            }
        }
    },
    _sliderLeftButtonDown:function(c,a){
        if(!this._enableSeeking)
            return false;
        var b=this._toValue(a.getPosition(c));
        this._setThumbPosition(b);
        if(this._changedHandler)
            this._changedHandler();
        if(this._thumbControl){
            this._isDragging=true;
            this._thumbControl.CaptureMouse()
        }
        return true
    },
    _thumbMouseLeftButtonDown:function(){
        if(!this._enableSeeking)
            return false;
        this._isDragging=true;
        this._thumbControl.CaptureMouse();
        return true
    },
    _thumbMouseLeftButtonUp:function(){
        if(!this._enableSeeking)
            return false;
        this._isDragging=false;
        this._thumbControl.ReleaseMouseCapture();
        return true
    },
    _thumbMouseMove:function(b,a){
        if(this._isDragging){
            this._setThumbPosition(this._toValue(a.getPosition(this._slider)));
            if(this._changedHandler)
                this._changedHandler()
        }
        return true
    },
    _toValue:function(b){
        var a;
        if(this._isHorizontal)
            a=(b.X-this._thumbControl.width/2)/(this._slider.width-this._thumbControl.width);
        else{
            a=(b.Y-this._thumbControl.height/2)/(this._slider.height-this._thumbControl.height);
            a=1-a
        }
        return Math.min(1,Math.max(0,a))
    },
    _toLocation:function(a){
        a=Math.min(1,Math.max(0,a));
        if(this._isHorizontal)
            return a*(this._slider.width-this._thumbControl.width)+this._thumbControl.width/2;
        else{
            var b=this._slider.height-this._thumbControl.height;
            return b-a*b+this._thumbControl.height/2
        }
    }
};
Ee.UI.Xaml.Media._Slider.registerClass("Ee.UI.Xaml.Media._Slider",Ee.UI.Xaml.Media._DomElement);
Ee.UI.Xaml.Media._ProgressBar=function(c,d,b){
    Ee.UI.Xaml.Media._ProgressBar.initializeBase(this,[c,d]);
    var a=this.get_control();
    if(a){
        this._originalWidth=a.width;
        a.width=0
    }
    if(b){
        this._xamlText=new Ee.UI.Xaml.Media._TextBlock(c,b);
        this._xamlText.set_text("")
    }
};
Ee.UI.Xaml.Media._ProgressBar.prototype={
    _xamlText:null,
    _originalWidth:0,
    get_value:function(){
        var a=this.get_control();
        if(!a)
            return 0;
        return a.width/this._originalWidth
    },
    set_value:function(a){
        var b=this.get_control();
        if(b)
            b.width=this._originalWidth*a;
        this._xamlText.set_text(""+Math.floor(a*100))
    },
    setVisible:function(a){
        Ee.UI.Xaml.Media._ProgressBar.callBaseMethod(this,"setVisible",[a]);
        if(this._xamlText)
            this._xamlText.setVisible(a)
    },
    dispose:function(){
        Ee.UI.Xaml.Media._ProgressBar.callBaseMethod(this,"dispose");
        if(this._xamlText){
            this._xamlText.dispose();
            this._xamlText=null
        }
    }
};
Ee.UI.Xaml.Media._ProgressBar.registerClass("Ee.UI.Xaml.Media._ProgressBar",Ee.UI.Xaml.Media._DomElement);
Type.registerNamespace("EePlayer");
EePlayer.UrlParam={
    startTime:"startTime",
    chapter:"chapter",
    loopCount:"loopCount",
    mediaUrl:"mediaUrl",
    volume:"volume",
    muted:"muted",
    duration:"duration",
    autoplay:"autoplay",
    mediainfo:"mediainfo"
};
EePlayer.Player=function(a){
    EePlayer.Player.initializeBase(this,[a]);
    this._fInitialized=false
};
EePlayer.Player.prototype={
    initialize:function(){
        EePlayer.Player.callBaseMethod(this,"initialize");
        this.set_autoPlay($getArgument(EePlayer.UrlParam.autoplay,this.get_autoPlay().toString())==="true");
        this.set_mediaUrl($getArgument(EePlayer.UrlParam.mediaUrl,this.get_mediaUrl()));
        this.set_muted($getArgument(EePlayer.UrlParam.muted,this.get_muted().toString())==="true");
        this.set_volume(parseFloat($getArgument(EePlayer.UrlParam.volume,this.get_volume())));
        this.set_timeIndex(parseFloat($getArgument(EePlayer.UrlParam.startTime,this.get_timeIndex())));
        this.set_mediainfo($getArgument(EePlayer.UrlParam.mediainfo,this.get_mediainfo()));
        var a=$getArgument(EePlayer.UrlParam.chapter);
        if(a!=="")
            this.set_currentChapter(parseInt(a));
        if(this.get_mediainfo()!=="")
            this._initMediainfo();
        this._fInitialized=true
    },
    get_mediainfo:function(){
        return this._mediainfo
    },
    set_mediainfo:function(a){
        this._mediainfo=a;
        if(this._fInitialized)
            this._initMediainfo()
    },
    _initMediainfo:function(){
        if(typeof this._mediainfo==="string"){
            var b=new Sys.Net.WebRequest;
            b.set_url(this._mediainfo);
            b.add_completed(Function.createDelegate(this,this._loadedMediainfo));
            var a=new Sys.Net.XMLHttpExecutor;
            b.set_executor(a);
            a.executeRequest();
            var c=a.get_started()
        }
        else if(typeof this._mediainfo==="function"){
            this.set_chapters(this._mediainfo().chapters);
            this.set_placeholderImage(this._mediainfo().placeholderImage);
            this.set_mediaUrl(this._mediainfo().mediaUrl)
        }
        else if(this._mediainfo.mediaUrl!=null){
            this.set_chapters(this._mediainfo.chapters);
            this.set_placeholderImage(this._mediainfo.placeholderImage);
            this.set_mediaUrl(this._mediainfo.mediaUrl)
        }
        else 
            throw Error.invalidOperation("unknown type for mediainfo")
    },
    _loadedMediainfo:function(executor,eventArgs){
        if(executor.get_statusText()==="OK"){
            try{
                eval("("+executor.get_responseData()+")");
                var mediainfoJSON=mediainfo();
                this.set_chapters(mediainfoJSON.chapters);
                this.set_placeholderImage(mediainfoJSON.placeholderImage);
                this.set_mediaUrl(mediainfoJSON.mediaUrl)
            }
            catch(a){
                throw Error.invalidOperation("problem with mediainfo")
            }
        }
    },
    set_timeIndex:function(a){
        if(this._mediaElement&&this._canSeek&&a>this._naturalduration)
            this._raiseEvent("mediaEnded",Sys.EventArgs.Empty);
        else 
            EePlayer.Player.callBaseMethod(this,"set_timeIndex",[a])
    }
};
EePlayer.Player._playerCount=0;
EePlayer.Player._getUniqueName=function(a){
    return a+EePlayer.Player._playerCount++
};
EePlayer.Player.registerClass("EePlayer.Player",Ee.UI.Xaml.Media.Player);
function $getArgument(g,b){
    var f=window.location.search.substring(1),d=f.split("&"),e=g.toLowerCase();
    for(var a=0;a<d.length;a++){
        var c=d[a].split("=");
        if(c[0].toLowerCase()===e)
            return unescape(c[1])
    }
    if(typeof b!=="undefined")return b;
    return ""
};

