var acrobat = new Object();

acrobat.installed = false;
acrobat.canDetect = false;
acrobat.version = "0.0";

var pluginObj = null;

try
{
	acrobat.canDetect = (navigator.userAgent.indexOf("Windows NT 6.0") == -1);
}
catch (e)
{
	acrobat.canDetect = true;
}

if (acrobat.canDetect)
{
	try
	{
		// -- Try to get a Plugin object from the plugins array
		if (navigator.plugins && navigator.plugins.length)
		{
			if (navigator.plugins['Adobe Acrobat'] != null)
				pluginObj = navigator.plugins['Adobe Acrobat'];
		}

		// -- If we didn't get one, try the mimeTypes array
		if (pluginObj == null && navigator.mimeTypes && navigator.mimeTypes.length)
		{
			// -- This will get us a null if the mimeType object is disabled, but a Plugin object if it is found and enabled
			if (navigator.mimeTypes['application/pdf'] != null)
				pluginObj = navigator.mimeTypes['application/pdf'].enabledPlugin;
		}
	}
	catch (e)
	{
		pluginObj = null;
	}

	// -- If we found a plugin object this way, get it's properties
	if (pluginObj != null)
	{
		// -- Make sure it's an acrobat plugin - if it's a third-party reader, we can't parse anything about it
		if (pluginObj.description.indexOf("Adobe Acrobat") != -1 || pluginObj.description.indexOf("Adobe PDF") != -1)
		{
			// -- If the description contains a version number, parse that out
			if (pluginObj.description.indexOf("Version ") != -1)
			{
				acrobat.version=parseFloat(navigator.plugins[x].description.split("Version ")[1]);
				if (acrobat.version.toString().length == 1) acrobat.version += ".0";
			}

			// -- If the description doesn't have a version number, says and Adobe PDF instead of Adobe Acrobat, it must be 8.0 or later
			else if (pluginObj.description.indexOf("Adobe PDF") != -1)
				acrobat.version = "8.0";

			// -- Worst case, we found it, so it must be 4.0 or later
			else
				acrobat.version = "4.0";

			acrobat.installed = true;
		}
	}

	// -- If we have ActiveX, then we don't have navigator.plugins, so this is the alternative code (for IE)
	if (window.ActiveXObject)
	{
		// -- Acrobat 4.0 through 6.0 used this control, so if we have it then we at least have 4.0
		try
		{
			oAcro4 = new ActiveXObject("PDF.PdfCtrl.1");
			if (oAcro4)
			{
				acrobat.installed = true;
				acrobat.version = "4.0";
			}
		}
		catch(e) { }

		// -- In 7.0, they changed to this control name.  If we have this control name, then we have at least 7.0
		try
		{
			oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
			if (oAcro7)
			{
				acrobat.installed = true;
				acrobat.version = "7.0";
			}
		}
		catch(e) { }
	}
}

