<%@  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("BaseResources"); %>
<HTML>
<HEAD>
<TITLE><%= c.toDisplay(c.string("CreateClass.Title")) %></TITLE>
<LINK rel="stylesheet" href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" type="text/css">
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />
<jsp:include page='<%= c.getPath("dev/ValidateIntegerScripts_inc.jsp") %>' flush="true" />
</HEAD>

<!-------------------------JAVA SCRIPT BEGINS HERE------------------------------------------->
<SCRIPT language="JavaScript">

function nextSelected()
{
   // to validate the ASN1ID since Netscape had problems with onblur
   if (!validateASN1IDString(document.ClassNameForm.ASN1ID, "<%= c.string("UIHandler.OnlyDigits") %> "))
   {
      return false;
   }

   if(document.ClassNameForm.NewClassName.value == "")
   {
      alert("<%= c.toScript(c.string("CreateClass.MustEnterName")) %>");
      document.ClassNameForm.NewClassName.focus();
   }
   else
   {
      if (doesNameExist())
      {
         alert ("<%= c.toScript(c.string("CreateClass.NameAlreadyExists")) %>");
         // Should probably reset the text box here.
         document.ClassNameForm.NewClassName.focus();
      }
      else
      {
         document.ClassNameForm.elements["EnteredClassName"].value = document.ClassNameForm.NewClassName.value;
         document.ClassNameForm.elements["EnteredClassID"].value = document.ClassNameForm.ASN1ID.value;
         document.ClassNameForm.elements["merge"].value="base.CreateClsFlags";
         document.ClassNameForm.elements["nextState"].value="getNewClassName";
         document.ClassNameForm.elements["Task.SelectedButton"].value="nextSelected";
         document.ClassNameForm.submit();
      }
   }
}

// Checking to see if the entered name is already in DS.
function doesNameExist()
{
   var className  =  document.ClassNameForm.elements["ClassNames"].value;
   var newClsName = document.ClassNameForm.NewClassName.value;
   classNameArray = new Array(document.ClassNameForm.elements["ClassCount"].value);
   classNameArray = className.split("\,");
   newClsName = newClsName.toUpperCase(newClsName);
   for (i=0; i < classNameArray.length; i++)
   {
      tmpString = classNameArray[i].toUpperCase(classNameArray[i])
      if(newClsName == tmpString)
      {
         return true;
      }
   }
   return false;
}// end of function

// Need to put the id back as well
function putClassName()
{
   var classname;
   classname = document.ClassNameForm.elements["EnteredClassName"].value;
   document.ClassNameForm.NewClassName.value=classname;
   return true;
}

function setFormFocus()
{
   document.ClassNameForm.NewClassName.focus();
}

// Check to make sure that user only inputs numbers and periods
var focused=false;
if (document.captureEvents)
{
   document.captureEvents(Event.KEYPRESS);
}
   document.onkeypress=function(e){
   if (!focused)
   {
      return true;
   }
   if (!e && event)
   {
      e={which:event.keyCode};
   }
   if (e.which != 46 && (e.which < 48 || e.which >57))
   {
      return false;
   }
}
// Creating new window to show the help information information
var win=null;
function NewWindow(mypage,myname,w,h,scroll)
{
   LeftPosition=(screen.width)?(screen.width-w)/2:100;
   TopPosition=(screen.height)?(screen.height-h)/2:100;
   settings='width='+w+',height='+h+',top='+TopPosition+',left='+ LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
   win=window.open(mypage,myname,settings);
   if(win.focus)
   {
      win.focus();
   }
}

</SCRIPT>

<BODY text="#000000" link="#000000" vlink="#000000" alink="#000000" bgcolor="#FFFFFF" onload="putClassName();setFormFocus();">
<FORM name="ClassNameForm" method=post action="webacc">

<!------------------------ BEGIN WEBACCESS VARIABLES ---------------------------->

<INPUT type="hidden" name="error" value="dev.GenErr">
<INPUT type="hidden" name="merge" value="">
<INPUT type="hidden" name="User.context" value="<%= c.var("User.context") %>">
<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="EnteredClassName" value="<%= c.var("EnteredClassName") %>">
<INPUT type="hidden" name="EnteredClassID" value="<%= c.var("EnteredClassID") %>">
<INPUT type="hidden" name="ClassNames" value="<%= c.var("ClassNames") %>">
<INPUT type="hidden" name="ClassCount" value="<%= c.var("ClassCount") %>">

<% c.set("WizardHeader.title", c.toDisplay(c.string("CreateClass.Title")));
   c.set("WizardHeader.subtitle", c.toDisplay(c.string("Schema.Step1")));
   c.set("WizardHeader.instruction", c.toDisplay(c.string("CreateClass.Instr1")));
   c.set("WizardHeader.helpFile", "base/schemacreate_class_wizard_name.html"); %>
<jsp:include page='<%= c.getPath("dev/WizardHeader_inc.jsp") %>' flush="true" />

<!----------------------------------------- CONTENT TABLE ------------------------------------>
<TABLE border="0" cellspacing="0" cellpadding="2">
   <TR valign="baseline">
      <TD class="mediumtext">
      <%= c.toDisplay(c.string("SchemaClassName")) %>
      </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
      <INPUT type="text" name="NewClassName" Size="25" Maxlength="32">
      </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
      <%= c.toDisplay(c.string("SchemaID")) %>
      </TD>
   </TR>
   <TR valign="baseline">
      <TD class="smalltext2d">
         <INPUT type="text" name="ASN1ID" Size="25" onChange='validateASN1IDString(this, "<%= c.string("UIHandler.OnlyDigits") %> ");'>&nbsp; <%= c.toDisplay(c.string("CreateAttr.Optional")) %>
      </TD>
   </TR>
</TABLE>

<!------------------------- BUTTON TABLE --------------------------->

<TABLE width="100%" border="0" cellspacing="0" cellpadding="2" height="25">
   <TR><TD>&nbsp;</TD>
   </TR>
   <TR>
      <TD><jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" /></TD>
   </TR>
   <TR>
      <TD>
         <A HREF="#"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.BackDisabled.image") %>" alt="<%= c.toDisplay(c.string("Button.BackDisabled.alt")) %>" title="<%= c.toDisplay(c.string("Button.BackDisabled.alt")) %>" border=0></A>
         <A HREF="#"onClick="javascript:nextSelected();return false"> <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Next.image") %>" alt="<%= c.toDisplay(c.string("Button.Next.alt")) %>" title="<%= c.toDisplay(c.string("Button.Next.alt")) %>" border=0></A>
         <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
      </TD>
   </TR>
</TABLE>
</FORM>
</BODY></HTML>

