var nokeyword = 'Please enter one or more search terms.';

searchtargets = ['articles', 'journal', 'mirlyn', 'reserves', 'reference', 'reference_health_care', 'both', 'articles_reference', 'both_reference', 'articles_biography', 'both_biography', 'articles_college_and_careers', 'both_college_and_careers', 'articles_health_care', 'both_health_care' ];


// Help text for the general search
var searchHelp = new Array();

searchHelp['articles']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>George Washington Carver<br>"elasticity of demand"<\/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=33155>Go to advanced search<\/a><\/B><\/P>';

searchHelp['journal']= 'Find if the Thompson Library has a magazine, journal, or e-book online<P>&nbsp;<P><b>Example:<\/b><\/P><\/P><OL>journal of sociology<br>JAMA<br>Coding Standards<\/br><\/OL><P>&nbsp;<P><B><a href=http://th5yk4dg6v.search.serialssolutions.com/>More search options<\/a><\/B><\/P>';

searchHelp['mirlyn']= 'Search for books, DVDs, videos, CDs, manuscripts, & more<P>&nbsp;<P><b>Examples:<\/b><\/P><\/P><OL>"occult fiction"<br>wom?n<\/br><br>mark twain criticism<\/br><\/OL><P>&nbsp;<P><B><a href=http://mirlyn.lib.umich.edu/F?func=find-a-0&local_base=flint_pub>Go to Advanced Search</a><\/B><\/P><\/P>';

searchHelp['reserves']= 'Search for materials your instructors have placed on reserve.  Search for author, title, course number, or instructor name<P>&nbsp;<P><B>Examples:<\/B><\/P><\/P><OL>ecn 201<br>kietzman<\/br><\/OL><P>&nbsp;<P><B><a href=http://libproxy.umflint.edu:2048/login?url=http://mirlyn.lib.umich.edu:80/F?func=find-b-0&local_base=miu30_pub>More search options<\/a><\/B><\/P>';

searchHelp['reference']= 'Search for background information or quick answers to a topic <P><B>Examples:<\/B><\/P><OL>grand guignol<br>"gothic architecture"<\/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['articles_reference']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>George Washington Carver<br>etymology<\/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=33155>Go to advanced search<\/a><\/B><\/P>';
searchHelp['both_reference']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>deconstruction and literature<br>mania<\/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['articles_biography']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>George Washington Carver<br>etymology<\/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=33113>Go to advanced search<\/a><\/B><\/P>';
searchHelp['both_biography']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>deconstruction and literature<br>mania<\/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['reference_business']= 'Search for background information or quick answers to a topic <P><B>Examples:<\/B><\/P><OL>immunization<br>"occupational therapy"<\/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['articles_business']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>productivity metrics<br>"zero based budgeting"<\/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=33117>Go to advanced search<\/a><\/B><\/P>';
searchHelp['both_business']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>General Dynamics<br>"total quality management"<\/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['articles_college_and_careers']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>George Washington Carver<br>etymology<\/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=33118>Go to advanced search<\/a><\/B><\/P>';
searchHelp['both_college_and_careers']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL>deconstruction and literature<br>mania<\/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['reference_health_care']= 'Search for background information or quick answers to a topic <P><B>Examples:<\/B><\/P><OL>immunization<br>"occupational therapy"<\/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['articles_health_care']= 'Search for journal & magazine articles <P>&nbsp;<P><b>Examples:<\/b><OL>infection and evidence based<br>clinical trials<\/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=33137>Go to advanced search<\/a><\/B><\/P>';
searchHelp['both_health_care']= 'Search for background information and journal articles <P>&nbsp;<P><b>Examples:<\/b><OL> infection and evidence based <br>aquatic exercises<\/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['journal'] = 'http://search.serialssolutions.com/?SS_searchTypeAll=yes&SS_searchTypeBook=yes&SS_searchTypeJournal=yes&SS_searchTypeOther=yes&SS_searchTypesUsed=yes&V=1.0&N=100&L=TH5YK4DG6V&S=T_W_A&C=';

searchurls['mirlyn'] = 'http://mirlyn.lib.umich.edu:80/F/?func=find-b&local_base=flint_pub&find_code=WRD&request=';

searchurls['reserves'] = 'http://mirlyn.lib.umich.edu:80/F/?func=find-b&local_base=miu30_pub&find_code=WRD&request=';

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['reference_health_care'] = '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_reference'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AKQ%2CIAO%2CLXU%2CPRA&term0=';
searchurls['both_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%2CAKQ%2CIAO%2CLXU%2CPRA&term0=';

searchurls['articles_biography'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AKQ%2CAPE%2CIAO%2CLXU%2CPRA&term0=';
searchurls['both_biography'] = '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%2CAKQ%2CAPE%2CIAO%2CLXU%2CPRA&term0=';

searchurls['reference_business'] = '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_business'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=BID%2CEBU%2CEBW%2CLXU%2CPAC%2CSMO&term0=';
searchurls['both_business'] = '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%2CBID%2CEBU%2CEBW%2CLXU%2CPAC%2CSMO&term0=';

searchurls['articles_college_and_careers'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=AKQ%2CIAO%2CLXU%2CPRA&term0=';
searchurls['both_college_and_careers'] = '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%2CAKQ%2CIAO%2CLXU%2CPRA&term0=';

searchurls['articles_health_care'] = 'http://libproxy.umflint.edu:2048/login?url=http://th5yk4dg6v.cs.serialssolutions.com/resultFrameset.jsp?SS_LibHash=TH5YK4DG6V&searchBy=Database&field0=Title&dbIDList=CUY%2CECT%2CPNJ%2CRWY&term0=';
searchurls['both_health_care'] = '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%2CCUY%2CECT%2CPNJ%2CRWY&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
