/*******************************************************
ACROBAT DETECT
All code by Ryan Parman, unless otherwise noted.
(c) 1997-2003, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1, http://www.skyzyx.com/license/
Updated by: Derek J Dustin
Modified the IE detection to use an embedded object instead
of using the activeXObject method.  This caused automation errors
*******************************************************/

var acrobat = new Object();
document.open();
document.writeln( '<link href="http://static.3rdl.com/en-us/css/sysrequire.css" type="text/css" rel="stylesheet" />' );
document.writeln( '<object id="Pdf1" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="0" height="0"></object>');

// Set some base values
acrobat.installed=false;
acrobat.version='0.0';

if (navigator.plugins && navigator.plugins.length)
{
	for (x=0; x<navigator.plugins.length; x++)	{
		if (navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1){
			acrobat.version=parseFloat(navigator.plugins[x].description.split('Version ')[1]);
			if (acrobat.version.toString().length == 1) acrobat.version+='.0';
			acrobat.installed=true;
			break;
		}
	}
}
else if (window.ActiveXObject){		

	try {
		// Call the ActiveX Object and get the Version Information
		var versionData = Pdf1.GetVersions();	
		// Create an Array of all of the Plugin Names
		var versionDataArray = versionData.split(",");
		// this index is hopefully the same
		var acroForm = versionDataArray [1];
		// find out what version and set object	
		for( var ver=4; ver < 10; ver++){
			if(acroForm.indexOf( ("="+ver.toString()+".0") ) != -1) {
				// we have it installed
				acrobat.installed = true;						
				// split up name value pairs
				var tmpArray = acroForm.split("=");			
				// extract the version from temp array
				acrobat.version= tmpArray[1];
			}
		}
	}
	catch (e) {
	}
}

if( acrobat.installed ) {
	for ( var i=4; i < 20; i++ ){
		var val = (acrobat.installed && parseInt(acrobat.version) >= i) ? true:false; 
		eval( "acrobat.ver"+i + " = "+ val +";" );		
	}
}

// END OF Adobe Detection


// Browser Detection 

function getBrowser()
{

	// this is for an alert box to get a new browser, so it only opens once
	var b_first;

	//initialization, browser, os detection
	var d, dom, nu='', brow='', ie, ie4, ie5, ie5x, ie6, ie7;
	var ns4, moz, moz_rv_sub, release_date='', moz_brow, moz_brow_nu='', moz_brow_nu_sub='', rv_full=''; 
	var mac, win, old, lin, ie5mac, ie5xwin, konq, saf, op, op4, op5, op6, op7;

	d=document;
	n=navigator;
	nav=n.appVersion;
	nan=n.appName;
	nua=n.userAgent;
	old=(nav.substring(0,1)<4);
	mac=(nav.indexOf('Mac')!=-1) ? true : false;
	win=( ( (nav.indexOf('Win')!=-1) || (nav.indexOf('NT')!=-1) ) && !mac)?true:false;
	lin=(nua.indexOf('Linux')!=-1);
	// begin primary dom/ns4 test
	// this is the most important test on the page
	if ( !document.layers )
	{
		dom = ( d.getElementById ) ? d.getElementById : false;
	}
	else { 
		dom = false; 
		ns4 = true;// only netscape 4 supports document layers
	}
	// end main dom/ns4 test

	op=(nua.indexOf('Opera')!=-1);
	saf=(nua.indexOf('Safari')!=-1);
	konq=(!saf && (nua.indexOf('Konqueror')!=-1) ) ? true : false;
	moz=( (!saf && !konq ) && ( nua.indexOf('Gecko')!=-1 ) ) ? true : false;
	ie=((nua.indexOf('MSIE')!=-1)&&!op);
	if (op)
	{
		str_pos=nua.indexOf('Opera');
		nu=nua.substr((str_pos+6),4);
		brow = 'Opera';
	}
	else if (saf)
	{
		str_pos=nua.indexOf('Safari');
		nu=nua.substr((str_pos+7),5);
		brow = 'Safari';
	}
	else if (konq)
	{
		str_pos=nua.indexOf('Konqueror');
		nu=nua.substr((str_pos+10),3);
		brow = 'Konqueror';
	}
	// this part is complicated a bit, don't mess with it unless you understand regular expressions
	// note, for most comparisons that are practical, compare the 3 digit rv nubmer, that is the output
	// placed into 'nu'.
	else if (moz)
	{
		// regular expression pattern that will be used to extract main version/rv numbers
		pattern = /[(); \n]/;
		// moz type array, add to this if you need to
		moz_types = new Array( 'Firebird', 'Phoenix', 'Firefox', 'Galeon', 'K-Meleon', 'Camino', 'Epiphany', 
			'Netscape6', 'Netscape', 'MultiZilla', 'Gecko Debian', 'rv' );
		rv_pos = nua.indexOf( 'rv' );// find 'rv' position in nua string
		rv_full = nua.substr( rv_pos + 3, 6 );// cut out maximum size it can be, eg: 1.8a2, 1.0.0 etc
		// search for occurance of any of characters in pattern, if found get position of that character
		rv_slice = ( rv_full.search( pattern ) != -1 ) ? rv_full.search( pattern ) : '';
		//check to make sure there was a result, if not do  nothing
		// otherwise slice out the part that you want if there is a slice position
		( rv_slice ) ? rv_full = rv_full.substr( 0, rv_slice ) : '';
		// this is the working id number, 3 digits, you'd use this for 
		// number comparison, like if nu >= 1.3 do something
		nu = rv_full.substr( 0, 3 );
		for (i=0; i < moz_types.length; i++)
		{
			if ( nua.indexOf( moz_types[i]) !=-1 )
			{
				moz_brow = moz_types[i];
				break;
			}
		}
		if ( moz_brow )// if it was found in the array
		{
			str_pos=nua.indexOf(moz_brow);// extract string position
			moz_brow_nu = nua.substr( (str_pos + moz_brow.length + 1 ) ,3);// slice out working number, 3 digit
			// if you got it, use it, else use nu
			moz_brow_nu = ( isNaN( moz_brow_nu ) ) ? moz_brow_nu = nu: moz_brow_nu;
			moz_brow_nu_sub = nua.substr( (str_pos + moz_brow.length + 1 ), 8);
			// this makes sure that it's only the id number
			sub_nu_slice = ( moz_brow_nu_sub.search( pattern ) != -1 ) ? moz_brow_nu_sub.search( pattern ) : '';
			//check to make sure there was a result, if not do  nothing
			( sub_nu_slice ) ? moz_brow_nu_sub = moz_brow_nu_sub.substr( 0, sub_nu_slice ) : '';
		}
		
		if ( moz_brow == 'Netscape6' )
		{
			moz_brow = 'Netscape';
		}
		else if ( moz_brow == 'rv' || moz_brow == '' )// default value if no other gecko name fit
		{
			moz_brow = 'Mozilla';
		} 
		if ( !moz_brow_nu )// use rv number if nothing else is available
		{
			moz_brow_nu = nu;
			moz_brow_nu_sub = nu;
		}
		if (n.productSub)
		{
			release_date = n.productSub;
		}
		
		brow = moz_brow + ' ' + moz_brow_nu_sub;
	}
	else if (ie)
	{
		str_pos=nua.indexOf('MSIE');
		nu=nua.substr((str_pos+5),3);
		brow = 'Microsoft Internet Explorer ' + nu;
	}
	// default to navigator app name
	else 
	{
		brow = nan;
	}

return brow;
}

// End of Browser Detection

// globals for All Pages
// browser
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isIE5 = (navigator.appVersion.indexOf("5.") != -1) ? true : false;
var isIE6 = (navigator.appVersion.indexOf("6.") != -1) ? true : false;
var isNS  = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
var isMoz = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

// platform 
var isWin = (navigator.appVersion.indexOf("Win") != -1) ? true : false;
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;

// Flash boolean
var isFlashinstalled = false;
// -->

// Write out VB Functions
document.write('<SCR' + 'IPT LANGUAGE="VBScript"\>   \n');


// detect presence of ActiveX controls
document.write(' on error resume next  \n');
document.write(' Dim  pdf405 \n');
document.write(' Dim  pdf50  \n');
document.write(' Dim  PDFViewer \n');

document.write(' MediaPlayer = IsObject(CreateObject("MediaPlayer.MediaPlayer.1"))    \n'); //acrobat 5.0 for MacOS9
document.write(' \'MsgBox MediaPlayer \n');

document.write(' Function detectFlashPC(lVersion)  \n');
document.write('   on error resume next  \n');
document.write('   Dim i, obj : obj = null \n ');
document.write('   flashVersion = 4                \n ');
document.write('    For i = lVersion To 4 Step - 1  \n');
document.write('	  Set obj = CreateObject("ShockwaveFlash.ShockwaveFlash." & i )   \n');
document.write('      If IsObject(obj) Then \n');
document.write('			 flashVersion = i \n');
document.write('			 Set obj = nothing \n');
document.write('			 Exit For \n');
document.write('	  End IF		 \n');	
document.write('    Next \n');
document.write('    detectFlashPC = flashVersion \n ');
document.write(' End Function ');
document.write('</SCR' + 'IPT\>     \n'); // break up end tag so it doesn't end our script

document.close();
// -------------------------   Start  Detection function  -------------------------------

function detectFlash( lVersionToDetect, src, h, w, objectID, sRedirectPage ){
	// Things we are looking for
	var flashVersion = 1;
	var bRedirect = false;
		
	// for redirection
	if( ( sRedirectPage.length > 0 ) && ( sRedirectPage != 'undefined') ){ bRedirect = true;}
		
	flashVersion = getFlashVersion( lVersionToDetect );
		
	if(flashVersion > 3){
		isFlashinstalled = true;
	}
											
	// now we should have the version to detect for
	// if a mac with less than IE 5, can't do anything, user disgretion
	if((isIE && !isIE5) && isMac){
		var go = confirm(" You have a Mac with IE 4.x.  Do you have the flash plugin? Click Ok to continue to Flash Site, or cancel to get html version.");

		// download page
		if(!go)
			if(bRedirect)
				location.replace (sRedirectPage);
				
	}
	
	// now check everything else:		
	if ((!isFlashinstalled ) || (flashVersion  < lVersionToDetect)){
		var bgetFlash = confirm("Flash "+ lVersionToDetect + " or greater was not detected on your machine.  Please click Ok to download, or cancel to get html version. ");
		if (bgetFlash){
			getBrowserPlugin('flashplayer');	
		} else {
			// goto HTML Version, and pop up something on them
			getBrowserPlugin('flashplayer');
			if(bRedirect) 
				location.replace (sRedirectPage); 
		}
	}
	
	
	// all checks went through, render Flash Object
	if(src.length > 0 && src != 'undefined')
		renderFlashObject(src, h, w, objectID);
		
} // end of flash detectiion function

// ----------------------------------------------	//

function detectFlashNetscape(){
	var lVersion;
	if (navigator.plugins["Shockwave Flash 2.0"] 	// yes>> then is Flash 2 
		|| navigator.plugins["Shockwave Flash"]){		// or flash 3+ installed?
			isFlashinstalled = true;
			// set convenient references to flash 2 and the plugin description
			var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
			// a flash plugin-description looks like this: Shockwave Flash 4.0 r5
			// so we can get the major version by grabbing the character before the period
			// note that we don't bother with minor version detection. do that in your movie with $version
			lVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
	}
	return lVersion;
} // end fo function

// ----------------------------------------------	//	

function getFlashVersion(lVersion){
	// Detect Flash Version for NetScape
	if ((isMoz || isNS) || (isMac && (isIE5 || isIE6))){// does navigator.plugins exist?
		return detectFlashNetscape();
	}
	// end of detecting flash for Netscrape
	
	// detection script for IE/Windows			
	if(((isIE) || (isIE5)) && isWin && !isNS ){ // don't write vbscript tags on anything but ie win
		return detectFlashPC(lVersion);
	}
} // end of function

function getOS(){
	var agt=navigator.userAgent.toLowerCase();
	var os = "";
	var win = (agt.indexOf("win")!=-1);
	// windows 95 OS
	this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
	if (this.win95) os="Windows 95";
	// windows 98 OS
	this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
	if (this.win98) os="Windows 98";
	// windows NT
	this.winNT = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
	if (this.winNT) os="Windows NT/XP";
	// windows 2000
	this.win2000 = ((agt.indexOf("windows nt 5.0")!=-1));
	if (this.win2000) os="Windows 2000";

	this.win32 = ( this.win95 || this.winnt || this.win98 || this.win2000 ||
                   ((this.major >= 4) && (navigator.platform == "Win32")) ||
                   (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1) );

	// macintosh
	this.mac = ((agt.indexOf("mac")!=-1)||(agt.indexOf("Mac")!=-1));
	//alert(this.mac);
	if (this.mac) os="Macintosh";

	return os;
}

// --------------------------------------------------------------- //

function checkCookies(){
	if (document.cookie != null){
		document.cookie = "name=value";  // cookies enabled?
		if (document.cookie == "") {
			return "Please turn on cookies.";
		} else { 
			return "Cookies are accepted.";
		}
	}
} // end of cookie checker

// --------------------------------------------------------------- //

function checkAcrobat( __os ){
//	alert( __os );
	if( acrobat.installed )
		return "Version "+ acrobat.version + "";
	else
		return "Unknown.";	
}


// --------------------------------------------------------------- //
function checkMediaPlugin(sOs){
	var bPlayerInstalled = false;

	if (sOs.indexOf("Windows") != -1) {
		if(navigator.plugins.length > 0) {
			for (var i=0; i< navigator.plugins.length; i++){
				if (navigator.plugins[i].name.indexOf("Windows Media") != -1){
					bPlayerInstalled = true;
				}
			}
		} else {	
		  // need to get this going	with IE PC
		  bPlayerInstalled = MediaPlayer;
		}
		
		
		if(bPlayerInstalled == true){ //Detecting Real Basic 8/RealOne in IE5+ in Windows NT, 98, 2000
			return "Media Player installed.";
		} else {
			return "Not installed or cannot detect";
		}
	}//end of Windows check
	
	else if (sOs.indexOf("Macintosh") != -1) {
		if(isIE) {//IN Mac IE 5 + can't detect Real using Active X Or Javascript
			return "Can't detect on Mac with IE 4 and 5";
		}
		else if(navigator.plugins.length != null) {
			for (var i=0; i< navigator.plugins.length; i++){
				if( navigator.plugins[i].name.indexOf("Windows Media") != -1 )
					return "Media Player installed.";
			}	
			
			// send back not installed
			return "Not installed or cannot detect";			
		}
	}// end of Macintosh block
}
// -------------------------   End  Detection  -------------------------------

function GetPlugin( code ){
	var pluginUrl = '';
	switch (code.toLowerCase())
	{
		case "flash":
			pluginUrl = "http://www.macromedia.com/go/getFlashPlayer/";               
			break;
		case "pdf":
			pluginUrl = "http://www.adobe.com/products/acrobat/readstep2.html";
			break;
		case "java":
			pluginUrl = "http://www.java.com/en/download/index.jsp";
			break;
		case "mspowerpoint":
			pluginUrl = "http://www.microsoft.com/downloads/details.aspx?FamilyID=428d5727-43ab-4f24-90b7-a94784af71a4&displaylang=en";
			break;
		case "msword":
			pluginUrl = "http://www.microsoft.com/downloads/details.aspx?familyid=95E24C87-8732-48D5-8689-AB826E7B8FDF&displaylang=en";
			break;
		case "msexcel":
			pluginUrl = "http://www.microsoft.com/downloads/details.aspx?familyid=C8378BF4-996C-4569-B547-75EDBD03AAF0&displaylang=en";
			break;
		case "windowsmedia":
			pluginUrl = "http://www.microsoft.com/windows/windowsmedia/";
			break;
		case "quicktime":
			pluginUrl = "http://www.apple.com/quicktime/download/";
			break;
		case "realplayer":
			pluginUrl = "http://www.real.com/";
			break;
		case "mrsid":
			pluginUrl = "http://www.lizardtech.com/download/dl_options.php?page=viewers";
			break;
		case "smartboard":
			//pluginUrl = "http://www.smarttech.com/support/software/index.asp";
			pluginUrl = "http://www2.smarttech.com/st/en-US/Support/Downloads/SBS/";
			break;
	}
	if (  pluginUrl != '' )
		window.open(pluginUrl, 'plugindownload', null);

	return false;
}

function GetComputerInfo(render){
	// Render Requirements Listing
	var sBrowser = getBrowser();//navigator.appName;
	var appVer = navigator.appVersion;
	var sOS = getOS();
	var lFlashVersion;
	var sMPVersion;
	var sAdobeAcroba;
	//	Detect the plug-ins
	lFlashVersion = getFlashVersion(6);
	sMPVersion    = checkMediaPlugin(sOS);
	sAdobeAcrobat = checkAcrobat(sOS);

	// write out users configuration
	var html = '<div id="MyComputerInfo">';
	html += '<h2>Your computer reports that it is running the following:</h2>';
	html += '<div id="MyComputerItems">';
	html += '<div class="left label">Operating System:</div><div class="right info">'+ sOS +'</div>';
	html += '<div class="left label">Browser:</div><div class="right info">'+ sBrowser + '</div>';
	html += '<div class="left label">Flash Player:</div><div class="right info">'+ lFlashVersion +'</div>';
	html += '<div class="left label">Media Player:</div><div class="right info">'+ sMPVersion +'</div>';
	html += '<div class="left label">Adobe Acrobat:</div><div class="right info">'+ sAdobeAcrobat +'</div>';
	html += '<div class="left label">Accept Cookies:</div><div class="right info">'+ checkCookies() +'</div>';
//	html += '';

	html += '<div style="clear:both;"></div></div></div>';
	
	if( render == true ){
		document.open();
		document.write(html);
		document.close();
	} // end of rendering info

return html;
}

