//this variable must remain as a global variable outside of any functions for the
//script to preform correctly.
var plugin = 0;

//this part checks for the presence of an override cookie vaue set as jflashcookie
var dc = document.cookie;
var dcindex = dc.indexOf("jflashcookie=");
if (dcindex >= 0)
	{
	dcindex = dc.indexOf("=",dcindex) + 1;
	var dcend = dc.indexOf(";",dcindex);
	dcend = (dcend == -1) ? dc.length : dcend;
	plugin = unescape(dc.substring(dcindex,dcend));
	if (plugin == null) plugin = 0;
	}

//first the script checks for the shockwave flash mime type and an associated plugin
//if it is found it sets the plugin variable to 1, this works with Netsscape and MAC IE 5 
if (plugin < 1)
	{
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) 
		{
		if (navigator.plugins && navigator.plugins["Shockwave Flash"]) 
			{
			versionIndex = navigator.plugins["Shockwave Flash"].description.indexOf(".");
			var versionString = navigator.plugins["Shockwave Flash"].description.substring(versionIndex-1, versionIndex);
			plugin = parseInt( versionString );
			}
		}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Win")>=0)) 
		{
		//if it is a windows computer, it writes a client side vb script to try to create
		//an instnace of the flash activeX object for each version 3 - 6. If it succeeds then
		//it sets the plugin variable to 1 (see why we need the plugin variable to be outside the function?)
		document.write('<SCRI' + 'PT LANGUAGE=VBScript\> \n');
		document.write('on error resume next \n');
        document.write('Dim i\n');
		document.write('For i = 6 to 3 step -1\n');
		document.write('SFlash = "ShockwaveFlash.ShockwaveFlash." & i \n');
		document.write('hasflash = isObject(CreateObject(SFlash)) \n');
		document.write('If hasflash Then \n');
		document.write('plugin = i \n');
		document.write('Exit For \n');
		document.write('End If \n');
		document.write('Next \n');
		document.write('</SCRIPT\> \n');
		}
	}

function gotFlash(arg, expires)
	{
	if (!arg) arg = 0;
	var ndc = "jflashcookie=" + arg + ";";
	if (expires)	
		{
		nd = new Date(expires);
		ndc += " expires=" + nd.toGMTString() + ";";
		}
	
	document.cookie = ndc;
	location.reload();
	}

	
	function printJack_Sandwich(arg)	
	{
	//at this point, we are either on a browser with a script detectable version of flash
	//or we aren't. Real deep.
	//if we are, write the appropriate flash code, if not write an alternate image.	
	fval = (arg)? arg : 1;
	if ( plugin >= fval ) 
		{
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write('  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ');
		document.write(' id=jack9 width=960 height=551>');
		document.write(' <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="jack9.swf" />	<param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="bgcolor" value="#660000" />'); 
		document.write(' <embed src="/jack9.swf" wmode="transparent" bgcolor="#660000" width="960" height="551" name="jack9" align="middle" ');
		document.write(' swLiveConnect=false width=960 height=551 bgcolor=#660000');
		document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
		document.write(' </embed>');
		document.write(' </object>');
		} 
	else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
		{
		document.write('<a href="http://www.adobe.com/products/flashplayer/ target="_blank"><img src="/images/home.jpg" width="960" height="551" border="0" alt="Make a Jack Sandiwch"></a>');
		}
	}