<!--

/*
 *	sniffer.js
 *
 *  credits:  Anthony Thompson & Phil Scott (Juxt Interactive)
 *       	  Netscape Communications (technical support)
 *
 *  Copyright 2000 Juxt Interactive.  All Rights Reserved.
 *
 *  You are free to reuse and modify this script for personal or commercial
 *  use, so long as you do not remove or modify this message, title block, 
 *  credits, or copyright.
 *
 */


 
/****************************************************************************
 *
 *  Last Modified:  07-05-00
 *
 *  Purpose:  To sniff out what kind of browser, platform, and version of
 *            Flash is viewing a web site.
 *
 ***************************************************************************
 *  Published Values:
 *
 *	-- browser values --
 *	is_ns			True if detected: Netscape (any, including compatibles)
 *	is_ns2			True if detected: Netscape 2.x
 *	is_ns3			True if detected: Netscape 3.x
 *	is_ns4			True if detected: Netscape 4.0
 *  is_ns4up		True if detected: Netscape 4.0 or higher
 *  is_nsonly		True if detected: Netscape (True, real, actual Netscape)
 *  is_ns5			True if detected: Netscape 5.0 (not out yet)
 *  is_ns5up		True if detected: Netscape 5.0 or higher
 *  is_ie			True if detected: Internet Explorer (ANY)
 *  is_ie3			True if detected: Internet Explorer 3.x
 *  is_ie4			True if detected: Internet Explorer 4.x
 *  is_ie45			True if detected: Internet Explorer 4.5
 *  is_ie4up		True if detected: Internet Explorer 4.0 or higher
 *  is_ie5			True if detected: Internet Explorer 5.0
 *  is_ie5up		True if detected: Internet Explorer 5.0 or higher
 *  is_aol			True if detected: America Online    :(
 *  is_aol3			True if detected: America Online IE 3.x
 *  is_aol4			True if detected: America Online IE 4.x
 *  is_opera		True if detected: Opera browser
 *  is_webtv		True if detected: WebTV  :(
 *
 *	-- platform values --
 *  is_win			True if detected: Windows (ANY)
 *  is_win16		True if detected: 16-bit Windows  :(
 *  is_win32		True if detected: 32-bit Windows
 *  is_win31		True if detected: Windows 3.1
 *  is_win95		True if detected: Windows 95
 *  is_win98		True if detected: Windows 98
 *  is_winnt		True if detected: Windows NT
 *  is_os2			True if detected: IBM OS/2
 *  is_mac			True if detected: Macintosh
 *  is_mac68k		True if detected: Macintosh 68000 series  :(
 *  is_macppc		True if detected: Macintosh PowerPC
 *
 *	-- flash values --
 *  is_flash3		True if detected: Flash 3   :)
 *  is_flash4		True if detected: Flash 4   :)
 *
 ***************************************************************************
 *  Notes:
 * 
 *  To set a cookie which manually sets the version of Flash 
 *  (bypassing the sniffer), add the following to your URL's query string:
 *
 *			setflash=3     or     setflash=4
 *
 *  For example:
 *			http://www.myserver.com/gotflash.htm?setflash=4
 *
 *  In the preceding example, be sure to include the sniffer.js file within
 *  the gotflash.htm page.  The sniffer.js script will automatically
 *  check for the setflash=? value and set a cookie for a future reminder.
 *
 ***************************************************************************/


////////////////////////
// Convert user Agent string to Lowercase
////////////////////////
var agt=navigator.userAgent.toLowerCase();		// for internal use only


///////////////////
// Browser Version
///////////////////

var is_major = parseInt(navigator.appVersion);	// for internal use only
var is_minor = parseFloat(navigator.appVersion);	// for internal use only

var is_ns  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));
var is_ns2 = (is_ns && (is_major == 2));
var is_ns3 = (is_ns && (is_major == 3));
var is_ns4 = (is_ns && (is_major == 4));
var is_ns4up = (is_ns && (is_major >= 4));
var is_nsonly  = (is_ns && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_ns5 = (is_ns && (is_major == 5));
var is_ns5up = (is_ns && (is_major >= 5));

var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) && (agt.indexOf("msie 4.5")==-1) );
var is_ie45  = (is_ie && (is_major == 4) && (agt.indexOf("msie 4.5")!=-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);

var is_opera = (agt.indexOf("opera") != -1);
var is_webtv = (agt.indexOf("webtv") != -1);


////////////
// Platform
////////////

var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
var is_win16 = ((agt.indexOf("win16")!=-1) || (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("windows 16-bit")!=-1) );
var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || (agt.indexOf("windows 16-bit")!=-1));

var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 || ((is_major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

var is_os2   = ((agt.indexOf("os/2")!=-1) || (navigator.appVersion.indexOf("OS/2")!=-1) || (agt.indexOf("ibm-webexplorer")!=-1));

var is_mac= (agt.indexOf("mac")!=-1);
var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1)));
var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)));




//////////////////
// Cookie Handling Functions
// Last Modified: 07-05-00
//////////////////

//--------------------------------------------------------------------------
function set_cookie(name, value) {

	//--- Set up the cookie expiration for 1 year ---
	var exp = new Date();
	var oneYearFromNow = exp.getTime() + (365 * 24 * 60 * 60 * 1000);
	exp.setTime(oneYearFromNow);

	//--- Set the Browser cookie ---
	document.cookie = name+ "=" +value+"; expires="+ exp.toGMTString();
}

//--------------------------------------------------------------------------
function get_cookie(name) {
	var nameLen = name.length;
	var cLen = document.cookie.length;
	var idx = 0;
	var cEnd;
	while (idx < cLen) {
		var j = idx + nameLen;
		if (document.cookie.substring(idx,j) == name) {
			cEnd = document.cookie.indexOf(";", j);
			if (cEnd == -1) {
				cEnd = document.cookie.length;
			}
			return unescape(document.cookie.substring(j+1, cEnd));
		}
		idx++;
	}
	return "";
}

/*
 *	Here, we check the URL for a variable called "setflash".  If it is found
 *	in the URL, then we need to set a cookie to remember which flash version
 *	was found.
 *
 *	This is used to bypass the sniffer for those unfortunate browsers that
 *	do not allow JavaScript detection of plug-ins like Flash.
 */
var cookie_request_found = document.location.href.indexOf('setflash=');
if (cookie_request_found != -1) {
	//--- Yes, we need to set a cookie to remember the Flash version ---
	var flash_ver = parseInt(document.location.href.substr(cookie_request_found+9,1));
	set_cookie('flash_ver', flash_ver);
}



//////////////////
// Flash 3 Detection
// Last Modified: 07-05-00
//////////////////

var is_flash_detectable = 1;	// for internal use only
var flash_ver = 0;				// for internal use only
if (is_mac && (is_ie4 || is_ie45) ) {
	is_flash_detectable = 0;

	//--- since we can't check for Flash, let's check for a cookie ---
	flash_ver = get_cookie('flash_ver');
}


var is_flash3 = 0;	// Default: Flash 3 is NOT available

if (is_flash_detectable) {

	// Check IE on windows for flash 3 using VB Script
	if (is_ie && is_win32) {

		document.write('<SCRIPT LANGUAGE="VB'+'Script"\>\n');
		document.write('on error resume next\n');
		document.write('is_flash3 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
		document.write('<'+'/SCRIPT> \n');

	// On other browsers, check for flash 3 using the DOM
	} else if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] 
		&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin 
		&& navigator.plugins && navigator.plugins["Shockwave Flash"]){
	
		is_flash3 = 1; // Flash 3 is available
	
	}

} else if (flash_ver == 3) {

	is_flash3 = 1;	// Flash 3 is available

}



//////////////////
// Flash 4 Detection
// Last Modified: 07-05-00
//////////////////

var is_flash4 = 0;	// Default: Flash 4 is NOT available

if (is_flash_detectable) {

	// for internal use only
	var flashPlugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0);
	

	// Check IE on windows for flash 4 using VB Script
	if (is_ie && is_win32) {
	
		document.write('<SCRIPT LANGUAGE="VB'+'Script"\>\n');
		document.write('on error resume next\n');
		document.write('is_flash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
		document.write('<'+'/SCRIPT> \n');

	// On other browsers, check for flash 4 using the DOM
	} else if (flashPlugin && parseInt(flashPlugin.description.substring(flashPlugin.description.indexOf(".")-1)) >= 4) { 
	
		is_flash4 = 1; // Flash 4 or greater is available
	
	}

} else if (flash_ver == 4) {

	is_flash4 = 1;	// Flash 3 is available

}

// -->
