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

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

***********************************************************************
*/
/**
Finish Page
*/

function Finish()
{
	this.Hide();
/*	this.quitWB = new WizardButton1(9, "n", gSession.localization.GetString("locExit", "Exit"), 
		"128px", "32px", "236px", "16px","bigbutton_normalsize", document.getElementById("finishID_button"), function(){gSession.UIExitDialog("0");});
*/
}

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

Finish.prototype.OnShow = function()
{
	this.quitWB = new WizardButton1(9, "n", gSession.localization.GetString("locExit", "Exit"), 
		"128px", "32px", "236px", "16px","bigbutton_normalsize", document.getElementById("finishID_button"), function(){gSession.UIExitDialog("0");});
	// gSession.UISetCloseBoxEnabled(1);		
	if (gWAM) {
		gWAM.AddElementSet([
			//{element:_,hotkey:_,focal:_,nofocal:_,type:_},
			{element:this.quitWB.GetDisplayElement(),hotkey:'E',virtualtype:'WizardButton1'}
		]);
		gWAM.SetPageDefaultEnterElement(this.quitWB.GetDisplayElement());
		gWAM.SetPageDefaultFocusElement(this.quitWB.GetDisplayElement());
		gWAM.SetPageDefaultEscapeElement(this.quitWB.GetDisplayElement());
		gWAM.SetFocusOnDefaultElement();
	}

	var listNode = document.getElementById("updatedListID");
	gSession.UISetWindowTitle("Adobe Update Installer - " + gSession.localization.GetString("main_finishSubTitle", "Thanks"));
	var multi = 0;
	var succUpdated = window.external.UIGetSuccessPayloadsMap();
	succUpdated =  eval('(' + succUpdated + ')');
	
	for (var si in succUpdated)
	{
		var upd = succUpdated[si];
		if( upd != "9999") 
		{
		    //append "Installed successfully."
		    multi++;
		    upd = upd + " - " + gSession.localization.GetString("locSuccessfullyInstalled", "Installed successfully.",null);
		    var li = document.createElement("li");
		    li.innerHTML = upd;
		    listNode.appendChild(li);
		     
		}
	}
	if(multi > 1)
	{
		var label=document.getElementById("finishLabelID");
	    	label.innerHTML = gSession.localization.GetString("main_finishInst1", "The following updates were successfully installed.");
	}
	multi = 0;
	
	var notInstalled = window.external.UIGetFailedPayloadsMap();
	notInstalled =  eval('(' + notInstalled + ')');
	
	for (var si in notInstalled)
	{
		var upd = notInstalled[si];
		if( upd != "9999") 
		{
		    //append "Failed to install."
		    var label=document.getElementById("finishLabelID");
	    	    label.innerHTML = "";
		    multi++;
		    upd = upd + " - " + gSession.localization.GetString("locFailedToInstall", "Failed to install.",null);
		    var li = document.createElement("li");
		    li.innerHTML = "<font color=red>" +upd+ "</font>";
		    listNode.appendChild(li);
		    gSession.UISetWindowTitle("Adobe Update Installer - " + gSession.localization.GetString("locDoneError", "Done with error"));
		    var title = document.getElementById("main_finishSubTitle");
		    title.innerHTML = gSession.localization.GetString("locDoneError", "Done with error");
		}
	}
	
	var keyedInstalled = window.external.UIGetSassaFrasFailedPayloadsMap();
	keyedInstalled =  eval('(' + keyedInstalled + ')');
	
	for (var si in keyedInstalled)
	{
		var upd = keyedInstalled[si];
		if( upd != "9999") 
		{
		    //append "Failed to install."
		    var label=document.getElementById("finishLabelID");
	    	    label.innerHTML = "";
		    multi++;
		    upd = upd + " - " + gSession.localization.GetString("locSassaAlert", "Sassafras Keyed Binary found. Please contact your IT Administrator and get the customized patch installer.",null);
		    var li = document.createElement("li");
		    li.innerHTML = "<font color=red>" +upd+ "</font>";
		    listNode.appendChild(li);
		    gSession.UISetWindowTitle("Adobe Update Installer - " + gSession.localization.GetString("locDoneError", "Done with error"));
		    var title = document.getElementById("main_finishSubTitle");
		    title.innerHTML = gSession.localization.GetString("locDoneError", "Done with error");
		}
	}
	
	if(multi > 1)
	{
	    	gSession.UISetWindowTitle("Adobe Update Installer - " + gSession.localization.GetString("locDoneErrors", "Done with errors"));
	    	var title = document.getElementById("main_finishSubTitle");
		title.innerHTML = gSession.localization.GetString("locDoneErrors", "Done with errors");
	    	
	}
	
	//rtl implementation
	if(gSession.languagertl)
	{
		this.AutoReverseRTL();
		this.quitWB.mainelement.style.left="330px";
		this.quitWB.label.style.left="50px";
	}
	return true;
}
