var g_flashDetectMinTarget="";
var g_flashDectectVersion="";

function GetFlashVersion(minTarget)
{
	var agt = navigator.userAgent.toLowerCase();	  
	var is_major = parseInt(navigator.appVersion);	   
	var is_mac = (agt.indexOf("mac")!=-1);	   
	var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));	   
	var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));	   
	var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));	   
	var is_win32 = (is_win95 || is_winnt || is_win98 || ((is_major >= 4) &&				
		(navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) ||				
		(agt.indexOf("32bit")!=-1));	   
	var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1));	   
	var is_nav4up = (is_nav && (is_major >= 4));	   
	var is_ie   = (agt.indexOf("msie") != -1);	   
	var is_ie4up  = (is_ie  && (is_major >= 4));	   

	if ((is_win32) ^ (is_mac))
	{
		//minTarget must be "" or an integer >0 to be valid
		if(typeof(minTarget)=="undefined" || minTarget=="")
		{
			minTarget=1;
		}

		if (is_nav4up && navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] &&	
   			navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){	
				g_flashDectectVersion = 5;				
		}
		
		if ( is_ie4up ) {
			if(parseInt(minTarget)==minTarget && minTarget>0)
			{
				g_flashDetectMinTarget=minTarget;
				document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
				document.write('on error resume next \n');
				document.write('For vb_i = 9 To g_flashDetectMinTarget Step -1\n');
					document.write('vb_CLSID="ShockwaveFlash.ShockwaveFlash." & vb_i\n');
					document.write('Set vb_FlashObj = CreateObject(vb_CLSID)\n');
					document.write('If IsObject(vb_FlashObj) Then\n');
						document.write('Set vb_FlashObj = nothing\n');
						document.write('g_flashDectectVersion=vb_i\n');
						document.write('Exit For\n');
					document.write('End If\n');
					document.write('Next\n');											
				document.write('</SCR' + 'IPT\>');
			}	
		}
	}
	return g_flashDectectVersion;
}

function HasFlashVersion(minVersion)
{
	var currentVersion=GetFlashVersion(minVersion);
	if(currentVersion!="" && currentVersion>=minVersion)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ForceFlashUpgrade(minVersion, launchRetURL)
{
	//this code was removed but some CMS code still calls this (MZKI) so can't delete the method until all calls removed.
}
	

function writeFlash(width, height, ID, swfPath, basePath, bgcolor)
{	writeFlashEx2(width, height, ID, swfPath, basePath, bgcolor,"", "");
}

function writeFlashEx(width, height, ID, swfPath, basePath, bgcolor, flashVars)
{
	writeFlashEx2(width, height, ID, swfPath, basePath, bgcolor, flashVars, "");
}

function writeFlashEx2(width, height, ID, swfPath, basePath, bgcolor, flashVars, configObj)
{
	var version=configObj.version;
	try
		{
		if(version==undefined)
		{
			version="6,0,0,0";
		}
	}
	catch(e)
	{
		version="6,0,0,0";
	}
	
	var wmode=configObj.wmode;
	try
	{
		if(wmode==undefined)
		{
			wmode="opaque";
		}
	}
	catch(e)
	{
		wmode="opaque";
	}

	var play = configObj.play;
	try
	{
		if(play==undefined)
		{
			play="true";
		}
	}
	catch(e)
	{
		play="true";
	}

	document.writeln("<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + version + "\" width=\"" + width + "\" height=\"" + height + "\" id=\"" + ID + "\"VIEWASTEXT>");
	document.writeln("<PARAM name=\"wmode\" value=\"" + wmode + "\">");
	document.writeln("<PARAM name=\"movie\" value=\"" + swfPath + "\">");
	document.writeln("<PARAM name=\"flashvars\" value=\"" + flashVars + "\">");
	document.writeln("<PARAM name=\"play\" value=\"" + play + "\">");
	document.writeln("<PARAM name=\"bgcolor\" value=\"" + bgcolor + "\">");
	document.writeln("<PARAM name=\"base\" value=\"" + basePath + "\">");
	document.writeln("<PARAM name=\"menu\" value=\"false\">");
	document.writeln("<EMBED id=\"" + ID + "\" src=\"" + swfPath + "\"");
	document.writeln("wmode=\"" + wmode + "\"");
        document.writeln("flashvars=\"" + flashVars + "\"");
	document.writeln("play=\"" + play + "\"");
	document.writeln("bgcolor=\"" + bgcolor + "\"");
	document.writeln("width=\"" + width + "\"");
	document.writeln("height=\"" + height + "\"");
	document.writeln("type=\"application/x-shockwave-flash\"");
	document.writeln("pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"");
	document.writeln("base=\"" + basePath + "\"");
	document.writeln("menu=\"false\">");
	document.writeln("</embed>");
	document.writeln("<noembed>");
	document.writeln("<blockquote><font face=\"Lucida Console, Monaco, mono\" size=\"-2\"><A href=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" target=\"_self\">This site requires Macromedia Flash to be properly installed in a capable browser.<BR> Follow this link, and you'll find out everything you need to know.</A></font></blockquote>");
	document.writeln("</noembed>");
	document.writeln("</OBJECT>");
}
