function DetectPlugin(pstrTargetPlugin){
// this function uses javascript to detect a plugin.
//	
// Parameter:
//
// pstrTargetPlugin	= The plugin we're looking for

	// Assume failure
	blnFound		= false;

	// For each plugin installed in this browser
	for (i = 0; i < navigator.plugins.length; i++){
		// If it is the target plugin
		strPlugin	= navigator.plugins[i].name;
		if (strPlugin.indexOf(pstrTargetPlugin) != -1){
			// redirect to plugin enabled page
			blnFound		= true;
		}	
	}

	// return the redirect URL
	return blnFound;

}

function PickBrowserScript(pstrTargetPlugin, pstrPluginEnabled, pstrNoPlugin, pstrCantTellURL){
// This function routes browsers based on their plugin detectability. 
// Users are redirected as follows:
//
//	 > IE on a PC is sent to a VBScripted page
//	 > IE (4.5 or lower) on a Mac is sent to the Can't Detect page
//	 > All others are tested via JavaScript
//
//	Parameters:
//
//	pstrTargetPlugin	= The plugin we're looking for
//	pstrPluginEnabled	= URL of Plugin Enabled page
//	pstrNoPlugin		= URL of No Plugin needed page
//	pstrCantTellURL		= URL of "Can't detect" page

	strPlugin	= pstrTargetPlugin;
	strApp 		= navigator.appName;
	strVrs		= navigator.appVersion;
	//alert(strApp + " / " + strVrs);

	strVBScriptURL		= "vbscriptdetection.htm";

	blnNoDetect	= ((strVrs.indexOf("Mac") > -1) && (strVrs.indexOf("MSIE") != -1) && (strVrs.indexOf("MSIE 5") == -1));
	//alert("No Detection = " + blnNoDetect);
	// if this a Mac version of IE (below 5.0)
	if (blnNoDetect){
		// then we redirect to the "can't detect" page
		strRedirectURL = pstrCantTellURL; 
	}

	blnNeedVB	= ((strApp == "Microsoft Internet Explorer") && (strVrs.indexOf("Win") > -1));
	//alert("Need VB = " + blnNeedVB);
	// If this is Internet Explorer and we are on a PC
	if (blnNeedVB){
		// then we need VB Script detection
		strURL = "vbscr_" + pstrPluginEnabled;
		strRedirectURL = strURL; 
	}

	// If we don't need VB and there is plugin detection
	if ((!blnNoDetect) && (!blnNeedVB)){
		// use javascript test
		blnFound =  DetectPlugin(strPlugin);
		//alert("Found via JavaScript = " + blnFound);
		// assign the appropriate URL to recirect to
		if (blnFound){
			strRedirectURL = pstrPluginEnabled;
		} else {
			strRedirectURL = pstrNoPlugin;
		}	
	} 
	return strRedirectURL;
}
