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

<html>
<head>
<title><%= c.string("Creator.CreateTitle") %></title>
<LINK href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" rel="styleSheet" type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/MoveListItems_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/OSScripts_inc.jsp") %>' flush="true" />

<script language="JavaScript">

   function setFocus( )
   {
      document.ClassListForm.AvailableClasses.focus();
      var Opt = document.ClassListForm.AvailableClasses.options;
      if (Opt.length > 0)
      {
         document.ClassListForm.AvailableClasses[0].selected = true;
      }

      <% if (FwUtils.canConfigureiManager(request)) { %>
         if (document.ClassListForm.showAllClassesHidden.value == "true")
         {
            document.ClassListForm.ShowAllClasses.checked = true;
         }
         else
         {
            document.ClassListForm.ShowAllClasses.checked = false;
         }
      <% } %>
   }

   function nextSelected()
   {
      var Opt = document.ClassListForm.AvailableClasses.options;
      if (Opt.length == 0)
      {
         cancelSelected();
         return false;
      }

      var selectedItem = -1;
      selectedItem 	= document.ClassListForm.AvailableClasses.selectedIndex;
      if (selectedItem == -1)
      {
         selectedItem = 0;
      }
      document.ClassListForm.AvailableClasses[selectedItem].selected = true;

      // get the untranslated name from the class list
      tempText = untranslatedClasses[selectedItem];
      var selectedText = "";
      selectedText = urlEncode(tempText);
      document.ClassListForm.elements["SelectedClass"].value = selectedText;
      document.ClassListForm.elements["nextState"].value="launchCreator";
      document.ClassListForm.elements["Task.SelectedButton"].value="nextSelected";

      var createObjectUrl = document.ClassListForm.AvailableClasses[selectedItem].value;
      window.location = createObjectUrl + "&targetNames=<%= c.urlEncode(c.var("targetNames")) %>";
   }

   function cancelSelected()
   {
      document.ClassListForm.elements["taskId"].value="fw.HomePage";
      document.ClassListForm.elements["merge"].value="fw.HomePage";
      document.ClassListForm.elements["nextState"].value="fw.HomePage";
      document.ClassListForm.elements["Task.SelectedButton"].value="cancelSelected";
      document.ClassListForm.submit();
   }

	function checkDefaultKey(evt)
   {
      var keyCode = evt.which ? evt.which : evt.keyCode;
      // 13 is the Enter key code
      if (keyCode == 13)
      {
         nextSelected();
         return false;
      }
      return true;
   }

   function showAllClasses()
   {
      var url = "frameservice?NPService=fw.LaunchService&NPAction=Delegate&delegate=base.CreateObjects&launcher=fw.HomePage&lifecycle=Recreate&merge=fw.CreatorClass&nextState=initialState&targetNames=<%= c.var("targetNames") %>";
      if (document.ClassListForm.ShowAllClasses.checked == true)
      {
         url = url + "&showAllClasses=true";
         document.ClassListForm.showAllClassesHidden.value="true";
      }
      else
      {
         document.ClassListForm.showAllClassesHidden.value="false";
      }
      window.location=url;
   }


   var untranslatedClasses =
   [
	<% c.set("j", "0");
	   while (c.lt(c.var("j"), c.var("Sch_ClassList.Count"))) { %>
      "<%= c.toScript(c.var("Sch_ClassList.name."+c.var("j"))) %>"
      <% c.inc("j");
         if (c.lt(c.var("j"), c.var("Sch_ClassList.Count"))) { %>,<% }
  	   } %>
   ];

</script>
</head>

<body text="#000000" link="#000000" vlink="#000000" alink="#000000" bgcolor="#FFFFFF" onload="setFocus()">
<form name="ClassListForm" method=post action="webacc">


   <input type="hidden" name="merge" value="">
   <input type="hidden" name="error" value="dev.GenErr">
   <input type="hidden" name="nextState" value="">
   <input type="hidden" name="taskId" value="<%= c.var("taskId") %>">
   <input type="hidden" name="Task.SelectedButton" value="">
   <input type="hidden" name="SelectedClass" value="<%= c.toTag(c.var("SelectedClass")) %>">
   <input type="hidden" name="targetNames" value="<%= c.var("targetNames") %>">
   <input type="hidden" name="showAllClassesHidden" value="<%= c.var("showAllClassesHidden") %>">


   <% c.set("TaskHeader.title", c.string("Creator.CreateTitle"));
      c.set("TaskHeader.iconUrl", c.plus("dir/", c.string("GenericTask.image"))); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>

   <p class="instructions"><%= c.string("Creator.SelectPrompt") %></p>

   <table name="ClassListTable" >
   <tr>
	   <td  class="mediumtext"><%= c.string("Creator.AvailableClasses") %></td>
   </tr>
   <tr>
	   <td>
		   <select name="AvailableClasses" size=10 style="WIDTH: 340px" onkeypress="return checkDefaultKey(event)">
		      <% c.set("i", "0");
		         while (c.lt(c.var("i"), c.var("Sch_ClassList.Count"))) { %>
		         <option value="<%= c.toTag(c.var("Sch_ClassList.createObjectUrl."+c.var("i"))) %>"><%= c.var("Sch_ClassList.displayname."+c.var("i")) %>
 		         <% c.inc("i");
		     	   } %>
		  	</select>
	   </td>
   </tr>
   </table>
   <br>

   <% if (FwUtils.canConfigureiManager(request)) { %>
   
      <table>
      <tr>
         <td class="mediumtext"><input type="checkbox" name="ShowAllClasses" value="" onclick='showAllClasses()'><%= c.string("Creator.ShowAllClasses") %></td>
      </tr>
      <tr>
         <td class="smalltext2d"><%= c.string("Creator.ShowAllClassesNote") %></td>
      </tr>
      </table>
   
   <% } %>

   <IFRAME src="/nps/Empty.html" style="visibility: hidden" name="exchangerFrame" id="exchangerFrame" width="0" height="0" marginwidth="0" marginheight="0"></IFRAME>

   <br>
   <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
   <A HREF="#"onClick="javascript:nextSelected();return false"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>" alt="<%= c.string("Button.OK.alt") %>" title="<%= c.string("Button.OK.alt") %>" border=0></a>
   <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
</form>
</body></html>
