function convertspaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
temp = splitstring[0];
for(i = 1; i < splitstring.length; i++)
 {
  temp = temp + "+" + splitstring[i]; 
 }
return temp;
}
function search_site(inurl, insearch)
{
// Build the destination url by placing the selection option first
var url = inurl;  
//EBSCOHost databases vary on whether they can handle either or both of these limiters as parameters
// the default URL "site" is if the user checks neither limit box
// C1 is checkbox for peer-reviewed, C2 is checkbox for full text
// site2 is the URL if the user checks peer-reviewed but not full text
if ((document.articleform.C1.checked == true) && (document.articleform.C2.checked == false)){ url = document.articleform.site2.value; };
// site3 is for full text not peer-reviewed
if ((document.articleform.C1.checked == false) && (document.articleform.C2.checked == true)) { url = document.articleform.site3.value; };
// site4 is if both are checked
if ((document.articleform.C1.checked == true) && (document.articleform.C2.checked == true)) { url = document.articleform.site4.value; };
if (insearch == "") { insearch = "keyword" };
// Append the text box input to the search url for the selected site
url = url +  convertspaces(insearch);
if (document.articleform.C2.checked == true) { url = url + "+AND+FT Y"; };
if (document.articleform.C1.checked == true) { url = url + "+AND+%28RV+Y+OR+RV+T%29"; };
if (document.articleform.C3.checked == true) { url = url + "+AND+DT+>+20021231"; };
// Change the the browser location to the new url
myWindow = window.open(url, "EBSCO");
myWindow.focus();
  
// window.location.href = url;
}

function submitenter1(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
search_site(document.articleform.site.value,document.articleform.u_search.value);
return false;
}
else
return true;
}

//Build the course reserves search URL and run the search
function search_res(inurl, insearch)
{
// Build the destination url by placing the selection option first
var url = document.reservesform.ressite.value;  
if (document.reservesform.resSearchType[0].checked){ url = url + "p?SEARCH="; };
if (document.reservesform.resSearchType[1].checked){ url = url + "r?SEARCH="; };
// Append the text box input to the search url for the selected site
url = url +  convertspaces(document.reservesform.respattern.value) + '&SUBMIT=Search';
// Change the the browser location to the new url
myWindow = window.open(url, "ResCatalog");
myWindow.focus();
// window.location.href = url;
}

function submitenter_res(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
search_res(document.reservesform.ressite.value,document.reservesform.respattern.value);
return false;
}
else
return true;
}
//Build the catalog search URL and run the search
function search_cat(insearch)
{
// Build the destination url by placing the selection option first
var url = 'http://bridges.missouri.edu.proxy.library.maryville.edu/search~S7/X' + convertspaces(document.catform.SEARCH.value);  
// Append the text box input to the search url for the selected site
url = url +  '&SORT=D&searchscope=7';
// Change the the browser location to the new url
myWindow = window.open(url, "Catalog");
myWindow.focus();
// window.location.href = url;
}

function submitenter_cat(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
search_cat(document.catform.SEARCH.value);
return false;
}
else
return true;
}

//Build the periodical search URL and run the search
function search_jou(insearch)
{
// Build the destination url by placing the selection option first
var url = 'http://www.mulibrary.org/openurl/openresolver.pl?titlekw=' + convertspaces(document.journalform.titlekw.value);  
var unused = insearch;
url = url + '&sid=MUPerSearch&pid=MULookup&genre=journal';
// Change the the browser location to the new url
myWindow = window.open(url, "PerSearch");
myWindow.focus();
// window.location.href = url;
}

function submitenter_jou(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (keycode == 13)
{
search_jou(document.journalform.titlekw.value);
return false;
}
else
return true;
}
