<%@  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("CreateAttr.Title")) %></TITLE>
<LINK rel="stylesheet" href="<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>" type="text/css">

</HEAD>
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />

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

// Global variable to check if the sized check box is disabled or not
var sizeFlag = true;

function previousSelected()
{
   document.AttrFlagsForm.elements["merge"].value="base.CreateAttrSyntax";
   document.AttrFlagsForm.elements["nextState"].value="getNewAttrFlags";
   document.AttrFlagsForm.elements["Task.SelectedButton"].value="previousSelected";
   document.AttrFlagsForm.submit();
}

function nextSelected()
{
   if (getFlags())
   {
      document.AttrFlagsForm.elements["nextState"].value="getNewAttrFlags";
      document.AttrFlagsForm.elements["Task.SelectedButton"].value="nextSelected";
      document.AttrFlagsForm.submit();
   }
}

function disableSized()
{
   if ((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)>=4))
   {
      var enteredSyntax = document.AttrFlagsForm.elements["EnteredAttrSyntax"].value;
      if(enteredSyntax == "Case Exact String" || enteredSyntax == "Case Ignore String" ||
      enteredSyntax == "Integer" || enteredSyntax == "Interval" ||
      enteredSyntax == "Numeric String" || enteredSyntax == "Octet String" ||
      enteredSyntax == "Path" || enteredSyntax == "Printable String" ||
      enteredSyntax == "Telephone Number")
      {
         return true;
      }
      else
      {
         return false;
      }
   }
   return true;
}

function disableSingle()
{
   if ((navigator.appName=="Netscape")&&(parseInt(navigator.appVersion)>=4))
   {
      var enteredSyntax = document.AttrFlagsForm.elements["EnteredAttrSyntax"].value;
      if(enteredSyntax == "Boolean" || enteredSyntax == "Stream" ||
      enteredSyntax == "Counter")
      {
         return false;
      }
   }
   return true;
}

function disableCheckBox()
{
   var enteredSyntax = document.AttrFlagsForm.elements["EnteredAttrSyntax"].value;
   if(enteredSyntax == "Case Exact String" || enteredSyntax == "Case Ignore String" ||
   enteredSyntax == "Integer" || enteredSyntax == "Interval" ||
   enteredSyntax == "Numeric String" || enteredSyntax == "Octet String" ||
   enteredSyntax == "Path" || enteredSyntax == "Printable String" ||
   enteredSyntax == "Telephone Number")
   {
      document.AttrFlagsForm.sized.disable = false;
      sizeFlag = false;
   }
   else
   {
      document.AttrFlagsForm.sized.disabled = true;
   }
   if(enteredSyntax == "Boolean" || enteredSyntax == "Stream" ||
   enteredSyntax == "Counter")
   {
      document.AttrFlagsForm.single.checked = true;
      document.AttrFlagsForm.elements["SingleValued"].value = "SingleValued";
      document.AttrFlagsForm.single.disabled = true;
   }
   else
   {
      document.AttrFlagsForm.single.disabled = false;
   }
   return true;
}

function getFlags()
{
   var strFlags="";
   var syntaxEntered = document.AttrFlagsForm.elements["EnteredAttrSyntax"].value;
   if (document.AttrFlagsForm.single.checked)
   {
      document.AttrFlagsForm.elements["SingleValued"].value = "SingleValued";
      strFlags += document.AttrFlagsForm.single.value +",";
   }
   if (!document.AttrFlagsForm.single.checked)
   {
      document.AttrFlagsForm.elements["SingleValued"].value = "";
   }
   if (document.AttrFlagsForm.sync.checked)
   {
      document.AttrFlagsForm.elements["SyncImmediately"].value = "SyncImmediately";
      strFlags += document.AttrFlagsForm.sync.value +",";
   }
   if (!document.AttrFlagsForm.sync.checked)
   {
      document.AttrFlagsForm.elements["SyncImmediately"].value = "";
   }
   if (document.AttrFlagsForm.read.checked)
   {
      document.AttrFlagsForm.elements["PublicRead"].value = "PublicRead";
      strFlags += document.AttrFlagsForm.read.value +",";
   }
   if (!document.AttrFlagsForm.read.checked)
   {
      document.AttrFlagsForm.elements["PublicRead"].value = "";
   }
   if (document.AttrFlagsForm.write.checked)
   {
      document.AttrFlagsForm.elements["WriteManaged"].value = "WriteManaged";
      strFlags += document.AttrFlagsForm.write.value+",";
   }
   if (!document.AttrFlagsForm.write.checked)
   {
      document.AttrFlagsForm.elements["WriteManaged"].value = "";
   }
   if (document.AttrFlagsForm.replica.checked)
   {
      document.AttrFlagsForm.elements["PerReplica"].value = "PerReplica";
      strFlags += document.AttrFlagsForm.replica.value +",";
   }
   if (!document.AttrFlagsForm.replica.checked)
   {
      document.AttrFlagsForm.elements["PerReplica"].value = "";
   }
   if (document.AttrFlagsForm.sized.checked)
   {
      strFlags += document.AttrFlagsForm.sized.value + ",";
      document.AttrFlagsForm.elements["Sized"].value = "Sized";
   }
   if (!document.AttrFlagsForm.sized.checked)
   {
      document.AttrFlagsForm.elements["Sized"].value = "";
   }
   if(syntaxEntered == "Case Exact String" || syntaxEntered == "Case Ignore String" ||
   syntaxEntered == "Numeric String" || syntaxEntered == "Printable String" ||
   syntaxEntered == "Telephone Number")
   {
      document.AttrFlagsForm.elements["String"].value = "String"
      strFlags += "String" + ",";
   }
   document.AttrFlagsForm.elements["whichFlags"].value = strFlags;
   return true;
}

function restore()
{
   whichFlags=document.AttrFlagsForm.elements["whichFlags"].value;
   var whichFlagsArray = whichFlags.split(",");
   var length = whichFlagsArray.length;
   for (var i=0; i<whichFlagsArray.length; i++)
   {
      if(whichFlagsArray[i] == "SingleValued")
      {
         document.AttrFlagsForm.single.checked = true;
      }
      if(whichFlagsArray[i] == "SyncImmediately")
      {
         document.AttrFlagsForm.sync.checked = true;
      }
      if(whichFlagsArray[i] == "PublicRead")
      {
          document.AttrFlagsForm.read.checked = true;
      }
      if(whichFlagsArray[i] == "WriteManaged")
      {
         document.AttrFlagsForm.write.checked = true;
      }
      if(whichFlagsArray[i] == "PerReplica")
      {
         document.AttrFlagsForm.replica.checked = true;
      }
      if(whichFlagsArray[i] == "Sized")
      {
         document.AttrFlagsForm.sized.checked = true;
      }
   }
}

function setFormFocus()
{
   if(document.AttrFlagsForm.single.disabled == false)
   {	
   		document.AttrFlagsForm.single.focus();
   }
   else
   {
		document.AttrFlagsForm.sync.focus();
   }	
   return true;
}

</SCRIPT>
</HEAD>

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

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

<INPUT type="hidden" name="merge" value="">
<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="">
<INPUT type="hidden" name="Task.SelectedButton" value="">
<INPUT type="hidden" name="taskId" value="<%= c.var("taskId") %>">
<INPUT type="hidden" name="Sch_AttrSyntax.Count" value="<%= c.var("Sch_AttrSyntax.Count") %>">
<INPUT type="hidden" name="SyntaxNames" value="<%= c.var("SyntaxNames") %>">
<INPUT type="hidden" name="EnteredAttrName" value="<%= c.var("EnteredAttrName") %>">
<INPUT type="hidden" name="EnteredAttrID" value="<%= c.var("EnteredAttrID") %>">
<INPUT type="hidden" name="EnteredAttrSyntax" value="<%= c.var("EnteredAttrSyntax") %>">
<INPUT type="hidden" name="SingleValued" value="<%= c.var("SingleValued") %>">
<INPUT type="hidden" name="SyncImmediately" value="<%= c.var("SyncImmediately") %>">
<INPUT type="hidden" name="PublicRead" value="<%= c.var("PublicRead") %>">
<INPUT type="hidden" name="WriteManaged" value="<%= c.var("WriteManged") %>">
<INPUT type="hidden" name="PerReplica" value="<%= c.var("PerReplica") %>">
<INPUT type="hidden" name="Sized" value="<%= c.var("Sized") %>">
<INPUT type="hidden" name="String" value="<%= c.var("String") %>">
<INPUT type="hidden" name="whichFlags" value="<%= c.var("whichFlags") %>">
<% c.set("WizardHeader.title", c.toDisplay(c.string("CreateAttr.Title"))); 
   c.set("WizardHeader.subtitle", c.toDisplay(c.string("Schema.Step3"))); 
   c.set("WizardHeader.instruction", c.toDisplay(c.string("CreateAttr.Instr3"))); 
   c.set("WizardHeader.helpFile", "base/schemacreate_attr_wizard_flags.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">
        <INPUT type="checkbox" name="single" value="SingleValued" onClick="return disableSingle()"> <%= c.toDisplay(c.string("CreateAttr.SingleValued")) %> </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
         <INPUT type="checkbox" name="sync" value="SyncImmediately"> <%= c.toDisplay(c.string("CreateAttr.SynchronizeImmediately")) %></TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
         <INPUT type="checkbox" name="read" value="PublicRead"> <%= c.toDisplay(c.string("CreateAttr.PublicRead")) %> </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
         <INPUT type="checkbox" name="write" value="WriteManaged"> <%= c.toDisplay(c.string("CreateAttr.WriteManaged")) %> </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
         <INPUT type="checkbox" name="replica" value="PerReplica"> <%= c.toDisplay(c.string("CreateAttr.PerReplica")) %>  </TD>
   </TR>
   <TR valign="baseline">
      <TD class="mediumtext">
         <INPUT type="checkbox" name="sized" value="Sized"onClick="return disableSized()"> <%= c.toDisplay(c.string("CreateAttr.Sized")) %> </TD>
   </TR>
</TABLE>
<BR>

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

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0" >
   <TR>
      <TD><jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" /></TD>
   </TR>
   <TR>
      <TD>
         <A HREF="#"onClick="javascript:previousSelected();return false"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Back.image") %>" alt="<%= c.toDisplay(c.string("Button.Back.alt")) %>" title="<%= c.toDisplay(c.string("Button.Back.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>
