<%@  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="DeleteAttr.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.ChooseAttrForm.AvailableAttr.attachEvent('ondblclick',getSelectedAttr);
        else
            for (var i=0; i<document.ChooseAttrForm.AvailableAttr.length; i++) {
                document.ChooseAttrForm.AvailableAttr[i].addEventListener("dblclick",getSelectedAttr, false);
            }
}

function nextSelected()
{
   var selection = document.ChooseAttrForm.AvailableAttr.selectedIndex;
   if (document.ChooseAttrForm.AvailableAttr.options[selection].value == "NoSelection")
   {
      alert("<iman:string key='DeleteClass.MustChoose'/>");
   }
   else
   {
      if (getSelectedAttr())
      {
         if (choice = confirm("<iman:string key='DeleteClass.ConfirmDeletion'/>"))
         {
            document.ChooseAttrForm.elements["nextState"].value="getSelectedAttr";
            document.ChooseAttrForm.elements["Task.SelectedButton"].value="nextSelected";
            document.ChooseAttrForm.submit();
         }
      }
   }
}

function getSelectedAttr(event)
{
   // 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.ChooseAttrForm.AvailableAttr.options;
   var selectedItem  = document.ChooseAttrForm.AvailableAttr.selectedIndex;
   var selectedValue  = availOpt[selectedItem].value;
   var selectedAttr;
   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;
         }
         // Call AreYouSure function here
         selectedAttr = selectedValue;
       }
   }
   document.ChooseAttrForm.elements["SelectedAttribute"].value = selectedAttr;
   return true;
}

function setFocus()
{
   document.ChooseAttrForm.AvailableAttr.focus();
}
</SCRIPT>
</HEAD>

<BODY text="#000000" link="#000000" vlink="#000000" alink="#000000" bgcolor="#FFFFFF"onLoad="setFocus(),detectBrowser();">
<FORM name="ChooseAttrForm" 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() %>"><!-- Can't use iman:resultString for this one. Why? -->
<INPUT type="hidden" name="Task.SelectedButton" value="">
<INPUT type="hidden" name="SelectedAttribute" value="<iman:resultString key='SelectedAttribute'/>">

<iman:taskHeader titleKey="DeleteAttr.Title" iconUrl="dir/schema.gif" iconAlt="SchemaManagementDisplayName"/>

<!----------------------------- STEPS & INSTRUCTION TABLE --------------------------------------->
<TABLE border="0" cellspacing="0" cellpadding="2" width="90%">
   <TR valign="baseline">
      <TD>&nbsp;</TD>
   </TR>
   <TR valign="baseline">
      <TD height="22" valign="middle" class="instructions">
         <iman:string key="DeleteAttr.SelectInstr"/><BR><BR>
      </TD>
   </TR>
</TABLE>
<!----------------------------- CONTENT TABLE --------------------------------------->
<TABLE name="AttrSelectionTable" border="0" cellspacing="0" cellpadding="2" width="90%">
   <TR>
      <TD align="left" class="mediumtext"><iman:string key="SchemaAvailAttr"/>
   <TR valign="baseline">
      <TD class="mediumtext">
      <!-- Populating the select box with the webaccess code --->
         <SELECT name="AvailableAttr" size=10 style="WIDTH: 250px">
         <c:forEach items="${AvailableAttrList}" var="attrName"> 
         	<%--  use regular jstl for the value, but call NoBR for the display--%>
         	<OPTION value="<c:out value='${attrName}'/>" ><iman:nobr><c:out value="${attrName}"/></iman:nobr></OPTION>
         </c:forEach>
         
         </SELECT>
      </TD>
   <TR valign="baseline">
      <TD height="22" valign="middle" class="instructions">
      <BR><iman:string key="DeleteAttr.Note"/>
      </TD>
   </TR>
</TABLE>
<!------------------------- BUTTON TABLE --------------------------->
<TABLE width="100%" border="0" cellspacing="0" cellpadding="2" height="25">
   <TR>
      <TD><iman:include page="dev/Bar_inc.jsp" /></TD>
   </TR>
   <TR>
      <TD>&nbsp;&nbsp;<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>
