//===============================================================================
// Name:     mainScript.js
// Purpose:  The main scripts for all the pages
// Version:  1.0
//------------------------------------------------------------------------------
var N_FLOODHEIGHT_MIN=17;
var N_FLOODHEIGHT_MAX=23;


var STR_WARNING_NONE="No Flood Forecast";
var STR_WARNING_PRE="NWS Flood Forecast:<br>";
var STR_WARNING_POST=" ft., ";
var STR_WARNING_POST1=" at ";
var STR_WARNING_POST2=" for 119<sup>th</sup> St.";
var STR_WARNING_SUB="by the National Weather Service";

var STR_BLANK_PIC="pics/blank.gif";
var N_BLANK_PIC_W=10;

var STR_MAPBROWSE_PAGE="mapBrowse.shtml";
var STR_MAPBROWSE_PAGE_ABS="mapBrowse.shtml";

var STR_RETURN_PIC="pics/return.gif";
var N_CLIP_WIDTH=701;
//var N_CLIP_WIDTH=466;
//var N_CLIP_WIDTH=448;
//var N_CLIP_WIDTH=400;
var N_RETURN_WIDTH=97;

var STR_FLOODBROWSE_VALUE = "floodHeight";
var STR_MAPS_DIR = "maps/";


var nSecWidths = new Array(nNumSecs);
var nSecHeights = new Array(nNumSecs);
var nSecStarts = new Array(nNumSecs);
nSecWidths[0]=N_SEC1_W;
nSecWidths[1]=N_SEC2_W;
nSecWidths[2]=N_SEC3_W;
nSecHeights[0]=N_SEC1_H;
nSecHeights[1]=N_SEC2_H;
nSecHeights[2]=N_SEC3_H;
nSecStarts[0]=N_SEC1_S;
nSecStarts[1]=N_SEC2_S;
nSecStarts[2]=N_SEC3_S;

//var nFloodHeightForecast;  -- Specified in a CGI script included with SSI
//var strFloodHeightForecastAt;  -- Specified in a CGI script included with SSI
//var strFloodHeightForecastTime;  -- Specified in a CGI script included with SSI
//var nFloodDischargeForecast;  -- Specified in a CGI script included with SSI

var dateFloodHeightForecastAt;
var dateFloodHeightForecastTime;

//var nCreekHeightCurrent;  -- Specified in a CGI script included with SSI
//var strCreekHeightCurrentTime;  -- Specified in a CGI script included with SSI

var nFloodHeightCurrent;
var dateCreekHeightCurrentTime;

var nFloodHeightBrowse;

var nFloodHeight1998 = 22;
var STR_MAP_PIC_1998 = "pics/98floodmap.jpg";
var N_98_PIC_W=281;

var currRow=0;
var currCol=0;
var currSec=0;
var currClipRow=0;
var currClipCol=0;

var STR_MAP_PIC_MAIN_NAME="full";
var STR_MAP_PIC_MAIN_EXT="jpg";

var STR_MAP_PIC_CLIP_EXT="jpg";

//setFloodForecastHeight( );
setFloodCurrentHeight( );
setFloodBrowseHeight( );
		

/*******************************************************************************
 * Function:	getFloodForecastHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function parses the data file to get the flood forecast height
 * 
 * @return The forecasted height
 ******************************************************************************/
function getFloodForecastHeight( )
{
	if(!nFloodHeightForecast || nFloodHeightForecast==null || nFloodHeightForecast<=0.0)
		return 0;
		
	dateFloodHeightForecastAt=Date.parse(strFloodHeightForecastAt);
	dateFloodHeightForecastTime=Date.parse(strFloodHeightForecastTime);
	
	return nFloodHeightForecast;
} // getFloodForecastHeight				


/*******************************************************************************
 * Function:	setFloodForecastHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function retrieves the flood forecast height
 ******************************************************************************/
function setFloodForecastHeight( )
{
	var nFHeight=0;
	nFHeight=getFloodForecastHeight( );
	//nFHeight=18;
	if(!isValidForecastHeight(nFHeight))
	{
		nFloodHeightForecast = 0;	
	} // if(!isValidForecastHeight(nFHeight))
	else
		nFloodHeightForecast = nFHeight;
} // setFloodForecastHeight		


/*******************************************************************************
 * Function:	setFloodBrowseHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function checks to see if there is a value set for what flood
 * height to browse.  If so, it browses at that flood height, otherwise, it uses
 * the current flood-warning height.
 ******************************************************************************/
function setFloodBrowseHeight( )
{
	var nFHeight=QueryString(STR_FLOODBROWSE_VALUE);
	if(!nFHeight || nFHeight==null || !isValidFloodHeight(nFHeight))
	{
		nFloodHeightBrowse=nFloodHeightForecast;
		if(nFloodHeightBrowse<N_FLOODHEIGHT_MIN)
			nFloodHeightBrowse=N_FLOODHEIGHT_MIN;
		if(nFloodHeightBrowse>N_FLOODHEIGHT_MAX)
			nFloodHeightBrowse=N_FLOODHEIGHT_MAX;
	} // if(!isValidFloodHeight(nFHeight))
	else
		nFloodHeightBrowse = nFHeight;
} // setFloodBrowseHeight


/*******************************************************************************
 * Function:	setFloodCurrentHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function retreives the flood forecast height
 ******************************************************************************/
function setFloodCurrentHeight( )
{
	var nFHeight=0;
	nFHeight=getCurrentFloodHeight( );
	if(!isValidFloodHeight(nFHeight))
	{
		nFloodHeightCurrent = 0;	
	} // if(!isValidFloodHeight(nFHeight))
	else
		nFloodHeightCurrent = nFHeight;
} // setFloodCurrentHeight		


/*******************************************************************************
 * Function:	floodWarning
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function prints out the flood warning text
 ******************************************************************************/
function floodWarning( )
{
	if (!nFloodHeightForecast ||  nFloodHeightForecast==null || nFloodHeightForecast < N_FLOODHEIGHT_MIN )
	{
		// Steve Brady has decided we should not post the message that there is no flood forecast
		//  simply because data is not available, because of the possibility data may (if there is some error for example)
		//  be unavailable when there is a flood anyway.
		// Thus, the commented out code below is the original code but should not be used at this time.


		//document.writeln("<FONT CLASS=floodWarningNone>");
		//document.writeln(STR_WARNING_NONE);
		//document.writeln("</FONT>");

		

		
	} // if (nFloodHeightForecast < N_FLOODHEIGHT_MIN)
	else
	{
		document.writeln("<FONT CLASS=floodWarning>");
		document.write(	 STR_WARNING_PRE + nFloodHeightForecast + STR_WARNING_POST + STR_WARNING_POST1
				+ strFloodHeightForecastAt + STR_WARNING_POST2);
		document.writeln("</FONT>");

		//COMMENTED OUT#########################################################################
		/*document.write  ("<FORM" +
							" ACTION=\"" + STR_MAPBROWSE_PAGE + "\"" +
							" METHOD=GET" +
							">");
		document.write  ("<BUTTON TYPE=SUBMIT" + 
							" VALUE=\"" + STR_WARNING_PRE + nFloodHeightForecast + STR_WARNING_POST + "\"" +
							" WIDTH=10" +
							">");
		document.write  ("<A CLASS=floodWarning>" +
							STR_WARNING_PRE + nFloodHeightForecast + STR_WARNING_POST +
							"</A>");
		document.write  ("</BUTTON>");
		document.writeln("</FORM>");*/
		//##########################################################################


		document.writeln("<BR>");
		document.writeln("<A HREF=\"" + STR_MAPBROWSE_PAGE + "\"" +
							" CLASS=floodWarningSmall" +
							">" +
							"click for " + Math.round(nFloodHeightForecast) + "ft. inundation map" + 
							"</A>");
		document.writeln("<BR>");
		document.writeln("<FONT CLASS=floodWarningSmall>");
		document.writeln(STR_WARNING_SUB);
		document.writeln("</FONT><BR>");
		document.writeln("<A HREF=\"" + "http://iwin.nws.noaa.gov/iwin/ks/warnings.html" + "\"" +
							" CLASS=floodWarningLink" +
							">" +
							"NWS Flood Statement" + 
							"</A>");
	} // else/if
	
	document.writeln("<P>");
	document.writeln("<FONT CLASS=floodWarningSmall>");
	document.writeln("<B>NOTE: October 1998 Flood Height Was 22 Ft.</B>");
	document.writeln("</FONT>");
} // floodWarning


/*******************************************************************************
 * Function:	bestBrowserInfo
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function prints out the best browser information
 ******************************************************************************/
function bestBrowserInfo( )
{	document.writeln("<FONT CLASS=bestBrowserInfo>");
	document.writeln("Best viewed with:<BR>&nbsp;&nbsp;&nbsp;&nbsp;<I>IE 5</I> or greater and<BR>&nbsp;&nbsp;&nbsp;&nbsp;<I>Netscape 7</I>.");
	document.writeln("</FONT>");
} // bestBrowserInfo


/*******************************************************************************
 * Function:	openwindow
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function opens a window
 * 
 * @param strLoc		The location to open up in the window
 * @param strTitle		The title of the window
 * @param nHeight		The window height
 * @param nWidth		The window width
 ******************************************************************************/
function openwindow(strLoc,strTitle,nWidth,nHeight)
{
	/*if(screen.width)
	{
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
	}
	else
	{
		winl = 0;wint =0;
	}
	
	if(winl < 0)
		winl = 0;
	if(wint < 0)
		wint = 0;
	*/	
	var settings = "height=" + nHeight;
	settings += "," + "width=" + nWidth;
	//settings += 'top=' + wint + ',';
	//settings += 'left=' + winl + ',';
	settings += ",toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no";
	win = window.open(strLoc,strTitle,settings);
	win.window.focus();
} // openwindow


/*******************************************************************************
 * Function:	openCommentWindow
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function opens a window
 ******************************************************************************/
function openCommentWindow( )
{
	openwindow("futureplans.html", "FuturePlans", 600, 500);
} // openCommentWindow


/*******************************************************************************
 * Function:	putMapComments
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function prints out the comments underneath the map
 ******************************************************************************/
function putMapComments( )
{
	document.writeln("<TABLE CELLPADDING=0 CELLSPACING=20 BORDER=0>");
	document.writeln("	<TR>");
	document.writeln("		<TD ALIGN=CENTER>");
	
	document.write  ("		<FONT CLASS=mapComment>");
	//document.write  ("&nbsp;<P>");
	document.write  ("Currently (2003), estimated flood-inundation maps are " +
						"available for the Cowskin Creek basin from 21st Street North to Central Avenue. " +
						"<BR>" +
						"For more information on proposed future plans to extend the coverage area click ");
	document.write  ("<A HREF=\"JavaScript:openCommentWindow( );\" CLASS=mapComment>");
	document.write  ("here");
	document.write  ("</A>");
	document.write  (".");
	document.writeln("</FONT>");

	document.writeln("		</TD>");
	document.writeln("	</TR>");
	document.writeln("</TABLE>");
} // putMapComments
		

/*******************************************************************************
 * Function:	chooseMap
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * @param nFloodHeight The flood height to use for the maps
 * This function chooses which map to have as the browsing map
 ******************************************************************************/
function chooseMap(nFloodHeight)
{
	//alert(nFloodHeight);
	//alert(isValidFloodHeight(nFloodHeight));
	if(isValidFloodHeight(nFloodHeight))
	{
		
		location.href = STR_MAPBROWSE_PAGE_ABS + "?" + STR_FLOODBROWSE_VALUE + "=" + nFloodHeight;
	}
} // chooseMap
		

/*******************************************************************************
 * Function:	isValidFloodHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This funciton checks to see if a specified flood height is valid
 * @param	nFHeight	The flood height to check
 * @return True if it is a valid flood height
 ******************************************************************************/
function isValidFloodHeight(nFHeight)
{
	if(nFHeight >= N_FLOODHEIGHT_MIN &&
		nFHeight <= N_FLOODHEIGHT_MAX)
	{
		return true;
	}
	
	return false;
} // isValidFloodHeight
		

/*******************************************************************************
 * Function:	isValidForecastHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This funciton checks to see if a specified forecast height is valid
 * @param	nFHeight	The forecast height to check
 * @return True if it is a valid forecast height
 ******************************************************************************/
function isValidForecastHeight(nFHeight)
{
	if(nFHeight >= N_FLOODHEIGHT_MIN)
	{
		return true;
	}
	
	return false;
} // isValidForecastHeight
		

/*******************************************************************************
 * Function:	get1998FloodHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This funciton returns the height of the 1998 flood
 * @return The 1998 flood height
 ******************************************************************************/
function get1998FloodHeight( )
{
	return nFloodHeight1998;
} // get1998FloodHeight
		

/*******************************************************************************
 * Function:	getCurrentFloodHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This funciton returns the current flood height
 * @return The current flood height
 ******************************************************************************/
function getCurrentFloodHeight( )
{
	if(nCreekHeightCurrent &&
		nCreekHeightCurrent!=null &&
		nCreekHeightCurrent>0.0)
	{
		dateCreekHeightCurrentTime=new Date(strCreekHeightCurrentTime);
// sjb		nCreekHeightCurrent=Math.ceil(nCreekHeightCurrent);
		return nCreekHeightCurrent;
	}
	return 0.0;
} // getCurrentFloodHeight
		

/*******************************************************************************
 * Function:	isCurrentFlood
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function tells whether there is currently a flood
 * @return Whether there is currently a flood
 ******************************************************************************/
function isCurrentFlood( )
{
	if(isValidFloodHeight(Math.round(nCreekHeightCurrent)))
	{
		return true;
	} // if(isValidFloodHeight(nCreekHeightCurrent))
	return false;
} // isCurrentFlood


/*******************************************************************************
 * Function:	currentFloodHeight
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function prints out the flood warning text
 ******************************************************************************/
function currentFloodHeight( )
{
	if(isCurrentFlood( ))
	{
// sjb		var nHeight = nCreekHeightCurrent;
		var nHeight = Math.round(nCreekHeightCurrent);
		var nPicWidth = N_LIMAGE_WIDTH/2;
 		document.writeln("<CENTER>\n" +
						 "<table>\n" +
						 "	<tr>\n" +
						 "		<td>");
		document.writeln("		<A HREF='" + STR_MAPBROWSE_PAGE + "?" +
											STR_FLOODBROWSE_VALUE + "=" + nHeight + "'>" + 
								"<IMG SRC=\"" + STR_MAPS_DIR + nHeight +
									"/" +
									STR_MAP_PIC_MAIN_NAME +
									"." +
									STR_MAP_PIC_MAIN_EXT +
									"\"" + 
									"WIDTH=" + nPicWidth + " ALIGN=CENTER>" +
								"</A><BR>(map shows inundation height at " + nHeight + " ft.) ");
		document.writeln("		<P>");
		document.writeln("		<CENTER>");
		document.writeln("		<A HREF='" + STR_MAPBROWSE_PAGE + "?" +
											STR_FLOODBROWSE_VALUE + "=" + nHeight + 
											"'  CLASS=floodCurrent>" + 
								"Current Flood Height - " + nCreekHeightCurrent + " ft." +
								"</A>");
		if(strCreekHeightCurrentTime &&
			strCreekHeightCurrentTime!=null &&
			strCreekHeightCurrentTime.length>0)
		{
			document.writeln("<BR>");
			document.write  ("<FONT CLASS=floodCurrentDate>");
			document.write	("(" + 
							strCreekHeightCurrentTime +
							")");
			document.writeln("<BR></FONT>");
		} // if(dateCreekHeightCurrentTime!=null)
		document.writeln("		</CENTER>");
		document.writeln("		</td>\n" +
						 "	</tr>\n" +
						 "</table>\n" +
						 "</CENTER>");
		document.writeln("<BR>\n" +
						 "<HR>");
	} // if(isCurrentFlood( ))
	else
	{
		var nHeight = get1998FloodHeight( );
		var nPicWidth = N_98_PIC_W;
 		document.writeln("<CENTER>\n" +
						 "<table>\n" +
						 "	<tr>\n" +
						 "		<td align=center>");
						 
		if(strCreekHeightCurrentTime &&
			strCreekHeightCurrentTime!=null &&
			strCreekHeightCurrentTime.length>0)
		{
			document.write  ("<FONT CLASS=creekCurrent>");
			document.writeln("Current Height - " + nCreekHeightCurrent + "ft." +
							"</FONT>");
			document.writeln("<BR>");
			document.write	("<FONT CLASS=floodCurrentDate>");
			document.write	(strCreekHeightCurrentTime);
			document.writeln("</FONT><P>");
		} // if(dateCreekHeightCurrentTime!=null)
						 
		document.writeln("		<FONT CLASS=flood1998>" +
									"1998 Flood Height - 22 ft." +
									"<BR>" +
								"</FONT>");
		//document.write  ("		<A HREF='" + STR_MAPBROWSE_PAGE + "?" +
		//									STR_FLOODBROWSE_VALUE + "=" + nHeight + "'>");
		document.write	(		"<IMG SRC=\"" + STR_MAP_PIC_1998 + "\" " + 
									"WIDTH=" + nPicWidth + " ALIGN=CENTER>");
		//document.writeln(		"</A>");
		document.writeln("		</td>\n" +
						 "	</tr>\n" +
						 "</table>\n" +
						 "</CENTER>");
	} // else/if
} // currentFloodHeight


/*******************************************************************************
 * Function:	putMapHeaderRow
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function puts the map header row onto the table
 ******************************************************************************/
function putMapHeaderRow( )
{
	document.writeln("<TR>");
	document.writeln("		<TD>");
	document.writeln("		<CENTER>");
	document.writeln("		<FONT CLASS=floodHeight>Flood Height - " +
							Math.round(nFloodHeightBrowse) +
							" ft.</FONT>\n");
	document.writeln("		<BR>");
	document.writeln("		<FONT CLASS=floodHeightInfo>" +
							"Estimated Flood-inundation for given Flood Stage" +
							"</FONT>");
	document.writeln("		</CENTER>");
	document.writeln("		</TD>");
	document.writeln("</TR>");
} // putMapHeaderRow


/*******************************************************************************
 * Function:	putMapMainMapRow
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function puts the main map onto the table for the specified height
 * 
 * @param nHeight		Which flood height map to show
 ******************************************************************************/
function putMapMainMapRow(nHeight)
{
	document.writeln("	<TR>\n" +
					 "		<TD>\n" +
					 "		<CENTER>\n");
	//document.write  ("		<A HREF='" + STR_MAPBROWSE_PAGE + "#pageTitle'>");
	document.write	("		<IMG NAME=mapImage SRC=\"" + STR_MAPS_DIR + nHeight + 
								"/" + 
								STR_MAP_PIC_MAIN_NAME +
								"." +
								STR_MAP_PIC_MAIN_EXT +
								"\"" +
								" BORDER=0" + 
								" WIDTH=" + N_LIMAGE_WIDTH + 
								" HEIGHT=" + N_LIMAGE_HEIGHT + 
								" ISMAP=true USEMAP='#" + STR_LMAP_NAME + "'>\n");
	//document.writeln("		</A>");
	document.writeln("		<BR>");
	document.writeln("		</CENTER>\n" +
					 "		</TD>\n" +
					 "	</TR>");
} // putMapMainMapRow


/*******************************************************************************
 * Function:	placeMaps
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function puts the maps onto the page
 ******************************************************************************/
function placeMaps( )
{
	document.writeln("<TABLE WIDTH='100%'>");
	
	putMapHeaderRow( );
	
	putMapMainMapRow(Math.round(nFloodHeightBrowse));

	document.writeln("	<TR>\n" +
					 "		<TD>\n" +
					 "		<CENTER>\n");
	document.writeln("		<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>\n" +
					 "			<TR>\n" +
					 "				<TD VALIGN=MIDDLE ALIGN=RIGHT>\n");
	document.writeln("				<A HREF='javascript: mapPicMove(" + N_MAP_MOVE_LEFT + ")'>" +
									"<IMG NAME=mapImageClipLeft SRC='" + STR_FILE_ARROW_BLANK_H + "' BORDER=0 WIDTH=" + N_ARROW_LEN + ">" +
									"</A>\n&nbsp;");
	document.writeln("				</TD>");
	
	document.writeln("				<TD VALIGN=MIDDLE>");
	document.writeln("				<CENTER>");
	document.writeln("				<A HREF='javascript: mapPicMove(" + N_MAP_MOVE_UP + ")'>" +
									"<IMG NAME=mapImageClipUp SRC='" + STR_FILE_ARROW_BLANK_V + "' BORDER=0 WIDTH=" + N_ARROW_WID + ">" +
									"</A><BR>&nbsp;<BR>\n");
	//document.writeln("				<A HREF='" + STR_MAPBROWSE_PAGE + "#pageTitle'>" +
	//								"<IMG NAME=mapImageClip1 SRC='" + STR_BLANK_PIC + "' BORDER=0 WIDTH=0 ISMAP=true USEMAP='#" + STR_CMAP_NAME + "'>" +
	//								"</A>");
	document.writeln("				<IMG NAME=mapImageClip1 SRC='" + STR_BLANK_PIC + "' BORDER=0 WIDTH=0" + ">");
	//document.writeln("				<A HREF='javascript:mapPicZoom(-1,-1);'>" +
	//								"<IMG NAME=mapImageClip2 SRC='" + STR_BLANK_PIC + "' BORDER=0 WIDTH=0>" +
	//								"</A><BR>");
	document.writeln("				&nbsp;<BR>" +
									"<A HREF='javascript: mapPicMove(" + N_MAP_MOVE_DOWN + ")'>" +
									"<IMG NAME=mapImageClipDown SRC='" + STR_FILE_ARROW_BLANK_V + "' BORDER=0 WIDTH=" + N_ARROW_WID + ">" +
									"</A>");
	document.writeln("				</CENTER>\n" + 
									"</TD>\n" +
									"<TD VALIGN=MIDDLE ALIGN=RIGHT>&nbsp;\n");
	document.writeln("				<A HREF='javascript: mapPicMove(" + N_MAP_MOVE_RIGHT + ")'>" +
									"<IMG NAME=mapImageClipRight SRC='" + STR_FILE_ARROW_BLANK_H + "' BORDER=0 WIDTH=" + N_ARROW_LEN + ">" +
									"</A>\n");
	document.writeln("				</TD>\n" +
					 "			</TR>\n" +
					 "		</TABLE>");
	document.writeln("		<BR>");
	document.writeln("		</CENTER>\n" +
					 "		</TD>\n" +
					 "	</TR>");
	document.writeln("	<TR>");
	document.writeln("		<TD>");
	document.writeln("		<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=100%>");
	document.writeln("			<TR>")
	document.writeln("				<TD WIDTH=100></TD>");
	
	document.writeln("				<TD ALIGN=CENTER>");
	document.writeln("				<CENTER>");
	
	putLegend(nFloodHeightBrowse);
	
	document.writeln("				</CENTER>");
	document.writeln("				</TD>");
	
	document.writeln("				<TD ALIGN=RIGHT WIDTH=100>");
	document.writeln("				<A HREF='javascript:mapPicZoom(0,0);'>\n" +
					 "				<IMG NAME=mapReturn SRC='" + STR_BLANK_PIC + "' BORDER=0 WIDTH=1>\n" +
					 "				</A>\n" +
					 "				</TD>");
	document.writeln("			</TR>");
	document.writeln("		</TABLE>");
	document.writeln("		</TD>");
	document.writeln("	</TR>");
	document.writeln("</TABLE>");
}


/*******************************************************************************
 * Function:	mapPicMove
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function "moves" the view onto the appropiate part of the map based
 * on the value of the number passed into the function
 * 
 * @param moveCmd		A constant value telling what direction to move the view
 ******************************************************************************/
function mapPicMove(moveCmd)
{
	if(currClipRow>0 && currClipCol>0)
	{
		switch(moveCmd)
		{
			case N_MAP_MOVE_UP:
				if(currRow>1 || currClipRow>1)
				{
					if(currClipRow>1)
						clipPicZoom(currClipRow-1,currClipCol);
					else
					{
						currRow--;
						currSec=calcSection(currRow);
						clipPicZoom(N_NUM_CLIP_SECS_H,currClipCol);
					}
				}
				break;
			case N_MAP_MOVE_DOWN:
				if(currRow<N_NUM_SECS_H || currClipRow<N_NUM_CLIP_SECS_H)
				{
					if(currClipRow<N_NUM_CLIP_SECS_H)
						clipPicZoom(currClipRow+1,currClipCol);
					else
					{
						currRow++;
						currSec=calcSection(currRow);
						clipPicZoom(1,currClipCol);
					}
				}
				break;
			case N_MAP_MOVE_LEFT:
				if(currCol>1 || currClipCol>1)
				{
					if(currClipCol>1)
						clipPicZoom(currClipRow,currClipCol - 1);
					else
					{
						currCol--;
						clipPicZoom(currClipRow,N_NUM_CLIP_SECS_W);
					}
				}
				break;
			case N_MAP_MOVE_RIGHT:
				if(currCol<nSecWidths[currSec] || currClipCol<N_NUM_CLIP_SECS_W)
				{
					if(currClipCol<N_NUM_CLIP_SECS_W)
						clipPicZoom(currClipRow,currClipCol + 1);
					else
					{
						currCol++;
						clipPicZoom(currClipRow,1);
					}
				}
				break;
		} // switch(moveCmd)
	} // if(currClipRow>0 && currClipCol>0)
	else
	{
		switch(moveCmd)
		{
			case N_MAP_MOVE_UP:
				if(currRow>1 &&
					(currCol>nSecStarts[calcSection(currRow-1)] &&
					 currCol<=(nSecStarts[calcSection(currRow-1)] +
							   nSecWidths[calcSection(currRow-1)]))
				  )
				{
					currSec=calcSection(currRow-1);
					mapPicZoom(currRow-1,currCol);
				}
				break;
			case N_MAP_MOVE_DOWN:
				if(currRow<N_NUM_SECS_H &&
					(currCol>nSecStarts[calcSection(currRow+1)] &&
					 currCol<=(nSecStarts[calcSection(currRow+1)] +
							   nSecWidths[calcSection(currRow+1)]))
				  )
				{
					currSec=calcSection(currRow+1);
					mapPicZoom(currRow+1,currCol);
				}
				break;
			case N_MAP_MOVE_LEFT:
				if(currCol>(nSecStarts[currSec]+1) &&
				   currCol<=(nSecStarts[currSec] +
							 nSecWidths[currSec])
				  )
				{
					mapPicZoom(currRow,currCol-1);
				}
				break;
			case N_MAP_MOVE_RIGHT:
				if(currCol<(nSecStarts[currSec] + nSecWidths[currSec]) &&
				   currCol>(nSecStarts[currSec])
				  )
				{
					mapPicZoom(currRow,currCol+1);
				}
				break;
		} // switch(moveCmd)
	} // else/if
} // mapPicMove


/*******************************************************************************
 * Function:	mapPicZoom
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function "zooms" into a the selected block of the main map
 * 
 * @param row		The row of the block to zoom in on
 * @param col		The column of the block to zoom in on
 ******************************************************************************/
function mapPicZoom(row, col)
{
	var sec=0;
	if(row==-1 && col==-1)
	{
		row=currRow;
		col=currCol;
	}
	if(row>0 && col>0)
	{
		document.mapImageClip1.src=STR_MAPS_DIR + Math.round(nFloodHeightBrowse) + "/" + 
									row + 
									"-" + 
									col + 
									"." +
									STR_MAP_PIC_CLIP_EXT;
		document.mapImageClip1.width=N_CLIP_WIDTH;
		document.mapImageClip1.ismap=true;
		
		sec=calcSection(row);
		calcArrows1(row, col, sec);

		//document.mapImageClip2.src=STR_BLANK_PIC;
		//document.mapImageClip2.ismap=false;
		//document.mapImageClip2.width=1;

		document.mapImage.src=STR_BLANK_PIC;
		document.mapImage.ismap=false;
		document.mapImage.width=1;
		document.mapImage.height=1;

		document.mapReturn.src=STR_RETURN_PIC;
		document.mapReturn.ismap=true;
		document.mapReturn.width=N_RETURN_WIDTH;
		
		currRow=row;
		currCol=col;
		currClipRow=0;
		currClipCol=0;
		currSec=sec;
	}
	else if(row==0 && col==0)
	{
		document.mapImageClip1.src=STR_BLANK_PIC;
		document.mapImageClip1.ismap=false;
		document.mapImageClip1.width=0;

		//document.mapImageClip2.src=STR_BLANK_PIC;
		//document.mapImageClip2.ismap=false;
		//document.mapImageClip2.width=0;
		
		hideArrows( );

		document.mapImage.src=STR_MAPS_DIR + Math.round(nFloodHeightBrowse) + 
								"/" + 
								STR_MAP_PIC_MAIN_NAME +
								"." +
								STR_MAP_PIC_MAIN_EXT;
		document.mapImage.ismap=true;
		document.mapImage.width=N_LIMAGE_WIDTH;
		document.mapImage.height=N_LIMAGE_HEIGHT;

		document.mapReturn.src=STR_BLANK_PIC;
		document.mapReturn.ismap=false;
		document.mapReturn.width=0;
		
		currRow=row;
		currCol=col;
		currClipRow=0;
		currClipCol=0;
		currSec=-1;
	}
} // mapPicZoom


/*******************************************************************************
 * Function:	clipPicZoom
 * Script:		mainScript.js
 * @author Kris Kline
 * 
 * This function "zooms" into a the selected block of the clip map
 * 
 * @param row		The row of the block to zoom in on
 * @param col		The column of the block to zoom in on
 ******************************************************************************/
function clipPicZoom(row, col)
{
	if(row>0 && col>0)
	{
		document.mapImageClip2.src=STR_MAPS_DIR + Math.round(nFloodHeightBrowse) + "/" + currRow + "-" + currCol + "/" +
								   row + 
								   "-" + 
								   col + 
								   "." +
								   STR_MAP_PIC_CLIP_EXT;
		document.mapImageClip2.width=N_CLIP_WIDTH;
		document.mapImageClip2.ismap=true;
		calcArrows2(currRow, currCol, row, col, currSec);
				
		document.mapImageClip1.src=STR_BLANK_PIC;
		document.mapImageClip1.ismap=false;
		document.mapImageClip1.width=0;

		document.mapImage.src=STR_BLANK_PIC;
		document.mapImage.ismap=false;
		document.mapImage.width=1;
		document.mapImage.height=1;

		document.mapReturn.src=STR_RETURN_PIC;
		document.mapReturn.ismap=true;
		document.mapReturn.width=N_RETURN_WIDTH;
		
		currClipRow=row;
		currClipCol=col;
	}
	currSec=calcSection(currRow);
} // clipPicZoom
