<%@  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("BaseResources");
   c.stringTable("DevResources"); %>
<HTML>
<HEAD>
<TITLE><%= c.string("CloneObject.CloneObjectTitle") %></TITLE>
<LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.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">

   var ENABLED_COLOR = "white";
   var DISABLED_COLOR = "#EFEEE9";

   function checkNullInput()
   {
      var strSON = document.CloneObjectForm.SourceObjectName.value;
      if ((null == strSON) || (0 == strSON.length))
      {
         alert("<%= c.string("CloneObject.InvalidSourceObjectName") %>");
         return false;
      }

      with(document.forms[0])
      {
         if (copytype[0].checked == true)
         {
            var strTON = document.CloneObjectForm.TargetObjectName.value;
            if ((null == strTON) || (0 == strTON.length))
            {
               alert("<%= c.string("CloneObject.InvalidTargetObjectName") %>");
               return false;
            }
            var strTCN = document.CloneObjectForm.TargetContextName.value;
            if ((null == strTCN) || (0 == strTCN.length))
            {
               alert("<%= c.string("CloneObject.InvalidTargetContextName") %>");
               return false;
            }
         }
         else
         {
            var strUON = document.CloneObjectForm.UpdateObjectName.value;
            if ((null == strUON) || (0 == strUON.length))
            {
               alert("<%= c.string("CloneObject.InvalidUpdateObjectName") %>");
               return false;
            }
         }

         if (UpdateExpAcls.checked == true)
         {
            var strSCN = document.CloneObjectForm.SearchContextName.value;
            if ((null == strSCN) || (0 == strSCN.length))
            {
               alert("<%= c.string("CloneObject.InvalidObjectNameForSearch") %>");
               return false;
            }
         }
      }

      return true;
   }

   function setFocusToFormElement()
   {
      // added for Object View
      if ("<%= c.var("OS.ReturningToAnchor") %>"!="true")    //haven't entered a value from OS
      {
         document.CloneObjectForm.SourceObjectName.value = "<%= c.toScript(eMFrameUtils.getSingleTarget(request)) %>";
      }

      document.CloneObjectForm.SourceObjectName.focus();
   }

   function InitControls()
   {
      with(document.forms[0])
      {
         if (copytype[0].checked == true)
         {
            TargetObjectName.style.backgroundColor = ENABLED_COLOR;
            TargetObjectName.readOnly = false;

            TargetContextName.style.backgroundColor = ENABLED_COLOR;
            TargetContextName.readOnly = false;

            UpdateObjectName.style.backgroundColor = DISABLED_COLOR;
            UpdateObjectName.readOnly = true;
         }
         else
         {
            TargetObjectName.style.backgroundColor = DISABLED_COLOR;
            TargetObjectName.readOnly = true;

            TargetContextName.style.backgroundColor = DISABLED_COLOR;
            TargetContextName.readOnly = true;

            UpdateObjectName.style.backgroundColor = ENABLED_COLOR;
            UpdateObjectName.readOnly = false;
         }

        if (UpdateExpAcls.checked == true)
        {
            SearchContextName.style.backgroundColor = ENABLED_COLOR;
            SearchContextName.readOnly = false;
        }
        else
        {
               SearchContextName.style.backgroundColor = DISABLED_COLOR;
               SearchContextName.readOnly = true;
        }
      }
   }

   function EnableDisableCopyControls()
   {
      with(document.forms[0])
      {
         if (copytype[0].checked == true)
         {
            TargetObjectName.style.backgroundColor = ENABLED_COLOR;
            TargetObjectName.readOnly = false;
            TargetObjectName.focus();

            TargetContextName.style.backgroundColor = ENABLED_COLOR;
            TargetContextName.readOnly = false;

            UpdateObjectName.style.backgroundColor = DISABLED_COLOR;
        UpdateObjectName.readOnly = true;
         }
         else
         {
            TargetObjectName.style.backgroundColor = DISABLED_COLOR;
            TargetObjectName.readOnly = true;

            TargetContextName.style.backgroundColor = DISABLED_COLOR;
            TargetContextName.readOnly = true;

            UpdateObjectName.style.backgroundColor = ENABLED_COLOR;
        UpdateObjectName.readOnly = false;
        UpdateObjectName.focus();
     }
      }
   }

   function EnableDisableAclControl()
   {
      with(document.forms[0])
      {
     if (UpdateExpAcls.checked == true)
     {
            SearchContextName.style.backgroundColor = ENABLED_COLOR;
            SearchContextName.readOnly = false;
        SearchContextName.focus();
     }
     else
     {
            SearchContextName.style.backgroundColor = DISABLED_COLOR;
            SearchContextName.readOnly = true;
            SourceObjectName.focus();
     }
      }
   }

   function TargetContextNameOS()
   {
      return document.CloneObjectForm.copytype[0].checked;
   }

   function UpdateObjectNameOS()
   {
      return document.CloneObjectForm.copytype[1].checked;
   }

   function SearchContextNameOS()
   {
      return document.CloneObjectForm.UpdateExpAcls.checked;
   }
</script>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="setFocusToFormElement();InitControls();returnFromOS();">
<form name="CloneObjectForm" method=post action="webacc" onSubmit="return(checkNullInput())">
   <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="doCloneObject">

   <% c.set("TaskHeader.helpFile", "base/copyobject.html");
      c.set("TaskHeader.HelpWindowWidth", "500");
      c.set("TaskHeader.HelpWindowHeight", "500");
      c.set("TaskHeader.title", c.string("CloneObject.CloneObjectTitle"));
      c.set("TaskHeader.iconUrl", c.plus("dir/", c.string("GenericTask.image"))); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>
   <% c.set("IndentVal", "10"); %>

   <table width="100%" style="margin-bottom:20" border="0" cellspacing="0" cellpadding="3">
   <!-- short help text -->
   <tr>
     <td valign="middle" colspan="2" class="instructions">
       <%= c.string("CloneObject.ShortHelp") %>
     </td>
   </tr>

   <tr><td><font size=-2>&nbsp;</font></td></tr>

   <!-- source object -->
   <tr>
     <td valign="middle" class="mediumtext" colspan="2">
       <%= c.string("CloneObject.SourceObjectName") %><br>
       <input type=text name="SourceObjectName" value="" size=<%= c.string("UI.textboxSize") %> style="width:<%= c.string("UI.textboxPixel") %>" >
       <% c.set("OS.TypeFilter", "");
          c.set("OS.Control", "SourceObjectName");
          c.set("OS.History", "true"); %>
       <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
     </td>
   </tr>

   <tr><td class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td></tr>

   <!-- create object radio button -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">
       <INPUT type="radio" name="copytype" value="Create" onClick="EnableDisableCopyControls()" checked>
     </td>
     <td height="33" valign="middle" class="mediumtext">
       <%= c.string("CloneObject.CreateObject") %>
     </td>
   </tr>

   <!-- create object name -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td>
     <td valign="middle" class="mediumtext">
       <%= c.string("CloneObject.ObjectName") %><br>
       <input type=text name="TargetObjectName" value="" size=<%= c.string("UI.textboxSize") %> maxlength="64" style="width:<%= c.string("UI.textboxPixel") %>" >
     </td>
   </tr>

   <!-- create object location -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td>
     <td valign="middle" class="mediumtext">
       <%= c.string("CloneObject.ObjectLocation") %><br>
       <input type=text name="TargetContextName" value="" size=<%= c.string("UI.textboxSize") %> style="width:<%= c.string("UI.textboxPixel") %>" >
       <% c.set("OS.TypeFilter", "[root],[containers]");
          c.set("OS.Control", "TargetContextName");
          c.set("OS.IsOSAllowed", "TargetContextNameOS");
          c.set("OS.History", "true"); %>
       <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
     </td>
   </tr>

   <tr><td><font size=-2>&nbsp;</font></td></tr>

   <!-- copy to existing object radio button -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">
       <INPUT type="radio" name="copytype" value="Update" onClick="EnableDisableCopyControls()">
     </td>
     <td valign="middle" class="mediumtext">
       <%= c.string("CloneObject.CopyObject") %>
     </td>
   </tr>

   <!-- copy to object name -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td>
     <td valign="middle" class="mediumtext">
       <%= c.string("CloneObject.ObjectName") %><br>
       <input type=text name="UpdateObjectName" value="" size=<%= c.string("UI.textboxSize") %> style="width:<%= c.string("UI.textboxPixel") %>" >
       <% c.set("OS.TypeFilter", "");
          c.set("OS.Control", "UpdateObjectName");
          c.set("OS.IsOSAllowed", "UpdateObjectNameOS");
          c.set("OS.History", "true"); %>
       <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
     </td>
   </tr>

   <tr><td><font size=-2>&nbsp;</font></td></tr>

   <!-- copy ACL rights checkbox -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">
       <input type="checkbox" name="UpdateExpAcls" onClick="EnableDisableAclControl()">
     </td>
     <td valign="middle" class="mediumtext">
       <%= c.string("CloneObject.UpdateACLs") %>
     </td>
   </tr>

   <!-- start ACL copy search from location -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td>
     <td valign="middle" class="mediumtext" colspan="2">
       <%= c.string("CloneObject.ACLSearch") %><BR>
       <input type="text" name="SearchContextName" value="" size=<%= c.string("UI.textboxSize") %> style="width:<%= c.string("UI.textboxPixel") %>" >
       <% c.set("OS.TypeFilter", "[root],[containers]");
          c.set("OS.Control", "SearchContextName");
          c.set("OS.IsOSAllowed", "SearchContextNameOS");
          c.set("OS.History", "true"); %>
       <jsp:include page='<%= c.getPath("dev/OS_inc.jsp") %>' flush="true" />
     </td>
   </tr>

   <!-- ACL copy note -->
   <tr>
     <td valign="middle" class="mediumtext" width="<%= c.var("IndentVal") %>">&nbsp;</td>
     <td class="smalltext2d" colspan="2" valign="top">
       <%= c.string("CloneObject.ACLWarning") %>
     </td>
   </tr>

   </table>
   <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
   <INPUT type=image name="Clone" alt="<%= c.string("Button.OK.alt") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.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>
