<%@  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");
   c.stringTable("BaseResources"); %>

<HTML>
<HEAD>
<TITLE><%= c.string("RenameObject.RenameObjectTitle") %></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" />
<jsp:include page='<%= c.getPath("dev/TCScripts_inc.jsp") %>' flush="true"/>
<script language="JavaScript">


	function isTargetValid()
  	 {
   	 
   		  return validateTargetChooser();
   	 
  	 }
  	 
  	 
  	 function onTargetChooserTextChange(control)
     {
            
             
             with(document.RenameObjectForm)
             {
             	control=eval(control);
                
            	 if(control.value!="" || control.value.length>0)
             	{
               	 
               		
             		RenameNewName.value = control.value.substring(0, control.value.indexOf('.'));
             		if (RenameNewName.value.length== 0)
             		{
             		 RenameNewName.value = control.value.substring(0, control.value.indexOf(',')); 
             		} 
             		
             		
             	}
             }
             
    }
    
   function setSelection(strSelection)
   {
      document.RenameObjectForm.RenameObjectName.value = unescape(strSelection);
   }

   function checkNullInput()
   {
     
      var containerInput = document.RenameObjectForm.RenameNewName.value;
      if ((null == containerInput) || (0 == containerInput.length))
      {
         alert("<%= c.string("RenameObject.InvalidName") %>");
         return false;
      }

      return true;
   }

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

      document.RenameObjectForm.single.focus(); // this is added to focus the text boxes which takes the object names 
										//we know "single" is the name of the control 
   }

   function disableOldName()
   {
        // Need to work on this for Netscape.
        document.RenameObjectForm.EnableOldName.checked = false;
        document.RenameObjectForm.EnableOldName.disabled = true;
        document.RenameObjectForm.EnableOldName.blur();
        return true;
	}

    function copyValue(control, results)
    {
      with(document.RenameObjectForm)
      {
      	var tmp=results[0];
      	if (tmp != null)
         {
	 	  	  control=eval(control);	
	 	      control.value = tmp;
	 	      document.RenameObjectForm.RenameNewName.value = tmp.substring(0, tmp.indexOf("."));
            	if (document.RenameObjectForm.RenameNewName.value.length == 0)
            	{
               		document.RenameObjectForm.RenameNewName.value = tmp.substring(0, tmp.indexOf(","));
            	}
         }
      }
     
    }


</script>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="returnFromOS(); setFocusToFormElement();">
<form name="RenameObjectForm" method=post action="webacc" onSubmit="return isTargetValid()&& 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="doRenameObject">
   <input type=hidden name="keepOldName" value="">
   <input type=hidden name="OSSearchFilter" value="<%= c.var("OSSearchFilter") %>">
   <input type=hidden name="GifName" value="<%= c.var("GifName") %>">
   <input type=hidden name="TranslatedClass" value="<%= c.var("TranslatedClass") %>">

	<% c.set("TaskHeader.title", c.formatMessage(c.string("RenameObject.RenameObject"), 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>


<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="instructions"><%= c.string("RenameObject.SelectPrompt") %></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  
  
      
    <% c.set("TC.controlName", "RenameObjectName");
       
    
       c.set("TC.quickFindEnabled","true");
       if(!c.var("targetName").equals(""))
       {
           c.set("TC.initialValues","P:"+c.var("targetName")+"P");
       }    
  
	       c.set("TC.callBack","copyValue");
	       c.set("TC.onChange","true");	
         
	       %>
 
    <td class="mediumtext"><jsp:include page='<%= c.getPath("dev/TC_inc.jsp") %>' flush="true" /></td>
    
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
         <td class="mediumtext"><%= c.string("RenameObject.NewName") %></td>
      </tr>
      <tr>
         <td ><input type="text" name="RenameNewName" size="<%= c.string("UI.textboxSize") %>" maxlength="64" style="width:<%= c.string("UI.textboxPixel") %>" ></td>
      </tr>
      <tr>
         <td class="smalltext2d"><%= c.string("RenameObject.RenameNote") %></td>
      </tr>
    </TABLE>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>

<table width="90%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td width="3%"><input type="checkbox" name="EnableOldName" value=""></td>
    <td width="64%" class="mediumtext"><%= c.string("RenameObject.SaveOldName") %></td>
    <td width="33%" >&nbsp;</td>
  </tr>
  <% if(!"false".equals(c.var("aliasCreation"))) { %>
  <tr>
    <td width="3%"><input type="checkbox" name="EnableCreateAlias" value=""></td>
    <td width="64%" class="mediumtext"><%= c.string("RenameObject.CreateAlias") %></td>
    <td width="33%" >&nbsp;</td>
  </tr>
  <%}%>
  <tr>
    <td colspan="2"></td>
  </tr>
</table>
<br>

<jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
<INPUT type=image name="Rename" 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>
