function change_library(){
	document.frmLogin.keyword.value = "Keyword(optional)";
	document.frmSearch.submit();
	//verify_form();
}
function clear_keyword(){
	if(document.frmLogin.keyword.value == 'Keyword(optional)' ){
		document.frmLogin.keyword.value = '';
	}
}
function verify_form() {
	if(document.frmLogin.keyword.value != 'Keyword(optional)'){
		if (document.forms.frmSearch.library_id.selectedIndex != "-1"){
			setKeywords();
			document.frmSearch.submit();
		}else{
			alert('You must select a library to search.');
		}
	}
	
	//location.href="search.asp"
}
function setKeywords(){

	var tempkw = document.forms.frmLogin.keyword.value;  //string of upto 3 keywords
	var w = 1;  //word #
	var key1 = '', key2 = '', key3 = '', endkey = '';  //endkey is only used as a holder for additional words
	
	//advance through the string 1 char at a time.  a new word is created after each space
	for (var i = 0; i < tempkw.length; i++){
		var oneChar = tempkw.charAt(i)
			if (oneChar == " " || oneChar == "," || oneChar == ";"){
				w = w + 1
			}
			else {
				switch (w){
					case 1:  //all characters upto the first space
						key1 = key1 + oneChar
						break
					case 2:  //all characters upto the second space
						key2 = key2 + oneChar
						break
					case 3:  //all characters upto the third space
						key3 = key3 + oneChar
						break
					default:  //any extra characters after the third space
						endkey = endkey + oneChar
				}
			}
	
	}
	//set form values
	document.frmSearch.key1.value = key1
	document.frmSearch.key2.value = key2
	document.frmSearch.key3.value = key3



}
function advancedSearch(library_id){
	location.href="search.asp?search=advanced";
}
function verify_form_temp() {
	//only if library_id is required to do a search
	//if (!document.layers){
		//if (document.forms.frmSearch.library_id.value != ''){
			if(document.frmSearch.keyword.value != 'Keyword(optional)'){
				setKeywords();
			}
			document.frmSearch.submit();
		//}else{
			//alert('You must select a library to search.');
		//}
	//}else{
		//if (document.forms.frmSearch.library_id.selectedIndex != "-1"){
			//if(document.frmSearch.keyword.value != 'Keyword(optional)'){
				setKeywords();
			//}
			//document.frmSearch.submit();
			
		//}else{
			//alert('You must select a library to search.');
		//}
	//}
}