/* This is the page code holding the Flash file

<script src="js/flash.js" type="text/javascript" language="javascript"></script>
<td valign="top" align="center"><script>writeFlash(7, "file.swf", width, height, "#ffffff");</script></td>

*/


if(!flashDetectInited)
{
	var flashDetectInited = true;

	function FlashDetector()
	{
		//alert("Nav.AppVersion: " + navigator.appVersion);
		//alert("Nav.AppName: " + navigator.appName);
		//alert("Nav.UserAgent: " + navigator.userAgent);
		//alert("Nav.Platform: " + navigator.platform);
		this.browserSniff();
		this.init();
	};
	
	// misc properties
	FlashDetector.prototype.$maxVersion = 7;
	FlashDetector.prototype._version = 0;
	FlashDetector.prototype.defaultAltContent = '<table class="getFlash" width="100%" height="100%" border="0" cellpadding="20" cellspacing="0"><tr><td valign="top">';
	FlashDetector.prototype.defaultAltContent += 'The latest version of the Flash player was not detected on your browser<br>';
	FlashDetector.prototype.defaultAltContent += 'In order to view this content, you need to install the latest version of the free Flash player from Macromedia. The links below will open in a new window - once you have installed the Flash Player, come back and refresh this page.<br><br>';
	FlashDetector.prototype.defaultAltContent += '<a class="gfAnchor" href="http://www.macromedia.com/go/getflashplayer/" target="_blank">&raquo; Click here to install the free Flash Player now!</a><br><br>';
	FlashDetector.prototype.defaultAltContent += '<a class="gfAnchor" href="http://www.macromedia.com/go/flashplayer/" target="_blank">&raquo; Click here for more information about the Macromedia Flash Player.</a><br>';
	FlashDetector.prototype.defaultAltContent += '<div align="center"><a href="http://www.macromedia.com/go/getflashplayer"><img src="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" border="0"></a></div><br>';
	FlashDetector.prototype.defaultAltContent += 'For the best experience, we also recommend that you install the most current version of your preferred browser.<br><br>';
	FlashDetector.prototype.defaultAltContent += '<ul>';
	FlashDetector.prototype.defaultAltContent += '<li><a class="gfAnchor" href="http://www.microsoft.com/windows/ie/default.asp" target="_blank">Internet Explorer (PC)</a></li>';
	FlashDetector.prototype.defaultAltContent += '<li><a class="gfAnchor" href="http://www.microsoft.com/mac/products/internetexplorer/internetexplorer.aspx?pid=internetexplorer" target="_blank">Internet Explorer (Mac)</a></li>';
	FlashDetector.prototype.defaultAltContent += '<li><a class="gfAnchor" href="http://channels.netscape.com/ns/browsers/default.jsp" target="_blank">Netscape 7 (PC/Mac)</a></li>';
	FlashDetector.prototype.defaultAltContent += '<li><a class="gfAnchor" href="http://www.apple.com/safari/" target="_blank">Safari (Mac)</a></li>';
	FlashDetector.prototype.defaultAltContent += '</ul><br>';
	FlashDetector.prototype.defaultAltContent += '</td></tr></table>';
	
	// Browser Info Props
	FlashDetector.prototype._isIE = false;
	FlashDetector.prototype._isWin = false;
	FlashDetector.prototype.altBrowsers = ["opera","safari","konqueror","netscape"];
	
	FlashDetector.prototype.init = function()
	{
		if(this._isIE && this._isWin)
		{
			this._version = this.checkFlashActiveX();
		}
		else
		{
			this._version = this.checkFlashNS();
		}
		//alert("Installed Flash Version: " + this._version);
	};
	
	FlashDetector.prototype.browserSniff = function()
	{
		var ua = navigator.userAgent.toLowerCase();
		this._isIE = (ua.indexOf("msie") != -1) ? true : false;
		if(this._isIE)
		{
			for(var i=0;i<this.altBrowsers.length;i++)
			{
				if(ua.indexOf(this.altBrowsers[i]) != -1)
				{
					//alert("Seems to contain: " + this.altBrowsers[i]);
					this._isIE = false;
					break;
				}
			}
		}
		this._isWin = (ua.indexOf("windows") != -1) ? true : false;
	};
	
	FlashDetector.prototype.checkFlashActiveX = function()
	{
		if(!this._isIE || !this._isWin) return false;
	
		var fObj;
		var c = 0;
		// runs the try/catch through an eval
		// so it doesn't break in older browsers
		// with older JS engines
		eval("for(i=this.$maxVersion;i>2;i--){try{fObj = new ActiveXObject(\"ShockwaveFlash.ShockwaveFlash.\"+i);c = i;break;}catch(e){}}");
		/*
		// this the (formatted) code of the above eval statement
		for(i=this.$maxVersion;i>2;i--)
		{
			try
			{
				fObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				//return i;
				c = i;
				break;			
			}
			catch(e)
			{
				// do nothing on error...just roll through
			}
		}
		*/
		return c;
	};
	
	FlashDetector.prototype.checkFlashNS = function()
	{
		if (navigator.plugins && navigator.plugins["Shockwave Flash"])
		{
				var d = navigator.plugins["Shockwave Flash"].description;
				var fv = parseInt(d.charAt(d.indexOf(".") - 1));
				return fv;
		}
		return false;
	};
	
	FlashDetector.prototype.writeFlash = function(version, fileName, width, height, bgColor, altImage, altContent)
	{
		if(this._version >= version)
		{
			// get the codebase/classid attributes based on version number
			var codeBase = "#version=5,0,0,0";
			if(version == 6)
			{
				codeBase = "#version=6,0,0,0";
			}
			else if(version == 7)
			{
				codeBase = "#version=7,0,14,0";
			}
			document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash/cabs/swflash.cab'+ codeBase +'" width="' + width + '" height="' + height + '">');
			document.write('<param name="movie" value="' + fileName + '">');
			document.write('<param name="quality" value="high">');
			document.write('<param name="menu" value="false">');
			document.write('<param name="loop" value="true">');
			document.write('<param name="bgcolor" value="' + bgColor + '">');
			document.write('<embed src="'+ fileName +'"');
			document.write(' width="' + width + '" height="' + height + '"');
			document.write(' quality="high"');
			document.write(' menu="false"');
			document.write(' bgcolor="'+ bgColor +'"');
			document.write(' loop="true"');
			document.write(' type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
			document.write('</embed>');
			document.write('</object>');
		}
		else
		{
			if((!altContent || altContent == "") && (!altImage || altImage == ""))
			{
				document.write(this.defaultAltContent);
			}
			else
			{
				if(altContent)
				{
					document.write(altContent);
				}
				else
				{
					document.write('<a href="http://www.macromedia.com/go/getflashplayer" target="_blank"><img src="' + altImage + '" width="' + width + '" height="' + height + '" border="0" alt="Get Flash!"></a>');
				}
			}
		}
	};
	
	var _fd = new FlashDetector();
	function writeFlash(version, fileName, width, height, bgColor, altImage, altContent)
	{
		_fd.writeFlash(version, fileName, width, height, bgColor, altImage, altContent);
	}
}