<%@  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: WizQuestion_js.jsp %
%version: 4 %
%date_modified: Mon Feb 24 10:01:37 2003 %
Copyright (c) 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.
***************************************************************************  */ 


  /* ------------------------------------------------------------------  */ 
  /* This file contains JavaScript specific to the question  */ 
  /* template.                                                           */ 
  /* ------------------------------------------------------------------  */ 


  /* -------------------------------------------------------------  */ 
  /* Handles one of the push buttons at the bottom of the question  */ 
  /* window getting pressed.                                        */ 
  /* -------------------------------------------------------------  */%> 
function handleQuestionPB(
	sPB)	<%/* The name of the push button that was pressed.  */%> 
{
	<%/* This function works on the main form.  */%> 
	with (getMainWizForm())
	{
		var	aResponses;
		var	cSel;
		var	e;
		

		<%/* Allocate an Array to hold the user"s responses.  */%> 
		aResponses = new Array();
		

		<%/* How did the user respond to the question?  */%> 		
		if      (sPB == "WizPB_Yes") aResponses[0] = "yes";	<%/* Simple Yes/No only         */%> 
		else if (sPB == "WizPB_No")  aResponses[0] = "no";	<%/* ...returns "yes" or "no".  */%> 
		else if (sPB == "WizPB_Ok")
		{
			<%/* By pressing the OK push button!  Is the user being  */ 
			  /* asked for simple input strings?                     */ 
			   if (("input".equals(c.var("Question_Type")))) { 
				  /* Yes!  Read their response(s).  */ 
				   c.set("qi", "0"); 
				   while ((c.lt(c.var("qi"), c.var("Question_MaxInput")))) { 
					   c.set("qn", c.plus("Answer_", c.var("qi"))); %>
					aResponses[<%= c.var("qi") %>] = <%= c.var("qn") %>.value;
					
					<% c.inc("qi"); 
				   } 

				
			  /* No, the user isn"t being asked for simple input     */ 
			  /* strings!  Are they being asked to select something  */ 
			  /* from a list?                                        */ 
			   } else if (("list".equals(c.var("Question_Type")))) { 
				  /* Yes!  Can they only select one item?  */ 
				   if ((c.gte("1", c.var("Question_MaxInput")))) { 
					  /* Yes!  Return the item they selected from the  */ 
					  /* SELECT widget.                                */%> 
					aResponses[0] =
						Answer_List.options[Answer_List.selectedIndex].text;
						
				<% } else { 
					  /* No, they can select more than one item!     */ 
					  /* Initialize a count of how many things they  */ 
					  /* select...                                   */%> 
					cSel = 0;

					<%/* ...and scan the list checkboxes.  */ 					
					   c.set("qIndex", "0"); 
					   while ((c.lt(c.var("qIndex"), c.var("Question_List_Count")))) { 
						  /* Is the next item checked?  */ 
						   c.set("cBoxName", c.plus("ListItem_", c.var("qIndex"))); %>
						e = getWizElement( "<%= c.var("cBoxName") %>" );
						if ((null != e) && e.checked)
						{
							<%/* Yes!  Have they checked too many  */ 
							  /* items?                            */%> 
							if (cSel >= Number( "<%= c.var("Question_MaxInput") %>" ))
							{
								<%/* Yes!  Tell them about the problem  */ 
								  /* and bail.                          */%> 
								tooManySelections();
								return;
							} <%/* if  */ 
							
							
							  /* No, they haven"t checked too many  */ 
							  /* items!  Store this one.            */%> 
							aResponses[cSel++] = e.value;
						} <%/* if  */ 
						
						
						  /* Move to the next checkbox.  */ 
						   c.inc("qIndex"); 
					   } 
				   } 
			   } %>
		} <%/* else if  */%> 

		
		else
		{
			<%/* However they responded, we don"t recognize it!  Tell  */ 
			  /* them about the problem and bail.                      */%> 
			alert( "<%= c.string("CfgWiz.InternalError.UnknownPB") %>" );
			return;
		} <%/* else  */ 
		
		
		  /* Are we still in contact with a valid opener window?  */%> 
		if (!(isOpenerValid()))
		{
			<%/* No!  Tell the user about the problem and bail.  */%> 
			alert( "<%= c.string("CfgWiz.Error.CantAccessOpener_Question") %>" );
			return;
		} <%/* if  */ 
		

		  /* Apply the users response to the question.  */%> 
		window.opener.questionApply( aResponses );
	} <%/* with  */%> 
} <%/* handleQuestionPB  */ 



  /* -------------------------------------------  */ 
  /* Initializes the Wizard question panel. 	    */ 
  /* -------------------------------------------  */%> 
function setFocusAndInitializeForm()
{
	<%/* This function works on the main form.  */%> 
	with (getMainWizForm())
	{
		<%/* Where it makes sense, put the focus into an appropriate  */ 
		  /* widget.                                                  */ 
		   if (("input".equals(c.var("Question_Type")))) { %>
			Answer_0.focus();
			
		<% } else if (("list".equals(c.var("Question_Type")))) { %>
			Answer_List.selectedIndex = 0;
			Answer_List.focus();
		<% } %>
	} <%/* with  */%> 
} <%/* setFocusAndInitializeForm  */ 



  /* -------------------------------------------------  */ 
  /* Tells the user that too many items were selected.  */ 
  /* -------------------------------------------------  */%> 
function tooManySelections()
{
	<% c.set("errStr", c.string("CfgWiz.Error.TooManySelections")); %>
	alert( "<%= c.formatMessage(c.var("errStr"), new String[]{c.var("Question_MaxInput")}) %>" );
	return;
} <%/* tooManySelections  */ 



						     /* * * * * * *  */ 
                             /* End of File  */ 
                             /* * * * * * *  */%> 
