/************************************************
**     Inline Flash Sniffer Version 20040406   **
**                                             **
**     Modified by Petey                       **
************************************************/
//this variable must remain as a global variable outside of any functions for the
//script to perform correctly.
var plugin = 0;

//this part checks for the presence of an override cookie value 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;
	}
	
//this part looks for a sound prefernce
var au_pref = 1;
//alert(au_pref);
dcindex = dc.indexOf("audioprefs=");
if (dcindex >= 0)
	{
	dcindex = dc.indexOf("=",dcindex) +1;
	dcend = dc.indexOf(";",dcindex);
	dcend = (dcend == -1) ? dc.length : dcend;
	au_pref = unescape(dc.substring(dcindex,dcend));
	if (au_pref == null) au_pref = 1;
	}
//alert(au_pref);
au_pref = (au_pref == 1)? 0 : 1;

//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 Netscape 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('For i = 9 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('</SCR'+'IPT\> \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 printFlash(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.	
	var dc = document.cookie;
	var dcindex = dc.indexOf("seenit=");
	var beenSeen = 0;
	if (dcindex >= 0)
		{
		dcindex = dc.indexOf("=",dcindex) + 1;
		var dcend = dc.indexOf(";",dcindex);
		dcend = (dcend == -1) ? dc.length : dcend;
		beenSeen = unescape(dc.substring(dcindex,dcend));
		if (beenSeen == null) plugin = 0;
		}
	
	fval = (arg)? arg : 1;
	if ( plugin >= fval && beenSeen < 10 ) 
		{
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="600" height="302" id="homepage" align="">');
		document.write(' <param name=movie value="/images/home/fazolis_flash.swf"><param name=menu value=false><param name=quality value=best><param name=bgcolor value=#FFFFFF> ');
		document.write(' <embed src="/images/home/fazolis_flash.swf" menu=false quality=best bgcolor=#FFFFFF  width="600" height="302" name="homepage" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');
		document.write('</object>');
		} 
	else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
		{
		document.write('<img src="/images/home/fazolis_flash.jpg" width="600" height="302" alt="">');
		}
	}
	
function seenIt(arg)
	{
	var si = "seenit=10;"
	document.cookie = si;
	}
	
function soundPrefs(arg)
	{
	var nd = new Date()
	nd.setYear(nd.getYear() + 2);
	var ap = "audioprefs=" + arg + ";expires=" + nd.toGMTString() + ";";
	document.cookie = ap;
	//alert(ap);
	}


