function doSearch(theForm) {
 	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");

 	window.location='http://nell.boulderlibrary.org/search/X?'+ text + '&searchscope=7';
 	return false;
}

function doSearchCarn(theForm) {
 	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");

 	window.location='http://nell.boulderlibrary.org/search/X?SEARCH='+ text + '&searchscope=8&SORT=A';
 	return false;
}

function doSearchCarnPhoto(theForm) {
 	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");

 	window.location='http://nell.boulderlibrary.org/search/X?SEARCH=Photograph* '+ text + '&searchscope=8&SORT=A&m=q';
 	return false;
}

function doSearchCarnOH(theForm) {
 	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");

 	window.location='http://nell.boulderlibrary.org/search/X?SEARCH=Oral History '+ text + '&searchscope=8&SORT=A';
 	return false;
}

function doSS(theForm) {
// pass through to 360 search
	text = theForm.q.value;
	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");
 	window.location='http://0-ay3qd7ct3e.cs.serialssolutions.com.nell.boulderlibrary.org/results?SS_LibHash=AY3QD7CT3E&dbIDList=all%2CINF%2CEAP%2CBNT%2CAHA%2CAKK%2CIBG%2CHJD%2CARV%2CIBR%2CEBR%2CAYC%2CBIE%2CBIF%2CBQL%2CEFA%2CBSU%2CEFU%2CIOF%2CIGG%2CBVY%2CIHR%2CEHC%2CCBG%2CIKB%2CAGJ%2CILR%2CCRQ%2CCSE%2CESE%2CEML%2CEMM%2CDAL%2CENS%2CDCY%2CDCZ%2CEPR%2CRPD%2CEBW%2CEAC%2CEFX%2CEHH%2CEJQ%2C&searchType=basic&action=start&catGroupList=default&searchBy=Database&field=Title&term='+text;
 	return false;
}

function doGoogle(theForm) {
	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");	 	
	window.location='http://www.boulderlibrary.org/searchresults.html?cx=007923843354824212367%3Ab_4ric8x5zs&cof=FORID%3A11&q='+text+'&sa=Search#610';
 	return false;
}

function doEvents(theForm) {
	text = theForm.q.value;
 	text = text.replace(/%/g,"%25");
 	text = text.replace(/\\+/g,"%2B");
 	text = text.replace(/\\&/g,"%26");
 	text = text.replace(/=/g,"%3D");
 	text = text.replace(/#/g,"%23");
 	text = text.replace(/ /g,"%20");
 	text.replace(/ /g,"%20");
 	window.location='http://events.boulderlibrary.org/eventcalendar.asp?EventType=ALL&Lib=ALL&kw='+text;
 	return false;
}	

function goto_URL(theForm,object) {
	//alert(object.options[object.selectedIndex].value);
	switch(object.options[object.selectedIndex].value) {
		case 'doGoogle':
			return doGoogle(theForm);
		case 'doSearch':
			return doSearch(theForm);
		case 'doSearchCarn':
			return doSearchCarn(theForm);	
		case 'doSearchCarnPhoto':
			return doSearchCarnPhoto(theForm);	
		case 'doSearchCarnOH':
			return doSearchCarnOH(theForm);				
		case 'doSS':
			return doSS(theForm);
		case 'doEvents':
			return doEvents(theForm);	
	}
	return false;
}

function handleKeyPress(e,form,object) {
	var key=e.keyCode || e.which;
	if (key==13) {
		goto_URL(form,object);
	}
}

