/**************************************************************
 Right: Returns a String containing a specified number of 
        characters from the right side of a string.

 Parameters:
      String = String expression from which the leftmost 
               characters are returned. If string contains null, 
               false is returned.
      Length = Numeric expression indicating how many characters 
               to return. If 0, a zero-length string ("") is 
               returned. If greater than or equal to the number 
               of characters in string, the entire string is 
               returned. 

 Returns: String
***************************************************************/
function Right(String, Length)
{
	if (String == null)
		return (false);

    var dest = '';
    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	String = dest;
	String = String.substr(0, Length);
	dest = '';

    for (var i = (String.length - 1); i >= 0; i--)
		dest = dest + String.charAt(i);

	return dest;
}

/**************************************************************
 InStr: Returns a Long specifying the position of the first 
        occurrence of one string within another. Is String1
        or String2 are null, false is returned.

 Parameters:
      String1 = String expression being searched.
      String2 = String expression sought

 Returns: Integer
***************************************************************/
function InStr (String1, String2)
{

	var a = 0;
	if (String1 == null || String2 == null)
	{
		return (false);
	}

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	a = String1.indexOf(String2);
	
	if (a == -1)
	{
		return 0;
	}
	else
	{
		return a + 1;
	}
}

function SearchBox ()
{
	if (document.getElementById ('searchfield').value == '') 
	{
		document.getElementById ('searchfield').value = 'search this website';
	}
}

function highlightCurrent ()
{
	var theTable = document.getElementById ('tblNavLinks');
	var theImgs = theTable.getElementsByTagName ('img');
	
	for (i = 0; i <= theImgs.length-1; i++) 
	{
		var myString = theImgs [i].src.toUpperCase ();
		if (myString.indexOf(document.getElementById ('hdnSection').value.toUpperCase ()) > 0)
		{
			theImgs [i].src = '../../assets/btn' + document.getElementById ('hdnSection').value  + '_f2.jpg';
		}
	}
}