//===============================================================================
// Name:     mapArrows.js
// Purpose:  The script that handles all the arrow processing
// Version:  1.0
//------------------------------------------------------------------------------
var N_MAP_MOVE_UP=-10;
var N_MAP_MOVE_DOWN=-11;
var N_MAP_MOVE_LEFT=-20;
var N_MAP_MOVE_RIGHT=-21;

var N_ARROW_LEN=33;
var N_ARROW_WID=25;

var STR_FILE_ARROW_UP="pics/arrow1Up.gif";
var STR_FILE_ARROW_DOWN="pics/arrow1Down.gif";
var STR_FILE_ARROW_RIGHT="pics/arrow1Right.gif";
var STR_FILE_ARROW_LEFT="pics/arrow1Left.gif";
var STR_FILE_ARROW_BLANK_V="pics/arrowBlankV.gif";
var STR_FILE_ARROW_BLANK_H="pics/arrowBlankH.gif";


function showUpArrow( )
{
	document.mapImageClipUp.src=STR_FILE_ARROW_UP;
	document.mapImageClipUp.width=N_ARROW_WID;
}

function hideUpArrow( )
{
	document.mapImageClipUp.src=STR_FILE_ARROW_BLANK_V;
	document.mapImageClipUp.width=N_ARROW_WID;
}

function showDownArrow( )
{
	document.mapImageClipDown.src=STR_FILE_ARROW_DOWN;
	document.mapImageClipDown.width=N_ARROW_WID;
}

function hideDownArrow( )
{
	document.mapImageClipDown.src=STR_FILE_ARROW_BLANK_V;
	document.mapImageClipDown.width=N_ARROW_WID;
}

function showLeftArrow( )
{
	document.mapImageClipLeft.src=STR_FILE_ARROW_LEFT;
	document.mapImageClipLeft.width=N_ARROW_LEN;
}

function hideLeftArrow( )
{
	document.mapImageClipLeft.src=STR_FILE_ARROW_BLANK_H;
	document.mapImageClipLeft.width=N_ARROW_LEN;
}

function showRightArrow( )
{
	document.mapImageClipRight.src=STR_FILE_ARROW_RIGHT;
	document.mapImageClipRight.width=N_ARROW_LEN;
}

function hideRightArrow( )
{
	document.mapImageClipRight.src=STR_FILE_ARROW_BLANK_H;
	document.mapImageClipRight.width=N_ARROW_LEN;
}


function hideArrows( )
{
	hideUpArrow( );
	hideDownArrow( );
	hideLeftArrow( );
	hideRightArrow( );
}

function calcSection(row)
{
	var secAdder=0;
	for(var x=0;x<nNumSecs && secAdder<row;x++)
	{
		secAdder+=nSecHeights[x];
	}
	return x-1;
}

function calcArrows1(row, col, sec)
{
	var prevHeights=0;
	for(x=0;x<sec;x++)
		prevHeights+=nSecHeights[x];
	
	if(row>1 &&
		(col<=(nSecStarts[calcSection(row-1)] + nSecWidths[calcSection(row-1)]))
	  )
		showUpArrow( );
	else
		hideUpArrow( );
	if(row<N_NUM_SECS_H &&
		(col>nSecStarts[calcSection(row+1)] &&
		 col<=(nSecStarts[calcSection(row+1)] + nSecWidths[calcSection(row+1)]))
	  )
		showDownArrow( );
	else
		hideDownArrow( );
	if(col>(nSecStarts[sec]+1))
		showLeftArrow( );
	else
		hideLeftArrow( );
	if(col<(nSecStarts[sec] + nSecWidths[sec]))
		showRightArrow( );
	else
		hideRightArrow( );
}

function calcArrows2(row, col, clipRow, clipCol, sec)
{
	if(row>1 || clipRow>1)
		showUpArrow( );
	else
		hideUpArrow( );
	if(row<N_NUM_SECS_H || clipRow<N_NUM_CLIP_SECS_H)
		showDownArrow( );
	else
		hideDownArrow( );
	if(col>1 || clipCol>1)
		showLeftArrow( );
	else
		hideLeftArrow( );
	if(col<nSecWidths[sec] || clipCol<N_NUM_CLIP_SECS_W)
		showRightArrow( );
	else
		hideRightArrow( );
}
