//Functions to get flash version & deploy flash/HTML depending on installed Vs required version

// v8 required for Flash to load GIFs
var flashinstalled = 0;
var installedFlashversion = GetFlashVersion();

//window.alert('flash player version installed='+installedFlashversion);


function GetFlashVersion()	{
	var flashversion = 0;
	
	if (navigator.plugins && navigator.plugins.length) {
		x = navigator.plugins["Shockwave Flash"];
		if (x) {
			flashinstalled = 1;
			if (x.description) {
				y = x.description;
				//alert(x.description);
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		} else {
			flashinstalled = 1;
			if (navigator.plugins["Shockwave Flash 2.0"]) {
				flashinstalled = 1;
				flashversion = 2;
			}
		}
	
	return flashversion;	

	}	else {
		if (navigator.mimeTypes && navigator.mimeTypes.length)	{
			x = navigator.mimeTypes['application/x-shockwave-flash'];
			if (x && x.enabledPlugin) {
				flashinstalled = 1;
			} else {
				flashinstalled = 0;
			}
		} else {
			document.open();
			document.write('<SCRIPT LANGUAGE=VBScript\> \n');
			document.write('Function VBGetSwfVer() \n');
			document.write('	on error resume next \n');
			document.write('	Dim flashObject \n');
			document.write('	for i=12 to 2 Step - 1\n');  //current version is 9, but set to 12 for future-proofing.
			document.write('	Set flashObject = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n');
			document.write('	if IsObject(flashObject) then\n');
			document.write('		flashinstalled = 1\n');
			document.write('		flashversion=i\n');
			document.write('		Exit for \n');
			document.write('	end if\n');
			document.write('	next\n');
			document.write('	VBGetSwfVer = flashversion \n');
			document.write('End Function \n');
			document.write('<\/SCRIPT\> \n');
			document.close();
		}
		
		return VBGetSwfVer();
	}	

}


// Deploy a flash movie OR alternative HTML
function DeployFlashMovie(flashMovieURL, requiredFlashVersion, width, height, noFlashHTML) {
	var ShowFlash=false;

	//alert(flashinstalled + '.' + installedFlashversion + '.' + requiredFlashVersion);
	if (flashinstalled == 1){
		if (installedFlashversion>=requiredFlashVersion) {
			ShowFlash=true;
		}
	}
	document.open();
	
	if (ShowFlash==true) {
		document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '"> ');
		document.write(' <param name="movie" value="' + flashMovieURL + '"> ');
		document.write(' <param name="wmode" value="transparent"> ');
		document.write(' <param name="quality" value="high"> ');
		document.write(' <embed src="' + flashMovieURL + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
		document.write('</object>');
	} else {
		document.write(noFlashHTML);
		document.close();
	}
}