<!--

function jsInitSearch()
{
	<!-- check for required fields in form -->
	if  ( !document.searchForm.searchString ) 
	{
		alert ( "You must have in your form an INPUT element of TYPE=\"TEXT\" and NAME=\"searchString\" ");
		return false;
	}
	if  ( !document.searchForm.completeSearchString ) 
	{
		alert ( "You must have in your form an INPUT element of TYPE=\"hidden\" and NAME=\"completeSearchString\" ");
		return false;
	}
	if  ( !document.searchForm.CiSort ) 
	{
		alert ( "You must have in your form an INPUT element of TYPE=\"hidden\" and NAME=\"CiSort\" and VALUE=\"Rank[d]\" ");
		return false;
	}
	if  ( !document.searchForm.CiMaxRecordsPerPage ) 
	{
		alert ( "You must have in your form an INPUT element of TYPE=\"hidden\" and NAME=\"CiMaxRecordsPerPage\" and VALUE=\"20\" ");
		return false;
	}
	if  ( !document.searchForm.HTMLQueryForm ) 
	{
		alert ( "You must have in your form an INPUT element of TYPE=\"hidden\" and NAME=\"HTMLQueryForm\" and with a value set to the html page that calls this javascript ");
		return false;
	}
	
	<!------------------------------------------------------------------------------------------>
	<!------------------------------------------------------------------------------------------>
	<!-- empty search string causes request to crash -->

	if ( (document.searchForm.searchString.value == "") || (document.searchForm.searchString.value == null) )
	{
		alert ( "You must provide a search string" );
		return false;
	}

	<!------------------------------------------------------------------------------------------>
	<!------------------------------------------------------------------------------------------>
	
	<!-- determine which search request file to use -->
	<!-- default should be set in html. however, if not set in html the make SearchAllWonder the default -->
	if ( document.searchForm.action == ""  | document.searchForm.action == null )
	{
		document.searchForm.action = "/scripts/Search/SearchAllWonder.idq";
	}
	if  ( document.searchForm.scopeWonder ) 
	{
		scope = document.searchForm.scopeWonder.options[document.searchForm.scopeWonder.selectedIndex].value;
		if  (scope == "data") 
		{
			document.searchForm.action = "/scripts/Search/SearchDatasets.idq";
		}
		else if  (scope == "sci") 
		{
			document.searchForm.action = "/scripts/Search/SearchSciDoc.idq";
		}
	
		else if  (scope == "prev") 
		{
			document.searchForm.action = "/scripts/Search/SearchPrevGuid.idq";
		}
	
	}

	<!------------------------------------------------------------------------------------------>
	<!------------------------------------------------------------------------------------------>

	<!-- set up complete search string which is composed from words user entered in searchString field -->
	<!-- and the word operator, the content to search, and the file type selected -->

	<!-- add boolean or proximity operator on words in search edit field -->
	operator=" ";
	if ( document.searchForm.operator )
	{
		if ( document.searchForm.operator[0].checked )
		{
			operator = document.searchForm.operator[0].value;
		}
		else if ( document.searchForm.operator[1].checked )
		{
			operator = document.searchForm.operator[1].value;
		}
		else if ( document.searchForm.operator[2].checked )
		{
			operator = document.searchForm.operator[2].value;
		}
	}
	temp = document.searchForm.searchString.value;
	splitstring = temp.split(" ");
	tempSearchString =  splitstring[0];
	for(i = 1; i < splitstring.length; i++)
		tempSearchString += operator + splitstring[i];
	tempSearchString = tempSearchString;

	<!-- limit search to content specified -->
	completeSearchString = "";
	if ( document.searchForm.content )
	{
		if ( document.searchForm.content[0].checked || document.searchForm.content[1].checked )
		{
			// search text
			completeSearchString = completeSearchString + "(@contents " + tempSearchString + ")";
			if ( document.searchForm.content[0].checked )
				completeSearchString = completeSearchString + " | ";
		}
		if ( document.searchForm.content[0].checked || document.searchForm.content[2].checked )
		{
			// search title
			completeSearchString = completeSearchString + "(@doctitle " + tempSearchString + ")";
		}
	}
	else
		completeSearchString = tempSearchString;

	completeSearchString = "(" + completeSearchString + ")";


	<!-- limit search to certain file types -->
	if ( document.searchForm.filetype )
	{
		if ( document.searchForm.filetype[1].checked )
		{
			completeSearchString = "(" + completeSearchString + " & #filename *.pdf)";
		}
		else if ( document.searchForm.filetype[2].checked )
		{
			completeSearchString = "(" + completeSearchString + " & #filename *.html)";
		}
	}	
	document.searchForm.completeSearchString.value = completeSearchString;
	
	<!------------------------------------------------------------------------------------------>
	<!------------------------------------------------------------------------------------------>
	
	<!-- set sort by and ascending vs descending -->
	<!-- default set in html -->
	if ( document.searchForm.order && document.searchForm.sort)
	{
		sort = document.searchForm.sort.options[document.searchForm.sort.selectedIndex].value;
		if ( document.searchForm.order[0].checked )
		{
			document.searchForm.CiSort.value =  sort + "[d]";
		}
		else 
		{
			document.searchForm.CiSort.value = sort + "[a]";
		}
	}

	<!------------------------------------------------------------------------------------------>
	<!------------------------------------------------------------------------------------------>

	<!-- set the CiMaxRecordsPerPage only if select field present for user to set -->
	<!-- default set in html -->
	if ( document.searchForm.tmpCiMaxRecordsPerPage )
	{
		if ( (document.searchForm.tmpCiMaxRecordsPerPage.value != "") || (document.searchForm.tmpCiMaxRecordsPerPage.value != null) )
		{
			document.searchForm.CiMaxRecordsPerPage.value = document.searchForm.tmpCiMaxRecordsPerPage.value;
		}
	}

	return true;
}
// -->
