/* FlashDetect Script v1.2


Script created by Adam Curry and Eric Upchurch - 02/02.
This script will detect the presence of either the plug-in or
the Active X Control for the Flash Player and return a value
equal to the version number. It will also detect browser and
version number for NS4 - NS6, IE4 Macintosh, and IE on a PC.
If elected, this can also call a pop-up window allowing the 
user to install the required version of Flash. It will also, 
then, set a cookie if the user decides not to install flash. 
This decision will be recalled upon every visit to the site. 
Portions of code borrowed from script created by Robert 
Reinhardt for the Flash 5 
Bible, IDG Books.

		VERSION HISTORY

v1.0		Not worth mentioning
v1.1		Added loadFlash0() and loadNonFlash0()
					- for adding multiple .swf's to a page
				CheckFlash() function updated to support
			 		former loadFlash functions
				Fixed VBScript bug preventing true version
			 		reporting
v1.2		5/10/02
				Added platform/browser/version detection
					- Support for detecting Opera, NS 4.x - 6.2,
					IE on Win95 - WinXP, Mac

Instructions:
http://pc2/flashdetect/flashdetect_readme.htm
*/

var plugin = 0;
var version = 0;
var macOK = 0;
var macCookie = 0;

var debug = 0; //change to '1' to view platform/browser popup

var platform = "Unknown";
var browser = "Unknown";
var browserVer = "Unknown";

//Platform sniffing...
if (navigator.userAgent.indexOf("Windows 95")>=0) {platform = "Win95"}
else if ((navigator.userAgent.indexOf("Win98")>=0) || (navigator.userAgent.indexOf("Windows 98")>=0)){platform = "Win98"}
else if (navigator.userAgent.indexOf("Windows NT")>=0) {platform = "WinNT/2000"}
else if (navigator.userAgent.indexOf("Windows 2000")>=0) {platform = "Win2000"}
else if (navigator.userAgent.indexOf("Windows XP")>=0) {platform = "WinXP"}
else if (navigator.platform.indexOf("Mac")>=0) { platform = "Mac"}

//Browser sniffing...
if (navigator.appName == "Microsoft Internet Explorer") { browser = "IE";}
else if (navigator.appName == "Netscape") {browser = "NS";}
else if (navigator.appName == "Opera") {browser = "Opera";}

//Browser Version sniffing...
if (browser == "Opera") {
	browserVer = navigator.appVersion.substring(0,3);
} else if (navigator.appVersion.indexOf("MSIE")>=0) {
	browser = "IE";
	var startChar = navigator.appVersion.indexOf("MSIE")+5;
	endChar = startChar + 3;
	browserVer = navigator.appVersion.substring(startChar,endChar);
} else if (browser == "NS") {
	if (navigator.userAgent.indexOf("Netscape")>=0) {
	startChar = navigator.userAgent.indexOf("Netscape") + 8;
	endChar = startChar + 5;
	browserVer = navigator.userAgent.substring(startChar,endChar);
	} else {
	startChar = navigator.appVersion.indexOf(".")-1;
	endChar = startChar + 4;
	browserVer = navigator.appVersion.substring(startChar,endChar)
	}
}

//Detect if _any_ flash plugin is installed.
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
//fix for NS 4.? browser with NO flash plugin installed
if (plugin == null) { 
	plugin = 0; 
}
//Detect the version of flash plugin installed.
if ( plugin ) {
	if (parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) == 3) {
		version = 3;
	}	else if (parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) == 4) {
		version = 4;
	}	else if (parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) == 5) {
		version = 5;
	} else if (parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) == 6) {
		version = 6;
	}
}


//If no plugin architecture present, detect if IE capable of
//reading VBScript is present. Then write VBScript to detect
//if flash activeX version 3, 4, 5, or 6 is present.
else if (browser == "IE") {
	document.write('<scr' + 'ipt language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('version = 0 \n');
	//document.write('browser = "InternetExplorerPC" \n');
	document.write('set tempObj = CreateObject("ShockwaveFlash.ShockwaveFlash.6") \n');
	document.write('if err.Number = 0 then version = 6 \n');
	document.write('err.Clear \n');
	document.write('if version < 6 then \n');
	document.write('   set tempObj = CreateObject("ShockwaveFlash.ShockwaveFlash.5") \n');
	document.write('   if err.Number = 0 then version = 5 \n');
	document.write('end if \n');
	document.write('err.Clear \n');
	document.write('if version < 5 then \n');
	document.write('   set tempObj = CreateObject("ShockwaveFlash.ShockwaveFlash.4") \n');
	document.write('   if err.Number = 0 then version = 4 \n');
	document.write('end if \n');
	document.write('err.Clear \n');
	document.write('if version < 4 then \n');
	document.write('   set tempObj = CreateObject("ShockwaveFlash.ShockwaveFlash.3") \n');
	document.write('   if err.Number = 0 then version = 3 \n');
	document.write('end if \n');
	document.write('err.Clear \n');
	document.write('</scr' + 'ipt\> \n');
}



//Check to see if the user has already checked
//for flash. If they elect not to upgrade flash
//set a cookie to remember their decision.
if (window.location.search == "?macOK=1") {
	macOK = 1;
	macCookie = 1;
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = "macOK=1"
										+ "; expires=" + nextyear.toGMTString()
										+ "; path=/";
} else if (window.location.search == "?checked=1") {
	cookied = 1;
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = "cookied=1"
										+ "; expires=" + nextyear.toGMTString()
										+ "; path=/";

//Recall the cookie values, if set.
} else {
	var allcookies = document.cookie;
	var pos = allcookies.indexOf("cookied=");
	if (pos != -1) {
		var start = pos + 8;
		var end = allcookies.indexOf(";", start);
		if (end == -1) end = allcookies.length;
		var cookied = allcookies.substring(start, end);
	}
	var pos2 = allcookies.indexOf("macOK=");
	if (pos2 != -1) {
		var start = pos2 + 6;
		var end = allcookies.indexOf(";", start);
		if (end == -1) end = allcookies.length;
		var macOK = allcookies.substring(start, end);
	}
}
if (macOK == 1) {
	version = requiredVersion;
}
function checkFlash(functionNum) {
//If the user has elected not to upgrade to flash,
//load the alternate material.
	if (version < requiredVersion && cookied == 1){
			eval("loadNonFlash"+functionNum+"();");
			
//If Mac IE 4.5 or lower, this script cannot detect flash.
//Run the mac flash checker.
	} else if ((version < requiredVersion) && (platform=="Mac")){		window.open('check.htm?requiredVersion='+requiredVersion,'checker','height=330,width=300,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,');
	
//If IE or Netscape with correct flash version, insert flash
	} else if (version >= requiredVersion){
			eval("loadFlash"+functionNum+"();");
			
//If IE or NS without correct flash version, and popups
//are turned on, prompt user to upgrade.
	} else if (version < requiredVersion && popups == 1) {		window.open('frame.htm?version='+requiredVersion,'install','height=440,width=600,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,');
//If IE or NS without correct flash version, insert
//non-flash stuff.
	} else if (version < requiredVersion){
		eval("loadNonFlash"+functionNum+"();");
	}
}



//*****  IF PLACING THE LINK TO THIS EXTERNAL
//*****  FILE IN THE <HEAD> TAG OF THE DOCUMENT,
//*****  CUT THIS NEXT INSTRUCTION, AND PASTE
//*****  IT INTO THE APPROPRIATE LOCATION
//*****  WITHIN YOUR FILE, PER THE INSTRUCTIONS:
//*****  http://pc2/flashdetect/flashdetect_readme.htm

//checkFlash(0);

if (debug == 1) {
	alert(platform + " - " + browser + " v" + browserVer + " & Flash v" + version);
}
//-->