//GLOBAL OBJECTS / VARIABLES
//object:objAgent, location:/js/getAgent.js

//global variables and parameters
var quickTimePluginRequired = 6;		//required verison 6.0
var quickTimePluginName = false;		//name
var quickTimePluginDescription = false;	//description
var quickTimePluginFileName = false;	//name of file
var quickTimePluginVersion = false;		//verion
var quickTimePluginInstalled = false;	//installed
var quickTimePluginEnabled = false;		//enabled

var bQuickTimePlugins = (navigator.plugins) ? true : false; //detect plugins Array
var bQuickTimeMimeTypes = (navigator.mimeTypes) ? true : false; //detect mimetypes Array
var bQuickTimeVB = ((objClient.platform == "win") && (objClient.application == "ie") && (!(objClient.applicationMinor == "op"))) ? true : false; //detect vb script use for MS IE windows and exclude opera

//Create the object
var objQuickTime = new objQuickTime();

function objQuickTime() {
	this.pluginRequired = quickTimePluginRequired; //add param to object
	//	loop throgh the plugins array (if supported)
	if ((bQuickTimePlugins) && (!(bQuickTimeVB))) {
		for (i = 0; i < navigator.plugins.length; i ++) {
			// if the plugin is found then collect the details
			if (navigator.plugins[i].name.indexOf("QuickTime") != -1) {
				quickTimePluginName = navigator.plugins[i].name;
				quickTimePluginDescription = navigator.plugins[i].description;
				quickTimePluginFileName = navigator.plugins[i].filename;
				quickTimePluginVersion = parseInt(quickTimePluginDescription.charAt(quickTimePluginDescription.indexOf(".") -1));
				if(isNaN(quickTimePluginVersion)) { //if the description does not contain the version check the name (mac)
					quickTimePluginVersion = parseInt(quickTimePluginName.charAt(quickTimePluginName.indexOf(".") -1));
				}
				if((isNaN(quickTimePluginVersion)) && (objBrowser.bMacSA)) { //safari exception NaN built in
					quickTimePluginVersion = quickTimePluginRequired;
				}
				quickTimePluginInstalled = true;
				quickTimePluginEnabled = true;
				if(quickTimePluginVersion >= quickTimePluginRequired) {
					break;
				}
			}
		}
	}

	//	loop throgh the mimetypes array (if supported and the above condition fails
	else if ((!(bQuickTimePlugins)) && (bQuickTimeMimeTypes) && (!(bQuickTimeVB))) {
		for (i = 0; i < navigator.mimeTypes.length; i ++) {
			// if the plugin is found then collect the details
			if (navigator.mimeTypes['video/quicktime'] && navigator.mimeTypes['video/quicktime'].enabledPlugin) {
				quickTimePluginName = navigator.mimeTypes[i].name;
				quickTimePluginDescription = navigator.mimeTypes[i].description;
				quickTimePluginEnabled = (navigator.mimeTypes[i].enabledPlugin) ? true : false;
				quickTimePluginInstalled = true;
				break;
			}
		}
	}

	//if neither collection is present and the browser is not win ie we cant detect it
	else if ((!(bQuickTimePlugins && bQuickTimeMimeTypes)) && (!(bQuickTimeVB))) {
		 quickTimePluginVersion = "unknown";
	}

	//use VB for browsers that do not support the plugins object or the mimetypes array
	else {
		checkQuickTimeVB();
	}

	//ok were done lets add what we know to our custom object
	this.pluginName = quickTimePluginName;
	this.pluginDescription = quickTimePluginDescription;
	this.pluginFileName = quickTimePluginFileName;
	this.pluginVersion = quickTimePluginVersion;
	this.pluginInstalled = quickTimePluginInstalled;
	this.pluginEnabled = quickTimePluginEnabled;
}

function checkQuickTimeVB() {
	document.write('<script language="VBScript"\> \n');
	document.write('on error resume next \n');
	document.write('dim obQuicktime \n');
	document.write('set obQuicktime = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
	document.write('if IsObject(obQuicktime) then \n');
	document.write('   if obQuicktime.IsQuickTimeAvailable(0) then \n');
	document.write('      quickTimePluginVersion = CInt(Hex(obQuicktime.QuickTimeVersion) / 1000000) \n');
	document.write('   end if \n');
	document.write('end if \n');
	document.write('</script\> \n');
}