<%@  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);
   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/OSScripts_inc.jsp") %>' flush="true" />
<script language="JavaScript">


   <% c.set("SYN_CE_STRING", "2"); 
      c.set("SYN_TYPED_NAME", "25"); 	
      c.set("SYN_CI_STRING", "3"); 
      c.set("SYN_NU_STRING", "5"); 	
      c.set("SYN_CLASS_NAME", "20"); 
      c.set("SYN_EMAIL_ADDRESS", "14"); 	
      c.set("SYN_PR_STRING", "4"); 

      c.set("SYN_BOOLEAN", "7"); 
	
	   c.set("SYN_COUNTER", "22"); 
      c.set("SYN_INTEGER", "8"); 
	   c.set("SYN_INTERVAL", "27"); 
			
      c.set("SYN_DIST_NAME", "1"); 

	   c.set("SYN_CI_LIST", "6"); 
	
      c.set("SYN_FAX_NUMBER", "11"); 
      c.set("SYN_TEL_NUMBER", "10"); 

      c.set("SYN_NET_ADDRESS", "12"); 
	
      c.set("SYN_PATH", "15"); 	

      c.set("SYN_PO_ADDRESS", "18"); 

      c.set("SYN_STREAM", "21"); 

      c.set("SYN_TIME", "24"); 
      c.set("SYN_TIMESTAMP", "19"); 

      c.set("SYN_OBJECT_ACL", "17"); 
      c.set("SYN_OCTET_LIST", "13"); 
      c.set("SYN_OCTET_STRING", "9"); 
	
      c.set("SYN_HOLD", "26"); 
	   c.set("SYN_BACK_LINK", "23"); 
      c.set("SYN_REPLICA_POINTER", "16"); 	
      c.set("SYN_UNKNOWN", "0"); %>
   	
   function nextSelected()
   {
      document.CreateForm.elements["merge"].value="dev.GenConf";
      document.CreateForm.elements["nextState"].value="doCreateObject";
      document.CreateForm.elements["Task.SelectedButton"].value="nextSelected";

/*		if (checkCreateNullInput() == false)
		{
			document.CreateForm.elements["merge"].value="CreatorForm";
        	document.CreateForm.elements["nextState"].value="";
		}
*/		
//		getAttr();
      document.CreateForm.submit();
   }
	
   function cancelSelected()
   {
      document.CreateForm.elements["taskId"].value="fw.HomePage";
      document.CreateForm.elements["merge"].value="fw.HomePage";
      document.CreateForm.elements["nextState"].value="fw.HomePage";
	  document.CreateForm.elements["Task.SelectedButton"].value="cancelSelected";
	  document.CreateForm.submit();
   }
	
   function previousSelected()
   {
      document.CreateForm.elements["merge"].value="fw.CreatorClass";
      document.CreateForm.elements["nextState"].value="";
      document.CreateForm.elements["Task.SelectedButton"].value="previousSelected";
      document.CreateForm.submit();
   }
   

   function checkCreateNullInput()
   {
      var strContainerInput = document.CreateForm.elements["ObjectContext"].value;

      if ((null == strContainerInput) || (0 == strContainerInput.length))
      {
         alert("<%= c.string("TaskPI.CreateOrg.InvalidContainer") %>");
         return false;
      }
      return true;
   }

	function getAttr(listOfAttr)
   {
		var list = listOfAttr;
	
		var option = list.options;
     	var attrCount = option.length;	
		newList = new Array(attrCount);
		for (var i=0; i < attrCount; i++) 
	   {
				//alert("");
		}
   } // end of function
 

   function setFocus()
   {
      if(document.CreateForm.elements["attr_<%= c.var("AttrList."+"0"+ ".Name") %>"] != null)
      {
         document.CreateForm.elements["attr_<%= c.var("AttrList."+"0"+ ".Name") %>"].focus();
      }
   }
   
  	function validateName(nameField)
   {
		var name = document.CreateForm.elements[nameField].value;
		return true;
   }

	function validateBoolean(boolValue)
	{	
		var opt = document.CreateForm.booleanField.options;
		if(opt[0].selected)
		{
			boolValue = document.CreateForm.elements["booleanField"].value;
		}
		else
		{
			boolValue = document.CreateForm.elements["booleanField"].value;
		}				
		return true;
	}

	function validateCounter(counterValue)
	{	
		var counter = document.CreateForm.elements["counterField"].value;
		var valid = "0123456789"
		var ok = "yes";
		var temp;
		
		for (var i = 0; i < counter.length; i++)
		{
			temp = "" + document.CreateForm.elements["counterField"].value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			ok = "no";
		}
		if (ok == "no")
		{
			alert("Invalid entry!  Only numbers are accepted!");
			document.CreateForm.elements["counterField"].focus();
			document.CreateForm.elements["counterField"].select();
   	}
		counterValue = counter;
		return true;
	}

	function validateDistinguished()
	{	
		var dist = document.CreateForm.elements["distinguishedField"].value;
		if(dist)
		{
			//alert("Dist Valid");
		}
		else
		{
			alert("Dist Invalid");
		}				
		return true;
	}

	
</script>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#ffffff" onLoad="setFocus();returnFromOS();">
<FORM name="CreateForm" 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="doCreateObject">
   <input type=hidden name="Task.SelectedButton" value="">
   <input type=hidden name="SelectedClass" value="<%= c.var("SelectedClass") %>">
   <input type=hidden name="TranslatedClass" value="<%= c.var("TranslatedClass") %>">
   <input type=hidden name="AttrList" value="<%= c.var("AttrList") %>">
   <input type=hidden name="GifName" value="<%= c.var("GifName") %>">
		
   <% c.set("TaskHeader.title", c.formatMessage(c.string("Creator.Create"), new String[]{c.var("TranslatedClass")})); 
      c.set("TaskHeader.iconUrl", c.plus("dir/", c.var("GifName"))); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>


<%/*
   <!------------ debug ------------>
   DEBUG:   
   <TABLE BORDER="1" CELLPADDING="3px">
        <TR>
            <TD>Index</TD>
            <TD>DisplayName</TD>
            <TD>Name</TD>
            <TD>Syntax</TD>
        </TR>
        {SET j = 0}
        {WHILE j < AttrList.Count}
        <TR>
            <TD>{VAR j}</TD>
            <TD>{VAR AttrList[j].DisplayName}</TD>
            <TD>{VAR AttrList[j].Name}</TD>
            <TD>{VAR AttrList[j].Syntax}</TD>
        </TR>
        {INC j}					
        {ENDWHILE}
	</TABLE>
 */ 
    
    
    
      c.set("i", "0"); 
      while (c.lt(c.var("i"), c.var("AttrList.Count"))) { %>
      <FONT face="Helvetica,Arial" size=-1>
   	<NOBR><%= c.var("AttrList."+c.var("i")+ ".DisplayName") %>:</NOBR><BR>
				
		<% if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_CI_STRING")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_TYPED_NAME")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_NU_STRING")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_CLASS_NAME")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_EMAIL_ADDRESS")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_PR_STRING"))) { %>
		   <input type=text name="attr_<%= c.var("AttrList."+c.var("i")+ ".Name") %>" onchange="javascript:validateName( 'attr_<%= c.var("AttrList."+c.var("i")+ ".Name") %>' )" value="" size=35 maxlength=64><BR>

			
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_BOOLEAN"))) { %>
			<SELECT name="booleanField" onchange="javascript:validateBoolean(<%= c.var("AttrList."+c.var("i")+ ".attrValue") %>)">			
				<OPTION value="true" SELECTED>True
				<OPTION value="false" >False
			</SELECT><BR>
				
				
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_COUNTER")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_INTEGER")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_INTERVAL"))) { %>
		   <input type=text name="counterField" onchange="javascript:validateCounter(<%= c.var("AttrList."+c.var("i")+ ".attrValue") %>)" value="matt" size=10 maxlength=64><BR>
					
													
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_DIST_NAME"))) { %>
  			<input type=text name="distinguishedField" onchange="javascript:validateDistinguished()" value="" size=35 maxlength=64>
			<% c.set("OS.Control", "ObjectName"); 
			   c.set("OS.TypeFilter", "*"); %>
			<jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" /><BR><BR>
				
				
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_CI_LIST"))) { %>
			<BR><NOBR>SYN_CI_LIST:</NOBR><BR>
	
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_FAX_NUMBER")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_TEL_NUMBER"))) { %>
			<BR><NOBR>SYN_FAX_NUMBER:</NOBR><BR>
					
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_NET_ADDRESS"))) { %>
			<BR><NOBR>SYN_NET_ADDRESS:</NOBR><BR>
						
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_PATH"))) { %>	
			<BR><NOBR>SYN_PATH:</NOBR><BR>
					
	   <% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_PO_ADDRESS"))) { %>
			<BR><NOBR>SYN_PO_ADDRESS:</NOBR><BR>				

		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_STREAM"))) { %>
			<BR><NOBR>SYN_STREAM:</NOBR><BR>				

		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_TIME")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_TIMESTAMP"))) { %>
			<BR><NOBR>SYN_TIME:</NOBR><BR>							

		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_OBJECT_ACL")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_OCTET_LIST")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_OCTET_STRING"))) { %>
   		<BR><NOBR>SYN_OCTECT_STRING:</NOBR><BR>														
	
		<% } else if (c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_HOLD")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_BACK_LINK")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_REPLICA_POINTER")) || c.var("AttrList."+c.var("i")+ ".Syntax").equals(c.var("SYN_UNKNOWN"))) { %>
			<BR><NOBR>SYN_UNKNOWN:</NOBR><BR>															
				

		<% } %> <!-- end of if different syntaxes -->
				
				
      <% c.inc("i"); 					
      } %>


	<BR><NOBR><%= c.string("Creator.Context") %></NOBR><BR>
   <input type=text name="ObjectContext" value="" size=35>
	<% c.set("OS.Control", "ObjectContext"); 
	   c.set("OS.TypeFilter", c.var("CreatorSearchFilter")); %>
	<jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" /><BR><BR>

   <!--a href="javascript:previousSelected()"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Previous.image") %>" alt="<%= c.string("Button.Previous.Alt") %>" title="<%= c.string("Button.Previous.Alt") %>" border=0></a-->
    <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" />
</font>
	<hr size=2 color=#458ab9>
</FORM>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY>
<% if (c.var("Browser.name").equals("MSIE")) { %>
   <!-- Added this to get around caching problem and not hitting the server i IE -->
   <HEAD>
      <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
      <META HTTP-EQUIV="Expires" CONTENT="-1">
   </HEAD>
<% } %>

</HTML>

