var v_currentCategoryInfo = new CurrentCategoryInfo();

function CurrentCategoryInfo() 
{
	this.CategoryID = "";
	this.LayoutDisplayType = "";
}

function SfRequestVariables(){}
SfRequestVariables.PresentationExperienceID = "peid"; //!! must be in sync with RequestVariableNames.PresentationExperienceID
SfRequestVariables.PresentationID = "pid";
SfRequestVariables.EventID = "eventid";
SfRequestVariables.MediaTicketId = "mediaid";
SfRequestVariables.MetaDataID = "metaDataID";
SfRequestVariables.PollID = "pollID";
SfRequestVariables.PollShowType = "pollShowType";
SfRequestVariables.ViewerMode = "mode";
SfRequestVariables.ViewerModeDefault = "Default";
SfRequestVariables.PlayerType = "playerType";
SfRequestVariables.SlideNumber = "slideNum";
SfRequestVariables.PlayFrom = "playFrom";
SfRequestVariables.ShouldResize = "shouldResize";
SfRequestVariables.EndVideo = "endVideo";
SfRequestVariables.IsLive = "isLive";
SfRequestVariables.UserTicketId = "ticketId";
SfRequestVariables.WindowLoc = "wndLoc";
SfRequestVariables.OverridePort25PluginInstall = "overridePort25PluginInstall";

function StartViewer(url, viewerMode, shouldResize)
{
	var playerType = new PlayerDetect().GetPlayerType();
	var playerWidth = 790;
	var playerHeight = 569;
	if (playerType == PlayerType.Unknown)
	{
		alert('You must have Windows Media 6.4 player or higher installed in your machine.');
		return;
	}
	
	WindowHelper.CreatePopup(url + 
		'&' + SfRequestVariables.PlayerType + '=' + playerType + 
		'&' + SfRequestVariables.ViewerMode + '=' + viewerMode +
		'&' + SfRequestVariables.ShouldResize + '=' + shouldResize,
		'Viewer', 
		playerWidth , 
		playerHeight , 
		false, 
		true);
}

// BEGINFILE PlayerDetect.js ------------------------------------------------------------------------------->

function PlayerType(){}
	PlayerType.WM64 = "WM64";
	PlayerType.WM64Lite = "WM64Lite";
	PlayerType.WM7 = "WM7";
	PlayerType.Port25 = "Port25";
	PlayerType.Unknown = "Unknown";
	PlayerType.SL1 = "SL1";


function PlayerDetect()
{
	this.PlayerType = null;
	
	this.SystemInfo = new SystemInfo();
	
	this.GetPlayerType = function()
	{
		if (this.PlayerType == null)
		{
			this.CreatePlayerType();
		}
		return this.PlayerType;
	}
	
	this.CreatePlayerType = function()
	{
		if (this.IsWin())
		{
			if (this.IsIE())
			{
				this.SetWinIEPlayerType();
				return;
			}
			else if (this.IsMozilla())
			{
				this.SetWinMozillaPlayerType();
				return;
			}
		}
		else if (this.IsMac())
		{
			this.SetMacPlayerType();
			return;
		}
		else
		{
			SfDebug(SfDebug.ErrMsgCritical, 'defaulting to WM64 playertype');
			this.PlayerType = this.WM64Lite;
		}
	}
	
	this.SetMacPlayerType = function()
	{
		this.PlayerType = PlayerType.SL1;
		return;
	}
	
	this.IsIntel = function()
	{
		return (this.SystemInfo.Browser.Agent.toLowerCase().indexOf("intel") > -1);
	}
	
	this.SetWinMozillaPlayerType = function()
	{
		if (IsPluginPresent() == true)
		{
			this.PlayerType = PlayerType.Port25;
			return;
		}

		this.PlayerType = PlayerType.WM64Lite;

		function IsPluginPresent()
		{
			for	(var i=0; i<navigator.plugins.length; ++i)
			{
				var plugin = navigator.plugins[i];
				if (
					(plugin.name && plugin.name.indexOf("np-mswmp") > -1)
					||
					(plugin.description && plugin.description.indexOf("np-mswmp") > -1)
					)
				{
					return true;
				}
			}
			return false;
		}
	}
	
	this.SetWinIEPlayerType = function()
	{
		if (this.HasWMP7())
		{
			this.PlayerType = PlayerType.WM7;
			return;
		}
		if (this.HasWMP64())
		{
			this.PlayerType = PlayerType.WM64;
			return;
		}
		this.PlayerType = PlayerType.WM64Lite;
	}
	
	this.IsMozilla = function()
	{
		return (this.SystemInfo.Browser.Type == BrowserType.Mozilla);
	}
	
	this.IsOpera = function()
	{
		return (this.SystemInfo.Browser.Type == BrowserType.Opera);
	}
	
	this.IsMac = function()
	{	
		return (this.SystemInfo.Browser.OSGeneric == OSTypeGeneric.Macintosh);
	}
	
	this.IsWin = function()
	{
		return (this.SystemInfo.Browser.OSGeneric == OSTypeGeneric.Windows);
	}
	
	this.IsIE = function()
	{
		return (this.SystemInfo.Browser.Type == BrowserType.InternetExplorer);
	}

	this.HasWMP7 = function()
	{	
		try
		{
			new ActiveXObject("WMPlayer.OCX.7");
			return true;
		}
		catch (ex)
		{
			return false;
		}
	}

	this.HasWMP64 = function()
	{	
		try
		{
			new ActiveXObject("MediaPlayer.MediaPlayer.1");
			return true;
		}
		catch (ex)
		{
			return false;
		}
	}
}
// ENDFILE PlayerDetect.js --------------------------------------------------------------------------------->

// BEGINFILE SystemInfo.js --------------------------------------------------------------------------------->

var BrowserType =
{
    Unknown:			0,
    InternetExplorer:	1,
    Mozilla:			2,
    AOL:				3,
    Opera:				4,
    WebTV:				5,
    OmniWeb:			6,  // apples osx browser
    Galeon:				7
}

var OSTypeGeneric=
{
	Unknown:	0,
	Windows:	1,
	Macintosh:	2,
	Unix:		3,
	OS2:		4
}

var OSTypeSpecific=
{
	Unknown:		0,
	Windows16:		1,
	Windows95:		2,
	Windows98:		3,
	WindowsME:		4,
	WindowsNT:		5,
	Windows2000:	6,
	WindowsXP:		7,
	OS2:			10,
	Sun:			11,
	Irix:			12,
	HPUX:			13,
	AIX:			14,
	DEC:			15,
	SCO:			16,
	VMS:			17,
	Linux:			18,
	Sinix:			19,
	Reliant:		20,
	FreeBSD:		21,
	OpenBSD:		22,
	NetBSD:			23,
	OtherBSD:		24,
	Unixware:		25,
	MPRAS:			26,
	x11:			27,
	Mac68k:			40,
	MacPPC:			41
}
	
function ScreenInfo()
{
	this.Width=640;
	this.Height=480;
	this.Depth=8;
	
	if (window.screen)
	{
		this.Width=window.screen.width;
		this.Height=window.screen.height;
		this.Depth=window.screen.colorDepth;
	}
}

function BrowserInfo(nav)
{
	this.Agent=nav.userAgent.toLowerCase();
	this.Platform="";
	if (nav.platform)
		this.Platform=nav.platform.toLowerCase();
	this.Application=nav.appName.toLowerCase();
	this.Version=nav.appVersion.toLowerCase();

	
	if (!BrowserInfo.prototype.ParseBrowserType)
	{
		BrowserInfo.prototype.ParseBrowserType=ParseBrowserType;
		BrowserInfo.prototype.ParseOS=ParseOS;
	}
	this.Type=BrowserType.Unknown;
	this.OSGeneric=OSTypeGeneric.Unknown;
	this.OSSpecific=OSTypeSpecific.Unknown;

	
	this.ParseBrowserType();
	this.ParseOS();
	

	this.VersionMajor=parseInt(this.Version);
	this.VersionMinor=parseFloat(this.Version);
	this.VersionMinor-=this.VersionMajor;
	this.VersionMinor=Math.round(this.VersionMinor*100);
	
	if (this.Type==BrowserType.InternetExplorer)
	{
		// all ie >4 report 4.0 need to fix this for ie
		var sub=this.Agent.slice(this.Agent.indexOf("msie ")+5);
		this.VersionMajor=parseInt(sub);
		this.VersionMinor=parseFloat(sub);
		this.VersionMinor-=this.VersionMajor;
		this.VersionMinor=Math.round(this.VersionMinor*100);
	}
	
	
	function ParseBrowserType()
	{
		if (this.Agent.indexOf("opera")>-1)
		{
			this.Type=BrowserType.Opera;
			return;
		}
			
		if (this.Agent.indexOf("msie")>-1)
		{
			this.Type=BrowserType.InternetExplorer;
			return;
		}
				
		if (this.Agent.indexOf("mozilla")>-1)
		{
			if (this.Agent.indexOf("compatible")<0)
			{
				this.Type=BrowserType.Mozilla;
				return;
			}
		}
		
		if (this.Agent.indexOf("aol")>-1)
		{
			this.Type=BrowserType.AOL;
			return;
		}
		
		if (this.Agent.indexOf("webtv")>-1)
		{
			this.Type=BrowserType.WebTV;
			return;
		}
		
		if (this.Agent.indexOf("omniweb")>-1)
		{
			this.Type=BrowserType.OmniWeb;
			return;
		}
		
		if (this.Agent.indexOf("galeon")>-1)
		{
			this.Type=BrowserType.Galeon;
			return;
		}
	}
	
	function ParseOS()
	{
	
		if (this.Agent.indexOf("win")>-1)
		{
			this.OSGeneric=OSTypeGeneric.Windows;
			
			
			if (this.Agent.indexOf("nt 5.1")>-1)
			{
				this.OSSpecific=OSTypeSpecific.WindowsXP;
				return;
			
			}
			
			if (this.Agent.indexOf("nt 5")>-1)
			{
				this.OSSpecific=OSTypeSpecific.Windows2000;
				return;
			
			}
			
			if (this.Agent.indexOf("nt")>-1)
			{
				this.OSSpecific=OSTypeSpecific.WindowsNT;
				return;
			
			}
						
			if (this.Agent.indexOf("win 9x 4.90")>-1)
			{
				this.OSSpecific=OSTypeSpecific.WindowsME;
				return;
			
			}			
			
			if (this.Agent.indexOf("98")>-1)
			{
				this.OSSpecific=OSTypeSpecific.Windows98;
				return;
			
			}			
			
			if (this.Agent.indexOf("95")>-1)
			{
				this.OSSpecific=OSTypeSpecific.Windows95;
				return;
			}
			
			if (this.Agent.indexOf("16")>-1)
			{
				this.OSSpecific=OSTypeSpecific.Windows16;
				return;
			}
			
			return;
		}
		
		if (this.Agent.indexOf("mac")>-1)
		{
			this.OSGeneric=OSTypeGeneric.Macintosh;
			
			if ((this.Agent.indexOf("68k")>-1) || (this.Agent.indexOf("68000")>-1))
			{
				this.OSSpecific=OSTypeSpecific.Mac68K;
				return;
			}
			
			if ((this.Agent.indexOf("ppc")>-1) || (this.Agent.indexOf("powerpc")>-1))
			{
				this.OSSpecific=OSTypeSpecific.MacPPC;
				return;
			}
			
			return;
		}
		
		if (this.Agent.indexOf("os/2")>-1)
		{
			this.OSGeneric=OSTypeGeneric.OS2;
			this.OSSpecific=OSTypeSpecific.OS2;
			return;
		}
		
	}

}


function SystemInfo()
{
	this.Screen= new ScreenInfo();
	this.Browser= new BrowserInfo(navigator);
	this.m_debugLevel = 4;
	
	this.Debug = function(msg)
	{
		SfDebug.DPF(this.m_debugLevel, "SystemInfo: " + msg);
	}
}

// ENDFILE SystemInfo.js ---------------------------------------------------------------------------------->

// BEGINFILE Windows.js ----------------------------------------------------------------------------------->

function WindowHelper(){}
	WindowHelper.IsOpen = function (wnd)
	{
		if (!wnd)
		{
			return false;
		}
		if (wnd == null)
		{
			return false;
		}
		if (wnd.closed == true)
		{
			return false;
		}
		return true;
	}

	WindowHelper.CreatePopup=function(sUrl,sName,nWidth,nHeight,fScrollbars,fResizeable)
	{
		// extra offset for mac
		var offsetX = 0;
		var offsetY = 0;

		nWidth=Math.floor(nWidth) + offsetX;
		nHeight=Math.floor(nHeight) + offsetY;

		var sFeatures = "width=" + nWidth + ",height=" + nHeight;
	       
		if (fScrollbars)
		{
			sFeatures += ",scrollbars=yes";
		}
		else
		{
			sFeatures += ",scrollbars=no";
		}
	        
		if (fResizeable)
		{
			sFeatures += ",resizable=yes";
		}
		else
		{
			sFeatures += ",resizable=no";
		}
		
		sFeatures += ",status=no";
	        
		var popup = window.open(sUrl,sName,sFeatures);
//		this.Center(popup, nWidth, nHeight);
	    
		return popup;
	}

	WindowHelper.Center=function(wnd,nWidth,nHeight)
	{
		var posX = Math.round((screen.availWidth-nWidth)/2);
		var posY=  Math.round((screen.availHeight-nHeight)/2);
		wnd.moveTo(posX,posY);
	}

// ENDFILE Windows.js ------------------------------------------------------------------------------------->

