function CommandBar()
{
    mss.AddAnimationMouseEventListeners("CommandButton_Zoom",Event.createDelegate(this, this.handleZoomMouseUp));
	mss.AddAnimationMouseEventListeners("CommandButton_InfoCard",Event.createDelegate(this, this.handleInfoCardMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_SlideList",Event.createDelegate(this, this.handleSlideListMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_Pip",Event.createDelegate(this, this.handlePipMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_Links",Event.createDelegate(this, this.handleLinksMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_Chapters",Event.createDelegate(this, this.handleChaptersMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_Share",Event.createDelegate(this, this.handleShareMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_Magnify",Event.createDelegate(this, this.handleMagnifyMouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_HidePopups",Event.createDelegate(this, this.handleHidePopupsMouseUp));
    
    mss.AddAnimationMouseEventListeners("CommandButton_User1",Event.createDelegate(this, this.handleUser1MouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_User2",Event.createDelegate(this, this.handleUser2MouseUp));
    mss.AddAnimationMouseEventListeners("CommandButton_User3",Event.createDelegate(this, this.handleUser3MouseUp));
    this.CurrentZoom=0;
    this.CurrentButtonPanel=1;
}


CommandBar.prototype =
{

    handleZoomMouseUp: function(sender, eventArgs)
    {
        if (!Manifest.HasSlides)
        {
            return;
        }
        this.CurrentZoom++;

        if (!mss.Animate("CommandBar_Zoom_MouseUp_" + this.CurrentZoom))
        {
            this.CurrentZoom = 0;
            mss.Animate("CommandBar_Zoom_MouseUp_" + this.CurrentZoom);
        }
    },

    handleInfoCardMouseUp: function(sender, eventArgs)
    {
        window.mplayer.infoCard.Toggle();
        mss.Animate(MediasitePlayer.AnimationEvent.ButtonClickInfo);
    },

    handleSlideListMouseUp: function(sender, eventArgs)
    {
        if (!Manifest.HasSlides)
        {
            return;
        }
        window.mplayer.slideManager.Toggle();
        mss.Animate(MediasitePlayer.AnimationEvent.ButtonClickSlideList);
    },

    handlePipMouseUp: function(sender, eventArgs)
    {
        window.mplayer.pipManager.SwitchMode();
        mss.Animate(MediasitePlayer.AnimationEvent.ButtonClickPip);
    },


    handleLinksMouseUp: function(sender, eventArgs)
    {
        window.mplayer.linksPanel.Toggle();
        mss.Animate(MediasitePlayer.AnimationEvent.ButtonClickLinks);
    },

    handleChaptersMouseUp: function(sender, eventArgs)
    {
        window.mplayer.chaptersPanel.Toggle();
        mss.Animate(MediasitePlayer.AnimationEvent.ButtonClickChapters);
    },

    handleShareMouseUp: function(sender, eventArgs)
    {
        this.ShowSharePanel(true);
    },

    ShowSharePanel: function(show)
    {
        var panel = document.getElementById("ShareInfo");

        if (panel != null)
        {
            var vis = panel.style;

            if (show)
            {
                vis.display = '';
            }
            else
            {
                vis.display = 'none';
            }

        }
    },
    handleMagnifyMouseUp: function(sender, eventArgs)
    {
        if (!Manifest.HasSlides)
        {
            return;
        }
        if (window.mplayer.magnifier.Enabled)
        {
            window.mplayer.magnifier.Disable();
        }
        else
        {
            window.mplayer.magnifier.Enable();
        }

    },


    handleUser1MouseUp: function(sender, eventArgs)
    {
        mss.Animate("CommandBar_ButtonSwap_" + this.CurrentButtonPanel);
        this.CurrentButtonPanel++;
        if (this.CurrentButtonPanel > 2)
        {
            this.CurrentButtonPanel = 1;
        }
    },


    handleUser2MouseUp: function(sender, eventArgs)
    {
        this.handleMagnifyMouseUp(sender, eventArgs);
    },

    handleUser3MouseUp: function(sender, eventArgs)
    {

    },

    handleHidePopupsMouseUp: function(sender, eventArgs)
    {
        window.mplayer.RequestPanelSwitch("");
    }
}

