/*	Function:	pad()
	Purpose:		Adds character padding to the beginning of a string.
	Input Variables:
					varValue			==> string to add padding to
					cPad				==> character(s) used in padding the the result
					sizeOfRtnValue	==> length of the returned string
	Return Value:
					String	==> The string with the padded characters at the beginning
	Note1:		While this function will except multiple characters to pad the final
					string, it will not truncate the 'cPad' value to make the string the
					same as 'sizeOfRtnVal'.
	Note2:		This function converts each parameter to its correct data type for its
					use. Therefore, if sizeOfRtnVal = "23", then the function will convert
					it to 23. If cPad = 3, the the function converts it to "3" and if
					varValue = 50000 then the function converts it to "50000".
	Note3:		The returned string's length is the actual number of characters indicated
					by 'sizeOfRtnVal'. (Not the size from 0 -> n, where n='sizeOfRtnVal'-1)
	Note4:		If the 'varValue's length is >= 'sizeOfRtnVal', the return value = varValue.
	Note5:		If 'varValue' = "" (empty string) then the return string is filled with the
					character(s) in 'cPad'.
*/
function pad(varValue, cPad, sizeOfRtnVal)
{
	var sValue = varValue.toString();
	var sPad = cPad.toString();
	var sRtnValue = "";
	var lSize = parseInt(sizeOfRtnVal);
	var lSizeOfPad = lSize - sValue.length;
	var lPos = 0;

	for(lPos = 0; lPos <= lSizeOfPad - 1; lPos++)
	{
		sRtnValue = sRtnValue + sPad;
	}
	
	return sRtnValue + sValue;
} //pad() 


/*	Function:	showHideInnerSection()
	Purpose:		Toggles visibility of a section within the element specified.
	Input Variables:
					section			==> section containing the section to hide.
					switchImage		==> indicates that User wishes to switch the image.
	Return Value:
					None
	Note1:		The element can be any element as long as it contains an 
					attribute called "toggleHide".
	Note2:		It will not find multiple sections and toggle them. It will 
					find the last one in the section and toggle it's "display" 
					section.
*/
function showHideInnerSection(section)
{
	var sectionToHide = null;
	
	//Start searching for the element needed to make disappear.
	for( var elementIndex = section.childNodes.length - 1; (elementIndex >= 0) && (sectionToHide == null); elementIndex-- )
	{
		var examineElement = section.childNodes[elementIndex];
		
		if( (examineElement != null) && (examineElement.attributes != null) )
		{
			//Examine each element for the indicator that we need to manipulate it.
			if( examineElement.getAttribute('toggleHide') != null )
			{
				sectionToHide = section.childNodes[elementIndex];
			}
		}
	}
	
	if( (sectionToHide != null) && ( (sectionToHide.style.display == 'none') || (sectionToHide.style.display == '') ) )
	{
		sectionToHide.style.display='block';
	}
	else
	{
		sectionToHide.style.display='';
	}
}

/*	Function:	switchImages()
	Purpose:	Switches one image for the other or back again.
	Input Variables:
					control		==> image control
					firstImage	==> image object containing the first image
					secondImage	==> image object containing the second image
	Return Value:
					None
	Note1:		
*/
function switchImages(control, firstImage, secondImage)
{
	if( control.src == firstImage.src )
	{
		control.src = secondImage.src;
	}
	else
	{
		control.src = firstImage.src;
	}
}

/*	Function: gotoLink
	Purpose: pieces a URL together to go to that address.
	Input Variables:
				first	==> first piece.
				second	==> second piece.
				third	==> third piece.
				fourth	==> fourth piece.
				signal	==> signifies what this URL is.
	Return Value:
				None
*/
function gotoLink(first, second, third, fourth, signal)
{
	window.location = first + signal + second + third + fourth
}

/*	Function: trim
	Purpose: deletes whitespace from both ends of a string.
	Input Variables:
				org	==> orginial string to trim off of.
	Return Value:
				String	==> value with whitespace trimmed off.
	
	Note:	Got this code from The JavaScript Source: http://javascript.internet.com/snippets/regular-expressions-taster.html
*/
function trim(org)
{	var returnVal = org.replace(new RegExp(/^\s+/),"");  //Delete the Whitespace in the front.
	return returnVal.replace(new RegExp(/\s+$/),"");	//Delete the Whitespace in the back.
}
