/// MediaPlayer Status Display
PlayerStatusPanel = function(container, containingWindow, id)
{
	this.ID = id;
	
	this.OnLoad = function()
	{
		this.AddEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.PlayStateChanged, this.PlayStateChangedEventHandler.bind(this));
	}
	
	this.PlayStateChangedEventHandler = function(sender, state)
	{
		this.UpdateStatus(state);
	}
	
	this.UpdateStatus = function(status)
	{
		var name = SfKernel.GetPlayStateName(status);
		$(this.ID).innerHTML = name;
	}
}

/// MediaPlayer Language Selector
LanguageDropDownArea = function(container, containingWindow, id)
{
    this.ID = id;
    this.Container = container;
}
LanguageDropDownArea.prototype =
{
    LoadLanguages : function(Languages, CurrentIndex)
    {
  		this.Show();

		var template = new SfUI.Menu.MenuTemplate();
		template.CssPrefix = "LanguageSelectionMenu";
		template.LocationInfo = new SfUI.Menu.LocationInfo(0, 0, 40, 18);
		template.SubMenuSizeInfo = new SfUI.Menu.SizeInfo(150, 20);
		template.BaseBorderWidth = 0;
		template.BaseRightDivWidth = 16;
		template.LeftDivWidth = 19;
		var group = new SfUI.Menu.LeafGroup();
	    this.BaseMenuItem = new SfUI.Menu.BaseMenuItem(this.Container + ".BaseMenuItem", '', template, Localization.Common.Language);
	    //this.BaseMenuItem.SetToolTip(Localization.Common.Language);
		
		for (var i=0; i<Languages.length; ++i)
		{
			var func = new Function("", "mPlayer.PlayerAreaInstance.SetAudioLanguageIndex(" + Languages[i].Index + ");");
			var leaf = this.BaseMenuItem.AddLeaf(Languages[i].DisplayName, func);
			group.Add(leaf);
			if (i== (CurrentIndex-1))
			{
				group.Select(leaf);
			}
		}

		this.BaseMenuItem.CollapseChildrenNow();
		$(this.ID).appendChild(this.BaseMenuItem.RootDiv);

    },
    
	OnLoad : function()
	{
	    this.Hide();		
	},
	
	Show : function() 
	{
        $(this.ID).style.display = '';
    },
    
    Hide : function() 
    {
        $(this.ID).style.display = 'none';
    }
}

/// Media Player Position Display
PlayerPositionPanel=function(container,containingWindow,id){this.ID = id;}
PlayerPositionPanel.prototype={
    isDragging: false,    
    duration: 0,
       
    OnLoad:function()
    {    
        this.AddHandlers();
    },
        
    AddHandlers:function()
    {
        mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MediaLengthObtained,Function.createDelegate(this,this.SetDuration));
        mPlayer.EventManager.Events.addHandler(SfKernel.EventType.SliderNotify,Function.createDelegate(this,this.SliderNotifyHandler));
        mPlayer.EventManager.Events.addHandler(SfKernel.EventType.TimerLoop,Function.createDelegate(this,this.TimerLoopHandler));
        
    },
    
    SetDuration:function(sender,args)
    {        
        this.duration=args['Right'];
    },
    
    SliderNotifyHandler:function(sender,args)
    {
        var notifyType=args['NotifyType'];
        switch(notifyType)
        {
            case SfKernel.SliderNotifyType.NewPosition:
                this.UpdatePosition(args['Position']);
            break;
            case SfKernel.SliderNotifyType.DragPosition:
                this.UpdatePosition(args['Position']);
            break;
            case SfKernel.SliderNotifyType.BeginDrag:
                this.isDragging=true;
            break;
            case SfKernel.SliderNotifyType.EndDrag:
                this.isDragging=false;
            break;
        }        
    },
    
    UpdatePosition:function(pos)
    {
        var display = SfKernel.GetDisplayDuration(pos);
        if(this.duration > 0)
        {
            display += '/'+SfKernel.GetDisplayDuration(this.duration);
        }
        $(this.ID).innerHTML= display;
    },
    
    SetDisplayText:function(text)
    {
        $(this.ID).innerHTML=text;
    },
    
    TimerLoopHandler:function(sender,args)
    {
        if(this.isDragging){return;}this.UpdatePosition(args['Position']);
    }
 }

/// MediaPlayer Captioning Display
SamiDropDownPanel = function(container, containingWindow, id)
{
    this.ID = id;
    this.Container = container;
    
	this.IsClosedCaptioningVisible = false;
	this.ShowCaptioningText = Localization.PlayerLayoutResource.ShowCaptioning;
	this.HideCaptioningText = Localization.PlayerLayoutResource.HideCaptioning;
	this.CurrentIndex = -1;
	this.diplayArea = null;
	
	this.OnLoad = function()
	{
		if (Manifest.CaptionsFile.length < 1)
		{
            $(this.ID + 'Container').style.display = 'none';
			return;
		}

		this.Toggle = $('btnCC');
		this.displayArea = $(this.ID + 'Display');
		this.CaptioningContainer = $(this.ID + 'Container');
		
        this.CaptioningContainer.style.display = '';
        this.Toggle.style.display = '';
		
		this.Toggle.onclick = new Function("", this.Container + ".ToggleClosedCaptioning();");
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.TimerLoop, this.TimerLoopEventHandler.bind(this));
	}
	
	this.TimerLoopEventHandler = function(sender, args)
	{
	    this.CheckAdvance(args["Position"]);
	}
	
	this.ToggleClosedCaptioning = function() 
	{
		if ( this.IsClosedCaptioningVisible ) 
		{
            $('PresentationCardAreaInnerPadding').style.display = 'block';
			this.CaptioningContainer.style.display = 'none';
			
			if(document.all)
			{
                this.Toggle.title = this.ShowCaptioningText;
            } 
            else
            {            
                this.Toggle.title = this.ShowCaptioningText;
            }                       
		} 
		else 
		{
            $('PresentationCardAreaInnerPadding').style.display = 'none';
			this.CaptioningContainer.style.display = 'block';
			this.CaptioningContainer.style.height = '100%';
			
			if(document.all)
			{
               this.Toggle.title = this.HideCaptioningText;
            } 
            else
            {            
                this.Toggle.title = this.HideCaptioningText;
            }                       

		}

		this.IsClosedCaptioningVisible = !this.IsClosedCaptioningVisible;
	}
	
	this.Seek=function(currentPosition)
    {
        if (Manifest.CaptionsFile.length < 1)
        {
            return;
        }
        
        var currentTranscriptIndex = -1; 
        
        while ((currentTranscriptIndex+1)<Transcript.EventList.length)
        {
            var time = Transcript.EventList[currentTranscriptIndex+1].Time;
            
            if (currentPosition>=time)
            {
               currentTranscriptIndex++;
            }
            else 
            {
                break;
            }
        }
        
        this.SetTextIndex(currentTranscriptIndex);
    }

    this.Reset=function()
    {
        if (Manifest.CaptionsFile.length < 1)
        {
            return;
        }
        this.SetTextIndex(-1);
    }


    this.CheckAdvance=function(currentPosition)
    {
        if (Manifest.CaptionsFile.length < 1)
        {
            return;
        }
     
        var currentTranscriptIndex = this.CurrentIndex; 
        
        if (currentTranscriptIndex<0)
        {
            currentTranscriptIndex= -1;
        }
        
        while ((currentTranscriptIndex+1)<Transcript.EventList.length)
        {
            var time = Transcript.EventList[currentTranscriptIndex+1].Time;
            
            if (currentPosition>=time)
            {
               currentTranscriptIndex++;
            }
            else 
            {
                break;
            }
        }
                
        if (currentTranscriptIndex>this.CurrentIndex)
        {
            this.SetTextIndex(currentTranscriptIndex);
        }
    }

    this.SetTextIndex=function(index)
    {
        this.CurrentIndex=index;
                 
        if (index<0)
        {
            this.SetText("");
        }
        else if (index<Transcript.EventList.length)
        {
            this.SetText(Transcript.EventList[index].Text);
        }
    }

    this.SetText=function(text)
    {         
        if(this.displayArea)
        {
            this.displayArea.innerHTML = text;
        }        
    }
	
	
}


/// MediaPlayer Play/Pause Button
PlayPauseButton = function(id, container)
{
	this.id = id;
	this.IsEnabled = false;
	this.IsHilighted = false;
	this.Container =  container;
	
	this.PlayImageDetails = new SfUI.ButtonImage();
	this.PauseImageDetails = new SfUI.ButtonImage();
	this.StopImageDetails = new SfUI.ButtonImage();
	this.ToolTipPlay;
	this.ToolTipPause;
	this.ToolTipStop;
	
	var m_this = this;
	var m_link = null;
	var m_imageElement = null;
	var m_currentImageDetails = null;
	
	this.AllowPlay = true;
	
	this.Initialize = function()
	{

		m_imageElement = GetImage();
		m_link = GetLink();
		
		m_link.onmouseover = new Function("", this.Container + ".button.OnMouseOver();");
		m_link.onmouseout = new Function("", this.Container + ".button.OnMouseOut();");
		m_link.onclick = new Function("", this.Container + ".OnClick();");

		this._PreLoadImages();
				
		this.SetPlayImage();		
	}
	
	this._PreLoadImages = function()
	{
		var img = new Image();
		img.src = this.StopImageDetails.Over;
		img.src = this.StopImageDetails.Normal;
		img.src = this.StopImageDetails.Disabled;		
		img.src = this.PauseImageDetails.Over;
		img.src = this.PauseImageDetails.Normal;
		img.src = this.PauseImageDetails.Disabled;
		img.src = this.PlayImageDetails.Over;
		img.src = this.PlayImageDetails.Normal;
		img.src = this.PlayImageDetails.Disabled;
	}
	
	this.SetPlayImage = function()
	{
		m_currentImageDetails = m_this.PlayImageDetails;
		this.AllowPlay = true;
		this.Paint();
		this.SetToolTip(this.ToolTipPlay);
	}
	
	this.SetPauseImage = function()
	{
		m_currentImageDetails = m_this.PauseImageDetails;
		this.AllowPlay = false;
		this.Paint();
		this.SetToolTip(this.ToolTipPause);
	}
	
	this.SetStopImage = function()
	{
		m_currentImageDetails = m_this.StopImageDetails;
		this.AllowPlay = false;
		this.Paint();
		this.SetToolTip(this.ToolTipStop);
	}

	var GetImage = function()
	{
		var image = document.getElementById(m_this.id + "Img");
					
		return image;
	}
	
	var GetLink = function()
	{
		var link = document.getElementById(m_this.id + "Link");
				
		return link;
	}
	
	this.SetToolTip = function(strToolTip)
	{
		m_imageElement.alt = strToolTip;
		m_link.title = strToolTip;
	}
	
	this.Enable = function(enabled)
	{
		this.IsEnabled = enabled;
		
		this.Paint();
	}
	
	this.OnMouseOver = function()
	{
		this.IsHilighted = true;
		this.Paint();
	}
	
	this.OnMouseOut = function()
	{
		this.IsHilighted = false;
		this.Paint();
	}
	
	this.OnClick = function()
	{		
		if (this.IsEnabled)
		{
			this.ClickHandler();
		}
			
		this.Paint();
	}
	
	this.Paint = function()
	{
	
		var imgToSet;
		
		if (!this.IsEnabled)
		{
			imgToSet = m_currentImageDetails.Disabled;
		}
		else
		{
			if (this.IsHilighted)
			{
				imgToSet = m_currentImageDetails.Over;
			}
			else
			{
				imgToSet = m_currentImageDetails.Normal;
			}
		}
			
		m_imageElement.src = imgToSet;
	}
	
	this.ClickHandler = function()
	{
		Sys.Debug.trace("Unimplimented Button ClickHandler id: " + this.id);
	}
}

PlayPauseButtonArea = function(container, containingWindow, id)
{
	this.OnLoad = function()
	{
		this.button.Initialize();
	}
	
	this.OnDataLoad = function()
	{
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.AddEventHandlers = function()
	{
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MediaOpened, this.MediaOpenedEventHandler.bind(this));		
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.PlayStateChanged, this.PlayStateChangedEventHandler.bind(this));
	}
	
	this.MediaOpenedEventHandler = function(sender, args)
	{
    	this.button.Enable(true);
	}
	
	this.PlayStateChangedEventHandler = function(sender, state)
	{	    
	    if(Manifest.PlayStatus == SfKernel.PresentationPlayStatus.LiveEnded)
	    {
	        this.button.Enable(false);
	    }
		else
		{
		    this.OnPlayerStateChanged(state);
		}
	}

	this.OnPlayerStateChanged = function(state)
	{
		var playIsEnabled = true;		
		switch(state)
		{
			case SfKernel.MediaState.Stopped:
			case SfKernel.MediaState.Ready:
			case SfKernel.MediaState.Paused:
				playIsEnabled = true;				
				break;
			case SfKernel.MediaState.Playing:
			case SfKernel.MediaState.ScanForward:
			case SfKernel.MediaState.ScanReverse:
				playIsEnabled = false;
				break;
			default:
				return;
		}
		
		if (playIsEnabled)
		{
			this.button.SetPlayImage();
		}
		else
		{
		    if(Manifest.PlayStatus == SfKernel.PresentationPlayStatus.OnDemand)
		    {
		        this.button.SetPauseImage();    
		    }
		    else
		    {
		        this.button.SetStopImage();
		    }			
		}
	}

	this.OnClick = function()
	{
	    if(!this.button.IsEnabled)
	    {
	        return;
	    }
	    
		if (this.button.AllowPlay == true)
		{
			mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.Play, this, null);
		}
		else
		{
			if(Manifest.PlayStatus == SfKernel.PresentationPlayStatus.OnDemand)
		    {
		        mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.Pause, this, null);
		    }
		    else
		    {
		        mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.Stop, this, null);
		    }	
			
		}			
	}
	
}

/// MediaPlayer Skip Back Button
SkipbackButtonArea = function(container, containingWindow, id)
{	
	this.OnLoad = function()
	{
		this.button.Initialize();
		this.button.SetTooltip(Localization.Buttons.Skipback);
	}
	
	this.OnDataLoad = function()
	{
        if(Manifest.PlayStatus == SfKernel.PresentationPlayStatus.OnDemand)
	    {
	    	this.button.SetClickHandler(this.OnClick.bind(this));
		    this.AddEventHandlers();
		}
	}
	
	this.AddEventHandlers = function()
	{
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.PlayStateChanged, this.PlayStateChangedEventHandler.bind(this));
	}
		
	this.PlayStateChangedEventHandler = function(sender, state)
	{
		switch(state)
		{
			case SfKernel.MediaState.Playing:
			case SfKernel.MediaState.Paused:	
    			this.button.Enable(true);
				break;
			default:
			    this.button.Enable(false);			
				break;
		}	
	}

	this.OnClick = function()
	{
		mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.SkipBack, this, null);
	}
}

///MediaPlayer Speed Control
PlayerSpeedControlPanel = function(container, containingWindow, id) {
    this.ID = id;
    this._availableSpeeds$1 = [ 0.5, 0.66, 0.75, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2];
    this._availableSpeedsDisplay$1 = [ '1/2x', '2/3x', '3/4x', '4/5x', '1x', '1.2x', '1.4x', '1.6x', '1.8x', '2x']; 
    
}

PlayerSpeedControlPanel.prototype = {
    _leftDiv$1: null,
    _middleDiv$1: null,
    _rightDiv$1: null,
    _leftDivMouseOverHandler$1: null,
    _leftDivMouseOutHandler$1: null,
    _leftDivClickHandler$1: null,
    _rightDivMouseOverHandler$1: null,
    _rightDivMouseOutHandler$1: null,
    _rightDivClickHandler$1: null,
    _indexOfNormal$1: 3,
    _currentSpeedIndex$1: 3,
    _isLeftDivEnabled$1: true,
    _isRightDivEnabled$1: true,
    
    OnLoad: function() 
    {
        if (Manifest.PlayStatus != SfKernel.PresentationPlayStatus.OnDemand) {
            this.Hide();
            return;
        }
        this._initialize$1();
    },
        
    _initialize$1: function() {
        this._leftDiv$1 = $(this.ID + 'Left');
        this._middleDiv$1 = $(this.ID + 'Middle');
        this._rightDiv$1 = $(this.ID + 'Right');
        this._leftDivMouseOverHandler$1 = Function.createDelegate(this, this._leftDivOnMouseOver$1);
        this._leftDivMouseOutHandler$1 = Function.createDelegate(this, this._leftDivOnMouseOut$1);
        this._leftDivClickHandler$1 = Function.createDelegate(this, this._leftDivOnClick$1);
        this._rightDivMouseOverHandler$1 = Function.createDelegate(this, this._rightDivOnMouseOver$1);
        this._rightDivMouseOutHandler$1 = Function.createDelegate(this, this._rightDivOnMouseOut$1);
        this._rightDivClickHandler$1 = Function.createDelegate(this, this._rightDivOnClick$1);
        this._leftDiv$1.observe('mouseover', this._leftDivMouseOverHandler$1);
        this._leftDiv$1.observe('mouseout', this._leftDivMouseOutHandler$1);
        this._leftDiv$1.observe('click', this._leftDivClickHandler$1);
        this._rightDiv$1.observe('mouseover', this._rightDivMouseOverHandler$1);
        this._rightDiv$1.observe('mouseout', this._rightDivMouseOutHandler$1);
        this._rightDiv$1.observe('click', this._rightDivClickHandler$1);
        mPlayer.EventManager.CommandEvents.addHandler(SfKernel.CommandEventId.Play, Function.createDelegate(this, this._onPlay$1));
    },
    
    _onPlay$1: function PlayerSpeedControl$_onPlay$1(sender, args) {
        if (this._currentSpeedIndex$1 !== this._indexOfNormal$1) {
            this._changePlayerSpeed$1();
        }
    },
    
    _changePlayerSpeed$1: function PlayerSpeedControl$_changePlayerSpeed$1() {
        var param = {};
        param['PlaybackSpeed'] = this._availableSpeeds$1[this._currentSpeedIndex$1];
        mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.ChangePlaybackSpeed, this, param);
    },
    
    _leftDivOnMouseOver$1: function PlayerSpeedControl$_leftDivOnMouseOver$1(sender, args) {
        this._leftDiv$1.className = this.ID + 'LeftOver';
    },
    
    _leftDivOnMouseOut$1: function PlayerSpeedControl$_leftDivOnMouseOut$1(sender, args) {
        this._leftDiv$1.className = this.ID + 'LeftNormal';
    },
    
    _leftDivOnClick$1: function PlayerSpeedControl$_leftDivOnClick$1(sender, args) {
    
        if(!this._isLeftDivEnabled$1)
        {
            return;
        }
        --this._currentSpeedIndex$1;
        if (!this._currentSpeedIndex$1) {
            this._disableLeftDiv$1();
        }
        if (!this._isRightDivEnabled$1) {
            this._enableRightDiv$1();
        }
        this._changePlayerSpeed$1();
        this._displayCurrentSpeed$1();
    },
    
    _displayCurrentSpeed$1: function PlayerSpeedControl$_displayCurrentSpeed$1() {
        SfKernel.Util.SetText(this._middleDiv$1, this._availableSpeedsDisplay$1[this._currentSpeedIndex$1]);
    },
    
    _disableLeftDiv$1: function PlayerSpeedControl$_disableLeftDiv$1() {
        this._leftDiv$1.className = this.ID + 'LeftDisabled';
        this._leftDiv$1.stopObserving('mouseover', this._leftDivMouseOverHandler$1);
        this._leftDiv$1.stopObserving('mouseout', this._leftDivMouseOutHandler$1);
        this._leftDiv$1.stopObserving('click', this._leftDivClickHandler$1);
        this._isLeftDivEnabled$1 = false;
    },
    
    _enableLeftDiv$1: function PlayerSpeedControl$_enableLeftDiv$1() {
        this._leftDiv$1.className = this.ID + 'LeftNormal';
        this._leftDiv$1.observe('mouseover', this._leftDivMouseOverHandler$1);
        this._leftDiv$1.observe('mouseout', this._leftDivMouseOutHandler$1);
        this._leftDiv$1.observe('click', this._leftDivClickHandler$1);
        this._isLeftDivEnabled$1 = true;
    },
    
    _disableRightDiv$1: function PlayerSpeedControl$_disableRightDiv$1() {
        this._rightDiv$1.className = this.ID + 'RightDisabled';
        this._rightDiv$1.stopObserving('mouseover', this._rightDivMouseOverHandler$1);
        this._rightDiv$1.stopObserving('mouseout', this._rightDivMouseOutHandler$1);
        this._rightDiv$1.stopObserving('click', this._rightDivClickHandler$1);
        this._isRightDivEnabled$1 = false;
    },
    
    _enableRightDiv$1: function PlayerSpeedControl$_enableRightDiv$1() {
        this._rightDiv$1.className = this.ID + 'RightNormal';
        this._rightDiv$1.observe('mouseover', this._rightDivMouseOverHandler$1);
        this._rightDiv$1.observe('mouseout', this._rightDivMouseOutHandler$1);
        this._rightDiv$1.observe('click', this._rightDivClickHandler$1);
        this._isRightDivEnabled$1 = true;
    },
    
    _rightDivOnMouseOver$1: function PlayerSpeedControl$_rightDivOnMouseOver$1(sender, args) {
        this._rightDiv$1.className = this.ID + 'RightOver';
    },
    
    _rightDivOnMouseOut$1: function PlayerSpeedControl$_rightDivOnMouseOut$1(sender, args) {
        this._rightDiv$1.className = this.ID + 'RightNormal';
    },
    
    _rightDivOnClick$1: function PlayerSpeedControl$_rightDivOnClick$1(sender, args) {
    
        if(!this._isRightDivEnabled$1)
        {
            return;
        }
        ++this._currentSpeedIndex$1;
        if (this._currentSpeedIndex$1 === this._availableSpeeds$1.length - 1) {
            this._disableRightDiv$1();
        }
        if (!this._isLeftDivEnabled$1) {
            this._enableLeftDiv$1();
        }
        this._changePlayerSpeed$1();
        this._displayCurrentSpeed$1();
    },
    
   	Show: function() 
	{
        $(this.ID).style.display = 'block';
    },
    
    Hide: function() 
    {
        $(this.ID).style.display = 'none';
    }
}

/// MediaPlayer Mute Button

MuteButtonArea = function(container, containingWindow, id)
{
	this.OnLoad = function()
	{
		this.button.SetTooltip(Localization.Buttons.Mute);
		this.button.Initialize();
	}
	
	this.OnDataLoad = function()
	{	
		this.button.SetClickHandler(this.OnClick.bind(this));
		this.AddEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{		
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MediaOpened, this.PlayerSetupCompleteEventHandler.bind(this));		
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MuteToggled, this.MuteToggledEventHandler.bind(this));
	}
	
	this.PlayerSetupCompleteEventHandler = function(sender, args)
	{
		this.button.Enable(true);
	}
	
	this.MuteToggledEventHandler = function(sender, mute)
	{
		if (mute == true)
		{
			this.button.SetChecked(true);
			this.button.SetTooltip(Localization.Buttons.UnMute);
		}
		else
		{
			this.button.SetChecked(false);
			this.button.SetTooltip(Localization.Buttons.Mute);
		}
	}

	this.OnClick = function()
	{
		mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.Mute, this, null);
	}
}

/// MediaPlayer Volume Slider
VolumeSliderArea = function(container, containingWindow, id)
{
    this.ID = id;
	this.Slider = null;	
	this.VolumeInitializedEventHandler = null;	
	this.IsCurrentlyDragging = false;	
	this.Orientation = SfUI.SfSlider.Orientation.Vertical;
	
	this.OnLoad = function()
	{
		this.Initialize();
	}
	
	this.Initialize = function()
	{
		var imageInfo = {SliderBackroundImage:this.SliderBackgroundImage, ThumbImage:this.ThumbImage, ThumbOverImage:this.ThumbOverImage};
		this.Slider = new SfUI.SfSlider({NamePrefix:this.ID, Orientation:this.Orientation, ImageInfo:imageInfo});
	    this.AddEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Slider.AddClickHandler(Function.createDelegate(this, this.OnSliderClick));
		this.Slider.AddDragHandler(Function.createDelegate(this, this.OnSliderDrag));		
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.VolumeInitialized, this.VolumeInitializedEventHandler.bind(this));
	}
	
	this.VolumeInitializedEventHandler = function(sender, args)
	{
		this.Slider.SetPosition(args.Volume);
	}

	this.OnSliderClick = function(sender, args)
	{
		this.Slider.SetPosition(args.Position);
		this.PostSetVolumeCommand(args.Position);
	}
	
	this.OnSliderDrag = function(sender, dragArgs)
	{
		if (dragArgs.DragEventType == SfUI.SfSlider.DragEventType.DragMove)
		{
			this.Slider.SetPosition(dragArgs.Position);
			this.PostSetVolumeCommand(dragArgs.Position);
		}
		else if (dragArgs.DragEventType == SfUI.SfSlider.DragEventType.BeginDrag)
		{
			this.IsCurrentlyDragging = true;
		}
		else if (dragArgs.DragEventType == SfUI.SfSlider.DragEventType.EndDrag)
		{
			this.IsCurrentlyDragging = false;
		}
	}
	
	this.PostSetVolumeCommand = function(vol)
	{
		mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.SetVolume, this, {Volume:vol});
	}
}

CCButtonArea = function(container, containingWindow, id)
{
	this.OnLoad = function()
	{
		this.button.Initialize();
	}
	
	this.OnDataLoad = function()
	{	
		this.button.SetClickHandler(this.OnClick.bind(this));
		this.AddEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{		
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MediaOpened, this.PlayerSetupCompleteEventHandler.bind(this));	
	}
	
	this.PlayerSetupCompleteEventHandler = function(sender, args)
	{
		this.button.Enable(true);
	}

	this.OnClick = function()
	{
	}
}

/// MediaPlayer Full Screen Button
FullScreenButtonArea = function(container, containingWindow, id)
{
	this.OnLoad = function()
	{
		this.button.Initialize();
		this.button.SetTooltip(Localization.Buttons.FullScreen);
	}
	
	this.OnDataLoad = function()
	{
		this.button.SetClickHandler(this.OnClick.bind(this));
		this.AddEventHandlers();
	}
	
	this.EnableDisableButton = function()
	{
		if (Manifest.HasVideo == false)
		{
			this.button.Enable(false);
		}
		else
		{
			this.button.Enable(true);
		}
	}
	
	
	this.AddEventHandlers = function()
	{
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.MediaOpened, this.PlayerSetupCompleteEventHandler.bind(this));
		mPlayer.EventManager.Events.addHandler(SfKernel.EventType.PlayStateChanged, this.PlayStateChangedEventHandler.bind(this));
	}
	
	this.PlayerSetupCompleteEventHandler = function(sender, args)
	{
		this.EnableDisableButton();
	}
	
	this.PlayStateChangedEventHandler = function(sender,state)
	{
		switch(state)
		{
			case SfKernel.MediaState.Playing:
			case SfKernel.MediaState.Paused:	
    			this.button.Enable(true);
				break;
			default:
			    this.button.Enable(false);			
				break;
		}	
	}
	
	this.OnClick = function()
	{
		mPlayer.EventManager.PostCommandEvent(SfKernel.CommandEventId.FullScreen, this, null);
	}
	
}


