function doSearch() {
	var searchForm = document.ipac;
	var searchTerm = searchForm.term.value;
	
	// determine which radio button was selected...
	var searchThis = "";
	for (i = 0; i < searchForm.where.length; i++) {
		if (searchForm.where[i].checked) {
			searchThis = searchForm.where[i].value;
			break;
		}
	}
	
	// remove hidden inputs: start with a clean slate...
	removeHiddenInputs(searchForm);
	
	// now redirect to the proper search page...
	if (searchThis == "Catalog") {
		// add necessary inputs...
		addInputToForm(searchForm, "hidden", "menu", "search");
		addInputToForm(searchForm, "hidden", "aspect", "power");
		addInputToForm(searchForm, "hidden", "index", ".GW");
		
		// set the action and submit form
		//searchForm.action = "https://catalog.spl.org/ipac20/ipac.jsp";
		searchForm.action = "http://catalog.spl.org/";
		searchForm.submit();
	} else if (searchThis == "Site") {
		// add necessary inputs...
		//addInputToForm(searchForm, "hidden", "cx", "011686149360725945627:oktcrpzc1ni");
		addInputToForm(searchForm, "hidden", "cx", "012160248532957636676:4e5cfg6n_a8");
		addInputToForm(searchForm, "hidden", "cof", "FORID:11");
		//addInputToForm(searchForm, "hidden", "cof", "FORID:10");
		addInputToForm(searchForm, "hidden", "q", searchTerm);
		
		// set action and submit form...
		searchForm.action = "http://www.spl.org/search-results";
		searchForm.submit();
	}
}
	
function addInputToForm(theForm, inputType, inputName, inputValue) {
	var nodeInput = document.createElement("input");
	nodeInput.type = inputType;
	nodeInput.name = inputName;
	nodeInput.id = inputName;
	nodeInput.value = inputValue;
	theForm.appendChild(nodeInput);
}
	
function removeHiddenInputs(theForm) {
	var allInputs = theForm.elements;
	for (i = 0; i < allInputs.length; i++) {
		var curInput = allInputs.item(i);
		if (curInput.type == "hidden")
			theForm.removeChild(curInput);
	}
}
	
function keyDownHandler(evt) {
	// run search only for Enter key
	evt = (evt)? evt: ((window.event)? window.event: "")
	if (evt)
		if (evt.keyCode == 13)
			doSearch();
}

function Show(id) {
	var divArticleSearch = document.getElementById('divArticleSearch');
	var divRegularSearch = document.getElementById('divRegularSearch');

	if (id == 'divRegularSearch') {
		divRegularSearch.style.display = 'block';
		divArticleSearch.style.display = 'none';
	} else {
		divRegularSearch.style.display = 'none';
		divArticleSearch.style.display = 'block';
	}
}
