
// Copyright (c) 2003 Sonic Foundry, Inc. and Sonic Foundry 
// Media Systems, Inc. Neither this code nor any portion 
// thereof may be reproduced, altered, or otherwise changed, 
// distributed or copied, without the express written 
// permission of Sonic Foundry.  
// All rights reserved.

// BEGINFILE AskButtonArea.js -------------------------------------------------------------------------->
AskButtonArea.prototype = new AreaBase();
function AskButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	this.PrimarySpeakerEmail = "";
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "AskButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		
		this.HandleButtonState();
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		this.ScriptEventHandler = new SfEventHandler("AskButtonArea");
		this.ScriptEventHandler.MethodName = "OnScriptEvent";
		this.ScriptEventHandler.Container = this.Container;
		
		MainHelper.EventScript.AddHandler(this.ScriptEventHandler);

		this.DataAvailableEventHandler = new SfEventHandler("AskButtonArea");
		this.DataAvailableEventHandler.MethodName = "OnDataAvailableEvent";
		this.DataAvailableEventHandler.Container = this.Container;
		
		MainHelper.EventDataAvailable.AddHandler(this.DataAvailableEventHandler);
	}

	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		MainHelper.EventScript.RemoveHandler(this.ScriptEventHandler);
		MainHelper.EventDataAvailable.RemoveHandler(this.DataAvailableEventHandler);
	}
	
	this.OnScriptEvent = function(args)
	{
		this.Debug("OnScriptEvent called");
		switch(args.Command)
		{
			case SfScriptCommandType.EndPresentation:
				if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
				{
					this.button.Enable(false);
				}
				break;
		}
	}
	
	this.OnDataAvailableEvent = function(args)
	{
		this.Debug("DataAvailableEvent called");
		this.HandleButtonState();
	}

	this.HandleButtonState = function()
	{
		// live or replay
		if ( (MainHelper.Presentation.ForumEnabled == true) && 
			(
				(MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress) 
					|| (this.PrimarySpeakerEmail != "")
			)
		   )
		{
			this.button.Enable(true);
		}
		else
		{
			this.button.Enable(false);
		}
			
	}
	
	this.OnClick = function()
	{
		if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
		{
			// needs to be resizeable
			window.popupAsk = WindowHelper.CreateNamedPopup(PopupNames.Forum, "polls", 450, 305, true, false);
			if (window.popupAsk) 
			{
				window.popupAsk.focus();
			}
		}
		else if ( this.PrimarySpeakerEmail != "" )
		{
			window.location = "mailto:" + this.PrimarySpeakerEmail;
		}
	}
}
// ENDFILE AskButtonArea.js ---------------------------------------------------------------------------->
// BEGINFILE CloseButtonArea.js ------------------------------------------------------------------------>
CloseButtonArea.prototype = new AreaBase();
function CloseButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "CloseButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		top.close();
	}
}

// ENDFILE CloseButtonArea.js -------------------------------------------------------------------------->
// BEGINFILE FullScreenButtonArea.js ------------------------------------------------------------------->
FullScreenButtonArea.prototype = new AreaBase();
function FullScreenButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "FullScreenButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.RemoveEventHandlers();
	}
	
	this.EnableDisableButton = function()
	{
		this.Debug("EnableDisableButton called");
		if (MainHelper.Presentation.IsAudioOnly == true)
		{
			this.Debug("IsAudioOnly");
			this.button.Enable(false);
		}
		else
		{
			this.Debug("Not IsAudioOnly");
			this.button.Enable(true);
		}
	}
	
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.PlayerSetupCompleteEventHandler = new SfEventHandler("FullScreenButtonArea");
		this.PlayerSetupCompleteEventHandler.MethodName = "OnPlayerSetupCompleteEvent";
		this.PlayerSetupCompleteEventHandler.Container = this.Container;
		MainHelper.EventPlayerSetupComplete.AddHandler(this.PlayerSetupCompleteEventHandler);
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventPlayerSetupComplete.RemoveHandler(this.PlayerSetupCompleteEventHandler);
	}

	this.OnPlayerSetupCompleteEvent = function(args)
	{
		this.Debug("OnPlayerSetupCompleteEvent called");
		this.EnableDisableButton();
	}
	
	this.OnClick = function()
	{
		MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.FullScreen));
	}
	
}
// ENDFILE FullScreenButtonArea.js --------------------------------------------------------------------->
// BEGINFILE HelpButtonArea.js ------------------------------------------------------------------------->
HelpButtonArea.prototype = new AreaBase();
function HelpButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "HelpButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		WindowHelper.PopupHelp(GetPopupURL(PopupNames.Help),450,330);
	}
}

// ENDFILE HelpButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE ExtraInfoButtonArea.js ------------------------------------------------------------------------->
InfoButtonArea.prototype = new AreaBase();
function InfoButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.Enabled = true; // comes from code
	this.CommandName = null;// comes from code
	this.ControlArea = null;// comes from code
	this.DisableOnNoLinks = false; // comes from code
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "InfoButtonArea: ID, " + this.ID + ", msg: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		if (this.Enabled == false)
		{
			this.Debug("Not Enabled");
			this.Hide();
			return;
		}
		else
		{
			this.Debug("Enabled");
			this.Show();
		}

		this.CheckDisableOnNoLinks();
		
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		
	}
	
	this.CheckDisableOnNoLinks = function()
	{
		if (this.DisableOnNoLinks == true)
		{
			this.button.IsChecked = false;
			this.button.IsEnabled = false;
		}
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		if (this.button.IsChecked)
		{
			this.ControlArea.Hide();
		}
		else
		{
			this.ControlArea.Show();
		}
		this.button.SetCheck(!this.button.IsChecked);
	}
	
	this.ShowControlArea = function()
	{
		this.ControlArea.Show();	
		this.button.SetCheck(true);
	}
	
	this.HideControlArea = function()
	{
		this.ControlArea.Hide();
		this.button.SetCheck(false);
	}
}
// ENDFILE InfoButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE ExtraInfoButtonArea.js ------------------------------------------------------------------------->
ExtraInfoButtonArea.prototype = new AreaBase();
function ExtraInfoButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "ExtraInfoButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		
		if (this.Enabled == false)
		{
			this.Hide();
			return;
		}
		else
		{
			this.Show();
		}

		this.button.Initialize();
		
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		this.Debug("OnClick");
		
		if (this.button.IsChecked == true)
		{
			return;
		}
		
		this.button.SetCheck(true);
	
		MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.ShowExtraInfo));
	}
	
}
// ENDFILE ExtraInfoButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE ChapterPointsButtonArea.js ------------------------------------------------------------------------->
ChapterPointsButtonArea.prototype = new AreaBase();
function ChapterPointsButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "ChapterPointsButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad()");
		
		if (this.Enabled == false)
		{
			this.Hide();
			return;
		}
		else
		{
			this.Show();
		}

		this.button.Initialize();
		
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad()");
	}
	
	this.OnClick = function()
	{
		this.Debug("OnClick()");
		
		if (this.button.IsChecked == true)
		{
			return;
		}
		
		this.button.SetCheck(true);
	
		MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.ShowChapterPoints));
	}
	
}
// ENDFILE ChapterPointsButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE MaxSlideButtonArea.js --------------------------------------------------------------------->
MaxSlideButtonArea.prototype = new AreaBase();
function MaxSlideButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "MaxSlideButtonArea: " + msg);
	}
	
	this.RegisterEvents = function()
	{
		this.Debug("RegisterEvents called");
		this.ScriptEventHandler = new SfEventHandler(this.Container);
		this.ScriptEventHandler.Container = this.Container;
		this.ScriptEventHandler.MethodName = "OnScriptEvent";
		MainHelper.EventScript.AddHandler(this.ScriptEventHandler);
	}
	
	this.UnRegisterEvents = function()
	{
		this.Debug("UnRegisterEvents called");
		MainHelper.EventScript.RemoveHandler(this.ScriptEventHandler);
	}

	this.OnScriptEvent = function(args)
	{
		this.Debug("OnScriptEvent: " + args);
		switch(args.Command)
		{
			case SfScriptCommandType.EndPresentation:
				this.button.Enable(false);
				break;
			case SfScriptCommandType.ShowSlide:
				if (args.Index > 0)
				{
					this.button.Enable(true);
				}
				else
				{
					this.button.Enable(false);
				}
				break;
		}
	}

	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		if (this.ShouldEnableButtonInBeginning() == true)
		{
			this.button.IsEnabled = true;
		}
		else
		{
			this.button.IsEnabled = false;
		}
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		this.RegisterEvents();
	}
	
	this.ShouldEnableButtonInBeginning = function()
	{
		this.Debug("ShouldEnableButtonInBeginning");
		if (MainHelper.Presentation.Status != PresentationStatus.CaptureInProgress)
		{
			// disable all non-live presentations
			return false;
		}
		
		// it is a live presentation
		if (MainHelper.MaxSlideTimings > 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.UnRegisterEvents();
	}

	// need to duplicate the functionality in CurrentSlideArea
	// because of Google popup blocker issue	
	this.OnClick = function()
	{
		this.Debug("OnClick");
		
		if (WindowHelper.IsOpen(MainHelper.PopupWindows.FullSize) == true)
		{
			this.Debug("Is already open");
			return;
		}
		
		MainHelper.PopupWindows.FullSize =
			
			WindowHelper.CreateNamedPopup(
				PopupNames.FullSize,
				"FullSize",
				MainHelper.DefaultFullSizeWindowWidth,
				MainHelper.DefaultFullSizeWindowHeight,
				true,
				true);
	}
}
// ENDFILE MaxSlideButtonArea.js ----------------------------------------------------------------------->
// BEGINFILE MuteButtonArea.js ------------------------------------------------------------------------->
MuteButtonArea.prototype = new AreaBase();
function MuteButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "MuteButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.PlayerSetupCompleteEventHandler = new SfEventHandler("MuteButtonArea");
		this.PlayerSetupCompleteEventHandler.MethodName = "OnPlayerSetupCompleteEvent";
		this.PlayerSetupCompleteEventHandler.Container = this.Container;
		MainHelper.EventPlayerSetupComplete.AddHandler(this.PlayerSetupCompleteEventHandler);
		
 		this.VolumeChangedEventHandler = new SfEventHandler("MuteButtonArea");
		this.VolumeChangedEventHandler.MethodName = "OnVolumeChangedEvent";
		this.VolumeChangedEventHandler.Container = this.Container;
		MainHelper.EventVolumeChanged.AddHandler(this.VolumeChangedEventHandler);
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventPlayerSetupComplete.RemoveHandler(this.PlayerSetupCompleteEventHandler);
		MainHelper.EventVolumeChanged.RemoveHandler(this.VolumeChangedEventHandler);
	}

	this.OnPlayerSetupCompleteEvent = function(args)
	{
		this.Debug("OnPlayerSetupCompleteEvent called");
		this.button.Enable(true);
	}
	
	this.OnVolumeChangedEvent = function(args)
	{
		this.Debug("OnVolumeChangedEvent: " + args);
		switch(args.ChangeType)
		{
			case SfVolumeChangeType.Muted:
				this.button.SetCheck(true);
				this.button.SetToolTip("Mute Off");
				break;
			case SfVolumeChangeType.UnMuted:
				this.button.SetCheck(false);
				this.button.SetToolTip("Mute");
				break;
		}
	}

	this.OnClick = function()
	{
		MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.Mute));
	}
	
}

// ENDFILE MuteButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE NextSlideButtonArea.js -------------------------------------------------------------------->
NextSlideButtonArea.prototype = new AreaBase();
function NextSlideButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "NextSlideButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		
		this.button.Initialize();
		
		this.AddEventHandlers();
		
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		this.HandleButtonState(-1);
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.SlideChangedEventHandler = new SfEventHandler("NextSlideButtonArea");
		this.SlideChangedEventHandler.MethodName = "OnSlideChangedEvent";
		this.SlideChangedEventHandler.Container = this.Container;
		MainHelper.EventSlideChanged.AddHandler(this.SlideChangedEventHandler);
		
		this.PlayBeginEventHandler = new SfEventHandler("NextSlideButtonArea");
		this.PlayBeginEventHandler.MethodName = "OnPlayBeginEvent";
		this.PlayBeginEventHandler.Container = this.Container;
		MainHelper.EventPlayBegin.AddHandler(this.PlayBeginEventHandler);
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventSlideChanged.RemoveHandler(this.SlideChangedEventHandler);
		MainHelper.EventPlayBegin.RemoveHandler(this.PlayBeginEventHandler);
	}

	this.OnSlideChangedEvent = function(args)
	{
		this.Debug("OnSlideChanged called, :" + args.Index);
		var index = args.Index;
		this.HandleButtonState(Number(index));
	}
	
	this.OnPlayBeginEvent = function(args)
	{
		this.Debug("OnPlayBeginEvent");
		this.HandleButtonState(-1);
	}

	this.OnClick = function()
	{
		this.Debug("NextSlideHandler called");
		var currentSlide = MainHelper.CurrentSlideNumber;
		var maxSlide = MainHelper.MaxSlideTimings;
		this.Debug("CurrentSlide: " + currentSlide + ", maxSlide: " + maxSlide);
		if (currentSlide == -1 && maxSlide > 0)
		{
			var args = new CommandArgs(SfCommandType.NavigateToSlide);
			args.SlideNumber = 1;
			MainHelper.EventCommand.Post(args);
		}
		else if (currentSlide < maxSlide)
		{
			var args = new CommandArgs(SfCommandType.NavigateToSlide);
			args.SlideNumber = currentSlide + 1;
			MainHelper.EventCommand.Post(args);
		}
		else
		{
			SfDebug.DPF(SfDebug.ErrMsgSubCritical, "Next slide should not be called here");
			return;
		}

		this.TimedDisable(1000);
	}
	
	this.InTimeDisabled = false;
	this.EnableLater = false;
	this.TimedDisable = function(milliSeconds)
	{
		this.Debug("TimedDisable called: " + milliSeconds);
		
		this.InTimeDisabled = true;
		this.button.Enable(false);

		setTimeout(this.Container + '.TimedEnable()', milliSeconds);
	}
	
	this.TimedEnable = function()
	{
		this.Debug("TimedEnable called");
		
		if (this.EnableLater == true)
		{
			this.Debug("Enabling Next button");
			this.button.Enable(true);
		}
		else
		{
			this.Debug("Disabling Next button");
			this.button.Enable(false);
		}
		
		this.InTimeDisabled = false;
	}

	this.HandleButtonState = function(currentSlide)
	{
		this.Debug("HandleButtonState called, CurrentSlide: " + currentSlide);
		this.EnableLater = false;
		
		if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
		{
			// disable in live mode
			this.button.Enable(false);
			return;
		}
		
		var maxSlide = MainHelper.MaxSlideTimings;
		this.Debug("MaxSlide: " + maxSlide);
		if (currentSlide == -1)
		{
			// uninitialized
			if (maxSlide > 0)
			{
				this.button.Enable(true);
			}
			else
			{
				this.button.Enable(false);
			}
			return;
		}
		
		if (currentSlide < maxSlide)
		{
			if (this.InTimeDisabled == true)
			{
				this.EnableLater = true;
			}
			else
			{
				this.button.Enable(true);
			}
		}
		else
		{
			this.button.Enable(false);
		}
	}
	
}
// ENDFILE NextSlideButtonArea.js ---------------------------------------------------------------------->
// BEGINFILE OptionsButtonArea.js ---------------------------------------------------------------------->
OptionsButtonArea.prototype = new AreaBase();
function OptionsButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "OptionsButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		
		this.HandleButtonState();
	}
	
	this.HandleButtonState = function()
	{
		if (MainHelper.Presentation.IsStandAlone == true)
		{
			// in standalone these are always disabled
			this.button.Enable(false);
		}
		else
		{
			// live or replay
			this.button.Enable(true);
		}		
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		// needs to be resizeable
		window.popupoptions = WindowHelper.CreateNamedPopup(PopupNames.Options,"__options",400,200,false,false);
		if (window.popupoptions) 
		{
			window.popupoptions.focus();
		}
	}
}
// ENDFILE OptionsButtonArea.js ------------------------------------------------------------------------>
// BEGINFILE PlayPauseButton.js ------------------------------------------------------------------------>
function PlayPauseButton(id)
{
	this.DebugLevel = SfDebug.Verbose;

	this.id = id;
	
	this.IsEnabled = true;
	this.IsHilighted = false;
	
	this.PlayImageDetails = new SfButtonImage();
	this.PauseImageDetails = new SfButtonImage();
	this.ToolTipPlay;
	this.ToolTipPause;
	
	var m_this = this;
	var m_link = null;
	var m_imageElement = null;
	var m_currentImageDetails = null;
	
	this.AllowPlay = true;
	
	this.Initialize = function()
	{
		this.Debug("Initialize()");

		m_imageElement = GetImage();
		m_link = GetLink();
		
		m_link.onmouseover = new Function("", this.Container + ".OnMouseOver();");
		m_link.onmouseout = new Function("", this.Container + ".OnMouseOut();");
		m_link.onclick = new Function("", this.Container + ".OnClick();");
		
		this.SetPlayImage();		
	}
	
	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);
	}

	var GetImage = function()
	{
		var image = SfDOM.FindElementFromID(document, m_this.id + "Img");
		
		if (image == null)
		{
		    SfDebug.DPF(SfDebug.ErrMsgCritical,"No image for " + m_this.id + "Img");
		}
			
		return image;
	}
	
	var GetLink = function()
	{
		var link = SfDOM.FindElementFromID(document, m_this.id + "Link");
		
		if (link == null)
		{
		    SfDebug.DPF(SfDebug.ErrMsgCritical,"No link for " + 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.Debug("OnMouseOver()");
		this.IsHilighted = true;
		this.Paint();
	}
	
	this.OnMouseOut = function()
	{
		this.Debug("OnMouseOut()");
		this.IsHilighted = false;
		this.Paint();
	}
	
	this.OnClick = function()
	{
		this.Debug("OnClick()");
		
		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.Debug = function(msg)
	{
		SfDebug.DPF(this.DebugLevel, "Container: " + this.Container + ", Msg: " + msg);
	}
	
	this.ClickHandler = function()
	{
		alert("Unimplimented Button ClickHandler id: " + this.id);
	}
}
// ENDFILE PlayPauseButton.js ------------------------------------------------------------------------------>
// BEGINFILE PlayPauseButtonArea.js ------------------------------------------------------------------------->
PlayPauseButtonArea.prototype = new AreaBase();
function PlayPauseButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "PlayPauseButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.PlayerSetupCompleteEventHandler = new SfEventHandler("PlayPauseButtonArea");
		this.PlayerSetupCompleteEventHandler.MethodName = "OnPlayerSetupCompleteEvent";
		this.PlayerSetupCompleteEventHandler.Container = this.Container;
		MainHelper.EventPlayerSetupComplete.AddHandler(this.PlayerSetupCompleteEventHandler);
		
		this.PlayerStateChangedEventHandler = new SfEventHandler("PlayPauseButtonArea");
		this.PlayerStateChangedEventHandler.MethodName = "OnPlayerStateChangedEvent";
		this.PlayerStateChangedEventHandler.Container = this.Container;
		MainHelper.EventPlayerStateChanged.AddHandler(this.PlayerStateChangedEventHandler);
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventPlayerSetupComplete.RemoveHandler(this.PlayerSetupCompleteEventHandler);
		MainHelper.EventPlayerStateChanged.RemoveHandler(this.PlayerStateChangedEventHandler);
	}

	this.OnPlayerSetupCompleteEvent = function(args)
	{
		this.Debug("OnPlayerSetupCompleteEvent called");
		if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
		{
			this.button.Enable(false);
		}
		else
		{
			this.button.Enable(true);
		}
	}
	
	this.OnPlayerStateChangedEvent = function(state)
	{
		this.Debug("OnPlayerStateChangedEvent(): " + state);
		
		if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
		{
			this.OnPlayerStateChangedLive(state);
		}
		else
		{
			this.OnPlayerStateChangedOnDemand(state);
		}
	}

	this.OnPlayerStateChangedLive = function(state)
	{
		this.Debug("OnPlayerStateChangedLive(): " + state);
		switch(state)
		{
			case PlayState.Stopped:
			case PlayState.Ready:
			case PlayState.Paused:
				this.button.Enable(true);
				break;
			case PlayState.Playing:
			case PlayState.ScanForward:
			case PlayState.ScanReverse:
				this.button.Enable(false);
				break;
			default:
				return;
		}
	}

	this.OnPlayerStateChangedOnDemand = function(state)
	{
		this.Debug("OnPlayerStateChangedOnDemand(): " + state);
		var playIsEnabled = true;
		var pauseIsEnabled = false;
		switch(state)
		{
			case PlayState.Stopped:
			case PlayState.Ready:
			case PlayState.Paused:
				playIsEnabled = true;
				pauseIsEnabled = false;
				break;
			case PlayState.Playing:
			case PlayState.ScanForward:
			case PlayState.ScanReverse:
				playIsEnabled = false;
				pauseIsEnabled = true;
				break;
			default:
				return;
		}
		
		if (playIsEnabled)
		{
			this.button.SetPlayImage();
		}
		else
		{
			this.button.SetPauseImage();
		}
	}

	this.OnClick = function()
	{
		if (this.button.AllowPlay == true)
		{
			MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.Play));
		}
		else
		{
			MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.Pause));
		}			
	}
	
}
// ENDFILE PlayPauseButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE PollButtonArea.js ------------------------------------------------------------------------->
PollButtonArea.prototype = new AreaBase();
function PollButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "PollButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		
		this.HandleButtonState();
	}
	
	this.HandleButtonState = function()
	{
		this.Debug("HandleButtonState called");

		// in standalone these are always disabled
		if (MainHelper.Presentation.IsStandAlone == true)
		{
			this.Debug("disabling for standalone");
			this.button.Enable(false);
			return;
		}
		
		if ( (MainHelper.Presentation.PollsEnabled == false) && (MainHelper.Presentation.PollResultsEnabled == false) )
		{
			this.Debug("no polls are present");
			this.button.Enable(false);
		}
		else
		{
			this.Debug("polls present");
			this.button.Enable(true);
		}
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
	}
	
	this.OnClick = function()
	{
		this.Debug("OnClick called");
		// needs to be resizeable
		window.popupPoll = WindowHelper.CreateNamedPopup(PopupNames.ShowPolls, "polls", 600, 450, true, false);
		if (window.popupPoll) 
		{
			window.popupPoll.focus();
		}
	}
}
// ENDFILE PollButtonArea.js --------------------------------------------------------------------------->
// BEGINFILE PreviousSlideButtonArea.js ---------------------------------------------------------------->
PreviousSlideButtonArea.prototype = new AreaBase();
function PreviousSlideButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "PreviousSlideButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		
		this.button.Initialize();
		
		this.AddEventHandlers();
		
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
		this.HandleButtonState(-1);
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.SlideChangedEventHandler = new SfEventHandler("PreviousSlideButtonArea");
		this.SlideChangedEventHandler.MethodName = "OnSlideChangedEvent";
		this.SlideChangedEventHandler.Container = this.Container;
		MainHelper.EventSlideChanged.AddHandler(this.SlideChangedEventHandler);

		this.PlayBeginEventHandler = new SfEventHandler("PreviousSlideButtonArea");
		this.PlayBeginEventHandler.MethodName = "OnPlayBeginEvent";
		this.PlayBeginEventHandler.Container = this.Container;
		MainHelper.EventPlayBegin.AddHandler(this.PlayBeginEventHandler);
		
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventSlideChanged.RemoveHandler(this.SlideChangedEventHandler);
		MainHelper.EventPlayBegin.RemoveHandler(this.PlayBeginEventHandler);
	}

	this.OnSlideChangedEvent = function(args)
	{
		this.Debug("OnSlideChanged called, :" + args.Index);
		var index = args.Index;
		this.HandleButtonState(Number(index));
	}
	
	this.OnPlayBeginEvent = function(args)
	{
		this.Debug("OnPlayBeginEvent");
		this.HandleButtonState(-1);
	}

	this.OnClick = function()
	{
		this.Debug("Previous SlideHandler called");
		
		var currentSlide = MainHelper.CurrentSlideNumber;
		this.Debug("OnClick CurrentSlide: " + currentSlide);
		
		var toJumpTo;
		if (MainHelper.PresentationEnded == true)
		{
			if (MainHelper.MaxSlideTimings > 0)
			{
				toJumpTo = MainHelper.MaxSlideTimings;
			}
			else
			{
				SfDebug.DPF(SfDebug.ErrMsgSubCritical, "PreviousSlide should not be called here");
				return;
			}
		}
		else if (currentSlide > 1)
		{
			toJumpTo = currentSlide-1;
		}
		else
		{
			SfDebug.DPF(SfDebug.ErrMsgSubCritical, "PreviousSlide should not be called here");
			return;
		}

		var args = new CommandArgs(SfCommandType.NavigateToSlide);
		args.SlideNumber = (toJumpTo);
		MainHelper.EventCommand.Post(args);
		
		this.TimedDisable(1000);
	}
	
	this.InTimeDisabled = false;
	this.EnableLater = false;
	this.TimedDisable = function(milliSeconds)
	{
		this.Debug("TimedDisable called for: " + milliSeconds);
		
		this.InTimeDisabled = true;
		this.button.Enable(false);

		setTimeout(this.Container + '.TimedEnable()', milliSeconds);
	}
	
	this.TimedEnable = function()
	{
		this.Debug("TimedEnable called");
		if (this.EnableLater == true)
		{
			this.Debug("Enabling Previous button");
			this.button.Enable(true);
		}
		else
		{
			this.Debug("Disabling Previous button");
			this.button.Enable(false);
		}
		
		this.InTimeDisabled = false;
	}

	this.HandleButtonState = function(currentSlide)
	{
		this.Debug("HandleButtonState called, CurrentSlide: " + currentSlide);
		this.EnableLater = false;
		
		if (MainHelper.Presentation.Status == PresentationStatus.CaptureInProgress)
		{
			// disable in live mode
			this.button.Enable(false);
			return;
		}
		
		if (currentSlide < 2)
		{
			// uninitialized, or slide number 1
			this.button.Enable(false);
			return;
		}
		
		if (this.InTimeDisabled == true)
		{
			this.EnableLater = true;
		}
		else
		{
			this.button.Enable(true);
		}
	}
	
}
// ENDFILE PreviousSlideButtonArea.js ------------------------------------------------------------------>
// BEGINFILE StopButtonArea.js ------------------------------------------------------------------------->
StopButtonArea.prototype = new AreaBase();
function StopButtonArea(container, containingWindow, ID)
{
	this.m_debugLevel = SfDebug.Verbose;
//	this.m_debugLevel = SfDebug.Information;
	
	this.InitializeArea(container, containingWindow, ID);
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "StopButtonArea: " + msg);
	}
	
	this.OnLoad = function()
	{
		this.Debug("OnLoad");
		this.button.Initialize();
		this.AddEventHandlers();
		this.button.ClickHandler = new Function("", this.Container + ".OnClick();");
	}
	
	this.OnUnLoad = function()
	{
		this.Debug("OnUnLoad");
		this.RemoveEventHandlers();
	}
	
	this.AddEventHandlers = function()
	{
		this.Debug("AddEventHandlers");
		
		this.PlayerSetupCompleteEventHandler = new SfEventHandler("StopButtonArea");
		this.PlayerSetupCompleteEventHandler.MethodName = "OnPlayerSetupCompleteEvent";
		this.PlayerSetupCompleteEventHandler.Container = this.Container;
		MainHelper.EventPlayerSetupComplete.AddHandler(this.PlayerSetupCompleteEventHandler);
		
		this.PlayerStateChangedEventHandler = new SfEventHandler("StopButtonArea");
		this.PlayerStateChangedEventHandler.MethodName = "OnPlayerStateChangedEvent";
		this.PlayerStateChangedEventHandler.Container = this.Container;
		MainHelper.EventPlayerStateChanged.AddHandler(this.PlayerStateChangedEventHandler);
	}
	
	this.RemoveEventHandlers = function()
	{
		this.Debug("RemoveEventHandler");
		
		MainHelper.EventPlayerSetupComplete.RemoveHandler(this.PlayerSetupCompleteEventHandler);
		MainHelper.EventPlayerStateChanged.RemoveHandler(this.PlayerStateChangedEventHandler);
	}

	this.OnPlayerSetupCompleteEvent = function(args)
	{
		this.Debug("OnPlayerSetupCompleteEvent called");
		this.button.Enable(true);
	}
	
	this.OnPlayerStateChangedEvent = function(state)
	{
		this.Debug("OnPlayerStateChangedEvent: " + state);
		var stopIsEnabled = true;

		switch(state)
		{
			case PlayState.Paused:
			case PlayState.Stopped:
			case PlayState.Ready:
				stopIsEnabled = false;
				break;
			case PlayState.Playing:
				stopIsEnabled = true;
				break;
			default:
				return;
		}
	
		this.Debug("ButtonEnabledState: " + stopIsEnabled);
		if (stopIsEnabled)
		{
			if (this.button.IsEnabled == false)
			{
				this.button.Enable(true);
			}
		}
		else
		{
			if (this.button.IsEnabled == true)
			{
				this.button.Enable(false);
			}
		}
	}

	this.OnClick = function()
	{
		MainHelper.EventCommand.Post(new CommandArgs(SfCommandType.Stop));
	}
	
}
// ENDFILE StopButtonArea.js --------------------------------------------------------------------------->
