// ## Flash detection START ##

// plugin version greater than
var pluginTargetVersion = 4;

// set all conditional variabels to 'false'
var detectableWithVB = false;
var detectableWithPlugins = false;
var pluginDetected = false;

// writes a block of VBScript for all VBScript capable browsers, namely MSIE(Win), which will do the check
document.writeln('<script language="VBscript">');
document.writeln('detectableWithVB = False');
document.writeln('If ScriptEngineMajorVersion >= 2 then');
document.writeln('  detectableWithVB = True');
document.writeln('End If');
document.writeln('Function detectActiveXControl(activeXControlName)');
document.writeln('  on error resume next');
document.writeln('  detectActiveXControl = False');
document.writeln('  If detectableWithVB Then');
document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
document.writeln('  End If');
document.writeln('End Function');
document.writeln('<\/scr' + 'ipt>');

// if the browser has a plugins-array, run through this array and search for a plugin with the appropriate mime,suffix,
function checkForPlugin(){
	if(detectableWithPlugins){
		for (i=0;i<navigator.plugins.length;i++){
			for(j=0;j<navigator.plugins[i].length;j++){
				if (navigator.mimeTypes && navigator.plugins[i][j].type.indexOf('application/x-shockwave-flash') != -1 && 
					(navigator.plugins[i][j].suffixes.indexOf('swf') != -1) && 
					navigator.plugins[i].description.indexOf('Flash') != -1 && 
					parseInt(navigator.plugins[i].description.substr(navigator.plugins[i].description.indexOf('.')-1,1)) >= pluginTargetVersion) pluginDetected = true;
				}
			}
		}
	else if (detectableWithVB) pluginDetected = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.'+pluginTargetVersion);
	}
	
	
function canDetect(){

	// check if the browser has the 'navigator.plugins' object and if any plugins are installed 
	detectableWithPlugins = (navigator.plugins && navigator.plugins.length > 0)? true:false;
	
	if (detectableWithVB || detectableWithPlugins) return true;
	else return false;
	
    }

if(canDetect()) checkForPlugin();

//alert('VB:'+detectableWithVB+' | Plugins:'+detectableWithPlugins+' | FlashDetected:'+pluginDetected);

// ## Flash detection END ##
