<%@  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.toHTML(c.string("PartitionReplica.ReplicaAdministration")) %></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 replicaImages = new Array();
    
    
    // pre-cache replica images
    if(document.images)
    {
        replicaImages["master"] = new Image(24, 24);
        replicaImages["master"].src = "<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaMaster24.image") %>";
        
        replicaImages["readwrite"] = new Image(24, 24);
        replicaImages["readwrite"].src = "<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaReadWrite24.image") %>";
        
        replicaImages["readonly"] = new Image(24, 24);
        replicaImages["readonly"].src = "<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaReadOnly24.image") %>";
        
        replicaImages["filteredreadwrite"] = new Image(24, 24);
        replicaImages["filteredreadwrite"].src = "<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaFilteredReadWrite24.image") %>";
        
        replicaImages["filteredreadonly"] = new Image(24, 24);
        replicaImages["filteredreadonly"].src = "<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaFilteredReadOnly24.image") %>";
    }
    
   
    /*******************
     * FUNCTION HEADER *
     *******************/   
    function okSelected()
    {
        var form = document.ChangeReplicaForm;
        var replicaType;
        
        if(form.ReplicaTypeRadio[4].checked == true)
        {
            replicaType = form.ReplicaTypeRadio[4].value;
        }
        else if(form.ReplicaTypeRadio[3].checked == true)
        {
            replicaType = form.ReplicaTypeRadio[3].value;
        }
        else if(form.ReplicaTypeRadio[2].checked == true)
        {
            replicaType = form.ReplicaTypeRadio[2].value;
        }
        else if(form.ReplicaTypeRadio[1].checked == true)
        {
            replicaType = form.ReplicaTypeRadio[1].value;
        }
        else
        {
            replicaType = form.ReplicaTypeRadio[0].value;
        }
        
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            form.elements["ReplicaType"].value = replicaType;
            form.elements["merge"].value="base.partition.ReplicaTable";
            form.elements["nextState"].value="changeReplica";
            
            form.submit();
        <% } else { %>
            window.opener.changeReplicaInfo(replicaType);
            window.close();
        <% } %>
    }
   
    
    /*******************
     * FUNCTION HEADER *
     *******************/   
    function cancelSelected()
    {
        <% if (session.getAttribute("DeviceType").equals("default")) { %>
            var form = document.ChangeReplicaForm;
            
            form.elements["merge"].value="base.partition.ReplicaTable";
            form.elements["nextState"].value="cancelReplicaOperation";
            
            form.submit();
        <% } else { %>
            window.close();
        <% } %>
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function changeReplicaType(imgName)
    {
        if(document.images)
        {
            var form = document.ChangeReplicaForm;
            var replicaType;

            if(form.ReplicaTypeRadio[4].checked == true)
            {
                replicaType = form.ReplicaTypeRadio[4].value;
            }
            else if(form.ReplicaTypeRadio[3].checked == true)
            {
                replicaType = form.ReplicaTypeRadio[3].value;
            }
            else if(form.ReplicaTypeRadio[2].checked == true)
            {
                replicaType = form.ReplicaTypeRadio[2].value;
            }
            else if(form.ReplicaTypeRadio[1].checked == true)
            {
                replicaType = form.ReplicaTypeRadio[1].value;
            }
            else
            {
                replicaType = form.ReplicaTypeRadio[0].value;
            }

            document.images[imgName].src = replicaImages[replicaType].src;

        }
        return true;
    }


    /*******************
     * FUNCTION HEADER *
     *******************/
    function changeReplicaTypeLabel(imgName, num)
    {
        var form = document.ChangeReplicaForm;
        form.ReplicaTypeRadio[num].checked = true;
        changeReplicaType(imgName);
        return true;
    }


</SCRIPT>
</HEAD>

<BODY   TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF"
        onLoad="returnFromOS()">
<form   name="ChangeReplicaForm"
        method="post"
        action="webacc"
        onSubmit="return(okSelected())">

        <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="ReplicaType"
                value="">
                
        <input  type=hidden
                name="nextState"
                value="">
            
	<!-- ************ -->
	<!-- HEADER TABLE -->
	<!-- ************ -->
   <% c.set("TaskHeader.title", c.string("PartitionReplica.ChangeReplicaType")); 
      c.set("TaskHeader.helpFile", "base/changereplicatype.html"); %>
   <jsp:include page='<%= c.getPath("dev/TaskHeader_inc.jsp") %>' flush="true" /><BR>
                
    <!-- ************* -->
    <!-- CONTENT TABLE -->
    <!-- ************* -->
    <TABLE>
        <TR> 
            <TD class="mediumtext" width="0*">
                <%= c.toHTML(c.string("PartitionReplica.PartitionName")) %>
            </TD> 
            <TD class="mediumtext">
                <%= c.toHTML(c.var("Replica.SelectedObjectName")) %>
            </TD> 
        </TR> 
        <TR> 
            <TD height="10" colspan="2"> 
            </TD> 
        </TR> 
        <TR> 
            <TD class="mediumtext" width="0*">
                <%= c.toHTML(c.string("PartitionReplica.ServerName")) %>
            </TD> 
            <TD class="mediumtext">
                <%= c.toHTML(c.var("Replica.SelectedTableName")) %>
            </TD> 
        <TR> 
            <TD height="10" colspan="2"> 
            </TD> 
        </TR> 
        </TR> 
    </TABLE>
    
    <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
        <TR>
            <TD width="25">
                <% if (c.var("Replica.SelectedReplica").equals("Read-Write")) { %>
                    <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaReadWrite24.image") %>" name="ReplicaImage" border=0>
                <% } 
                   if (c.var("Replica.SelectedReplica").equals("Read-Only")) { %>
                    <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaReadOnly24.image") %>" name="ReplicaImage" border=0>
                <% } 
                   if (c.var("Replica.SelectedReplica").equals("Filter Read-Write")) { %>
                    <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaFilteredReadWrite24.image") %>" name="ReplicaImage" border=0>
                <% } 
                   if (c.var("Replica.SelectedReplica").equals("Filter Read-Only")) { %>
                    <IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("ReplicaFilteredReadOnly24.image") %>" name="ReplicaImage" border=0>
                <% } %>
            </TD>
            <TD>
                <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
                    <TR>
                        <TD width="25" valign="middle">
                            <input  type="radio"
                                    name="ReplicaTypeRadio"
                                    value="master"
                                    onClick="return changeReplicaType('ReplicaImage')">
                        </TD>
                        <TD valign="middle" class="mediumtext">
                            <a href="#" style="color: #039; text-decoration: none" onClick="return changeReplicaTypeLabel('ReplicaImage', 0)">
                            <%= c.toHTML(c.string("PartitionReplica.Master")) %>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="25" valign="middle">
                            <% if (c.var("Replica.SelectedReplica").equals("Read-Write")) { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="readwrite"
                                        onClick="return changeReplicaType('ReplicaImage')"
                                        checked>
                            <% } else { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="readwrite"
                                        onClick="return changeReplicaType('ReplicaImage')">
                            <% } %>
                        </TD>
                        <TD valign="middle" class="mediumtext">
                            <a href="#" style="color: #039; text-decoration: none" onClick="return changeReplicaTypeLabel('ReplicaImage', 1)">
                            <%= c.toHTML(c.string("PartitionReplica.ReadWrite")) %>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="25" valign="middle">
                            <% if (c.var("Replica.SelectedReplica").equals("Read-Only")) { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="readonly"
                                        onClick="return changeReplicaType('ReplicaImage')"
                                        checked>
                            <% } else { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="readonly"
                                        onClick="return changeReplicaType('ReplicaImage')">
                            <% } %>
                        </TD>
                        <TD valign="middle" class="mediumtext">
                            <a href="#" style="color: #039; text-decoration: none" onClick="return changeReplicaTypeLabel('ReplicaImage', 2)">
                            <%= c.toHTML(c.string("PartitionReplica.ReadOnly")) %>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="25" valign="middle">
                            <% if (c.var("Replica.SelectedReplica").equals("Filter Read-Write")) { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="filteredreadwrite"
                                        onClick="return changeReplicaType('ReplicaImage')"
                                        checked>
                            <% } else { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="filteredreadwrite"
                                        onClick="return changeReplicaType('ReplicaImage')">
                            <% } %>
                        </TD>
                        <TD valign="middle" class="mediumtext">
                            <a href="#" style="color: #039; text-decoration: none" onClick="return changeReplicaTypeLabel('ReplicaImage', 3)">
                            <%= c.toHTML(c.string("PartitionReplica.FilteredReadWrite")) %>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="25" valign="middle">
                            <% if (c.var("Replica.SelectedReplica").equals("Filter Read-Only")) { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="filteredreadonly"
                                        onClick="return changeReplicaType('ReplicaImage')"
                                        checked>
                            <% } else { %>
                                <input  type="radio"
                                        name="ReplicaTypeRadio"
                                        value="filteredreadonly"
                                        onClick="return changeReplicaType('ReplicaImage')">
                            <% } %>
                        </TD>
                        <TD valign="middle" class="mediumtext">
                            <a href="#" style="color: #039; text-decoration: none" onClick="return changeReplicaTypeLabel('ReplicaImage', 4)">
                            <%= c.toHTML(c.string("PartitionReplica.FilteredReadOnly")) %>
                        </TD>
                    </TR>
                </TABLE>
            </TD>
        </TR>
        <tr>
            <td>&nbsp;</td>
        </tr>
    </TABLE>
	
	<!-- ************ -->
	<!-- BUTTON TABLE -->
	<!-- ************ -->
    <jsp:include page='<%= c.getPath("dev/Bar_inc.jsp") %>' flush="true" />
    
    <a href="#" onClick="javascript:okSelected();return false">
        <IMG    src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.OK.image") %>"
                alt="<%= c.string("Button.OK.alt") %>"
                title="<%= c.string("Button.OK.alt") %>"
                border=0></a>
    <a href="#" onClick="javascript:cancelSelected();return false">
        <IMG    src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Cancel.image") %>"
                alt="<%= c.string("Button.Cancel.alt") %>"
                title="<%= c.string("Button.Cancel.alt") %>"
                border=0></a>
</form>
</BODY></HTML>
