/***********************************************************************************
 * @Name	legend.js
 * @author 	Kris Kline
 * 
 * @Purpose	This script handles putting the legend on the page
 * 
 * Date Created:	27 FEB 2003
 * Date Modified:	27 FEB 2003
 **********************************************************************************/

var STR_LEGEND_TITLE="Explanation";
var STR_LEGEND_TITLE_CLASS="legendTitle";

var STR_LEGEND_TITLE_SUB="Est. Depth of Water (ft)";
var STR_LEGEND_TITLE_SUB_CLASS="legendSubTitle";

var STR_LEGEND_TABLE_OUTER="legendTable";
var STR_LEGEND_TABLE_INNER="legendInternalTable";

var STR_LEGEND_PIC_CELL_CLASS="legendCellPic";

var STR_LEGEND_NAME_CELL_CLASS="legendCellName";

var STR_LEGEND_ITEM_FONT="legendItem";

var N_NUM_ELEMENTS=6;
var N_NUM_COLUMNS=2;
var N_NUM_LEGENDS=2;

var N_LEGEND_NEW_1=19;

var strLegendNames = new Array(N_NUM_LEGENDS);

strLegendNames[0] = new Array(N_NUM_ELEMENTS);
strLegendNames[0][0]="0.0 - 1.0";
strLegendNames[0][1]="1.0 - 2.0";
strLegendNames[0][2]="2.0 - 3.0";
strLegendNames[0][3]="3.0 - 4.0";
strLegendNames[0][4]="4.0 - 5.0";
strLegendNames[0][5]="> 5.0";

strLegendNames[1] = new Array(N_NUM_ELEMENTS);
strLegendNames[1][0]="0.0 - 2.0";
strLegendNames[1][1]="2.0 - 4.0";
strLegendNames[1][2]="4.0 - 6.0";
strLegendNames[1][3]="6.0 - 8.0";
strLegendNames[1][4]="8.0 - 10.0";
strLegendNames[1][5]="> 10.0";

var STR_LEGEND_PIC_ROOT="pics/legendpic";
var STR_LEGEND_PIC_EXT="jpg";


/*********************************************************************
 * @Function	putLegendSubTitle
 * @Script	legend.js
 * @author 	Kris Kline
 *
 * This method puts the legend sub-title onto the page
 *
 ********************************************************************/
function putLegendSubTitle( )
{
	document.writeln("<CENTER>");
	document.writeln("<FONT CLASS=" + STR_LEGEND_TITLE_SUB_CLASS + ">" +
			 	STR_LEGEND_TITLE_SUB + 
			 	"</FONT>");
	document.writeln("</CENTER>");
} // putLegendSubTitle


/*********************************************************************
 * @Function	putLegendTitle
 * @Script	legend.js
 * @author 	Kris Kline
 *
 * This method puts the legend title cell onto the page
 *
 ********************************************************************/
function putLegendTitle( )
{
	document.writeln("<TR>");
	document.writeln("	<TD COLSPAN=" + (N_NUM_COLUMNS * 2) + " " +
			 	"CLASS=" + STR_LEGEND_TITLE_CLASS + ">");
	document.writeln("	<CENTER>");
	document.writeln("	<FONT CLASS=" + STR_LEGEND_TITLE_CLASS + ">" +
			 	STR_LEGEND_TITLE + 
			 	"</FONT>");
	document.writeln("	</CENTER>");
	putLegendSubTitle( );
	document.writeln("	</TD>");
	document.writeln("</TR>");
} // putLegendTitle

/*********************************************************************
 * @Function	putLegendNames
 * @Script	legend.js
 * @author 	Kris Kline
 *
 * This function puts in all the legend names
 *
 * @param arrNames	The array of all the names
 * @param strPicRoot	The root of all the legend pictures
 * @param strPicExt	The extenstion of all the legend pictures
 ********************************************************************/
function putLegendNames(arrNames, strPicRoot, strPicExt)
{
	for(var x=0;x<arrNames.length;)
	{
		document.writeln("<TR>");
		for(var y=0;y<N_NUM_COLUMNS && x+y<arrNames.length;y++)
		{
			document.writeln("<TD CLASS=" + 
					 STR_LEGEND_PIC_CELL_CLASS + ">");
			document.writeln("<IMG SRC='" +
					 strPicRoot + "_" + (x+y+1) + "." + strPicExt + "' " +
					 "BORDER=0>");
			document.writeln("</TD>");
			document.writeln("<TD CLASS=" + 
					 STR_LEGEND_NAME_CELL_CLASS + ">");
			document.writeln("<FONT CLASS=" +
					 STR_LEGEND_ITEM_FONT + ">" +
					 arrNames[x+y] + "</FONT>");
			document.writeln("</TD>");
		}
		document.writeln("</TR>");
		x+=N_NUM_COLUMNS;
	}
} // putLegendNames


/*********************************************************************
 * @Function	putInternalTable
 * @Script	legend.js
 * @author 	Kris Kline
 *
 * This function puts in all the legend names
 *
 * @param nHeight		The height to put the legend for
 ********************************************************************/
function putInternalTable(nHeight)
{
	document.writeln("<TABLE BORDER=0 "+
			 	"CELLPADDING=2 CELLSPACING=2 " + 
				"CLASS=" + STR_LEGEND_TABLE_INNER + ">");

	putLegendTitle( );
	
	if(nHeight<N_LEGEND_NEW_1)
	{
		putLegendNames(strLegendNames[0],
				STR_LEGEND_PIC_ROOT,
				STR_LEGEND_PIC_EXT);
	}
	else
	{
		putLegendNames(strLegendNames[1],
				STR_LEGEND_PIC_ROOT,
				STR_LEGEND_PIC_EXT);
	}
	document.writeln("</TABLE>");
} // putInternalTable


/*********************************************************************
 * @Function	putLegend
 * @Script	legend.js
 * @author 	Kris Kline
 *
 * This method puts the entire legend onto the page
 *
 * @param nHeight		The height to put the legend for
 ********************************************************************/
function putLegend(nHeight)
{
	document.writeln("<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0" +
			 	" CLASS=" + STR_LEGEND_TABLE_OUTER + ">\n" +
			 "	<TR>\n" +
			 "		<TD>");
	putInternalTable(nHeight);
	document.writeln("		</TD>\n" +
			 "	</TR>\n" +
			 "</TABLE>");

} // putLegend

