<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- @(#)viewDiscussionHeader.jsp --%>
<%@page language= "java" import="com.sun.portal.search.util.Encoder,
				com.sun.portal.search.util.DateParser, 
				com.sun.portal.search.soif.SOIF, 
				com.sun.portal.discussions.providers.Comments,
				com.sun.portal.search.providers.SearchContext,
				java.lang.*, java.util.*, java.text.*" %>

<%@ taglib uri="/tld/jx.tld" prefix="jx" %>
<%@ taglib uri="/tld/desktop.tld" prefix="dt" %>

<jx:declare id="tTitleBarColor" type="java.lang.String"/>
<jx:declare id="channelHighlightColor" type="java.lang.String"/>
<jx:declare id="channelName" type="java.lang.String"/>
<jx:declare id="dbname" type="java.lang.String"/>
<jx:declare id="locale" type="java.util.Locale"/>
<jx:declare id="dpurl" type="java.lang.String"/>

<%
// Get first element which is the main item for this subtree
// Display main item 
Comments comments = (Comments)pageContext.findAttribute("comments");
SOIF s = new SOIF();
if (comments != null) {
    s = (SOIF)comments.getRootSOIF();
    if (s == null) return;
}
%>

<%-- Include navigation bar which has links to other related pages --%>
<jsp:include page="viewDiscussionNavigation.jsp" flush="true"/>

<tr>
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td>
</tr>

<tr> 
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height= "1"></td>
<td bgcolor="<%=tTitleBarColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="100%" height="1"></td>
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<tr>
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td>
</tr>

<%-- Display Title --%>
<tr bgcolor="<%=channelHighlightColor%>">
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
<td width="100%">
<% if (s.getValue("title") != null) { %>
    <a href="<%=dpurl%>?<%=channelName%>_dmode=vl&did=<%=Encoder.urlEncode(s.getURL())%>"><span class="discTitleHeader"><%=s.getValue("title")%></span></a>
<% } %>
</td>

<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<%-- Display Author and Date --%>
<tr bgcolor="<%=channelHighlightColor%>">
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
<td width="100%">
<% String author = s.getValue("author"); %>
<% 
if ((author == null) || author.equals("") || author.equals("authlessanonymous")) 
   author = (String)pageContext.findAttribute("anonymousAuthor"); 
%>

<span class="discTitle">
Posted by <%=author%>
<% 
String lastPost = s.getValue("rd-last-changed"); 
if (lastPost != null) {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale); %>
    <% try {
        Date d = DateParser.parse(lastPost); %>
	on <%=df.format(d)%>
    <% } catch (Exception e) { } %>
<% } %>
</span>

<%-- Display Rating --%>
<% 
String pkrating = s.getValue("rd-rating"); 
if (pkrating != null) { 
    int rtg = Integer.parseInt(pkrating); 
    if (pkrating.equals("-1")) { 
	pkrating = "Irrelevant"; 
    } else if (pkrating.equals("0")) { 
	pkrating = "Routine"; 
    } else if (pkrating.equals("1")) { 
	pkrating = "Interesting"; 
    } else if (pkrating.equals("2")) { 
	pkrating = "Important"; 
    } else if (pkrating.equals("3")) { 
	pkrating = "Must Read"; 
    } else { 
	pkrating = "Routine"; 
    } %> 

    <span class="discRating">(<%=pkrating%>)</span>
<% } %>
</td>
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<tr bgcolor="<%=channelHighlightColor%>">
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="10"></td>
</tr>

<%-- Display description --%>
<tr bgcolor="<%=channelHighlightColor%>">
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
<td width="100%">
<% if (s.getValue("description") != null) { %>
    <span class="discDesc"><%=SearchContext.htmlEncode(s.getValue("description"))%></span>
<% } %>
</td>
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<%-- Display Rating menu --%>
<jx:set var="rating">
    <%=s.getValue("rd-rating")%>
</jx:set>
<jx:set var="rid">
    <%=s.getURL()%>
</jx:set>
<% String did = request.getParameter("did"); %>
<tr bgcolor="<%=channelHighlightColor%>">
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
<td width="100%"><%@ include file="rating.jsp" %></td>
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<tr bgcolor="<%=channelHighlightColor%>">
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td>
</tr>

<tr> 
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height= "1"></td>
<td bgcolor="<%=tTitleBarColor%>"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
<td><img src="<dt:scontent/>/images/spacer.gif" width="1" height="1"></td>
</tr>

<tr>
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td>
</tr>

<%-- Include navigation bar which has links to other related pages --%>
<jsp:include page="viewDiscussionNavigation.jsp" flush="true"/>

<tr>
<td colspan="3"><img src="<dt:scontent/>/images/spacer.gif" width="1" height="5"></td>
</tr>
