<%@  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.toHTML(c.string("RBSManagement.CreateBookTitle")) %></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">


   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageLoad()
    {
        document.CreateBookForm.BookName.focus();

   	  if (document.CreateBookForm.mooEnabledCheckBox.value == "true")
        {
            document.CreateBookForm.elements["mooEnabled"].checked = true;
        }
        else
        {
            document.CreateBookForm.elements["mooEnabled"].checked = false;
        }

        <% if (c.var("RBSAdmin_TaskDelegate").equals("taskDelegate") == true) { %>
            document.CreateBookForm.ModuleList.selectedIndex = <%= c.var("SelectedModuleIndex") %>;
        <% } %>
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function createBookFormNameChanged()
    {
        document.CreateBookForm.elements["CreateBookFormNameChanged"].value = "true";
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function createBookFormDescChanged()
    {
        document.CreateBookForm.elements["CreateBookFormDescChanged"].value = "true";
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function createBookFormContextChanged()
    {
        document.CreateBookForm.elements["CreateBookFormContextChanged"].value = "true";
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function createBookFormMooEnabledChanged()
    {
        document.CreateBookForm.elements["CreateBookFormMooEnabledChanged"].value = "true";
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function createBookFormContextChangedCallBack(controlName, results)
    {
        document.CreateBookForm.elements["CreateBookFormContextChanged"].value = "true";
        document.CreateBookForm.elements[controlName].value=results;
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageSubmit()
    {
        var form = document.CreateBookForm;
        var strBookName = document.CreateBookForm.BookName.value;

        <% if (c.var("RBSAdmin_TaskDelegate").equals("taskDelegate") == false) { %>
            var strContainer = document.CreateBookForm.BookContext.value;
   		<% } else { %>
            form.SelectedModuleIndex.value = form.ModuleList.selectedIndex;
            var strContainer = form.ModuleList.options[form.ModuleList.selectedIndex].value;
            form.BookContext.value = strContainer;
         <% } %>

        if ((null == strBookName) || (0 == strBookName.length))
        {
            alert("<%= c.toScript(c.string("CreateBook.InvalidBookName")) %>");
            document.CreateBookForm.BookName.focus();
            return false;
        }

        if ((null == strContainer) || (0 == strContainer.length))
        {
            alert("<%= c.toScript(c.string("CreateBook.InvalidBookContext")) %>");
            <% if (c.var("RBSAdmin_TaskDelegate").equals("taskDelegate") == false) { %>
               document.CreateBookForm.BookContext.focus();
   		   <% } else { %>
               form.ModuleList.focus();
         <% } %>

            return false;
        }

         //	Make sure they haven't entered more than 1024 characters.
         var sizeOk = checkFinalTextAreaSize();
         if (sizeOk == false)
         {
            document.CreateBookForm.BookDescription.focus();
            return false;
         }

         if(document.CreateBookForm.mooEnabled.checked)
         {
            document.CreateBookForm.mooEnabledCheckBox.value = "true";
         }
         else
         {
            document.CreateBookForm.mooEnabledCheckBox.value = "false";
         }

        return true;
    }

   // Check to make sure the description attribute max size is not exceeded.
   function checkFinalTextAreaSize()
   {
      var maxlimit = 1024;

      if (document.CreateBookForm.BookDescription.value.length > maxlimit) // if too long...trim it!
      {
         var limitMessage = "<%= c.toScript(c.string("ModifyRBSObjectDescription.ExceededLimit")) %>";
         alert(limitMessage);
         document.CreateBookForm.BookDescription.value = document.CreateBookForm.BookDescription.value.substring(0, maxlimit);
         return false;
      }
      else
      {
         return true;
      }
   }


</SCRIPT>
</HEAD>

<BODY   TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF"
        onLoad="returnFromOS();onPageLoad();">

<FORM   name="CreateBookForm"
        method=post
        action="webacc"
        onSubmit="return(onPageSubmit())">

   <input   type=hidden
            name="taskId"
            value="<%= c.var("taskId") %>">

   <input   type=hidden
            name="merge"
            value="fw.BookObjectType">

   <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="nextBookObjectType">

   <input   type=hidden
            name="CreateBookFormNameChanged"
            value="false">

   <input   type=hidden
            name="CreateBookFormDescChanged"
            value="false">

   <input   type=hidden
            name="CreateBookFormContextChanged"
            value="false">

   <input   type=hidden
            name="CreateBookFormMooEnabledChanged"
            value="false">

   <input   type=hidden
            name="mooEnabledCheckBox"
            value="<%=c.var("mooEnabledCheckBox")%>">

   <input   type=hidden
            name="RBSAdmin_TaskDelegate"
            value="<%= c.var("RBSAdmin_TaskDelegate") %>">

   <input   type=hidden
            name="SelectedModuleIndex"
            value="<%= c.var("SelectedModuleIndex") %>">

   <input   type=hidden
            name="selectedCollectionName"
            value="<%= c.var("selectedCollectionName") %>">

   <!-- End of hidden tags -->

    <% c.set("WizardHeader.title", c.toHTML(c.string("CreateBook.WizardTitle")));
       c.set("WizardHeader.subtitle", c.toHTML(c.string("General.Step1")));
       c.set("WizardHeader.instruction", c.toHTML(c.string("CreateBook.Name")));
       c.set("WizardHeader.helpFile", "base/createpropertybook_name.html"); %>
    <jsp:include page='<%= c.getPath("dev/WizardHeader_inc.jsp") %>' flush="true" />

    <div class="formdescriptext"><span class="width400"><%= c.toHTML(c.string("CreateBook.Instruction")) %></span></div>
    <br>
    <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
        <TR>
            <TD width="20%" class="mediumtext" valign="bottom">
                <%= c.toHTML(c.string("CreateBook.BookName")) %><br>
                <input type=text name="BookName" value="<%= c.toHTML(c.var("BookName_Value")) %>" onchange="createBookFormNameChanged()" size=35 maxlength=64>
                &nbsp;
            </td>
            <TD width="0*" bgcolor="#FFFFFF" class="instructions">
                <%= c.toHTML(c.string("CreateBook.Example")) %>
             </TD>
             <TD width="0*">&nbsp;</TD>
        </TR>
        <TR>
            <TD width="20%" class="mediumtext" valign="bottom">
                <%= c.toHTML(c.string("CreateBook.Module")) %><br>
                <% if (c.var("RBSAdmin_TaskDelegate").equals("taskDelegate") == false) { %>
                   <input type=text name="BookContext" value="<%= c.toHTML(c.var("BookContext_Value")) %>" onchange="createBookFormContextChanged()" size=30>
                   <% c.set("OS.TypeFilter", "rbsModule2");
                      c.set("OS.Control", "BookContext");
                      c.set("OS.CallBack", "createBookFormContextChangedCallBack");
                      c.set("OS.History", "true");
                      c.set("OS.Mode", "search"); %>
                   <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
                <% } else { %>
                   <input type=hidden name="BookContext" value="<%= c.toHTML(c.var("BookContext_Value")) %>">
                   <select name="ModuleList" onchange="createBookFormContextChanged()">
                     <% c.set("i", "0");
                         while (c.lt(c.var("i"), c.var("ModuleName.Count"))) { %>
                        <OPTION value="<%= c.toHTML(c.var("ModuleName.Element."+c.var("i"))) %>"><%= c.toHTML(c.var("ModuleName.Element."+c.var("i"))) %>
                        <% c.inc("i");
                        } %>
                   </select>
                <% } %>
                &nbsp
            </TD>
            <TD width="0*" bgcolor="#FFFFFF" class="instructions">
                <%= c.toHTML(c.string("CreateBook.EnterPath")) %>
            </TD>
            <TD width="0*">&nbsp;</TD>
        </TR>
        <TR>
            <TD width="20%" class="mediumtext" width="0*" valign="bottom">
                <%= c.toHTML(c.string("CreateBook.Description")) %><br>
                <TEXTAREA name="BookDescription" value="<%= c.toHTML(c.var("BookDescription_Value")) %>" onchange="createBookFormDescChanged()" rows="3" cols=30 wrap="VIRTUAL" ><%= c.toHTML(c.var("BookDescription_Value")) %></TEXTAREA>
            </TD>
        </TR>
        <TR>
            <TD width="0*"><INPUT type="checkbox" name="mooEnabled" onclick="createBookFormMooEnabledChanged()">&nbsp;<%= c.toHTML(c.string("TaskBuilder.MultipleObjectEnabled")) %></TD>
        </TR>
        <TR>
            <TD width="0*">&nbsp;</TD>
        </TR>
    </TABLE>
    <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
    <a href="#"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.BackDisabled.image") %>" alt="<%= c.toHTML(c.string("Button.BackDisabled.alt")) %>" title="<%= c.toHTML(c.string("Button.BackDisabled.alt")) %>" border=0></a>
    <INPUT type=image name="Next" alt="<%= c.toHTML(c.string("Button.Next.alt")) %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Next.image") %>" border=0>
    <jsp:include page='<%= c.getPath("dev/Cancel_inc.jsp") %>' flush="true" />
</FORM>
<jsp:include page='<%= c.getPath("dev/OSFooter_inc.jsp") %>' flush="true" />
</BODY></HTML>
