
var detectableWithVB = false;
var pluginFound = false;

function canDetectPlugins() {
	if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
		return true;
	} else {
		return false;
	}
}

function detectFlash() {
	pluginFound = detectPlugin('Shockwave','Flash'); 
	// if not found, try to detect with VisualBasic
	if(!pluginFound && detectableWithVB) {
		pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
	}
	// check for redirection
	return pluginFound;
}

function detectWindowsMedia() {
	pluginFound = detectPlugin('Windows Media');
	/*
	if(!pluginFound && detectableWithVB) {
		pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
	}
	*/
	// detect with WMP through ActiveXObject instead of VB
	if(!pluginFound)
	{
		if (!window.ActiveXObject) return pluginFound;
		var control = null;
		try {
			control = new ActiveXObject('WMPlayer.OCX');
		}
		catch (e) { return pluginFound;}	
		
		if(control){
			wmpVersion = parseFloat(control.versionInfo);
			if(wmpVersion >= 9)
			{
				pluginFound = true;
			}
		}
	}

	return pluginFound;
}

function detectPlugin() {
	// allow for multiple checks in a single pass
	var daPlugins = detectPlugin.arguments;
	var pluginFound = false;

	if (navigator.plugins && navigator.plugins.length > 0) {
		var pluginsArrayLength = navigator.plugins.length;
		for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			var numFound = 0;
			for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
				// if desired plugin name is found in either plugin name or description
				if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					numFound++;
				}
			}

			// if the number we found matches the total number provided then we were successful
			if(numFound == daPlugins.length) {
				pluginFound = true;
				break;
			}
		}
	}
	return pluginFound;
}


