<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Adobe Installer</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="media/css/styles.css" rel="stylesheet" type="text/css" media="all">
			<link href="media/css/alert.css" rel="stylesheet" type="text/css" media="all">

		<!-- IE specific overrides -->
		<!--[if IE]>
	        <link href="media/css/styles_win.css" rel="stylesheet" type="text/css" media="all" />
		<![endif]-->

				<script language="JavaScript" src="common/scripts/ContainerProxy.js" type="text/javascript"></script>
				<script language="JavaScript" src="common/scripts/utils.js" type="text/javascript"></script>
				<script language="JavaScript" src="common/scripts/localization.js" type="text/javascript"></script>
				<script language="JavaScript" src="scripts/WizardAlert1.js" type="text/javascript"></script>
				<script language="JavaScript" src="scripts/WizardAccessibilityManager1.js" type="text/javascript"></script>
				<script language="JavaScript" type="text/javascript">
			/** Body ID of bootstrapper body test */
			var _k_bootstrapperBodyID = "bootstrapperBody";
			/** DIV ID of main page container into which all other pages are inserted */
			var _k_mainPageContainerID = "bootstrap";
			/** DIV ID of progress bar for resource loading */
			var _k_progressBarID = 'progressBarMid';
			var _k_bodyID = "bootstrapperBody";
			/** Has the page load already been called? */
			var _gPageLoadCalled = null;
            var _gBootstrapPerc = 90;
            var _gProgressAnounceTime = 0;
            var _gWAM = null;
			/*
			Initial logic to handle the bootstrapping/localization/and progress indicator of bootstrap
			if we need to do so.
			Workflow:
				- On startup, initialize the session
				- Does Ahmbed need to be bootstrapped?
					- If so, bootstrap it here and handle the progress
					- If not, forward execution to the Ahmbed application that's resident on the machine
			*/


			var container = null;
			var localizationStub = null;
			var _g_pollIntervalName = null;
			var gWorkflowStarted = false;
			var standardAlerts = null;

			function onWizardLoad()
			{
				setTimeout(onWizardLoadReal, 1);
			}

			function onWizardLoadReal()
			{
				if (gWorkflowStarted)
					return;
				container = new ContainerProxy();
				container.systemInfo = container.GetSystemInfo();
				var retVal = null;
				try
				{
					if (!_gPageLoadCalled && container.UIHosted())
 					{
						gWorkflowStarted = true;
						// Test for credentials and only try to install
						// if we're good
						var bootstrapperBody = document.getElementById(_k_bootstrapperBodyID);

						// Get the loading page size and set the window size to that
						var pageContainer = document.getElementById(_k_mainPageContainerID);
						if (pageContainer)
						{
							var defaultProperties = container.GetDefaultProperties();
							var platformName = defaultProperties["platform"];
							var xmlPath = _concatPaths([container.GetResourcesPath(), 'main.xml'], platformName);

							localizationStub = new Localization(container, xmlPath, defaultProperties, false);
							container.localization = localizationStub;  // so WizardAlert can grab the localization object.
							if (localizationStub)
								localizationStub.LocalizeDOM(bootstrapperBody);

							// Create the pool we can fish standard alerts from.
							standardAlerts = new StandardAlert(container, localizationStub);

							container.UISetCloseBoxEnabled(0);

							// Test for user credentials
							var userCredentials = container.GetUserInfo();
							var isValid = (null != userCredentials);
							if (userCredentials && userCredentials.hasCredentials)
								isValid = (1 == userCredentials.hasCredentials) ? true : false;

							if (!isValid)
							{
								container.UIExitDialog(standardAlerts.InvalidUserCredentials());
								return;
							}

							// Test for single instance
							if (container.IsSetupLocked() ||
								container.IsBootstrapperLocked() ||
								!container.AcquireBootstrapperLock())
							{
								container.UIExitDialog(standardAlerts.SetupAlreadyRunning());
							}

							if (container.IsOSUpdaterRunning()) {
								var WA = standardAlerts.WindowsUpdateRunning();
								if (WA.returnValue=="1") {
									container.UIExitDialog(WA.returnValue);
									return;
								}
							}
							if (container.IsCAPSDBLocked()) {
								container.UIExitDialog(standardAlerts.CAPSDBLocked());
								return;
							}


							// If we're ok, then start up
							if (isValid)
							{
								if (localizationStub)
									container.UISetWindowTitle(localizationStub.GetString("locProductNameInstall", "[productName] Installer: [pageTitle]", { pageTitle: localizationStub.GetString("locInitializing", "Initializing") }));

								container.UIResizeWindow(document.getElementById(_k_bodyID).clientWidth, document.getElementById(_k_bodyID).clientHeight);
								container.UIShowWindow(1);
								pageContainer.style.visibility = 'visible';
								container.UIShowWindow(1);
								if (container.systemInfo.Windows) {
									_gWAM = new WizardAccessibilityManager1(container.IsJawsRunning());
									_gWAM.AddElement({element:document.getElementById("progressBarGroup"),virtualtype:'ReadableText',jawslabel:'Overall progress.'});
									_gProgressAnounceTime = GetCurrentTime();
								}
								// Startup
								retVal = container.InstallBootstrapper("install");
								if (null == retVal || retVal.success != 1)
								{
									container.UIExitDialog();
								}
								_g_pollIntervalName = setInterval('pollBootstrapStatus()', 250);

							}
						}
						else
						{
							throw "malformed bootstrapper UI";
						}

						// Either way the page was loaded
						_gPageLoadCalled = true;
					}
				}
				catch (error)
				{
					alert("Exception: " + error);
					container.UIExitDialog();
				}
			}

			// DARK entry point
			function onPublisherRegistered()
			{
				onWizardLoad();
			}

			function AnnounceJAWSProgressMessage(oldAltTotalProgress, newAltTotalProgress)
			{
				var E = document.getElementById("progressBarGroup");
				if (E.WizardAccessibilityManager) {
					var currentTime = GetCurrentTime();
					// Anounce Progress bar percent complete if parcent has been updated and 3 seconds has been passed to give JAWS time to speak
					var announceJAWSMessage = (oldAltTotalProgress != newAltTotalProgress) && (currentTime - _gProgressAnounceTime) > 3000;

					if (announceJAWSMessage) {
						E.jawslabel = "Initializing progress " + newAltTotalProgress;
						E.WizardAccessibilityManager.ExtraForceAnnounceJawsMessage(E);
						_gProgressAnounceTime = currentTime; // Update anounce time
					}
				}
			}

			function pollSystemCheckStatus()
			{
				var iCurrentProgressObj = container.GetSystemCheckStatus();
				iCurrentProgress = iCurrentProgressObj.percentComplete;
				var progressBarNode = document.getElementById(_k_progressBarID);
				var progressBarStyle = progressBarNode.style;
				if (iCurrentProgress)
				{
					if (iCurrentProgress != 0)
					{
						var newWidth =  (_gBootstrapPerc + iCurrentProgress * (1-_gBootstrapPerc/100 )).toString() + "%";
						progressBarStyle.width = newWidth;
						//progressBarNode.alt = newWidth;
						var oldAltTotalProgress = progressBarNode.alt;
						progressBarNode.alt = parseInt(newWidth).toString()+"%";
						var newAltTotalProgress = progressBarNode.alt;
						AnnounceJAWSProgressMessage(oldAltTotalProgress, newAltTotalProgress);
					}

					if (iCurrentProgress >= 100)
					{
						container.UISetCloseBoxEnabled(1);
						clearInterval(_g_pollIntervalName);

						var newWidth =  "100%"
						progressBarStyle.width = newWidth;
						//progressBarNode.alt = newWidth;
						progressBarNode.alt = parseInt(newWidth).toString()+"%";

						container.UIExitDialog();
					}
				}
			}

			function pollBootstrapStatus()
			{
				var iCurrentProgressObj = container.GetInstallStatus();
				iCurrentProgress = iCurrentProgressObj.percentComplete;
				var progressBarNode = document.getElementById(_k_progressBarID);
				var progressBarStyle = progressBarNode.style;
				if (iCurrentProgress)
				{
					if (iCurrentProgress != 0)
					{
						var newWidth =  (iCurrentProgress * _gBootstrapPerc/100).toString() + "%";
						progressBarStyle.width = newWidth;
						//progressBarNode.alt = newWidth;
						var oldAltTotalProgress = progressBarNode.alt;
						progressBarNode.alt = parseInt(newWidth).toString()+"%";
						var newAltTotalProgress = progressBarNode.alt;
						AnnounceJAWSProgressMessage(oldAltTotalProgress, newAltTotalProgress);
					}

					if (iCurrentProgressObj.isRunning &&
						iCurrentProgressObj.isRunning != 1 &&
						iCurrentProgress >= 100)
					{
						//container.UISetCloseBoxEnabled(1);
						clearInterval(_g_pollIntervalName);

						container.LogError(iCurrentProgressObj);

						var newWidth =  _gBootstrapPerc + "%";
						progressBarStyle.width = newWidth;
						//progressBarNode.alt = newWidth;
						progressBarNode.alt = parseInt(newWidth).toString()+"%";
						
						// If there is an error we need to reformulate the bootstrapper object
						// to display the error and then exit
						if (iCurrentProgressObj.message &&
							iCurrentProgressObj.message.code &&
							(0!=iCurrentProgressObj.message.code))
						{
							container.LogError("Bootstrapper failed to install");
							container.LogError(iCurrentProgressObj);
							if (standardAlerts)
							{
								container.UIExitDialog(standardAlerts.BootstrapInstallFailure(iCurrentProgressObj.message.code, iCurrentProgressObj.message.args));
							}
						}
						else
						{
							// We only want to auto exit if there wasn't an error, since otherwise
							// we're going to force the user to dismiss the dialog
							_g_pollIntervalName = setInterval('pollSystemCheckStatus()', 50);
						}
					}
				}
			}
				</script>
	</head>
	<body onload="onWizardLoad()" id="bootstrapperBody">
		<form id="bootstrapForm" method="post" action="" onsubmit="return false;">
			<div id="content" class="content">
				<DIV class="progress" id="bootstrap">
					<p id="progressBarGroup">
						<img id="progressBarLeft" src="media/img/progbar_blue.png" alt="" height="0"> <img id="progressBarMid" src="media/img/progbar_blue.png" alt="0%" style="WIDTH: 0%">
					</p>
					<p id="main_pageSubTitle" locid="main_pageSubTitle">Checking System Profile...</p>
				</DIV>
			</div>
		</form>
	</body>
</html>
