/**
 * Search page helper functions
 * Multi-engine radio button logic
 *
 * @package JavaScript
 * @version $Id: search.js,v 1.0 2006/10/22
 */

/**
 * Select all search fields
 */
function selectAllFields()
{
	for (var i = 0; i < document.search['fields[]'].length; i++)
	{
		document.search['fields[]'].options[i].selected = true;
	}
}

/**
 * Remove enclosing quotes when doing external searches
 */
function unQuote(s)
{
	var result = s;

	if ((result.length > 2) && (result.substr(0,1) == "\"") && (result.substr(result.length-1,1) == "\""))
	{
		result = result.substr(1,result.length-2);
	}

	return result;
}



/**
 * Submit search form depending on selected engine
 */
function changeSearch(searchtype)
{
	var mysearch;
	mysearch = document.search.q.value
    window.location = 'search.php?searchtype=' + searchtype + '&cs=1&q=' + mysearch;
	
}

/**
 * Focus field and select contents
 */
function selectField(formfield)
{
	formfield.focus();
	formfield.select();
}
