//********************************************************************************************
//	FILE:			flashSniffer.js
//	AUTHOR:			Al Kahler
//	DATE:			11/02/2001
//	REQUIREMENTS:	must have flashSniffer.vbs loaded first!
//********************************************************************************************
	
	var reqFlashVer		= 5;		// minimum required flash version
	var noFlashURL		= null;		// url for noflash redirection (use null if no redirection)
	var promptDownload	= true;		// should user be prompted for Flash plugin download?
	var downloadURL		= null;		// url of download prompting page (use null for default)
	
	var invalidFlash	= sniffFlashIgnorance(reqFlashVer);
	
	//--------------------------------------------------------------------------------------------
	//	DISPLAY FLASH MOVIE
	//	displays flash movie or appropriate alternative based on parameters
	//--------------------------------------------------------------------------------------------
		function displayFlashMovie(movieFilePath, movieWidth, movieHeight, movieColor, stillFilePath) {
			var movieName = movieFilePath.substring((movieFilePath.lastIndexOf("/") + 1), (movieFilePath.length - 4));
			
			if (invalidFlash) {
				if (stillFilePath != null) { document.write('<img src="' + stillFilePath + '" width="' + movieWidth + '" height="' + movieHeight + '" border="0" alt="" usemap="#navBar" />'); }
				if (promptDownload) { buildDownloadPrompt(); }
				if (noFlashURL != null) { document.location.href = noFlashURL; }
			} else {
				document.write('<object classid="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=' + reqFlashVer + ',0,0,0" id="' + movieName + '" width="' + movieWidth + '" height="' + movieHeight + '">');
				document.write('	<param name="movie" value="' + movieFilePath + '">');
				document.write('	<param name="quality" value="high">');
				document.write('	<param name="bgcolor" value="' + movieColor + '">');
				document.write('	<embed src="' + movieFilePath + '" quality="high" bgcolor="' + movieColor + '" width="' + movieWidth + '" height="' + movieHeight + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>');
				document.write('</object>');
			}
		}


	//--------------------------------------------------------------------------------------------
	//	SNIFF FLASH PLAYER AND REQUIRED VERSION
	//	returns true/false value of browsers inability to display requested flash version.
	//	(true = NO FLASH; false = YES FLASH)
	//--------------------------------------------------------------------------------------------
		function sniffFlashIgnorance(flashVersion) {
			browserNaming();	// call browser sniffer routines...
			
			if (browserName == "IE") {	// Welcome Internet Explorer...
				return vbFlashIgnorance(flashVersion);
			} else if (browserName == "NS") {		// Welcome Netscape...
				if ((navigator.plugins) && (navigator.plugins["Shockwave Flash"]) && (parseInt(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin.description.substring(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin.description.indexOf(".") - 1)) >= flashVersion)) { return false; } else { return true; }
			} else { return false; }
		}
	
	
	//--------------------------------------------------------------------------------------------
	// CHECK CLIENT BROWSER & PLATFORM
	// original code from http://developer.apple.com/internet/_javascript/
	//
	// USAGE:	browserNaming();
	// RESULT:	browserNew = true/false
	//			browserName = IE/NS/Opera
	//			browserNameLong = IE5/etc
	//			Macintosh = true/false
	//--------------------------------------------------------------------------------------------
		var its;
		var browserName;
		var browserNameLong;
		var browserNew;
		var Macintosh = (navigator.userAgent.indexOf('Mac') > 0);
		
		function its() {
			var n = navigator;
			var ua = ' ' + n.userAgent.toLowerCase();
			var pl = n.platform.toLowerCase();
			var an = n.appName.toLowerCase();
		
			// browser version
			this.version = n.appVersion;
			this.nn = ua.indexOf('mozilla') > 0;
		
			// 'compatible' versions of mozilla aren't navigator
			if (ua.indexOf('compatible') > 0) { this.nn = false; }
			
			this.opera = ua.indexOf('opera') > 0;
			this.ie = ua.indexOf('msie') > 0;
			this.major = parseInt(this.version);
			this.minor = parseFloat(this.version);
		
			// platform
			this.mac = ua.indexOf('mac') > 0;
			this.win = ua.indexOf('win') > 0;
		
			// workaround for IE5 which reports itself as version 4.0
			if (this.ie) {
				if (ua.indexOf("msie 5") > 1) {
					var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
					this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
				}
			}
		
			return this;
		}
		
		function browserNaming() {
			its = new its();
			
			// is it a DOM-enabled browser?
			browserNew = (document.getElementById);
		
			// need the name, too
			if (its.opera) { browserName = "Opera"; }
				else if (its.ie) { browserName = "IE"; }
					else { browserName = "NS"; }
		
			// and the number
			browserNameLong = browserName + its.major;
		}


	//--------------------------------------------------------------------------------------------
	//	DISPLAY DOWNLOAD PROMPT
	//	displays prompt for download in a small popup window
	//--------------------------------------------------------------------------------------------
		function buildDownloadPrompt() {
			if (downloadURL == null) {
				promptWindow = window.open("", "flashPrompt", "toolbar=no,location=no,status=yes,menubar=no,scrollbars=1,width=400,height=220,resizable=1");
				
				promptWindow.document.write('<html><title>Download Flash Plugin Now!</title>');
				promptWindow.document.write('<body bgcolor="#eeeeee" text="#000000" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
				promptWindow.document.write('<div align="center">');
				promptWindow.document.write('	<table border="0" cellpadding="0" cellspacing="0" width="100%">');
				promptWindow.document.write('		<tr valign="top" bgcolor="#666666">');
				promptWindow.document.write('			<td width="50%">&nbsp;</td>');
				promptWindow.document.write('			<td width="340"><br /><div><font face="verdana, arial" size="4" color="#ffffff"><strong>YOU NEED FLASH!</strong></font></div><hr width="340" size="0" border="0" bgcolor="#eeeeee" /></td>');
				promptWindow.document.write('			<td width="50%">&nbsp;</td>');
				promptWindow.document.write('		</tr>');
				promptWindow.document.write('	</table><table border="0" cellpadding="0" cellspacing="0" width="100%">');
				promptWindow.document.write('		<tr valign="top">');
				promptWindow.document.write('			<td width="50%">&nbsp;</td>');
				promptWindow.document.write('			<td width="340"><br />');
				promptWindow.document.write('				<p><font face="verdana, arial" size="2" color="#333333">This website utilizes the Flash ' + reqFlashVer + ' plug-in. We have noticed that you do not have the most recent version of Flash.  Click the button below to download the newest plugin from Macromedia.</font></p>');
				promptWindow.document.write('				<div align="right"><a href="http://macromedia.com/go/getflashplayerbutton/" target="macromedia"><img src="http://macromedia.com/images/get_flashplayer_88_31.gif" width="88" height="31" border="0" alt="Autoinstall Macromedia Flash Player Now!"></a></div>');
				promptWindow.document.write('				<hr width="340" size="0" border="0" bgcolor="#666666" /></td>');
				promptWindow.document.write('			<td width="50%">&nbsp;</td>');
				promptWindow.document.write('		</tr>');
				promptWindow.document.write('	</table>');
				promptWindow.document.write('</div>');
				promptWindow.document.write('</body>');
				promptWindow.document.write('</html>');
				promptWindow.document.close();
			} else {
				promptWindow = window.open(newWindowURL, "flashPrompt", "toolbar=no,location=no,status=yes,menubar=no,scrollbars=1,width=400,height=220,resizable=1");
			}
		}


//********************************************************************************************
// THE END!

