//Objects

/////////////////////////////////////////////////////////////////////////////
//
// Title:  Launcher()
//
// Description: This object creates the launch codes.
//	
// Methods:
//
// 1. openWindow() : sets links to open a window for higher than required resolutions.
// 2. openScrolls() : sets links to open a scrollable window for matched res on ie
// 3. openNormal() : sets links to open a chromeless window for use with F11.
//
/////////////////////////////////////////////////////////////////////////////
myLauncher = new Object();
myLauncher.openWindow = function()
	{
		var lurl = "\'"+url_ns+"?f11=false\'";
		launchButton = document.getElementById("controls");
		launchButton.innerHTML = "<a onClick=\"var player = window.open("+lurl+",\'cshell\',\'height=\' + courseHeight + \',width=\' + courseWidth + \',fullscreen=no,menubar=no,toolbar=no,statusbar=no,directories=0,\' + '\fullscreen=0,location=0,menubar=0,status=0,vtoolbar=0;\');\">"+messages[35]+"<IMG SRC=\'course/next.jpg\' WIDTH=\'78\' HEIGHT=\'40\' BORDER=\'0\'></a>";
	}
myLauncher.openScrolls = function()
	{
		var lurl = "\'"+url_sc+"?f11=false\'";
		launchButton = document.getElementById("controls");
		launchButton.innerHTML = "<a onClick=\"var player = window.open("+lurl+",\'cshell\',\'height=\' + courseHeight + \',width=\' + courseWidth + \',scrollbars=yes,fullscreen=yes,menubar=no,toolbar=no,statusbar=no,directories=0,\' + '\scrollbars=1,fullscreen=1,location=0,menubar=0,status=0,vtoolbar=0;\');\">"+messages[35]+"<IMG SRC=\'course/next.jpg\' WIDTH=\'78\' HEIGHT=\'40\' BORDER=\'0\'></a>";
	}
myLauncher.openNormal = function()
	{
		var lurl = "\'"+url_ns+"?f11=true\'";
		launchButton = document.getElementById("controls");
		launchButton.innerHTML = "<a onClick=\"var player = window.open("+lurl+",\'cshell\',\'height=\' + courseHeight + \',width=\' + courseWidth + \',scroll=no,scrollbars=no,fullscreen=yes,menubar=no,toolbar=no,statusbar=no,directories=0,\' + '\scroll=0,scrollbars=0,fullscreen=1,location=0,menubar=0,status=0,vtoolbar=0;\');\">"+messages[35]+"<IMG SRC=\'course/next.jpg\' WIDTH=\'78\' HEIGHT=\'40\' BORDER=\'0\'></a>";
	}
myLauncher.openOptions = function()
	{
		var lurlsc = "\'"+url_sc+"?f11=false\'";
		var lurlns = "\'"+url_ns+"?f11=false\'";
		launchButton = document.getElementById("controls");
		launchButton.innerHTML = "<a onClick=\"var player = window.open("+lurlns+",\'cshell\',\'height=\' + courseHeight + \',width=\' + courseWidth + \',scroll=no,scrollbars=no,fullscreen=yes,menubar=no,toolbar=no,statusbar=no,directories=0,\' + '\scroll=0,scrollbars=0,fullscreen=1,location=0,menubar=0,status=0,vtoolbar=0;\');\">"+messages[36]+"<IMG SRC=\'course/next.jpg\' WIDTH=\'78\' HEIGHT=\'40\' BORDER=\'0\'></a>";
		launchButton.innerHTML += "<br><a onClick=\"var player = window.open("+lurlsc+",\'cshell\',\'height=\' + courseHeight + \',width=\' + courseWidth + \',scroll=yes,scrollbars=yes,fullscreen=yes,menubar=no,toolbar=no,statusbar=yes,directories=0,\' + '\scroll=1,scrollbars=1,fullscreen=1,location=0,menubar=0,status=0,vtoolbar=0;\');\">"+messages[37]+"<IMG SRC=\'course/next.jpg\' WIDTH=\'78\' HEIGHT=\'40\' BORDER=\'0\'></a>";
		launchButton.innerHTML += "<br>" + messages[38];
	}
//Functions

/////////////////////////////////////////////////////////////////////////////
//
// Title:  branchBrowser()
//
// Description: This function determines which browser, version, and platform
// is currently accessing the course and calls the appropriate launcher.
//
/////////////////////////////////////////////////////////////////////////////
function branchBrowser()
{
	var browserMessage;
	var mediaMessage;
	//"Resolution is "+yyyxyyy
	var resolutionMessage;
	var aspectMessage;
	var messageOutput = document.getElementById("messageContainer");
	var linkVal;
	if(myScreenAspect=="43")
	{
		//"Screen aspect ratio is 4:3"+": <font color='green'>Meets the recommendation.</font>"
		aspectMessage = indicators[0]+messages[27]+messages[17];
	}
	else if(myScreenAspect=="54")
	{
		//"Screen aspect ratio is 5:4"+": <font color='green'>Meets the recommendation.</font>"
		aspectMessage = indicators[0]+messages[28]+messages[25];
	}
	else if (myScreenAspect=="53")
	{
		//"Screen aspect ratio is 5:3"+": <font color='orange'>Your wide aspect ratio monitor may cause distortion.  Consider changing your settings to 4:3 or 5:4, if possible.</font>"
		aspectMessage = indicators[2]+messages[31]+messages[30];
	}
	else if (myScreenAspect=="169")
	{
		//"Screen aspect ratio is 16:9"+": <font color='orange'>Your wide aspect ratio monitor may cause distortion.  Consider changing your settings to 4:3 or 5:4, if possible.</font>"
		aspectMessage = indicators[2]+messages[29]+messages[30];
	}
	else if (myScreenAspect=="unk")
	{
		aspectMessage = indicators[2]+messages[33]+messages[30];
	}
	//Test for Internet Explorer
	if(BrowserDetect.browser=="Explorer")
	{
		if (BrowserDetect.version >= 7)
		{
			//"Browser is "+"Internet "+Explorer+" version "+6+": <font color='green'>Meets the recommendation.</font>"
			browserMessage = indicators[0]+messages[22]+messages[26]+BrowserDetect.browser+messages[23]+BrowserDetect.version+messages[17];

			//Get media player message if neccesary
			mediaMessage = msieMediaPlayerCheck();
			//If screen is larger than required prep to launch in a window
			if(myScreenSize==1)
			{
				//prepare messages
				//"Resolution is "+yyyxyyy+": <font color='green'>Meets the recommendation.</font>"
				resolutionMessage = indicators[0]+messages[24]+" "+width+"x"+height+messages[17];
				messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];
				//issue the launch command	
				myLauncher.openWindow();			
			}
			else if(myScreenSize==2 || myScreenSize==3 || myScreenSize==4 || myScreenSize==5)
			{				
				//prepare messages
				//Resolution is "+yyyxyyy+": <font color='orange'>Your screen resolution is less than recommended.  Consider resizing your screen to higher resolution and restarting.  If you choose to continue, scrollbars will be present.</font>"
				resolutionMessage = indicators[2]+messages[24]+" "+width+"x"+height+messages[18];
				messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];	
				//issue the launch command
				//myLauncher.openScrolls();
				myLauncher.openScrolls();
			}
			else
			{
				//"Your screen resolution is not supported.  Please change the resolution to "+courseWidth+", "+courseHeight+" or greater."
				resolutionMessage = indicators[3]+messages[24]+" "+width+"x"+height+messages[19]+courseWidth+", "+courseHeight+messages[20];
				//Do not display launch button.
			}
		}
		else if (BrowserDetect.version <= 6)
		{
			//"Browser is "+"Internet "+Explorer+" version "+6+": <font color='green'>Meets the recommendation.</font>"
			browserMessage = indicators[0]+messages[22]+messages[26]+BrowserDetect.browser+messages[23]+BrowserDetect.version+messages[17];

			//Get media player message if neccesary
			mediaMessage = msieMediaPlayerCheck();
			//If screen is larger than required prep to launch in a window
			if(myScreenSize==1)
			{
				//prepare messages
				//"Resolution is "+yyyxyyy+": <font color='green'>Meets the recommendation.</font>"
				resolutionMessage = indicators[0]+messages[24]+" "+width+"x"+height+messages[17];
				messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];
				//issue the launch command	
				myLauncher.openWindow();			
			}
			else if(myScreenSize==2 || myScreenSize==3 || myScreenSize==4 || myScreenSize==5)
			{				
				//prepare messages
				//Resolution is "+yyyxyyy+": <font color='orange'>Your screen resolution is less than recommended.  Consider resizing your screen to higher resolution and restarting.  If you choose to continue, scrollbars will be present.</font>"
				resolutionMessage = indicators[2]+messages[24]+" "+width+"x"+height+messages[18];
				messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];	
				//issue the launch command
				//myLauncher.openScrolls();
				myLauncher.openOptions();
			}
			else
			{
				//"Your screen resolution is not supported.  Please change the resolution to "+courseWidth+", "+courseHeight+" or greater."
				resolutionMessage = indicators[3]+messages[24]+" "+width+"x"+height+messages[19]+courseWidth+", "+courseHeight+messages[20];
				//Do not display launch button.
			}
		}
		else
		{
			//"Your screen resolution is not supported.  Please change the resolution to "+courseWidth+", "+courseHeight+" or greater."
			resolutionMessage = indicators[3]+messages[24]+" "+width+"x"+height+messages[19]+courseWidth+", "+courseHeight+messages[20];
			//Do not display launch button.
		}
		
	}

	else if (BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Mozilla" || BrowserDetect.browser=="Netscape" || BrowserDetect.browser=="Opera")
	{
		//"Browser is "+"Internet "+Explorer+" version "+6+": <font color='green'>Meets the recommendation.</font>"
		browserMessage = indicators[0]+messages[22]+BrowserDetect.browser+messages[23]+BrowserDetect.version+messages[17];
		//Is Windows Media Player present?
		mediaMessage = nonMSMediaPlayerCheck();
		branchBrowserF11(browserMessage, mediaMessage, resolutionMessage, aspectMessage, messageOutput);
	}
	else
	{
		browserMessage = indicators[3]+messages[22]+BrowserDetect.browser+messages[23]+BrowserDetect.version+messages[34];
		//Is Windows Media Player present?
	}
}
function branchBrowserF11(browserMessage, mediaMessage, resolutionMessage, aspectMessage, messageOutput)
{
	//If screen is larger than required prep to launch in a window
	if(myScreenSize==1)
	{
		//prepare messages
		//"Resolution is "+yyyxyyy+": <font color='green'>Meets the recommendation.</font>"
		resolutionMessage = indicators[0]+messages[24]+" "+width+"x"+height+messages[17];
		messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];
		//issue the launch command	
		myLauncher.openWindow();			
	}
	else if(myScreenSize==2 || myScreenSize==4)
	{
		
		//prepare messages
		//Resolution is "+yyyxyyy+": <font color='orange'>Your screen resolution is less than recommended.  Consider resizing your screen to higher resolution and restarting.  If you choose to continue, scrollbars will be present.</font>"
		resolutionMessage = indicators[2]+messages[24]+" "+width+"x"+height+messages[32];
		messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];	
		//issue the launch command
		myLauncher.openNormal();
	}
	else if(myScreenSize==3 || myScreenSize==5)
	{
		
		//prepare messages
		//Resolution is "+yyyxyyy+": <font color='orange'>Your screen resolution is less than recommended.  Consider resizing your screen to higher resolution and restarting.  If you choose to continue, scrollbars will be present.</font>"
		resolutionMessage = indicators[2]+messages[24]+" "+width+"x"+height+messages[18];
		messageOutput.innerHTML = browserMessage+"<br>"+mediaMessage+"<br>"+resolutionMessage+"<br>"+aspectMessage+"<br><br>"+messages[21];	
		//issue the launch command
		myLauncher.openScrolls();
	}
	else
	{
		//"Your screen resolution is not supported.  Please change the resolution to "+courseWidth+", "+courseHeight+" or greater."
		resolutionMessage = indicators[3]+messages[24]+" "+width+"x"+height+messages[19]+courseWidth+", "+courseHeight+messages[20];
		//Do not display launch button.
	}
}

/////////////////////////////////////////////////////////////////////////////
//
// Title:  mediaPlayerCheck()
//
// Description: This function is called for non-MSIE browswer and determines 
// if the Windows Media Player plugin is required and/or present.
//
/////////////////////////////////////////////////////////////////////////////
function nonMSMediaPlayerCheck(){
	var tempMessage;
	if(courseHasVideo == true)
	{
		if (navigator.plugins) {
			for (var i=0; i < navigator.plugins.length; i++) {
				if (navigator.plugins[i].name.toLowerCase().indexOf("windows media player") >= 0) {
					hasWMplayer = true;
					//The Windows Media Player plugin has been found.  This runs best with Windows Media Player 10
					tempMessage = indicators[2]+messages[16]+messages[13];
					break;
				}
			}
		}
		else
		{
			//"Requires the Windows Media Player plug-in.  See the <a href=\"http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=\">Windows Media download center.</a> for more details."
			tempMessage = indicators[3]+messages[16]+messages[14];
		}
	}
	else
	{
		//"This does not require Windows Media Player."
		tempMessage = indicators[0]+messages[16]+messages[15];
	}
	
	return tempMessage;
}

/////////////////////////////////////////////////////////////////////////////
//
// Title:  msieMediaPlayerCheck()
//
// Description: This function is called for MSIE and determines 
// if the Windows Media Player plugin is required and/or present.
//
/////////////////////////////////////////////////////////////////////////////
function msieMediaPlayerCheck()
{
	//Instantiate media player message
	var tempMessage;
	//Test if the course has video
	if (courseHasVideo == true)
	{
		//Is Windows Media Player present?
		if(hasWMplayer)
		{
			//add code to display media player version
			newVer = WMPver.substring(0,2);
			//"Windows Media Player "+newVer+" is recommended and has been detected."
			tempMessage = indicators[0]+messages[16]+newVer+messages[17];
		}
		else
		{
			//add code to display "requires media player 10 message"
			//"Requires the Windows Media Player plug-in.  See the <a href=\"http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx?displang=en&qstechnology=\">Windows Media download center.</a> for more details."
			tempMessage = indicators[2]+messages[16]+messages[14];			
		}
	}
	else
	{
		tempMessage = indicators[1]+messages[16]+messages[15];
	}
	//the course has media files, send the message back to the calling function
	return tempMessage;
}

/////////////////////////////////////////////////////////////////////////////
//
// Title:  testScreenSize()
//
// Description: This function compares the users current resolution to the 
// resolution required for the course.  The result is a number from 1 to 5
// defined as follows.  
//
//  1 is >  
//  2 is =
//  3 is <
//
/////////////////////////////////////////////////////////////////////////////
function testScreenSize()
{
	if(width > courseWidth && height > courseHeight)
	{
		myScreenSize = 1;
	}
	else if (width == courseWidth && height == courseHeight)
	{
		myScreenSize = 2;
	}
	else if (width < courseWidth && height < courseHeight)
	{
		myScreenSize = 3;
	}
	else if (width > courseWidth && height == courseHeight)
	{
		myScreenSize = 4;
	}
	else if (width > courseWidth && height < courseHeight)
	{
		myScreenSize = 5;
	}
	else
	{
		myScreenSize = 0;
	}
	return myScreenSize;
}
/////////////////////////////////////////////////////////////////////////////
//
// Title:  testScreenAspect)
//
// Description: This function determines the current aspect ratio as follows.
//
//  43 is 4:3 
//  43 is 5:4
//  169 is 16:9
//
/////////////////////////////////////////////////////////////////////////////
function testScreenAspect()
{	
	var aspect = (height/width);
	var newAspect = aspect.toString();
	if(newAspect == .75)
	{
		myScreenAspect = "43";
	}
	else if (newAspect == .8)
	{
		myScreenAspect = "54";
	}
	//need to test this on a wide aspect screen.
	else if(newAspect == .6)
	{
		myScreenAspect = "53";
	}
	else if (newAspect == .56)
	{
		myScreenAspect = "169";
	}
	else
	{
		myScreenAspect = "unk";
	}
	return myScreenAspect;	
}