// This script will test up to the following version.
flash_versions = 20;

// Initialize variables and arrays
var flash = new Object();
flash.installed=false;
flash.version='0.0';

// Dig through Netscape-compatible plug-ins first.
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}

// Then, dig through ActiveX-style plug-ins afterwords
else if (window.ActiveXObject) {
	for (x = 2; x <= flash_versions; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = x + '.0';
			}
		}
		catch(e) {}
	}
}

// Create sniffing variables in the following style: flash.ver[x]
// Modified by mjac
flash.ver = Array();
for(i = 4; i <= flash_versions; i++) {
	eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
}

// Write flash because of border
function writeFlash(url_root, width, height, bgcolor, version, name)
{
            if (version == null || version == ''){
                        version = '7,0,0,0';
            }
            document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'");
            document.writeln(" codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' ");
            document.writeln(" width='"+width+"' height='"+height+"'> ");
            document.writeln("<param name='movie' value='"+url_root+"'>");
            document.writeln("<param name='quality' value='high'>");
            document.writeln("<param name='bgcolor' value='"+bgcolor+"'>");
            if (bgcolor == null || bgcolor == 'FFFFFF'){
                        document.writeln("<param name='wmode' value='transparent'>");
            }
            document.writeln("<embed src='"+url_root+"' ");
            if (bgcolor == null || bgcolor == 'FFFFFF'){
                        document.writeln(" wmode='transparent' ");
            }
            document.writeln(" quality='high' bgcolor='"+bgcolor+"'  width='"+width+"' height='"+height+"' ");
            document.writeln(" type='application/x-shockwave-flash' ");
            document.writeln(" pluginspage='http://www.macromedia.com/shockwav/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>");
            document.writeln("</embed></object>");
}
