/*!
**********************************************************************
@file maintenanceWelcome.js

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

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

/**
Implement a Wizard Page in three easy steps:

 1. Subclass WizardPage
 2. Extend with page-specific method overrides
 3. Return the WizardPage subclass name

*/

/***********************************************************************
1. Subclass WizardPage
*/
function maintenanceWelcome_wp(inController)
{
	this.SetController(inController);
	
	this.doubleDown = false;
	this.doubleUp = false;
	
	this.modeBox = null;	
}

maintenanceWelcome_wp.prototype = new WizardPage("maintenanceWelcome");


/***********************************************************************
2. Extend/override with page-specific logic
*/

maintenanceWelcome_wp.prototype.GetDisplayName = function()
{
	return this.localization.GetString("locNavTitle", "Welcome");
}


maintenanceWelcome_wp.prototype.UpdateInstructionText = function(inMode)
{
	var instructionDiv = this.getElementById("modeDetails");
	if (instructionDiv)
	{
		var instructionText = this.localization.GetString(inMode + "Instructions");
		instructionDiv.innerHTML = instructionText;
	}
}


maintenanceWelcome_wp.prototype.SelectMode = function(inMode)
{
	this.wizardControl.setupMode = inMode;
	var modes = this.getElementById("modes").childNodes;
	for (var n = 0; n < modes.length; n++)
	{
		modes[n].className = "row";
		if (inMode == modes[n].id)
		{
			modes[n].className += " selected";
			this.UpdateInstructionText(inMode);
		}
	}
	
	this.wizardControl.SetNavUI(this.wizardControl.currentPageIndex);
}


maintenanceWelcome_wp.prototype.HandleKeyUp = function(ev)
{
	if (this.modeBox)
	{
		// Up
		if (ev.keyCode == 38 && ev.ctrlKey)
		{
			if (this.doubleUp)
			{
			 	if (this.wizardControl.setupMode != kInstallerModeModify)
						this.SelectMode(kInstallerModeModify);
			
				this.doubleUp = false;
			}
			else
			{
				this.doubleUp = true;
			}	
		}
		// Down
		else if (ev.keyCode == 40 && ev.ctrlKey)
		{
			if (this.doubleDown)
			{
			 	if (this.wizardControl.setupMode != kInstallerModeRemove)
						this.SelectMode(kInstallerModeRemove);
				
				this.doubleDown = false;
			}
			else
			{
				this.doubleDown = true;
			}
		}
	}

	return false;
}


maintenanceWelcome_wp.prototype.SetModeWithKeyboard = function(mode, ev)
{
	// Set the mode when the space bar is hit
	if (ev && ev.keyCode == 32)
		this.SelectMode(mode);

	return false;
}


maintenanceWelcome_wp.prototype.onShow = function()
{
	this.setWindowTitle();	
	this.wizardControl.session.UISetCloseBoxEnabled(1);	
	
	this.wizardControl.nextButton.SetTabIndex(102);
	this.wizardControl.backButton.SetTabIndex(103);
	this.wizardControl.quitButton.SetTabIndex(101);	
	
	this.wizardControl.nextButton.SetAccessKey("n");
	this.wizardControl.backButton.SetAccessKey("b");
	this.wizardControl.quitButton.SetAccessKey("c");

	this.wizardControl.nextButton.button.focus();
	this.wizardControl.SetFocus(this.wizardControl.nextButton.button);				
}


maintenanceWelcome_wp.prototype.onResourcesLoaded = function()
{
	this.modeBox = this.getElementById("modes").childNodes;
	var thisCB = this;
	for (var n = 0; n < this.modeBox.length; n++)
	{
		this.modeBox[n].onclick = function() { thisCB.SelectMode(this.id); };
		this.modeBox[n].onkeyup = function() { thisCB.SetModeWithKeyboard(this.id, event); };
	}

	this.SelectMode(kInstallerModeModify);
}


/***********************************************************************
3. Last, and very important, return the name of the class.
*/
"maintenanceWelcome_wp";
