<%@  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("ExtendSchema.Title") %></TITLE>
<LINK rel='stylesheet' href='<%= c.getModulesUrl() + "/dev/css/hf_style.css" %>'>
<jsp:include page='<%= c.getPath("dev/eMFrameScripts_inc.jsp") %>' flush="true" />

<script language="JavaScript">


    //Global variables
    var myWindow = null;


    /*******************
     * FUNCTION HEADER *
     *******************/
    function replicaInformation(selectedName)
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var form = document.ReplicaTableForm;

            form.elements["SelectedTableName"].value=urlEncode(selectedName);
            form.elements["merge"].value="base.partition.ReplicaInformation";
            form.elements["nextState"].value="showReplicaInformationWindow";

            form.submit();
        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
                var strUrl = "webacc?taskId=<%= c.var("taskId") %>&merge=base.partition.ReplicaInformation&User.context=<%= c.toHTML(c.var("User.context")) %>&nextState=showReplicaInformationWindow&SelectedTableName="+urlEncode(selectedName);
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.ReplicaInfoPixelWidth") %>,height=<%= c.string("UI.ReplicaInfoPixelHeight") %>";
                myWindow = window.open(strUrl, "", winOptions);
            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function addReplica()
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var form = document.ReplicaTableForm;

            form.elements["merge"].value="base.partition.AddReplica";
            form.elements["nextState"].value="showAddReplicaWindow";

            form.submit();
        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
                var strUrl = "webacc?taskId=<%= c.var("taskId") %>&merge=base.partition.AddReplica&User.context=<%= c.toHTML(c.var("User.context")) %>&nextState=showAddReplicaWindow";
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.AddReplicaPixelWidth") %>,height=<%= c.string("UI.AddReplicaPixelHeight") %>";
                myWindow = window.open(strUrl, "", winOptions);
            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function replicaFilterTask(selectedName)
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var newTaskInfo = "webacc?taskId=base.ReplicaAdministration&oldTaskId=<%= c.var("taskId") %>&merge=base.partition.ReplicaTable&error=dev.GenErr&User.context=<%= c.var("User.context") %>&nextState=replicaTable&eDir$target="+selectedName;
            var restoreInfo = "&onComplete=return:merge=base.partition.ReplicaTable%26error=dev.GenErr%26nextState=replicaTable%26eDir$target=<%= c.var("eDir$target") %>";
            self.location = newTaskInfo+restoreInfo;
        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
                var strUrl = "webacc?taskId=base.ReplicaAdministration&onComplete=close&newInstance=true&merge=base.partition.ReplicaTable&User.context=<%= c.var("User.context") %>&error=dev.GenErr&nextState=replicaTable&eDir$target="+selectedName;
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=550";
                myWindow = window.open(strUrl, "", winOptions);
            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function editReplicaFilter(selectedName)
    {
        <% if (c.var("Replica.taskAvailable").equals("false")) { %>
            alert("<%= c.string("PartitionReplica.TaskNotAvailable") %>");
            return;
        <% } %>

	    var arTarget = new Array();
	    arTarget[0] = selectedName;
        var str = pack(arTarget);

        <% if (session.getAttribute("DeviceType").equals("default")) { %>
<%--            var newTaskInfo = "webacc?taskId=RWiz.RWizFilterSetBook&oldTaskId=<%= c.var("taskId") %>&User.context=<%= c.var("User.context") %>&nextState=initialState&eDir$target="+urlEncode(str);--%>
<%--            var restoreInfo = "&onComplete=return:merge=base.partition.ReplicaTable%26error=dev.GenErr%26nextState=refreshReplica%26eDir$target=<%= c.var("eDir$target") %>";--%>
<%--            self.location = newTaskInfo+restoreInfo;--%>
            var newTaskInfo = "webacc?NPService=fw.LaunchService&NPAction=Delegate&delegate=RWiz.RWizFilterSetBook&eDir$target=" + urlEncode(str) + "&launcher=<%= c.var("taskId") %>&lifecycle=Recreate";
            self.location = newTaskInfo;


        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
<%--                var strUrl = "webacc?NPService=fw.LaunchService&NPAction=Launch&launch=base.SetPassword&launcher=<%= c.var("taskId") %>&lifecycle=New&eDir$target="+urlEncode(str);                --%>
<%--                var strUrl = "webacc?taskId=RWiz.RWizFilterSetBook&onComplete=close&newInstance=true&nextState=initialState&User.context=<%= c.var("User.context") %>&eDir$target="+urlEncode(str);--%>
<%--                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.EditFilterPixelWidth") %>,height=<%= c.string("UI.EditFilterPixelHeight") %>";--%>
<%--                myWindow = window.open(strUrl, "", winOptions);                --%>
                var strUrl = "webacc?NPService=fw.LaunchService&NPAction=Launch&launch=RWiz.RWizFilterSetBook&launcher=fw.LaunchService&lifecycle=New&eDir$target=" + urlEncode(str);
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.EditFilterPixelWidth") %>,height=<%= c.string("UI.EditFilterPixelHeight") %>";
                myWindow = window.open(strUrl, "", winOptions);

            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function deleteReplica(selectedName)
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var form = document.ReplicaTableForm;

            form.elements["SelectedTableName"].value=urlEncode(selectedName);
            form.elements["merge"].value="base.partition.DeleteReplica";
            form.elements["nextState"].value="showDeleteReplicaWindow";

            form.submit();
        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
                var strUrl = "webacc?taskId=<%= c.var("taskId") %>&merge=base.partition.DeleteReplica&User.context=<%= c.toHTML(c.var("User.context")) %>&nextState=showDeleteReplicaWindow&SelectedTableName="+urlEncode(selectedName);
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.DeleteReplicaPixelWidth") %>,height=<%= c.string("UI.DeleteReplicaPixelHeight") %>";
                myWindow = window.open(strUrl, "", winOptions);
            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function changeReplicaType(selectedName, replicaType)
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var form = document.ReplicaTableForm;

            form.elements["SelectedTableName"].value=urlEncode(selectedName);
            form.elements["ReplicaType"].value=urlEncode(replicaType);
            form.elements["merge"].value="base.partition.ChangeReplica";
            form.elements["nextState"].value="showChangeReplicaWindow";

            form.submit();
        <% } else { %>
            if ((myWindow == null) || myWindow.closed)
            {
                var strUrl = "webacc?taskId=<%= c.var("taskId") %>&merge=base.partition.ChangeReplica&User.context=<%= c.toHTML(c.var("User.context")) %>&nextState=showChangeReplicaWindow&SelectedTableName="+urlEncode(selectedName)+"&ReplicaType="+urlEncode(replicaType);
                var winOptions = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=<%= c.string("UI.ChangeReplicaPixelWidth") %>,height=<%= c.string("UI.ChangeReplicaPixelHeight") %>";
                myWindow = window.open(strUrl, "", winOptions);
            }
            else
            {
                myWindow.focus();
            }
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function refreshReplicaList()
    {
        var form = document.ReplicaTableForm;

        form.elements["merge"].value="base.partition.ReplicaTable";
        form.elements["nextState"].value="refreshReplica";

        form.submit();
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function addReplicaInfo(selectedName, replicaType)
    {
        var form = document.ReplicaTableForm;

        form.elements["SelectedTableName"].value = urlEncode(selectedName);
        form.elements["ReplicaType"].value = urlEncode(replicaType);
        form.elements["merge"].value="base.partition.ReplicaTable";
        form.elements["nextState"].value="addReplica";

        form.submit();
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function changeReplicaInfo(replicaType)
    {
        var form = document.ReplicaTableForm;

        form.elements["ReplicaType"].value = urlEncode(replicaType);

        form.elements["merge"].value="base.partition.ReplicaTable";
        form.elements["nextState"].value="changeReplica";

        form.submit();
    }


    /*******************1
     * FUNCTION HEADER *
     *******************/
    function deleteReplicaInfo()
    {
        var form = document.ReplicaTableForm;

        form.elements["merge"].value="base.partition.ReplicaTable";
        form.elements["nextState"].value="deleteReplica";
        form.submit();
    }


</script>
</HEAD>

<BODY   TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF">
<form   name="ReplicaTableForm"
        method=post
        action="webacc">

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

        <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="SelectedTableName"
                value="">

        <input  type=hidden
                name="ReplicaType" value="">

    <% c.set("TaskHeader.title", c.string("PartitionReplica.ReplicaAdministration"));
       c.set("TaskHeader.iconUrl", c.plus("dir/", c.string("PartitionTask.image")));
      c.set("TaskHeader.helpFile", "base/replicaview.html"); %>
    <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" />
    <br>
    <br>
    <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
        <TR bgcolor="#FFFFFF">
            <TD valign="top"  align="left">
                <a href="#" onClick="javascript:addReplica();return false"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.AddReplica.image") %>" alt="<%= c.string("Button.AddReplica.alt") %>" title="<%= c.string("Button.AddReplica.alt") %>" border=0></a>
            </TD>
            <TD valign="top" align="right">
                <a href="#" onClick="javascript:refreshReplicaList();return false"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Refresh.image") %>" alt="<%= c.string("Button.Refresh.alt") %>" title="<%= c.string("Button.Refresh.alt") %>" border=0></a>
            </TD>
        </TR>
    </TABLE>

    <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
        <tr>
            <% if (c.var("Replica.TableType").equals("Replica.ServerView")) { %>
                <td class="head4margin4">
                    <%= c.toHTML(c.string("PartitionReplica.PartitionName")) %>&nbsp;<%= c.toHTML(c.var("Replica.SelectedObjectName")) %>
                </td>
            <% } else { %>
                <td class="head4margin4">
                    <%= c.toHTML(c.string("PartitionReplica.ServerName")) %>&nbsp;<%= c.toHTML(c.var("Replica.SelectedObjectName")) %>
                </td>
            <% } %>
        </tr>
    </TABLE>

    <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
        <TR  bgcolor="#FFFFFF">
            <td class="formdescriptext" width="32">
                &nbsp;
            </td>
            <% if (c.var("Replica.TableType").equals("Replica.ServerView")) { %>
                <td class="head5tm6" width="0*">
                    <%= c.string("PartitionReplica.ReplicaServer") %>
                </td>
            <% } else { %>
                <td class="head5tm6" width="0*">
                    <%= c.string("PartitionReplica.ReplicaPartition") %>
                </td>
            <% } %>
            <td class="formdescriptext" width="2%">
                &nbsp;
            </td>
                <td class="head5tm6" width="0*">
                    <%= c.string("PartitionReplica.ReplicaType") %>
                </td>
                <td class="head5tm6" width="0*">
                    <%= c.string("PartitionReplica.Filter") %>
                </td>
                <td class="head5tm6" width="0*">
                    <%= c.string("PartitionReplica.ReplicaState") %>
                </td>
        </TR>
        <% c.set("count", "0");
           c.set("color", "#EFEEE9");
           while (c.lt(c.var("count"), c.var("Replica.Count"))) { %>
            <TR bgcolor=<%= c.var("color") %>>
                <% if (c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.Master")) || c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.SubReference"))) { %>
                    <TD>
                    </TD>
                <% } else { %>
                    <TD>
                        <a href="#" onClick="javascript:deleteReplica('<%= c.toHTML((c.toScript(c.var("Replica.Object."+c.var("count"))))) %>');return false"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.DeleteReplica.image") %>" alt="<%= c.string("Button.DeleteReplica.alt") %>" title="<%= c.string("Button.DeleteReplica.alt") %>" border=0></a>
                    </TD>
                <% } %>
                <TD  class="mediumtext">
                    <a href="#" onClick="javascript:replicaInformation('<%= c.toHTML((c.toScript(c.var("Replica.Object."+c.var("count"))))) %>');return false"><%= c.var("Replica.Object."+c.var("count")) %></a>
                </TD>
                <TD>
                <% if (c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.Master")) || c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.SubReference"))) { %>
                        <img src="<%= c.getModulesUrl() %>/dev/images/<%= c.var("Replica.GifName."+c.var("count")) %>" border=0>
                <% } else { %>
                        <a href="#" onClick="javascript:changeReplicaType('<%= c.toHTML((c.toScript(c.var("Replica.Object."+c.var("count"))))) %>','<%= c.toHTML((c.toScript(c.var("Replica.Type."+c.var("count"))))) %>');return false"><img src="<%= c.getModulesUrl() %>/dev/images/<%= c.var("Replica.GifName."+c.var("count")) %>" border=0></a>
                <% } %>
                </TD>
                <% if (c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.Master")) || c.var("Replica.Type."+c.var("count")).equals(c.string("PartitionReplica.SubReference"))) { %>
                    <TD class="mediumtext">
                        <%= c.var("Replica.Type."+c.var("count")) %>
                    </TD>
                <% } else { %>
                    <TD class="mediumtext">
                        <a href="#" onClick="javascript:changeReplicaType('<%= c.toHTML((c.toScript(c.var("Replica.Object."+c.var("count"))))) %>','<%= c.toHTML((c.toScript(c.var("Replica.Type."+c.var("count"))))) %>');return false"><%= c.var("Replica.Type."+c.var("count")) %></a>
                <% }
                   if (c.var("Replica.TableType").equals("Replica.ServerView")) { %>
                    <TD class="mediumtext">
                        <a href="#" onClick="javascript:editReplicaFilter('<%= c.toHTML((c.toScript(c.var("Replica.Object."+c.var("count"))))) %>');return false"><%= c.string("PartitionReplica.Edit") %></a>
                    </TD>
                <% } else { %>
                    <TD class="mediumtext">
                        <a href="#" onClick="javascript:editReplicaFilter('<%= c.toHTML((c.toScript(c.var("Replica.SelectedObjectName")))) %>');return false"><%= c.string("PartitionReplica.Edit") %></a>
                    </TD>
                <% }
                   if (c.var("Replica.State."+c.var("count")).equals(c.string("PartitionReplica.StateOn"))) { %>
                    <TD class="mediumtext">
                        <%= c.var("Replica.State."+c.var("count")) %>
                    </TD>
                <% } else { %>
                    <TD class="mediumtext">
                        <font color="#FF0000">
                            <b><%= c.var("Replica.State."+c.var("count")) %></b>
                        </font>
                    </TD>
                <% } %>
            </TR>
   		    <% c.inc("count");
               if (c.var("color").equals("#EFEEE9")) {
                   c.set("color", "#FFFFFF");
               } else {
                   c.set("color", "#EFEEE9");
               }
           } %>
    </TABLE>
    <br>
    <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
    <TABLE width="100%" border="0" cellspacing="0" cellpadding="3">
        <TR bgcolor="#FFFFFF">
            <TD valign="top"  align="left">
                <a href="webacc?taskId=<%= c.var("taskId") %>&taskComplete=true&User.context=<%= c.var("User.context") %>"><IMG name="Cancel" alt="<%= c.string("Button.Done.alt") %>" title="<%= c.string("Button.Done.alt") %>" src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Done.image") %>" border=0></a>
            </TD>
        </TR>
    </TABLE>
</form>
</BODY></HTML>
