/***************************************************************************
***                                                                      ***
***       Modified on 10/04/2005. Added DIM to vbScript. Not sure why it ***
***       was not working correctly for this 1 site without it           ***
***                                                                      ***
***************************************************************************/

//this variable must remain as a global variable outside of any functions for the
//script to preform correctly.
var plugin = 0;
var ploverride = false;

//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;
		}
	else
		{
		ploverride = 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 && !ploverride )
	{
	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 = 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('</SCRIPT\> \n');
		}
	}

function gotFlash(arg, expires)
	{
	if (!arg) arg = 0;
	var ndc = "jflashcookie=" + arg + "; path=/";
	if (expires)	
		{
		nd = new Date(expires);
		ndc += " expires=" + nd.toGMTString() + ";";
		}
	
	document.cookie = ndc;
	location.reload();
	}
	

function printFlash(arg)
	{
	fval = (arg)? arg : 1;
	if ( plugin >= fval || navigator.appName.indexOf('Netscape')>=0 ) 
		{
		document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
		document.write('  width="367" height="240" id="homepage" align="">');
		document.write('<param name=movie value="/images/home/flash_home.swf">');
		document.write('<param name=menu value=false>');
		document.write('<param name=quality value=best>');
		document.write('<param name=bgcolor value=#b2bb77>');
		document.write('<embed src="/images/home/flash_home.swf"  menu=false quality=best bgcolor=#b2bb77  width="367" height="240" name="homepage" align=""  ');
		document.write(' type="application/x-shockwave-flash" ');
		document.write('pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');
		} 
	else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
		{
		document.write('<img src="/images/home/flash/holiday_feast.jpg" width="367" height="240" alt="">');
		}
	}