<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- @(#)viewDiscussionBar.jsp --%>
<%@page language= "java" import=" java.util.*, java.text.*" %> 
				
<%@page errorPage="error.jsp" %> 
<%@ taglib uri="/tld/jx.tld" prefix="jx" %> 
<%@ taglib uri="/tld/desktop.tld" prefix="dt" %> 

<jx:declare id="tBorderColor" type="java.lang.String"/>
<jx:declare id="tTitleBarColor" type="java.lang.String"/>

<jx:declare id="ddd" type="java.lang.String"/>
<jx:declare id="df" type="java.lang.String"/>
<jx:declare id="det" type="java.lang.String"/>
<jx:declare id="dbname" type="java.lang.String"/>
<jx:declare id="desktopPathInfo" type="java.lang.String"/>
<jx:declare id="channelName" type="java.lang.String"/>

<%
// set the 'SELECTED' values for all the form fields 
// scriptlet evaluates user selection from the request
// or pick the default values from display profile. 

// FLAT/ THREADED
boolean threaded = false;
String selectFlat = "", selectThreaded="";
if (request.getParameter("th") != null) {
  String th = request.getParameter("th");
  if (th.equalsIgnoreCase("threaded")) {
    threaded = true;
    selectThreaded = "SELECTED";
  } else {
    selectFlat = "SELECTED";
  }
} else {
  // get from display profile
  if (ddd.equalsIgnoreCase("threaded")) {
    threaded = true;
    selectThreaded = "SELECTED";
  } else {
    selectFlat = "SELECTED";
  }
}
pageContext.setAttribute("threaded", new Boolean(threaded), PageContext.REQUEST_SCOPE);

// EXPAND / COLLAPSE 
boolean expand = false;
String selectExpand = "", selectCollapse =  "";
if (request.getParameter("show") != null) {
  String exp = request.getParameter("show");
  if (exp.equalsIgnoreCase("Expand")) {
    expand= true;
    selectExpand= "SELECTED";
  } else {
    selectCollapse = "SELECTED";
  }
} else {
   // get from display profile
  if (det.equalsIgnoreCase("Expand All")) {
    expand= true;
    selectExpand= "SELECTED";
  } else {
    selectCollapse = "SELECTED";
  }
}
pageContext.setAttribute("expand", new Boolean(expand), PageContext.REQUEST_SCOPE);

// RATING FILTER. IRRELEVANT...MUST READ 
int filter = 0;
String f0="", f1="",f2="",f3="", fminus1="";
if (request.getParameter("f") != null) {
  String f = request.getParameter("f");
  filter = Integer.parseInt(f);
  if (f.equalsIgnoreCase("-1")) {
    fminus1 = "SELECTED";
  } else if (f.equalsIgnoreCase("0")) {
    f0 = "SELECTED";
  } else if (f.equalsIgnoreCase("1")) {
    f1 = "SELECTED";
  } else if (f.equalsIgnoreCase("2")) {
    f2 = "SELECTED";
  } else {
    f3 = "SELECTED";
  }
} else {
    // get from display profile
    if (df.equalsIgnoreCase("Irrelevant")) {
       fminus1 = "SELECTED";
       filter = -1;
    } else if (df.equalsIgnoreCase("Routine")) {
       f0 = "SELECTED";
       filter = 0;
    } else if (df.equalsIgnoreCase("Interesting")) {
      f1 = "SELECTED";
       filter = 1;
    } else if (df.equalsIgnoreCase("Important")) {
       f2 = "SELECTED";
       filter = 2;
    } else {
       f3 = "SELECTED";
       filter = 3;
    }
}
pageContext.setAttribute("filter", new Integer(filter), PageContext.REQUEST_SCOPE);

%>
<tr>
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0" width="100%"> 

<tr> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="5"></td> 
<td bgcolor="<%=tBorderColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="5" height="1"></td> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="5" height="5"></td> 
<td bgcolor="<%=tBorderColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="5"></td> 
</tr>

<form NAME="dform" METHOD=GET ENCTYPE="application/x-www-form-urlencoded">
<INPUT type=HIDDEN name="<%=channelName%>_dmode" value="vl">
<% 
String did = request.getParameter("did");
if (did != null) { %>
    <INPUT type=HIDDEN name="did" value="<%=did%>">
<% } %>

<tr bgcolor="<%=tBorderColor%>"> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="1"></td> 
<td width="1%" valign="baseline" nowrap> &nbsp;
<span class="discBarLbl"><LABEL FOR="threaded">View:</LABEL></span>
<span class="discBarFont">
<select name="th" id="threaded"  onChange="javascript:document.dform.submit()">
<option value="threaded" <%=selectThreaded%>>Threaded</option>
<option value="flat" <%=selectFlat%>>Flat</option>
</select></span>

&nbsp;

<span class="discBarLbl"><LABEL FOR="filter">Filter:</LABEL></span>
<span class="discBarFont">
<select name="f" id="filter" onChange="javascript:document.dform.submit()">
<option value=-1 <%=fminus1%>>Irrelevant</option>
<option value=0 <%=f0%>>Routine</option>
<option value=1 <%=f1%>>Interesting</option>
<option value=2 <%=f2%>>Important</option>
<option value=3 <%=f3%>>Must read</option>
</select></span>

&nbsp;
<span class="discBarLbl"><LABEL FOR="threshold">Threshold:</LABEL></span>
<span class="discBarFont">
<select name="show" id="threshold" onChange="javascript:document.dform.submit()">
<option value="Expand" <%=selectExpand%>>Expand all</option>
<option value="Collapse" <%=selectCollapse%>>Collapse all</option>
</select></span>&nbsp;
</td>
</form>

<td bgcolor="#FFFFFF" width="1"><img src="<dt:scontent/>/images/spacer.gif" width="5" height="1"></td>
<%
String q = request.getParameter("scope");
if (q == null) q = "";
%>
<form NAME="searchform" ACTION="<%=desktopPathInfo%>" METHOD="GET" target="ps_main">
<td width="98%" valign="baseline" nowrap>
<jx:if test="$displaySearch">
    <input type="hidden" name="mode" value="basic">
    <input type="hidden" name="searchdiscussion" value="<%=dbname%>">
    <input type="hidden" name="database" value="<%=dbname%>">
    <input type="hidden" name="did" value="<%=did%>">
    <input type="hidden" name="page" value="1">

    &nbsp;<LABEL FOR="searchbox"></LABEL>
    <INPUT TYPE="text" NAME="scope" VALUE = "<%=q%>" size="14" id="searchbox">&nbsp;
    <INPUT TYPE=SUBMIT NAME="Submit" VALUE="Search Discussion" class="discSearchButton">&nbsp;
</jx:if>
</td> 
</form>
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="1"></td>
</tr>

<tr> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="5"></td> 
<td bgcolor="<%=tBorderColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="5" height="5"></td> 
<td bgcolor="<%=tBorderColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td> 
<td bgcolor="#FFFFFF"><img src="<dt:scontent/>/images/spacer.gif" width="2" height="5"></td> 
</tr>

</table>
</td>
</tr>
