<%@  page import="com.novell.webaccess.common.JSPConduit2, com.novell.emframe.dev.eMFrameUtils" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%   JSPConduit2 c = JSPConduit2.getJSPConduit(request);
   c.stringTable("DevResources"); 
   c.stringTable("BaseResources"); 
   c.stringTable("FwResources");%> 
<HTML>
<HEAD>
<TITLE><%= c.string("CreateUser.CreateUserTitle") %></TITLE>
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/ASScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/MvSel_inc.jsp") %>' flush="true" />
<LINK href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" rel="styleSheet" type="text/css">

<script language="JavaScript">

   function setFocusToFormElement()
   {
      document.CreateUserForm.CreateUserContext.focus();
   }


   function isEnabled()
   {
      //alert("isEnabled called...");
      return true;
   }
   
   function myCallback(controlName, resultArray)
   {
      alert("myCallback called...  resultArray = "+resultArray);
      eval('document.CreateUserForm.'+controlName+'.value="'+toScript(resultArray[0])+'"');
   }
   
   var initialCriterion = new Array();
   function saveInitialCriterion(controlName, types, criterion)
   {
      //alert("saveInitialCriterion called... types="+types+"\ncriterion="+criterion);
      initialCriterion[types]=criterion;
   }
   
   function getTypes()
   {
      var t = document.CreateUserForm.elements["Types"].value;
      if (t==null)
      {
         t=""
      }
      return t;
   }
   
   function getInitialCriterion(types)
   {
      var ret = "";
      if (types!=null)
      {
         var ic=initialCriterion[types];
         if (ic!=null)
         {
            ret=ic;
         }
      }
      //alert("getInitialCriterion called... criterion="+ret);
      return ret;
   }
   
   function preOS(osControl)
   {
      alert("preOS called");
   }
   
   function postOS(osControl)
   {
      alert("postOS called... osControl="+osControl);
   }
   
   function ssChange()
   {
      var e = document.getElementById("startupMode");
      var ssMode = e.options[e.selectedIndex].value;
      e = document.getElementById("subcontainerSearch");
      var scSearch = e.options[e.selectedIndex].value;
      if (ssMode=="browse")
      {
         //set subcontainer search false when in browse mode
         e.options[0].selected = true;
         e = document.getElementById("SOSOption");
         e.style.display="none";
         e = document.getElementById("SCOption");
         e.style.display="none";
      }
      else
      {
         e = document.getElementById("SOSOption");
         e.style.display="block";
         e = document.getElementById("SCOption");
         e.style.display="block";
      }
   }
   
   function sosChange()
   {
      var e = document.getElementById("startupMode");
      var ssMode = e.options[e.selectedIndex].value;
      e = document.getElementById("SOSearch");
      var soSearch = e.options[e.selectedIndex].value;
      if (ssMode=="browse")
      {
         //set search on startup false when in browse mode
         e.options[0].selected = true;
         e = document.getElementById("SOSOption");
         e.style.display="none";
         e = document.getElementById("SCOption");
         e.style.display="none";
         }
      else
      {
         e = document.getElementById("SOSOption");
         e.style.display="block";
         e = document.getElementById("SCOption");
         e.style.display="block";
      }
   }
   
   function getAdvSelType()
   {
      var type = document.CreateUserForm.AdvSelType.value;
      if (type==null || type.length==0)
      {
         type = "User";
         document.CreateUserForm.AdvSelType.value=type;
      }
      return type;
   }
   
   function myDoDynamicOS()
   {
      var OS = new Object();
      var e = null;
      OS.control="SelectionResult";
      OS.callBack="";
      e = document.getElementById("advancedSelection");
      OS.advancedSelection=e.options[e.selectedIndex].value;
      OS.initialContext=document.CreateUserForm.InitialContext.value;
      OS.isOSAllowed="";
      e = document.getElementById("startupMode");
      OS.mode = e.options[e.selectedIndex].value;
      e = document.getElementById("selectionMode");
      OS.multiSelect=e.options[e.selectedIndex].value;
      OS.nameFilter=document.CreateUserForm.NameFilter.value;
      OS.resultsPerPage=document.CreateUserForm.ResultsPerPage.value;
      e = document.getElementById("subcontainerSearch");
      OS.searchSubContainers=e.options[e.selectedIndex].value;
      e = document.getElementById("SOSearch");
      OS.searchOnStartup=e.options[e.selectedIndex].value;
      OS.showSubClasses=="";
      OS.typeFilter=document.CreateUserForm.TypeFilter.value;
      OS.typeFilterCallBack="";
      OS.advSelCriteria=document.CreateUserForm.AdvTypeFilter.value;
      //e = document.getElementById("resultsFormat");
      //OS.resultsFormat=e.options[e.selectedIndex].value;
      doDynamicOS("",OS);
   }

</script>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="setFocusToFormElement()">
<form name="CreateUserForm" method=post action="webacc" onSubmit="">
   <input type=hidden name="taskId" value="<%= c.var("taskId") %>">
   <input type=hidden name="merge" value="dev.GenConf">
   <input type=hidden name="error" value="dev.GenErr">
   <input type=hidden name="User.context" value="<%= c.var("User.context") %>">
   <input type=hidden name="nextState" value="doCreateUser">
   
   <% c.set("TaskHeader.title", "Debug Task"); 
      c.set("TaskHeader.iconUrl", "dir/User.gif");  
      c.set("TaskHeader.iconAlt", "User"); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />
   
   <FONT face="Helvetica,Arial" size=-1><NOBR>
   <% String imageName = c.getModulesUrl() + "/dev/images/" + c.toDisplay(c.string("Button.OS.image")); %>
   <br>
   <b>Build-your-own Object Selector:</b>
   <br><br>
   <table>
     <tr>
         <td>Mode On Startup:</td>
         <td>
         <select id="startupMode" onChange="ssChange();sosChange();">
            <option style="font-size:1.1em" value="browse" selected><%= c.toTag(c.string("OS.Browser.BrowseMode")) %>&nbsp;
            <option style="font-size:1.1em" value="search"><%= c.toTag(c.string("OS.Browser.SearchMode")) %>&nbsp;
         </select>
         </td>
     </tr>
     <tr id="SOSOption" style="display:none">
         <td>&nbsp;&nbsp;&nbsp;Search On Startup:</td>
         <td>&nbsp;&nbsp;&nbsp;
         <select id="SOSearch" onChange="sosChange()">
            <option style="font-size:1.1em" value="false" selected>Off&nbsp;
            <option style="font-size:1.1em" value="true">On&nbsp;
         </select>
         </td>
     </tr>
     <tr id="SCOption" style="display:none">
         <td>&nbsp;&nbsp;&nbsp;Search Subcontainers:</td>
         <td>&nbsp;&nbsp;&nbsp;
         <select id="subcontainerSearch" onChange="ssChange()">
            <option style="font-size:1.1em" value="false" selected>Off&nbsp;
            <option style="font-size:1.1em" value="true">On&nbsp;
         </select>
         </td>
     </tr>
     <tr>
         <td>Selection Mode:</td>
         <td>
         <select id="selectionMode">
            <option style="font-size:1.1em" value="false" selected>Single-Select&nbsp;
            <option style="font-size:1.1em" value="true">Multi-Select&nbsp;
         </select>
         </td>
     </tr>
     <tr>
         <td>Advanced Selection:</td>
         <td>
         <select id="advancedSelection">
            <option style="font-size:1.1em" value="false" selected>Off&nbsp;
            <option style="font-size:1.1em" value="true">On&nbsp;
         </select>
         </td>
     </tr>
<%--     <tr>--%>
<%--         <td>Results Format:</td>--%>
<%--         <td>--%>
<%--         <select id="resultsFormat">--%>
<%--            <option style="font-size:1.1em" value="Rooted">Rooted&nbsp;--%>
<%--            <option style="font-size:1.1em" value="Unrooted" selected>Unrooted&nbsp;--%>
<%--         </select>--%>
<%--         </td>--%>
<%--     </tr>--%>
     <tr>
         <td>Results Per Page:</td>
         <td><input type=text name="ResultsPerPage" value="" size=3>
         <span style="font-size:0.8em">(>0 and <=500)</span></td>
     </tr>
     <tr>
         <td>Initial Search Context:</td>
         <td><input type=text name="InitialContext" value="" size=30></td>
     </tr>
     <tr>
      <td>Name Filter:</td>
      <td><input type=text name="NameFilter" value="*" size=30></td>
   </tr>
   <tr>
      <td>Type Filter:</td>
      <td><input type=text name="TypeFilter" value="*" size=30></td>
   </tr>
   <tr>
      <td>Advanced Type Filter:</td>
      <td><input type=text name="AdvTypeFilter" value="" size=30></td>
      <td>&nbsp;&nbsp;Type:&nbsp;&nbsp;<input type=text name="AdvSelType" value="" size=10>
<%    c.set("AS.TypesCallBack","getAdvSelType");
      c.set("AS.Control","AdvTypeFilter"); %>
      <jsp:include page='<%= c.getPath("dev/AS_inc.jsp") %>' flush="true" />
      </td>
   </tr>
   </table>

   <input type=text name="SelectionResult" value="" size=80>&nbsp;<img src="<%= imageName %>" onClick="javascript:myDoDynamicOS();">
   <br><br>
<% String mvselImageName = c.getModulesUrl() + "/dev/images/drop_down.gif"; %>
<% String clickCmd = "onShowHideList('mvsel1')"; %>
   Multi-valued select 1:&nbsp;&nbsp;<input type=text id="mvsel1" name="mvsel1" value="" style="width:300px; padding-left:3px" onKeyDown="mvselReadOnly('mvsel1',event)"><a href="#" onKeyDown="mvselKeyDown('mvsel1',event);" onBlur="hideItems('mvsel1')" onClick="onListActivation('mvsel1')"><img id="mvsel1btn" src="<%= mvselImageName %>" border=0></a>
   <script>setupMvsel("mvsel1", ["one","two","three","four"], ["two"]);</script>
   <br><br>
   Multi-valued select 2:&nbsp;&nbsp;<input type=text id="mvsel2" name="mvsel2" value="" style="width:100px; padding-left:3px" onKeyDown="mvselReadOnly('mvsel2',event)"><a href="#" onKeyDown="mvselKeyDown('mvsel2',event);" onBlur="hideItems('mvsel2')" onClick="onListActivation('mvsel2')"><img id="mvsel2btn" src="<%= mvselImageName %>" border=0></a>
   <script>setupMvsel("mvsel2", ["uno","dos","tres","quatro"], ["uno", "quatro"]);</script>
   
   <br><br>
   <BR><b>Pre-configured Object Selectors:</b>
   <BR><BR>
   <input type=text name="CreateUserContext" value="Alias, User, Organization, Organizational Unit, Country, Group, Computer, [root], [this], [public], [containers]" size=50>
   <% c.set("OS.Control", "CreateUserContext"); 
      c.set("OS.InitialContext", ""); 
      c.set("OS.NameFilter", "*"); 
      c.set("OS.TypeFilter", "Alias, User, Organization, Organizational Unit, Country, Group, Computer, [root], [this], [public], [containers]"); 
      c.set("OS.CallBack", ""); 
      c.set("OS.IsOSAllowed", "isEnabled"); 
      c.set("OS.Mode", "Browse"); 
      c.set("OS.MultiSelect", "true"); 
      c.set("OS.SearchSubContainers", "true"); 
      c.set("OS.SearchOnStartup", "false"); 
      c.set("OS.AltText", "God Bless America"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   
   <!--Advanced Selection widget-->
   <% c.set("AS.Types", "User");
      c.set("AS.AuxTypes", "FlorasAuxClass, Partition");
      c.set("AS.Control", "CreateUserContext"); 
      c.set("AS.CallBack", ""); 
      c.set("AS.InitialCriterion", "<selection-criterion><types>User</types><group><row><attribute>CN</attribute><operation>AS.Op.isEqual</operation><value>Mike Harris</value><row-op>and</row-op></row><row><attribute>Full Name</attribute><operation>equals</operation><value>Now is the time</value><row-op>and</row-op></row><group-op>or</group-op></group></selection-criterion>"); 
      c.set("AS.IsASAllowed", ""); 
      c.set("AS.TypeInfoCallBack", "com.novell.emframe.fw.NDSTypeInfoCallback"); 
      c.set("AS.HelpFile", "fw/helpindex.html"); %>
   <% c.set("AS.AltText", "Advanced Selection Criterion"); 
      c.set("AS.IconName", ""); %>
   <jsp:include page='<%= c.getPath("dev/AS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Browse,Control,NameFilter*,IsAllowed,Multiselect,SearchSubContainers,!SearchOnStartup</font><br>
   
   <br>
   <input type=text name="Junk" value="User" size=50>
   <% c.set("OS.Control", "Junk"); 
      c.set("OS.TypeFilter", "User"); 
      c.set("OS.CallBack", "myCallback"); 
      c.set("OS.AltText", "Down with terrorism!");
      c.set("OS.IconName", "/dev/images/en/btnadd_en.gif"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control,Callback</font><br>
   
   <br>
   <input type=text name="Junk1" value="[non-containers],User" size=50>
   <% c.set("OS.Control", "Junk1"); 
      c.set("OS.TypeFilter", "[non-containers],User"); 
      c.set("OS.AltText", "Down with terrorism!");
      c.set("OS.IconName", "/dev/images/en/btnadd_en.gif"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control,Callback</font><br>
   
   <br>
   <input type=text name="Junk1a" value="[non-containers],[containers]" size=50>
   <% c.set("OS.Control", "Junk1a"); 
      c.set("OS.TypeFilter", "[non-containers],[containers]"); 
      c.set("OS.AltText", "Down with terrorism!");
      c.set("OS.IconName", "/dev/images/en/btnadd_en.gif"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control,Callback</font><br>
   
   <br>
   <input type=text name="Junk2" value="[root],[non-partitions]" size=50>
   <% c.set("OS.Control", "Junk2"); 
      c.set("OS.TypeFilter", "[root],[non-partitions]"); 
      c.set("OS.AltText", "Down with terrorism!"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control</font><br>
   
   <br>
   <input type=text name="Junk2a" value="[root],[partitions]" size=50>
   <% c.set("OS.Control", "Junk2a"); 
      c.set("OS.TypeFilter", "[root],[partitions]"); 
      c.set("OS.AltText", "Down with terrorism!"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control</font><br>
   
   <br>
   <input type=text name="Junk3" value="*,[root],[this],[public],[containers]" size=50>
   <% c.set("OS.Control", "Junk3"); 
      c.set("OS.TypeFilter", "*,[root],[this],[public],[containers]"); 
      c.set("OS.AltText", "Down with terrorism!"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control</font><br>
   
   <br>
   <input type=text name="Junk4" value="" size=50>
   <% c.set("OS.Control", "Junk4"); 
      c.set("OS.TypeFilter", ""); 
      c.set("OS.AltText", "Down with terrorism!"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control</font><br>
   
   <br>
   <input type=text name="Junk5" value="[root]" size=50>
   <% c.set("OS.Control", "Junk5"); 
      c.set("OS.TypeFilter", "[root]"); 
      c.set("OS.AltText", "Down with terrorism!"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Control</font><br>
   
   <br>
   <input type=text name="Junk15" value="dynamicGroupAux" size=50>
   <% c.set("OS.Control", "Junk15"); 
      c.set("OS.TypeFilter", "dynamicGroupAux"); 
      c.set("OS.AltText", "Searching for auxClasses");
      c.set("OS.History", "true"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>auxClasses</font><br>
   
   <br>
   <input type=text name="Junk6" value="User,[root],[this],[public]" size=50>
   <% c.set("OS.Control", "Junk6"); 
      c.set("OS.TypeFilter", "User,[root],[this],[public]"); 
      c.set("OS.AltText", "Down with French judges!"); 
      c.set("OS.Mode", "Search"); 
      c.set("OS.SearchOnStartup", "true"); 
      c.set("OS.AdvancedSelection", "true"); 
      c.set("OS.ResultsPerPage", "100"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Search,SearchOnStartup,AdvancedSearch,ResultsPerPage=100</font><br>
   <br>
   <input type=text name="Junk7" value="User,[root],[this],[public]" size=50>
   <% c.set("OS.Control", "Junk7"); 
      c.set("OS.TypeFilter", "User,[root],[this],[public]"); 
      c.set("OS.AltText", "Down with terrorism!"); 
      c.set("OS.Mode", "Search"); 
      c.set("OS.MultiSelect", "true"); 
      c.set("OS.ResultsPerPage", "1000"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Search,Multiselect,Control,ResultsPerPage=1000</font><br>
   <br>
   <input type=text name="Junk8" value="*,[root],[this],[public]" size=50>
   <% c.set("OS.Control", "Junk8"); 
      c.set("OS.TypeFilter", "*,[root],[this],[public]"); 
      c.set("OS.AltText", "Down with terrorism!"); 
      c.set("OS.Mode", "Search"); 
      c.set("OS.MultiSelect", "true"); %>
   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Search,Multiselect,Control</font><br>

   <br>
   <input type=text name="Junk20" value="User" size=50>
   <% c.set("OS.Control", "Junk20");
      c.set("OS.TypeFilter", "User");
      c.set("OS.AltText", "Down with terrorism!");
      c.set("OS.Text", "Button");
      c.set("OS.Mode", "Browse");
      c.set("OS.History", "true");
      c.set("OS.MultiSelect", "true"); %>
   <jsp:include page='<%= c.getPath("dev/OSBtn_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Browse,Multiselect,Control</font><br>

   <br>
   <input type=text name="Junk21" value="rbsCollection2" size=50>
   <% c.set("OS.Control", "Junk21");
      c.set("OS.TypeFilter", "rbsCollection2");
      c.set("OS.Text", "Link");
      c.set("OS.Mode", "Browse");
      c.set("OS.History", "true");
      c.set("OS.MultiSelect", "true"); %>
   <jsp:include page='<%= c.getPath("dev/OSLink_inc.jsp") %>' flush="true" />
   <br>&nbsp;&nbsp;<font size=-4>Browse,Multiselect,Control</font><br>


   <br>
   <br>
   <select name="Types">
   <option value="User">User
   <option value="Organization">Organization
   <option value="Organizational Unit">Organizational Unit
   </select>

   <% c.set("AS.Types", "");
      c.set("AS.TypesCallBack", "getTypes"); 
      c.set("AS.InitialCriterion", ""); 
      c.set("AS.InitialCriterionCallBack", "getInitialCriterion"); 
      c.set("AS.Control", ""); 
      c.set("AS.ControlCallBack", "saveInitialCriterion"); 
      c.set("AS.IsASAllowed", ""); 
      c.set("AS.TypeInfoCallBack", ""); 
      c.set("AS.ValidateSyntax", ""); %> <!--not yet supported-->
   <% c.set("AS.AltText", "Advanced Selection Criterion"); 
      c.set("AS.IconName", ""); %>
   <jsp:include page='<%= c.getPath("dev/AS_inc.jsp") %>' flush="true" />
   
   </FONT>
</form>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>
