var nokeyword = 'Please enter one or more search terms.';

searchtargets = ['articles', 'reference', 'mirlyn', 'both', 'articles_biology', 'both_biology', 'articles_chemistry', 'both_chemistry', 'articles_engineering', 'both_engineering', 'articles_earth_and_resource_science', 'both_earth_and_resource_science', 'articles_mathematics', 'both_mathematics', 'articles_physics', 'both_physics', 'articles_science', 'both_science'];

// Help text for the general search
var searchHelp = new Array();

searchHelp['articles']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33154>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_physics']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33147>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_biology']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33114>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_chemistry']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33119>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_computer_science']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33123>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_earth_and_resource_science']= 'Search for journal & magazine <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33127>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_engineering']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33131>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_mathematics']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33143>Go to advanced search<\/a><\/B><\/P>';

searchHelp['articles_science']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>osmosis<br>plasma physics<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchType=advanced&currentCat=33154>Go to advanced search<\/a><\/B><\/P>';

searchHelp['reference']= 'Search for background information or quick answers to a topic <P><B>Examples:<\/B><\/P><OL>filtration<br>"distributed processing"<\/br><\/OL><P><P><B>Other resources to try:</B><UL><LI><span class="advancedlink"><B><a href="http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced ">Advanced Easy Search</a></B></span></LI><LI><B><a href=http://libproxy.umflint.edu:2048/login?url=http://www.oxfordreference.com/views/GLOBAL.html?authstatuscode=202>Oxford Reference Online</a></B></LI><LI><B><a href=http://libproxy.umflint.edu:2048/login?url=http://www.credoreference.com/search.jsp>Credo Reference</a></B></LI><LI><B><a href=http://libproxy.umflint.edu:2048/login?url=http://infotrac.galegroup.com/itweb/umuser?db=GVRL>Gale Virtual Reference Library</a></B></LI><LI><B><a href=http://libproxy.umflint.edu:2048/login?url=http://scholar.google.com/>Google Scholar</a></B></UL><\/B><\/P><\/P>';

searchHelp['both_chemistry']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_physics']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_biology']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_computer_science']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_earth_and_resource_science']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_engineering']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_mathematics']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';

searchHelp['both_science']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>metallurgy<br>radiocarbon dating<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://TH5YK4DG6V.cs.serialssolutions.com/?SS_LibHash=TH5YK4DG6V&searchBy=category&searchType=advanced>Go to advanced search<\/a><\/B><\/P>';


// Utility function to get the value of radio buttons in generalsearch
function getSource() {
  var val;

  for (var index in searchtargets) {
      target = searchtargets[index];
      i = document.getElementById('gs_' + target);
      if (i && i.checked) {
	   return i.value;
      }
  }
}


// Change the hint text to the value in the appropriate array

function changehint(val, helparray, target) {
  document.getElementById(target).innerHTML = helparray[val];
  }


function submitQuickSearch(form) {
  var source = form.source.options[form.source.selectedIndex].value;
  var keywords = form.findarticlekeywords.value;

  // Do a value check so the form would not submit null or meaningless values
  if (keywords == '' || keywords == 'Enter keywords') {
    window.alert(nokeyword);
    return false;
  }

  document.location = quicksearchFunc+keywords+quicksearchParam+quicksets[source];
  return false;

}//end of function submitQuickSearch


// Define the general search URLs
searchurls = new Array();

searchurls['reference'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU&term0=';

searchurls['articles_physics'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=DUA%2CHTB%2CAJE%2CBTU%2CPSK%2CRSV%2CRWI&term0=';
searchurls['both_physics'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CDUA%2CHTB%2CAJE%2CBTU%2CPSK%2CRSV%2CRWI&term0=';

searchurls['articles_biology'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=APQ%2CPBJ%2CPSK%2CHTB%2CRSV%2CRWI&term0=';
searchurls['both_biology'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CAPQ%2CPBJ%2CPSK%2CHTB%2CRSV%2CRWI&term0=';

searchurls['articles_chemistry'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AJE%2CBTU%2CHTB%2CPSK%2CRSV%2CRWI&term0=';
searchurls['both_chemistry'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CAJE%2CBTU%2CHTB%2CPSK%2CRSV%2CRWI&term0=';

searchurls['articles_computer_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AJE%2CHTB%2CRSV%2CRWI%2CPQC%2CICD%2CDRU&term0=';
searchurls['both_computer_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CAJE%2CHTB%2CRSV%2CRWI%2CPQC%2CICD%2CDRU&term0=';

searchurls['articles_earth_and_resource_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=BUL%2CHTB%2CPSK%2CRSV%2CRWI&term0='; 
searchurls['both_earth_and_resource_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CBUL%2CHTB%2CPSK%2CRSV%2CRWI&term0=';

searchurls['articles_engineering'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AJE%2CHTB%2CRSV%2CRWI%2CSMA&term0=';
searchurls['both_engineering'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CAJE%2CHTB%2CRSV%2CRWI%2CSMA&term0=';

searchurls['articles_mathematics'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=HTB%2CRSV%2CRWI&term0=';
searchurls['both_mathematics'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CHTB%2CRSV%2CRWI&term0=';

searchurls['articles_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AJE%2CBTU%2CHTB%2CPSK%2CRSV%2CRWI&term0=';
searchurls['both_science'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=EKQ%2CGAS%2CEFU%2CAJE%2CBTU%2CHTB%2CPSK%2CRSV%2CRWI&term0=';

function submitGeneralSearch(form) {
  var source = getSource();
  var keywords = form.generalsearchkeywords.value;

  // Do a value check so the form would not submit null or meaningless values
  if (keywords == '' || keywords =='Enter keywords') {
    window.alert(nokeyword);
    return false;
  }

  keywords = encodeURIComponent(keywords);
  var url = searchurls[source] + keywords;


 window.location=url;
  return false;
}//end of function submitGeneralSearch

function removekeyword(elementID){
    document.getElementById(elementID).value = '';
	document.getElementById(elementID).style.color = 'black';
	return false;
}

function updateGeneralSearchRadio() {
    $('#gs_'+ $('#gs_select').attr('value')).click();
} //end of function updateGeneralSearchRadio

