<%@  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.var("DisplayNameTitle") %></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" />
<jsp:include page='<%= c.getPath("dev/MoveListItems_inc.jsp") %>' flush="true" />

<script language="JavaScript">


   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageLoad()
    {

    }



   /*******************
    * FUNCTION HEADER *
    *******************/
    function onPageSubmit()
    {
        var form = document.eGuideRolesForm;
        var listLength = form.AssignedRoles.length;

        if (listLength != null)
        {
            assignedRolesArray = new Array();

            for (i = 0; i<listLength; i++)
            {
                if (form.AssignedRoles.options[i].text != emptyListBracket)
                {
                    assignedRolesArray[i] = urlDecode(form.AssignedRoles.options[i].text);
                }
            }
        }

        if ( assignedRolesArray.length > 0 )
        {
			form.SelectedRoles.value = pack(assignedRolesArray);
		}

    }


    /*******************
    * FUNCTION HEADER *
    *******************/
    function backSelected()
    {
		document.eGuideRolesForm.elements["merge"].value="fw.eGuideTaskAttributes";
		document.eGuideRolesForm.elements["nextState"].value="displayCategoryAttributes";
		document.eGuideRolesForm.elements["CategoryList"].value="<%= c.toScript(c.var("eGuide.Category")) %>";
		document.eGuideRolesForm.submit();
    }


    /*******************
    * FUNCTION HEADER *
    *******************/
    function setRoleListFocus(list)
    {

        var form = document.eGuideRolesForm;

        if (list.name == "AssignedRoles")
        {
            form.AvailableRoles.selectedIndex=-1;
        }
        else
        {
            form.AssignedRoles.selectedIndex=-1;
        }

        var i = list.selectedIndex;
        var selected = list.options[i].value;

        var arr = selected.split("$");

		TaskAssignFrame.document.writeln("<LINK href='<%= c.getModulesUrl()%>/css/dev/hf_style.css' rel='styleSheet' type='text/css'>");
		TaskAssignFrame.document.writeln("<TABLE width='76%' border='0' cellspacing='0' cellpadding='0'>");
		TaskAssignFrame.document.writeln("<TR bgcolor='#EFEEE9'><TD class='tablesubhead1' style='width:65%'><%= c.toDisplay(c.string("eGuide.TaskBuilder.RoleType.Label")) %></TD></TR>");
		TaskAssignFrame.document.writeln("<TR><TD class='marginleft1' style='font-size: 0.75em'>&nbsp;&nbsp;" + urlDecode(arr[1]) + "<TR><TD>&nbsp;</TD></TR>");
		TaskAssignFrame.document.writeln("<TR bgcolor='#EFEEE9'><TD class='tablesubhead1' style='width:65%'><%= c.toDisplay(c.string("DevelopersForm.Role.RoleDescription")) %></TD></TR>");
		TaskAssignFrame.document.writeln("<TR><TD class='marginleft1' style='font-size: 0.75em'>&nbsp;&nbsp;" + urlDecode(arr[2]) + "</TD></TR></TABLE>");
		TaskAssignFrame.document.close();

		/*
		TaskAssignFrame.document.writeln("<DIV class='tablesubhead1' style='width:65%'><%= c.toDisplay(c.string("eGuide.TaskBuilder.RoleType.Label")) %></DIV>");
		TaskAssignFrame.document.writeln("<DIV class='marginleft1' style='font-size: 0.75em'>" + urlDecode(arr[1]) + "</DIV>");
		TaskAssignFrame.document.writeln("<DIV class='tablesubhead1' style='width:65%'><%= c.toDisplay(c.string("DevelopersForm.Role.RoleDescription")) %></DIV>");
		TaskAssignFrame.document.writeln("<DIV class='marginleft1' style='font-size: 0.75em'>" + urlDecode(arr[2]) + "</DIV>");
		TaskAssignFrame.document.close();
		*/

    }


    /*******************
    * FUNCTION HEADER *
    *******************/
    function addSelectedRole()
    {
        var form = document.eGuideRolesForm;
        moveListItems(form.AssignedRoles, form.AvailableRoles);
    }


   /*******************
    * FUNCTION HEADER *
    *******************/
    function removeSelectedRole()
    {
        var form = document.eGuideRolesForm;
        moveListItems(form.AvailableRoles, form.AssignedRoles);
    }


</SCRIPT>
</HEAD>

<BODY TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="returnFromOS();onPageLoad()">
<FORM name="eGuideRolesForm" method=post action="webacc" onSubmit="return(onPageSubmit())">
	<input  type=hidden name="taskId" value="<%= c.var("taskId") %>">
	<input  type=hidden name="merge" value="fw.eGuideTaskSummary">
	<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="taskSummary">
	<input  type=hidden name="SelectedRoles" value="">
	<input  type=hidden name="CategoryList" value="">
   <!-- End of hidden tags -->

   <% c.set("WizardHeader.title", c.toDisplay(c.string("eGuide.Taskbuilder.Title")));
      c.set("WizardHeader.subtitle", c.toDisplay(c.string("eGuide.Taskbuilder.AssignRole.SubTitle"))); %>
   <jsp:include page='<%= c.getPath("dev/WizardHeader_inc.jsp") %>' flush="true" />

   <DIV class="instructions"><%= c.toDisplay(c.string("eGuide.Taskbuilder.Roles.Description")) %></DIV>
   <BR>

   <table>
        <tr>
            <td class=mediumtext align="left" valign="bottom">
                <%= c.toDisplay(c.string("DevelopersForm.AvailableRoles")) %>
            </td>
            <td align="left">
            </td>
            <td class=mediumtext align="left" valign="bottom">
                <%= c.toDisplay(c.string("DevelopersForm.AssignedRoles")) %>
            </td>
        </tr>
        <tr>
            <td>
                <SELECT name="AvailableRoles" size=8 style="WIDTH: 180px"
                    multiple ondblclick="removeSelectedRole()"
                    onchange="setRoleListFocus(this)">
                    <% c.set("i", "0"); %>
						<!--
                        <% if (c.var("eGuide.Role.Count").equals("0")) { %>
                            <OPTION value="NoName"><%= c.toDisplay(c.string("Generic.EmptyListBracket")) %>
                        <% } %>
                        -->
                   <% while (c.lt(c.var("i"), c.var("eGuide.Role.Count"))) { %>
                        <OPTION value="<%= c.urlEncode(c.var("eGuide."+c.var("i")+ ".Role")) %>$<%= c.urlEncode(c.var("eGuide."+c.var("i")+ ".RoleType")) %>$<%= c.urlEncode(c.var("eGuide."+c.var("i")+ ".RoleDescription")) %>"><%= c.toDisplay(c.var("eGuide."+c.var("i")+ ".Role")) %>
                        <% c.inc("i");
                       } %>
                </SELECT>
            </td>
            <td>
                <table>
                    <tr>
                        <td valign="bottom">
                            <a href="javascript:removeSelectedRole()"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.ArrowRight.image") %>" alt="<%= c.string("Button.ArrowRight.alt") %>" border=0></a>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top">
                            <a href="javascript:addSelectedRole()"><IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.ArrowLeft.image") %>" alt="<%= c.string("Button.ArrowLeft.alt") %>" border=0></a>
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                <SELECT name="AssignedRoles" size=8 style="WIDTH: 180px"
                    multiple ondblclick="addSelectedRole()"
                    onchange="setRoleListFocus(this)">
                    <!-- ### Eventually implement this when we are editing vs. creating
                    <% c.set("i", "0"); %>
						<!--
                        <% if (c.var("AssignedRoleList.Count").equals("0")) { %>
                            <OPTION value="NoName"><%= c.toDisplay(c.string("Generic.EmptyListBracket")) %>
                        <% } %>
                        -->
                    <% while (c.lt(c.var("i"), c.var("AssignedRoleList.Count"))) { %>
                        <OPTION value="<%= c.var("AssignedRoleList.Element."+c.var("i")) %>"><%= c.var("AssignedRoleList.Element."+c.var("i")) %>
                        <% c.inc("i");
                       } %>
                    -->
                </SELECT>
            </td>
        </tr>
    </table>

   	<IFRAME src="webacc?taskId=dev.Empty&merge=fw.Empty" name="TaskAssignFrame" width="550" height="140" scrolling="auto" frameborder="0"></IFRAME>

	<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
      <TR>
      	<TD class="ruleabove">
      	<a href="#" onClick="javascript:backSelected();">
         	<IMG src="<%= c.getModulesUrl() + "/dev/images/" + c.string("Button.Back.image") %>" alt="<%= c.toHTML(c.string("Button.Back.alt")) %>" border=0></a>
            <INPUT type=image name="Next" alt="<%= c.toDisplay(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" />
         </TD>
      </TR>
   </TABLE>
   <BR>
</FORM>
</BODY>

</HTML>
