// We return the major version number or 0 if not installed.
function pdf_check() {
	var acrobat=new Object();
	acrobat.installed = false;
	acrobat.version = 0;
	var temp_version = 0;

	if(navigator.plugins && navigator.plugins.length) {
		for(x = 0; x < navigator.plugins.length; x++) {
			if(navigator.plugins[x].description.indexOf('Adobe PDF Plug-In') != -1) {
				acrobat.installed = true;
				acrobat.version = 8;
			}
			else if(navigator.plugins[x].description.indexOf('Adobe Acrobat') != -1) {
				temp_version = parseFloat(navigator.plugins[x].description.split('Version ')[1]);
				temp_version = parseInt(temp_version); // We only need the major version number
				// Instead of breaking, we loop through all versions and detect the maximum.
				// For some reason it's been detecting the wrong version if someone still has old
				// ones sitting around on their system.  Looping backwards didn't help.
				if(temp_version > acrobat.version) {
					acrobat_version = temp_version;
				}
				acrobat.installed = true;
			}
		}
	}
	else if(window.ActiveXObject) {
		var control = null;  
		try {
			// AcroPDF.PDF is used by version 7 and later
			control = new ActiveXObject('AcroPDF.PDF');
		} catch (e) {
			// Do nothing
		}
		if (!control) {
			try {
			// PDF.PdfCtrl is used by version 6 and earlier
			control = new ActiveXObject('PDF.PdfCtrl');
			} catch (e) {
				return;
			}
		}
		if (control) {
			isInstalled = true;
			version = control.GetVersions().split(',');
			version = version[0].split('=');
			acrobat.version = parseInt(version[1]); // I only want the major version.
		}
	}
	return acrobat.version;
}

