
function Form_Validator(theForm) {
if (theForm.p_title.value == "")
  {
    alert("Please type a word or phrase in the search box!");
    theForm.p_title.focus();
    return (false);
  } else {    
    DoSearch(theForm);
    return (false);
    }
}    

function DoSearch(theForm) {
var action
var p_srch
var p_srchtype
var p_title
p_title = theForm.p_title.value
var rExp1 = /&/g
var rExp2 = /\*/g

var sURL

for (i=0;i<theForm.p_srch.length;i++){
	if (theForm.p_srch[i].checked==true)
	p_srch=theForm.p_srch[i].value
	}
for (i=0;i<theForm.p_srchtype.length;i++){
	if (theForm.p_srchtype[i].checked==true)
	p_srchtype=theForm.p_srchtype[i].value
	}	
if ((p_srch == "ct") && (p_srchtype == "cat")) {
	action = "http://innopac.library.unr.edu/search/X?SEARCH=";
	sURL = action+"t:("+p_title+")&m=s&SORT=D"; }	
else if ((p_srch == "sw") && (p_srchtype == "cat")) {
	action = "http://innopac.library.unr.edu/search/l?SEARCH=";
	p_title = p_title.replace(rExp2,'');
	sURL = action+p_title;
}	
else {
	action = "http://knowledgecenter.unr.edu/ejournals/full/ejdbsearch.aspx?";
	p_title=p_title.replace(rExp1,' and ');
	p_title=p_title.replace(rExp2,'');
	sURL = action+"p_srch="+p_srch+"&p_title="+p_title;
	}
  window.location.href = sURL;
  return(false);
}

function changeSearchType(sType) 
{
    var inputArr = new Array();
    inputArr = document.form1.getElementsByTagName("input");
    for (var i = 0; i < inputArr.length; i++) 
    {
        if (inputArr[i].value == sType)
		{
            inputArr[i].checked = "checked";
			document.getElementById("sboxMain").className = "tab " + inputArr[i].className;
		}
        else if (inputArr[i].name == "p_srchtype")
            inputArr[i].checked = "";
    }


}

function resetSearchType(defaultSearch) 
{
    changeSearchType(defaultSearch, null);
	document.getElementById("searchbox_ejournals").p_title.focus();
}