<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.emframe.dev.eMFrameUtils" %>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x.tld" prefix="x" %>

<iman:stringtable bundle="DevResources"/>
<iman:stringtable bundle="BaseResources"/>
   
<HTML>
<HEAD>
<TITLE><iman:string key="DeleteClass.Title"/></TITLE>
<iman:stylesheet/>
<iman:include page="dev/OSScripts_inc.jsp" />
<iman:include page="dev/eMFrameScripts_inc.jsp" />
<!------------------------------ JAVA SCRIPT STARTS HERE ------------------------------------->

<SCRIPT language="JavaScript">

function detectBrowser(){
    var appVer = navigator.appVersion;
    var iePos = appVer.indexOf('MSIE');
        if (iePos != -1)
    	    document.ChooseClassForm.AvailableClasses.attachEvent('ondblclick',getSelectedClass);
        else{
            var availAttrOpt = document.ChooseClassForm.AvailableClasses.options;
            addDblClickEvent(availAttrOpt);
        }
}

function addDblClickEvent(x)
{
    sortedArray = new Array();

    for (var i=0; i<x.length; i++) {
        sortedArray[i] = new Array(x[i].text, x[i].value, false, false);
    }

    for (var i=0; i<x.length; i++) {
        x[i] = new Option(sortedArray[i][0], sortedArray[i][1], sortedArray[i][2], sortedArray[i][3]);
        x[i].addEventListener("dblclick",getSelectedClass, false);
        x[i].selected = sortedArray[i][3];
    }

    return;
}

function nextSelected()
{
   var selection = document.ChooseClassForm.AvailableClasses.selectedIndex;
   if (document.ChooseClassForm.AvailableClasses.options[selection].value == "NoSelection")
   {
      alert("<iman:string key='DeleteClass.MustChoose'/>");

   }
   else
   {
      if (getSelectedClass())
      {
         if (choice = confirm("<iman:string key='DeleteClass.ConfirmDeletion' />"))
         {
            document.ChooseClassForm.elements["nextState"].value="getSelectedClass";
            document.ChooseClassForm.elements["Task.SelectedButton"].value="nextSelected";
            document.ChooseClassForm.submit();
         }
      }
   }
}

function getSelectedClass()
{
   // Find out if selection is made and then put up a message box that makes sure that
   // they really want to delete the class. If yes, then get the selected class and
   // delete the class.
   var availOpt = document.ChooseClassForm.AvailableClasses.options;
   var selectedItem  = document.ChooseClassForm.AvailableClasses.selectedIndex;
   var selectedValue  = availOpt[selectedItem].value;
   var selectedClass;

   for(var i = 0; i < availOpt.length; i++)
   {
      if(availOpt[i].selected)
      {
         if(availOpt[i].value=="NoSelection")
         {
            alert("<iman:string key='AddAttribute.MustMakeSelection'/>");
            return false;
         }
         selectedClass = selectedValue;
      }
   }
   document.ChooseClassForm.elements["SelectedClass"].value = selectedClass;
   return true;
}

function setFocus()
{
   document.ChooseClassForm.AvailableClasses.focus();
}

</SCRIPT>
</HEAD>
<BODY text="#000000" link="#000000" vlink="#000000" alink="#000000" bgcolor="#FFFFFF" onLoad="setFocus(),detectBrowser();">
<FORM name="ChooseClassForm" method=post action="webacc">

<!------------------------ BEGIN WEBACCESS VARIABLES ---------------------------->

<INPUT type="hidden" name="merge" value="">
<INPUT type="hidden" name="error" value="dev.GenErr">
<INPUT type="hidden" name="User.context" value="<iman:resultString key='User.context' />">
<INPUT type="hidden" name="nextState" value="">
<INPUT type="hidden" name="taskId" value="<%= request.getAttribute("taskId").toString() %>"><!--  iman:resultString doesn't work here. -->
<INPUT type="hidden" name="Task.SelectedButton" value="">
<INPUT type="hidden" name="SelectedClass" value="<iman:resultString key='SelectedClass'/>">
   
<iman:taskHeader titleKey="DeleteClass.Title" iconUrl="dir/schema.gif" iconAlt="SchemaManagementDisplayName"/>
<!----------------------------- STEPS & INSTRUCTION TABLE --------------------------------------->
<TABLE border="0" cellspacing="0" cellpadding="2" width="90%">
<TR valign="baseline">
<TD height="16" colspan="7" align="center" valign="middle" class="instructions">
&nbsp;
</TD>
</TR>
<TR valign="baseline">
<TD height="22" valign="middle" class="instructions">
<iman:string key="DeleteClass.SelectInstr"/><BR><BR>
</TD>
</TR>
</TABLE>
<!----------------------------- CONTENT TABLE --------------------------------------->
<TABLE name="ClassSelectionTable" border="0" cellspacing="0" cellpadding="2" width="90%">
<TR valign="baseline">
<TD align="left" class="mediumtext"><iman:string key="SchemaAvailCls"/></TD>
</TR>
<TR valign="baseline">
<TD class="mediumtext">
<!-- Populating the select box with the webaccess code --->
<SELECT name="AvailableClasses" size=10 style="WIDTH: 250px"> 
	<c:forEach items="${AvailableClassList}" var="className"> 
         <%--  use regular jstl for the value, but call NoBR for the display--%>
         <OPTION value="<c:out value='${className}'/>" ><iman:nobr><c:out value="${className}"/></iman:nobr></OPTION>
	</c:forEach>  

</SELECT>
</TD>
</TR>
<TR valign="baseline">
<TD height="22" valign="middle" class="instructions">
<BR><iman:string key="DeleteClass.Note" />
</TD>
</TABLE>
<!------------------------- BUTTON TABLE --------------------------->
<TABLE width="100%" border="0" cellspacing="0" cellpadding="2" height="25">
<TR>
<TD><iman:bar/></TD>
</TR>
<TR>
<TD><iman:button key="OK" onClick="javascript:nextSelected();return false"/>
<iman:include page="dev/Cancel_inc.jsp" />
</TD>
</TR>
</TABLE>
</FORM>
<iman:include page="dev/OSFooter_inc.jsp" />
</BODY></HTML>
