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

<search:getValue attribute="score" id="documentScore"/>

<%
    // Configure here if you like
    int minWidth = 4;		// minimum score bar width for non-zero score
    int totalWidth = 35;	// total score bar width
    double gamma = 2.5;		// expands the scale for higher scores

    int score = 0;
    try { score = Integer.parseInt((String)pageContext.getAttribute("documentScore")); }
    catch (Exception e) {}

    // in case search engine returns wackiness
    if (score > 100)
    	score = 100;
    if (score < 0)
    	score = 0;

    // calculate score image widths
    int scoreWidth = 0;
    if (score > 0)
	scoreWidth = minWidth + (int)(Math.pow(score/100.0, gamma) * (totalWidth - minWidth));
    int remainderWidth = totalWidth - scoreWidth;

    // pad the score string to fixed width
    String scorePad = "";
    if (score < 100)
	scorePad = "0";
    if (score < 10)
	scorePad += "0";
%>

<%-- Start output, beginning in <TR> context --%>

<table align=left cellpadding=5 cellspacing=0 border=0>
<tr>
    <TD style='background-color:<%=tBgColor%>; vertical-align:top'><FONT color=<%=tBgColor%> face="times, serif"><%=scorePad%></font><FONT face="times, serif"><%=score%></FONT></TD>
</tr></table>

<table align=left cellpadding=0 cellspacing=0 border=0>

 <tr><td colspan=2><font size=-2>&nbsp;</font></td></tr>

<TR>
	<% if (scoreWidth != 0) { %>
	    <TD bgcolor="<%=tBorderColor%>" ><img src="<dt:scontent/>/static/search/images/blank.gif" width="<%=scoreWidth%>" height="6" alt="<%=score%>% Relevant"></TD>
	<% } %>
	<% if (remainderWidth != 0) { %>
	    <TD bgcolor="#DDDDDD"><img src="<dt:scontent/>/static/search/images/blank.gif" width="<%=remainderWidth%>" height="6" alt="<%=score%>% Relevant"></TD>
	<% } %>
	</TR>

</TABLE>



