// Hong Gyu Han
function FindIn(keyword)  
{
  temp = keyword.split("\"");
  keyword = "";  
  for(var i=0;i<temp.length;i++)
  {
    if (i%2==0)
    { // outside a quote
      keyword += temp[i].replace(/\bin\b/ig, "\"in\"");
    }
    else
    { // inside a quote
      // no process is needed
      keyword += "\"" + temp[i] + "\"";
    }
  }
//	alert(keyword);
	return keyword;
}

function catSearch()
{	
	var soption = document.getElementById('catalogOption').value;
	var keyword = document.getElementById('TowersCatalogtabcontent1').value;
	keyword = FindIn(keyword);
	var towers= "http://towers.missouri.edu/search/"; 
	var mobius= "http://mobius.umsystem.edu/search/Y?search=";

if (soption == 't')
		document.location = towers + "t?SEARCH=" + keyword + "&searchscope=4";
	else if (soption == 'a')
		document.location = towers + "a?SEARCH=" + keyword + "&searchscope=4";
	else if (soption == 'd')
		document.location = towers + "d?SEARCH=" + keyword + "&searchscope=4";
	else if (soption == 'm')
		document.location = towers + "Y?searchtype=m&searcharg=" + keyword + "&searchscope=4";
	else if (soption == 'e')
		document.location = towers + "Y?SEARCH=" + keyword + "&m=2&SORT=D&searchscope=4"; 
	else if (soption == 'i')
		document.location = towers + "Y?SEARCH=" + keyword + "&m=i&SORT=D&searchscope=4"; 
	else if (soption == 'g')
		document.location = towers + "Y?SEARCH=" + keyword + "&m=g&SORT=D&searchscope=4"; 
	else if (soption == 'h')
		document.location = towers + "Y?SEARCH=" + keyword + "&m=g&SORT=D&searchscope=4&b=w5b";		
	else if (soption == 'mo')
		document.location = mobius + keyword;
	else
		document.location = towers + "Y?SEARCH=" + keyword + "&m=&SORT=D&searchscope=4";
}

var ipchecking = "http://www.nwmissouri.edu/library/ipchecking.asp?";

function articleSearch(){
	var db = document.getElementById('dbOption').value;
	var keyword = document.getElementById("TowersCatalogtabcontent2").value;
	var keyLen =  keyword.length;

	if (db == 'EBSCO')
		ebscoHostSearchGo(keyword);
	else if (db == 'WilsonWeb')
		WilsonWebSearch(keyword);
}

// ebsco search
function ebscoHostSearchGo(keyword) {
  var ebscohosturl="http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&db=a9h&db=ah1&db=buh&db=c9h&db=eoah&db=ehh&db=eih&db=eric&db=8gh&db=hia&db=lxh&db=kah&db=mzh&db=pdh&db=psyh&db=s3h&bquery=";
	keyword = FindIn(keyword);
	document.location = ipchecking + ebscohosturl + keyword;
}

// WilsonWeb
function WilsonWebSearch(keyword)  {
	var wilsonweburl = "http://vnweb.hwwilsonweb.com/hww/jumpstart.jhtml?prod=BAIN,ERIC,RGR,EDUFT&query=";
	keyword = FindIn(keyword);
	document.location = ipchecking + wilsonweburl + keyword;
}

function ebookSearch(){
	var eb = document.getElementById('ebookOption').value;
	var keyword = document.getElementById("TowersCatalogtabcontent4").value;
	
	if (eb == 'ebrary')
		ebrarySearch(keyword);
	else if (eb == 'credo')
		credoSearch(keyword);
	else if (eb == 'galeVR')
		galeVRSearch(keyword);
//	else if (eb == 'safari')
//		safariSearch(keyword);
}

function ebrarySearch(keyword){
	var ebrary = "http://site.ebrary.com/lib/nwmsu/Top?layout=search&nosr=1&frm=smp.x&p00=";
	document.location = ipchecking + ebrary  + keyword;
}

function credoSearch(keyword){
	var credo = "http://www.credoreference.com/search.do?query=" + keyword + "&subject=all&view=facet";
	document.location = ipchecking + credo; 
}

function galeVRSearch(keyword){
	var galeVR = "http://go.galegroup.com/ps/i.do?action=interpret&ty=bs&v=2.1&u=nwmosu_owens&it=search&s=RELEVANCE&p=GVRL&searchType=BasicSearchForm&st=T003&qt=KE~" + keyword + "&sw=w&authCount=1";
	document.location = ipchecking + galeVR; 
}

/*function safariSearch(keyword){
	var safari = "http://proquestcombo.safaribooksonline.com/search?" + "searchSelect=&" + keyword + "&searchmode=simple&page=0&searchview=books&sort=rank&order=desc&_searchsurvey=1&__nestedsearch";
	
	// searchmode=simple&page=0&searchview=books&sort=rank&order=desc&_searchsurvey=1&__nestedsearch
	alert(safari);
	document.location = ipchecking + safari; 
}
*/

// JavaScript Document



