<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils" %>
<%   JSPConduit c = JSPConduit.getJSPConduit(request);

  /* **************************************************************************
%name: CfgWizModules.js %
%version: 3 %
%date_modified: Wed Jun 19 02:52:04 2002 %
Copyright (c) 2001, 2002 Novell, Inc. All Rights Reserved.
THIS WORK IS AN UNPUBLISHED WORK AND CONTAINS CONFIDENTIAL PROPRIETARY
AND TRADE SECRET INFORMATION OF NOVELL, INC. ACCESS TO THIS WORK IS
RESTRICTED TO (I) NOVELL, INC. EMPLOYEES WHO HAVE A NEED TO KNOW HOW
TO PERFORM TASKS WITHIN THE SCOPE OF THEIR ASSIGNMENTS AND (II)
ENTITIES OTHER THAN NOVELL, INC. WHO HAVE ENTERED INTO APPROPRIATE
LICENSE AGREEMENTS. NO PART OF THIS WORK MAY BE USED, PRACTICED,
PERFORMED COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST, TRANSFORMED
OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL, INC. ANY USE
OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT THE
PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
***************************************************************************  */

  /* -------------------------------------------  */
  /* Puts the initial input focus into the page.  */
  /* -------------------------------------------  */%>
function setFocusAndInitializeForm()
{
	<%/* This function works on the main form.  */%>
	with (getMainWizForm())
	{
		var	aCaptionData;
		var	oNavData;

		<%/* Perform initializations common to all panels.  */%>
		initializePanel_Common();

		<%/* Set up input values  */
		   if (c.gt(c.var("CfgWiz.ModulesToInstall.Count"), "0")) {
			  /*-- get the selected indexes for the install modules and select them -- */%>
			var aSelectedInstallModules = unpack( "<%= c.var("CfgWiz.SelectedInstallModules") %>" );
			if ( aSelectedInstallModules != null )
			{
				for ( var i=0; i < aSelectedInstallModules.length; i++ )
				{
					ModulesToBeInstalled[ aSelectedInstallModules[i] ].selected = true;
				}
			}

			<%/*-- set the assign rights-- */%>
			AssignRights.checked = "<%= c.var("CfgWiz.InstallModulesAssignRights") %>" == "true" ? true : false;
			<%/*-- set the scope -- */%>
			Scope.value = "<%= c.var("CfgWiz.InstallModulesScope") %>";
			<%/*-- set the scope inheritance -- */%>
			ScopeInheritable.checked = "<%= c.var("CfgWiz.InstallModulesScopeInherited") %>" == "true" ? true : false;
			<%/*-- disable the Inherited checkbox if needed -- */%>
			enableScopeInherited();
		<% }

		  /* Finally, force the caption frame...  */%>
		aCaptionData = new Array();
		aCaptionData["Wiz_Banner_Text"]     = "<%= c.toScript(c.string("CfgWiz.Wizard.Title")) %>";
	 	aCaptionData["Wiz_Banner_ShowHelp"] = true;
		aCaptionData["Wiz_Header_Size"]     = 1;
		aCaptionData["Wiz_Header_Icon_0"]   = "<%= c.getModulesUrl() %>/fw/images" + "/rbsCollection.gif";;
		aCaptionData["Wiz_Header_Item_0"]   = "<%= c.var("CfgWiz.CurrentCollection.Name") %>";
		aCaptionData["Wiz_Header_Type_0"]   = "<%= c.var("CfgWiz.CollectionXofY") %>";

		parent.window.Wiz_BannerFrame.updateCaption( aCaptionData );

		<%/* ...and navigation frame to update with settings  */
		  /* ...appropriate for this panel.                   */%>
		oNavData               	= new Object();
		<% if (c.var("CfgWiz.LastCollection").equals("true")) { %>
		oNavData.disableFinish 	= false;
		oNavData.disableBack 	= false;
		oNavData.disableNext 	= true;
        oNavData.disableClose   = false;
		<% } else { %>
		oNavData.disableFinish 	= true;
		oNavData.disableBack 	= false;
		oNavData.disableNext 	= false;
        oNavData.disableClose   = false;
		<% } %>
		parent.window.Wiz_NavigationFrame.updateNavigation( oNavData );

		<%/*-- set focus to the first input on the page -- */
		   if (c.gt(c.var("CfgWiz.ModulesToInstall.Count"), "0")) { %>
		Scope.focus();
		<% } %>

	} <%/* with  */%>
} <%/* setFocusAndInitializeForm  */

  /* -----------------------------------------------------  */
  /* Called when the help button is pressed on this panel.  */
  /* -----------------------------------------------------  */%>
function showHelp()
{
	runHelp( "modules_in_collection_info.html" );
} <%/* showHelp  */


  /* --------------------------------------  */
  /* Callback for OS 						   */
  /* --------------------------------------  */%>
function addScope( ctrl, val )
{
	with (getMainWizForm())
    {
		Scope.value = val;
    }
    enableScopeInherited();
}


<%/* ----------------------------------------------------------------  */
  /* ScopeInheritable should not be active when there is no scope		 */
  /* specified 														 */
  /* ----------------------------------------------------------------  */%>
function enableScopeInherited( )
{
	<%/* This function works on the main form.  */%>
	with (getMainWizForm())
	{
		var scope = Scope.value;
		ScopeInheritable.disabled = ( scope == "" );
        AssignRights.disabled = ( scope == "" );
	}
}

<%/* ---------------------------------------------------------------------  */
  /* Selects or deselects all options in the Modules To Install select box  */
  /* ---------------------------------------------------------------------  */%>
function selectAllInstallModules( select )
{
	<% if (c.gt(c.var("CfgWiz.ModulesToInstall.Count"), "0")) {
		  /* This function works on the main form.  */%>
		with (getMainWizForm())
		{
			for ( var i=0; i < ModulesToBeInstalled.length; i++ )
			{
				ModulesToBeInstalled[ i ].selected = select;
			}
		}
	<% } %>
}


<%/* ----------------------------------------------------------------  */
  /* Validates the selected server information when one of the backup  */
  /* push buttons is pressed.                                          */
  /* ----------------------------------------------------------------  */%>
function validateForm_PerPanel()
{
	<%/* This function works on the main form.  */%>
	with (getMainWizForm())
	{
		var	sPB;

		<%/*-- save off values to pass to other pages -- */
		  /*-- get the selected modules to install and store them in a packed list -- */
		   if (c.gt(c.var("CfgWiz.ModulesToInstall.Count"), "0")) { %>
			var selArray = new Array();
			var dstIndex = 0;
			var selIndex = ModulesToBeInstalled.selectedIndex;
			if ( selIndex != -1 )
			{
				<%/*-- Handle multiple selection by extracting each selected item. -- */%>
				var theSelectLen = ModulesToBeInstalled.length;
				for ( srcIndex = theSelectLen - 1, dstIndex; srcIndex >= 0; srcIndex-- )
				{
					if ( ModulesToBeInstalled[ srcIndex ].selected == true )
					{
						<%/*-- Add this item to the array. -- */%>
						selArray[ dstIndex++ ] = srcIndex ;
					}
				}
			}
			SelectedModulesToInstall.value = pack( selArray );

			<%/*-- scope itself is passed back as "Scope" -- */
			  /*-- the scope inheritance -- */%>
			ScopeIsInherited.value = ScopeInheritable.checked == true ? "true" : "false";
			DoAssignRights.value = AssignRights.checked == true ? "true" : "false";

		<% }

		  /* Validate which push button was pressed.  */%>
		sPB = getPBClicked();
		if ("WizPB_Back" == sPB)
		{
			performBack();
			return( false );
		} <%/* if  */%>
		if ("WizPB_Close" == sPB)
		{
			<%/* Return true so that the form gets submitted and the  */
			  /* plug-in gets a chance to cleanup.                    */%>
			return( true );
		} <%/* if  */
		   if (c.var("CfgWiz.LastCollection").equals("true")) { %>
			if ("WizPB_Finish" != sPB)
			{
				alert( "<%= c.toScript(c.string("CfgWiz.InternalError.UnknownPB")) %>" );
				return( false );
			} <%/* if  */
		   } else { %>
			if ("WizPB_Next" != sPB)
			{
				alert( "<%= c.toScript(c.string("CfgWiz.InternalError.UnknownPB")) %>" );
				return( false );
			} <%/* if  */
		   }

		  /* Validate input information  */
		  /*-- warn them if there was no scope specified -- */
		   if (c.gt(c.var("CfgWiz.ModulesToInstall.Count"), "0")) { %>
			if ( (selArray.length > 0) && (Scope.value == "") )
			{
				if ( !confirm("<%= c.toScript(c.string("CfgWiz.Modules.WarnNoScopeSpecified")) %>") )
					return false;
			}
		<% }

		  /* Returning true will cause the form to be submitted.  */%>
		return( true );
	} <%/* with  */%>
} <%/* validateForm_PerPanel  */



						     /* * * * * * *  */
                             /* End of File  */
                             /* * * * * * *  */%>
function preOS(controlName)
{
    with (getMainWizForm())
    {
		<%/* Disable all the buttons */%>
		var	oNavData;
		oNavData               	= new Object();
		oNavData.disableFinish 	= true;
		oNavData.disableBack 	= true;
		oNavData.disableNext 	= true;
        oNavData.disableClose   = true;
		parent.window.Wiz_NavigationFrame.updateNavigation( oNavData );
   }
}

function postOS(controlName)
{
    with (getMainWizForm())
    {
      <%/* Re-enable active buttons */%>
        var	oNavData;
        oNavData               	= new Object();
        <% if (c.var("CfgWiz.LastCollection").equals("true")) { %>
        oNavData.disableFinish 	= false;
        oNavData.disableBack 	= false;
        oNavData.disableNext 	= true;
        oNavData.disableClose   = false;
        <% } else { %>
        oNavData.disableFinish 	= true;
        oNavData.disableBack 	= false;
        oNavData.disableNext 	= false;
        oNavData.disableClose   = false;
        <% } %>
        parent.window.Wiz_NavigationFrame.updateNavigation( oNavData );

        Scope.focus();
   }
}

function changeInherited()
{
	with (getMainWizForm())
	{
      if(AssignRights.checked == true)
      {
         ScopeInheritable.disabled = false;
         ScopeInheritable.checked = true;
      }
      else
      {
         ScopeInheritable.disabled = true;
         ScopeInheritable.checked = false;
      }
   }
}
