var frm; // declared here; set in the onload event of the form


function openROSinLanguage() {
	var lang = frm.lang_select.value;
	location = gvDbDir + lang + '/ros.nsf';
}


function noenter() {
  if (window.event) {
		if (window.event.keyCode == 13) {search();};
	}
  };

function search() {
	var search_query = frm.search_query.value
	if (search_query != '') {
		location = gvDbPath + '/vwSearch?SearchView&query=' + search_query;
	}
}


function toggleFlashObject() {

	// Because we have a Flash object on the home page of each database, and because any Flash
	// object is always going to appear in front of anything else, the DHTML menus have to be programmed
	// to hide the Flash object when menus are being drawn.  This function gets called every time the
	// DHTML menu is hovered over (in any page), but only really does anything if the Flash object appears
	// in that same page.

	var flash_obj = document.getElementById('main_flash_object');
	var flash_obj_repl = document.getElementById('flash_object_replacement');

	if (flash_obj && flash_obj_repl) {

		if (flash_obj.style.display == '' || flash_obj.style.display == 'block') {
			flash_obj.style.display = 'none';
			flash_obj_repl.style.display = 'block';
		} else {
			flash_obj.style.display = 'block';
			flash_obj_repl.style.display = 'none';
		}
	}
}


function trim(str) {

	// S.Lewis, June 2006.

	// remove leading spaces
	while (str.charAt(0) == ' ') {
		str = str.substr(1);
	};

	// remove trailing spaces
	while (str.charAt(str.length-1) == ' ') {
		str = str.substr(0, str.length-1);
	};

	// remove unnecessary spaces within string
	while (str.indexOf('  ') >= 0) {
			str = str.replace('  ', ' ');
	};

	return str;

}