/* --- global --- */
//Combined scripts used throughout the site...

/* ----------------------------------------------------------------------
FormFocus
This function places the focus on a form field when a page loads if it finds a field designated "inputFocusTarget".

Call using this code:
<body onload="FormFocus()"...
<input type="text" name="WHATEVER" id="inputFocusTarget"/>
*/
function FormFocus() {
	if(document) {
		if(document.getElementById) {
			if(document.getElementById("inputFocusTarget")) {
				document.getElementById("inputFocusTarget").focus();
			}
		}
	}
}
/* ----------------------------------------------------------------------
ActivateSearchForm
This function shows or hides the search form in the global navigation.

Call using this code:
<li><a class="site" href="/cgi-bin/swish245.cgi" onclick="return toggleSearchForm()" title="link to site search">Site Search</a></li>   
<li id="searchForm" style="visibility:hidden;width:13%;">
<form id="searchSite" style="display:inline;width:13%;" action="/cgi-bin/swish245.cgi" method="get">
<input type="hidden" name="sort" value="swishrank" checked="checked" />
<input style="display:inline;width:13%;" class="text" type="text" id="searchField" name="query" maxlength="150" size="35" />
</form>
</li>
*/
function toggleSearchForm() {
	//if the form exists...
	if (document && document.getElementById && document.getElementById("searchForm")) {
		
		//if the form field is visible
		if (document.getElementById("searchForm").style.visibility == "visible") {
					
			//if there is text in the form field, submit the form.
			if (document.getElementById("searchField") && 
				document.getElementById("searchField").value != "") {
				
				document.getElementById("searchSite").submit();
				return false;
			}
					
			//otherwise, hide the form.
			document.getElementById("searchForm").style.visibility = "hidden";
			return false;
			
		} 
		//if the form field is hidden
		else {
			//make the form visible.
			document.getElementById("searchForm").style.visibility = "visible";
			//put the focus on the form field.
			if (document.getElementById("searchField")) {
				document.getElementById("searchField").focus();
			}
			return false;				
		}
	}
	//if the script couldn't find the form, return true and direct user to search page.
	return true;
}
