function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function checkForm(){     
    if(document.searchform.term.value == '' && document.searchform.faculty.value == '' && document.searchform.School.value == "0"){
	  if(confirm("Your search criteria will return too many records. It will take long time to process. Are you sure you want to continue?")){
        return true;		
	  }
	  else{
	    return false;
	  }
	}	
}

function selectSchool(formsearch){  
  browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4.8 )) || 
                     ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))
  var strurl = "search.jsp?t=";
  var strspace = "%20";  
  
  if (browser) {
  //if term is not null
    if(document.searchform.term.value!=""){
      strurl = strurl + document.searchform.term.value;
    }
  }
  else{
    if(document.searchform.term.value!=""){	  
	  var temp = "";
	  strurl = strurl + document.searchform.term.value;
	  splitstring = strurl.split(" ");
	  for(var i=0; i<splitstring.length; i++){
	    if(i==0){
		  temp = splitstring[i];
		}
		if(i>0){
		  temp = temp + strspace + splitstring[i];
		}
	  }
	  strurl = temp;
	 //alert(strurl);
	}
  }
  //if termchoice is not null
  if(document.searchform.termchoice.options[document.searchform.termchoice.selectedIndex].value!=""){
    strurl = strurl + "&tc=" + document.searchform.termchoice.options[document.searchform.termchoice.selectedIndex].value;
  }
  //if termbutton is not null
  for(var i=0; i<document.searchform.termbutton.length; i++){
    if(document.searchform.termbutton[i].checked){
      strurl = strurl + "&tb=" + document.searchform.termbutton[i].value;
	  break;
    }
  }
  if (browser) {
  //if name is not null
    if(document.searchform.faculty.value!=""){
      strurl = strurl + "&n=" + document.searchform.faculty.value;
    }
  }
  else{
    if(document.searchform.faculty.value!=""){	  
	  var temp = "";
	  strurl = strurl + "&n=" + document.searchform.faculty.value;
	  splitstring1 = strurl.split(" ");
	  for(var i=0; i<splitstring1.length; i++){
	    if(i==0){
		  temp = splitstring1[i];
		}
		if(i>0){
		  temp = temp + strspace + splitstring1[i];
		}
	  }
	  strurl = temp;
	 //alert(strurl);
	}
  }
  //if namechoice is not null
  if(document.searchform.namechoice.options[document.searchform.namechoice.selectedIndex].value!=""){
    strurl = strurl + "&nc=" + document.searchform.namechoice.options[document.searchform.namechoice.selectedIndex].value;
  }
   //if namebutton is not null
  for(var i=0; i<document.searchform.namebutton.length; i++){
    if(document.searchform.namebutton[i].checked){
      strurl = strurl + "&nb=" + document.searchform.namebutton[i].value;
	  break;
    }
  }
  //if user choose school
  if(document.searchform.School.options[document.searchform.School.selectedIndex].value!=""){
    strurl = strurl + "&schoolid=" + document.searchform.School.options[document.searchform.School.selectedIndex].value;
  } 
  location.href = strurl;  
}


function selectDept(formsearch){
  browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4.8 )) || 
                     ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))
  var strurl = "search.jsp?t=";
  var strspace = "%20";  
  
  if (browser) {
  //if term is not null
    if(document.searchform.term.value!=""){
      strurl = strurl + document.searchform.term.value;
    }
  }
  else{
    if(document.searchform.term.value!=""){	  
	  var temp = "";
	  strurl = strurl + document.searchform.term.value;
	  splitstring = strurl.split(" ");
	  for(var i=0; i<splitstring.length; i++){
	    if(i==0){
		  temp = splitstring[i];
		}
		if(i>0){
		  temp = temp + strspace + splitstring[i];
		}
	  }
	  strurl = temp;	
	}
  }
  //if termchoice is not null
  if(document.searchform.termchoice.options[document.searchform.termchoice.selectedIndex].value!=""){
    strurl = strurl + "&tc=" + document.searchform.termchoice.options[document.searchform.termchoice.selectedIndex].value;
  }
  //if termbutton is not null
  for(var i=0; i<document.searchform.termbutton.length; i++){
    if(document.searchform.termbutton[i].checked){
      strurl = strurl + "&tb=" + document.searchform.termbutton[i].value;
	  break;
    }
  }
  if (browser) {
  //if name is not null
    if(document.searchform.faculty.value!=""){
      strurl = strurl + "&n=" + document.searchform.faculty.value;
    }
  }
  else{
    if(document.searchform.faculty.value!=""){	  
	  var temp = "";
	  strurl = strurl + "&n=" + document.searchform.faculty.value;
	  splitstring1 = strurl.split(" ");
	  for(var i=0; i<splitstring1.length; i++){
	    if(i==0){
		  temp = splitstring1[i];
		}
		if(i>0){
		  temp = temp + strspace + splitstring1[i];
		}
	  }
	  strurl = temp;
	 //alert(strurl);
	}
  }
  //if namechoice is not null
  if(document.searchform.namechoice.options[document.searchform.namechoice.selectedIndex].value!=""){
    strurl = strurl + "&nc=" + document.searchform.namechoice.options[document.searchform.namechoice.selectedIndex].value;
  }
  //if namebutton is not null
  for(var i=0; i<document.searchform.namebutton.length; i++){
    if(document.searchform.namebutton[i].checked){
      strurl = strurl + "&nb=" + document.searchform.namebutton[i].value;
	  break;
    }
  }
  //if user choose school
  if(document.searchform.School.options[document.searchform.School.selectedIndex].value!=""){
    strurl = strurl + "&schoolid=" + document.searchform.School.options[document.searchform.School.selectedIndex].value;
  }
  //if user choose dept
  if(document.searchform.Department.options[document.searchform.Department.selectedIndex].value!=""){
    strurl = strurl + "&deptid=" + document.searchform.Department.options[document.searchform.Department.selectedIndex].value;
  }  
  location.href = strurl;  
}

function toForm() {
  var strurl = "search.jsp";
  location.href = strurl;
  document.searchform.term.focus();
}