<%--
  Copyright 2003 Sun Microsystems, Inc. All rights reserved 
  Use is subject to license terms.
 --%>
<%-- @(#)feedbackForm.jsp --%>

<%@page errorPage="error.jsp" %> 

<%@page language= "java" import="java.text.*,java.util.Date,
				com.sun.portal.search.util.Encoder, com.sun.portal.search.util.DateParser" %>

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

<%-- Get portal config information and portal desktop theme values --%> 
<%@ include file= "portal.jsp" %> 
<jx:declare id="tFontColor" type="java.lang.String"/>
<jx:declare id="tFontFace" type="java.lang.String"/>
<jx:declare id="tTitleBarColor" type="java.lang.String" />
<jx:declare id="tTitleFontColor" type="java.lang.String" />
<jx:declare id="tBorderColor" type="java.lang.String"/>
<jx:declare id="tBgColor" type="java.lang.String"/>

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

<STYLE type="text/css">
    .discMessage{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:x-small; font-weight: bold;} 
    .discTitle{font-family: <%=tFontFace%>; font-size:small; font-weight: bold;} 
    .discTitleHeader{font-family: <%=tFontFace%>; font-size:medium; font-weight: bold;} 
    .discDate{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:small;} 
    .discRating{font-family: <%=tFontFace%>; font-size:small; font-weight: bold;} 
    .discDesc{font-family: <%=tFontFace%>; color: <%=tFontColor%>; font-size:small;} 
    .discLabel{font-family: <%=tFontFace%>; color: <%=tTitleFontColor%>; font-size:large; font-weight: bold;}
    .discButton{background: <%=tTitleBarColor%>; color:<%=tTitleFontColor%>; font-family: <%=tFontFace%>; font-size:small; font-weight: bold;} 
</STYLE>

<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH="100%">
<tr><td colspan="2" img="<dt:scontent/>/images/spacer.gif" width="1" height="10"></td>
</tr>

<%
String rid = "";
String database= "";
if ((request.getParameter("ref_id") != null) && (request.getParameter("database") != null)) {
    database = request.getParameter("database");
    rid = request.getParameter("ref_id");
    String query = "URL = "+rid; 
%>
    <jx:set var="query">
       <%=query%>
    </jx:set>
    <jx:set var="viewOrder" value=""/>
    <jx:set var="dbname">
    <%=database%>
    </jx:set>
    <search:searchContext>
	<%@ include file="query.jsp"%>
	<%@ include file="feedbackDisplay.jsp"%>
    </search:searchContext>
<% } %>

<%
// set the form title value
String title = "";
if ((title = request.getParameter("t")) == null) {
    title = "";
} else {
    title = "Re: "+title;
}
%>

<script language=Javascript>

function check_submit() {
    var haveTitle = document.form.title.value != '';
    if (!haveTitle) {
	alert('Please give your feedback a title!');
	return;
    }

    var haveBody = document.form.desc.value != '';
    if (!haveBody && !confirm('Confirm empty feedback...')) {
       return;
    }

   document.form.submit();
}
</script>

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

<tr>
<td bgcolor=<%=tBorderColor%> width=100% colspan="2">&nbsp;&nbsp;&nbsp;
<% if (rid.equals("")) { %>
    <span class= "discLabel">Start a New Discussion</span>
<% } else { %>
    <span class= "discLabel">Post Reply</span>
<% } %>
</TD>
</TR>

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


<FORM name=form METHOD=POST>
<input type=hidden name="<%=channelName%>_dmode" value="cmt">
<input type=hidden name="rid" value="<%=rid%>">
<input type=hidden name="database" value="<%=database%>">

<center>

<tr>
<td colspan=2">
<table>
<tr valign="middle">
<td align="right" class="discTitle"><LABEL FOR="title">Title: </LABEL>&nbsp;&nbsp;</TD>
<td class="discDesc"><input type=text name="title" size=62 value="<%=title%>" id="title">
</td>
</tr>

<tr valign=top>
<td align="right" class="discTitle"><LABEL FOR="message">Message: </LABEL>&nbsp;&nbsp;</TD>
<td class="discDesc"><textarea name="desc" wrap=soft rows=20 cols=60 id="message"></textarea>
</td>
</tr>

<tr valign=middle>
<td align="right" class="discTitle">
<LABEL FOR="rating">Rating: </LABEL>&nbsp;&nbsp;</td>
<td class="discDesc">
<select name="rtg" id="rating">
<option value=-1> Irrelevant 
<option value=0> Routine
<option value=1 selected> Interesting
<option value=2> Important
<option value=3> Must Read
</SELECT></td>
</tr>

<tr>
<td colspan = "2" align="right"><INPUT TYPE=button NAME="post" VALUE="Post" class="discButton" onClick="javascript:check_submit();">&nbsp;&nbsp;
<%
String cancelUrl = rid.equals("") ? dpurl : dpurl+"?"+channelName+"_dmode=vl&did="+rid;
%>
<INPUT TYPE=button NAME="cancel" VALUE="Cancel" onClick="javascript:top.document.location.href='<%=cancelUrl%>'" class="discButton"></td>
</tr>
</table>

</td>
</tr>

</center>
</FORM>
</TABLE>
