// CAPABILITIES.JS
//
// Written by S. Saporta for Midi, Inc.
// 9/22/99
//
// Defines functions to check for browser version, installed plugins, Java and JavaScript
// support.

// The calling document must load cookiefunct.js prior to capabilities.js, since
// capabilities.js requires functions defined in cookiefunct.js.

function checkCookies ()

// Determines whether cookies are enabled.
//
// Arguments:	None
//
// Returns:	true = cookies are enabled
//		false = cookies are not enabled

{
	// test whether any cookie exists
	if (document.cookie)
		return true;
	return false;
}



function checkReal ()

// Determines whether RealPlayer G2 is available in the browser.
//
// Arguments:	None
//
// Returns:	true = RealPlayer G2 is available in the browser
//		false = RealPlayer G2 is not available in the browser

{
	// assume initially that RealPlayer G2 is not available
	realInstalled = false;

	// determine which browser is in use
	if (BR.brand == "NS"){

		// for Netscape, loop over plugins
		numPlugins = navigator.plugins.length;
		i = 0;
		while ((i < numPlugins) && (realInstalled == false)){

			// examine plugin name
			//if (navigator.plugins[i].name.substring (0,17) == "RealPlayer(tm) G2" )  
			//OSX CHECKS FOR THE FOLLOWING STRING INSTEAD:
			//|| navigator.plugins[i].name.substring(0,17) == "RealPlayer Plugin"
			if (navigator.plugins[i].name.substring (0,17) == "RealPlayer(tm) G2" || navigator.plugins[i].name.substring(0,17) == "RealPlayer Plugin")
				realInstalled = true;
			i++;
		}
	}
	else{

		// for IE, dynamically generate VBScript to check for ActiveX control
		lWriteString = '<SCRIPT LANGUAGE=VBScript>\n';
		lWriteString += '<!--\n';
		lWriteString += 'on error resume next\n';
		lWriteString += 'realInstalled = (NOT IsNull (CreateObject ("rmocx.RealPlayer G2 Control")))\n';
		lWriteString += '//-->\n';
		lWriteString += '</SCRIPT>\n';
		
		document.write(lWriteString);
	
	}

	// return true or false
	return realInstalled;
}



function checkWmp ()

// Determines whether Windows Media Player 6.2 or later is available in the browser.
//
// Arguments:	None
//
// Returns:	true = WMP 6.2 or later is available in the browser
//		false = WMP 6.2 or later is not available in the browser

{
	// assume initially that WMP 6.2 or later is not available
	wmpInstalled = false;

	// determine which browser is in use
	if (navigator.appName == "Netscape"){

		// for Netscape, loop over plugins
		numPlugins = navigator.plugins.length;
		i = 0;
		while ((i < numPlugins) && (wmpInstalled == false)){

			// examine plugin name
			if (navigator.plugins[i].name.substring (0,20) == "Windows Media Player")
				wmpInstalled = true;
			i++;
		}
	}
	else{

		// trivial error-handling function
		function ignoreerror(){
			return true;
		}

		// for IE, attempt to create an object
		document.write ('<object ID="WMPlay" WIDTH="1" HEIGHT="1" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"></object>');

		// set error handler
		window.onerror = ignoreerror;

		// test MIME types and object
		fHasMP1 = false;
		fHasMP2 = false;
		fHasMP1 = navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin;
		if (typeof (WMPlay) != "undefined")
			fHasMP2 = (WMPlay.FileName == "");
		fHasMP = fHasMP1 || fHasMP2;
		if (fHasMP == true)
			wmpInstalled = true;

		// turn off error handler
		window.onerror = null;
	}

	// return true or false
	return wmpInstalled;
}



function checkFlash ()

// Determines whether Flash is available in the browser.
//
// Arguments:	None
//
// Returns:	true = Flash is available in the browser
//		false = Flash is not available in the browser

{

	// assume initially that Flash is not available
	flashInstalled = false;

	// determine which browser is in use
	if (navigator.appName == "Netscape"){
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
		if(plugin) {
			var flashVersion=parseInt(plugin.description.substring(plugin.description.indexOf(".")-1));
			//var minFlashVersion = (BR.name=="NS6")? 6:3
			var minFlashVersion = 3
			if(flashVersion>=minFlashVersion && BR.name!="NS6") {
				flashInstalled=true;
			}
			else flashInstalled=false;
		}
		else flashInstalled=false;
	}
	else{

		// for IE, attempt to instantiate object
		lWriteString = '<SCRIPT LANGUAGE=VBScript>\n';
		lWriteString += '<!--\n';
		lWriteString += 'on error resume next\n';
		lWriteString += 'flashInstalled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n';
		lWriteString += '//-->\n';
		lWriteString += '</SCRIPT>\n';
		
		document.write(lWriteString);
		
		if (flashInstalled == 1)
			flashInstalled = true;
		else
			flashInstalled = false;
			
			
			
		// 10/30/05 - BRD -- Flash 8 will not work in local mode.  New protections force error
		// See Forum: http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=464&threadid=1058562&enterthread=y#3791373
		// See Article on work-arounds:  http://www.macromedia.com/devnet/flash/articles/fplayer8_security.html
		// See Screen shot of the error: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=73a8e542
		
		// for now, test for flash 8 and disable if true.  At some point in the future, it may
		// make sense just to test for flash 7,6,5 and disable if those versions not found.
		
		if (GetCookie("Local") == "true") {
		flashInstalled8 = false	
		// BRD 10/23/06 -- account for flash 9 (now avail) and flash 10	and flash 11 (for future)
		flashInstalled9 = false
		flashInstalled10 = false
		flashInstalled11 = false
		
		// for IE local version, attempt to instantiate object and test for Flash 8.  
		lWriteString = '<SCRIPT LANGUAGE=VBScript>\n';
		lWriteString += '<!--\n';
		lWriteString += 'on error resume next\n';
		lWriteString += 'flashInstalled8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8")))\n';
		// BRD 10/23/06 -- account for flash 9 (now avail) and flash 10	and flash 11 (for future)
		lWriteString += 'flashInstalled9 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9")))\n';
		lWriteString += 'flashInstalled10 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10")))\n';
		lWriteString += 'flashInstalled11 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.11")))\n';
		lWriteString += '//-->\n';
		lWriteString += '</SCRIPT>\n';
		
		document.write(lWriteString);
		
		// BRD 10/23/06 -- account for flash 9 (now avail) and flash 10	and flash 11 (for future)
		if (flashInstalled8 == 1 || flashInstalled9 == 1 || flashInstalled10 == 1 || flashInstalled11 == 1)	//If ver 8 - 11 comes up, set flash to false
			flashInstalled = false;
		}
			

			
			
	}

	// return true or false
	return flashInstalled;
}



function checkResolution (dimension)

// Determines the horizontal resolution of the display
//
// Arguments:	dimension - "width" for horizontal resolution, "height" for vertical
//
// Returns:	horizontal or vertical display resolution

{
	// for Netscape, results are more accurate with Java, so use it if it's available
	if (BR.name == "NS4"){
		if (navigator.javaEnabled()){
		// use Java to determine resolution
		toolkit = Packages.java.awt.Toolkit.getDefaultToolkit();
		if (toolkit != null){
			screenSize = toolkit.getScreenSize();
			if (dimension == "width") {
				res = screenSize.width;
			} else {
				res = screenSize.height;
			}
		}
		}
	}
	else{
		// determine horizontal or vertical resolution
		if (dimension == "width") {
			res = window.screen.width;
		} else {
			res = window.screen.height;
		}
	}

	// return resolution
	return res;
}


function checkColorDepth ()

// Determines the color depth, in bits per pixel, of the display
//
// Arguments:	none
//
// Returns:	color depth, in bits per pixel

{
	// Netscape gives inaccurate results with colorDepth; IE doesn't support pixelDepth
	if (navigator.appName == "Netscape")
		return window.screen.pixelDepth;
	else
		return window.screen.colorDepth;
}

function checkCSS()

// Determines if CSS is enabled
//
// Arguments:	none
//
// Returns: 1 if CSS is enabled or 0 if it is not.
{
	lRet = true
	if (dom == "NS4") {		
		if(!document.testlayer) {lRet = false;}
	}
	
	return lRet
}

function checkPlatform() {
	lPlatforms = Platforms.split("|")

	for (var i=0; i<lPlatforms.length; i++) {
		   if (navigator.platform == lPlatforms[i]) {
			   return true;
		   }
    }

	return false;
	
}


function checkAcrobat(){

// 5/22/2005: BRD changed Acrobat checking for MSIE from VBScript method to CLSID method
// with a little help from http://www.planetpdf.com/developer/article.asp?ContentID=6759
// assume initially that Acrobat is not available

	// BRD 6/26/2007: check for "MacAcroBypass" cookie (set in help_acrobat.html) to allow MAC OSX users to self-bypass acro check
	if((typeof(IgnoreAcrobatCheck)!="undefined" && eval(IgnoreAcrobatCheck)) || GetCookie("MacAcroBypass")=="true"){
		 hasAcrobat = true;
	}else{
	// assume initially that Acrobat is not available
		hasAcrobat = false;
		hasAcrobat4 = false;
		hasAcrobat5 = false;
		hasAcrobat6 = false;
		hasAcrobat7 = false;
		hasAcrobat7Full = false;
		hasAcrobat8 = false;
		hasAcrobat9 = false;
		hasAcrobat10 = false;
	
		// for mac using IE, assume acrobat is installed, since we can't use activex controls
		if (BR.brand=="IE" && navigator.platform.indexOf("Mac") != -1) {
			return true
		}
		
		// determine which browser is in use
		if (navigator.appName == "Netscape"){
			
			// BRD 7/31/05 for Safari
			// BRD 4/7/08 -- do this only for Safari on MAC, not on PC			
			if (BR.agent.indexOf('Safari') != -1 && (navigator.platform=="MacPPC" || navigator.platform.indexOf("Mac") != -1)){
// 				if (navigator.plugins != null && navigator.plugins.length > 0) {
// 			      for (i=0; i < navigator.plugins.length; i++ ) {
// 				     //alert("plugin.name = "+ plugin.name)
// 			         var plugin = navigator.plugins[i];
// 			         if (plugin.name.indexOf("Adobe Acrobat") > -1) {

	
						// For Safari, just assume that they have Acrobat.  
						// "Preview" allows users to view PDF
				        plugin = true
				        hasAcrobat=true;
//			            acrobatVersion = parseFloat(plugin.description.substring(30));

//			         }
//			      }
//			   } 
		 	} else {	// not Safari on MAC
				var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/pdf"])

			}
			
			
			if (plugin) {
				hasAcrobat=true;
			} else {
				hasAcrobat=false;
			}
		
		} else {	//Must be MSIE
	
			// BRD 4/23/2008 -- remove the old VBScript method.  This may give a false positive that the acro control exists, but is not properly configured for the browser. Just use CLSID method.  This may take longer, as it actually has to instantiate Acrobat, but will prove more accurate.
			
			// BRD 5/5/2009 - SLSID method causes problems with SVVhelper objects in MSIE 7 and above. Go back to VBScript method
			
			// for IE, first attempt to instantiate object using VBScript method
			lWriteString = '<SCRIPT LANGUAGE=VBScript>\n';
			lWriteString += '<!--\n';
			lWriteString += 'on error resume next\n';
			lWriteString += 'hasAcrobat4 = (IsObject(CreateObject("PDF.PdfCtrl.1")))\n';
			lWriteString += 'hasAcrobat5 = (IsObject(CreateObject("PDF.PdfCtrl.5")))\n';
			lWriteString += 'hasAcrobat6 = (IsObject(CreateObject("PDF.PdfCtrl.6")))\n';
			lWriteString += 'hasAcrobat7 = (IsObject(CreateObject("AcroPDF.PDF.1")))\n';
			// Above is Reader.  Test full Acro 7 Exchange below. Not sure if this is the real control name, but it can't hurt
			lWriteString += 'hasAcrobat7Full = (IsObject(CreateObject("PDF.PdfCtrl.7")))\n';
			lWriteString += 'hasAcrobat8 = (IsObject(CreateObject("PDF.PdfCtrl.8")))\n';
			lWriteString += 'hasAcrobat9 = (IsObject(CreateObject("PDF.PdfCtrl.9")))\n';
			lWriteString += 'hasAcrobat10 = (IsObject(CreateObject("PDF.PdfCtrl.10")))\n';
			lWriteString += '//-->\n';
			lWriteString += '</SCRIPT>\n';
				
			document.write(lWriteString);
			
			// brd insert: cookiesetting for ACROBAT checking -- *** ONLY ADD FOR sites with "requirements" in the URL ***
			if (window.location.toString().toLowerCase().indexOf("requirements") != -1) {
				CookieMonsterSet("ACROBAT", ["hasAcrobat4-PDF.PdfCtrl.1", "hasAcrobat5-PDF.PdfCtrl.5", "hasAcrobat6-PDF.PdfCtrl.6", "hasAcrobat7-AcroPDF.PDF.1", "hasAcrobat7Full-PDF.PdfCtrl.7", "hasAcrobat8-PDF.PdfCtrl.8", "hasAcrobat9-PDF.PdfCtrl.9", "hasAcrobat10-PDF.PdfCtrl.10","AcroVer"], [hasAcrobat4, hasAcrobat5, hasAcrobat6, hasAcrobat7, hasAcrobat7Full, hasAcrobat8, hasAcrobat9, hasAcrobat10, "Pdf1.GetVersions-not tested"])
			}
			
			if (hasAcrobat4 || hasAcrobat5 || hasAcrobat6 || hasAcrobat7 || hasAcrobat7Full || hasAcrobat8 || hasAcrobat9 || hasAcrobat10) {
				hasAcrobat = true;
			} 
			
			
			//***************************************
			
			//alert("entering 2nd phase acrobat testing")
			// 5/22/05 BRD: If the above method failed, use CLSID method, since Acro 7 sometimes erroneously fails the VBScript method
			
			if (hasAcrobat != true) {		// test using CLSID method in MSIE
			
				lWriteString = '<object id="Pdf1" CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="0" HEIGHT="0">'
				lWriteString += '</object>'
				document.write(lWriteString);
			
				if (typeof(Pdf1.GetVersions)!= "undefined") {
    			
					hasAcrobat = true;
					
					if (window.location.toString().toLowerCase().indexOf("requirements") != -1) {
						// Call the ActiveX Object and get the Version Information
						var versionData = Pdf1.GetVersions();
						MultiCookieSet("ACROBAT", "AcroVer", versionData)
					}
			 	}
			}
			
			//****************************************
			
			/*
			
			// UNUSED ACROBAT CHECKING CODE BELOW
			//Acrobat is not responding.  Either its not installed properly
			//or the "Display PDF in Browser" (Acro 5,6,7) or "Web Browser Integration" (Acro 4) option is unchecked
				
			// or the GetVersions is not working
			// see: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACReference.pdf#page=237
				
				hasAcrobat = false;
				
				// *** BRD testing ONLY -- DO NOT ADD IN RELEASE VERSIONS *** 
				//MultiCookieSet("ACROBAT", "AcroVer","Pdf1.GetVersions-failed")
				
						// try new method in Acro8 -- try to load a file using LoadFile(BSTR fileName)
						if (typeof(Pdf1.LoadFile)!= "undefined") {
							alert("Pdf1.LoadFile is not undefined.")
							//var testload = Pdf1.LoadFile("../assets/pdf/test.pdf");
							//alert("testload = "+testload);
							MultiCookieSet("ACROBAT", "LoadFile","LoadFile is present, which means Acro version is greater than 8.0.0.")
							hasAcrobat = true;
						} else {
							//alert ("Pdf1.LoadFile is undefined")
						}
			*/
			
			//****************************************
			
			
		}	// end else MSIE

		
	}	// end IgnoreAcrobatCheck is undefined or set to false in config.js
	

	
	// return true or false
	return hasAcrobat;


}


function checkAcrobat7(){

// BRD 4/22/05 - check specifically for acrobat 7 for local version
// This is because Acro7 has a current bug in which it can not open local files (local zone)
// if the calling HTML page has the MOTW on it (Internet Zone)
// This bug fixed under Acro7 version 7.0.2.

// Local version is only supported under MSIE

// Assume initially that Acrobat7 is not being used

		hasAcrobat = true;
		hasAcrobat7 = false;
		hasAcrobat7Full = false;
		hasAcrobat7BadVer = false;

		
if(typeof(IgnoreAcrobatCheck)!="undefined" && eval(IgnoreAcrobatCheck)){

	// Do nothing, ignore this check and end function
	
}else{			
				
		// we will only check acrobat7 for local version
		// which is only supported on IE on Windows
//alert("hasAcrobat7 and hasAcrobat7Full start of function = "+ hasAcrobat7 + ", " + hasAcrobat7Full)	
 		if (BR.brand=="IE" && (navigator.platform=="Win32" || navigator.platform=="Win64")) {
		
// 			// for IE, first attempt to instantiate object using VBScript method
// 			// DONT USE THIS METHOD -- WE NEED TO FIND EXACT VERSION NUMBER USING ACTIVEX CODE
// 			lWriteString = '<SCRIPT LANGUAGE=VBScript>\n';
// 			lWriteString += '<!--\n';
// 			lWriteString += 'on error resume next\n';
// 			lWriteString += 'hasAcrobat7 = (IsObject(CreateObject("AcroPDF.PDF.1")))\n';
// 			// Test full Acro 7 Exchange. Not sure if this is the real control name, but it can't hurt
// 			lWriteString += 'hasAcrobat7Full = (IsObject(CreateObject("PDF.PdfCtrl.7")))\n';
// 			lWriteString += '//-->\n';
// 			lWriteString += '</SCRIPT>\n';

// 			document.write(lWriteString);
// //alert("hasAcrobat7 and hasAcrobat7Full after vbscript method = "+ hasAcrobat7 + ", " + hasAcrobat7Full)			
// 			if (hasAcrobat7 || hasAcrobat7Full) {
// 				hasAcrobat7 = true;
// 			 } else {
				 
			// 5/22/05 BRD: If the above method failed, use CLSID method, since Acro 7 sometimes erroneously fails the VBScript method
			// 6/19/05: BRD: Acro 7.0.2 works fine with local version, so test for 7.0.2
						
			// Dont need to call it out again because the write sting was already called out in in checkmain.html checkAcrobat() above
			// But just in case ...
			if (typeof(Pdf1) == "undefined") {
				//alert ("re-launching the Pdf1 CLSID instantiation function")
				lWriteString = '<object id="Pdf1" CLASSID="clsid:CA8A9780-280D-11CF-A24D-444553540000" WIDTH="0" HEIGHT="0">'
				lWriteString += '</object>'
				document.write(lWriteString);
			}
			
			
			//alert("typeof Pdf1.GetVersions in checkAcrobat7 "+typeof(Pdf1.GetVersions))  // This should yeild "unknown", but not "undefined"
			if (typeof(Pdf1)!= "undefined" && typeof(Pdf1.GetVersions)!= "undefined") {
				var versionData = Pdf1.GetVersions();			
				//alert("Acrobat version string = "+ Pdf1.GetVersions())
				
				
								
				// Create an Array of all of the Plugin Names
				// We will be searching for "Acroform" or "AcroForm" or "acroform" to check the version
				var versionDataArray = versionData.split(",");


				// create hash (key, value pair) in javascript by using Object method
				var AcroVerHashVal = new Object();
				var HashKeyName = "foo"
				var HashKeyPair ="foo"
				for (var i=0;i<versionDataArray.length-1;i++)
					{
  					HashKeyPair = versionDataArray[i].split("=");
  					HashKeyName = HashKeyPair[0].toLowerCase()	//set to lower case due to acrobat inconsistency across versions
  					
  					if (HashKeyName == "acroform") {var FoundAcroForm = true}
  					
  					//alert(HashKeyPair + " " + HashKeyName)
  					AcroVerHashVal[HashKeyName] = HashKeyPair[1];
  					// call key/value pair with "AcroVerHashVal.HashKeyName" or AcroVerHashVal['HashKeyName']
  					//alert("HashKeyPair = "+ HashKeyName + "|"+  AcroVerHashVal[HashKeyName])
				
					}

					//alert("acroform version = "+ AcroVerHashVal.acroform) // should yeild something like "7.0.2"
					
			
				//if(versionData.indexOf("=7.0") != -1) {}
				//var versionDataIndex7 = versionData.indexOf("=7.0")
				//alert("versionData.indexOf =7.0 = " + versionDataIndex7)

				if (FoundAcroForm) {
					if(AcroVerHashVal.acroform != "undefined" && AcroVerHashVal.acroform.charAt(0) == "7") {
						// we are in version 7, now find if its 7.2 or later
						// take the 3rd - 5th chars and convert to floating point
						var AcroMinorVer = parseFloat(AcroVerHashVal.acroform.substring(2,5)) 
							//alert("AcroMinorVer = "+ AcroMinorVer)
							if(AcroMinorVer < .2){
											
	 								hasAcrobat7 = true;
	 								hasAcrobat7BadVer = true;
							}
	 				}
				}
			
			}	// typeof(Pdf1.GetVersions)!= "undefined"

//				// CLSID method removed from if statement
//			}	// end Try CSLID method
		}		// BR.brand=="IE" && navigator.platform=="Win32"

	// return true or false
	//alert("hasAcrobat7 and hasAcrobat7Full end of function = "+ hasAcrobat7 + ", " + hasAcrobat7Full)
	//return hasAcrobat7;
	return hasAcrobat7BadVer;

	}	// end IgnoreAcrobatCheck is undefined or set to false in config.js
	
}



function EmbedReal(){
// BRD 6/27/05
// Embed custom Real Player to test if it is correctly configured in browser
	
		
	var RealPlugConf = false;
	var MFILERPM = "../assets/multimedia/testfile.rpm";

		
	//AVREALPLUGIN = new Object;
	
	
	if (BR.brand=="NS") { 
	
				var lWriteString = '<EMBED name=AVREALPLUGIN type="audio/x-pn-realaudio-plugin" SRC="' + MFILERPM + '" AUTOSTART=false CONTROLS=none NOLOGO=true CONSOLE=one width=0 height=0 ></EMBED>';

	} else if (BR.brand=="IE") { 	// MSIE
				var lWriteString = '<OBJECT ID="AVREALPLUGIN" width=0 height=0 CLASSID="CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"><PARAM name="SRC" value=' + MFILERPM + '> <PARAM name="AUTOSTART" value="false"><PARAM name="CONTROLS" value=none><PARAM name="NOLOGO" value="true"><PARAM name="CONSOLE" value="one"></OBJECT>';
	}
				
				//lWriteString += ".";
				
				//lWriteString += '<P></P> <FORM> <P> <INPUT TYPE="button" VALUE="Play" onClick="document.AVREALPLUGIN.DoPlay()"><INPUT TYPE="button" VALUE="Pause" onClick="document.AVREALPLUGIN.DoPause()"> <INPUT TYPE="button" VALUE="Stop" onClick="document.AVREALPLUGIN.DoStop()"></P><P><INPUT TYPE="button" VALUE="CanPlayPause?" onClick="alert(document.AVREALPLUGIN.CanPlayPause())"></P></FORM>'
					   		
				document.writeln(lWriteString);
				//document.close();
				document.writeln("<p>")

				
}


function CheckRC(){

// BRD -- 6/27/05	
// Check if Real Player is correctly configured in browser by testing either
// document.AVREALPLUGIN.GetVersionInfo() or typeof AVREALPLUGIN.CanPlayPause()

var RealPlugConf = false;

	if (BR.brand=="NS"){ 				
		
		if(document.AVREALPLUGIN.GetVersionInfo) {
			//alert("NS -- GetVersionInfo / CanPlayPause exists as a function!")
			RealPlugConf = true;
		} else {
			//alert("NS -- GetVersionInfo / CanPlayPause does NOT exist as a function.")
			RealPlugConf = false;
		}
	} else if (BR.brand=="IE") {
		// appName == MSIE
		//alert("typeof AVREALPLUGIN.CanPlayPause = "+ typeof(document.AVREALPLUGIN.CanPlayPause()))	
		if(typeof(document.AVREALPLUGIN.GetVersionInfo)!="undefined") {
			//alert("document.AVREALPLUGIN.CanPlayPause is not undefined")
			//alert("MSIE -- CanPlayPause exists as a function!")
 		   RealPlugConf = true;
		} else {
			//alert("MSIE -- CanPlayPause does NOT exist as a function.")
			RealPlugConf = false;
		}
	}	

	//alert("RealPlugConf = "+ RealPlugConf);
	return RealPlugConf;
}	// end function CheckRC()




function EmbedFlash(){
// BRD 6/27/05
// Embed custom Real Player to test if it is correctly configured in browser
	
		
	var gFlashFile = "../assets/flash/testfile"; //don't put .swf extention
	//alert ("gFlashFile = "+gFlashFile)
	var w = 100
	var h = 100
		
	//AVREALPLUGIN = new Object;
		var lWriteString = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		lWriteString += 'ID="FlashWindow" WIDTH="'+ w +'" HEIGHT="'+ h +'"';
		// BRD 10/24/2007 - the page below is no longer active, remove
		//lWriteString += 'CODEBASE="http://active.macromedia.com/flash5/cabs/';
		lWriteString += 'swflash.cab#version=4,0,0,0">';
		lWriteString += '<PARAM NAME="MOVIE" VALUE="'+ gFlashFile +'.swf">';
		lWriteString += '<PARAM NAME="PLAY" VALUE="false">';
		lWriteString += '<PARAM NAME="LOOP" VALUE="false">';
		lWriteString += '<PARAM NAME="QUALITY" VALUE="high">';
		lWriteString += '<PARAM NAME="MENU" VALUE="false">';
		lWriteString += '<PARAM NAME="wmode" VALUE="transparent">' 
		lWriteString += '<EMBED NAME="FlashWindow" TYPE="application/x-shockwave-flash"';
		lWriteString += 'SRC="'+ gFlashFile +'.swf"';
		lWriteString += 'WIDTH="'+ w +'" HEIGHT="'+ h +'"';
		lWriteString += 'swliveconnect="true"'
		lWriteString += 'PLAY="false"';
		lWriteString += 'wmode="transparent"';
		lWriteString += 'LOOP="false" QUALITY="high" MENU="false"';
		
		// BRD 10/24/2007 - make next line variable for http or https
		//alert("UIFCGIPath = " + UIFCGIPath)
		var UIFCGIServerProtocol = UIFCGIPath.split(":")[0]
		//alert("UIFCGIServerProtocol = " + UIFCGIServerProtocol)
		if (UIFCGIServerProtocol == "https" || UIFCGIServerProtocol == "HTTPS") { 
			// then we ARE using SSL/https
			lWriteString += 'PLUGINSPAGE="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
		} else {
			// we are NOT using SSL/https
			lWriteString += 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
		}
			
		lWriteString += '</EMBED>';
		lWriteString += '</OBJECT>';
		document.writeln(lWriteString);
		//document.close();
		document.writeln("<p>")
		
	//alert("embedded the flash player")
}


function CheckFC(){

// BRD -- 6/27/05	
// Check if Real Player is correctly configured in browser by testing either
// document.AVREALPLUGIN.GetVersionInfo() or typeof AVREALPLUGIN.CanPlayPause()

	var FlashPlugConf = false;
	
	
	switch(dom){
	
	case "w3c":		gFlashObj = document.FlashWindow;
				break;

	case "IE" :		gFlashObj = document.all.FlashWindow; 
				break;

	case "NS4":		gFlashObj = document.embeds['FlashWindow'];
					break;

	}
	
	if (BR.brand=="NS"){ // Netscape 4, 6, 7, 8, Firefox				
		
		if(gFlashObj.GotoFrame) {
			//alert("NS -- gFlashObj.GotoFrame exists as a function!")
			FlashPlugConf = true;
		} else {
			//alert("NS -- gFlashObj.GotoFrame does NOT exist as a function.")
			FlashPlugConf = false;
		}
	} else if (BR.brand=="IE") {
		// appName == MSIE
		//alert("typeof gFlashObj.GotoFrame = "+ typeof(gFlashObj.GotoFrame()))	
		if(typeof(gFlashObj.GotoFrame)!="undefined") {
		//if(typeof(gFlashObj.keyUp)!="undefined") 	
			
			//alert("gFlashObj.GotoFrame is not undefined")
			//alert("MSIE -- gFlashObj.GotoFrame exists as a function!")
 		   FlashPlugConf = true;
		} else {
			//alert("MSIE -- CanPlayPause does NOT exist as a function.")
			FlashPlugConf = false;
		}
	}	

	//alert("FlashPlugConf = "+ FlashPlugConf);
		
	return FlashPlugConf;
}	// end function CheckFC()




function EmbedWMP64(){

	// NOTE: DO NOT DO THIS IN LOCAL MODE -- ACTIVE X MAY GIVE IESP6 NOTICES
	
	//var MFILE = "badfile.wmv";
	//var MFILE = "hv00020.wmv"
	//var MFILE = "../assets/multimedia/testaudio.wma";
	var MFILE = "../assets/multimedia/blankaudio.wma";
	
	//The codebase tells IE where to go to download Windows Media Player if version 6.4+ is not on the computer. It will automatically install in IE. Notice the Version information at the end of the line, this tells IE which version is needed to display the content. 

	//The standby value will display while the new WiMP is downloading and installing. 
	//The type attribute is important because it tells IE what kind of plugin to use.

	// BRD 10/24/2007 - the page below is no longer active, remove
	//var CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=,1,52,701"


	//Pluginspage tells the browser where to send the user if they do not have the Windows Media Player plugin.
	// BRD 10/24/2007 - the page directly below is no longer active, remove
	//var PLUGINP="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"
	//var PLUGINP='http://www.microsoft.com/Windows/MediaPlayer/'
	//var PLUGINP="http://www.voiceage.com/codecsite/prod_acelp_eula.php"
	//var PLUGINP="./acelpacm.cab"
	//var PLUGINP="http://192.168.0.40/wmptest/acelpacm.cab"
	//var PLUGINP="http://192.168.0.40/wmptest/acelp.cab"
	//var PLUGINP="http://192.168.0.40/wmptest/acelp_net.exe"
	//var PLUGINP="http://www.voiceage.com/codecsite/media/acelp_net.exe"
	//var PLUGINP="noplugin.html"
	
	// Apparently, neither PLUGINP nor CODEBASE work in WMP 7-10 
	// nor the backward compatible versions emulating 6.4.  The WMP is hard-coded to look at:
	// activex.microsoft.com and codecs.microsoft.com for all codecs.
	
	
	// embed 6.4 player, call out a media file, set parameters
	// Note in particular "AUTOSTART" and "SendErrorEvents"
	// If the SendErrorEvents property is true, error message boxes are disabled and the control sends error events instead. If SendErrorEvents is false, the Windows Media Player control displays error dialogs and does not send error events.
	
	// BRD 10/24/2007 - remove CODEBASE and PLUGINP from instantiation
	//var lWriteString = '<OBJECT ID="WMPlay64" width=0 height=0 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase='+CODEBASE+' standby="Testing Microsoft Windows Media Player components..."><PARAM name="FILENAME" value= '+ MFILE + '> <PARAM name="AUTOSTART" value="true"><PARAM name="SendErrorEvents" value="true"><PARAM name="SHOWPOSITIONCONTROLS" value="true"><PARAM name="SHOWSTATUSBAR" value="true"><PARAM name="TRANSPARENTATSTART" value="true"><PARAM name="ANIMATIONATSTART" value="false"><EMBED type="application/x-mplayer2" pluginspage=' + PLUGINP + ' FILENAME='+ MFILE +' name="WMPlay64" AUTOSTART=true AUTOPLAY=true width=0 height=0> </EMBED></OBJECT>';
	var lWriteString = '<OBJECT ID="WMPlay64" width=0 height=0 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Testing Microsoft Windows Media Player components..."><PARAM name="FILENAME" value= '+ MFILE + '> <PARAM name="AUTOSTART" value="true"><PARAM name="SendErrorEvents" value="true"><PARAM name="SHOWPOSITIONCONTROLS" value="true"><PARAM name="SHOWSTATUSBAR" value="true"><PARAM name="TRANSPARENTATSTART" value="true"><PARAM name="ANIMATIONATSTART" value="false"><EMBED type="application/x-mplayer2" FILENAME='+ MFILE +' name="WMPlay64" AUTOSTART=true AUTOPLAY=true width=0 height=0> </EMBED></OBJECT>';
		
	
	// Note that the WMP10 CLSID uses entirely different methods and properties:
	// CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"


				document.writeln(lWriteString);
				//document.close();
				document.writeln("<p>")
				
} // end function EmbedWMP64()


function CheckWMPACELP(){

	// BRD 7/14/05 -- check to see that learner's Windows PC has the ACELP.NET codec installed and usable
	
	// This function will only be called in checkmain.html if ((REQ.wmp && BR.brand=="IE" && ViewingOptions != "tg" && GetCookie("Local")!="true")	

	
	// Test this function by either:
	// A: Renaming $WINDOWS\SYSTEM$\SL_ANET.ACM to SL_ANET.ACM.HOLD (for WMP9 version of codec)
	// B: Renaming $WINDOWS\SYSTEM$\acelpdec.ax to acelpdec.ax.HOLD (old version of codec??)
	// C: Setting the value of "MFILE" in function EmbedWMP64() to a non-existant file
	
	// First, we need to force EmbedWMP64() output to display and launch
	// As per the "document" method in IE, output does not appear until the current <SCRIPT> block
	// ends, or the current event handler function returns, or an alert message is issued, 
	// or you can always use setTimeout() to schedule the next "chunk" of code to run in 0 milliseconds.

	// Note the call in checkmain.html to setTimeout:
	// <body bgcolor="#e9e9ca" onload='setTimeout("CheckDone();",2500)'>

	
	var ACELPfound = true;	


	// only proceed if we find the instantiated player and it supports the "PlayState" property
	//if (typeof(WMPlay64)!="undefined" && typeof(WMPlay64.PlayState) != "undefined")
	
	if (typeof(WMPlay64)=="undefined" || typeof(WMPlay64.PlayState) == "undefined"){
		ACELPfound = false;
		alert("Test for ACELP.NET Audio Codec in Windows Media Player failed to initialize");
	} else {
	
		
	// ReadyState - Retrieves the state of readiness of the Windows Media Player control.
	//Value Visual Basic constant Description 
	//0 mpReadyStateUninitialized - The FileName property has not been initialized. 
	//1 mpReadyStateLoading - Windows Media Player control is asynchronously loading a file. 
	//3 mpReadyStateInteractive - Windows Media Player control loaded a file, and downloaded enough data to play the file, but has not yet received all data. 
	//4 mpReadyStateComplete - All data has been downloaded. 
	//alert("WMPlay64.ReadyState = "+WMPlay64.ReadyState)
	
	
	
	// 	PlayState --	Returns for "PlayState"	
	// 	0 Undefined Windows Media Player is in an undefined state. 
	// 	1 Stopped Playback of the current media item is stopped. 
	// 	2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location. 
	// 	3 Playing The current media item is playing. 
	// 	4 ScanForward The current media item is fast forwarding. 
	// 	5 ScanReverse The current media item is fast rewinding. 
	// 	6 Buffering The current media item is getting additional data from the server. 
	// 	7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin. 
	// 	8 MediaEnded Media item has completed playback.  
	// 	9 Transitioning Preparing new media item. 
	// 	10 Ready Ready to begin playing. 
  	//alert("WMPlay.playState = "+WMPlay.PlayState);
	
 	
  	
  	//alert("WMPlay64.ReadyState = "+WMPlay64.ReadyState+ " | WMPlay.playState = "+WMPlay.PlayState+ " | ACELPerror = "+ACELPerror+" | WMPlay64.HasError = "+WMPlay64.HasError)

	  	
	//ErrorCode Retrieves the current error code. 
	//ErrorDescription Retrieves a description of the current error state. 
	 	
  	 //alert("WMPlay64.ErrorCode and Description = "+WMPlay64.ErrorCode+", "+WMPlay64.ErrorDescription);	

  	    	 
	// CodecCount - Retrieves the number of installable codecs used by the current clip.
	// GetCodecDescription() - Retrieves the descriptive name of the given codec.
	// GetCodecInstalled() - Retrieves a value indicating whether a given codec is installed.
	// GetCodecURL() - Retrieves URL location containing additional information about the given codec.
	//THE CodecCount PROPERTY HAS BEEN TOTALLY DEPRICATED IF WMP9 IS INSTALLED AND DOES NOT WORK
	//GetCodec* will not work either

	


	//alert("WMPlay64.ReadyState = "+WMPlay64.ReadyState+ " | WMPlay64.playState = "+WMPlay64.PlayState+ " | ACELPerror = "+ACELPerror+" | WMPlay64.HasError = "+WMPlay64.HasError+" | WMPlay64.ErrorCode and Description = "+WMPlay64.ErrorCode+", "+WMPlay64.ErrorDescription)

	//alert("WMPlay64.HasError = "+WMPlay64.HasError);
	if (ACELPerror || WMPlay64.HasError || WMPlay64.ErrorCode >= 1) { 
		ACELPfound = false;
	}

	
	} 	// end if typeof(WMPlay64)!="undefined" 

	return ACELPfound;
		
		
}	// end function checkACELP()



function EmbedWMP64_wmp9(){

	// NOTE: DO NOT DO THIS IN LOCAL MODE -- ACTIVE X MAY GIVE IESP6 NOTICES
	
	// WMP9MFILE listings below are just for show -- they will be called from checkmain.html
	//var WMP9MFILE = "badfile9.wmv";
	//var WMP9MFILE = "../assets/multimedia/testaudio.wma"; // ACELP file
	//var WMP9MFILE = "../assets/multimedia/testaudiowmp9.wma";
	//var WMP9MFILE = "../assets/multimedia/blankwmp9audio.wma";
	// BRD 10/24/2007 - the page below is no longer active, remove
	//var CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=,1,52,701"
	// BRD 10/24/2007 - the page below is no longer active, remove
	//var PLUGINP="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"
	//var lWriteString = '<OBJECT ID="WMPlay64_wmp9" width=0 height=0 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase='+CODEBASE+' standby="Testing Microsoft Windows Media Player components..."><PARAM name="FILENAME" value= '+ WMP9MFILE + '> <PARAM name="AUTOSTART" value="true"><PARAM name="SendErrorEvents" value="true"><PARAM name="SHOWPOSITIONCONTROLS" value="true"><PARAM name="SHOWSTATUSBAR" value="true"><PARAM name="TRANSPARENTATSTART" value="true"><PARAM name="ANIMATIONATSTART" value="false"><EMBED type="application/x-mplayer2" pluginspage=' + PLUGINP + ' FILENAME='+ WMP9MFILE +' name="WMPlay64_wmp9" AUTOSTART=true AUTOPLAY=true width=0 height=0> </EMBED></OBJECT>';
	
	// For WMP9, instantiate player without a file name.  Otherwise, player immediately tests file
	// Also, we don't want to play the file, so don't autostart or autoplay the file.
	// We will set .filename and call the .Play() function checkmain.html
	
	// BRD 10/24/2007 - remove CODEBASE and PLUGINP from instantiation
	//var lWriteString = '<OBJECT ID="WMPlay64_wmp9" width=0 height=0 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase='+CODEBASE+' standby="Testing Microsoft Windows Media Player components..."><PARAM name="AUTOSTART" value="false"><PARAM name="SendErrorEvents" value="true"><PARAM name="SHOWPOSITIONCONTROLS" value="true"><PARAM name="SHOWSTATUSBAR" value="true"><PARAM name="TRANSPARENTATSTART" value="true"><PARAM name="ANIMATIONATSTART" value="false"><EMBED type="application/x-mplayer2" pluginspage=' + PLUGINP + ' AUTOSTART=false AUTOPLAY=false width=0 height=0> </EMBED></OBJECT>';
	var lWriteString = '<OBJECT ID="WMPlay64_wmp9" width=0 height=0 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Testing Microsoft Windows Media Player components..."><PARAM name="AUTOSTART" value="false"><PARAM name="SendErrorEvents" value="true"><PARAM name="SHOWPOSITIONCONTROLS" value="true"><PARAM name="SHOWSTATUSBAR" value="true"><PARAM name="TRANSPARENTATSTART" value="true"><PARAM name="ANIMATIONATSTART" value="false"><EMBED type="application/x-mplayer2" AUTOSTART=false AUTOPLAY=false width=0 height=0> </EMBED></OBJECT>';
	
	
	
	// Note that the WMP10 CLSID uses entirely different methods and properties:
	// CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
	
				document.writeln(lWriteString);
				//document.close();
				document.writeln("<p>")
				
} // end function EmbedWMP64_wmp9()


function CheckWMP9AUDIO(){

	// BRD 11/27/05 -- check to see that learner's Windows PC has the WMP9-Audio codec installed and usable by WMP
	
	// This function will only be called in checkmain.html if ((REQ.wmp && BR.brand=="IE" && ViewingOptions != "tg" && GetCookie("Local")!="true" && if the ACELP codec has not been found)	

	
	// Test this function by either:
	// A: Renaming $WINDOWS\SYSTEM$\SL_ANET.ACM to SL_ANET.ACM.HOLD (for WMP9 version of codec)
	// B: Renaming $WINDOWS\SYSTEM$\acelpdec.ax to acelpdec.ax.HOLD (old version of codec??)
	// C: Setting the value of "WMP9MFILE" in function EmbedWMP64_wmp9() or in checkmain to a non-existant file
	
	var WMP9AUDIOfound = true;	


	// only proceed if we find the instantiated player and it supports the "PlayState" property
	//if (typeof(WMPlay64_wmp9)!="undefined" && typeof(WMPlay64_wmp9.PlayState) != "undefined")
	if (typeof(WMPlay64_wmp9)=="undefined" || typeof(WMPlay64_wmp9.PlayState) == "undefined"){
		WMP9AUDIOfound = false;
		alert("Test for WMP9-Audio-Voice Codec in Windows Media Player failed to initialize");
	} else {
		
		
  	 	//alert("WMPlay64_wmp9.ErrorCode and Description = "+WMPlay64_wmp9.ErrorCode+", "+WMPlay64_wmp9.ErrorDescription);	
  	 
		//alert("WMPlay64_wmp9.ReadyState = "+WMPlay64_wmp9.ReadyState+ " | WMPlay64_wmp9.playState = "+WMPlay64_wmp9.PlayState+ " | wmp9AUDIOerror = "+wmp9AUDIOerror+" | WMPlay64_wmp9.HasError = "+WMPlay64.HasError+" | WMPlay64_wmp9.ErrorCode and Description = "+WMPlay64_wmp9.ErrorCode+", "+WMPlay64_wmp9.ErrorDescription)

		//alert("WMPlay64_wmp9.HasError = "+WMPlay64_wmp9.HasError);
	if (wmp9AUDIOerror || WMPlay64_wmp9.ErrorCode >= 1) { 
		WMP9AUDIOfound = false;
	}

	} 	// end if typeof(WMPlay64_wmp9)!="undefined"
	
	return WMP9AUDIOfound;
		
		
}	// end function checkACELP()



// BRD - 7/14/05 - Function unused for now, but similar to "sleep" in c-shell
function delay(gap){ 	/* gap is in millisecs */
var then,now; then=new Date().getTime();
now=then;
while((now-then)<gap)
{now=new Date().getTime();}
}

