/* CHECK FOR QT ACTIVE X AND SCREENSIZE v1b1*/

pluginFound      = false     // Determines if the latest version of the plugin is installed
activeXFound     = false     // Determines if the latest version of the ActiveX is installed

quickTimeSupportedVersion = 5   // Supported version for QuickTime plugin only
latestQuickTimeVersion    = 6   // Latest QuickTime version available


// If this Microsoft Internet Explorer 4.5 for Macintosh, plugins detection is impossible
plgIe4Mac = false
if (navigator.appVersion.indexOf("PPC")!=-1 && navigator.userAgent.indexOf("MSIE 4")!=-1) {plgIe4Mac = true}

// Check if it's an IE Windows Browser
plgIeWin = false
if ( (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1) ) {plgIeWin = true}


function getQuickTime(requiredVersion) {

	// If IE4 Mac, plugins can't be detected
	if(plgIe4Mac) {return false}

	// User version overrides default version
	if (typeof(requiredVersion)!="undefined") {quickTimeSupportedVersion = requiredVersion}

	// Make sure it's a string
	quickTimeSupportedVersion+=""
	
	// Check if the supported version of the plugin or upper is installed
	plugInFound = false
	
	// Check if the lastest version of the plugin is supported
	checkedVersion  = quickTimeSupportedVersion
	isLatestVersion = checkedVersion == latestQuickTimeVersion

	while (!plugInFound) {
		
		plugInFound = getPlugIn("QuickTime",checkedVersion)
			
		// If we've just checked the lastest existing plugin version, drop the search
		if (isLatestVersion) {break}
		
		// If we've just checked an old version, search for a newer plugin
		if (!isLatestVersion) {
			checkedVersion++
			isLatestVersion = checkedVersion == latestQuickTimeVersion
		}
	}
	
	if (plgIeWin) {

		// Check if the QuickTime ActiveX is installed
		try {
			testObject = new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck.1")

			// Can only check if QuickTime ActiveX is available or not
			activeXFound = testObject.IsQuickTimeAvailable(0)
			
		} catch(e) {
			activeXFound = false
		}
	}

	if (plugInFound || activeXFound) {return true} else {return false}
	
}

// Parse plugins collection with strings to find
// User has to pass strings to be found in plugin name and description
// Ex. "Shockwave","Flash","5"
function getPlugIn() {


	// search for the right plugin among all those have been installed
	allFound = false
    plugInsCollection = navigator.plugins
	
	for (i=0;i<plugInsCollection.length;i++) {

		// Get plugin description
        plugInDescription = " " + plugInsCollection[i].description
		plugInName = " " + plugInsCollection[i].name
	
		for (j=0;j<arguments.length;j++) {
		
			if (plugInDescription.indexOf(" " + arguments[j])!=-1 || plugInName.indexOf(" " + arguments[j])!=-1) {
				allFound = true
			} else {
				allFound = false
				break
			}
		}
		
		// Send back the search result
		if (allFound) {return true}
    }

	// Send back the search result
	return false
}

