//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.
// 3. openNormal() : sets links to open a chromeless window for use with F11 on non ie.
//
/////////////////////////////////////////////////////////////////////////////
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");
		width = width-10
		height = height-60;
		launchButton.innerHTML = "<a onClick=\"var player = window.open("+lurl+",\'cshell\',\'height=\' + height + \',width=\' + width + \', resizable=yes, resizable=1, scrollbars=yes,fullscreen=no,menubar=no,toolbar=no,statusbar=no,directories=0,\' + '\scrollbars=1,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.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>";
	}
//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 resolutionMessage;
	var aspectMessage;
	var tempMessage = "";
	var messageOutput = document.getElementById("messageContainer");
	var linkVal;
	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"+":, resizeable=1 <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 screen is larger than required prep to launch in a window
			if(myScreenSize==1)
			{
				//prepare messages				
				if(browserMessage!=null || browserMessage!=undefined){
					tempMessage = browserMessage+"<br>";
					alert("tempMessage=="+tempMessage);
				}
				if(resolutionMessage!=null || resolutionMessage!=undefined){
					tempMessage += resolutionMessage+"<br>";
				}
				if(aspectMessage!=null || aspectMessage!=undefined){
					tempMessage += aspectMessage+"<br>";
				}
				
				messageOutput.innerHTML = tempMessage;
				//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];
				if(browserMessage!=null || browserMessage!=undefined){
					tempMessage = browserMessage+"<br>";
					alert("tempMessage=="+tempMessage);
				}
				if(resolutionMessage!=null || resolutionMessage!=undefined){
					tempMessage += resolutionMessage+"<br>";
				}
				if(aspectMessage!=null || aspectMessage!=undefined){
					tempMessage += aspectMessage+"<br>";
				}
				messageOutput.innerHTML = tempMessage;
				//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.
			}
	}

	else if (BrowserDetect.browser=="Firefox" || BrowserDetect.browser=="Mozilla" || BrowserDetect.browser=="Netscape" || BrowserDetect.browser=="Opera")
	{
		branchBrowserF11(browserMessage, resolutionMessage, aspectMessage, messageOutput, tempMessage);
	}
	else
	{
		browserMessage = indicators[3]+messages[22]+BrowserDetect.browser+messages[23]+BrowserDetect.version+messages[34];
	}
}
function branchBrowserF11(browserMessage, resolutionMessage, aspectMessage, messageOutput, tempMessage)
{
	//alert("height=="+height+", width=="+width);
	//If screen is larger than required prep to launch in a window
	if(myScreenSize==1)
	{
		//prepare messages
		if(browserMessage!=null || browserMessage!=undefined){
			tempMessage = browserMessage+"<br>";
			alert("tempMessage=="+tempMessage);
		}
		if(resolutionMessage!=null || resolutionMessage!=undefined){
			tempMessage += resolutionMessage+"<br>";
		}
		if(aspectMessage!=null || aspectMessage!=undefined){
			tempMessage += aspectMessage+"<br>";
		}
		messageOutput.innerHTML = tempMessage;
		//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];
				if(browserMessage!=null || browserMessage!=undefined){
					tempMessage = browserMessage+"<br>";
					alert("tempMessage=="+tempMessage);
				}
				if(resolutionMessage!=null || resolutionMessage!=undefined){
					tempMessage += resolutionMessage+"<br>";
				}
				if(aspectMessage!=null || aspectMessage!=undefined){
					tempMessage += aspectMessage+"<br>";
				}
				messageOutput.innerHTML = tempMessage;
		//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];
		if(browserMessage!=null || browserMessage!=undefined){
					tempMessage = browserMessage+"<br>";
					alert("tempMessage=="+tempMessage);
				}
				if(resolutionMessage!=null || resolutionMessage!=undefined){
					tempMessage += resolutionMessage+"<br>";
				}
				if(aspectMessage!=null || aspectMessage!=undefined){
					tempMessage += aspectMessage+"<br>";
				}	
				messageOutput.innerHTML = tempMessage;
		//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:  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;	
}
