/*
	FlashCheck.js - Cleanup of Macromedias plugin version check

	Daniel Gustafsson
	Phosworks AB
	daniel@phosworks.se
*/




// Returns true if the browser supports the specified version, false if not
var bFlashCanPlay;

function HasFlashVersion(version)
{
	// Netscape plugin check for the flash player
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin )
	{
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
			if (isNaN(parseInt(words[i]))) continue; // Skip the rest of the code block but continue with iteration
			var PluginVersion = words[i];
	    }
		bFlashCanPlay = PluginVersion >= version;
	}
	else // Internet Explorer plugin check for the flash player
	{
		// If Internet Explorer then output VBScript code to check for the flash availability
		if ( navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1) )
   		{
			//FS hide this from IE4.5 Mac by splitting the tag
			document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
			document.write('on error resume next \n');
			document.write('bFlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + version + '")))\n');
			document.write('</SCR' + 'IPT\> \n');
		}
	}
	return bFlashCanPlay==true;
}




// Checks for the specified version of flash, if it doesn't exist then goto url
function CheckFlash(version, theurl)
{
	if ( !HasFlashVersion(version) )
	{
		document.location.href = theurl;
	}
}