/*!
**********************************************************************
@file Finish.js

Copyright 2003-2006 Adobe Systems Incorporated.                     
All Rights Reserved.                                                
                                                                    
NOTICE: All information contained herein is the property of Adobe   
Systems Incorporated.                                                                                                                    

***********************************************************************
*/

function Finish_wp(inController)
{
	this.SetController(inController);
	this.restartNeeded = false;
	this.bForceDisplayThanks = false;
	this.moreInforContainer = null;
	this.WAMElementSet = new Array();
}

Finish_wp.prototype = new WizardPage("Finish");

Finish_wp.prototype.GetPageTitleDisplayName = function()
{
	return this.localization.GetString("locTitle", "Done");
}

Finish_wp.prototype.GetNavDisplayName = function()
{
	return this.localization.GetString("locNavTitle", "Finish");
}

Finish_wp.prototype.onResourcesLoaded = function()
{
	this.RenderInitialWizardImagesOfPage();
}

Finish_wp.prototype.RenderInitialWizardImagesOfPage = function()
{
	var icon_PP_FailedContainer = new WizardImage1(kImgIconCriticalLarge, "icon_PP_Failed", "finishScreenIcon", this.getElementById("icon_PP_FailedContainer"));
	var icon_Suite_Failed = new WizardImage1(kImgIconCriticalLarge, "icon_Suite_Failed", "finishScreenIcon", this.getElementById("icon_Suite_FailedContainer"));
	var icon_PP_DoneWithErrors = new WizardImage1(kImgIconWarningLarge, "icon_PP_DoneWithErrors", "finishScreenIcon", this.getElementById("icon_PP_DoneWithErrorsContainer"));
	var icon_Suite_DoneWithErrors1 = new WizardImage1(kImgIconCriticalLarge, "icon_Suite_DoneWithErrors1", "finishScreenIcon", this.getElementById("icon_Suite_DoneWithErrors1Container"));
	var icon_Suite_DoneWithErrors2 = new WizardImage1(kImgIconWarningLarge, "icon_Suite_DoneWithErrors2", "finishScreenIcon", this.getElementById("icon_Suite_DoneWithErrors2Container"));
}

Finish_wp.prototype.FillButtonArea = function()
{
	var buttonarea = document.getElementById("navButtons");
	var thisPage = this;

	if (this.nextWB) {
		delete this.nextWB;
		this.nextWB = null;
	}
    //The installer has succeeded partially. Need to show registration
	if(this.doneWithErrors && !this.bForceDisplayThanks)
	{
		this.quitWB = new WizardButton1(8, "c", this.wizardControl.session.localization.GetString("locBtnQuit", "Quit"), 
		    "128px", "32px", "258px", "16px", "bigbutton_normalsize", buttonarea, function(){thisPage.wizardControl.NavQuit();});
		
		this.nextWB = new WizardButton1(9, "n", this.wizardControl.session.localization.GetString("locBtnNext", "Next"), 
		    "128px", "32px", "400px", "16px", "bigbutton_normalsize", buttonarea, function(){thisPage.wizardControl.NavNext();});

		this.quitWB.GetDisplayElement().laterhotkey = 'Q';
	}
	else if(this.totalFailure)
	{
		this.quitWB = new WizardButton1(8, "c", this.wizardControl.session.localization.GetString("locBtnQuit", "Quit"), 
		    "128px", "32px", "331px", "16px", "bigbutton_normalsize", buttonarea, function(){thisPage.wizardControl.NavQuit();});
		this.quitWB.GetDisplayElement().laterhotkey = 'Q';
	}
	else
	{
		this.quitWB = new WizardButton1(8, "c", this.wizardControl.session.localization.GetString("locexitbtn", "Exit"), 
		    "128px", "32px", "331px", "16px", "bigbutton_normalsize", buttonarea, function(){thisPage.wizardControl.NavQuit();});
		this.quitWB.GetDisplayElement().laterhotkey = 'E';
	}
	if (this.moreInforContainer) {
		var moreinformationWB = new WizardButton1(10, "m", this.localization.GetString("locMoreInformation", "More Information"),
				"140px", "22px", "120px", "245px", "smallbutton_extralong", this.moreInforContainer, function(){thisPage.onMoreInformation();});
		moreinformationWB.GetDisplayElement().style.position="relative";
		moreinformationWB.SetPos("50px", "20px");
		this.moreinformationWB = moreinformationWB;
	}
}

Finish_wp.prototype.CreateWAMPage = function()
{
	if (this.wizardControl.WAM)
	{
		var defElement = this.quitWB.GetDisplayElement();
		this.wizardControl.WAM.AddElementSet	([
							//{element:_,hotkey:_,focal:_,nofocal:_,type:_},
							{element:this.getElementById("installCompleteSuccess_PP"),virtualtype:'ReadableText'},
							{element:this.getElementById("installCompleteSuccess_Suite"),virtualtype:'ReadableText'},
							
							{element:this.getElementById("installCompleteFailure_PP_placeholder_content_column1"),virtualtype:'ReadableText'},
							{element:this.getElementById("installCompleteFailure_PP_placeholder_content_column2"),virtualtype:'ReadableText'},
							
							{element:this.getElementById("installCompleteFailure_SuiteCol1"),virtualtype:'ReadableText'},
							{element:this.getElementById("installCompleteFailure_SuiteCol2"),virtualtype:'ReadableText'},
							
							{element:this.getElementById("installCompleteDoneWithErrors_PPCol1"),virtualtype:'ReadableText'},
							{element:this.getElementById("installCompleteDoneWithErrors_PPCol2"),virtualtype:'ReadableText'},
							
							{element:this.getElementById("installCompleteDoneWithErrors_Suite_col1"),virtualtype:'ReadableText'},
							{element:this.getElementById("completelyFailedProductsOuterDiv"),virtualtype:'ReadableText'},
							{element:this.getElementById("partiallyFailedProductsOuterDiv"),virtualtype:'ReadableText'}
						]);
		this.wizardControl.WAM.AddElementSet(this.WAMElementSet);
		this.wizardControl.WAM.AddElement({element:defElement,hotkey:defElement.laterhotkey,virtualtype:'WizardButton1'});
		if (this.nextWB) {
			defElement = this.nextWB.GetDisplayElement();
			this.wizardControl.WAM.AddElement({element:defElement,hotkey:'N',virtualtype:'WizardButton1'})
		}
		if (this.moreinformationWB)
			this.wizardControl.WAM.AddElement({element:this.moreinformationWB.GetDisplayElement(),hotkey:'M',virtualtype:'WizardButton1'})
		this.wizardControl.WAM.SetPageDefaultEnterElement(defElement);
		if (this.WAMElementDefFocusElement)
			this.wizardControl.WAM.SetPageDefaultFocusElement(this.WAMElementDefFocusElement);
		else
			this.wizardControl.WAM.SetPageDefaultFocusElement(defElement);
		this.wizardControl.WAM.SetFocusOnDefaultElement();
	}
}

Finish_wp.prototype.onShow = function()
{
	var thisCB = this;
	
	this.ClearButtonArea();
	this.moreInforContainer = document.getElementById("navButtons");

	this.setWindowTitle();
	
	this.wizardControl.session.UISetCloseBoxEnabled(1);	
	
	var kCompleteSuccessDivID = "installCompleteSuccess";
	var kCompleteFailureDivID = "installCompleteFailure";
	var kDoneWithErrorsDivID = "installCompleteDoneWithErrors";
	var kRecordModeContentDivID =  "recordModeContent";

	var kPPCompleteSuccessDivID = "installCompleteSuccess_PP";
	var kPPCompleteFailureDivID = "installCompleteFailure_PP";
	var kPPDoneWithErrorsDivID = "installCompleteDoneWithErrors_PP";
	
	var kSuiteCompleteSuccessDivID = "installCompleteSuccess_Suite";
	var kSuiteCompleteFailureDivID = "installCompleteFailure_Suite";
	var kSuiteDoneWithErrorsDivID = "installCompleteDoneWithErrors_Suite";
	
	var allInstallCompleteTypes = new Array(kCompleteSuccessDivID, kCompleteFailureDivID, kDoneWithErrorsDivID);

	var successCompleteTypes = new Array(kPPCompleteSuccessDivID, kSuiteCompleteSuccessDivID);
	var failureCompleteTypes = new Array(kPPCompleteFailureDivID, kSuiteCompleteFailureDivID);
	var doneWithErrorsCompleteTypes = new Array(kPPDoneWithErrorsDivID, kSuiteDoneWithErrorsDivID);

	// If we are in record mode, just collect the payload selections, save the result and be done.
	if (this.wizardControl.session.IsRecordMode())
	{
		var payloadDict = new Object();
		var recommendDict = new Object();
		var topLevelPayloads = new Array();
		var recordId = this.getElementById("recordModeContent");
		var allDivs = new Array(kCompleteSuccessDivID, kCompleteFailureDivID, kDoneWithErrorsDivID,kRecordModeContentDivID);
		for (var payloadAdobeCode in this.wizardControl.session.sessionPayloads)
		{
			var payload = this.wizardControl.session.sessionPayloads[payloadAdobeCode];
			var policy = payload.policyNode.GetUIPolicy();
			var satisfiedLength = payload.GetSatisfiedArray().length;
			if (!payload.policyNode.IsProtected(payloadAdobeCode) && (payload.IsDriverForSession(this.wizardControl.session) || satisfiedLength == 0))
			{
			      topLevelPayloads.push(payloadAdobeCode);
			}
			else if (policy.visible && policy.selectable && (policy.checkedState == false) && satisfiedLength > 0)
			{
				recommendDict[payloadAdobeCode] = 1;
			}
		}
		for (var index in topLevelPayloads)
		{
			// Record only the driver and visible and checked payloads.
			var payloadAdobeCode = topLevelPayloads[index];
			var payload = this.wizardControl.session.sessionPayloads[payloadAdobeCode];
			var policy = payload.policyNode.GetUIPolicy();
			if ((policy.visible && policy.checkedState) || payload.IsDriverForSession(this.wizardControl.session))
			{
				payloadDict[payloadAdobeCode] = 1;
			}
			depends = payload.GetDependentsArray();
			for ( var i = 0 ; i < depends.length ; i++)
			{
				var depPolicy = depends[i].policyNode.GetUIPolicy();
				if ((depPolicy.visible && depPolicy.checkedState))
				{
					payloadDict[depends[i].GetAdobeCode()] = 1;
				}
			}
		}

		var results = this.wizardControl.session.SaveDeploymentFiles(this.wizardControl.session.properties, payloadDict, recommendDict);
		this.wizardControl.session.LogInfo("Results of saving deployment files");
		this.wizardControl.session.LogInfo(results);
		
		// Show the user the results
		if (results && (results.installFile || results.removeFile))
		{
			var titleText= this.wizardControl.session.localization.GetString("locrecordTitle", "Saved deployment files");
			this.AddTitle(titleText, recordId);


			if (results && results.installFile)
			{
				var p = this.AppendTextElement("p", "", recordId);
				this.AppendTextElement("strong", "Install: ", p);
				this.AppendTextElement("span", results.installFile, p);
			}

			if (results && results.removeFile)
			{
				var p = this.AppendTextElement("p", "", recordId);
				this.AppendTextElement("strong", "Remove: ", p);
				this.AppendTextElement("span", results.removeFile, p);
			}
		}
		else
		{
			this.AppendTextElement("h4", "Error saving deployment files", "recordModeContent");
		}
        this.makeElementVisibleInList(kRecordModeContentDivID, allDivs);
		this.moreInforContainer = null;
		this.FillButtonArea();
		// Short circuit return right here!
		return;
	}
	
	// Get the scoop on the payloads.
	this.allPayloads = GetPayloadListByOperationResult(this.wizardControl.session);
	var allPayloads = this.allPayloads;

	// Do we need a restart to keep anyone happy?
	if (true == this.restartNeeded || this.wizardControl.session.IsRestartNeeded())
	{
		this.restartNeeded = true; 

		var buttonTextMap = {
			Restart: this.localization.GetString("locFinishAndRestartButton", "Finish & Restart"),
			Finish: this.localization.GetString("locNextButton", "Finish")
		}
		this.errorbox.AddError("Finish.restart", "warning", 
			this.localization.GetString("locFinishRestartWarningMessage", "Restarting your computer is recommended.  Click '[Restart]' to exit the install and restart or click '[Finish]' to exit immediately.", buttonTextMap));

		// Log the restart info for secondary use
		gSession.LogInfo(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");		
		gSession.LogInfo("Restarting your computer is recommended:");
		gSession.LogInfo("In order to Finish the installation, please restart the computer");
		gSession.LogInfo(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
	}
	
	// Total success case
	if (allPayloads.driverFailure == false
		&& allPayloads["fail"].visibleList.length == 0
		&& allPayloads["fail"].hiddenList.length == 0
		&& allPayloads["partialPass"].visibleList.length == 0
		&& allPayloads["partialPass"].hiddenList.length == 0
		|| this.bForceDisplayThanks)
	{
		this.makeElementVisibleInList(kCompleteSuccessDivID, allInstallCompleteTypes);
		this.moreInforContainer = null;
		var set = allPayloads["pass"];
		var thisSession = this.wizardControl.session;

		// Suite success case
		if(gSession.IsSuiteMode())
		{
			thisCB.makeElementVisibleInList(kSuiteCompleteSuccessDivID, successCompleteTypes);
			
			var componentList = this.getElementById("installFinishSuiteSuccessScrollPort");

			if ((!set.visibleList || set.visibleList.length == 0)
					&& (!allPayloads["partialPass"].visibleList || allPayloads["partialPass"].visibleList.length == 0)) {
				componentList.style.display="none";
				this.getElementById("success_suite_extratext").style.display="none";
			}
			// Show the per-payload results.
			else if ((set.visibleList && set.visibleList.length > 0) || (set.hiddenList && set.hiddenList.length > 0)
					|| (allPayloads["partialPass"].visibleList.length > 0))
			{
				// Setup the section header and list
				var componentCount = set.visibleList.length;
				if (set.hiddenList.length > 0)
					componentCount++;
				
				var componentTable = document.createElement("table");
				componentList.appendChild(componentTable);
				
				var componentTableBody = document.createElement("tbody");
				componentTable.appendChild(componentTableBody);
				
				var num_rows = parseInt(Math.ceil((set.visibleList.length)/2));
				var trs = new Object;
				var isLeftComponent = true;
				var visibleSets = new Array(allPayloads["pass"], allPayloads["partialPass"]);
				var index;

				// List out the visible payloads
				for (index in visibleSets) {
					set = visibleSets[index];
					for (var i = 0; i < set.visibleList.length; i++)
					{
						var name = set.visibleList[i].payloadName;
						var icon = set.visibleList[i].payloadIcon;

						// Skip those payloads not having producticon
						if (icon == null) {
							continue;
						}
						// Create a table row only if we are starting a new row
						if((i % 2) == 0)
						{
							trs[i / 2] = document.createElement("tr");
							componentTableBody.appendChild(trs[i / 2]);
							isLeftComponent = true;
						}
						else
						{
							isLeftComponent = false;
						}
						
						var td = document.createElement("td");
						td.className = "td_finish_product_success";
						var mydata=this.wizardControl;
						//td.thisSet_plp = set.visibleList[i].payloadLaunchPath;
						//td.thisSet_pla = set.visibleList[i].payloadLaunchArguments;
						td.thisSet_pac = set.visibleList[i].payloadAdobeCode;
						td.thisSet_pna = set.visibleList[i].payloadName;
						/*
						td.onclick = function()
						{
							thisSession.RunApplication(
								this.thisSet_pac, this.thisSet_plp, this.thisSet_pla
							);
							mydata.NavQuit();
						};
						*/
						// Left side td
						if(isLeftComponent)
						{
							trs[i / 2].appendChild(td);
						}
						// Right side td
						else
						{
							trs[(i - 1)/ 2].appendChild(td);
						}
						
						// Create another inner table so we can align the icon and name properly
						var finishProductTable = document.createElement("table");
						td.appendChild(finishProductTable);
						
						var finishProductTableBody = document.createElement("tbody");
						finishProductTable.appendChild(finishProductTableBody);
						
						var finishProductTr = document.createElement("tr");
						finishProductTableBody.appendChild(finishProductTr);
						
						var finishProductIconTd = document.createElement("td");
						finishProductIconTd.className = "td_finish_product_icon";
						finishProductTr.appendChild(finishProductIconTd);
						
						var finishProductNameTd = document.createElement("td");
						finishProductNameTd.className = "td_finish_name_icon";
						finishProductTr.appendChild(finishProductNameTd);
						
						var productIconImg = new WizardImage1(icon, "", "productimageicon", finishProductIconTd);
						
						var nameSpanElement = document.createElement("span");
						nameSpanElement.className = "productnametext";
						nameSpanElement.innerHTML = name;
						finishProductNameTd.appendChild(nameSpanElement);
						finishProductTable.uel=nameSpanElement;
						
						/*
						finishProductTable.onmouseover = function()
						{
							this.uel.style["text-decoration"]="underline";
							this.uel.style.textDecoration="underline";
							this.style.cursor="hand";
							this.style.cursor="pointer";
						};
						finishProductTable.onmouseout = function()
						{
							this.uel.style["text-decoration"]="none";
							this.uel.style.textDecoration="none";
							this.style.cursor="default";
						};
						finishProductTable.onblur = function()
						{
							this.uel.style["text-decoration"]="none";
							this.uel.style.textDecoration="none";
							this.style.cursor="default";
						};
						// Add tab order sequesnce
						if (this.wizardControl.WAM) {
							this.WAMElementSet.push({element:finishProductTable,virtualtype:'WizardButton1'});
						}
						*/

                        /*
						var li = document.createElement("li");
						
						var opresult = this._textForOperationResult(set.visibleList[i].payloadOperation, set.visibleList[i].payloadResult);
						if (set.visibleList[i].payloadNote)
						{
							var span = this.AppendTextElement("span", "(" + set.visibleList[i].payloadNote.Translate(this.wizardControl.session.localization) + ")", lip);
							span.className = "payloadNote";
						}

						if (set.visibleList[i].payloadDetail || (opresult && opresult.detail))
						{
							if (opresult&& opresult.detail)
							{
								li.appendChild(this._createErrorListElement(null, opresult.detail))
							}
							if (set.visibleList[i].payloadDetail)
							{
								li.appendChild(this._createErrorListElement(null, set.visibleList[i].payloadDetail));
							}
						}
						*/
					}
				}
			}
		}
		// PP success case
		else
		{
			thisCB.makeElementVisibleInList(kPPCompleteSuccessDivID, successCompleteTypes);

			var driver = this.wizardControl.session.GetDriverPayload();
			var icon = null;
			var alp = null;

			if (driver)
			{
				driver = this.wizardControl.session.sessionPayloads[driver.AdobeCode];
				icon = driver.GetProductIcon();
				alp = driver.GetAppLaunchPathAndArguments();
			
			}

			if (icon == null || alp == null || alp["AppLaunchPath"] == null || alp["AppLaunchPath"] == "")
			{
			    // No-op
			}
			else
			{
				var PPIconPlaceHolder = this.getElementById("PPIconPlaceHolder");
				var PPButtonPlaceHolder = this.getElementById("PPButtonPlaceHolder");
				var mydata=this.wizardControl;
				var myextra = new Object();
				myextra.thisSet_plp = alp["AppLaunchPath"];
				myextra.thisSet_pla =alp["AppLaunchArguments"];
				myextra.thisSet_pac = driver.GetAdobeCode();
				myextra.thisSet_pna = driver.GetUIProductName(this.wizardControl.session);
				myextra.onClickFunc = function(){thisSession.RunApplication(myextra.thisSet_pac, myextra.thisSet_plp, myextra.thisSet_pla);mydata.NavQuit();};
				
				var productTotalButton = new WizardButton1(1, "e", 
					this.localization.GetString("locPPButton","Launch [productName] now"),
					"479px", "50px", "0px", "0px", "launchbutton", PPButtonPlaceHolder, myextra.onClickFunc);

				productTotalButton.uielement.onmouseover = function()
				{
					this.style.cursor="hand";
					this.style.cursor="pointer";
				};
			    productTotalButton.uielement.onmouseout = function()
			    {
					this.style.cursor="default";
				};
			    productTotalButton.uielement.onblur = function()
			    {
					this.style.cursor="default";
				};
				// Add tab order sequesnce
				if (this.wizardControl.WAM) {
					this.WAMElementSet.push({element:productTotalButton.GetDisplayElement(),virtualtype:'WizardButton1'});
					this.WAMElementDefFocusElement = productTotalButton.GetDisplayElement();
				}

				var productIconImg = new WizardImage1(icon, "", "productimageicon", PPIconPlaceHolder, myextra.onClickFunc);

				productIconImg.image.onmouseover = function()
				{
					this.style.cursor="hand";
					this.style.cursor="pointer";
				};
			    productIconImg.image.onmouseout = function()
			    {
					this.style.cursor="default";
				};
			    productIconImg.image.onblur = function()
			    {
					this.style.cursor="default";
				};
			}
		}
		
		
	}
	// Total failure case
	else if ((allPayloads.driverFailure == true) 
	    || (allPayloads["pass"].visibleList.length == 0 && allPayloads["pass"].hiddenList.length == 0 && allPayloads["partialPass"].visibleList.length == 0 && allPayloads["partialPass"].hiddenList.length == 0)
	    || (gSession.IsSuiteMode() && allPayloads["pass"].visibleList.length == 0 && allPayloads["partialPass"].visibleList.length == 0)
	)
	{
	    this.totalFailure = true;
    	this.makeElementVisibleInList(kCompleteFailureDivID, allInstallCompleteTypes);
	    // Suite failure case
        if(gSession.IsSuiteMode())
        {
    	    thisCB.makeElementVisibleInList(kSuiteCompleteFailureDivID, failureCompleteTypes);
        }
	    // PP failure case
        else
        {
    	    thisCB.makeElementVisibleInList(kPPCompleteFailureDivID, failureCompleteTypes);
        }
	}
	// Done with errors - Partial success
	else
	{
	    this.doneWithErrors = true; // Required for registration to come after Finish
    	this.makeElementVisibleInList(kDoneWithErrorsDivID, allInstallCompleteTypes);
	    // Suite partial failure case
        if(gSession.IsSuiteMode())
        {
    	    thisCB.makeElementVisibleInList(kSuiteDoneWithErrorsDivID, doneWithErrorsCompleteTypes);
		    var set = allPayloads["fail"];
		    if(set.visibleList.length > 0)
		    {
                var completelyFailedProductsListing = this.getElementById("completelyFailedProductsListing");
		        for (var i = 0; i < set.visibleList.length; i++)
		        {
				    var name = set.visibleList[i].payloadName;
                    var nameSpanElement = document.createElement("span");
                    nameSpanElement.className = "failedproductnametext";
        	        nameSpanElement.innerHTML = name;
        	        completelyFailedProductsListing.appendChild(nameSpanElement);
		        }
		    }
		    else
		    {
                var completelyFailedProductsOuterDiv = this.getElementById("completelyFailedProductsOuterDiv");
                completelyFailedProductsOuterDiv.style.display="none";
		    }
		    
		    set = allPayloads["partialPass"];
		    if(set.visibleList.length > 0)
		    {
                var partiallyFailedProductsListing = this.getElementById("partiallyFailedProductsListing");
		        for (var i = 0; i < set.visibleList.length; i++)
		        {
				    var name = set.visibleList[i].payloadName;
                    var nameSpanElement = document.createElement("span");
                    nameSpanElement.className = "failedproductnametext";
        	        nameSpanElement.innerHTML = name;
        	        partiallyFailedProductsListing.appendChild(nameSpanElement);
		        }
		    }
		    else
		    {
                var partiallyFailedProductsOuterDiv = this.getElementById("partiallyFailedProductsOuterDiv");
                partiallyFailedProductsOuterDiv.style.display="none";
		    }
        }
	    // PP partial failure case
        else
        {
    	    thisCB.makeElementVisibleInList(kPPDoneWithErrorsDivID, doneWithErrorsCompleteTypes);
        }
	}
	this.FillButtonArea();
	
	if(gSession.languagertl)
	{
           if(gSession.IsSuiteMode())
           {
             document.getElementById("success_pointproduct_thanks").style.position="static";
             document.getElementById("success_pointproduct_thanks").style.left="100px";
           }
           else
           {
             document.getElementById("success_pointproduct_thanks").style.position="static";
             document.getElementById("success_pointproduct_thanks").style.left="20px";
             document.getElementById("PPIconPlaceHolder").style.left="100px";
           }
        }   
	this.AutoReverseRTLOnce();
	this.ConfigureAutoReverseRTL();
	this.AutoReverseRTL();
	this.CreateWAMPage();
}

Finish_wp.prototype.isActive = function()
{
	return true;
}

/**
Fabricate the DOM for a system check error/warning
*/
Finish_wp.prototype._createErrorListElement = function(inClass, inText, inOptContainerElement)
{
	var session = this.wizardControl.session;

	var isArray = function(inObj)
	{
		return typeof inObj == "object" && inObj.length && inObj.concat && inObj.join;
	};

	var isLocalizedString = function(inObj)
	{
		return typeof inObj == "object" && inObj.Translate && typeof inObj.Translate == "function";
	};

	var resolveString = function(inObj, forLog)
	{
		if (isLocalizedString(inObj))
		{
			if (forLog)
				return inObj.Translate(session.localization, 'en_US');
			else
				return inObj.Translate(session.localization);
		}
		return inObj;
	};

	var contentList = inText;
	if (!isArray(inText))
		contentList = new Array(inText);
		
	var errorDiv = document.createElement(typeof inOptContainerElement == "string" ? inOptContainerElement : "div");
	if (inClass)
		errorDiv.className = inClass;

	for (var i in contentList)
	{
		var item = contentList[i];
		if (isArray(item))
		{
			if (item.length > 0)
			{
				var listElement = document.createElement("ul");
				for (var si in item)
				{
					var li = document.createElement("li");
					li.style.setAttribute("listStyleType","none");
					li.appendChild(document.createTextNode(resolveString(item[si])));
					listElement.appendChild(li);
				}
				errorDiv.appendChild(listElement);
			}
		}
		else
		{
			var p = document.createElement("p");
			p.appendChild(document.createTextNode(resolveString(item)));
			errorDiv.appendChild(p);
		}
	}

	return errorDiv;
}


/**
For an payload operation and the companion result, come up with the UI text.
*/
Finish_wp.prototype._textForOperationResult = function(inOperation, inOperationResult)
{
	var result = {
		text: null,
		detail: null,
		alert: true
	};

	if (inOperationResult && inOperationResult.message)
	{
		if (inOperationResult.message.code == gConstants.kORSuccess
			|| inOperationResult.message.code == gConstants.kORSuccessWithReboot 
			|| inOperationResult.message.code == gConstants.kORSuccessWithMessage)
		{
			switch (inOperation)
			{
				case kInstallerActionInstall:
					result.text = this.localization.GetString("locSuccessInstalled", "Installed");
					break;
				case kInstallerActionRepair:
					result.text = this.localization.GetString("locSuccessRepaired", "Reinstalled");
					break;
				case kInstallerActionRemove:
					result.text = this.localization.GetString("locSuccessRemoved", "Removed");
					break;
			}
			
			if (inOperationResult.message.code == gConstants.kORSuccessWithMessage)
			{		
				if (inOperationResult.message.args)
				{
					result.detail = inOperationResult.message.args[getUserInterfaceLanguage(this.wizardControl.session)];
					if (null == result.detail)
					{
						result.detail = inOperationResult.message.args["en_US"];
					}					
				}
				result.alert = false;
			}
		}
		else
		{			
			switch (inOperation)
			{
				case kInstallerActionInstall:
					result.text = this.localization.GetString("locFailInstalled", "Not installed");
					break;
				case kInstallerActionRepair:
					result.text = this.localization.GetString("locFailRepaired", "Not reinstalled");
					break;
				case kInstallerActionRemove:
					result.text = this.localization.GetString("locFailRemoved", "Not removed");
					break;
			}
			switch (Number(inOperationResult.message.code))
			{
				case gConstants.kORUserCancel:
					result.detail = (kInstallerActionRemove != inOperation) ? 
					 				this.localization.GetString("locErrorUserCancel", "User canceled installation") :
									this.localization.GetString("locErrorUninstallUserCancel", "User canceled uninstallation");
					break;
				case gConstants.kORConflictsExist:
					result.detail = this.localization.GetString("locErrorConflicts", "Conflicts with a component already installed");
					break;
				case gConstants.kORUpgradeFailure:
					result.detail = this.localization.GetString("locErrorUpgradeFailure", "Upgrade failed");
					break;
				case gConstants.kORMissingMedia:
					result.detail = this.localization.GetString("locErrorFailedMissingMedia", "Install failed - missing media", inOperationResult.message.args);
					break;			
				default:
					result.detail = (kInstallerActionRemove != inOperation) ? 
				 					this.localization.GetString("locErrorFailed", "Install failed") :
									this.localization.GetString("locErrorUninstallFailed", "Uninstall failed");
					break;
			}
		}
	}
	return result;
}


Finish_wp.prototype.onNext = function()
{
	var driver = this.wizardControl.session.GetDriverPayload();
	if ( this.wizardControl.session.IsRecordMode() == false && this.bForceDisplayThanks == false) {
		if (this.wizardControl.session.properties["pers_EPIC_SERIAL"])
			this.wizardControl.session.ShowRegistrationDialog(driver.AdobeCode,this.wizardControl.session.properties["installLanguage"]);
		// Show the Finish page again for Thank you
		this.bForceDisplayThanks = true;
		this.onShow();
		// We are showing same page with defferent layout, so announce JAWS page message.
		if (this.wizardControl.WAM)
			this.wizardControl.WAM.AnnouncePageMeesage();
	}
	else {
		this.wizardControl.session.UIExitDialog();
	}
}

Finish_wp.prototype.onCancel = function()
{
	this.wizardControl.session.UIExitDialog();
}


// The reworked Back is Finish in cases where a restart is optional
Finish_wp.prototype.onBack = function()
{
	this.wizardControl.session.UIExitDialog();
}

Finish_wp.prototype.onMoreInformation = function()
{
	// Do we have payload operation result with us?
	if (!this.allPayloads) { // No
		// Show full log file
		var logFileName = this.wizardControl.session.GetLogFilePath();
		var command = "";
		if (this.wizardControl.session.systemInfo.Windows)
			command = "notepad";
		else
			command = "/Applications/TextEdit.app/Contents/MacOS/TextEdit";
		this.wizardControl.session.OpenFileWithApplication(command, logFileName);
	}
	else { // Yes
		var text = "";
		var failList = this.allPayloads["fail"].visibleList;
		var locError = this.wizardControl.session.localization.GetString("locError", "Error")+":";
		failList = failList.concat(this.allPayloads["fail"].hiddenList);		
		for (var i = 0; i < failList.length; i++) {
			var failedPayload = failList[i];
		    var code = failedPayload.payloadResult.message.code;	
			if ( (failedPayload.payloadResult.message) && (code!= 1) && (code!= 8)) {
			    text += failedPayload.payloadName + "\n" + locError;	
				var errorText = "";
				if (failedPayload.payloadResult.message.args) {
					if (failedPayload.payloadResult.message.args.code)
						code = failedPayload.payloadResult.message.args.code;
					if (failedPayload.payloadResult.message.args.errorText)
						errorText = failedPayload.payloadResult.message.args.errorText;
				}
				text += "\nError " + code + ". " + errorText;
				if (i < failList.length-1) {
			    	text += "\n";
			    	text += "\n";
			    }
			}
		}
		var logFileData = text;
		var button1 = {label:this.wizardControl.session.localization.GetString("locClose", "Close"), left:"86px", top:"16px", returnCode:"1", hotkey:"C", defaultOption:"7"};
		var button2 = {label:this.localization.GetString("locGetSupport", "Get Support"), left:"226px", top:"16px", returnCode:"2", hotkey:"G", defaultOption:"0"};
		var buttonsArray = new Array(button1, button2);
		var moreInfoInstruction = "<span>"
				+ this.localization.GetString("locMoreInfoInstruction1")
				+ "</span><br/><br/><span>"
				+ this.localization.GetString("locMoreInfoInstruction2");
		var _WE = new WizardInformation(this.wizardControl.session,
				this.wizardControl.session.localization.GetString("locAlertCancelTitle", "[productName] Installer"),
				this.localization.GetString("locMoreInfoSubTitle"),
				moreInfoInstruction, buttonsArray, logFileData);
		if (_WE.returnValue == "2") {
			var adobeSupportSite = this.wizardControl.session.localization.GetString("locAdobeSupportSite",
					"http://www.adobe.com/go/loganalyzer/");
			if (this.wizardControl.session.systemInfo.Windows)
				window.open(adobeSupportSite);
			else
				this.wizardControl.session.OpenFileWithApplication(adobeSupportSite, "Browser");
		}

		delete logFileData;
		delete _WE;
	}
}

Finish_wp.prototype.AddTitle = function(inTitle, inContainer)
{
	return this.AppendTextElement("h4", inTitle + ":", inContainer);
}


Finish_wp.prototype.AppendTextElement = function(inElementName, inText, inContainer)
{
    var container = this.contentBox;
	if (arguments.length == 3)
		container = inContainer

	if (container)
	{
		var e = document.createElement(inElementName);
		e.appendChild(document.createTextNode(inText));
		container.appendChild(e);
		return e;
	}
	return null;
}

// Return the name of the class.
"Finish_wp";
